Reconstruction begins. State 1: Initialize digit map
157 {
158
159 MsgStream log(
msgSvc(), name());
160 log << MSG::DEBUG << "in execute()" << endreq;
161
162
163 int event, run;
164
165 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
166 if (!eventHeader) {
167 log << MSG::FATAL <<name() << " Could not find Event Header" << endreq;
168 return( StatusCode::FAILURE);
169 }
170 run=eventHeader->runNumber();
171 event=eventHeader->eventNumber();
173
176
177
178 if(fEventNb!=0&&m_event%fEventNb==0) {
179 log << MSG::FATAL <<m_event<<"-------: "<<run<<","<<event<<endreq;
180 }
181 m_event++;
182 if(fOutput>=2) {
183 log << MSG::DEBUG <<"===================================="<<endreq;
184 log << MSG::DEBUG <<"run= "<<run<<"; event= "<<event<<endreq;
185 }
186
187 Hep3Vector posG;
188#ifndef OnlineMode
190 if(fOutput>=1&&run<0) {
191
192 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
193 if (!mcParticleCol) {
194 log << MSG::WARNING << "Could not find McParticle" << endreq;
195 } else {
196 HepLorentzVector pG;
197 McParticleCol::iterator iter_mc = mcParticleCol->begin();
198 for (;iter_mc != mcParticleCol->end(); iter_mc++) {
199 log << MSG::INFO
200 << " particleId = " << (*iter_mc)->particleProperty()
201 << endreq;
202 pG = (*iter_mc)->initialFourMomentum();
203 posG = (*iter_mc)->initialPosition().v();
204 }
205 ttheta = pG.theta();
206 tphi = pG.phi();
207 if(tphi<0) {
208 tphi=twopi+tphi;
209 }
210 tp = pG.rho();
211
212
213 SmartDataPtr<EmcMcHitCol> emcMcHitCol(eventSvc(),"/Event/MC/EmcMcHitCol");
214 if (!emcMcHitCol) {
215 log << MSG::WARNING << "Could not find EMC truth" << endreq;
216 }
217
219 unsigned int mcTrackIndex;
220 double mcPosX=0,mcPosY=0,mcPosZ=0;
221 double mcPx=0,mcPy=0,mcPz=0;
222 double mcEnergy=0;
223
224 EmcMcHitCol::iterator iterMc;
225 for(iterMc=emcMcHitCol->begin();iterMc!=emcMcHitCol->end();iterMc++){
226 mcId=(*iterMc)->identify();
227 mcTrackIndex=(*iterMc)->getTrackIndex();
228 mcPosX=(*iterMc)->getPositionX();
229 mcPosY=(*iterMc)->getPositionY();
230 mcPosZ=(*iterMc)->getPositionZ();
231 mcPx=(*iterMc)->getPx();
232 mcPy=(*iterMc)->getPy();
233 mcPz=(*iterMc)->getPz();
234 mcEnergy=(*iterMc)->getDepositEnergy();
235
236 if(fOutput>=2){
237
238
239
240
241 }
242 }
243 }
244 }
245 }
246
247#endif
248
249
250 fDigitMap.clear();
251 fHitMap.clear();
252 fClusterMap.clear();
253 fShowerMap.clear();
254
255
257 StatusCode sc = service("EmcCalibConstSvc", emcCalibConstSvc);
258 if(sc != StatusCode::SUCCESS) {
259 ;
260
261 }
262
263 SmartDataPtr<EmcDigiCol> emcDigiCol(eventSvc(),"/Event/Digi/EmcDigiCol");
264 if (!emcDigiCol) {
265 log << MSG::FATAL << "Could not find EMC digi" << endreq;
266 return( StatusCode::FAILURE);
267 }
268
269 EmcDigiCol::iterator iter3;
270 for (iter3=emcDigiCol->begin();iter3!= emcDigiCol->end();iter3++) {
273 (*iter3)->getChargeChannel());
275
276
280
281 int index = emcCalibConstSvc->
getIndex(nnpart,nnthe,nnphi);
283
284
285 if(run>0&&ixtalNumber>0) {
286 unsigned int npartNew=emcCalibConstSvc->
getPartID(ixtalNumber);
287 unsigned int ntheNew=emcCalibConstSvc->
getThetaIndex(ixtalNumber);
288 unsigned int nphiNew=emcCalibConstSvc->
getPhiIndex(ixtalNumber);
290 }
291
292
293 if (ixtalNumber==-9) {
294 adc=0.0;
295 }
296
297
298 if (ixtalNumber==-99) {
299 adc=0.0;
300 }
301
303 aDigit.
Assign(
id,adc,tdc);
304 fDigitMap[id]=aDigit;
305 }
306
307 if(fOutput>=2) {
308 RecEmcDigitMap::iterator iDigitMap;
309 for(iDigitMap=fDigitMap.begin();
310 iDigitMap!=fDigitMap.end();
311 iDigitMap++){
312
313 }
314 }
315
316
317
318
319 fDigit2Hit.
Convert(fDigitMap,fHitMap);
320 if(fOutput>=2) {
321 RecEmcHitMap::iterator iHitMap;
322 for(iHitMap=fHitMap.begin();
323 iHitMap!=fHitMap.end();
324 iHitMap++){
325
326 }
327 fDigit2Hit.
Output(fHitMap);
328 }
329
330
331
332 fHit2Cluster.
Convert(fHitMap,fClusterMap);
333
334 if(fOutput>=2) {
335 RecEmcClusterMap::iterator iClusterMap;
336 for(iClusterMap=fClusterMap.begin();
337 iClusterMap!=fClusterMap.end();
338 iClusterMap++){
339
340 }
341 }
342
343
344 fCluster2Shower->
Convert(fClusterMap,fShowerMap);
345
346 if(fOutput>=2) {
347 RecEmcShowerMap::iterator iShowerMap;
348 for(iShowerMap=fShowerMap.begin();
349 iShowerMap!=fShowerMap.end();
350 iShowerMap++) {
351
352 }
353 }
354
355
356
359 if(fOutput>=2) {
361 }
362
363
364#ifndef OnlineMode
366 if(fOutput>=1) {
367 nrun=run;
368 nrec=event;
369
370
371 ndigi=fDigitMap.size();
372 nhit=fHitMap.size();
373 ncluster=fClusterMap.size();
375 RecEmcShowerMap::iterator iShowerMap;
376 for(iShowerMap=fShowerMap.begin();
377 iShowerMap!=fShowerMap.end();
378 iShowerMap++) {
379 fShowerVec.push_back(iShowerMap->second);
380 }
381 sort(fShowerVec.begin(), fShowerVec.end(), greater<RecEmcShower>());
382 nneu=fShowerMap.size();
383
385
386 RecEmcShowerVec::iterator iShowerVec;
387 iShowerVec=fShowerVec.begin();
388 npart=-99;
389 ntheta=-99;
390 nphi=-99;
391 if(iShowerVec!=fShowerVec.end()) {
392 aShower=*iShowerVec;
401 theta1=(aShower.
position()-posG).theta();
402 phi1=(aShower.
position()-posG).phi();
403 if(phi1<0) {
404 phi1=twopi+phi1;
405 }
411 eseed=aShower.
eSeed();
418 }
424 enseed=fHitMap[nseed].getEnergy();
425 } else {
426 enseed=0;
427 }
428
429 dphi1=phi1-tphi;
430 if(dphi1<-
pi) dphi1=dphi1+twopi;
431 if(dphi1>
pi) dphi1=dphi1-twopi;
432 }
433
434 if(iShowerVec!=fShowerVec.end()) {
435 iShowerVec++;
436 if(iShowerVec!=fShowerVec.end()) {
437 aShower=*iShowerVec;
442 }
443 }
444
445
446 if(fShowerVec.size()>=2) {
447 RecEmcShowerVec::iterator iShowerVec1,iShowerVec2;
448 iShowerVec1=fShowerVec.begin();
449 iShowerVec2=fShowerVec.begin()+1;
450 double e1=(*iShowerVec1).energy();
451 double e2=(*iShowerVec2).energy();
452 double angle=(*iShowerVec1).position().angle((*iShowerVec2).position());
453 mpi0=sqrt(2*
e1*
e2*(1-
cos(angle)));
454 }
455 m_tuple->write();
456 }
457 }
458#endif
459
460 return StatusCode::SUCCESS;
461}
vector< RecEmcShower > RecEmcShowerVec
double cos(const BesAngle a)
HepPoint3D position() const
double secondMoment() const
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
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)
virtual void Convert(RecEmcClusterMap &aClusterMap, RecEmcShowerMap &aShowerMap)=0
void Convert(const RecEmcDigitMap &aDigitMap, RecEmcHitMap &aHitMap)
void Output(const RecEmcHitMap &aHitMap) const
void Convert(const RecEmcHitMap &aHitMap, RecEmcClusterMap &aClusterMap)
void SetDataMode(double en)
StatusCode RegisterToTDS(RecEmcHitMap &aHitMap, RecEmcClusterMap &aClusterMap, RecEmcShowerMap &aShowerMap)
StatusCode CheckRegister()
virtual unsigned int getPartID(int Index) const =0
virtual int getIxtalNumber(int No) const =0
virtual unsigned int getPhiIndex(int Index) const =0
virtual unsigned int getThetaIndex(int Index) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
virtual bool isOnlineMode()=0
bool is_valid() const
Check if id is in a valid state.
static double EmcTime(int timeChannel)
static double EmcCharge(int measure, int chargeChannel)
double getSecondMoment() const
void Assign(const RecEmcID &CellId, const RecEmcADC &ADC, const RecEmcTDC &TDC)
RecEmcID getShowerId() const
RecEmcCluster * getCluster() const
RecEmcEnergy getETof2x1() const
RecEmcID NearestSeed() const
RecEmcEnergy getETof2x3() const