48 MsgStream log(
msgSvc(), name());
50 log << MSG::INFO <<
"in initialize()" << endmsg;
59 if(service(
"THistSvc", m_thsvc).isFailure()) {
60 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
61 return StatusCode::FAILURE;
66 NTuplePtr nt_bb(
ntupleSvc(),
"DQAFILE/DEDX");
67 if ( nt_bb ) m_bb_tuple = nt_bb;
69 m_bb_tuple =
ntupleSvc()->book(
"DQAFILE/DEDX/Bhabha", CLID_ColumnWiseTuple,
"Dedx ntuple");
71 status = m_bb_tuple->addItem(
"runNo", m_bb_runNo);
72 status = m_bb_tuple->addItem(
"event", m_bb_event);
73 status = m_bb_tuple->addItem(
"p", m_bb_p);
74 status = m_bb_tuple->addItem(
"costh", m_bb_costh);
75 status = m_bb_tuple->addItem(
"t0", m_bb_t0);
76 status = m_bb_tuple->addItem(
"chiE",m_bb_chiE);
77 status = m_bb_tuple->addItem(
"chiMu",m_bb_chiMu);
78 status = m_bb_tuple->addItem(
"chiPi",m_bb_chiPi);
79 status = m_bb_tuple->addItem(
"chiK",m_bb_chiK);
80 status = m_bb_tuple->addItem(
"chiP",m_bb_chiP);
81 status = m_bb_tuple->addItem(
"nhit", m_bb_nhit);
82 status = m_bb_tuple->addItem(
"ndedxhit", m_bb_ndedxhit);
83 status = m_bb_tuple->addItem(
"dEdx", m_bb_dEdx);
85 log << MSG::ERROR <<
"Can not book N-tuple:" << long(m_bb_tuple) << endreq;
89 TH1F* h_dedx_bb =
new TH1F(
"Dedx_bhabha",
"dEdx distribution of bhabha samples", 150, 0., 1500.);
90 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx", h_dedx_bb).isFailure()) {
91 log << MSG::ERROR <<
"Couldn't register Dedx_bhabha" << endreq;
93 TH1F* h_dedxbarrel_bb =
new TH1F(
"Dedx_Barrel_bhabha",
"dEdx distribution of barrel bhabha samples", 150, 0., 1500.);
94 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_barrel", h_dedxbarrel_bb).isFailure()) {
95 log << MSG::ERROR <<
"Couldn't register Dedx_Barrel_bhabha" << endreq;
97 TH1F* h_chie_bb =
new TH1F(
"ChiE_bhabha",
"ChiE distribution of bhabha samples", 200, -20., 20.);
98 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/chiE", h_chie_bb).isFailure()) {
99 log << MSG::ERROR <<
"Couldn't register chiE_bhabha" << endreq;
101 TH1F* h_nhitdedx_bb =
new TH1F(
"Nhitdedx",
"dEdx used hits", 40, 0., 60.);
102 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/nhitdedx", h_nhitdedx_bb).isFailure()) {
103 log << MSG::ERROR <<
"Couldn't register Nhitdedx" << endreq;
105 TH1F* h_nhit_bb =
new TH1F(
"Nhit",
"Total hits", 40, 0., 60.);
106 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/nhit", h_nhit_bb).isFailure()) {
107 log << MSG::ERROR <<
"Couldn't register Nhit" << endreq;
109 TH2F* h_dedxvsp_bb=
new TH2F(
"dEdx vs momentume",
"dEdx vs momentume", 200,0,2.5,200,0,2000);
110 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_p", h_dedxvsp_bb).isFailure()) {
111 log << MSG::ERROR <<
"Couldn't register dedx vs p" << endreq;
113 TH2F* h_dedxvscos_bb=
new TH2F(
"dEdx vs costheta",
"dEdx vs costheta", 100,-1,1,150,0,1500);
114 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_costh", h_dedxvscos_bb).isFailure()) {
115 log << MSG::ERROR <<
"Couldn't register dedx vs costh" << endreq;
117 TH2F* h_dedxvst0_bb=
new TH2F(
"dEdx vs t0",
"dEdx vs t0", 250,0,2500,150,0,1500);
118 if(m_thsvc->regHist(
"/DQAHist/Dedx/Bhabha/dedx_t0", h_dedxvst0_bb).isFailure()) {
119 log << MSG::ERROR <<
"Couldn't register dedx vs t0" << endreq;
123 NTuplePtr nt_du(
ntupleSvc(),
"DQAFILE/DEDX");
124 if ( nt_du ) m_bb_tuple = nt_du;
126 m_du_tuple =
ntupleSvc()->book(
"DQAFILE/DEDX/Dimu", CLID_ColumnWiseTuple,
"Dedx ntuple");
128 status = m_du_tuple->addItem(
"runNo", m_du_runNo);
129 status = m_du_tuple->addItem(
"event", m_du_event);
130 status = m_du_tuple->addItem(
"p", m_du_p);
131 status = m_du_tuple->addItem(
"costh", m_du_costh);
132 status = m_du_tuple->addItem(
"t0", m_du_t0);
133 status = m_du_tuple->addItem(
"chiE",m_du_chiE);
134 status = m_du_tuple->addItem(
"chiMu",m_du_chiMu);
135 status = m_du_tuple->addItem(
"chiPi",m_du_chiPi);
136 status = m_du_tuple->addItem(
"chiK",m_du_chiK);
137 status = m_du_tuple->addItem(
"chiP",m_du_chiP);
138 status = m_du_tuple->addItem(
"nhit", m_du_nhit);
139 status = m_du_tuple->addItem(
"ndedxhit", m_du_ndedxhit);
140 status = m_du_tuple->addItem(
"dEdx", m_du_dEdx);
142 log << MSG::ERROR <<
"Can not book N-tuple:" << long(m_du_tuple) << endreq;
147 TH1F* h_dedx_du =
new TH1F(
"Dedx_dimu",
"dEdx distribution of bhabha samples", 150, 0., 1500.);
148 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx", h_dedx_du).isFailure()) {
149 log << MSG::ERROR <<
"Couldn't register Dedx_dimu" << endreq;
151 TH1F* h_dedxbarrel_du =
new TH1F(
"Dedx_Barrel_dimu",
"dEdx distribution of barrel bhabha samples", 150, 0., 1500.);
152 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_barrel", h_dedxbarrel_du).isFailure()) {
153 log << MSG::ERROR <<
"Couldn't register Dedx_Barrel_dimu" << endreq;
155 TH1F* h_chimu_du =
new TH1F(
"ChiE_dimu",
"ChiE distribution of bhabha samples", 200, -20., 20.);
156 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/chiMu", h_chimu_du).isFailure()) {
157 log << MSG::ERROR <<
"Couldn't register chiMu_dimu" << endreq;
159 TH1F* h_nhitdedx_du =
new TH1F(
"Nhitdedx",
"dEdx used hits", 40, 0., 60.);
160 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/nhitdedx", h_nhitdedx_du).isFailure()) {
161 log << MSG::ERROR <<
"Couldn't register Nhitdedx" << endreq;
163 TH1F* h_nhit_du =
new TH1F(
"Nhit",
"Total hits", 40, 0., 60.);
164 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/nhit", h_nhit_du).isFailure()) {
165 log << MSG::ERROR <<
"Couldn't register Nhit" << endreq;
167 TH2F* h_dedxvsp_du=
new TH2F(
"dEdx vs momentume",
"dEdx vs momentume", 200,0,2.5,200,0,2000);
168 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_p", h_dedxvsp_du).isFailure()) {
169 log << MSG::ERROR <<
"Couldn't register dedx vs p" << endreq;
171 TH2F* h_dedxvscos_du=
new TH2F(
"dEdx vs costheta",
"dEdx vs costheta", 100,-1,1,150,0,1500);
172 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_costh", h_dedxvscos_du).isFailure()) {
173 log << MSG::ERROR <<
"Couldn't register dedx vs costh" << endreq;
175 TH2F* h_dedxvst0_du=
new TH2F(
"dEdx vs t0",
"dEdx vs t0", 200,0,2500,150,0,1500);
176 if(m_thsvc->regHist(
"/DQAHist/Dedx/Dimu/dedx_t0", h_dedxvst0_du).isFailure()) {
177 log << MSG::ERROR <<
"Couldn't register dedx vs t0" << endreq;
183 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
184 return StatusCode::SUCCESS;
192 MsgStream log(
msgSvc(), name());
193 log << MSG::INFO <<
"in execute()" << endreq;
195 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
196 m_bb_runNo=eventHeader->runNumber();
197 m_bb_event=eventHeader->eventNumber();
199 m_du_runNo=eventHeader->runNumber();
200 m_du_event=eventHeader->eventNumber();
202 log << MSG::DEBUG <<
"run, evt num = "
203 << m_bb_runNo <<
" , "
204 << m_bb_event <<endreq;
209 SmartDataPtr<DQAEvent::DQAEvent> dqaevt(eventSvc(),
"/Event/DQATag");
211 log << MSG::INFO <<
"success get DQAEvent" << endreq;
213 log << MSG::ERROR <<
"Error accessing DQAEvent" << endreq;
214 return StatusCode::FAILURE;
217 log << MSG::DEBUG <<
"event tag = " << dqaevt->EventTag() << endreq;
220 if ( dqaevt->Bhabha() ) {
221 log << MSG::INFO <<
"Bhabha event" << endreq;
223 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
225 log << MSG::DEBUG << i <<
" " << (*itTrk)->partId() <<
" "
226 << (*itTrk)->quality() << endreq;
229 if ( (*itTrk)->partId() != 1 )
continue;
236 int qual = (*itTrk)->quality();
237 if ( qual != 0 && qual != 2)
continue;
259 if((*itTrk)->isMdcKalTrackValid()){
262 if ( mdcTrk->
charge() > 0 ) {
263 log << MSG::DEBUG <<
"is electron" << endreq;
265 log << MSG::DEBUG <<
"is positron" << endreq;
267 double x0 =mdcTrk->
x();
268 double y0 =mdcTrk->
y();
269 double z0 =mdcTrk->
z();
270 double Rxy=sqrt(x0*x0+y0*y0);
272 m_bb_p=mdcTrk->
p()*mdcTrk->
charge();
279 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
280 if( aevtimeCol && aevtimeCol->size()>0 ){
281 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
282 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
283 tes = (*iter_evt)->getTest();
290 if((*itTrk)->isMdcDedxValid()){
292 m_bb_chiE = dedxTrk->
chi(0);
293 m_bb_chiMu = dedxTrk->
chi(1);
294 m_bb_chiPi = dedxTrk->
chi(2);
295 m_bb_chiK = dedxTrk->
chi(3);
296 m_bb_chiP = dedxTrk->
chi(4);
299 m_bb_dEdx = dedxTrk->
probPH();
302 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx", h).isSuccess()) {
303 h->Fill(dedxTrk->
probPH());
306 log << MSG::ERROR <<
"Couldn't retrieve dedx" << endreq;
308 if(fabs(
cos(mdcTrk->
theta()))<0.83){
309 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_barrel", h).isSuccess()) {
310 h->Fill(dedxTrk->
probPH());
313 log << MSG::ERROR <<
"Couldn't retrieve dedx_barrel" << endreq;
316 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/chiE", h).isSuccess()) {
317 h->Fill(dedxTrk->
chiE());
320 log << MSG::ERROR <<
"Couldn't retrieve chiE" << endreq;
322 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/nhitdedx", h).isSuccess()) {
326 log << MSG::ERROR <<
"Couldn't retrieve nhitdedx" << endreq;
328 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/nhit", h).isSuccess()) {
332 log << MSG::ERROR <<
"Couldn't retrieve nhit" << endreq;
334 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_p", h2).isSuccess()) {
335 h2->Fill(mdcTrk->
p(), dedxTrk->
probPH());
338 log << MSG::ERROR <<
"Couldn't retrieve dedx_p" << endreq;
340 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_costh", h2).isSuccess()) {
344 log << MSG::ERROR <<
"Couldn't retrieve dedx_costh" << endreq;
346 if (m_thsvc->getHist(
"/DQAHist/Dedx/Bhabha/dedx_t0", h2).isSuccess()) {
347 h2->Fill(tes, dedxTrk->
probPH());
350 log << MSG::ERROR <<
"Couldn't retrieve dedx_t0" << endreq;
359 if ( dqaevt->Dimu() ) {
360 log << MSG::INFO <<
"Dimu event" << endreq;
362 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
364 log << MSG::DEBUG << i <<
" " << (*itTrk)->partId() <<
" "
365 << (*itTrk)->quality() << endreq;
368 if ( (*itTrk)->partId() != 2 )
continue;
375 int qual = (*itTrk)->quality();
376 if ( qual != 0 && qual != 2)
continue;
397 if((*itTrk)->isMdcKalTrackValid()){
400 if ( mdcTrk->
charge() > 0 ) {
401 log << MSG::DEBUG <<
"is muon+" << endreq;
403 log << MSG::DEBUG <<
"is muon-" << endreq;
405 double x0 =mdcTrk->
x();
406 double y0 =mdcTrk->
y();
407 double z0 =mdcTrk->
z();
408 double Rxy=sqrt(x0*x0+y0*y0);
410 m_du_p=mdcTrk->
p()*mdcTrk->
charge();
416 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
417 if( aevtimeCol && aevtimeCol->size()>0 ){
418 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
419 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
420 tes = (*iter_evt)->getTest();
427 if((*itTrk)->isMdcDedxValid()){
429 m_du_chiE = dedxTrk->
chi(0);
430 m_du_chiMu = dedxTrk->
chi(1);
431 m_du_chiPi = dedxTrk->
chi(2);
432 m_du_chiK = dedxTrk->
chi(3);
433 m_du_chiP = dedxTrk->
chi(4);
436 m_du_dEdx = dedxTrk->
probPH();
439 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx", h).isSuccess()) {
440 h->Fill(dedxTrk->
probPH());
443 log << MSG::ERROR <<
"Couldn't retrieve dedx" << endreq;
445 if(fabs(
cos(mdcTrk->
theta()))<0.83){
446 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_barrel", h).isSuccess()) {
447 h->Fill(dedxTrk->
probPH());
450 log << MSG::ERROR <<
"Couldn't retrieve dedx_barrel" << endreq;
453 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/chiMu", h).isSuccess()) {
454 h->Fill(dedxTrk->
chiE());
457 log << MSG::ERROR <<
"Couldn't retrieve chiMu" << endreq;
459 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/nhitdedx", h).isSuccess()) {
463 log << MSG::ERROR <<
"Couldn't retrieve nhitdedx" << endreq;
465 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/nhit", h).isSuccess()) {
469 log << MSG::ERROR <<
"Couldn't retrieve nhit" << endreq;
471 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_p", h2).isSuccess()) {
472 h2->Fill(mdcTrk->
p(), dedxTrk->
probPH());
475 log << MSG::ERROR <<
"Couldn't retrieve dedx_p" << endreq;
477 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_costh", h2).isSuccess()) {
481 log << MSG::ERROR <<
"Couldn't retrieve dedx_costh" << endreq;
483 if (m_thsvc->getHist(
"/DQAHist/Dedx/Dimu/dedx_t0", h2).isSuccess()) {
484 h2->Fill(tes, dedxTrk->
probPH());
487 log << MSG::ERROR <<
"Couldn't retrieve dedx_t0" << endreq;
499 return StatusCode::SUCCESS;