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