#include <MilleAlign.h>
Inheritance diagram for MilleAlign:
Public Member Functions | |
void | clear () |
void | clear () |
bool | fillHist (MdcAliEvent *event) |
bool | fillHist (MdcAliEvent *event) |
void | initialize (TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc) |
void | initialize (TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc) |
MilleAlign () | |
MilleAlign () | |
void | setParam (MdcAliParams ¶m) |
void | setParam (MdcAliParams ¶m) |
void | updateConst (MdcAlignPar *alignPar) |
void | updateConst (MdcAlignPar *alignPar) |
~MilleAlign () | |
~MilleAlign () | |
Public Attributes | |
std::string | fixMomLab |
Private Member Functions | |
int | getAlignParId (int lay, int iparHit) |
int | getAlignParId (int lay, int iparHit) |
bool | getDeriGlo (int iparHit, int iparGB, int lay, int cel, HepVector helix, HepSymMatrix &helixErr, double wpos[], double &deri) |
bool | getDeriGlo (int iparHit, int iparGB, int lay, int cel, HepVector helix, HepSymMatrix &helixErr, double wpos[], double &deri) |
bool | getDeriLoc (int ipar, int lay, int cel, HepVector helix, HepSymMatrix &helixErr, double &deri) |
bool | getDeriLoc (int ipar, int lay, int cel, HepVector helix, HepSymMatrix &helixErr, double &deri) |
double | moment (double phi0, double tanl) |
double | moment (double phi0, double tanl) |
Private Attributes | |
std::vector< double > | m_derGB |
std::vector< double > | m_derGB |
std::vector< double > | m_derLC |
std::vector< double > | m_derLC |
std::vector< double > | m_derNonLin |
std::vector< double > | m_derNonLin |
double | m_docaCut [LAYERNMAX][2] |
bool | m_dofs [NDOFALIGN] |
double | m_dxini [NEP] |
double | m_dyini [NEP] |
std::vector< double > | m_error |
std::vector< double > | m_error |
TH1F * | m_hddoca |
TH1F * | m_hddoca |
TH1F * | m_hddocaLay [LAYERNMAX] |
TH1F * | m_hddocaLay [LAYERNMAX] |
TObjArray * | m_hlist |
TObjArray * | m_hlist |
TH1F * | m_hresAll |
TH1F * | m_hresAll |
TH1F * | m_hresAllRec |
TH1F * | m_hresAllRec |
TH1F * | m_hresInn |
TH1F * | m_hresInn |
TH1F * | m_hresLay [LAYERNMAX] |
TH1F * | m_hresLay [LAYERNMAX] |
TH1F * | m_hresLayRec [LAYERNMAX] |
TH1F * | m_hresLayRec [LAYERNMAX] |
TH1F * | m_hresOut |
TH1F * | m_hresOut |
TH1F * | m_hresStp |
TH1F * | m_hresStp |
MdcCheckUtil * | m_mdcCheckUtil |
MdcCheckUtil * | m_mdcCheckUtil |
IMdcCalibFunSvc * | m_mdcFunSvc |
IMdcCalibFunSvc * | m_mdcFunSvc |
IMdcGeomSvc * | m_mdcGeomSvc |
IMdcGeomSvc * | m_mdcGeomSvc |
int | m_nglo |
int | m_nGloHit |
int | m_nloc |
int | m_npar |
double | m_p [20][15] |
std::vector< double > | m_par |
std::vector< double > | m_par |
MdcAliParams | m_param |
Millepede * | m_pMilleAlign |
Millepede * | m_pMilleAlign |
std::vector< double > | m_pull |
std::vector< double > | m_pull |
double | m_resiCut [LAYERNMAX] |
double | m_rzini [NEP] |
double | m_sigm [NDOFALIGN] |
|
00028 { 00029 for(int lay=0; lay<LAYERNMAX; lay++){ 00030 m_resiCut[lay] = 1.5; 00031 if(lay<8){ 00032 m_docaCut[lay][0] = 0.5; 00033 m_docaCut[lay][1] = 5.5; 00034 } else{ 00035 m_docaCut[lay][0] = 0.5; 00036 m_docaCut[lay][1] = 7.5; 00037 } 00038 } 00039 }
|
|
00041 { 00042 }
|
|
|
|
|
|
Implements MdcAlign. |
|
Implements MdcAlign. 00044 { 00045 delete m_hresAll; 00046 delete m_hresInn; 00047 delete m_hresStp; 00048 delete m_hresOut; 00049 for(int lay=0; lay<LAYERNMAX; lay++) delete m_hresLay[lay]; 00050 delete m_hresAllRec; 00051 for(int lay=0; lay<LAYERNMAX; lay++) delete m_hresLayRec[lay]; 00052 delete m_hddoca; 00053 delete m_pMilleAlign; 00054 }
|
|
Implements MdcAlign. |
|
Implements MdcAlign. 00190 { 00191 IMessageSvc* msgSvc; 00192 Gaudi::svcLocator() -> service("MessageSvc", msgSvc); 00193 MsgStream log(msgSvc, "MilleAlign"); 00194 log << MSG::DEBUG << "MilleAlign::fillTree()" << endreq; 00195 00196 int recFlag; 00197 int itrk; 00198 int ihit; 00199 int fgGetDoca; 00200 int lr; 00201 int lay; 00202 int cel; 00203 double doca; 00204 double dmeas; 00205 double zhit; 00206 double resi; 00207 double resiRec; 00208 double deri; 00209 double hitSigm; 00210 double hitpos[3]; 00211 double wpos[7]; // wpos[6] is wire tension 00212 const MdcGeoWire* pWire; 00213 00214 double trkpar[NTRKPAR]; 00215 double trkparms[NTRKPARALL]; // track parameters and errors 00216 00217 // numerical derivative 00218 int ipar; 00219 int iparGB; 00220 00221 MdcAliRecTrk* rectrk; 00222 MdcAliRecHit* rechit; 00223 00224 int ntrk = event -> getNTrk(); 00225 if( (ntrk<m_param.nTrkCut[0]) || (ntrk>m_param.nTrkCut[1])) return false; 00226 00227 m_mdcCheckUtil = new MdcCheckUtil(); 00228 for(itrk=0; itrk<ntrk; itrk++){ 00229 rectrk = event->getRecTrk(itrk); 00230 recFlag = rectrk->getStat(); 00231 // if(-1 != recFlag){ 00232 // delete m_mdcCheckUtil; 00233 // return false; 00234 // } 00235 00236 trkpar[0] = rectrk -> getDr(); 00237 trkpar[1] = rectrk -> getPhi0(); 00238 trkpar[2] = rectrk -> getKappa(); 00239 trkpar[3] = rectrk -> getDz(); 00240 trkpar[4] = rectrk -> getTanLamda(); 00241 00242 int nHit = rectrk -> getNHits(); 00243 if(nHit < m_param.nHitCut) continue; 00244 if(fabs(trkpar[0]) > m_param.drCut) continue; 00245 if(fabs(trkpar[3]) > m_param.dzCut) continue; 00246 00247 HepVector rechelix = rectrk->getHelix(); 00248 HepVector helix = rectrk->getHelix(); 00249 HepSymMatrix helixErr = rectrk->getHelixErr(); 00250 00251 int nHitUse = 0; 00252 for(ihit=0; ihit<nHit; ihit++){ 00253 rechit = rectrk -> getRecHit(ihit); 00254 lr = rechit->getLR(); 00255 lay = rechit -> getLayid(); 00256 cel = rechit -> getCellid(); 00257 pWire = m_mdcGeomSvc -> Wire(lay, cel); 00258 dmeas = rechit -> getDmeas(); 00259 zhit = rechit -> getZhit(); 00260 hitSigm = rechit -> getErrDmeas(); 00261 00262 wpos[0] = pWire -> Backward().x(); // east end 00263 wpos[1] = pWire -> Backward().y(); 00264 wpos[2] = pWire -> Backward().z(); 00265 wpos[3] = pWire -> Forward().x(); // west end 00266 wpos[4] = pWire -> Forward().y(); 00267 wpos[5] = pWire -> Forward().z(); 00268 wpos[6] = pWire -> Tension(); 00269 00270 double docaRec = rechit->getDocaInc(); 00271 double doca = (m_mdcCheckUtil->doca(lay, cel, helix, helixErr))*10.0; 00272 00273 resi = -1.0*dmeas - doca; 00274 if ((fabs(doca) < m_docaCut[lay][0]) || (fabs(doca) > m_docaCut[lay][1]) || 00275 (fabs(resi) > m_resiCut[lay])) continue; 00276 nHitUse++; 00277 00278 resiRec = rechit -> getResiIncLR(); 00279 00280 double dd = fabs(doca) - fabs(rechit->getDocaInc()); 00281 m_hddoca -> Fill(dd); 00282 m_hddocaLay[lay] -> Fill(dd); 00283 00284 // fill histograms 00285 m_hresAll->Fill(resi); 00286 if(lay < 8) m_hresInn->Fill(resi); 00287 else if(lay < 20) m_hresStp->Fill(resi); 00288 else m_hresOut->Fill(resi); 00289 m_hresLay[lay]->Fill(resi); 00290 00291 m_hresAllRec->Fill(resiRec); 00292 m_hresLayRec[lay]->Fill(resiRec); 00293 00294 // reset the derivatives arrays 00295 m_pMilleAlign -> ZerLoc(&m_derGB[0], &m_derLC[0], &m_derNonLin[0]); 00296 00297 // derivatives of local parameters 00298 for(ipar=0; ipar<m_nloc; ipar++){ 00299 if( ! getDeriLoc(ipar, lay, cel ,rechelix, helixErr, deri) ){ 00300 cout << "getDeriLoc == false!" << setw(12) << itrk << setw(12) << ipar << endl; 00301 delete m_mdcCheckUtil; 00302 return false; 00303 } 00304 m_derLC[ipar] = deri; 00305 } 00306 00307 // derivatives of global parameters 00308 // ipar 0 - 5: dx_east, dx_west, dy_east, dy_west, rz_east, rz_west 00309 for(ipar=0; ipar<m_nGloHit; ipar++){ 00310 iparGB = getAlignParId(lay, ipar); 00311 if( ! getDeriGlo(ipar, iparGB, lay, cel, helix, helixErr, wpos, deri) ) 00312 { 00313 cout << "getDeriGlo == false!" << setw(12) << itrk << setw(12) << ipar << endl; 00314 delete m_mdcCheckUtil; 00315 return false; 00316 } 00317 m_derGB[iparGB] = deri; 00318 } 00319 m_pMilleAlign -> EquLoc(&m_derGB[0], &m_derLC[0], &m_derNonLin[0], resi, hitSigm); 00320 } // loop of nhit 00321 00322 // local fit in Millepede 00323 bool sc = m_pMilleAlign -> FitLoc(m_pMilleAlign->GetTrackNumber(), trkparms, 0); 00324 if(sc) m_pMilleAlign -> SetTrackNumber( m_pMilleAlign->GetTrackNumber()+1 ); 00325 } // track loop 00326 delete m_mdcCheckUtil; 00327 return true; 00328 }
|
|
|
|
00368 { 00369 int ip; 00370 if(lay < 8) ip = 0; 00371 else if(lay < 10) ip = 1; 00372 else if(lay < 12) ip = 2; 00373 else if(lay < 14) ip = 3; 00374 else if(lay < 16) ip = 4; 00375 else if(lay < 18) ip = 5; 00376 else if(lay < 20) ip = 6; 00377 else ip = 7; 00378 00379 // iparHit 0 - 5: dx_east, dx_west, dy_east, dy_west, rz_east, rz_west 00380 int ipar = iparHit * 8 + ip; 00381 return ipar; 00382 }
|
|
|
|
00418 { 00419 int i; 00420 double doca; 00421 double xxGB[gNsamGB]; 00422 double yyGB[gNsamGB]; 00423 double dAlignPar; 00424 double dAlignParini = 0.0; 00425 double startpar = dAlignParini - 0.5*gStepGB[iparGB]*(double)gNsamGB; 00426 double wposSam[7]; 00427 for(i=0; i<7; i++) wposSam[i] = wpos[i]; // 0-2:east; 3-5:west 00428 00429 for(i=0; i<gNsamGB; i++){ 00430 dAlignPar = startpar + (double)i * gStepGB[iparGB]; 00431 xxGB[i] = dAlignPar; 00432 if(0 == iparHit){ // dx_east 00433 wposSam[0] = wpos[0] + dAlignPar; 00434 } else if(1 == iparHit){ // dx_west 00435 wposSam[3] = wpos[3] + dAlignPar; 00436 } else if(2 == iparHit){ // dy_east 00437 wposSam[1] = wpos[1] + dAlignPar; 00438 } else if(3 == iparHit){ // dy_west 00439 wposSam[4] = wpos[4] + dAlignPar; 00440 } else if(4 == iparHit){ // rz_east 00441 wposSam[0] = wpos[0] - (wpos[1] * dAlignPar * 0.001); 00442 wposSam[1] = wpos[1] + (wpos[0] * dAlignPar * 0.001); 00443 } else if(5 == iparHit){ // rz_west 00444 wposSam[3] = wpos[3] - (wpos[4] * dAlignPar * 0.001); 00445 wposSam[4] = wpos[4] + (wpos[3] * dAlignPar * 0.001); 00446 } 00447 00448 HepPoint3D eastP(wposSam[0]/10., wposSam[1]/10., wposSam[2]/10.); 00449 HepPoint3D westP(wposSam[3]/10., wposSam[4]/10., wposSam[5]/10.); 00450 doca = (m_mdcCheckUtil->doca(lay, cel, eastP, westP, helix, helixErr))*10.0; // cm->mm 00451 00452 if(NULL == doca) return false; 00453 00454 yyGB[i] = doca; 00455 } 00456 00457 TSpline3* pSpline3 = new TSpline3("deri", xxGB, yyGB, gNsamGB); 00458 deri = pSpline3 -> Derivative(dAlignParini); 00459 delete pSpline3; 00460 return true; 00461 }
|
|
|
|
00384 { 00385 int i; 00386 double doca; 00387 HepVector sampar(NTRKPAR, 0); 00388 double xxLC[gNsamLC]; 00389 double yyLC[gNsamLC]; 00390 00391 for(i=0; i<m_nloc; i++) sampar[i] = rechelix[i]; 00392 double startpar = rechelix[ipar] - 0.5*gStepLC[ipar]*(double)gNsamLC; 00393 00394 for(i=0; i<gNsamLC; i++){ 00395 sampar[ipar] = startpar + (double)i * gStepLC[ipar]; 00396 xxLC[i] = sampar[ipar]; 00397 if(0==ipar || 3==ipar) xxLC[i] *= 10.; // cm -> mm 00398 00399 HepVector helix = sampar; 00400 m_mdcCheckUtil->setPassCellRequired(false); 00401 doca = (m_mdcCheckUtil->doca(lay, cel, helix, helixErr))*10.0; 00402 00403 if(NULL == doca){ 00404 // cout << "in getDeriLoc, doca = " << doca << endl; 00405 return false; 00406 } 00407 yyLC[i] = doca; 00408 } 00409 00410 if (0==ipar || 3==ipar) rechelix[ipar] *= 10.; // cm -> mm 00411 TSpline3* pSpline3 = new TSpline3("deri", xxLC, yyLC, gNsamLC); 00412 deri = pSpline3->Derivative(rechelix[ipar]); 00413 delete pSpline3; 00414 return true; 00415 }
|
|
Implements MdcAlign. |
|
Implements MdcAlign. 00057 { 00058 IMessageSvc* msgSvc; 00059 Gaudi::svcLocator() -> service("MessageSvc", msgSvc); 00060 MsgStream log(msgSvc, "MilleAlign"); 00061 log << MSG::INFO << "MilleAlign::initialize()" << endreq; 00062 00063 m_hlist = hlist; 00064 m_mdcGeomSvc = mdcGeomSvc; 00065 m_mdcFunSvc = mdcFunSvc; 00066 00067 // initialize hitograms 00068 m_hresAll = new TH1F("HResAllInc", "", 200, -1.0, 1.0); 00069 m_hlist->Add(m_hresAll); 00070 00071 m_hresInn = new TH1F("HResInnInc", "", 200, -1.0, 1.0); 00072 m_hlist->Add(m_hresInn); 00073 00074 m_hresStp = new TH1F("HResStpInc", "", 200, -1.0, 1.0); 00075 m_hlist->Add(m_hresStp); 00076 00077 m_hresOut = new TH1F("HResOutInc", "", 200, -1.0, 1.0); 00078 m_hlist->Add(m_hresOut); 00079 00080 char hname[200]; 00081 for(int lay=0; lay<LAYERNMAX; lay++){ 00082 sprintf(hname, "Res_Layer%02d", lay); 00083 m_hresLay[lay] = new TH1F(hname, "", 200, -1.0, 1.0); 00084 m_hlist->Add(m_hresLay[lay]); 00085 } 00086 00087 m_hresAllRec = new TH1F("HResAllRecInc", "", 200, -1.0, 1.0); 00088 m_hlist->Add(m_hresAllRec); 00089 for(int lay=0; lay<LAYERNMAX; lay++){ 00090 sprintf(hname, "Res_LayerRec%02d", lay); 00091 m_hresLayRec[lay] = new TH1F(hname, "", 200, -1.0, 1.0); 00092 m_hlist->Add(m_hresLayRec[lay]); 00093 } 00094 00095 // for debug 00096 m_hddoca = new TH1F("delt_doca", "", 200, -1.0, 1.0); 00097 m_hlist->Add(m_hddoca); 00098 00099 for(int lay=0; lay<LAYERNMAX; lay++){ 00100 sprintf(hname, "delt_docaLay%02d", lay); 00101 m_hddocaLay[lay] = new TH1F(hname, "", 200, -1.0, 1.0); 00102 m_hlist->Add(m_hddocaLay[lay]); 00103 } 00104 00105 // initialize millepede 00106 m_nglo = NEP; 00107 m_nloc = NTRKPAR; 00108 m_nGloHit = 2 * NDOFALIGN; 00109 m_npar = NDOFALIGN * m_nglo; 00110 00111 int i; 00112 for(i=0; i<NDOFALIGN; i++){ 00113 m_dofs[i] = g_dofs[i]; 00114 m_sigm[i] = g_Sigm[i]; 00115 } 00116 00117 m_pMilleAlign = new Millepede(); 00118 m_pMilleAlign -> InitMille(&m_dofs[0], &m_sigm[0], m_nglo, m_nloc, 00119 g_start_chi_cut, 3, g_res_cut, g_res_cut_init); 00120 00121 m_derGB.resize(m_npar); 00122 m_derNonLin.resize(m_npar); 00123 m_par.resize(m_npar); 00124 m_error.resize(m_npar); 00125 m_pull.resize(m_npar); 00126 00127 m_derLC.resize(m_nloc); 00128 00129 // contraints 00130 std::vector<double> constTX; 00131 std::vector<double> constTY; 00132 std::vector<double> constRZ; 00133 00134 std::vector<double> constTXE; 00135 std::vector<double> constTXW; 00136 std::vector<double> constTYE; 00137 std::vector<double> constTYW; 00138 std::vector<double> constRZE; 00139 std::vector<double> constRZW; 00140 00141 constTX.resize(m_npar); 00142 constTY.resize(m_npar); 00143 constRZ.resize(m_npar); 00144 00145 constTXE.resize(m_npar); 00146 constTXW.resize(m_npar); 00147 constTYE.resize(m_npar); 00148 constTYW.resize(m_npar); 00149 constRZE.resize(m_npar); 00150 constRZW.resize(m_npar); 00151 00152 for(i=0; i<m_npar; i++){ 00153 constTX[i] = 0.0; 00154 constTY[i] = 0.0; 00155 constRZ[i] = 0.0; 00156 00157 constTXE[i] = 0.0; 00158 constTXW[i] = 0.0; 00159 constTYE[i] = 0.0; 00160 constTYW[i] = 0.0; 00161 constRZE[i] = 0.0; 00162 constRZW[i] = 0.0; 00163 } 00164 constTX[7] = 1.0; 00165 constTX[15] = 1.0; 00166 constTY[23] = 1.0; 00167 constTY[31] = 1.0; 00168 constRZ[39] = 1.0; 00169 constRZ[47] = 1.0; 00170 00171 constTXE[7] = 1.0; 00172 constTXW[15] = 1.0; 00173 constTYE[23] = 1.0; 00174 constTYW[31] = 1.0; 00175 constRZE[39] = 1.0; 00176 constRZW[47] = 1.0; 00177 00178 //m_pMilleAlign -> ConstF(&constTX[0], 0.0); 00179 //m_pMilleAlign -> ConstF(&constTY[0], 0.0); 00180 // m_pMilleAlign -> ConstF(&constRZ[0], 0.0); 00181 00182 m_pMilleAlign -> ConstF(&constTXE[0], 0.0); 00183 m_pMilleAlign -> ConstF(&constTXW[0], 0.0); 00184 m_pMilleAlign -> ConstF(&constTYE[0], 0.0); 00185 m_pMilleAlign -> ConstF(&constTYW[0], 0.0); 00186 m_pMilleAlign -> ConstF(&constRZE[0], 0.0); 00187 m_pMilleAlign -> ConstF(&constRZW[0], 0.0); 00188 }
|
|
|
|
|
|
Implements MdcAlign. |
|
Implements MdcAlign. 00082 { 00083 MdcAlign::setParam(param); 00084 m_param = param; 00085 }
|
|
Implements MdcAlign. |
|
Implements MdcAlign. 00331 { 00332 IMessageSvc* msgSvc; 00333 Gaudi::svcLocator() -> service("MessageSvc", msgSvc); 00334 MsgStream log(msgSvc, "MilleAlign"); 00335 log << MSG::INFO << "MilleAlign::updateConst()" << endreq; 00336 00337 m_pMilleAlign -> MakeGlobalFit(&m_par[0], &m_error[0], &m_pull[0]); 00338 00339 int iEP; 00340 int ipar; 00341 double val; 00342 double err; 00343 for(int i=0; i<NDOFALIGN; i++){ 00344 for(iEP=0; iEP<NEP; iEP++){ 00345 ipar = i * NEP + iEP; 00346 if(m_dofs[i]){ 00347 val = m_par[ipar]; 00348 err = m_error[ipar]; 00349 } else{ 00350 val = 0.0; 00351 err = 0.0; 00352 } 00353 00354 if(0 == i){ 00355 alignPar->setDelDx(iEP, val); 00356 alignPar->setErrDx(iEP, err); 00357 } else if(1 == i){ 00358 alignPar->setDelDy(iEP, val); 00359 alignPar->setErrDy(iEP, err); 00360 } else if(2 == i){ 00361 alignPar->setDelRz(iEP, val/1000.0); // mrad -> rad 00362 alignPar->setErrRz(iEP, err/1000.0); // mrad -> rad 00363 } 00364 } 00365 } 00366 }
|
|
Reimplemented from MdcAlign. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reimplemented from MdcAlign. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|