51 MsgStream log(
msgSvc(), name());
53 log << MSG::INFO <<
"in initialize()" << endmsg;
62 if(service(
"THistSvc", m_thsvc).isFailure()) {
63 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
64 return StatusCode::FAILURE;
69 NTuplePtr nt_bb(
ntupleSvc(),
"DQAFILE/DEDX");
70 if ( nt_bb ) m_bb_tuple = nt_bb;
72 m_bb_tuple =
ntupleSvc()->book(
"DQAFILE/DEDX/Bhabha", CLID_ColumnWiseTuple,
"Dedx ntuple");
74 status = m_bb_tuple->addItem(
"runNo", m_bb_runNo);
75 status = m_bb_tuple->addItem(
"event", m_bb_event);
76 status = m_bb_tuple->addItem(
"p", m_bb_p);
77 status = m_bb_tuple->addItem(
"costh", m_bb_costh);
78 status = m_bb_tuple->addItem(
"t0", m_bb_t0);
79 status = m_bb_tuple->addItem(
"chiE",m_bb_chiE);
80 status = m_bb_tuple->addItem(
"chiMu",m_bb_chiMu);
81 status = m_bb_tuple->addItem(
"chiPi",m_bb_chiPi);
82 status = m_bb_tuple->addItem(
"chiK",m_bb_chiK);
83 status = m_bb_tuple->addItem(
"chiP",m_bb_chiP);
84 status = m_bb_tuple->addItem(
"nhit", m_bb_nhit);
85 status = m_bb_tuple->addItem(
"ndedxhit", m_bb_ndedxhit);
86 status = m_bb_tuple->addItem(
"dEdx", m_bb_dEdx);
88 log << MSG::ERROR <<
"Can not book N-tuple:" << long(m_bb_tuple) << endreq;
92 TH1F* h_dedx_bb =
new TH1F(
"Dedx_bhabha",
"dEdx distribution of bhabha samples", 150, 0., 1500.);
93 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx", h_dedx_bb).isFailure()) {
94 log << MSG::ERROR <<
"Couldn't register Dedx_bhabha" << endreq;
96 TH1F* h_dedxbarrel_bb =
new TH1F(
"Dedx_Barrel_bhabha",
"dEdx distribution of barrel bhabha samples", 150, 0., 1500.);
97 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_barrel", h_dedxbarrel_bb).isFailure()) {
98 log << MSG::ERROR <<
"Couldn't register Dedx_Barrel_bhabha" << endreq;
100 TH1F* h_chie_bb =
new TH1F(
"ChiE_bhabha",
"ChiE distribution of bhabha samples", 200, -20., 20.);
101 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/chiE", h_chie_bb).isFailure()) {
102 log << MSG::ERROR <<
"Couldn't register chiE_bhabha" << endreq;
104 TH1F* h_nhitdedx_bb =
new TH1F(
"Nhitdedx",
"dEdx used hits", 40, 0., 60.);
105 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/nhitdedx", h_nhitdedx_bb).isFailure()) {
106 log << MSG::ERROR <<
"Couldn't register Nhitdedx" << endreq;
108 TH1F* h_nhit_bb =
new TH1F(
"Nhit",
"Total hits", 40, 0., 60.);
109 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/nhit", h_nhit_bb).isFailure()) {
110 log << MSG::ERROR <<
"Couldn't register Nhit" << endreq;
112 TH2F* h_dedxvsp_bb=
new TH2F(
"dEdx vs momentume",
"dEdx vs momentume", 200,0,2.5,200,0,2000);
113 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_p", h_dedxvsp_bb).isFailure()) {
114 log << MSG::ERROR <<
"Couldn't register dedx vs p" << endreq;
116 TH2F* h_dedxvscos_bb=
new TH2F(
"dEdx vs costheta",
"dEdx vs costheta", 100,-1,1,150,0,1500);
117 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_costh", h_dedxvscos_bb).isFailure()) {
118 log << MSG::ERROR <<
"Couldn't register dedx vs costh" << endreq;
120 TH2F* h_dedxvst0_bb=
new TH2F(
"dEdx vs t0",
"dEdx vs t0", 250,0,2500,150,0,1500);
121 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_t0", h_dedxvst0_bb).isFailure()) {
122 log << MSG::ERROR <<
"Couldn't register dedx vs t0" << endreq;
126 NTuplePtr nt_du(
ntupleSvc(),
"DQAFILE/DEDX");
127 if ( nt_du ) m_bb_tuple = nt_du;
129 m_du_tuple =
ntupleSvc()->book(
"DQAFILE/DEDX/Dimu", CLID_ColumnWiseTuple,
"Dedx ntuple");
131 status = m_du_tuple->addItem(
"runNo", m_du_runNo);
132 status = m_du_tuple->addItem(
"event", m_du_event);
133 status = m_du_tuple->addItem(
"p", m_du_p);
134 status = m_du_tuple->addItem(
"costh", m_du_costh);
135 status = m_du_tuple->addItem(
"t0", m_du_t0);
136 status = m_du_tuple->addItem(
"chiE",m_du_chiE);
137 status = m_du_tuple->addItem(
"chiMu",m_du_chiMu);
138 status = m_du_tuple->addItem(
"chiPi",m_du_chiPi);
139 status = m_du_tuple->addItem(
"chiK",m_du_chiK);
140 status = m_du_tuple->addItem(
"chiP",m_du_chiP);
141 status = m_du_tuple->addItem(
"nhit", m_du_nhit);
142 status = m_du_tuple->addItem(
"ndedxhit", m_du_ndedxhit);
143 status = m_du_tuple->addItem(
"dEdx", m_du_dEdx);
145 log << MSG::ERROR <<
"Can not book N-tuple:" << long(m_du_tuple) << endreq;
150 TH1F* h_dedx_du =
new TH1F(
"Dedx_dimu",
"dEdx distribution of bhabha samples", 150, 0., 1500.);
151 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx", h_dedx_du).isFailure()) {
152 log << MSG::ERROR <<
"Couldn't register Dedx_dimu" << endreq;
154 TH1F* h_dedxbarrel_du =
new TH1F(
"Dedx_Barrel_dimu",
"dEdx distribution of barrel bhabha samples", 150, 0., 1500.);
155 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_barrel", h_dedxbarrel_du).isFailure()) {
156 log << MSG::ERROR <<
"Couldn't register Dedx_Barrel_dimu" << endreq;
158 TH1F* h_chimu_du =
new TH1F(
"ChiE_dimu",
"ChiE distribution of bhabha samples", 200, -20., 20.);
159 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/chiMu", h_chimu_du).isFailure()) {
160 log << MSG::ERROR <<
"Couldn't register chiMu_dimu" << endreq;
162 TH1F* h_nhitdedx_du =
new TH1F(
"Nhitdedx",
"dEdx used hits", 40, 0., 60.);
163 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/nhitdedx", h_nhitdedx_du).isFailure()) {
164 log << MSG::ERROR <<
"Couldn't register Nhitdedx" << endreq;
166 TH1F* h_nhit_du =
new TH1F(
"Nhit",
"Total hits", 40, 0., 60.);
167 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/nhit", h_nhit_du).isFailure()) {
168 log << MSG::ERROR <<
"Couldn't register Nhit" << endreq;
170 TH2F* h_dedxvsp_du=
new TH2F(
"dEdx vs momentume",
"dEdx vs momentume", 200,0,2.5,200,0,2000);
171 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_p", h_dedxvsp_du).isFailure()) {
172 log << MSG::ERROR <<
"Couldn't register dedx vs p" << endreq;
174 TH2F* h_dedxvscos_du=
new TH2F(
"dEdx vs costheta",
"dEdx vs costheta", 100,-1,1,150,0,1500);
175 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_costh", h_dedxvscos_du).isFailure()) {
176 log << MSG::ERROR <<
"Couldn't register dedx vs costh" << endreq;
178 TH2F* h_dedxvst0_du=
new TH2F(
"dEdx vs t0",
"dEdx vs t0", 200,0,2500,150,0,1500);
179 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_t0", h_dedxvst0_du).isFailure()) {
180 log << MSG::ERROR <<
"Couldn't register dedx vs t0" << endreq;
186 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
187 return StatusCode::SUCCESS;
195 MsgStream log(
msgSvc(), name());
196 log << MSG::INFO <<
"in execute()" << endreq;
198 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
199 m_bb_runNo=eventHeader->runNumber();
200 m_bb_event=eventHeader->eventNumber();
202 m_du_runNo=eventHeader->runNumber();
203 m_du_event=eventHeader->eventNumber();
205 log << MSG::DEBUG <<
"run, evt num = "
206 << m_bb_runNo <<
" , "
207 << m_bb_event <<endreq;
212 SmartDataPtr<DQAEvent::DQAEvent> dqaevt(eventSvc(),
"/Event/DQATag");
214 log << MSG::INFO <<
"success get DQAEvent" << endreq;
216 log << MSG::ERROR <<
"Error accessing DQAEvent" << endreq;
217 return StatusCode::FAILURE;
220 log << MSG::DEBUG <<
"event tag = " << dqaevt->EventTag() << endreq;
223 if ( dqaevt->Bhabha() ) {
224 log << MSG::INFO <<
"Bhabha event" << endreq;
226 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
228 log << MSG::DEBUG << i <<
" " << (*itTrk)->quality() << endreq;
232 if ( !(*itTrk)->isElectron() )
continue;
239 int qual = (*itTrk)->quality();
240 if ( qual != 0 && qual != 2)
continue;
262 if((*itTrk)->isMdcKalTrackValid()){
265 if ( mdcTrk->
charge() > 0 ) {
266 log << MSG::DEBUG <<
"is electron" << endreq;
268 log << MSG::DEBUG <<
"is positron" << endreq;
270 double x0 =mdcTrk->
x();
271 double y0 =mdcTrk->
y();
272 double z0 =mdcTrk->
z();
273 double Rxy=sqrt(x0*x0+y0*y0);
275 m_bb_p=mdcTrk->
p()*mdcTrk->
charge();
283 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
284 if( aevtimeCol && aevtimeCol->size()>0 ){
285 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
286 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
287 tes = (*iter_evt)->getTest();
295 if((*itTrk)->isMdcDedxValid()){
297 m_bb_chiE = dedxTrk->
chi(0);
298 m_bb_chiMu = dedxTrk->
chi(1);
299 m_bb_chiPi = dedxTrk->
chi(2);
300 m_bb_chiK = dedxTrk->
chi(3);
301 m_bb_chiP = dedxTrk->
chi(4);
304 m_bb_dEdx = dedxTrk->
probPH();
307 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx", h).isSuccess()) {
308 h->Fill(dedxTrk->
probPH());
311 log << MSG::ERROR <<
"Couldn't retrieve dedx" << endreq;
313 if(fabs(
cos(mdcTrk->
theta()))<0.83){
314 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_barrel", h).isSuccess()) {
315 h->Fill(dedxTrk->
probPH());
318 log << MSG::ERROR <<
"Couldn't retrieve dedx_barrel" << endreq;
321 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/chiE", h).isSuccess()) {
322 h->Fill(dedxTrk->
chiE());
325 log << MSG::ERROR <<
"Couldn't retrieve chiE" << endreq;
327 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/nhitdedx", h).isSuccess()) {
331 log << MSG::ERROR <<
"Couldn't retrieve nhitdedx" << endreq;
333 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/nhit", h).isSuccess()) {
337 log << MSG::ERROR <<
"Couldn't retrieve nhit" << endreq;
339 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_p", h2).isSuccess()) {
340 h2->Fill(mdcTrk->
p(), dedxTrk->
probPH());
343 log << MSG::ERROR <<
"Couldn't retrieve dedx_p" << endreq;
345 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_costh", h2).isSuccess()) {
349 log << MSG::ERROR <<
"Couldn't retrieve dedx_costh" << endreq;
352 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_t0", h2).isSuccess()) {
353 h2->Fill(tes, dedxTrk->
probPH());
356 log << MSG::ERROR <<
"Couldn't retrieve dedx_t0" << endreq;
366 if ( dqaevt->Dimu() ) {
367 log << MSG::INFO <<
"Dimu event" << endreq;
369 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
371 log << MSG::DEBUG << i <<
" " << (*itTrk)->quality() << endreq;
375 if ( !(*itTrk)->isMuon() )
continue;
382 int qual = (*itTrk)->quality();
383 if ( qual != 0 && qual != 2)
continue;
404 if((*itTrk)->isMdcKalTrackValid()){
407 if ( mdcTrk->
charge() > 0 ) {
408 log << MSG::DEBUG <<
"is muon+" << endreq;
410 log << MSG::DEBUG <<
"is muon-" << endreq;
412 double x0 =mdcTrk->
x();
413 double y0 =mdcTrk->
y();
414 double z0 =mdcTrk->
z();
415 double Rxy=sqrt(x0*x0+y0*y0);
417 m_du_p=mdcTrk->
p()*mdcTrk->
charge();
424 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
425 if( aevtimeCol && aevtimeCol->size()>0 ){
426 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
427 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
428 tes = (*iter_evt)->getTest();
436 if((*itTrk)->isMdcDedxValid()){
438 m_du_chiE = dedxTrk->
chi(0);
439 m_du_chiMu = dedxTrk->
chi(1);
440 m_du_chiPi = dedxTrk->
chi(2);
441 m_du_chiK = dedxTrk->
chi(3);
442 m_du_chiP = dedxTrk->
chi(4);
445 m_du_dEdx = dedxTrk->
probPH();
448 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx", h).isSuccess()) {
449 h->Fill(dedxTrk->
probPH());
452 log << MSG::ERROR <<
"Couldn't retrieve dedx" << endreq;
454 if(fabs(
cos(mdcTrk->
theta()))<0.83){
455 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_barrel", h).isSuccess()) {
456 h->Fill(dedxTrk->
probPH());
459 log << MSG::ERROR <<
"Couldn't retrieve dedx_barrel" << endreq;
462 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/chiMu", h).isSuccess()) {
463 h->Fill(dedxTrk->
chiE());
466 log << MSG::ERROR <<
"Couldn't retrieve chiMu" << endreq;
468 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/nhitdedx", h).isSuccess()) {
472 log << MSG::ERROR <<
"Couldn't retrieve nhitdedx" << endreq;
474 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/nhit", h).isSuccess()) {
478 log << MSG::ERROR <<
"Couldn't retrieve nhit" << endreq;
480 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_p", h2).isSuccess()) {
481 h2->Fill(mdcTrk->
p(), dedxTrk->
probPH());
484 log << MSG::ERROR <<
"Couldn't retrieve dedx_p" << endreq;
486 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_costh", h2).isSuccess()) {
490 log << MSG::ERROR <<
"Couldn't retrieve dedx_costh" << endreq;
493 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_t0", h2).isSuccess()) {
494 h2->Fill(tes, dedxTrk->
probPH());
497 log << MSG::ERROR <<
"Couldn't retrieve dedx_t0" << endreq;
511 return StatusCode::SUCCESS;