#include <TofShower.h>
Public Member Functions | |
void | BookNtuple (NTuple::Tuple *&tuple, NTuple::Tuple *&tuple1, NTuple::Tuple *&tuple2) |
void | BookNtuple (NTuple::Tuple *&tuple, NTuple::Tuple *&tuple1, NTuple::Tuple *&tuple2) |
double | calib (const int n, const int m) const |
double | calib (const int n, const int m) const |
double | calibConst () const |
double | calibConst () const |
double | ecalib (const int nsci) const |
double | ecalib (const int nsci) const |
void | energyCalib (vector< TofData * > &tofDataVec) |
void | energyCalib (vector< TofData * > &tofDataVec) |
void | findSeed (vector< TofData * > &tofDataVec) |
void | findSeed (vector< TofData * > &tofDataVec) |
void | findShower (vector< TofData * > &tofDataVec, RecTofTrackCol *recTofTrackCol) |
void | findShower (vector< TofData * > &tofDataVec, RecTofTrackCol *recTofTrackCol) |
vector< Identifier > | getNeighbors (const Identifier &id) |
vector< Identifier > | getNeighbors (const Identifier &id) |
vector< Identifier > | getNextNeighbors (const Identifier &id) |
vector< Identifier > | getNextNeighbors (const Identifier &id) |
bool | isData () const |
bool | isData () const |
void | readCalibPar () |
void | readCalibPar () |
void | setCalib (const int n, const int m, const double ecalib) |
void | setCalib (const int n, const int m, const double ecalib) |
void | setCalibConst (const double cal) |
void | setCalibConst (const double cal) |
void | setEcalib (const int nsci, const double ecalib) |
void | setEcalib (const int nsci, const double ecalib) |
void | setIsData (const bool isData) |
void | setIsData (const bool isData) |
TofShower () | |
TofShower () | |
~TofShower () | |
~TofShower () | |
Private Attributes | |
NTuple::Item< double > | m_adc1 |
NTuple::Item< double > | m_adc1 |
NTuple::Item< double > | m_adc2 |
NTuple::Item< double > | m_adc2 |
double | m_calib [176][4] |
double | m_calibConst |
double | m_ecalib [176] |
NTuple::Item< long > | m_end |
NTuple::Item< long > | m_end |
NTuple::Item< double > | m_energy |
NTuple::Item< double > | m_energy |
NTuple::Item< long > | m_im |
NTuple::Item< long > | m_im |
bool | m_isData |
NTuple::Item< long > | m_layer |
NTuple::Item< long > | m_layer |
bool | m_output |
NTuple::Item< long > | m_part |
NTuple::Item< long > | m_part |
PropertyMgr | m_propMgr |
NTuple::Item< double > | m_seed_dist |
NTuple::Item< double > | m_seed_dist |
vector< Identifier > | m_seedVec |
vector< Identifier > | m_seedVec |
NTuple::Item< double > | m_shower_energy |
NTuple::Item< double > | m_shower_energy |
NTuple::Item< long > | m_shower_im |
NTuple::Item< long > | m_shower_im |
NTuple::Item< long > | m_shower_layer |
NTuple::Item< long > | m_shower_layer |
NTuple::Item< long > | m_shower_part |
NTuple::Item< long > | m_shower_part |
NTuple::Item< double > | m_shower_zpos |
NTuple::Item< double > | m_shower_zpos |
NTuple::Item< double > | m_tdc1 |
NTuple::Item< double > | m_tdc1 |
NTuple::Item< double > | m_tdc2 |
NTuple::Item< double > | m_tdc2 |
NTuple::Tuple * | m_tuple |
NTuple::Tuple * | m_tuple |
NTuple::Tuple * | m_tuple1 |
NTuple::Tuple * | m_tuple1 |
NTuple::Tuple * | m_tuple2 |
NTuple::Tuple * | m_tuple2 |
NTuple::Item< double > | m_zpos |
NTuple::Item< double > | m_zpos |
|
00018 :m_output(false),m_isData(true) 00019 { 00020 IJobOptionsSvc* jobSvc; 00021 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc); 00022 jobSvc->setMyProperties("TofShower", &m_propMgr); 00023 00024 }
|
|
00016 {;}
|
|
|
|
00016 {;}
|
|
|
|
00027 { 00028 m_output = true; 00029 m_tuple = tuple; 00030 if(!m_tuple) { 00031 std::cerr << "Invalid ntuple in TofEnergyRec!" << std::endl; 00032 } else { 00033 m_tuple->addItem ("part", m_part); 00034 m_tuple->addItem ("layer", m_layer); 00035 m_tuple->addItem ("im", m_im); 00036 m_tuple->addItem ("end", m_end); 00037 m_tuple->addItem ("zpos", m_zpos); 00038 m_tuple->addItem ("adc1", m_adc1); 00039 m_tuple->addItem ("adc2", m_adc2); 00040 m_tuple->addItem ("tdc1", m_tdc1); 00041 m_tuple->addItem ("tdc2", m_tdc2); 00042 m_tuple->addItem ("energy", m_energy); 00043 } 00044 00045 m_tuple1 = tuple1; 00046 if(!m_tuple1) { 00047 std::cerr << "Invalid ntuple1 in TofEnergyRec!" << std::endl; 00048 } else { 00049 m_tuple1->addItem ("part", m_shower_part); 00050 m_tuple1->addItem ("layer", m_shower_layer); 00051 m_tuple1->addItem ("im", m_shower_im); 00052 m_tuple1->addItem ("zpos", m_shower_zpos); 00053 m_tuple1->addItem ("energy", m_shower_energy); 00054 } 00055 00056 m_tuple2 = tuple2; 00057 if(!m_tuple2) { 00058 std::cerr << "Invalid ntuple2 in TofEnergyRec!" << std::endl; 00059 } else { 00060 m_tuple2->addItem ("dist", m_seed_dist); 00061 } 00062 }
|
|
|
|
00521 { 00522 if(n<176&&m<4) { 00523 return m_calib[n][m]; 00524 } else { 00525 return 0; 00526 } 00527 }
|
|
00034 { return m_calibConst; }
|
|
00034 { return m_calibConst; }
|
|
|
|
00505 { 00506 if(nsci<176) { 00507 return m_ecalib[nsci]; 00508 } else { 00509 return 0; 00510 } 00511 }
|
|
|
|
00065 { 00066 //Get TOF Calibtration Service 00067 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00068 ITofCaliSvc* tofCaliSvc; 00069 StatusCode sc = svcLocator->service("TofCaliSvc", tofCaliSvc); 00070 if (sc != StatusCode::SUCCESS) { 00071 cout << "TofEnergyRec Get Calibration Service Failed !! " << endl; 00072 } 00073 00074 ITofQCorrSvc* tofQCorrSvc; 00075 sc = svcLocator->service("TofQCorrSvc", tofQCorrSvc); 00076 if (sc != StatusCode::SUCCESS) { 00077 cout << "TofEnergyRec Get QCorr Service Failed !! " << endl; 00078 } 00079 00080 ITofQElecSvc* tofQElecSvc; 00081 sc = svcLocator->service("TofQElecSvc", tofQElecSvc); 00082 if (sc != StatusCode::SUCCESS) { 00083 cout << "TofEnergyRec Get QElec Service Failed !! " << endl; 00084 } 00085 00086 vector<TofData*>::iterator it; 00087 for(it=tofDataVec.begin(); 00088 it!=tofDataVec.end(); 00089 it++) { 00090 00091 Identifier id((*it)->identify()); 00092 int barrel_ec = TofID::barrel_ec(id); 00093 int layer = TofID::layer(id); 00094 int im = TofID::phi_module(id); 00095 int end = TofID::end(id); 00096 00097 if(m_output) { 00098 m_part = barrel_ec; 00099 m_layer = layer; 00100 m_im = im; 00101 m_end = end; 00102 } 00103 00104 if((*it)->barrel()) { 00105 TofData* bTofData = (*it); 00106 bTofData->setZpos(99.); 00107 bTofData->setEnergy(0.); 00108 if(bTofData->tdc1()<=0||bTofData->tdc1()>8000||bTofData->tdc2()<=0||bTofData->tdc2()>8000) continue; 00109 00110 double adc1,adc2,tdc1,tdc2; 00111 tdc1 = bTofData->tdc1(); 00112 tdc2 = bTofData->tdc2(); 00113 adc1 = bTofData->adc1(); 00114 adc2 = bTofData->adc2(); 00115 00116 //from data CalibSvc 00117 double zpos = tofCaliSvc->ZTDC( tdc1, tdc2, bTofData->tofId() ); 00118 if(fabs(zpos)>115) continue; 00119 double tofq = tofCaliSvc->BPh( adc1, adc2, zpos, bTofData->tofId()); 00120 if(tofq<100||tofq>10000) continue; 00121 //double energy = q*0.0036; 00122 double energy = tofq*m_calibConst; //new calibration result in 2009.9.27 00123 zpos /= 100.; //cm->m 00124 00125 bTofData->setZpos(zpos); 00126 bTofData->setEnergy(energy); 00127 00128 if(m_output) { 00129 m_part = barrel_ec; 00130 m_layer = layer; 00131 m_im = im; 00132 m_end = end; 00133 m_adc1 = bTofData->adc1(); 00134 m_adc2 = bTofData->adc2(); 00135 m_tdc1 = bTofData->tdc1(); 00136 m_tdc2 = bTofData->tdc2(); 00137 m_zpos = zpos; 00138 m_energy = energy; 00139 m_tuple->write(); 00140 } 00141 00142 } else { 00143 //cout<<"endcap"<<endl; 00144 //ETofData* eTofData = dynamic_cast<ETofData*>(*it); 00145 //TofData* bTofData = (*it); 00146 //double energy = 2*eTofData->adcChannel()/140; 00147 //eTofData->setEnergy(energy); 00148 } 00149 } 00150 }
|
|
|
|
00289 { 00290 bool max=false; 00291 m_seedVec.clear(); 00292 00293 vector<TofData*>::iterator it; 00294 for(it=tofDataVec.begin(); 00295 it!=tofDataVec.end(); 00296 it++) { 00297 if((*it)->barrel()) { //barrel 00298 TofData* bTofData = (*it); 00299 if(bTofData->energy()<5.) continue; //seed energy cut = 6MeV 00300 00301 max=true; 00302 vector<Identifier> NeighborVec=getNextNeighbors(Identifier(bTofData->identify())); 00303 vector<Identifier>::iterator iNeigh; 00304 for(iNeigh=NeighborVec.begin(); 00305 iNeigh!=NeighborVec.end(); 00306 iNeigh++) { 00307 00308 vector<TofData*>::iterator it2; 00309 for(it2=tofDataVec.begin(); 00310 it2!=tofDataVec.end(); 00311 it2++) { 00312 if((*it2)->identify()==*iNeigh) { 00313 TofData* bTofData2 = (*it2); 00314 if(bTofData2->energy()>bTofData->energy()) { 00315 max=false; 00316 } 00317 break; 00318 } 00319 } 00320 00321 } 00322 } 00323 00324 else { //endcap 00325 TofData* eTofData = (*it); 00326 if(eTofData->energy()<5.) continue; //seed energy cut = 5MeV 00327 00328 max=true; 00329 vector<Identifier> NeighborVec=getNextNeighbors(Identifier(eTofData->identify())); 00330 vector<Identifier>::iterator iNeigh; 00331 for(iNeigh=NeighborVec.begin(); 00332 iNeigh!=NeighborVec.end(); 00333 iNeigh++) { 00334 00335 vector<TofData*>::iterator it2; 00336 for(it2=tofDataVec.begin(); 00337 it2!=tofDataVec.end(); 00338 it2++) { 00339 if((*it2)->identify()==*iNeigh) { 00340 TofData* eTofData2 = (*it2); 00341 if(eTofData2->energy()>eTofData->energy()) { 00342 max=false; 00343 } 00344 break; 00345 } 00346 } 00347 00348 } 00349 } 00350 00351 if(max) { 00352 m_seedVec.push_back(Identifier((*it)->identify())); 00353 } 00354 00355 } 00356 }
|
|
|
|
00359 { 00360 energyCalib(tofDataVec); 00361 findSeed(tofDataVec); 00362 vector<Identifier>::iterator iSeed; 00363 for(iSeed=m_seedVec.begin(); 00364 iSeed!=m_seedVec.end(); 00365 iSeed++) { 00366 00367 int barrel_ec = TofID::barrel_ec(*iSeed); 00368 int layer = TofID::layer(*iSeed); 00369 int im = TofID::phi_module(*iSeed); 00370 im += layer * 88; 00371 00372 bool neutral=true; 00373 //match with Tof charged track 00374 int dphi=999; 00375 RecTofTrackCol::iterator iTrack, iMatch; 00376 for(iTrack=recTofTrackCol->begin(); 00377 iTrack!=recTofTrackCol->end(); 00378 iTrack++) { 00379 if(barrel_ec==1) { 00380 dphi=abs(im-(*iTrack)->tofID()); 00381 dphi = dphi>=44 ? 88-dphi : dphi; 00382 } else if(barrel_ec==2) { 00383 dphi=abs(im-(*iTrack)->tofID()+48); 00384 dphi = dphi>=24 ? 48-dphi : dphi; 00385 } else { 00386 dphi=abs(im-(*iTrack)->tofID()); 00387 dphi = dphi>=24 ? 48-dphi : dphi; 00388 } 00389 if(abs(dphi)<=2) { 00390 iMatch = iTrack; 00391 neutral=false; 00392 break; 00393 } 00394 } 00395 00396 //energy sum of seed and its neighbors 00397 //use avarage mean to calculation position 00398 double zpos=0; 00399 double energy=0; 00400 double seedPos=0; 00401 vector<TofData*>::iterator it; 00402 for(it=tofDataVec.begin(); 00403 it!=tofDataVec.end(); 00404 it++) { 00405 if((*it)->identify()==*iSeed) { 00406 //cout<<"iSeed="<<*iSeed<<endl; 00407 if((*it)->barrel()) { 00408 TofData* bTofData = (*it); 00409 zpos+=bTofData->zpos()*bTofData->energy(); 00410 energy+=bTofData->energy(); 00411 seedPos=bTofData->zpos(); 00412 } else { 00413 TofData* eTofData = (*it); 00414 energy+=eTofData->energy(); 00415 } 00416 break; 00417 } 00418 } 00419 00420 vector<Identifier> NeighborVec=getNextNeighbors(*iSeed); 00421 vector<Identifier>::iterator iNeigh; 00422 for(iNeigh=NeighborVec.begin(); 00423 iNeigh!=NeighborVec.end(); 00424 iNeigh++) { 00425 00426 vector<TofData*>::iterator it2; 00427 for(it2=tofDataVec.begin(); 00428 it2!=tofDataVec.end(); 00429 it2++) { 00430 if((*it2)->identify()==*iNeigh) { 00431 //cout<<"iNeigh="<<*iNeigh<<endl; 00432 if((*it)->barrel()) { 00433 TofData* bTofData2 = (*it2); 00434 00435 if(fabs(bTofData2->zpos())>2) continue; 00436 if(m_output) { 00437 m_seed_dist = seedPos-bTofData2->zpos(); 00438 m_tuple2->write(); 00439 } 00440 if(fabs(seedPos-bTofData2->zpos())>0.3) continue; 00441 zpos+=bTofData2->zpos()*bTofData2->energy(); 00442 energy+=bTofData2->energy(); 00443 } else { 00444 TofData* eTofData2 = (*it2); 00445 energy+=eTofData2->energy(); 00446 } 00447 break; 00448 } 00449 } 00450 } 00451 if(energy>0) zpos/=energy; 00452 00453 //for charged track, set energy 00454 if(neutral==false) { 00455 if(fabs(zpos)<1.15&&energy>5.&&energy<1000) { 00456 (*iMatch)->setEnergy(energy/1000); 00457 } 00458 continue; 00459 } 00460 00461 //for neutral track 00462 if(fabs(zpos)<1.15&&energy>5.&&energy<1000) { //shower energy cut = 10MeV 00463 RecTofTrack* tof = new RecTofTrack; 00464 tof->setTofID(*iSeed); 00465 tof->setZrHit(zpos); 00466 tof->setEnergy(energy/1000); //MeV-->GeV 00467 recTofTrackCol->push_back(tof); 00468 00469 if(m_output) { 00470 m_shower_part = barrel_ec; 00471 m_shower_layer = layer; 00472 m_shower_im = im; 00473 m_shower_zpos = zpos; 00474 m_shower_energy = energy; 00475 m_tuple1->write(); 00476 } 00477 } 00478 } 00479 }
|
|
|
|
00153 { 00154 vector<int> NeighborVec; 00155 vector<Identifier> NeighborIdVec; 00156 NeighborVec.clear(); 00157 NeighborIdVec.clear(); 00158 00159 int barrel_ec = TofID::barrel_ec(id); 00160 int layer = TofID::layer(id); 00161 int im = TofID::phi_module(id); 00162 int end = TofID::end(id); 00163 00164 if(barrel_ec==1) { //barrel 00165 int num = im+layer*88; 00166 if(num<88) { //layer1 00167 if(num==0) { 00168 NeighborVec.push_back(1); 00169 NeighborVec.push_back(87); 00170 NeighborVec.push_back(88); 00171 NeighborVec.push_back(89); 00172 } else if(num==87) { 00173 NeighborVec.push_back(0); 00174 NeighborVec.push_back(86); 00175 NeighborVec.push_back(88); 00176 NeighborVec.push_back(175); 00177 } else { 00178 NeighborVec.push_back(num+1); 00179 NeighborVec.push_back(num-1); 00180 NeighborVec.push_back(num+88); 00181 NeighborVec.push_back(num+88+1); 00182 } 00183 } else { 00184 if(num==88) { 00185 NeighborVec.push_back(89); 00186 NeighborVec.push_back(175); 00187 NeighborVec.push_back(0); 00188 NeighborVec.push_back(87); 00189 } else if(num==175) { 00190 NeighborVec.push_back(88); 00191 NeighborVec.push_back(174); 00192 NeighborVec.push_back(86); 00193 NeighborVec.push_back(87); 00194 } else { 00195 NeighborVec.push_back(num+1); 00196 NeighborVec.push_back(num-1); 00197 NeighborVec.push_back(num-88); 00198 NeighborVec.push_back(num-88-1); 00199 } 00200 } 00201 00202 int size=NeighborVec.size(); 00203 for(int i=0;i<size;i++) { 00204 layer = NeighborVec[i]/88; 00205 im = NeighborVec[i]%88; 00206 NeighborIdVec.push_back(TofID::cell_id(barrel_ec,layer,im,end)); 00207 } 00208 } 00209 00210 else { //endcap 00211 if(im==0) { 00212 NeighborVec.push_back(1); 00213 NeighborVec.push_back(47); 00214 } else if(im==47) { 00215 NeighborVec.push_back(0); 00216 NeighborVec.push_back(46); 00217 } else { 00218 NeighborVec.push_back(im-1); 00219 NeighborVec.push_back(im+1); 00220 } 00221 00222 int size=NeighborVec.size(); 00223 for(int i=0;i<size;i++) { 00224 im = NeighborVec[i]; 00225 NeighborIdVec.push_back(TofID::cell_id(barrel_ec,layer,im,end)); 00226 } 00227 } 00228 00229 return NeighborIdVec; 00230 }
|
|
|
|
00233 { 00234 vector<Identifier> NeighborVec,tmpNeighborVec,tmpNextNeighborVec; 00235 vector<Identifier>::iterator ci_NV,ci_tmpNV,ci_tmpNNV; 00236 NeighborVec=getNeighbors(id); 00237 tmpNeighborVec=getNeighbors(id); 00238 bool flag=false; //whether NeighborVec already includes this crystal 00239 bool flagNeighbor=false; //whether this crystal belongs to NeighborVec 00240 00241 //------------------------------------------------------------------ 00242 for(ci_tmpNV=tmpNeighborVec.begin(); 00243 ci_tmpNV!=tmpNeighborVec.end(); 00244 ci_tmpNV++){ 00245 tmpNextNeighborVec=getNeighbors(*ci_tmpNV); 00246 //================================================================ 00247 for(ci_tmpNNV=tmpNextNeighborVec.begin(); 00248 ci_tmpNNV!=tmpNextNeighborVec.end(); 00249 ci_tmpNNV++){ 00250 00251 for(ci_NV=NeighborVec.begin(); 00252 ci_NV!=NeighborVec.end(); 00253 ci_NV++){ 00254 if(*ci_tmpNNV==*ci_NV){ //this crystal is already included 00255 flag=true; 00256 break; 00257 } 00258 } 00259 00260 if(!flag){ //find a new crystal 00261 //for(ci_tmpNV1=tmpNeighborVec.begin(); 00262 // ci_tmpNV1!=tmpNeighborVec.end(); 00263 // ci_tmpNV1++){ 00264 // if(*ci_tmpNNV==*ci_tmpNV1){ //this crystal belongs to NeighborVec 00265 // flagNeighbor=true; 00266 // break; 00267 // } 00268 //} 00269 00270 if(*ci_tmpNNV==id) 00271 flagNeighbor=true; 00272 00273 if(!flagNeighbor) 00274 NeighborVec.push_back(*ci_tmpNNV); 00275 else 00276 flagNeighbor=false; 00277 } 00278 else 00279 flag=false; 00280 } 00281 //================================================================ 00282 } 00283 //------------------------------------------------------------------ 00284 00285 return NeighborVec; 00286 }
|
|
00037 { return m_isData; }
|
|
00037 { return m_isData; }
|
|
|
|
00482 { 00483 string paraPath = getenv("TOFENERGYRECROOT"); 00484 paraPath += "/share/peak.dat"; 00485 ifstream in; 00486 in.open(paraPath.c_str()); 00487 assert(in); 00488 for(int i=0;i<176;i++) { 00489 in>>m_ecalib[i]; 00490 } 00491 in.close(); 00492 00493 paraPath = getenv("TOFENERGYRECROOT"); 00494 paraPath += "/share/calib.dat"; 00495 ifstream in1; 00496 in1.open(paraPath.c_str()); 00497 assert(in1); 00498 for(int i=0;i<176;i++) { 00499 in1>>m_calib[i][0]>>m_calib[i][1]>>m_calib[i][2]>>m_calib[i][3]; 00500 } 00501 in1.close(); 00502 }
|
|
|
|
00530 { 00531 if(n<176&&m<4) { 00532 m_calib[n][m]=ecalib; 00533 } 00534 }
|
|
00035 { m_calibConst = cal; }
|
|
00035 { m_calibConst = cal; }
|
|
|
|
00514 { 00515 if(nsci<176) { 00516 m_ecalib[nsci]=ecalib; 00517 } 00518 }
|
|
00038 { m_isData = isData; }
|
|
00038 { m_isData = isData; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|