138 {
139
140 setFilterPassed( false );
141
142 MsgStream log(
msgSvc(), name() );
143 log << MSG::INFO << "in execute()" << endmsg;
144
145 m_events++;
146
147 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
148 if ( !eventHeader )
149 {
150 cout << " eventHeader " << endl;
151 return StatusCode::FAILURE;
152 }
153
154 int run = eventHeader->runNumber();
155 int event = eventHeader->eventNumber();
156 if ( event % 1000 == 0 ) cout << " run,event: " << run << "," << event << endl;
157
159 if ( !evtRecEvent )
160 {
161 cout << " evtRecEvent " << endl;
162 return StatusCode::FAILURE;
163 }
164
165 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
166 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
168 if ( !evtRecTrkCol )
169 {
170 cout << " evtRecTrkCol " << endl;
171 return StatusCode::FAILURE;
172 }
173
175 iGood.clear();
176
177 double ene5x5, theta, phi, eseed;
178 double showerX, showerY, showerZ;
179 long int thetaIndex, phiIndex;
180
182 unsigned int npart;
183
185 ipip.clear();
186 ipim.clear();
188 ppip.clear();
189 ppim.clear();
190
191 vector<RecEmcShower*> GoodShowers;
192 GoodShowers.clear();
194 for ( int i = 0; i < evtRecEvent->totalTracks(); i++ )
195 {
196 if ( i >= evtRecTrkCol->size() ) break;
198 if ( ( *itTrk )->isEmcShowerValid() )
199 {
200 RecEmcShower* theShower = ( *itTrk )->emcShower();
204 ene5x5 = theShower->
e5x5();
207 if ( ene5x5 > 0.4 && ene5x5 < 4 && npart == 1 && ( m_BarrelOrEndcap == 1 ) )
208 {
209 GoodShowers.push_back( theShower );
210 iGood.push_back( ( *itTrk )->trackId() );
211 }
212 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( npart == 2 || npart == 0 ) &&
213 ( m_BarrelOrEndcap == 2 ) )
214 {
215 GoodShowers.push_back( theShower );
216 iGood.push_back( ( *itTrk )->trackId() );
217 }
218 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( m_BarrelOrEndcap == 0 ) )
219 {
220 GoodShowers.push_back( theShower );
221 iGood.push_back( ( *itTrk )->trackId() );
222 }
223 }
224
225 }
226
227
228
229 double MaxE( 0 ), MaxPhi, MaxThe;
230 int MaxId;
231 double SecE( 0 ), SecPhi, SecThe;
232 for ( int i = 0; i < GoodShowers.size(); i++ )
233 {
234 RecEmcShower* theShower = GoodShowers[i];
235 double eraw = theShower->
energy();
236 if ( eraw > MaxE )
237 {
238 MaxId = i;
239 MaxE = eraw;
240 MaxPhi = theShower->
phi();
241 MaxThe = theShower->
theta();
242 }
243 }
244 for ( int i = 0; i < GoodShowers.size(); i++ )
245 {
246 RecEmcShower* theShower = GoodShowers[i];
247 double eraw = theShower->
energy();
248 if ( i != MaxId && eraw > SecE )
249 {
250 SecE = eraw;
251 SecPhi = theShower->
phi();
252 SecThe = theShower->
theta();
253 }
254 }
255
256 double dphi = ( fabs( MaxPhi - SecPhi ) -
PI ) * 180. /
PI;
257 double dthe = ( fabs( MaxThe + SecThe ) -
PI ) * 180. /
PI;
258 if ( GoodShowers.size() >= 2 && SecE > 1.0 && dphi > -4 && dphi < 2 &&
abs( dthe ) < 3 &&
260 {
261 setFilterPassed( true );
263 }
264
265 if ( m_output )
266 {
268 m_sh1_ene = MaxE;
269 m_sh1_theta = MaxThe;
270 m_sh1_phi = MaxPhi;
271 m_sh2_ene = SecE;
272 m_sh2_theta = SecThe;
273 m_sh2_phi = SecPhi;
274 m_di_phi = dphi;
275 m_di_the = dthe;
276 m_tuple1->write();
277 }
278
279 return StatusCode::SUCCESS;
280}
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
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)
RecEmcID getShowerId() const
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol