91 MsgStream log(
msgSvc(), name());
93 log << MSG::INFO <<
"in initialize()" << endmsg;
99 if(service(
"THistSvc", m_thsvc).isFailure()) {
100 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
101 return StatusCode::FAILURE;
106 TH1F* hbst_p =
new TH1F(
"bst_p",
"bst_p", 80, 1.15, 1.31);
107 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hbst_p", hbst_p).isFailure()) {
108 log << MSG::ERROR <<
"Couldn't register bst_p" << endreq;
111 TH1F* hbst_cos =
new TH1F(
"bst_cos",
"bst_cos", 20, -1.0, 1.0);
112 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hbst_cos", hbst_cos).isFailure()) {
113 log << MSG::ERROR <<
"Couldn't register bst_cos" << endreq;
116 TH1F* hmpp =
new TH1F(
"mpp",
"mpp", 100, 3.05, 3.15);
117 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hmpp", hmpp).isFailure()) {
118 log << MSG::ERROR <<
"Couldn't register mpp" << endreq;
121 TH1F* hangle =
new TH1F(
"angle",
"angle", 50, 175.0, 180.);
122 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hangle", hangle).isFailure()) {
123 log << MSG::ERROR <<
"Couldn't register angle" << endreq;
126 TH1F* hdeltatof =
new TH1F(
"deltatof",
"deltatof", 50, -10., 10.);
127 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hdeltatof", hdeltatof).isFailure()) {
128 log << MSG::ERROR <<
"Couldn't register deltatof" << endreq;
131 TH1F* he_emc1 =
new TH1F(
"e_emc1",
"e_emc1", 100, 0.0, 2.0);
132 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/he_emc1", he_emc1).isFailure()) {
133 log << MSG::ERROR <<
"Couldn't register e_emc1" << endreq;
136 TH1F* he_emc2 =
new TH1F(
"e_emc2",
"e_emc2", 100, 0.0, 2.0);
137 if(m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/he_emc2", he_emc2).isFailure()) {
138 log << MSG::ERROR <<
"Couldn't register e_emc2" << endreq;
145 NTuplePtr nt1(
ntupleSvc(),
"DQAFILE/DQAJpsi2PPbar");
146 if ( nt1 ) m_tuple = nt1;
148 m_tuple =
ntupleSvc()->book (
"DQAFILE/DQAJpsi2PPbar", CLID_ColumnWiseTuple,
"N-Tuple");
150 status = m_tuple->addItem (
"runNo", m_runNo);
151 status = m_tuple->addItem (
"event", m_event);
152 status = m_tuple->addItem (
"Nchrg", m_nchrg);
153 status = m_tuple->addItem (
"Nneu", m_nneu);
154 status = m_tuple->addItem (
"ngch", m_ngch, 0, 10);
156 status = m_tuple->addIndexedItem (
"charge",m_ngch, m_charge);
157 status = m_tuple->addIndexedItem (
"vx0", m_ngch, m_vx0);
158 status = m_tuple->addIndexedItem (
"vy0", m_ngch, m_vy0);
159 status = m_tuple->addIndexedItem (
"vz0", m_ngch, m_vz0);
160 status = m_tuple->addIndexedItem (
"vr0", m_ngch, m_vr0);
162 status = m_tuple->addIndexedItem (
"vx", m_ngch, m_vx);
163 status = m_tuple->addIndexedItem (
"vy", m_ngch, m_vy);
164 status = m_tuple->addIndexedItem (
"vz", m_ngch, m_vz);
165 status = m_tuple->addIndexedItem (
"vr", m_ngch, m_vr);
167 status = m_tuple->addIndexedItem (
"px", m_ngch, m_px);
168 status = m_tuple->addIndexedItem (
"py", m_ngch, m_py);
169 status = m_tuple->addIndexedItem (
"pz", m_ngch, m_pz);
170 status = m_tuple->addIndexedItem (
"p", m_ngch, m_p );
171 status = m_tuple->addIndexedItem (
"cos", m_ngch, m_cos);
173 status = m_tuple->addIndexedItem (
"bst_px", m_ngch, m_bst_px) ;
174 status = m_tuple->addIndexedItem (
"bst_py", m_ngch, m_bst_py) ;
175 status = m_tuple->addIndexedItem (
"bst_pz", m_ngch, m_bst_pz) ;
176 status = m_tuple->addIndexedItem (
"bst_p", m_ngch, m_bst_p) ;
177 status = m_tuple->addIndexedItem (
"bst_cos", m_ngch, m_bst_cos);
180 status = m_tuple->addIndexedItem (
"chie" , m_ngch, m_chie) ;
181 status = m_tuple->addIndexedItem (
"chimu" , m_ngch, m_chimu) ;
182 status = m_tuple->addIndexedItem (
"chipi" , m_ngch, m_chipi) ;
183 status = m_tuple->addIndexedItem (
"chik" , m_ngch, m_chik) ;
184 status = m_tuple->addIndexedItem (
"chip" , m_ngch, m_chip) ;
185 status = m_tuple->addIndexedItem (
"ghit" , m_ngch, m_ghit) ;
186 status = m_tuple->addIndexedItem (
"thit" , m_ngch, m_thit) ;
187 status = m_tuple->addIndexedItem (
"probPH" , m_ngch, m_probPH) ;
188 status = m_tuple->addIndexedItem (
"normPH" , m_ngch, m_normPH) ;
190 status = m_tuple->addIndexedItem (
"e_emc" , m_ngch, m_e_emc) ;
193 status = m_tuple->addIndexedItem (
"qual_etof" , m_ngch, m_qual_etof );
194 status = m_tuple->addIndexedItem (
"tof_etof" , m_ngch, m_tof_etof );
195 status = m_tuple->addIndexedItem (
"te_etof" , m_ngch, m_te_etof );
196 status = m_tuple->addIndexedItem (
"tmu_etof" , m_ngch, m_tmu_etof );
197 status = m_tuple->addIndexedItem (
"tpi_etof" , m_ngch, m_tpi_etof );
198 status = m_tuple->addIndexedItem (
"tk_etof" , m_ngch, m_tk_etof );
199 status = m_tuple->addIndexedItem (
"tp_etof" , m_ngch, m_tp_etof );
201 status = m_tuple->addIndexedItem (
"qual_btof1", m_ngch, m_qual_btof1 );
202 status = m_tuple->addIndexedItem (
"tof_btof1" , m_ngch, m_tof_btof1 );
203 status = m_tuple->addIndexedItem (
"te_btof1" , m_ngch, m_te_btof1 );
204 status = m_tuple->addIndexedItem (
"tmu_btof1" , m_ngch, m_tmu_btof1 );
205 status = m_tuple->addIndexedItem (
"tpi_btof1" , m_ngch, m_tpi_btof1 );
206 status = m_tuple->addIndexedItem (
"tk_btof1" , m_ngch, m_tk_btof1 );
207 status = m_tuple->addIndexedItem (
"tp_btof1" , m_ngch, m_tp_btof1 );
209 status = m_tuple->addIndexedItem (
"qual_btof2", m_ngch, m_qual_btof2 );
210 status = m_tuple->addIndexedItem (
"tof_btof2" , m_ngch, m_tof_btof2 );
211 status = m_tuple->addIndexedItem (
"te_btof2" , m_ngch, m_te_btof2 );
212 status = m_tuple->addIndexedItem (
"tmu_btof2" , m_ngch, m_tmu_btof2 );
213 status = m_tuple->addIndexedItem (
"tpi_btof2" , m_ngch, m_tpi_btof2 );
214 status = m_tuple->addIndexedItem (
"tk_btof2" , m_ngch, m_tk_btof2 );
215 status = m_tuple->addIndexedItem (
"tp_btof2" , m_ngch, m_tp_btof2 );
217 status = m_tuple->addIndexedItem (
"dedx_pid", m_ngch, m_dedx_pid);
218 status = m_tuple->addIndexedItem (
"tof1_pid", m_ngch, m_tof1_pid);
219 status = m_tuple->addIndexedItem (
"tof2_pid", m_ngch, m_tof2_pid);
220 status = m_tuple->addIndexedItem (
"prob_pi", m_ngch, m_prob_pi );
221 status = m_tuple->addIndexedItem (
"prob_k", m_ngch, m_prob_k );
222 status = m_tuple->addIndexedItem (
"prob_p", m_ngch, m_prob_p );
224 status = m_tuple->addItem (
"np", m_np );
225 status = m_tuple->addItem (
"npb", m_npb );
227 status = m_tuple->addItem (
"m2p", m_m2p );
228 status = m_tuple->addItem (
"angle", m_angle );
229 status = m_tuple->addItem (
"deltatof", m_deltatof );
231 status = m_tuple->addItem (
"vtx_m2p", m_vtx_m2p );
232 status = m_tuple->addItem (
"vtx_angle", m_vtx_angle );
234 status = m_tuple->addItem (
"m_chi2_4c", m_chi2_4c );
235 status = m_tuple->addItem (
"m_m2p_4c", m_m2p_4c );
236 status = m_tuple->addItem (
"m_angle_4c", m_angle_4c );
240 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple) << endmsg;
241 return StatusCode::FAILURE;
249 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
250 return StatusCode::SUCCESS;
258 MsgStream log(
msgSvc(), name());
259 log << MSG::INFO <<
"in execute()" << endreq;
261 setFilterPassed(
false);
264 log << MSG::INFO <<
"counter[0]=" << counter[0]<< endreq;
266 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
268 m_runNo = eventHeader->runNumber();
269 m_event = eventHeader->eventNumber();
270 m_nchrg = evtRecEvent->totalCharged();
271 m_nneu = evtRecEvent->totalNeutral();
273 log << MSG::INFO <<
"ncharg, nneu, tottks = "
274 << evtRecEvent->totalCharged() <<
" , "
275 << evtRecEvent->totalNeutral() <<
" , "
276 << evtRecEvent->totalTracks() <<endreq;
284 Vint iGood, iptrk, imtrk;
289 Hep3Vector xorigin(0,0,0);
293 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
299 xorigin.setX(dbv[0]);
300 xorigin.setY(dbv[1]);
301 xorigin.setZ(dbv[2]);
303 <<
"xorigin.x="<<xorigin.x()<<
", "
304 <<
"xorigin.y="<<xorigin.y()<<
", "
305 <<
"xorigin.z="<<xorigin.z()<<
", "
309 for (
int i = 0; i < evtRecEvent->totalCharged(); i++){
311 if(!(*itTrk)->isMdcTrackValid())
continue;
312 if(!(*itTrk)->isMdcKalTrackValid())
continue;
314 double x0=mdcTrk->
x();
315 double y0=mdcTrk->
y();
316 double z0=mdcTrk->
z();
317 double phi0=mdcTrk->
helix(1);
318 double xv=xorigin.x();
319 double yv=xorigin.y();
320 double zv=xorigin.z();
321 double rv=(x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0);
323 if(fabs(z0-zv) >= m_vz1cut)
continue;
324 if(fabs(rv) >= m_vr1cut)
continue;
328 nCharge += mdcTrk->
charge();
330 if (mdcTrk->
charge() > 0) {
339 int nGood = iGood.size();
340 m_ngch = iGood.size();
341 log << MSG::INFO <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endreq;
342 if((nGood != 2) || (nCharge!=0) ){
343 return StatusCode::SUCCESS;
346 log << MSG::INFO <<
"counter[1]=" << counter[1]<< endreq;
363 for(
int i = 0; i < nGood; i++) {
366 if(!(*itTrk)->isMdcTrackValid())
continue;
368 if(!(*itTrk)->isMdcKalTrackValid())
continue;
393 if (prob_p > prob_pi && prob_p > prob_k) {
395 HepLorentzVector pkaltrk;
398 pkaltrk.setPx(mdcKalTrk->
px());
399 pkaltrk.setPy(mdcKalTrk->
py());
400 pkaltrk.setPz(mdcKalTrk->
pz());
401 double p3 = pkaltrk.mag();
406 ipp.push_back(iGood[i]);
407 p_pp.push_back(pkaltrk);
410 ipm.push_back(iGood[i]);
411 p_pm.push_back(pkaltrk);
414 m_dedx_pid[ii] = pid->
chiDedx(2);
415 m_tof1_pid[ii] = pid->
chiTof1(2);
416 m_tof2_pid[ii] = pid->
chiTof2(2);
430 log << MSG::INFO <<
"counter[2]=" << counter[2]<< endreq;
436 p_ptrk.clear(), p_mtrk.clear();
440 for(
int i = 0; i < m_ngch; i++ ){
442 if(!(*itTrk)->isMdcTrackValid())
continue;
444 if(!(*itTrk)->isMdcKalTrackValid())
continue;
449 if (mdcTrk->
charge() > 0 ) {
451 ppKalTrk = mdcKalTrk ;
454 pmKalTrk = mdcKalTrk ;
457 m_charge[ii] = mdcTrk->
charge();
459 double x0=mdcKalTrk->
x();
460 double y0=mdcKalTrk->
y();
461 double z0=mdcKalTrk->
z();
462 double phi0=mdcTrk->
helix(1);
463 double xv=xorigin.x();
464 double yv=xorigin.y();
465 double zv=xorigin.z();
466 double rv=(x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0);
471 m_vr0[ii] = sqrt((x0*x0)+(y0*y0)) ;
475 m_vz[ii] = fabs(z0-zv) ;
476 m_vr[ii] = fabs(rv) ;
479 m_px[ii] = mdcKalTrk->
px();
480 m_py[ii] = mdcKalTrk->
py();
481 m_pz[ii] = mdcKalTrk->
pz();
482 m_p[ii] = mdcKalTrk->
p();
483 m_cos[ii] = mdcKalTrk->
pz()/mdcKalTrk->
p();
484 double temp_e = sqrt(m_p[ii]*m_p[ii] +
xmass[4]*
xmass[4]);
485 HepLorentzVector temp_p(m_px[ii],m_py[ii],m_pz[ii],temp_e);
487 p_ptrk.push_back(temp_p);
489 p_mtrk.push_back(temp_p);
493 double ptrk = mdcKalTrk->
p() ;
494 if ((*itTrk)->isMdcDedxValid()) {
496 m_chie[ii] = dedxTrk->
chiE();
497 m_chimu[ii] = dedxTrk->
chiMu();
498 m_chipi[ii] = dedxTrk->
chiPi();
499 m_chik[ii] = dedxTrk->
chiK();
500 m_chip[ii] = dedxTrk->
chiP();
503 m_probPH[ii]= dedxTrk->
probPH();
504 m_normPH[ii]= dedxTrk->
normPH();
508 if((*itTrk)->isEmcShowerValid()) {
510 m_e_emc[ii] = emcTrk->
energy();
514 if((*itTrk)->isTofTrackValid()) {
516 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
518 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
519 for(;iter_tof != tofTrkCol.end(); iter_tof++ ) {
521 status->
setStatus((*iter_tof)->status());
525 if( status->
layer()!=0 )
continue;
526 double path=(*iter_tof)->path();
527 double tof = (*iter_tof)->tof();
528 double ph = (*iter_tof)->ph();
529 double rhit = (*iter_tof)->zrhit();
530 double qual = 0.0 + (*iter_tof)->quality();
531 double cntr = 0.0 + (*iter_tof)->tofID();
533 for(
int j = 0; j < 5; j++) {
534 double gb = ptrk/
xmass[j];
535 double beta = gb/sqrt(1+gb*gb);
536 texp[j] = path /beta/
velc;
539 m_qual_etof[ii] = qual;
540 m_tof_etof[ii] = tof ;
541 m_te_etof[ii] = tof - texp[0];
542 m_tmu_etof[ii] = tof - texp[1];
543 m_tpi_etof[ii] = tof - texp[2];
544 m_tk_etof[ii] = tof - texp[3];
545 m_tp_etof[ii] = tof - texp[4];
549 if(status->
layer()==1){
550 double path=(*iter_tof)->path();
551 double tof = (*iter_tof)->tof();
552 double ph = (*iter_tof)->ph();
553 double rhit = (*iter_tof)->zrhit();
554 double qual = 0.0 + (*iter_tof)->quality();
555 double cntr = 0.0 + (*iter_tof)->tofID();
557 for(
int j = 0; j < 5; j++) {
558 double gb = ptrk/
xmass[j];
559 double beta = gb/sqrt(1+gb*gb);
560 texp[j] = path /beta/
velc;
563 m_qual_btof1[ii] = qual;
564 m_tof_btof1[ii] = tof ;
565 m_te_btof1[ii] = tof - texp[0];
566 m_tmu_btof1[ii] = tof - texp[1];
567 m_tpi_btof1[ii] = tof - texp[2];
568 m_tk_btof1[ii] = tof - texp[3];
569 m_tp_btof1[ii] = tof - texp[4];
573 if(status->
layer()==2){
574 double path=(*iter_tof)->path();
575 double tof = (*iter_tof)->tof();
576 double ph = (*iter_tof)->ph();
577 double rhit = (*iter_tof)->zrhit();
578 double qual = 0.0 + (*iter_tof)->quality();
579 double cntr = 0.0 + (*iter_tof)->tofID();
581 for(
int j = 0; j < 5; j++) {
582 double gb = ptrk/
xmass[j];
583 double beta = gb/sqrt(1+gb*gb);
584 texp[j] = path /beta/
velc;
587 m_qual_btof2[ii] = qual;
588 m_tof_btof2[ii] = tof ;
589 m_te_btof2[ii] = tof - texp[0];
590 m_tmu_btof2[ii] = tof - texp[1];
591 m_tpi_btof2[ii] = tof - texp[2];
592 m_tk_btof2[ii] = tof - texp[3];
593 m_tp_btof2[ii] = tof - texp[4];
601 log << MSG::INFO <<
"counter[3]=" << counter[3]<< endreq;
608 p_ptrk[0].boost(
u_cms);
609 p_mtrk[0].boost(
u_cms);
610 for (
int i=0; i<=1; i++ ) {
612 if (i==0) p = p_ptrk[0];
613 if (i==1) p = p_mtrk[0];
615 m_bst_px[i] = p.px();
616 m_bst_py[i] = p.py();
617 m_bst_pz[i] = p.pz();
618 m_bst_p[i] = p.rho();
619 m_bst_cos[i]= p.cosTheta();
622 m_m2p = (p_ptrk[0] + p_mtrk[0]).m();
626 m_angle = (p_ptrk[0].vect()).angle((p_mtrk[0]).vect()) * 180.0/(CLHEP::pi) ;
631 double deltatof = 0.0 ;
632 if(m_tof_btof1[0]*m_tof_btof1[1] != 0.0) deltatof+=m_tof_btof1[0]-m_tof_btof1[1];
633 if(m_tof_btof2[0]*m_tof_btof2[1] != 0.0) deltatof+=m_tof_btof2[0]-m_tof_btof2[1];
634 m_deltatof = deltatof ;
643 if (fabs(m_bst_p[0]-1.232)>0.02 ) {
return StatusCode::SUCCESS ; }
644 if (fabs(m_bst_p[1]-1.232)>0.02 ) {
return StatusCode::SUCCESS ; }
645 if (fabs(m_deltatof)>4.0) {
return StatusCode::SUCCESS ; }
646 if (m_angle<178.0) {
return StatusCode::SUCCESS ; }
647 if (m_e_emc[0]>0.7) {
return StatusCode::SUCCESS ; }
650 log << MSG::INFO <<
"counter[4]=" << counter[4]<< endreq;
654 (*(evtRecTrkCol->begin()+iptrk[0]))->tagProton();
655 (*(evtRecTrkCol->begin()+imtrk[0]))->tagProton();
662 (*(evtRecTrkCol->begin()+iptrk[0]))->setQuality(0);
663 (*(evtRecTrkCol->begin()+imtrk[0]))->setQuality(0);
665 setFilterPassed(
true);
668 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hbst_p", h).isSuccess()) {
671 log << MSG::ERROR <<
"Couldn't retrieve hbst_p" << endreq;
674 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hbst_cos", h).isSuccess()) {
675 h->Fill(m_bst_cos[0]);
677 log << MSG::ERROR <<
"Couldn't retrieve hbst_cos" << endreq;
680 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hmpp", h).isSuccess()) {
683 log << MSG::ERROR <<
"Couldn't retrieve hmpp" << endreq;
686 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hangle", h).isSuccess()) {
689 log << MSG::ERROR <<
"Couldn't retrieve hangle" << endreq;
692 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hdeltatof", h).isSuccess()) {
695 log << MSG::ERROR <<
"Couldn't retrieve hdeltatof" << endreq;
698 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/he_emc1", h).isSuccess()) {
701 log << MSG::ERROR <<
"Couldn't retrieve he_emc1" << endreq;
704 if (m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/he_emc2", h).isSuccess()) {
707 log << MSG::ERROR <<
"Couldn't retrieve he_emc2" << endreq;
716 return StatusCode::SUCCESS;