40int BhabhaPreSelect::idmax[43] = { 40, 44, 48, 56, 64, 72, 80, 80, 76, 76, 88,
41 88, 100, 100, 112, 112, 128, 128, 140, 140, 160, 160,
42 160, 160, 176, 176, 176, 176, 208, 208, 208, 208, 240,
43 240, 240, 240, 256, 256, 256, 256, 288, 288, 288 };
59 MsgStream log(
msgSvc(), name() );
61 log << MSG::INFO <<
"in initialize()" << endmsg;
62 cout <<
" BarrelOrEndcap " << m_BarrelOrEndcap << endl;
67 NTuplePtr nt1(
ntupleSvc(),
"FILE1/bhabha" );
68 if ( nt1 ) m_tuple1 = nt1;
71 m_tuple1 =
ntupleSvc()->book(
"FILE1/bhabha", CLID_ColumnWiseTuple,
"N-Tuple example" );
74 status = m_tuple1->addItem(
"sh1_ene", m_sh1_ene );
75 status = m_tuple1->addItem(
"sh1_theta", m_sh1_theta );
76 status = m_tuple1->addItem(
"sh1_phi", m_sh1_phi );
77 status = m_tuple1->addItem(
"sh2_ene", m_sh2_ene );
78 status = m_tuple1->addItem(
"sh2_theta", m_sh2_theta );
79 status = m_tuple1->addItem(
"sh2_phi", m_sh2_phi );
80 status = m_tuple1->addItem(
"di_phi", m_di_phi );
81 status = m_tuple1->addItem(
"di_the", m_di_the );
82 status = m_tuple1->addItem(
"acolli", m_acolli );
83 status = m_tuple1->addItem(
"etot", m_etot );
84 status = m_tuple1->addItem(
"mdc_hit1", m_mdc_hit1 );
85 status = m_tuple1->addItem(
"mdc_hit2", m_mdc_hit2 );
89 log << MSG::ERROR <<
" Cannot book N-tuple:" << long( m_tuple1 ) << endmsg;
90 return StatusCode::FAILURE;
94 NTuplePtr nt2(
ntupleSvc(),
"FILE1/bha1" );
95 if ( nt2 ) m_tuple2 = nt2;
98 m_tuple2 =
ntupleSvc()->book(
"FILE1/bha1", CLID_ColumnWiseTuple,
"N-Tuple example" );
101 status = m_tuple2->addItem(
"sh_ene", m_sh_ene );
102 status = m_tuple2->addItem(
"sh_theta", m_sh_theta );
103 status = m_tuple2->addItem(
"sh_phi", m_sh_phi );
107 log << MSG::ERROR <<
" Cannot book N-tuple:" << long( m_tuple2 ) << endmsg;
108 return StatusCode::FAILURE;
119 m_oneProngsSelected = 0;
120 m_twoProngsMatchedSelected = 0;
121 m_twoProngsOneMatchedSelected = 0;
122 m_selectedTrkID1 = 999;
123 m_selectedTrkID2 = 999;
125 log << MSG::INFO <<
"successfully return from initialize()" << endmsg;
126 return StatusCode::SUCCESS;
132 MsgStream log(
msgSvc(), name() );
133 log << MSG::INFO <<
"in execute()" << endmsg;
135 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
142 int run = eventHeader->runNumber();
143 int event = eventHeader->eventNumber();
145 if ( event % 1000 == 0 ) cout <<
" run,event: " << run <<
"," <<
event << endl;
150 cout <<
" evtRecEvent " << endl;
151 return StatusCode::FAILURE;
154 log << MSG::DEBUG <<
"ncharg, nneu, tottks = " << evtRecEvent->totalCharged() <<
" , "
155 << evtRecEvent->totalNeutral() <<
" , " << evtRecEvent->totalTracks() << endmsg;
159 cout <<
" evtRecTrkCol " << endl;
160 return StatusCode::FAILURE;
164 setFilterPassed(
false );
169 double ene5x5, theta, phi, eseed;
170 double showerX, showerY, showerZ;
171 long int thetaIndex, phiIndex;
183 vector<RecEmcShower*> GoodShowers;
186 for (
int i = 0; i < evtRecEvent->totalTracks(); i++ )
188 if ( i >= evtRecTrkCol->size() )
break;
190 if ( ( *itTrk )->isEmcShowerValid() )
196 ene5x5 = theShower->
e5x5();
199 if ( ene5x5 > 0.4 && ene5x5 < 4 && npart == 1 && ( m_BarrelOrEndcap == 1 ) )
201 GoodShowers.push_back( theShower );
202 iGood.push_back( ( *itTrk )->trackId() );
204 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( npart == 2 || npart == 0 ) &&
205 ( m_BarrelOrEndcap == 2 ) )
207 GoodShowers.push_back( theShower );
208 iGood.push_back( ( *itTrk )->trackId() );
210 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( m_BarrelOrEndcap == 0 ) )
212 GoodShowers.push_back( theShower );
213 iGood.push_back( ( *itTrk )->trackId() );
221 double MaxE( 0 ), MaxPhi, MaxThe;
223 double SecE( 0 ), SecPhi, SecThe;
224 for (
int i = 0; i < GoodShowers.size(); i++ )
227 double eraw = theShower->
energy();
232 MaxPhi = theShower->
phi();
233 MaxThe = theShower->
theta();
236 for (
int i = 0; i < GoodShowers.size(); i++ )
239 double eraw = theShower->
energy();
240 if ( i != MaxId && eraw > SecE )
243 SecPhi = theShower->
phi();
244 SecThe = theShower->
theta();
248 double dphi = ( fabs( MaxPhi - SecPhi ) -
PI ) * 180. /
PI;
249 double dthe = ( fabs( MaxThe + SecThe ) -
PI ) * 180. /
PI;
253 if ( GoodShowers.size() >= 2 && MaxE > 1.0 &&
abs( dthe ) < 3 &&
254 ( ( dphi > -25 && dphi < -4 ) || ( dphi > 2 && dphi < 20 ) ) &&
etot > 2.7 )
257 double phi1 = MaxPhi < 0 ? MaxPhi + CLHEP::twopi : MaxPhi;
258 double phi2 = SecPhi < 0 ? SecPhi + CLHEP::twopi : SecPhi;
263 double phi12 = ( phi11 + phi22 - CLHEP::pi ) * 0.5;
264 double phi21 = ( phi11 + phi22 + CLHEP::pi ) * 0.5;
265 if ( phi12 < 0. ) phi12 += CLHEP::twopi;
266 if ( phi21 > CLHEP::twopi ) phi21 -= CLHEP::twopi;
268 SmartDataPtr<MdcDigiCol> mdcDigiCol( evtSvc(),
"/Event/Digi/MdcDigiCol" );
271 log << MSG::FATAL <<
"Could not find MdcDigiCol!" << endmsg;
272 return StatusCode::FAILURE;
274 int hitnum = mdcDigiCol->size();
275 for (
int i = 0; i < hitnum; i++ )
277 MdcDigi* digi =
dynamic_cast<MdcDigi*
>( mdcDigiCol->containedObject( i ) );
280 if (
time == 0x7FFFFFFF || charge == 0x7FFFFFFF )
continue;
285 log << MSG::ERROR <<
"MDC(" << ilayer <<
"," << iphi <<
")" << endmsg;
286 double phi = CLHEP::twopi * iphi / idmax[ilayer];
293 if ( ( m_BarrelOrEndcap == 1 && total1 > 15 && total2 > 15 ) ||
294 ( m_BarrelOrEndcap != 1 && total1 > 5 && total2 > 5 ) )
296 setFilterPassed(
true );
307 m_sh1_theta = MaxThe;
310 m_sh2_theta = SecThe;
317 return StatusCode::SUCCESS;