31 MsgStream log(
msgSvc(), name() );
33 log << MSG::INFO <<
"in initialize()" << endmsg;
41 if ( service(
"THistSvc", m_thsvc ).isFailure() )
43 log << MSG::ERROR <<
"Couldn't get THistSvc" << endmsg;
44 return StatusCode::FAILURE;
47 NTuplePtr nt_bb(
ntupleSvc(),
"DQAFILE/DEDX" );
48 if ( nt_bb ) m_bb_tuple = nt_bb;
52 ntupleSvc()->book(
"DQAFILE/DEDX/Bhabha", CLID_ColumnWiseTuple,
"Dedx ntuple" );
55 status = m_bb_tuple->addItem(
"runNo", m_bb_runNo );
56 status = m_bb_tuple->addItem(
"event", m_bb_event );
57 status = m_bb_tuple->addItem(
"p", m_bb_p );
58 status = m_bb_tuple->addItem(
"costh", m_bb_costh );
59 status = m_bb_tuple->addItem(
"t0", m_bb_t0 );
60 status = m_bb_tuple->addItem(
"chiE", m_bb_chiE );
61 status = m_bb_tuple->addItem(
"chiMu", m_bb_chiMu );
62 status = m_bb_tuple->addItem(
"chiPi", m_bb_chiPi );
63 status = m_bb_tuple->addItem(
"chiK", m_bb_chiK );
64 status = m_bb_tuple->addItem(
"chiP", m_bb_chiP );
65 status = m_bb_tuple->addItem(
"nhit", m_bb_nhit );
66 status = m_bb_tuple->addItem(
"ndedxhit", m_bb_ndedxhit );
67 status = m_bb_tuple->addItem(
"dEdx", m_bb_dEdx );
69 else { log << MSG::ERROR <<
"Can not book N-tuple:" << long( m_bb_tuple ) << endmsg; }
73 new TH1F(
"Dedx_bhabha",
"dEdx distribution of bhabha samples", 150, 0., 1500. );
74 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx", h_dedx_bb ).isFailure() )
75 { log << MSG::ERROR <<
"Couldn't register Dedx_bhabha" << endmsg; }
76 TH1F* h_dedxbarrel_bb =
new TH1F(
77 "Dedx_Barrel_bhabha",
"dEdx distribution of barrel bhabha samples", 150, 0., 1500. );
78 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_barrel", h_dedxbarrel_bb ).isFailure() )
79 { log << MSG::ERROR <<
"Couldn't register Dedx_Barrel_bhabha" << endmsg; }
81 new TH1F(
"ChiE_bhabha",
"ChiE distribution of bhabha samples", 200, -20., 20. );
82 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/chiE", h_chie_bb ).isFailure() )
83 { log << MSG::ERROR <<
"Couldn't register chiE_bhabha" << endmsg; }
84 TH1F* h_nhitdedx_bb =
new TH1F(
"Nhitdedx",
"dEdx used hits", 40, 0., 60. );
85 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/nhitdedx", h_nhitdedx_bb ).isFailure() )
86 { log << MSG::ERROR <<
"Couldn't register Nhitdedx" << endmsg; }
87 TH1F* h_nhit_bb =
new TH1F(
"Nhit",
"Total hits", 40, 0., 60. );
88 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/nhit", h_nhit_bb ).isFailure() )
89 { log << MSG::ERROR <<
"Couldn't register Nhit" << endmsg; }
91 new TH2F(
"dEdx vs momentume",
"dEdx vs momentume", 200, 0, 2.5, 200, 0, 2000 );
92 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_p", h_dedxvsp_bb ).isFailure() )
93 { log << MSG::ERROR <<
"Couldn't register dedx vs p" << endmsg; }
94 TH2F* h_dedxvscos_bb =
95 new TH2F(
"dEdx vs costheta",
"dEdx vs costheta", 100, -1, 1, 150, 0, 1500 );
96 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_costh", h_dedxvscos_bb ).isFailure() )
97 { log << MSG::ERROR <<
"Couldn't register dedx vs costh" << endmsg; }
98 TH2F* h_dedxvst0_bb =
new TH2F(
"dEdx vs t0",
"dEdx vs t0", 250, 0, 2500, 150, 0, 1500 );
99 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_t0", h_dedxvst0_bb ).isFailure() )
100 { log << MSG::ERROR <<
"Couldn't register dedx vs t0" << endmsg; }
102 NTuplePtr nt_du(
ntupleSvc(),
"DQAFILE/DEDX" );
103 if ( nt_du ) m_bb_tuple = nt_du;
106 m_du_tuple =
ntupleSvc()->book(
"DQAFILE/DEDX/Dimu", CLID_ColumnWiseTuple,
"Dedx ntuple" );
109 status = m_du_tuple->addItem(
"runNo", m_du_runNo );
110 status = m_du_tuple->addItem(
"event", m_du_event );
111 status = m_du_tuple->addItem(
"p", m_du_p );
112 status = m_du_tuple->addItem(
"costh", m_du_costh );
113 status = m_du_tuple->addItem(
"t0", m_du_t0 );
114 status = m_du_tuple->addItem(
"chiE", m_du_chiE );
115 status = m_du_tuple->addItem(
"chiMu", m_du_chiMu );
116 status = m_du_tuple->addItem(
"chiPi", m_du_chiPi );
117 status = m_du_tuple->addItem(
"chiK", m_du_chiK );
118 status = m_du_tuple->addItem(
"chiP", m_du_chiP );
119 status = m_du_tuple->addItem(
"nhit", m_du_nhit );
120 status = m_du_tuple->addItem(
"ndedxhit", m_du_ndedxhit );
121 status = m_du_tuple->addItem(
"dEdx", m_du_dEdx );
123 else { log << MSG::ERROR <<
"Can not book N-tuple:" << long( m_du_tuple ) << endmsg; }
127 new TH1F(
"Dedx_dimu",
"dEdx distribution of bhabha samples", 150, 0., 1500. );
128 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx", h_dedx_du ).isFailure() )
129 { log << MSG::ERROR <<
"Couldn't register Dedx_dimu" << endmsg; }
130 TH1F* h_dedxbarrel_du =
new TH1F(
131 "Dedx_Barrel_dimu",
"dEdx distribution of barrel bhabha samples", 150, 0., 1500. );
132 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_barrel", h_dedxbarrel_du ).isFailure() )
133 { log << MSG::ERROR <<
"Couldn't register Dedx_Barrel_dimu" << endmsg; }
135 new TH1F(
"ChiE_dimu",
"ChiE distribution of bhabha samples", 200, -20., 20. );
136 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/chiMu", h_chimu_du ).isFailure() )
137 { log << MSG::ERROR <<
"Couldn't register chiMu_dimu" << endmsg; }
138 TH1F* h_nhitdedx_du =
new TH1F(
"Nhitdedx",
"dEdx used hits", 40, 0., 60. );
139 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/nhitdedx", h_nhitdedx_du ).isFailure() )
140 { log << MSG::ERROR <<
"Couldn't register Nhitdedx" << endmsg; }
141 TH1F* h_nhit_du =
new TH1F(
"Nhit",
"Total hits", 40, 0., 60. );
142 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/nhit", h_nhit_du ).isFailure() )
143 { log << MSG::ERROR <<
"Couldn't register Nhit" << endmsg; }
145 new TH2F(
"dEdx vs momentume",
"dEdx vs momentume", 200, 0, 2.5, 200, 0, 2000 );
146 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_p", h_dedxvsp_du ).isFailure() )
147 { log << MSG::ERROR <<
"Couldn't register dedx vs p" << endmsg; }
148 TH2F* h_dedxvscos_du =
149 new TH2F(
"dEdx vs costheta",
"dEdx vs costheta", 100, -1, 1, 150, 0, 1500 );
150 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_costh", h_dedxvscos_du ).isFailure() )
151 { log << MSG::ERROR <<
"Couldn't register dedx vs costh" << endmsg; }
152 TH2F* h_dedxvst0_du =
new TH2F(
"dEdx vs t0",
"dEdx vs t0", 200, 0, 2500, 150, 0, 1500 );
153 if ( m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_t0", h_dedxvst0_du ).isFailure() )
154 { log << MSG::ERROR <<
"Couldn't register dedx vs t0" << endmsg; }
156 log << MSG::INFO <<
"successfully return from initialize()" << endmsg;
157 return StatusCode::SUCCESS;
163 MsgStream log(
msgSvc(), name() );
164 log << MSG::INFO <<
"in execute()" << endmsg;
166 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
167 m_bb_runNo = eventHeader->runNumber();
168 m_bb_event = eventHeader->eventNumber();
170 m_du_runNo = eventHeader->runNumber();
171 m_du_event = eventHeader->eventNumber();
173 log << MSG::DEBUG <<
"run, evt num = " << m_bb_runNo <<
" , " << m_bb_event << endmsg;
177 SmartDataPtr<DQAEvent::DQAEvent> dqaevt( eventSvc(),
"/Event/DQATag" );
178 if ( dqaevt ) { log << MSG::INFO <<
"success get DQAEvent" << endmsg; }
181 log << MSG::ERROR <<
"Error accessing DQAEvent" << endmsg;
182 return StatusCode::FAILURE;
185 log << MSG::DEBUG <<
"event tag = " << dqaevt->EventTag() << endmsg;
188 if ( dqaevt->Bhabha() )
190 log << MSG::INFO <<
"Bhabha event" << endmsg;
191 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(),
193 for (
int i = 0; i < evtRecEvent->totalCharged(); i++ )
196 log << MSG::DEBUG << i <<
" " << ( *itTrk )->quality() << endmsg;
200 if ( !( *itTrk )->isElectron() )
continue;
207 int qual = ( *itTrk )->quality();
208 if ( qual != 0 && qual != 2 )
continue;
225 m_bb_ndedxhit = -999;
228 if ( ( *itTrk )->isMdcKalTrackValid() )
232 if ( mdcTrk->
charge() > 0 ) { log << MSG::DEBUG <<
"is electron" << endmsg; }
233 else { log << MSG::DEBUG <<
"is positron" << endmsg; }
234 double x0 = mdcTrk->
x();
235 double y0 = mdcTrk->
y();
236 double z0 = mdcTrk->
z();
237 double Rxy = sqrt( x0 * x0 + y0 * y0 );
239 m_bb_p = mdcTrk->
p() * mdcTrk->
charge();
240 m_bb_costh =
cos( mdcTrk->
theta() );
247 SmartDataPtr<RecEsTimeCol> aevtimeCol( eventSvc(),
"/Event/Recon/RecEsTimeCol" );
248 if ( aevtimeCol && aevtimeCol->size() > 0 )
250 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
251 for ( ; iter_evt != aevtimeCol->end(); iter_evt++ )
253 tes = ( *iter_evt )->getTest();
261 if ( ( *itTrk )->isMdcDedxValid() )
264 m_bb_chiE = dedxTrk->
chi( 0 );
265 m_bb_chiMu = dedxTrk->
chi( 1 );
266 m_bb_chiPi = dedxTrk->
chi( 2 );
267 m_bb_chiK = dedxTrk->
chi( 3 );
268 m_bb_chiP = dedxTrk->
chi( 4 );
271 m_bb_dEdx = dedxTrk->
probPH();
274 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx", h ).isSuccess() )
275 { h->Fill( dedxTrk->
probPH() ); }
276 else { log << MSG::ERROR <<
"Couldn't retrieve dedx" << endmsg; }
277 if ( fabs(
cos( mdcTrk->
theta() ) ) < 0.83 )
279 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_barrel", h ).isSuccess() )
280 { h->Fill( dedxTrk->
probPH() ); }
281 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_barrel" << endmsg; }
283 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/chiE", h ).isSuccess() )
284 { h->Fill( dedxTrk->
chiE() ); }
285 else { log << MSG::ERROR <<
"Couldn't retrieve chiE" << endmsg; }
286 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/nhitdedx", h ).isSuccess() )
288 else { log << MSG::ERROR <<
"Couldn't retrieve nhitdedx" << endmsg; }
289 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/nhit", h ).isSuccess() )
291 else { log << MSG::ERROR <<
"Couldn't retrieve nhit" << endmsg; }
292 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_p", h2 ).isSuccess() )
293 { h2->Fill( mdcTrk->
p(), dedxTrk->
probPH() ); }
294 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_p" << endmsg; }
295 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_costh", h2 ).isSuccess() )
297 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_costh" << endmsg; }
300 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_t0", h2 ).isSuccess() )
301 { h2->Fill( tes, dedxTrk->
probPH() ); }
302 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_t0" << endmsg; }
310 if ( dqaevt->Dimu() )
312 log << MSG::INFO <<
"Dimu event" << endmsg;
313 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(),
315 for (
int i = 0; i < evtRecEvent->totalCharged(); i++ )
318 log << MSG::DEBUG << i <<
" " << ( *itTrk )->quality() << endmsg;
322 if ( !( *itTrk )->isMuon() )
continue;
329 int qual = ( *itTrk )->quality();
330 if ( qual != 0 && qual != 2 )
continue;
347 m_du_ndedxhit = -999;
350 if ( ( *itTrk )->isMdcKalTrackValid() )
354 if ( mdcTrk->
charge() > 0 ) { log << MSG::DEBUG <<
"is muon+" << endmsg; }
355 else { log << MSG::DEBUG <<
"is muon-" << endmsg; }
356 double x0 = mdcTrk->
x();
357 double y0 = mdcTrk->
y();
358 double z0 = mdcTrk->
z();
359 double Rxy = sqrt( x0 * x0 + y0 * y0 );
361 m_du_p = mdcTrk->
p() * mdcTrk->
charge();
362 m_du_costh =
cos( mdcTrk->
theta() );
368 SmartDataPtr<RecEsTimeCol> aevtimeCol( eventSvc(),
"/Event/Recon/RecEsTimeCol" );
369 if ( aevtimeCol && aevtimeCol->size() > 0 )
371 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
372 for ( ; iter_evt != aevtimeCol->end(); iter_evt++ )
374 tes = ( *iter_evt )->getTest();
382 if ( ( *itTrk )->isMdcDedxValid() )
385 m_du_chiE = dedxTrk->
chi( 0 );
386 m_du_chiMu = dedxTrk->
chi( 1 );
387 m_du_chiPi = dedxTrk->
chi( 2 );
388 m_du_chiK = dedxTrk->
chi( 3 );
389 m_du_chiP = dedxTrk->
chi( 4 );
392 m_du_dEdx = dedxTrk->
probPH();
395 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx", h ).isSuccess() )
396 { h->Fill( dedxTrk->
probPH() ); }
397 else { log << MSG::ERROR <<
"Couldn't retrieve dedx" << endmsg; }
398 if ( fabs(
cos( mdcTrk->
theta() ) ) < 0.83 )
400 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_barrel", h ).isSuccess() )
401 { h->Fill( dedxTrk->
probPH() ); }
402 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_barrel" << endmsg; }
404 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/chiMu", h ).isSuccess() )
405 { h->Fill( dedxTrk->
chiE() ); }
406 else { log << MSG::ERROR <<
"Couldn't retrieve chiMu" << endmsg; }
407 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/nhitdedx", h ).isSuccess() )
409 else { log << MSG::ERROR <<
"Couldn't retrieve nhitdedx" << endmsg; }
410 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/nhit", h ).isSuccess() )
412 else { log << MSG::ERROR <<
"Couldn't retrieve nhit" << endmsg; }
413 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_p", h2 ).isSuccess() )
414 { h2->Fill( mdcTrk->
p(), dedxTrk->
probPH() ); }
415 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_p" << endmsg; }
416 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_costh", h2 ).isSuccess() )
418 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_costh" << endmsg; }
421 if ( m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_t0", h2 ).isSuccess() )
422 { h2->Fill( tes, dedxTrk->
probPH() ); }
423 else { log << MSG::ERROR <<
"Couldn't retrieve dedx_t0" << endmsg; }
433 m_bb_tuple->write().ignore();
434 m_du_tuple->write().ignore();
437 return StatusCode::SUCCESS;