213 {
214 MsgStream log(
msgSvc(), name());
215 log << MSG::INFO << "in execute()" << endreq;
216
217 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
218 int runNo=eventHeader->runNumber();
219
222 if(evtRecEvent->totalTracks()>evtRecTrkCol->size())return SUCCESS;
223 if(evtRecEvent->totalTracks()>50)return SUCCESS;
224
226 ISvcLocator* svcLocator = Gaudi::svcLocator();
227 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
228 if(sc!=StatusCode::SUCCESS) {
229 cout<<"Error: Can't get EmcRecGeoSvc"<<endl;
230 }
231
232 for(int i = 0; i< evtRecEvent->totalTracks(); i++) {
234 if(!(*itTrk)->isEmcShowerValid())continue;
236
237 int st = emcTrk->
status();
238 if(st>10000)continue;
240
241 if(emcTrk->
e5x5()<0.015)
continue;
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257 double etof=0;
258
259 if(usetof==1 && (*itTrk)->isTofTrackValid()){
260 SmartRefVector<RecTofTrack> recTofTrackVec=(*itTrk)->tofTrack();
261 if(!recTofTrackVec.empty())etof=recTofTrackVec[0]->energy();
262 if(etof>100.)etof=0;
263 }
264 double energyC=emcTrk->
energy()+etof;
265
266
267
268
269
270
271
272
273
274
275 double lnE = std::log(energyC);
276 double lnEcor=1.0;
277 if(
runNo>0 && dodatacor==1) lnEcor =
ai[0]+
ai[1]*lnE+
ai[2]*lnE*lnE+
ai[3]*lnE*lnE*lnE;
278 if(lnEcor<0.5)continue;
279
280
282
283 unsigned int module, ntheta, nphi;
287
288
289
291
294
296
297 double enecor=1.;
298 if(edgecor==1){
299
300 if(module==1) {
301 unsigned int theModule;
302 if(thetaModule>21) {
303 theModule = 43 - thetaModule;
305 pos.setZ(-pos.z());
306 } else {
307 theModule = thetaModule;
308 }
309
310 double IRShift;
311 if(theModule==21) {
312 IRShift = 0;
313
314 } else if(theModule==20) {
315 IRShift = 2.5;
316
317 } else {
318 IRShift = 5.;
319
320 }
321
322
327
328 double theta01,theta23,
length,d;
329 theta01 = (center01-IR).theta();
330 theta23 = (center23-IR).theta();
331 length = (center01-IR).mag();
333
334 double xIn;
335 xIn =
length*
tan(theta01-(pos-IR).theta())-d/2;
336 if (xIn < (-d/2) && theModule!=21){
337
338 theModule=theModule+1 ;
339
341 if(theModule==21) {
342 IRShift = 0;
343
344 } else if(theModule==20) {
345 IRShift = 2.5;
346
347 } else {
348 IRShift = 5.;
349
350 }
352 IR=IR1;
355 theta01 = (center01-IR).theta();
356 theta23 = (center23-IR).theta();
357 length = (center01-IR).mag();
359
360 xIn =
length*
tan(theta01-(pos-IR).theta())-d/2;
361
362 } else if (xIn > (d/2) && theModule!=0 ){
363
364 theModule=theModule-1 ;
366 if(theModule==21) {
367 IRShift = 0;
368
369 } else if(theModule==20) {
370 IRShift = 2.5;
371
372 } else {
373 IRShift = 5.;
374
375 }
376
378 IR=IR1;
381 theta01 = (center01-IR).theta();
382 theta23 = (center23-IR).theta();
383 length = (center01-IR).mag();
385
386 xIn =
length*
tan(theta01-(pos-IR).theta())-d/2;
387 }
388
389 double yIn;
390
391
392
393 yIn = pos.phi() < 0 ? pos.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
394 : pos.phi()*180./CLHEP::pi-phiModule*3.-1.843;
395
396 if(nphi==0&&yIn>100) yIn=yIn-360;
397 if(nphi==119&&yIn<-100) yIn=yIn+360;
398
399 if(yIn<-1.5-0.15){
400
401 if(nphi!=0) phiModule=phiModule-1;
402 if(nphi==0) phiModule=119;
403 yIn = pos.phi() < 0 ? pos.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
404 : pos.phi()*180./CLHEP::pi-phiModule*3.-1.843;
405 if(phiModule==0&&yIn>100) yIn=yIn-360;
406 if(phiModule==119&&yIn<-100) yIn=yIn+360;
407
408 }
409
410 if(yIn>1.5-0.15){
411
412
413 if(nphi!=119) phiModule=phiModule+1;
414 if(nphi==119) phiModule=0;
415
416 yIn = pos.phi() < 0 ? pos.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
417 : pos.phi()*180./CLHEP::pi-phiModule*3.-1.843;
418 if(phiModule==0&&yIn>100) yIn=yIn-360;
419 if(phiModule==119&&yIn<-100) yIn=yIn+360;
420 }
421
422 enecor=m_par[theModule][0]
423 +m_par[theModule][1]*xIn
424 +m_par[theModule][2]*xIn*xIn
425 +m_par[theModule][3]*xIn*xIn*xIn
426 +m_par[theModule][4]*xIn*xIn*xIn*xIn
427 +m_par[theModule][5]*xIn*xIn*xIn*xIn*xIn
428 +m_par[theModule][6]*xIn*xIn*xIn*xIn*xIn*xIn
429
430
431 +m_par[theModule][7]*yIn
432 +m_par[theModule][8]*yIn*yIn
433 +m_par[theModule][9]*yIn*yIn*yIn
434 +m_par[theModule][10]*yIn*yIn*yIn*yIn;
435
436 } else{
437 enecor=1;
438 }
439 }
440 double energyCC= energyC/(lnEcor*enecor);
441
443 if(ntOut==true){
444 m_ef=energyCC;
446 m_ec=energyC;
447 m_ct=lnEcor ;
448 m_cedge=enecor;
449 m_tuple1->write();
450 }
451
452
453 }
454
456 if(!recEmcShowerCol){
457 return( StatusCode::SUCCESS);
458 }
460 if(!dstEmcShowerCol){
461 return( StatusCode::SUCCESS);
462 }
463
464
465 if(recEmcShowerCol->size()!=dstEmcShowerCol->size())return SUCCESS;
466 for(int i=0;i<recEmcShowerCol->size();i++){
467 RecEmcShowerCol::iterator iter_rec = recEmcShowerCol->begin()+i;
468 DstEmcShowerCol::iterator iter_dst = dstEmcShowerCol->begin()+i;
469
470 (*iter_dst)->setEnergy((*iter_rec)->energy());
471 (*iter_dst)->setStatus((*iter_rec)->status());
472
473
474 }
475 return( StatusCode::SUCCESS);
476}
double tan(const BesAngle a)
EvtRecTrackCol::iterator EvtRecTrackIterator
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