159 {
160
161 MsgStream log(
msgSvc(), name());
162 log << MSG::DEBUG << "in execute()" << endreq;
163
164
165 int event, run;
166
167 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
168 if (!eventHeader) {
169 log << MSG::FATAL <<name() << " Could not find Event Header" << endreq;
170 return( StatusCode::FAILURE);
171 }
172 run=eventHeader->runNumber();
173 event=eventHeader->eventNumber();
175
178
179
180 if(fEventNb!=0&&m_event%fEventNb==0) {
181 log << MSG::FATAL <<m_event<<"-------: "<<run<<","<<event<<endreq;
182 }
183 m_event++;
184 if(fOutput>=2) {
185 log << MSG::DEBUG <<"===================================="<<endreq;
186 log << MSG::DEBUG <<"run= "<<run<<"; event= "<<event<<endreq;
187 }
188
189 Hep3Vector posG;
190#ifndef OnlineMode
192 if(fOutput>=1&&run<0) {
193
194 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
195 if (!mcParticleCol) {
196 log << MSG::WARNING << "Could not find McParticle" << endreq;
197 } else {
198 HepLorentzVector pG;
199 McParticleCol::iterator iter_mc = mcParticleCol->begin();
200 for (;iter_mc != mcParticleCol->end(); iter_mc++) {
201 log << MSG::INFO
202 << " particleId = " << (*iter_mc)->particleProperty()
203 << endreq;
204 pG = (*iter_mc)->initialFourMomentum();
205 posG = (*iter_mc)->initialPosition().v();
206 }
207 ttheta = pG.theta();
208 tphi = pG.phi();
209 if(tphi<0) {
210 tphi=twopi+tphi;
211 }
212 tp = pG.rho();
213
214
215 SmartDataPtr<EmcMcHitCol> emcMcHitCol(eventSvc(),"/Event/MC/EmcMcHitCol");
216 if (!emcMcHitCol) {
217 log << MSG::WARNING << "Could not find EMC truth" << endreq;
218 }
219
221 unsigned int mcTrackIndex;
222 double mcPosX=0,mcPosY=0,mcPosZ=0;
223 double mcPx=0,mcPy=0,mcPz=0;
224 double mcEnergy=0;
225
226 EmcMcHitCol::iterator iterMc;
227 for(iterMc=emcMcHitCol->begin();iterMc!=emcMcHitCol->end();iterMc++){
228 mcId=(*iterMc)->identify();
229 mcTrackIndex=(*iterMc)->getTrackIndex();
230 mcPosX=(*iterMc)->getPositionX();
231 mcPosY=(*iterMc)->getPositionY();
232 mcPosZ=(*iterMc)->getPositionZ();
233 mcPx=(*iterMc)->getPx();
234 mcPy=(*iterMc)->getPy();
235 mcPz=(*iterMc)->getPz();
236 mcEnergy=(*iterMc)->getDepositEnergy();
237
238 if(fOutput>=2){
239
240
241
242
243 }
244 }
245 }
246 }
247 }
248
249#endif
250
251
252 fDigitMap.clear();
253 fHitMap.clear();
254 fClusterMap.clear();
255 fShowerMap.clear();
256
257
259 StatusCode sc = service("EmcCalibConstSvc", emcCalibConstSvc);
260 if(sc != StatusCode::SUCCESS) {
261 ;
262
263 }
264
265 SmartDataPtr<EmcDigiCol> emcDigiCol(eventSvc(),"/Event/Digi/EmcDigiCol");
266 if (!emcDigiCol) {
267 log << MSG::FATAL << "Could not find EMC digi" << endreq;
268 return( StatusCode::FAILURE);
269 }
270
271 EmcDigiCol::iterator iter3;
272 for (iter3=emcDigiCol->begin();iter3!= emcDigiCol->end();iter3++) {
275 (*iter3)->getChargeChannel());
277
278
282
283 int index = emcCalibConstSvc->
getIndex(nnpart,nnthe,nnphi);
285
286
287 if(run>0&&ixtalNumber>0) {
288 unsigned int npartNew=emcCalibConstSvc->
getPartID(ixtalNumber);
289 unsigned int ntheNew=emcCalibConstSvc->
getThetaIndex(ixtalNumber);
290 unsigned int nphiNew=emcCalibConstSvc->
getPhiIndex(ixtalNumber);
292 }
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350 if (run>=52940&&run<=52995){
351 unsigned int ntheNew,nphiNew;
352 ntheNew=nnthe;
353 nphiNew=nnphi;
354 if(nnpart==2) {
355 if (nnthe==0){
356 if (nnphi==58) nphiNew=60;
357 if (nnphi==59) nphiNew=61;
358 if (nnphi==60) nphiNew=58;
359 if (nnphi==61) nphiNew=59;
360 ntheNew=0;
361 }
362 if (nnthe==1){
363 if (nnphi==58) nphiNew=60;
364 if (nnphi==59) nphiNew=61;
365 if (nnphi==60) nphiNew=58;
366 if (nnphi==61) nphiNew=59;
367 ntheNew=1;
368 }
369 if (nnthe==2){
370 if (nnphi==73) nphiNew=75;
371 if (nnphi==74) nphiNew=76;
372 if (nnphi==75) nphiNew=73;
373 if (nnphi==76) nphiNew=74;
374 ntheNew=2;
375
376 }
377 if (nnthe==3){
378 if (nnphi==73) nphiNew=75;
379 if (nnphi==74) nphiNew=76;
380 if (nnphi==75) nphiNew=73;
381 if (nnphi==76) nphiNew=74;
382 ntheNew=3;
383 }
384 if (nnthe==3&&nnphi==72){
385 ntheNew=2;
386 nphiNew=77;
387 }
388 if (nnthe==2&&nnphi==77){
389 ntheNew=3;
390 nphiNew=72;
391 }
392
393 if (nnthe==4){
394 if (nnphi==87) nphiNew=90;
395 if (nnphi==88) nphiNew=91;
396 if (nnphi==89) nphiNew=92;
397 if (nnphi==90) nphiNew=87;
398 if (nnphi==91) nphiNew=88;
399 if (nnphi==92) nphiNew=89;
400 ntheNew=4;
401 }
402 if (nnthe==5){
403 if (nnphi==87) nphiNew=90;
404 if (nnphi==88) nphiNew=91;
405 if (nnphi==89) nphiNew=92;
406 if (nnphi==90) nphiNew=87;
407 if (nnphi==91) nphiNew=88;
408 if (nnphi==92) nphiNew=89;
409 ntheNew=5;
410 }
411
413 }
414 }
415
416
417
418
419
420
421
422 if (ixtalNumber==-9) {
423 adc=0.0;
424 }
425
426
427 if (ixtalNumber==-99) {
428 adc=0.0;
429 }
430
432 aDigit.
Assign(
id,adc,tdc);
433 fDigitMap[id]=aDigit;
434 }
435
436 if(fOutput>=2) {
437 RecEmcDigitMap::iterator iDigitMap;
438 for(iDigitMap=fDigitMap.begin();
439 iDigitMap!=fDigitMap.end();
440 iDigitMap++){
441
442 }
443 }
444
445
446
447
448 fDigit2Hit.
Convert(fDigitMap,fHitMap);
449 if(fOutput>=2) {
450 RecEmcHitMap::iterator iHitMap;
451 for(iHitMap=fHitMap.begin();
452 iHitMap!=fHitMap.end();
453 iHitMap++){
454
455 }
456 fDigit2Hit.
Output(fHitMap);
457 }
458
459
460
461 fHit2Cluster.
Convert(fHitMap,fClusterMap);
462
463 if(fOutput>=2) {
464 RecEmcClusterMap::iterator iClusterMap;
465 for(iClusterMap=fClusterMap.begin();
466 iClusterMap!=fClusterMap.end();
467 iClusterMap++){
468
469 }
470 }
471
472
473 fCluster2Shower->
Convert(fClusterMap,fShowerMap);
474
475 if(fOutput>=2) {
476 RecEmcShowerMap::iterator iShowerMap;
477 for(iShowerMap=fShowerMap.begin();
478 iShowerMap!=fShowerMap.end();
479 iShowerMap++) {
480
481 }
482 }
483
484
485
488 if(fOutput>=2) {
490 }
491
492
493#ifndef OnlineMode
495 if(fOutput>=1) {
496 nrun=run;
497 nrec=event;
498
499
500 ndigi=fDigitMap.size();
501 nhit=fHitMap.size();
502 ncluster=fClusterMap.size();
504 RecEmcShowerMap::iterator iShowerMap;
505 for(iShowerMap=fShowerMap.begin();
506 iShowerMap!=fShowerMap.end();
507 iShowerMap++) {
508 fShowerVec.push_back(iShowerMap->second);
509 }
510 sort(fShowerVec.begin(), fShowerVec.end(), greater<RecEmcShower>());
511 nneu=fShowerMap.size();
512
514
515 RecEmcShowerVec::iterator iShowerVec;
516 iShowerVec=fShowerVec.begin();
517 npart=-99;
518 ntheta=-99;
519 nphi=-99;
520 if(iShowerVec!=fShowerVec.end()) {
521 aShower=*iShowerVec;
530 theta1=(aShower.
position()-posG).theta();
531 phi1=(aShower.
position()-posG).phi();
532 if(phi1<0) {
533 phi1=twopi+phi1;
534 }
540 eseed=aShower.
eSeed();
547 }
553 enseed=fHitMap[nseed].getEnergy();
554 } else {
555 enseed=0;
556 }
557
558 dphi1=phi1-tphi;
559 if(dphi1<-
pi) dphi1=dphi1+twopi;
560 if(dphi1>
pi) dphi1=dphi1-twopi;
561 }
562
563 if(iShowerVec!=fShowerVec.end()) {
564 iShowerVec++;
565 if(iShowerVec!=fShowerVec.end()) {
566 aShower=*iShowerVec;
571 }
572 }
573
574
575 if(fShowerVec.size()>=2) {
576 RecEmcShowerVec::iterator iShowerVec1,iShowerVec2;
577 iShowerVec1=fShowerVec.begin();
578 iShowerVec2=fShowerVec.begin()+1;
579 double e1=(*iShowerVec1).energy();
580 double e2=(*iShowerVec2).energy();
581 double angle=(*iShowerVec1).position().angle((*iShowerVec2).position());
582 mpi0=sqrt(2*
e1*
e2*(1-
cos(angle)));
583 }
584 m_tuple->write();
585 }
586 }
587#endif
588
589 return StatusCode::SUCCESS;
590}
double cos(const BesAngle a)
vector< RecEmcShower > RecEmcShowerVec
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