77 MsgStream log(
msgSvc(), name() );
79 log << MSG::INFO <<
"in initialize()" << endmsg;
83 if ( service(
"THistSvc", m_thsvc ).isFailure() )
85 log << MSG::ERROR <<
"Couldn't get THistSvc" << endmsg;
86 return StatusCode::FAILURE;
91 TH1F* hbst_p =
new TH1F(
"bst_p",
"bst_p", 80, 1.15, 1.31 );
92 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hbst_p", hbst_p ).isFailure() )
93 { log << MSG::ERROR <<
"Couldn't register bst_p" << endmsg; }
95 TH1F* hbst_cos =
new TH1F(
"bst_cos",
"bst_cos", 20, -1.0, 1.0 );
96 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hbst_cos", hbst_cos ).isFailure() )
97 { log << MSG::ERROR <<
"Couldn't register bst_cos" << endmsg; }
99 TH1F* hmpp =
new TH1F(
"mpp",
"mpp", 100, 3.05, 3.15 );
100 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hmpp", hmpp ).isFailure() )
101 { log << MSG::ERROR <<
"Couldn't register mpp" << endmsg; }
103 TH1F* hangle =
new TH1F(
"angle",
"angle", 50, 175.0, 180. );
104 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hangle", hangle ).isFailure() )
105 { log << MSG::ERROR <<
"Couldn't register angle" << endmsg; }
107 TH1F* hdeltatof =
new TH1F(
"deltatof",
"deltatof", 50, -10., 10. );
108 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/hdeltatof", hdeltatof ).isFailure() )
109 { log << MSG::ERROR <<
"Couldn't register deltatof" << endmsg; }
111 TH1F* he_emc1 =
new TH1F(
"e_emc1",
"e_emc1", 100, 0.0, 2.0 );
112 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/he_emc1", he_emc1 ).isFailure() )
113 { log << MSG::ERROR <<
"Couldn't register e_emc1" << endmsg; }
115 TH1F* he_emc2 =
new TH1F(
"e_emc2",
"e_emc2", 100, 0.0, 2.0 );
116 if ( m_thsvc->regHist(
"/DQAHist/DQAJpsi2PPbar/he_emc2", he_emc2 ).isFailure() )
117 { log << MSG::ERROR <<
"Couldn't register e_emc2" << endmsg; }
124 NTuplePtr nt1(
ntupleSvc(),
"DQAFILE/DQAJpsi2PPbar" );
125 if ( nt1 ) m_tuple = nt1;
128 m_tuple =
ntupleSvc()->book(
"DQAFILE/DQAJpsi2PPbar", CLID_ColumnWiseTuple,
"N-Tuple" );
131 status = m_tuple->addItem(
"runNo", m_runNo );
132 status = m_tuple->addItem(
"event", m_event );
133 status = m_tuple->addItem(
"Nchrg", m_nchrg );
134 status = m_tuple->addItem(
"Nneu", m_nneu );
135 status = m_tuple->addItem(
"ngch", m_ngch, 0, 10 );
137 status = m_tuple->addIndexedItem(
"charge", m_ngch, m_charge );
138 status = m_tuple->addIndexedItem(
"vx0", m_ngch, m_vx0 );
139 status = m_tuple->addIndexedItem(
"vy0", m_ngch, m_vy0 );
140 status = m_tuple->addIndexedItem(
"vz0", m_ngch, m_vz0 );
141 status = m_tuple->addIndexedItem(
"vr0", m_ngch, m_vr0 );
143 status = m_tuple->addIndexedItem(
"vx", m_ngch, m_vx );
144 status = m_tuple->addIndexedItem(
"vy", m_ngch, m_vy );
145 status = m_tuple->addIndexedItem(
"vz", m_ngch, m_vz );
146 status = m_tuple->addIndexedItem(
"vr", m_ngch, m_vr );
148 status = m_tuple->addIndexedItem(
"px", m_ngch, m_px );
149 status = m_tuple->addIndexedItem(
"py", m_ngch, m_py );
150 status = m_tuple->addIndexedItem(
"pz", m_ngch, m_pz );
151 status = m_tuple->addIndexedItem(
"p", m_ngch, m_p );
152 status = m_tuple->addIndexedItem(
"cos", m_ngch, m_cos );
154 status = m_tuple->addIndexedItem(
"bst_px", m_ngch, m_bst_px );
155 status = m_tuple->addIndexedItem(
"bst_py", m_ngch, m_bst_py );
156 status = m_tuple->addIndexedItem(
"bst_pz", m_ngch, m_bst_pz );
157 status = m_tuple->addIndexedItem(
"bst_p", m_ngch, m_bst_p );
158 status = m_tuple->addIndexedItem(
"bst_cos", m_ngch, m_bst_cos );
160 status = m_tuple->addIndexedItem(
"chie", m_ngch, m_chie );
161 status = m_tuple->addIndexedItem(
"chimu", m_ngch, m_chimu );
162 status = m_tuple->addIndexedItem(
"chipi", m_ngch, m_chipi );
163 status = m_tuple->addIndexedItem(
"chik", m_ngch, m_chik );
164 status = m_tuple->addIndexedItem(
"chip", m_ngch, m_chip );
165 status = m_tuple->addIndexedItem(
"ghit", m_ngch, m_ghit );
166 status = m_tuple->addIndexedItem(
"thit", m_ngch, m_thit );
167 status = m_tuple->addIndexedItem(
"probPH", m_ngch, m_probPH );
168 status = m_tuple->addIndexedItem(
"normPH", m_ngch, m_normPH );
170 status = m_tuple->addIndexedItem(
"e_emc", m_ngch, m_e_emc );
172 status = m_tuple->addIndexedItem(
"qual_etof", m_ngch, m_qual_etof );
173 status = m_tuple->addIndexedItem(
"tof_etof", m_ngch, m_tof_etof );
174 status = m_tuple->addIndexedItem(
"te_etof", m_ngch, m_te_etof );
175 status = m_tuple->addIndexedItem(
"tmu_etof", m_ngch, m_tmu_etof );
176 status = m_tuple->addIndexedItem(
"tpi_etof", m_ngch, m_tpi_etof );
177 status = m_tuple->addIndexedItem(
"tk_etof", m_ngch, m_tk_etof );
178 status = m_tuple->addIndexedItem(
"tp_etof", m_ngch, m_tp_etof );
180 status = m_tuple->addIndexedItem(
"qual_btof1", m_ngch, m_qual_btof1 );
181 status = m_tuple->addIndexedItem(
"tof_btof1", m_ngch, m_tof_btof1 );
182 status = m_tuple->addIndexedItem(
"te_btof1", m_ngch, m_te_btof1 );
183 status = m_tuple->addIndexedItem(
"tmu_btof1", m_ngch, m_tmu_btof1 );
184 status = m_tuple->addIndexedItem(
"tpi_btof1", m_ngch, m_tpi_btof1 );
185 status = m_tuple->addIndexedItem(
"tk_btof1", m_ngch, m_tk_btof1 );
186 status = m_tuple->addIndexedItem(
"tp_btof1", m_ngch, m_tp_btof1 );
188 status = m_tuple->addIndexedItem(
"qual_btof2", m_ngch, m_qual_btof2 );
189 status = m_tuple->addIndexedItem(
"tof_btof2", m_ngch, m_tof_btof2 );
190 status = m_tuple->addIndexedItem(
"te_btof2", m_ngch, m_te_btof2 );
191 status = m_tuple->addIndexedItem(
"tmu_btof2", m_ngch, m_tmu_btof2 );
192 status = m_tuple->addIndexedItem(
"tpi_btof2", m_ngch, m_tpi_btof2 );
193 status = m_tuple->addIndexedItem(
"tk_btof2", m_ngch, m_tk_btof2 );
194 status = m_tuple->addIndexedItem(
"tp_btof2", m_ngch, m_tp_btof2 );
196 status = m_tuple->addIndexedItem(
"dedx_pid", m_ngch, m_dedx_pid );
197 status = m_tuple->addIndexedItem(
"tof1_pid", m_ngch, m_tof1_pid );
198 status = m_tuple->addIndexedItem(
"tof2_pid", m_ngch, m_tof2_pid );
199 status = m_tuple->addIndexedItem(
"prob_pi", m_ngch, m_prob_pi );
200 status = m_tuple->addIndexedItem(
"prob_k", m_ngch, m_prob_k );
201 status = m_tuple->addIndexedItem(
"prob_p", m_ngch, m_prob_p );
203 status = m_tuple->addItem(
"np", m_np );
204 status = m_tuple->addItem(
"npb", m_npb );
206 status = m_tuple->addItem(
"m2p", m_m2p );
207 status = m_tuple->addItem(
"angle", m_angle );
208 status = m_tuple->addItem(
"deltatof", m_deltatof );
210 status = m_tuple->addItem(
"vtx_m2p", m_vtx_m2p );
211 status = m_tuple->addItem(
"vtx_angle", m_vtx_angle );
213 status = m_tuple->addItem(
"m_chi2_4c", m_chi2_4c );
214 status = m_tuple->addItem(
"m_m2p_4c", m_m2p_4c );
215 status = m_tuple->addItem(
"m_angle_4c", m_angle_4c );
219 log << MSG::ERROR <<
" Cannot book N-tuple:" << long( m_tuple ) << endmsg;
220 return StatusCode::FAILURE;
228 log << MSG::INFO <<
"successfully return from initialize()" << endmsg;
229 return StatusCode::SUCCESS;
235 MsgStream log(
msgSvc(), name() );
236 log << MSG::INFO <<
"in execute()" << endmsg;
238 setFilterPassed(
false );
241 log << MSG::INFO <<
"counter[0]=" << counter[0] << endmsg;
243 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
245 m_runNo = eventHeader->runNumber();
246 m_event = eventHeader->eventNumber();
247 m_nchrg = evtRecEvent->totalCharged();
248 m_nneu = evtRecEvent->totalNeutral();
250 log << MSG::INFO <<
"ncharg, nneu, tottks = " << evtRecEvent->totalCharged() <<
" , "
251 << evtRecEvent->totalNeutral() <<
" , " << evtRecEvent->totalTracks() << endmsg;
259 Vint iGood, iptrk, imtrk;
264 Hep3Vector xorigin( 0, 0, 0 );
268 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc ).ignore();
275 xorigin.setX( dbv[0] );
276 xorigin.setY( dbv[1] );
277 xorigin.setZ( dbv[2] );
278 log << MSG::INFO <<
"xorigin.x=" << xorigin.x() <<
", "
279 <<
"xorigin.y=" << xorigin.y() <<
", "
280 <<
"xorigin.z=" << xorigin.z() <<
", " << endmsg;
283 for (
int i = 0; i < evtRecEvent->totalCharged(); i++ )
286 if ( !( *itTrk )->isMdcTrackValid() )
continue;
287 if ( !( *itTrk )->isMdcKalTrackValid() )
continue;
289 double x0 = mdcTrk->
x();
290 double y0 = mdcTrk->
y();
291 double z0 = mdcTrk->
z();
292 double phi0 = mdcTrk->
helix( 1 );
293 double xv = xorigin.x();
294 double yv = xorigin.y();
295 double zv = xorigin.z();
296 double rv = ( x0 - xv ) *
cos( phi0 ) + ( y0 - yv ) *
sin( phi0 );
297 double cost =
cos( mdcTrk->
theta() );
298 if ( fabs( z0 - zv ) >= m_vz1cut )
continue;
299 if ( fabs( rv ) >= m_vr1cut )
continue;
302 iGood.push_back( i );
303 nCharge += mdcTrk->
charge();
305 if ( mdcTrk->
charge() > 0 ) { iptrk.push_back( i ); }
306 else { imtrk.push_back( i ); }
311 int nGood = iGood.size();
312 m_ngch = iGood.size();
313 log << MSG::INFO <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endmsg;
314 if ( ( nGood != 2 ) || ( nCharge != 0 ) ) {
return StatusCode::SUCCESS; }
316 log << MSG::INFO <<
"counter[1]=" << counter[1] << endmsg;
333 for (
int i = 0; i < nGood; i++ )
337 if ( !( *itTrk )->isMdcTrackValid() )
continue;
339 if ( !( *itTrk )->isMdcKalTrackValid() )
continue;
365 if ( prob_p > prob_pi && prob_p > prob_k )
368 HepLorentzVector pkaltrk;
371 pkaltrk.setPx( mdcKalTrk->
px() );
372 pkaltrk.setPy( mdcKalTrk->
py() );
373 pkaltrk.setPz( mdcKalTrk->
pz() );
374 double p3 = pkaltrk.mag();
375 pkaltrk.setE( sqrt( p3 * p3 +
xmass[4] *
xmass[4] ) );
377 if ( mdcTrk->
charge() > 0 )
380 ipp.push_back( iGood[i] );
381 p_pp.push_back( pkaltrk );
386 ipm.push_back( iGood[i] );
387 p_pm.push_back( pkaltrk );
390 m_dedx_pid[ii] = pid->
chiDedx( 2 );
391 m_tof1_pid[ii] = pid->
chiTof1( 2 );
392 m_tof2_pid[ii] = pid->
chiTof2( 2 );
405 log << MSG::INFO <<
"counter[2]=" << counter[2] << endmsg;
411 p_ptrk.clear(), p_mtrk.clear();
415 for (
int i = 0; i < m_ngch; i++ )
418 if ( !( *itTrk )->isMdcTrackValid() )
continue;
420 if ( !( *itTrk )->isMdcKalTrackValid() )
continue;
425 if ( mdcTrk->
charge() > 0 )
428 ppKalTrk = mdcKalTrk;
433 pmKalTrk = mdcKalTrk;
436 m_charge[ii] = mdcTrk->
charge();
438 double x0 = mdcKalTrk->
x();
439 double y0 = mdcKalTrk->
y();
440 double z0 = mdcKalTrk->
z();
441 double phi0 = mdcTrk->
helix( 1 );
442 double xv = xorigin.x();
443 double yv = xorigin.y();
444 double zv = xorigin.z();
445 double rv = ( x0 - xv ) *
cos( phi0 ) + ( y0 - yv ) *
sin( phi0 );
450 m_vr0[ii] = sqrt( ( x0 * x0 ) + ( y0 * y0 ) );
454 m_vz[ii] = fabs( z0 - zv );
455 m_vr[ii] = fabs( rv );
458 m_px[ii] = mdcKalTrk->
px();
459 m_py[ii] = mdcKalTrk->
py();
460 m_pz[ii] = mdcKalTrk->
pz();
461 m_p[ii] = sqrt( m_px[ii] * m_px[ii] + m_py[ii] * m_py[ii] + m_pz[ii] * m_pz[ii] );
462 m_cos[ii] = m_pz[ii] / m_p[ii];
463 double temp_e = sqrt( m_p[ii] * m_p[ii] +
xmass[4] *
xmass[4] );
464 HepLorentzVector temp_p( m_px[ii], m_py[ii], m_pz[ii], temp_e );
465 if ( i == 0 ) { p_ptrk.push_back( temp_p ); }
466 else { p_mtrk.push_back( temp_p ); }
468 double ptrk = m_p[ii];
469 if ( ( *itTrk )->isMdcDedxValid() )
472 m_chie[ii] = dedxTrk->
chiE();
473 m_chimu[ii] = dedxTrk->
chiMu();
474 m_chipi[ii] = dedxTrk->
chiPi();
475 m_chik[ii] = dedxTrk->
chiK();
476 m_chip[ii] = dedxTrk->
chiP();
479 m_probPH[ii] = dedxTrk->
probPH();
480 m_normPH[ii] = dedxTrk->
normPH();
483 if ( ( *itTrk )->isEmcShowerValid() )
486 m_e_emc[ii] = emcTrk->
energy();
489 if ( ( *itTrk )->isTofTrackValid() )
492 SmartRefVector<RecTofTrack> tofTrkCol = ( *itTrk )->tofTrack();
494 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
495 for ( ; iter_tof != tofTrkCol.end(); iter_tof++ )
498 status->
setStatus( ( *iter_tof )->status() );
503 if ( status->
layer() != 0 )
continue;
504 double path = ( *iter_tof )->path();
505 double tof = ( *iter_tof )->tof();
506 double ph = ( *iter_tof )->ph();
507 double rhit = ( *iter_tof )->zrhit();
508 double qual = 0.0 + ( *iter_tof )->quality();
509 double cntr = 0.0 + ( *iter_tof )->tofID();
511 for (
int j = 0; j < 5; j++ )
513 double gb = ptrk /
xmass[j];
514 double beta = gb / sqrt( 1 + gb * gb );
515 texp[j] = path / beta /
velc;
518 m_qual_etof[ii] = qual;
519 m_tof_etof[ii] = tof;
520 m_te_etof[ii] = tof - texp[0];
521 m_tmu_etof[ii] = tof - texp[1];
522 m_tpi_etof[ii] = tof - texp[2];
523 m_tk_etof[ii] = tof - texp[3];
524 m_tp_etof[ii] = tof - texp[4];
529 if ( status->
layer() == 1 )
531 double path = ( *iter_tof )->path();
532 double tof = ( *iter_tof )->tof();
533 double ph = ( *iter_tof )->ph();
534 double rhit = ( *iter_tof )->zrhit();
535 double qual = 0.0 + ( *iter_tof )->quality();
536 double cntr = 0.0 + ( *iter_tof )->tofID();
538 for (
int j = 0; j < 5; j++ )
540 double gb = ptrk /
xmass[j];
541 double beta = gb / sqrt( 1 + gb * gb );
542 texp[j] = path / beta /
velc;
545 m_qual_btof1[ii] = qual;
546 m_tof_btof1[ii] = tof;
547 m_te_btof1[ii] = tof - texp[0];
548 m_tmu_btof1[ii] = tof - texp[1];
549 m_tpi_btof1[ii] = tof - texp[2];
550 m_tk_btof1[ii] = tof - texp[3];
551 m_tp_btof1[ii] = tof - texp[4];
554 if ( status->
layer() == 2 )
556 double path = ( *iter_tof )->path();
557 double tof = ( *iter_tof )->tof();
558 double ph = ( *iter_tof )->ph();
559 double rhit = ( *iter_tof )->zrhit();
560 double qual = 0.0 + ( *iter_tof )->quality();
561 double cntr = 0.0 + ( *iter_tof )->tofID();
563 for (
int j = 0; j < 5; j++ )
565 double gb = ptrk /
xmass[j];
566 double beta = gb / sqrt( 1 + gb * gb );
567 texp[j] = path / beta /
velc;
570 m_qual_btof2[ii] = qual;
571 m_tof_btof2[ii] = tof;
572 m_te_btof2[ii] = tof - texp[0];
573 m_tmu_btof2[ii] = tof - texp[1];
574 m_tpi_btof2[ii] = tof - texp[2];
575 m_tk_btof2[ii] = tof - texp[3];
576 m_tp_btof2[ii] = tof - texp[4];
584 log << MSG::INFO <<
"counter[3]=" << counter[3] << endmsg;
590 p_ptrk[0].boost(
u_cms );
591 p_mtrk[0].boost(
u_cms );
592 for (
int i = 0; i <= 1; i++ )
595 if ( i == 0 ) p = p_ptrk[0];
596 if ( i == 1 ) p = p_mtrk[0];
598 m_bst_px[i] = p.px();
599 m_bst_py[i] = p.py();
600 m_bst_pz[i] = p.pz();
601 m_bst_p[i] = p.rho();
602 m_bst_cos[i] = p.cosTheta();
605 m_m2p = ( p_ptrk[0] + p_mtrk[0] ).m();
609 m_angle = ( p_ptrk[0].vect() ).angle( ( p_mtrk[0] ).vect() ) * 180.0 / ( CLHEP::pi );
614 double deltatof = 0.0;
615 if ( m_tof_btof1[0] * m_tof_btof1[1] != 0.0 ) deltatof += m_tof_btof1[0] - m_tof_btof1[1];
616 if ( m_tof_btof2[0] * m_tof_btof2[1] != 0.0 ) deltatof += m_tof_btof2[0] - m_tof_btof2[1];
617 m_deltatof = deltatof;
624 if ( fabs( m_bst_p[0] - 1.232 ) > 0.02 ) {
return StatusCode::SUCCESS; }
625 if ( fabs( m_bst_p[1] - 1.232 ) > 0.02 ) {
return StatusCode::SUCCESS; }
626 if ( fabs( m_deltatof ) > 4.0 ) {
return StatusCode::SUCCESS; }
627 if ( m_angle < 178.0 ) {
return StatusCode::SUCCESS; }
628 if ( m_e_emc[0] > 0.7 ) {
return StatusCode::SUCCESS; }
631 log << MSG::INFO <<
"counter[4]=" << counter[4] << endmsg;
635 ( *( evtRecTrkCol->begin() + iptrk[0] ) )->tagProton();
636 ( *( evtRecTrkCol->begin() + imtrk[0] ) )->tagProton();
643 ( *( evtRecTrkCol->begin() + iptrk[0] ) )->setQuality( 0 );
644 ( *( evtRecTrkCol->begin() + imtrk[0] ) )->setQuality( 0 );
646 setFilterPassed(
true );
649 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hbst_p", h ).isSuccess() )
650 { h->Fill( m_bst_p[0] ); }
651 else { log << MSG::ERROR <<
"Couldn't retrieve hbst_p" << endmsg; }
653 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hbst_cos", h ).isSuccess() )
654 { h->Fill( m_bst_cos[0] ); }
655 else { log << MSG::ERROR <<
"Couldn't retrieve hbst_cos" << endmsg; }
657 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hmpp", h ).isSuccess() ) { h->Fill( m_m2p ); }
658 else { log << MSG::ERROR <<
"Couldn't retrieve hmpp" << endmsg; }
660 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hangle", h ).isSuccess() )
661 { h->Fill( m_angle ); }
662 else { log << MSG::ERROR <<
"Couldn't retrieve hangle" << endmsg; }
664 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/hdeltatof", h ).isSuccess() )
665 { h->Fill( m_deltatof ); }
666 else { log << MSG::ERROR <<
"Couldn't retrieve hdeltatof" << endmsg; }
668 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/he_emc1", h ).isSuccess() )
669 { h->Fill( m_e_emc[0] ); }
670 else { log << MSG::ERROR <<
"Couldn't retrieve he_emc1" << endmsg; }
672 if ( m_thsvc->getHist(
"/DQAHist/DQAJpsi2PPbar/he_emc2", h ).isSuccess() )
673 { h->Fill( m_e_emc[1] ); }
674 else { log << MSG::ERROR <<
"Couldn't retrieve he_emc2" << endmsg; }
676 m_tuple->write().ignore();
678 return StatusCode::SUCCESS;