130 {
131
132 MsgStream log(
msgSvc(), name() );
133 log << MSG::INFO << "in execute()" << endmsg;
134
135 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
136
137
138
139
140
141
142 int run = eventHeader->runNumber();
143 int event = eventHeader->eventNumber();
144
145 if ( event % 1000 == 0 ) cout << " run,event: " << run << "," << event << endl;
146
148 if ( !evtRecEvent )
149 {
150 cout << " evtRecEvent " << endl;
151 return StatusCode::FAILURE;
152 }
153
154 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
155 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
157 if ( !evtRecTrkCol )
158 {
159 cout << " evtRecTrkCol " << endl;
160 return StatusCode::FAILURE;
161 }
162
163 m_events++;
164 setFilterPassed( false );
165
167 iGood.clear();
168
169 double ene5x5, theta, phi, eseed;
170 double showerX, showerY, showerZ;
171 long int thetaIndex, phiIndex;
172
174 unsigned int npart;
175
177 ipip.clear();
178 ipim.clear();
180 ppip.clear();
181 ppim.clear();
182
183 vector<RecEmcShower*> GoodShowers;
184 GoodShowers.clear();
186 for ( int i = 0; i < evtRecEvent->totalTracks(); i++ )
187 {
188 if ( i >= evtRecTrkCol->size() ) break;
190 if ( ( *itTrk )->isEmcShowerValid() )
191 {
192 RecEmcShower* theShower = ( *itTrk )->emcShower();
196 ene5x5 = theShower->
e5x5();
199 if ( ene5x5 > 0.4 && ene5x5 < 4 && npart == 1 && ( m_BarrelOrEndcap == 1 ) )
200 {
201 GoodShowers.push_back( theShower );
202 iGood.push_back( ( *itTrk )->trackId() );
203 }
204 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( npart == 2 || npart == 0 ) &&
205 ( m_BarrelOrEndcap == 2 ) )
206 {
207 GoodShowers.push_back( theShower );
208 iGood.push_back( ( *itTrk )->trackId() );
209 }
210 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( m_BarrelOrEndcap == 0 ) )
211 {
212 GoodShowers.push_back( theShower );
213 iGood.push_back( ( *itTrk )->trackId() );
214 }
215 }
216
217 }
218
219
220
221 double MaxE( 0 ), MaxPhi, MaxThe;
222 int MaxId;
223 double SecE( 0 ), SecPhi, SecThe;
224 for ( int i = 0; i < GoodShowers.size(); i++ )
225 {
226 RecEmcShower* theShower = GoodShowers[i];
227 double eraw = theShower->
energy();
228 if ( eraw > MaxE )
229 {
230 MaxId = i;
231 MaxE = eraw;
232 MaxPhi = theShower->
phi();
233 MaxThe = theShower->
theta();
234 }
235 }
236 for ( int i = 0; i < GoodShowers.size(); i++ )
237 {
238 RecEmcShower* theShower = GoodShowers[i];
239 double eraw = theShower->
energy();
240 if ( i != MaxId && eraw > SecE )
241 {
242 SecE = eraw;
243 SecPhi = theShower->
phi();
244 SecThe = theShower->
theta();
245 }
246 }
247
248 double dphi = ( fabs( MaxPhi - SecPhi ) -
PI ) * 180. /
PI;
249 double dthe = ( fabs( MaxThe + SecThe ) -
PI ) * 180. /
PI;
250
251 int total1 = 0;
252 int total2 = 0;
253 if ( GoodShowers.size() >= 2 && MaxE > 1.0 &&
abs( dthe ) < 3 &&
254 ( ( dphi > -25 && dphi < -4 ) || ( dphi > 2 && dphi < 20 ) ) &&
etot > 2.7 )
255 {
256
257 double phi1 = MaxPhi < 0 ? MaxPhi + CLHEP::twopi : MaxPhi;
258 double phi2 = SecPhi < 0 ? SecPhi + CLHEP::twopi : SecPhi;
259
260
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;
267
268 SmartDataPtr<MdcDigiCol> mdcDigiCol( evtSvc(), "/Event/Digi/MdcDigiCol" );
269 if ( !mdcDigiCol )
270 {
271 log << MSG::FATAL << "Could not find MdcDigiCol!" << endmsg;
272 return StatusCode::FAILURE;
273 }
274 int hitnum = mdcDigiCol->size();
275 for ( int i = 0; i < hitnum; i++ )
276 {
277 MdcDigi* digi = dynamic_cast<MdcDigi*>( mdcDigiCol->containedObject( i ) );
280 if (
time == 0x7FFFFFFF || charge == 0x7FFFFFFF )
continue;
284 if ( ilayer >= 43 )
285 log << MSG::ERROR << "MDC(" << ilayer << "," << iphi << ")" << endmsg;
286 double phi = CLHEP::twopi * iphi / idmax[ilayer];
289
290
291 }
292
293 if ( ( m_BarrelOrEndcap == 1 && total1 > 15 && total2 > 15 ) ||
294 ( m_BarrelOrEndcap != 1 && total1 > 5 && total2 > 5 ) )
295 {
296 setFilterPassed( true );
298 }
299 }
300
301 if ( m_output )
302 {
304 m_mdc_hit1 = total1;
305 m_mdc_hit2 = total2;
306 m_sh1_ene = MaxE;
307 m_sh1_theta = MaxThe;
308 m_sh1_phi = MaxPhi;
309 m_sh2_ene = SecE;
310 m_sh2_theta = SecThe;
311 m_sh2_phi = SecPhi;
312 m_di_phi = dphi;
313 m_di_the = dthe;
314 m_tuple1->write();
315 }
316
317 return StatusCode::SUCCESS;
318}
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
bool WhetherSector(double, double=0., double=CLHEP::twopi)
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
static int wire(const Identifier &id)
virtual Identifier identify() const
unsigned int getChargeChannel() const
unsigned int getTimeChannel() const
RecEmcID getShowerId() const
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol