83 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
84 MsgStream log(
msgSvc,
"ResiAlign");
85 log << MSG::INFO <<
"ResiAlign::initialize()" << endreq;
88 m_mdcGeomSvc = mdcGeomSvc;
89 m_mdcFunSvc = mdcFunSvc;
90 m_mdcUtilitySvc = mdcUtilitySvc;
93 for(
int lay=0; lay<43; lay++){
95 m_zrange[lay][1] = 2.0 * fabs(zeast) / (double)m_ndiv;
96 m_zrange[lay][0] = -1.0 * m_zrange[lay][1];
101 for(
int wir=0; wir<
WIRENMAX; wir++){
105 m_xw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().x();
106 m_yw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().y();
107 m_zw[wir] = m_mdcGeomSvc->
Wire(wir)->
Forward().z();
113 INTupleSvc* ntupleSvc;
114 Gaudi::svcLocator() -> service(
"NTupleSvc",
ntupleSvc);
115 for(iEP=0; iEP<=
NEP; iEP++){
116 if(iEP <
NEP)
sprintf(hname,
"FILE137/align%02d", iEP);
117 else sprintf(hname,
"FILE137/alignAll");
120 if( nt ) m_tuple[iEP] = nt;
122 m_tuple[iEP] =
ntupleSvc->book(hname, CLID_ColumnWiseTuple,
"align");
124 m_tuple[iEP]->addItem (
"run", m_iRun[iEP]);
125 m_tuple[iEP]->addItem (
"evt", m_iEvt[iEP]);
126 m_tuple[iEP]->addItem (
"resi", m_resi[iEP]);
127 m_tuple[iEP]->addItem (
"p", m_p[iEP]);
128 m_tuple[iEP]->addItem (
"pt", m_pt[iEP]);
129 m_tuple[iEP]->addItem (
"phi", m_phi[iEP]);
130 m_tuple[iEP]->addItem (
"lay", m_lay[iEP]);
131 m_tuple[iEP]->addItem (
"lr", m_lr[iEP]);
132 m_tuple[iEP]->addItem (
"cel", m_cel[iEP]);
135 log << MSG::FATAL <<
"Cannot book N-tuple:"
136 << long(m_tuple[iEP]) << endmsg;
141 m_hnTrk =
new TH1F(
"HNtrack",
"", 10, -0.5, 9.5);
142 m_hlist->Add(m_hnTrk);
144 m_hnHit =
new TH1F(
"HNhit",
"", 100, -0.5, 99.5);
145 m_hlist->Add(m_hnHit);
147 m_hlayHitmap =
new TH1F(
"Hitmap",
"", 43, -0.5, 42.5);
148 m_hlist->Add(m_hlayHitmap);
150 m_hresAll =
new TH1F(
"HResAllInc",
"", 200, -1.0, 1.0);
151 m_hlist->Add(m_hresAll);
153 m_hresInn =
new TH1F(
"HResInnInc",
"", 200, -1.0, 1.0);
154 m_hlist->Add(m_hresInn);
156 m_hresStp =
new TH1F(
"HResStpInc",
"", 200, -1.0, 1.0);
157 m_hlist->Add(m_hresStp);
159 m_hresOut =
new TH1F(
"HResOutInc",
"", 200, -1.0, 1.0);
160 m_hlist->Add(m_hresOut);
164 sprintf(hname,
"Res_Layer%02d", lay);
165 m_hresLay[lay] =
new TH1F(hname,
"", 200, -1.0, 1.0);
166 m_hlist->Add(m_hresLay[lay]);
168 for(
int i=0; i<4; i++){
169 if(0==i)
sprintf(hname,
"Resi_Lay%02d_Up_L", lay);
170 else if(1==i)
sprintf(hname,
"Resi_Lay%02d_Up_R", lay);
171 else if(2==i)
sprintf(hname,
"Resi_Lay%02d_Dw_L", lay);
172 else sprintf(hname,
"Resi_Lay%02d_Dw_R", lay);
173 m_hresLay_LR[lay][i] =
new TH1F(hname,
"", 200, -1.0, 1.0);
174 m_hlist->Add(m_hresLay_LR[lay][i]);
178 for(iEP=0; iEP<
NEP; iEP++){
179 m_gr[iEP] =
new TGraph();
180 sprintf(hname,
"grResi%02d", iEP);
181 m_gr[iEP]->SetName(hname);
182 m_hlist->Add(m_gr[iEP]);
184 m_fevt.open(
"evt.txt");
189 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
190 MsgStream log(
msgSvc,
"ResiAlign");
191 log << MSG::DEBUG <<
"ResiAlign::fillHist()" << endreq;
193 bool esCutFg =
event->getEsCutFlag();
235 IDataProviderSvc* eventSvc =
NULL;
236 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
237 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
239 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
241 return( StatusCode::FAILURE);
243 int iEvt = eventHeader->eventNumber();
244 int iRun = eventHeader->runNumber();
246 int nTrk =
event -> getNTrk();
248 m_fevt << setw(10) << iRun << setw(10) << iEvt << setw(10) << nTrk << endl;
254 for(i=0; i<nTrk; i++){
255 rectrk =
event->getRecTrk(i);
261 dr = rectrk -> getDr();
262 if(fabs(dr) > m_param.
drCut){ m_ncut4++;
continue; }
264 phi0 = rectrk -> getPhi0();
265 kappa = rectrk -> getKappa();
268 dz = rectrk -> getDz();
269 if(fabs(dz) > m_param.
dzCut){ m_ncut5++;
continue; }
272 fgHitLay[lay] =
false;
275 m_hnHit->Fill(
nhits);
276 for(k=0; k<
nhits; k++){
277 rechit = rectrk -> getRecHit(k);
278 lay = rechit -> getLayid();
279 fgHitLay[lay] =
true;
284 if(fgHitLay[lay]) nhitlay++;
287 if(nhitlay < m_param.
nHitLayCut){ m_ncut6++;
continue; }
289 tanl = rectrk -> getTanLamda();
290 chisq = rectrk -> getChisq();
291 p = rectrk -> getP();
292 pt = rectrk -> getPt();
294 if((fabs(pt)<m_param.
ptCut[0]) || (fabs(pt)>m_param.
ptCut[1])){ m_ncut7++;
continue;}
296 HepVector helix = rectrk->
getHelix();
297 for(k=0; k<
nhits; k++){
301 lr = rechit->
getLR();
302 doca = rechit -> getDocaInc();
305 stat = rechit -> getStat();
306 if((1 == m_param.
hitStatCut) && (1 != stat)){ m_ncut8++;
continue; }
315 if( (1==std::isnan(resi)) || (fabs(resi) > m_resiCut) ||
316 (fabs(doca) > m_docaMax[lay]) || (fabs(doca) < m_docaMin[lay]) ){
323 if( ! fgHitLay[1] ){ m_ncut10++;
continue; }
324 }
else if(42 == lay){
325 if( ! fgHitLay[41] ){ m_ncut11++;
continue; }
327 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ){ m_ncut12++;
continue; }
330 ((!fgHitLay[lay-1]) || (!fgHitLay[lay+1])) ){
336 m_hlayHitmap->Fill(lay);
339 if((zhit < m_zrange[lay][0]) || (zhit > m_zrange[lay][1])){
340 wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
341 xx = (zhit - m_zw[wir]) * (m_xe[wir] - m_xw[wir]) /
342 (m_ze[wir] - m_zw[wir]) + m_xw[wir];
343 yy = (zhit - m_zw[wir]) * (m_ye[wir] - m_yw[wir]) /
344 (m_ze[wir] - m_zw[wir]) + m_yw[wir];
345 rr = sqrt( (xx * xx) + (yy * yy) );
346 dphi = fabs(doca) / m_radii[lay];
348 if( yy >= 0 ) wphi = acos(xx / rr);
349 else wphi =
PI2 - acos(xx / rr);
350 if(1 == lr) hitPhi = wphi + dphi;
351 else hitPhi = wphi - dphi;
352 if(hitPhi < 0) hitPhi +=
PI2;
353 else if(hitPhi >
PI2) hitPhi -=
PI2;
355 if(zhit < m_zrange[lay][0]) iEnd = 0;
368 m_tuple[iEP]->write();
377 m_tuple[
NEP]->write();
379 m_hresAll->Fill(resi);
380 if(lay < 8) m_hresInn->Fill(resi);
381 else if(lay < 20) m_hresStp->Fill(resi);
382 else m_hresOut->Fill(resi);
383 m_hresLay[lay]->Fill(resi);
385 if(hitPhi<3.14) m_hresLay_LR[lay][0]->Fill(resi);
386 else m_hresLay_LR[lay][2]->Fill(resi);
388 if(hitPhi<3.14) m_hresLay_LR[lay][1]->Fill(resi);
389 else m_hresLay_LR[lay][3]->Fill(resi);
392 m_gr[iEP]->SetPoint(m_npoint[iEP], hitPhi, resi);
403 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
404 MsgStream log(
msgSvc,
"ResiAlign");
405 log << MSG::INFO <<
"ResiAlign::updateConst()" << endreq;
414 double rLayer[] = { 120.225, 205.0, 237.55, 270.175,
415 302.625, 334.775, 366.65, 500.0,
416 120.225, 205.0, 237.55, 270.175,
417 302.625, 334.775, 366.65, 500.0 };
419 TCanvas c1(
"c1",
"c1", 10, 10, 700, 500);
421 TF1* fResPhi =
new TF1(
"fResPhi",
funResi, 0,
PI2, 3);
422 fResPhi->SetParameter(0, 0.0);
423 fResPhi->SetParameter(1, 0.0);
424 fResPhi->SetParameter(2, 0.0);
426 for(iEP=0; iEP<
NEP; iEP++){
427 if((m_gr[iEP]->GetN()) > 500){
428 m_gr[iEP]->Fit(
"fResPhi",
"V");
429 par[0] = fResPhi->GetParameter(0);
430 par[1] = fResPhi->GetParameter(1);
431 par[2] = fResPhi->GetParameter(2);
433 err[0] = fResPhi->GetParError(0);
434 err[1] = fResPhi->GetParError(1);
435 err[2] = fResPhi->GetParError(2);
439 rz = par[0] / rLayer[iEP];
442 if (7==iEP || 15==iEP) {
456 alignPar->
setErrRz(iEP, err[0]/rLayer[iEP]);
460 cout <<
"TrackCut: cut1: " << m_ncut1 <<
", cut2: " << m_ncut2 <<
", cut3: " << m_ncut3
461 <<
", cut4: " << m_ncut4 <<
", cut5: " << m_ncut5 <<
", cut6: " << m_ncut6
462 <<
", cut7: " << m_ncut7 << endl;
463 cout <<
"HitCut: cut8: " << m_ncut8 <<
", cut9: " << m_ncut9 <<
", cut10: " << m_ncut10
464 <<
", cut11: " << m_ncut11 <<
", cut12: " << m_ncut12 <<
", cut13: " << m_ncut13 << endl;