281 {
282 MsgStream log(
msgSvc(), name());
283 log << MSG::INFO << "in execute()" << endreq;
284
285 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
286 int runNo=eventHeader->runNumber();
287
290 if(evtRecEvent->totalTracks()>evtRecTrkCol->size())return SUCCESS;
291 if(evtRecEvent->totalTracks()>50)return SUCCESS;
292
294 ISvcLocator* svcLocator = Gaudi::svcLocator();
295 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
296 if(sc!=StatusCode::SUCCESS) {
297 cout<<"Error: Can't get EmcRecGeoSvc"<<endl;
298 }
299
300 for(int i = 0; i< evtRecEvent->totalTracks(); i++) {
302 if(!(*itTrk)->isEmcShowerValid())continue;
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
335
336 unsigned int module, ntheta, nphi;
340
341
342
345
346
347 double e5x5=emcTrk->
e5x5();
348 double etof=0;
349
350 if(usetof==1 && (*itTrk)->isTofTrackValid()){
351 SmartRefVector<RecTofTrack> recTofTrackVec=(*itTrk)->tofTrack();
352 if(!recTofTrackVec.empty())etof=recTofTrackVec[0]->energy();
353 if(etof>100.)etof=0;
354 }
355
356 double energyC;
357
358 int thetaId;
359 if (module==0||module==2) thetaId = thetaModule;
360 if (module==1 && thetaModule<=21) thetaId = thetaModule + 6;
361 if (module==1 && thetaModule>21) thetaId = 43 - thetaModule + 6;
362
363 if(MCuseTof==1){
364 energyC=ECorrMC(e5x5+etof,thetaId);
365
366 }
367 if (MCuseTof==0) {
368 energyC=ECorrMC(e5x5,thetaId);
369
370 }
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392 double lnE = std::log(energyC);
393
394 if (energyC>1.0) lnE=std::log(1.0);
395 if (energyC<0.07) lnE=std::log(0.07);
396
397 double lnEcor=1.0;
398 if(dopi0Cor==1){
399 if(
runNo>0 && dodatacor==1) {
400 lnEcor =
ai[0]+
ai[1]*lnE+
ai[2]*lnE*lnE+
ai[3]*lnE*lnE*lnE;
401 }
402 }
403 if(lnEcor<0.5)continue;
404
405
406
407
409
410
411 double enecor=1.;
412 if(hotcellmask==1){
413 for(int ih=0;ih<10;ih++){
414 if(hrunstart[ih]==-1||hrunend[ih]==-1||hcell[ih]==-1)continue;
417 }
418 }
419
420 if(edgecor==1){
421
422 if(module==1) {
423 unsigned int theModule;
424 if(thetaModule>21) {
425 theModule = 43 - thetaModule;
427 pos.setZ(-pos.z());
428 } else {
429 theModule = thetaModule;
430 }
431
432 double IRShift;
433 if(theModule==21) {
434 IRShift = 0;
435
436 } else if(theModule==20) {
437 IRShift = 2.5;
438
439 } else {
440 IRShift = 5.;
441
442 }
443
444
449
450 double theta01,theta23,length,d;
451 theta01 = (center01-IR).theta();
452 theta23 = (center23-IR).theta();
453 length = (center01-IR).mag();
454 d = length*
tan(theta01-theta23);
455
456 double xIn;
457 xIn = length*
tan(theta01-(pos-IR).theta())-d/2;
458 if (xIn < (-d/2) && theModule!=21){
459
460 theModule=theModule+1 ;
461
463 if(theModule==21) {
464 IRShift = 0;
465
466 } else if(theModule==20) {
467 IRShift = 2.5;
468
469 } else {
470 IRShift = 5.;
471
472 }
474 IR=IR1;
477 theta01 = (center01-IR).theta();
478 theta23 = (center23-IR).theta();
479 length = (center01-IR).mag();
480 d = length*
tan(theta01-theta23);
481
482 xIn = length*
tan(theta01-(pos-IR).theta())-d/2;
483
484 } else if (xIn > (d/2) && theModule!=0 ){
485
486 theModule=theModule-1 ;
488 if(theModule==21) {
489 IRShift = 0;
490
491 } else if(theModule==20) {
492 IRShift = 2.5;
493
494 } else {
495 IRShift = 5.;
496
497 }
498
500 IR=IR1;
503 theta01 = (center01-IR).theta();
504 theta23 = (center23-IR).theta();
505 length = (center01-IR).mag();
506 d = length*
tan(theta01-theta23);
507
508 xIn = length*
tan(theta01-(pos-IR).theta())-d/2;
509 }
510
511 double yIn;
512
513
514
515 yIn = pos.phi() < 0 ? pos.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
516 : pos.phi()*180./CLHEP::pi-phiModule*3.-1.843;
517
518 if(nphi==0&&yIn>100) yIn=yIn-360;
519 if(nphi==119&&yIn<-100) yIn=yIn+360;
520
521 if(yIn<-1.5-0.15){
522
523 if(nphi!=0) phiModule=phiModule-1;
524 if(nphi==0) phiModule=119;
525 yIn = pos.phi() < 0 ? pos.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
526 : pos.phi()*180./CLHEP::pi-phiModule*3.-1.843;
527 if(phiModule==0&&yIn>100) yIn=yIn-360;
528 if(phiModule==119&&yIn<-100) yIn=yIn+360;
529
530 }
531
532 if(yIn>1.5-0.15){
533
534
535 if(nphi!=119) phiModule=phiModule+1;
536 if(nphi==119) phiModule=0;
537
538 yIn = pos.phi() < 0 ? pos.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
539 : pos.phi()*180./CLHEP::pi-phiModule*3.-1.843;
540 if(phiModule==0&&yIn>100) yIn=yIn-360;
541 if(phiModule==119&&yIn<-100) yIn=yIn+360;
542 }
543
544 enecor=m_par[theModule][0]
545 +m_par[theModule][1]*xIn
546 +m_par[theModule][2]*xIn*xIn
547 +m_par[theModule][3]*xIn*xIn*xIn
548 +m_par[theModule][4]*xIn*xIn*xIn*xIn
549 +m_par[theModule][5]*xIn*xIn*xIn*xIn*xIn
550 +m_par[theModule][6]*xIn*xIn*xIn*xIn*xIn*xIn
551
552
553 +m_par[theModule][7]*yIn
554 +m_par[theModule][8]*yIn*yIn
555 +m_par[theModule][9]*yIn*yIn*yIn
556 +m_par[theModule][10]*yIn*yIn*yIn*yIn;
557
558 } else{
559 enecor=1;
560 }
561 }
562
563
564 double energyCC= energyC/(lnEcor*enecor);
565
567
568 if(ntOut==true){
569 m_ef=energyCC;
571 m_ec=energyC;
572 m_ct=lnEcor ;
573 m_cedge=enecor;
574 m_tuple1->write();
575 }
576
577
578 }
579
581 if(!recEmcShowerCol){
582 return( StatusCode::SUCCESS);
583 }
585 if(!dstEmcShowerCol){
586 return( StatusCode::SUCCESS);
587 }
588
589
590 if(recEmcShowerCol->size()!=dstEmcShowerCol->size())return SUCCESS;
591 for(int i=0;i<recEmcShowerCol->size();i++){
592 RecEmcShowerCol::iterator iter_rec = recEmcShowerCol->begin()+i;
593 DstEmcShowerCol::iterator iter_dst = dstEmcShowerCol->begin()+i;
594
595 (*iter_dst)->setEnergy((*iter_rec)->energy());
596 (*iter_dst)->setStatus((*iter_rec)->status());
597
598
599 }
600 return( StatusCode::SUCCESS);
601}
EvtRecTrackCol::iterator EvtRecTrackIterator
double tan(const BesAngle a)
HepPoint3D position() 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 HepPoint3D GetCrystalPoint(const Identifier &id, const int i) const =0
_EXTERN_ std::string DstEmcShowerCol
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol
_EXTERN_ std::string RecEmcShowerCol