25 40, 44, 48, 56, 64, 72, 80, 80, 76, 76, 88, 88, 100, 100, 112,
26 112, 128, 128, 140, 140, 160, 160, 160, 160, 176, 176, 176, 176, 208, 208,
30 info() <<
"In initialize()" << endmsg;
32 m_bhabhaEmcECut = 0.7 * m_ecm;
33 m_bhabhaMaxECut = 0.3 * m_ecm;
34 m_bhabhaSecECut = 0.1 * m_ecm;
35 m_dimuEHighCut = 0.27 * m_ecm;
36 m_dimuELowCut = 0.027 * m_ecm;
37 m_diphotonEmcECut = 0.7 * m_ecm;
38 m_diphotonSecECut = 0.3 * m_ecm;
39 m_hadronChaECut = 0.3 * m_ecm;
40 m_hadronNeuECut = 0.3 * m_ecm;
44 m_bhabhaEmcECut = 0.7 * m_ecm;
45 m_bhabhaMaxECut = 0.15 * m_ecm;
46 m_bhabhaSecECut = 0.05 * m_ecm;
47 m_diphotonEmcECut = 0.7 * m_ecm;
48 m_diphotonSecECut = 0.2 * m_ecm;
51 info() <<
"Creating tools..." << endmsg;
54 std::vector<std::string> tools_to_retrieve;
57 tools_to_retrieve.push_back(
"SelectBarrelBhabha" );
58 tools_to_retrieve.push_back(
"SelectEndcapBhabha" );
63 tools_to_retrieve.push_back(
"SelectBarrelDimu" );
64 tools_to_retrieve.push_back(
"SelectEndcapDimu" );
67 if ( m_selectDiphoton )
69 tools_to_retrieve.push_back(
"SelectBarrelDiphoton" );
70 tools_to_retrieve.push_back(
"SelectEndcapDiphoton" );
73 if ( m_selectHadron ) { tools_to_retrieve.push_back(
"SelectHadron" ); }
75 for (
const auto& tool_name : tools_to_retrieve )
78 StatusCode sc = toolSvc()->retrieveTool(
"EventWriterTool", tool_name, tool,
this );
81 error() <<
"Error retrieving tool " << tool_name << endmsg;
84 else info() <<
"Successfully retrieved tool " << tool_name << endmsg;
86 m_preSelTools[tool_name] = tool;
92 StatusCode sc = toolSvc()->retrieveTool(
"DimuPreSelectTool", m_dimuTool,
this );
95 error() <<
"Error retrieving tool DimuPreSelectTool" << endmsg;
98 else info() <<
"Successfully retrieved tool DimuPreSelectTool" << endmsg;
104 NTuplePtr nt0(
ntupleSvc(),
"FILE1/hadron" );
105 if ( nt0 ) m_tuple0 = nt0;
108 m_tuple0 =
ntupleSvc()->book(
"FILE1/hadron", CLID_ColumnWiseTuple,
"N-Tuple example" );
111 status = m_tuple0->addItem(
"esum", m_esum );
112 status = m_tuple0->addItem(
"eemc", m_eemc );
113 status = m_tuple0->addItem(
"etot", m_etot );
114 status = m_tuple0->addItem(
"nGood", m_nGood );
115 status = m_tuple0->addItem(
"nCharge", m_nCharge );
116 status = m_tuple0->addItem(
"nGam", m_nGam );
117 status = m_tuple0->addItem(
"ptot", m_ptot );
118 status = m_tuple0->addItem(
"pp", m_pp );
119 status = m_tuple0->addItem(
"pm", m_pm );
120 status = m_tuple0->addItem(
"run", m_runnb );
121 status = m_tuple0->addItem(
"event", m_evtnb );
122 status = m_tuple0->addItem(
"maxE", m_maxE );
123 status = m_tuple0->addItem(
"secE", m_secE );
124 status = m_tuple0->addItem(
"dthe", m_dThe );
125 status = m_tuple0->addItem(
"dphi", m_dPhi );
126 status = m_tuple0->addItem(
"mdcHit1", m_mdcHit1 );
127 status = m_tuple0->addItem(
"mdcHit2", m_mdcHit2 );
131 error() <<
" Cannot book N-tuple:" << long( m_tuple0 ) << endmsg;
132 return StatusCode::FAILURE;
136 NTuplePtr nt1(
ntupleSvc(),
"FILE1/vxyz" );
137 if ( nt1 ) m_tuple1 = nt1;
140 m_tuple1 =
ntupleSvc()->book(
"FILE1/vxyz", CLID_ColumnWiseTuple,
"ks N-Tuple example" );
143 status = m_tuple1->addItem(
"vx0", m_vx0 );
144 status = m_tuple1->addItem(
"vy0", m_vy0 );
145 status = m_tuple1->addItem(
"vz0", m_vz0 );
146 status = m_tuple1->addItem(
"vr0", m_vr0 );
147 status = m_tuple1->addItem(
"theta0", m_theta0 );
148 status = m_tuple1->addItem(
"p0", m_p0 );
149 status = m_tuple1->addItem(
"pt0", m_pt0 );
153 error() <<
" Cannot book N-tuple:" << long( m_tuple1 ) << endmsg;
154 return StatusCode::FAILURE;
158 NTuplePtr nt2(
ntupleSvc(),
"FILE1/photon" );
159 if ( nt2 ) m_tuple2 = nt2;
163 ntupleSvc()->book(
"FILE1/photon", CLID_ColumnWiseTuple,
"ks N-Tuple example" );
166 status = m_tuple2->addItem(
"dthe", m_dthe );
167 status = m_tuple2->addItem(
"dphi", m_dphi );
168 status = m_tuple2->addItem(
"dang", m_dang );
169 status = m_tuple2->addItem(
"eraw", m_eraw );
173 error() <<
" Cannot book N-tuple:" << long( m_tuple2 ) << endmsg;
174 return StatusCode::FAILURE;
180 NTuplePtr nt3(
ntupleSvc(),
"FILE1/dimu" );
181 if ( nt3 ) m_tuple3 = nt3;
185 ntupleSvc()->book(
"FILE1/dimu", CLID_ColumnWiseTuple,
"ks N-Tuple example" );
186 if ( m_tuple3 ) { m_dimuTool->BookNtuple( m_tuple3 ); }
189 error() <<
" Cannot book N-tuple:" << long( m_tuple3 ) << endmsg;
190 return StatusCode::FAILURE;
197 m_barrelBhabhaNumber = 0;
198 m_endcapBhabhaNumber = 0;
199 m_barrelDimuNumber = 0;
200 m_endcapDimuNumber = 0;
202 m_barrelDiphotonNumber = 0;
203 m_endcapDiphotonNumber = 0;
205 info() <<
"successfully return from initialize()" << endmsg;
206 return StatusCode::SUCCESS;
210 info() <<
"In execute" << endmsg;
212 bool isBarrelBhabha =
false;
213 bool isEndcapBhabha =
false;
214 bool isBarrelDimu =
false;
215 bool isEndcapDimu =
false;
216 bool isHadron =
false;
217 bool isBarrelDiphoton =
false;
218 bool isEndcapDiphoton =
false;
220 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
223 error() <<
"Could not retrieve event header" << endmsg;
224 return StatusCode::FAILURE;
227 int run = eventHeader->runNumber();
228 int event = eventHeader->eventNumber();
234 error() <<
"Could not retrieve EvtRecEvent" << endmsg;
235 return StatusCode::FAILURE;
238 debug() <<
"ncharg, nneu, tottks = " << evtRecEvent->totalCharged() <<
" , "
239 << evtRecEvent->totalNeutral() <<
" , " << evtRecEvent->totalTracks() << endmsg;
244 error() <<
"Could not retrieve EvtRecTrackCol" << endmsg;
245 return StatusCode::FAILURE;
248 if ( evtRecEvent->totalTracks() != evtRecTrkCol->size() )
return StatusCode::SUCCESS;
251 std::vector<EvtRecTrack*> goodTracks;
254 for (
int i = 0; i < evtRecEvent->totalCharged(); i++ )
260 double vx0 = mdcTrk->
x();
261 double vy0 = mdcTrk->
y();
262 double vz0 = mdcTrk->
z();
263 double vr0 = mdcTrk->
r();
264 double theta0 = mdcTrk->
theta();
265 double p0 = mdcTrk->
p();
266 double pt0 = mdcTrk->
pxy();
277 m_tuple1->write().ignore();
280 if ( fabs( vz0 ) >= m_vz0cut )
continue;
281 if ( vr0 >= m_vr0cut )
continue;
282 if ( pt0 >= m_pt0HighCut )
continue;
283 if ( pt0 <= m_pt0LowCut )
continue;
285 goodTracks.push_back( recTrk );
286 nCharge += mdcTrk->
charge();
288 int nGood = goodTracks.size();
291 std::vector<EvtRecTrack*> goodGammas;
292 for (
int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++ )
298 double eraw = emcTrk->
energy();
302 m_tuple2->write().ignore();
305 if ( eraw < m_energyThreshold )
continue;
306 goodGammas.push_back( recTrk );
308 int nGam = goodGammas.size();
311 Vp4 ppip{ 0 }, ppim{ 0 };
320 for (
const auto& goodTrk : goodTracks )
322 if ( goodTrk->isMdcTrackValid() )
335 HepLorentzVector ptrk;
336 ptrk.setPx( mdcTrk->
px() );
337 ptrk.setPy( mdcTrk->
py() );
338 ptrk.setPz( mdcTrk->
pz() );
339 double p3 = ptrk.mag();
340 ptrk.setE( sqrt( p3 * p3 +
mpi *
mpi ) );
341 ptrk = ptrk.boost( -0.011, 0, 0 );
346 if ( mdcTrk->
charge() > 0 )
348 ppip.push_back( ptrk );
353 ppim.push_back( ptrk );
358 if ( goodTrk->isEmcShowerValid() )
361 double eraw = emcTrk->
energy();
362 double phi = emcTrk->
phi();
363 double the = emcTrk->
theta();
365 HepLorentzVector ptrk;
366 ptrk.setPx( eraw *
sin( the ) *
cos( phi ) );
367 ptrk.setPy( eraw *
sin( the ) *
sin( phi ) );
368 ptrk.setPz( eraw *
cos( the ) );
370 ptrk = ptrk.boost( -0.011, 0, 0 );
381 for (
const auto& goodGamTrk : goodGammas )
384 double eraw = emcTrk->
energy();
385 double phi = emcTrk->
phi();
386 double the = emcTrk->
theta();
387 HepLorentzVector ptrk;
388 ptrk.setPx( eraw *
sin( the ) *
cos( phi ) );
389 ptrk.setPy( eraw *
sin( the ) *
sin( phi ) );
390 ptrk.setPz( eraw *
cos( the ) );
392 ptrk = ptrk.boost( -0.011, 0, 0 );
393 pGam.push_back( ptrk );
399 double esum = echarge + eneu;
404 double maxThe = 999.;
405 double maxPhi = 999.;
406 double secThe = 999.;
407 double secPhi = 999.;
414 SmartDataPtr<RecEmcShowerCol> aShowerCol( eventSvc(),
"/Event/Recon/RecEmcShowerCol" );
417 warning() <<
"Could not find RecEmcShowerCol" << endmsg;
418 return StatusCode::SUCCESS;
422 RecEmcShowerCol::iterator iShowerCol;
423 for ( iShowerCol = aShowerCol->begin(); iShowerCol != aShowerCol->end(); iShowerCol++ )
428 maxE = ( *iShowerCol )->e5x5();
429 maxThe = ( *iShowerCol )->theta();
430 maxPhi = ( *iShowerCol )->phi();
431 npart = ( *iShowerCol )->module();
433 else if ( ishower == 1 )
435 secE = ( *iShowerCol )->e5x5();
436 secThe = ( *iShowerCol )->theta();
437 secPhi = ( *iShowerCol )->phi();
439 else if ( ishower == 2 ) {
break; }
444 if ( aShowerCol->size() >= 2 )
446 dphi = ( fabs( maxPhi - secPhi ) - CLHEP::pi ) * 180. / CLHEP::pi;
447 dthe = ( fabs( maxThe + secThe ) - CLHEP::pi ) * 180. / CLHEP::pi;
449 double phi1 = maxPhi < 0 ? maxPhi + CLHEP::twopi : maxPhi;
450 double phi2 = secPhi < 0 ? secPhi + CLHEP::twopi : secPhi;
455 double phi12 = ( phi11 + phi22 - CLHEP::pi ) * 0.5;
456 double phi21 = ( phi11 + phi22 + CLHEP::pi ) * 0.5;
457 if ( phi12 < 0. ) phi12 += CLHEP::twopi;
458 if ( phi21 > CLHEP::twopi ) phi21 -= CLHEP::twopi;
460 SmartDataPtr<MdcDigiCol> mdcDigiCol( evtSvc(),
"/Event/Digi/MdcDigiCol" );
463 error() <<
"Could not find MdcDigiCol!" << endmsg;
464 return StatusCode::FAILURE;
466 int hitnum = mdcDigiCol->size();
467 for (
int i = 0; i < hitnum; i++ )
469 MdcDigi* digi =
dynamic_cast<MdcDigi*
>( mdcDigiCol->containedObject( i ) );
473 if (
time == 0x7FFFFFFF || charge == 0x7FFFFFFF )
continue;
479 if ( ilayer >= 43 ) error() <<
"MDC(" << ilayer <<
"," << iphi <<
")" << endmsg;
481 double phi = CLHEP::twopi * iphi / idmax[ilayer];
483 if ( WhetherSector( phi, phi11, phi12 ) ) mdcHit1++;
484 else if ( WhetherSector( phi, phi21, phi22 ) ) mdcHit2++;
493 if ( eemc > m_bhabhaEmcECut && maxE > m_bhabhaMaxECut && secE > m_bhabhaSecECut &&
494 abs( dthe ) < m_bhabhaDTheCut &&
495 ( ( dphi > m_bhabhaDPhiCut1 && dphi < m_bhabhaDPhiCut2 ) ||
496 ( dphi > m_bhabhaDPhiCut3 && dphi < m_bhabhaDPhiCut4 ) ) )
498 if ( npart == 1 && mdcHit1 > m_bhabhaMdcHitCutB && mdcHit2 > m_bhabhaMdcHitCutB )
500 isBarrelBhabha =
true;
501 m_barrelBhabhaNumber++;
503 else if ( ( npart == 0 || npart == 2 ) && mdcHit1 > m_bhabhaMdcHitCutE &&
504 mdcHit2 > m_bhabhaMdcHitCutE )
506 isEndcapBhabha =
true;
507 m_endcapBhabhaNumber++;
514 if ( m_dimuTool->IsDimu() == 1 )
517 m_barrelDimuNumber++;
519 else if ( m_dimuTool->IsDimu() == 2 )
522 m_endcapDimuNumber++;
527 if ( ( nGood >= 1 && esum > m_hadronChaECut ) || ( nGood == 0 && esum > m_hadronNeuECut ) )
534 if ( nGood == 0 && eemc > m_diphotonEmcECut && secE > m_diphotonSecECut &&
535 fabs( dthe ) < m_diphotonDTheCut && dphi > m_diphotonDPhiCut1 &&
536 dphi < m_diphotonDPhiCut2 )
540 isBarrelDiphoton =
true;
541 m_barrelDiphotonNumber++;
543 else if ( npart == 0 || npart == 2 )
545 isEndcapDiphoton =
true;
546 m_endcapDiphotonNumber++;
551 if ( m_selectBhabha && isBarrelBhabha )
552 m_preSelTools[
"SelectBarrelBhabha"]->write().ignore();
553 if ( m_selectBhabha && isEndcapBhabha )
554 m_preSelTools[
"SelectEndcapBhabha"]->write().ignore();
556 if ( m_selectDimu && isBarrelDimu ) m_preSelTools[
"SelectBarrelDimu"]->write().ignore();
557 if ( m_selectDimu && isEndcapDimu ) m_preSelTools[
"SelectEndcapDimu"]->write().ignore();
559 if ( m_selectHadron && isHadron ) m_preSelTools[
"SelectHadron"]->write().ignore();
561 if ( m_selectDiphoton && isBarrelDiphoton )
562 m_preSelTools[
"SelectBarrelDiphoton"]->write().ignore();
563 if ( m_selectDiphoton && isEndcapDiphoton )
564 m_preSelTools[
"SelectEndcapDiphoton"]->write().ignore();
585 m_tuple0->write().ignore();
588 return StatusCode::SUCCESS;