80 ISvcLocator* svcLocator = Gaudi::svcLocator();
82 StatusCode sc = svcLocator->service(
"TofCaliSvc",
tofCaliSvc);
83 if (sc != StatusCode::SUCCESS) {
84 cout <<
"TofEnergyRec Get Calibration Service Failed !! " << endl;
88 sc = svcLocator->service(
"TofQCorrSvc",
tofQCorrSvc);
89 if (sc != StatusCode::SUCCESS) {
90 cout <<
"TofEnergyRec Get QCorr Service Failed !! " << endl;
94 sc = svcLocator->service(
"TofQElecSvc",
tofQElecSvc);
95 if (sc != StatusCode::SUCCESS) {
96 cout <<
"TofEnergyRec Get QElec Service Failed !! " << endl;
100 sc = svcLocator->service(
"TofEnergyCalibSvc", m_TofEnergyCalibSvc);
101 if( sc != StatusCode::SUCCESS){
102 cout <<
"can not use TofEnergyCalibSvc" << endreq;
119 vector<TofData*>::iterator it;
120 for(it=tofDataVec.begin();
121 it!=tofDataVec.end();
138 if((*it)->barrel()) {
142 if(bTofData->
tdc1()<=0||bTofData->
tdc1()>8000||bTofData->
tdc2()<=0||bTofData->
tdc2()>8000)
continue;
144 double adc1,adc2,tdc1,tdc2;
145 tdc1 = bTofData->
tdc1();
146 tdc2 = bTofData->
tdc2();
147 adc1 = bTofData->
adc1();
148 adc2 = bTofData->
adc2();
152 if(fabs(zpos)>115)
continue;
154 if(tofq<100||tofq>10000)
continue;
166 CalibPar[0]=m_TofEnergyCalibSvc -> getPara1();
167 CalibPar[1]=m_TofEnergyCalibSvc -> getPara2();
168 CalibPar[2]=m_TofEnergyCalibSvc -> getPara3();
169 CalibPar[3]=m_TofEnergyCalibSvc -> getPara4();
170 CalibPar[4]=m_TofEnergyCalibSvc -> getPara5();
172 double TofEnCalibConst=CalibPar[0]+CalibPar[1]*zpos+CalibPar[2]*pow(zpos,2)+CalibPar[3]*pow(zpos,3)+CalibPar[4]*pow(zpos,4);
173 double energy = tofq*TofEnCalibConst;
186 m_adc1 = bTofData->
adc1();
187 m_adc2 = bTofData->
adc2();
188 m_tdc1 = bTofData->
tdc1();
189 m_tdc2 = bTofData->
tdc2();
207 int module = TofID::module(
id);
211 if( barrel_ec!=3 || ( endcap!=0 && endcap!=1 ) ) {
212 cout <<
"TofEnergyRec Get ETF(MRPC) data ERROR !! barrel_ec:" << barrel_ec <<
" endcap:" << endcap << endl;
225 if(etfData->
tdc1()<=0||etfData->
tdc1()>8000||etfData->
tdc2()<=0||etfData->
tdc2()>8000)
continue;
227 double adc1,adc2,tdc1,tdc2;
228 tdc1 = etfData->
tdc1();
229 tdc2 = etfData->
tdc2();
230 adc1 = etfData->
adc1();
231 adc2 = etfData->
adc2();
235 if(fabs(zpos)>115)
continue;
237 if(tofq<100||tofq>10000)
continue;
239 double energy = tofq*m_calibConst;
251 m_adc1 = etfData->
adc1();
252 m_adc2 = etfData->
adc2();
253 m_tdc1 = etfData->
tdc1();
254 m_tdc2 = etfData->
tdc2();
266 vector<int> NeighborVec;
267 vector<Identifier> NeighborIdVec;
269 NeighborIdVec.clear();
278 int num = im+layer*88;
281 NeighborVec.push_back(1);
282 NeighborVec.push_back(87);
283 NeighborVec.push_back(88);
284 NeighborVec.push_back(89);
286 NeighborVec.push_back(0);
287 NeighborVec.push_back(86);
288 NeighborVec.push_back(88);
289 NeighborVec.push_back(175);
291 NeighborVec.push_back(
num+1);
292 NeighborVec.push_back(
num-1);
293 NeighborVec.push_back(
num+88);
294 NeighborVec.push_back(
num+88+1);
298 NeighborVec.push_back(89);
299 NeighborVec.push_back(175);
300 NeighborVec.push_back(0);
301 NeighborVec.push_back(87);
302 }
else if(
num==175) {
303 NeighborVec.push_back(88);
304 NeighborVec.push_back(174);
305 NeighborVec.push_back(86);
306 NeighborVec.push_back(87);
308 NeighborVec.push_back(
num+1);
309 NeighborVec.push_back(
num-1);
310 NeighborVec.push_back(
num-88);
311 NeighborVec.push_back(
num-88-1);
315 int size=NeighborVec.size();
316 for(
int i=0;i<size;i++) {
317 layer = NeighborVec[i]/88;
318 im = NeighborVec[i]%88;
325 NeighborVec.push_back(1);
326 NeighborVec.push_back(47);
328 NeighborVec.push_back(0);
329 NeighborVec.push_back(46);
331 NeighborVec.push_back(im-1);
332 NeighborVec.push_back(im+1);
335 int size=NeighborVec.size();
336 for(
int i=0;i<size;i++) {
345 int module = TofID::module(
id);
350 NeighborVec.push_back(1);
351 NeighborVec.push_back(35);
352 }
else if( module==35 ) {
353 NeighborVec.push_back(0);
354 NeighborVec.push_back(34);
356 NeighborVec.push_back(module-1);
357 NeighborVec.push_back(module+1);
360 int size=NeighborVec.size();
361 for(
int i=0;i<size;i++) {
362 int im = NeighborVec[i];
363 for(
int j=-2; j<3; j++ ) {
365 if( ist<0 || ist>11 )
continue;
366 NeighborIdVec.push_back(
TofID::cell_id(barrel_ec,endcap,module,ist,end));
372 return NeighborIdVec;
377 vector<Identifier> NeighborVec,tmpNeighborVec,tmpNextNeighborVec;
378 vector<Identifier>::iterator ci_NV,ci_tmpNV,ci_tmpNNV;
382 bool flagNeighbor=
false;
385 for(ci_tmpNV=tmpNeighborVec.begin();
386 ci_tmpNV!=tmpNeighborVec.end();
390 for(ci_tmpNNV=tmpNextNeighborVec.begin();
391 ci_tmpNNV!=tmpNextNeighborVec.end();
394 for(ci_NV=NeighborVec.begin();
395 ci_NV!=NeighborVec.end();
397 if(*ci_tmpNNV==*ci_NV){
417 NeighborVec.push_back(*ci_tmpNNV);
439 vector<TofData*>::iterator it;
440 for(it=tofDataVec.begin();
441 it!=tofDataVec.end();
444 if( !((*it)->is_mrpc()) ) {
445 if((*it)->barrel()) {
450 if(bTofData->
energy()<5.)
continue;
458 vector<Identifier>::iterator iNeigh;
459 for(iNeigh=NeighborVec.begin();
460 iNeigh!=NeighborVec.end();
466 vector<TofData*>::iterator it2;
467 for(it2=tofDataVec.begin();
468 it2!=tofDataVec.end();
470 if((*it2)->identify()==*iNeigh) {
485 if(eTofData->
energy()<5.)
continue;
488 vector<Identifier>::iterator iNeigh;
489 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
491 vector<TofData*>::iterator it2;
492 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
494 if((*it2)->identify()==*iNeigh) {
510 if(etfData->
energy()<2.)
continue;
513 vector<Identifier>::iterator iNeigh;
514 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
517 vector<TofData*>::iterator it2;
518 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
520 if((*it2)->identify()==*iNeigh) {
533 m_seedVec.push_back(
Identifier((*it)->identify()));
548 vector<Identifier>::iterator iSeed;
550 for(iSeed=m_seedVec.begin(); iSeed!=m_seedVec.end(); iSeed++)
565 RecTofTrackCol::iterator iTrack, iMatch;
566 for(iTrack=recTofTrackCol->begin(); iTrack!=recTofTrackCol->end(); iTrack++)
570 if( barrel_ec==1 && status->
is_barrel() ) {
571 dphi=
abs(im-(*iTrack)->tofID());
572 dphi = dphi>=44 ? 88-dphi : dphi;
573 }
else if( barrel_ec==2 && !(status->
is_barrel()) && ((*iTrack)->tofID()>47) ) {
574 dphi=
abs(im-(*iTrack)->tofID()+48);
575 dphi = dphi>=24 ? 48-dphi : dphi;
576 }
else if( barrel_ec==0 && !(status->
is_barrel()) && ((*iTrack)->tofID()<48) ) {
577 dphi=
abs(im-(*iTrack)->tofID());
578 dphi = dphi>=24 ? 48-dphi : dphi;
594 vector<TofData*>::iterator it;
595 for(it=tofDataVec.begin(); it!=tofDataVec.end(); it++)
597 if((*it)->identify()==*iSeed) {
599 if((*it)->barrel()) {
603 seedPos=bTofData->
zpos();
617 vector<Identifier>::iterator iNeigh;
618 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
621 vector<TofData*>::iterator it2;
622 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
624 if((*it2)->identify()==*iNeigh) {
626 if((*it)->barrel()) {
629 if(fabs(bTofData2->
zpos())>2)
continue;
631 m_seed_dist = seedPos-bTofData2->
zpos();
634 if(fabs(seedPos-bTofData2->
zpos())>0.3)
continue;
651 (*iMatch)->setEnergy(
energy/1000);
665 recTofTrackCol->push_back(tof);
668 m_shower_part = barrel_ec;
669 m_shower_layer = layer;
671 m_shower_zpos = zpos;
684 int im = TofID::module(*iSeed);
691 int dphi=999, dtheta=999;
692 RecTofTrackCol::iterator iTrack, iMatch;
693 for(iTrack=recTofTrackCol->begin(); iTrack!=recTofTrackCol->end(); iTrack++)
697 if( barrel_ec==3 && endcap==0 && ((*iTrack)->tofID()<36) ) {
698 dphi =
abs(im-(*iTrack)->tofID());
699 dphi = dphi>=18 ? 36-dphi : dphi;
700 dtheta =
abs( strip - status->
layer() );
701 }
else if( barrel_ec==3 && endcap==1 && ((*iTrack)->tofID()>35) ) {
702 dphi=
abs(im-(*iTrack)->tofID()+36);
703 dphi = dphi>=18 ? 36-dphi : dphi;
704 dtheta =
abs( strip - status->
layer() );
706 if( (
abs(dphi)==0 &&
abs(dtheta)<=2 ) || (
abs(dphi)==1 &&
abs(dtheta)<=1 ) ) {
720 vector<TofData*>::iterator it;
721 for(it=tofDataVec.begin(); it!=tofDataVec.end(); it++)
723 if((*it)->identify()==*iSeed) {
727 seedPos=etfData->
zpos();
733 vector<Identifier>::iterator iNeigh;
734 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
736 vector<TofData*>::iterator it2;
737 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
739 if((*it)->barrel())
continue;
740 if((*it2)->identify()==*iNeigh) {
742 if(fabs(etfData2->
zpos())>2)
continue;
744 m_seed_dist = seedPos-etfData2->
zpos();
747 if(fabs(seedPos-etfData2->
zpos())>0.3)
continue;
760 (*iMatch)->setEnergy(
energy/1000);
774 recTofTrackCol->push_back(tof);
777 m_shower_part = barrel_ec;
778 m_shower_layer = strip;
780 m_shower_zpos = zpos;