77 ISvcLocator* svcLocator = Gaudi::svcLocator();
79 StatusCode sc = svcLocator->service(
"TofCaliSvc",
tofCaliSvc);
80 if (sc != StatusCode::SUCCESS) {
81 cout <<
"TofEnergyRec Get Calibration Service Failed !! " << endl;
85 sc = svcLocator->service(
"TofQCorrSvc",
tofQCorrSvc);
86 if (sc != StatusCode::SUCCESS) {
87 cout <<
"TofEnergyRec Get QCorr Service Failed !! " << endl;
91 sc = svcLocator->service(
"TofQElecSvc",
tofQElecSvc);
92 if (sc != StatusCode::SUCCESS) {
93 cout <<
"TofEnergyRec Get QElec Service Failed !! " << endl;
96 vector<TofData*>::iterator it;
97 for(it=tofDataVec.begin();
116 if((*it)->barrel()) {
120 if(bTofData->
tdc1()<=0||bTofData->
tdc1()>8000||bTofData->
tdc2()<=0||bTofData->
tdc2()>8000)
continue;
122 double adc1,adc2,tdc1,tdc2;
123 tdc1 = bTofData->
tdc1();
124 tdc2 = bTofData->
tdc2();
125 adc1 = bTofData->
adc1();
126 adc2 = bTofData->
adc2();
130 if(fabs(zpos)>115)
continue;
132 if(tofq<100||tofq>10000)
continue;
134 double energy = tofq*m_calibConst;
146 m_adc1 = bTofData->
adc1();
147 m_adc2 = bTofData->
adc2();
148 m_tdc1 = bTofData->
tdc1();
149 m_tdc2 = bTofData->
tdc2();
169 double charge_ns = eTofData->
adc();
173 bool neighborhood =
false;
175 int partId_all = barrel_ec;
176 int module_all = im/25;
177 int strip_all = im%25;
179 int partId_charged =-9999;
180 int module_charged =-9999;
181 int strip_charged =-9999;
187 RecTofTrackCol::iterator rec_charged;
190 for( rec_charged = recTofTrackCol->begin(); rec_charged != recTofTrackCol->end();rec_charged++)
198 status->
setStatus((*rec_charged)->status());
200 if((*rec_charged)->tofID()<=125)
continue;
204 if((*rec_charged)->tofID()>=600) {partId_charged=3; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
205 else {partId_charged=4; module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25; }
209 if((*rec_charged)->tofID()>=600) {partId_charged=6; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
210 else {partId_charged=5;module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25;}
217 if( (partId_all==3 || partId_all==4) && (partId_charged==3 || partId_charged==4 ) )
219 if( partId_all==partId_charged && module_charged == module_all &&
abs(strip_charged-strip_all)<3) neutral =
false;
220 if( partId_all==partId_charged && module_charged == module_all)
222 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
223 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
227 if( partId_all!=partId_charged &&
abs(module_charged-module_all)<2)
229 if(strip_all%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
230 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
232 if(strip_all%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
233 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
237 else if ( (partId_all==5 || partId_all==6) && (partId_charged==5 || partId_charged==6 ) )
239 if( partId_all==partId_charged && module_charged ==module_all &&
abs(strip_charged-strip_all)<3) neutral =
false;
241 if( partId_all==partId_charged && module_charged == module_all)
243 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
244 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
248 if( partId_all!=partId_charged &&
abs(module_charged-module_all)<2)
250 if(strip_all%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
251 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
253 if(strip_all%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
254 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
263 vector<TofData*>::iterator it_temp;
264 for(it_temp=tofDataVec.begin();it_temp!=tofDataVec.end();it_temp++)
270 int module_temp = im_temp/25;
271 int strip_temp = im_temp%25;
274 if( partId_temp==1 )
continue;
275 if(!is_mrpc_temp)
continue;
277 if( (partId_all==3 || partId_all==4) && (partId_temp==3 || partId_temp==4 ) )
279 if( partId_all==partId_temp && module_temp == module_all &&
abs(strip_temp-strip_all)!=0 &&
abs(strip_temp-strip_all)<3) neighborhood =
true;
280 if( partId_all==partId_temp && module_temp == module_all)
282 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
283 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
286 if( partId_all!=partId_temp &&
abs(module_temp-module_all)<2)
288 if(strip_all%2==0 && strip_temp%2!=0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
289 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
291 if(strip_all%2!=0 && strip_temp%2==0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
292 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
296 else if( (partId_all==5 || partId_all==6) && (partId_temp==5 || partId_temp==6 ) )
298 if( partId_all==partId_temp && module_temp == module_all &&
abs(strip_temp-strip_all)!=0 &&
abs(strip_temp-strip_all)<3) neighborhood =
true;
299 if( partId_all==partId_temp && module_temp == module_all)
301 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
302 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
305 if( partId_all!=partId_temp &&
abs(module_temp-module_all)<2)
307 if(strip_all%2==0 && strip_temp%2!=0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
308 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
310 if(strip_all%2!=0 && strip_temp%2==0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
311 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
334 vector<int> NeighborVec;
335 vector<Identifier> NeighborIdVec;
337 NeighborIdVec.clear();
345 int num = im+layer*88;
348 NeighborVec.push_back(1);
349 NeighborVec.push_back(87);
350 NeighborVec.push_back(88);
351 NeighborVec.push_back(89);
353 NeighborVec.push_back(0);
354 NeighborVec.push_back(86);
355 NeighborVec.push_back(88);
356 NeighborVec.push_back(175);
358 NeighborVec.push_back(
num+1);
359 NeighborVec.push_back(
num-1);
360 NeighborVec.push_back(
num+88);
361 NeighborVec.push_back(
num+88+1);
365 NeighborVec.push_back(89);
366 NeighborVec.push_back(175);
367 NeighborVec.push_back(0);
368 NeighborVec.push_back(87);
369 }
else if(
num==175) {
370 NeighborVec.push_back(88);
371 NeighborVec.push_back(174);
372 NeighborVec.push_back(86);
373 NeighborVec.push_back(87);
375 NeighborVec.push_back(
num+1);
376 NeighborVec.push_back(
num-1);
377 NeighborVec.push_back(
num-88);
378 NeighborVec.push_back(
num-88-1);
382 int size=NeighborVec.size();
383 for(
int i=0;i<size;i++) {
384 layer = NeighborVec[i]/88;
385 im = NeighborVec[i]%88;
392 NeighborVec.push_back(1);
393 NeighborVec.push_back(47);
395 NeighborVec.push_back(0);
396 NeighborVec.push_back(46);
398 NeighborVec.push_back(im-1);
399 NeighborVec.push_back(im+1);
402 int size=NeighborVec.size();
403 for(
int i=0;i<size;i++) {
409 return NeighborIdVec;
552 vector<TofData*>::iterator it;
553 for(it=tofDataVec.begin();
554 it!=tofDataVec.end();
556 if((*it)->barrel()) {
563 if(bTofData->
energy()<5.)
continue;
571 vector<Identifier>::iterator iNeigh;
572 for(iNeigh=NeighborVec.begin();
573 iNeigh!=NeighborVec.end();
579 vector<TofData*>::iterator it2;
580 for(it2=tofDataVec.begin();
581 it2!=tofDataVec.end();
583 if((*it2)->identify()==*iNeigh) {
605 if(eTofData->
energy()<5.)
continue;
608 vector<Identifier>::iterator iNeigh;
609 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
612 vector<TofData*>::iterator it2;
613 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
615 if((*it2)->identify()==*iNeigh) {
629 if(eTofData->
energy()<2.)
continue;
635 vector<Identifier>::iterator iNeigh;
637 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
640 vector<TofData*>::iterator it2;
641 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
643 if((*it2)->identify()==*iNeigh) {
660 m_seedVec.push_back(
Identifier((*it)->identify()));
674 vector<Identifier>::iterator iSeed;
676 for(iSeed=m_seedVec.begin(); iSeed!=m_seedVec.end(); iSeed++)
692 RecTofTrackCol::iterator iTrack, iMatch;
693 for(iTrack=recTofTrackCol->begin(); iTrack!=recTofTrackCol->end(); iTrack++)
696 dphi=
abs(im-(*iTrack)->tofID());
697 dphi = dphi>=44 ? 88-dphi : dphi;
698 }
else if(barrel_ec==2) {
699 dphi=
abs(im-(*iTrack)->tofID()+48);
700 dphi = dphi>=24 ? 48-dphi : dphi;
702 dphi=
abs(im-(*iTrack)->tofID());
703 dphi = dphi>=24 ? 48-dphi : dphi;
720 vector<TofData*>::iterator it;
721 for(it=tofDataVec.begin(); it!=tofDataVec.end(); it++)
723 if((*it)->identify()==*iSeed) {
725 if((*it)->barrel()) {
729 seedPos=bTofData->
zpos();
743 vector<Identifier>::iterator iNeigh;
744 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
747 vector<TofData*>::iterator it2;
748 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++)
750 if((*it2)->identify()==*iNeigh) {
752 if((*it)->barrel()) {
755 if(fabs(bTofData2->
zpos())>2)
continue;
757 m_seed_dist = seedPos-bTofData2->
zpos();
760 if(fabs(seedPos-bTofData2->
zpos())>0.3)
continue;
777 (*iMatch)->setEnergy(
energy/1000);
788 recTofTrackCol->push_back(tof);
791 m_shower_part = barrel_ec;
792 m_shower_layer = layer;
794 m_shower_zpos = zpos;
813 RecTofTrackCol::iterator rec_charged,iMatch;
814 for( rec_charged = recTofTrackCol->begin(); rec_charged != recTofTrackCol->end();rec_charged++)
818 status->
setStatus((*rec_charged)->status());
820 if((*rec_charged)->tofID()<=125)
continue;
822 int partId_charged =-1;
823 int module_charged =-1;
824 int strip_charged =-1;
828 if((*rec_charged)->tofID()>=600) {partId_charged=3; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
829 else {partId_charged=4; module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25; }
833 if((*rec_charged)->tofID()>=600) {partId_charged=6; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
834 else {partId_charged=5;module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25;}
839 if( (partId_seed==3 || partId_seed==4) && (partId_charged==3 || partId_charged==4 ) )
841 if( partId_seed==partId_charged && module_charged == module_seed &&
abs(strip_charged-strip_seed)<3) {iMatch=rec_charged; neutral =
false;
break;}
842 if( partId_seed==partId_charged && module_charged == module_seed)
844 if(strip_seed%2==0 && strip_charged%2!=0 && strip_charged<strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
845 if(strip_seed%2!=0 && strip_charged%2==0 && strip_charged>strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
849 if( partId_seed!=partId_charged &&
abs(module_charged-module_seed)<2)
851 if(strip_seed%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_seed)<3 ) {iMatch=rec_charged; neutral =
false;
break;}
852 if(strip_seed%2==0 && strip_charged%2!=0 && strip_charged<strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
854 if(strip_seed%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_seed)<3 ) {iMatch=rec_charged; neutral =
false;
break;}
855 if(strip_seed%2!=0 && strip_charged%2==0 && strip_charged>strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
859 else if ( (partId_seed==5 || partId_seed==6) && (partId_charged==5 || partId_charged==6 ) )
861 if( partId_seed==partId_charged && module_charged ==module_seed &&
abs(strip_charged-strip_seed)<3) {iMatch=rec_charged; neutral =
false;
break;}
863 if( partId_seed==partId_charged && module_charged == module_seed)
865 if(strip_seed%2==0 && strip_charged%2!=0 && strip_charged<strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
866 if(strip_seed%2!=0 && strip_charged%2==0 && strip_charged>strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
869 if( partId_seed!=partId_charged &&
abs(module_charged-module_seed)<2)
871 if(strip_seed%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_seed)<3 ) {iMatch=rec_charged; neutral =
false;
break;}
872 if(strip_seed%2==0 && strip_charged%2!=0 && strip_charged<strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
874 if(strip_seed%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_seed)<3 ) {iMatch=rec_charged; neutral =
false;
break;}
875 if(strip_seed%2!=0 && strip_charged%2==0 && strip_charged>strip_seed &&
abs(strip_charged-strip_seed)<4) {iMatch=rec_charged; neutral =
false;
break;}
888 double timeinfo_neutral=0;
889 double charge_neutral=0;
890 vector<TofData*>::iterator it;
891 for(it=tofDataVec.begin();it!=tofDataVec.end();it++)
893 if((*it)->barrel())
continue;
895 if((*it)->identify()==*iSeed)
899 timeinfo_neutral= eTofData->
tdc();
900 charge_neutral= eTofData->
adc();
912 vector<Identifier>::iterator iNeigh;
913 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++)
916 vector<TofData*>::iterator it2;
917 for(it2=tofDataVec.begin();it2!=tofDataVec.end();it2++)
919 if((*it2)->identify()==(*iNeigh))
944 double tof= timeinfo_neutral-t0;
951 tof_track->
setPh(charge_neutral);
953 recTofTrackCol->push_back(tof_track);