#include <TofShower.h>
Public Member Functions | |
TofShower () | |
~TofShower () | |
vector< Identifier > | getNeighbors (const Identifier &id) |
vector< Identifier > | getNextNeighbors (const Identifier &id) |
void | energyCalib (vector< TofData * > &tofDataVec, RecTofTrackCol *recTofTrackCol) |
void | findSeed (vector< TofData * > &tofDataVec) |
void | findShower (vector< TofData * > &tofDataVec, RecTofTrackCol *recTofTrackCol, double) |
void | BookNtuple (NTuple::Tuple *&tuple, NTuple::Tuple *&tuple1, NTuple::Tuple *&tuple2) |
void | readCalibPar () |
double | ecalib (const int nsci) const |
void | setEcalib (const int nsci, const double ecalib) |
double | calib (const int n, const int m) const |
void | setCalib (const int n, const int m, const double ecalib) |
double | calibConst () const |
void | setCalibConst (const double cal) |
bool | isData () const |
void | setIsData (const bool isData) |
Private Attributes | |
vector< Identifier > | m_seedVec |
double | m_ecalib [176] |
double | m_calib [176][4] |
double | m_calibConst |
bool | m_isData |
PropertyMgr | m_propMgr |
bool | m_output |
NTuple::Tuple * | m_tuple |
NTuple::Item< long > | m_part |
NTuple::Item< long > | m_layer |
NTuple::Item< long > | m_im |
NTuple::Item< long > | m_end |
NTuple::Item< double > | m_zpos |
NTuple::Item< double > | m_adc1 |
NTuple::Item< double > | m_adc2 |
NTuple::Item< double > | m_tdc1 |
NTuple::Item< double > | m_tdc2 |
NTuple::Item< double > | m_energy |
NTuple::Tuple * | m_tuple1 |
NTuple::Item< long > | m_shower_part |
NTuple::Item< long > | m_shower_layer |
NTuple::Item< long > | m_shower_im |
NTuple::Item< double > | m_shower_zpos |
NTuple::Item< double > | m_shower_energy |
NTuple::Tuple * | m_tuple2 |
NTuple::Item< double > | m_seed_dist |
Definition at line 14 of file TofShower.h.
TofShower::TofShower | ( | ) |
Definition at line 31 of file TofShower.cxx.
References m_propMgr.
00031 :m_output(false),m_isData(true) // m_output wird auf false und m_isData auf true gesetzt 00032 { 00033 IJobOptionsSvc* jobSvc; 00034 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc); 00035 jobSvc->setMyProperties("TofShower", &m_propMgr); 00036 00037 }
TofShower::~TofShower | ( | ) | [inline] |
void TofShower::BookNtuple | ( | NTuple::Tuple *& | tuple, | |
NTuple::Tuple *& | tuple1, | |||
NTuple::Tuple *& | tuple2 | |||
) |
Definition at line 39 of file TofShower.cxx.
References m_adc1, m_adc2, m_end, m_energy, m_im, m_layer, m_output, m_part, m_seed_dist, m_shower_energy, m_shower_im, m_shower_layer, m_shower_part, m_shower_zpos, m_tdc1, m_tdc2, m_tuple, m_tuple1, m_tuple2, and m_zpos.
Referenced by TofEnergyRec::initialize().
00040 { 00041 m_output = true; 00042 m_tuple = tuple; 00043 if(!m_tuple) { 00044 std::cerr << "Invalid ntuple in TofEnergyRec!" << std::endl; 00045 } else { 00046 m_tuple->addItem ("part", m_part); 00047 m_tuple->addItem ("layer", m_layer); 00048 m_tuple->addItem ("im", m_im); 00049 m_tuple->addItem ("end", m_end); 00050 m_tuple->addItem ("zpos", m_zpos); 00051 m_tuple->addItem ("adc1", m_adc1); 00052 m_tuple->addItem ("adc2", m_adc2); 00053 m_tuple->addItem ("tdc1", m_tdc1); 00054 m_tuple->addItem ("tdc2", m_tdc2); 00055 m_tuple->addItem ("energy", m_energy); 00056 } 00057 00058 m_tuple1 = tuple1; 00059 if(!m_tuple1) { 00060 std::cerr << "Invalid ntuple1 in TofEnergyRec!" << std::endl; 00061 } else { 00062 m_tuple1->addItem ("part", m_shower_part); 00063 m_tuple1->addItem ("layer", m_shower_layer); 00064 m_tuple1->addItem ("im", m_shower_im); 00065 m_tuple1->addItem ("zpos", m_shower_zpos); 00066 m_tuple1->addItem ("energy", m_shower_energy); 00067 } 00068 00069 m_tuple2 = tuple2; 00070 if(!m_tuple2) { 00071 std::cerr << "Invalid ntuple2 in TofEnergyRec!" << std::endl; 00072 } else { 00073 m_tuple2->addItem ("dist", m_seed_dist); 00074 } 00075 }
double TofShower::calib | ( | const int | n, | |
const int | m | |||
) | const |
Definition at line 829 of file TofShower.cxx.
References m_calib.
00830 { 00831 if(n<176&&m<4) { 00832 return m_calib[n][m]; 00833 } else { 00834 return 0; 00835 } 00836 }
double TofShower::calibConst | ( | ) | const [inline] |
double TofShower::ecalib | ( | const int | nsci | ) | const |
Definition at line 813 of file TofShower.cxx.
References m_ecalib.
00814 { 00815 if(nsci<176) { 00816 return m_ecalib[nsci]; 00817 } else { 00818 return 0; 00819 } 00820 }
void TofShower::energyCalib | ( | vector< TofData * > & | tofDataVec, | |
RecTofTrackCol * | recTofTrackCol | |||
) |
Definition at line 77 of file TofShower.cxx.
References TofData::adc1(), TofData::adc2(), TofID::barrel_ec(), ITofCaliSvc::BPh(), TofID::end(), deljobs::end, TofID::endcap(), energy, TofID::is_scin(), TofID::layer(), m_adc1, m_adc2, m_calibConst, m_end, m_energy, m_im, m_layer, m_output, m_part, m_tdc1, m_tdc2, m_tuple, m_zpos, TofID::module(), TofID::phi_module(), TofData::setEnergy(), TofData::setZpos(), TofID::strip(), TofData::tdc1(), TofData::tdc2(), tofCaliSvc, TofData::tofId(), tofQCorrSvc, tofQElecSvc, and ITofCaliSvc::ZTDC().
Referenced by findShower().
00078 { 00079 //Get TOF Calibtration Service 00080 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00081 ITofCaliSvc* tofCaliSvc; 00082 StatusCode sc = svcLocator->service("TofCaliSvc", tofCaliSvc); 00083 if (sc != StatusCode::SUCCESS) { 00084 cout << "TofEnergyRec Get Calibration Service Failed !! " << endl; 00085 } 00086 00087 ITofQCorrSvc* tofQCorrSvc; 00088 sc = svcLocator->service("TofQCorrSvc", tofQCorrSvc); 00089 if (sc != StatusCode::SUCCESS) { 00090 cout << "TofEnergyRec Get QCorr Service Failed !! " << endl; 00091 } 00092 00093 ITofQElecSvc* tofQElecSvc; 00094 sc = svcLocator->service("TofQElecSvc", tofQElecSvc); 00095 if (sc != StatusCode::SUCCESS) { 00096 cout << "TofEnergyRec Get QElec Service Failed !! " << endl; 00097 } 00098 00099 ITofEnergyCalibSvc* m_TofEnergyCalibSvc=0; 00100 sc = svcLocator->service("TofEnergyCalibSvc", m_TofEnergyCalibSvc); 00101 if( sc != StatusCode::SUCCESS){ 00102 cout << "can not use TofEnergyCalibSvc" << endreq; 00103 } 00104 else { 00105 /* 00106 std::cout << "Test TofEnergyCalibSvc getCalibConst= " 00107 << m_TofEnergyCalibSvc -> getCalibConst() 00108 <<"para1="<<m_TofEnergyCalibSvc -> getPara1() 00109 <<"para2="<<m_TofEnergyCalibSvc -> getPara2() 00110 <<"para3="<<m_TofEnergyCalibSvc -> getPara3() 00111 <<"para4="<<m_TofEnergyCalibSvc -> getPara4() 00112 <<"para5="<<m_TofEnergyCalibSvc -> getPara5() 00113 << std::endl; 00114 */ 00115 } 00116 00117 00118 00119 vector<TofData*>::iterator it; 00120 for(it=tofDataVec.begin(); 00121 it!=tofDataVec.end(); 00122 it++) { 00123 00124 Identifier id((*it)->identify()); 00125 if( TofID::is_scin(id) ) { 00126 int barrel_ec = TofID::barrel_ec(id); 00127 int layer = TofID::layer(id); 00128 int im = TofID::phi_module(id); 00129 int end = TofID::end(id); 00130 00131 if(m_output) { 00132 m_part = barrel_ec; 00133 m_layer = layer; 00134 m_im = im; 00135 m_end = end; 00136 } 00137 00138 if((*it)->barrel()) { 00139 TofData* bTofData = (*it); 00140 bTofData->setZpos(99.); 00141 bTofData->setEnergy(0.); 00142 if(bTofData->tdc1()<=0||bTofData->tdc1()>8000||bTofData->tdc2()<=0||bTofData->tdc2()>8000) continue; 00143 00144 double adc1,adc2,tdc1,tdc2; 00145 tdc1 = bTofData->tdc1(); 00146 tdc2 = bTofData->tdc2(); 00147 adc1 = bTofData->adc1(); 00148 adc2 = bTofData->adc2(); 00149 00150 //from data CalibSvc 00151 double zpos = tofCaliSvc->ZTDC( tdc1, tdc2, bTofData->tofId() ); 00152 if(fabs(zpos)>115) continue; 00153 double tofq = tofCaliSvc->BPh( adc1, adc2, zpos, bTofData->tofId()); 00154 if(tofq<100||tofq>10000) continue; 00155 //double energy = q*0.0036; 00156 //double energy = tofq*m_calibConst; //new calibration result in 2009.9.27 00157 //cout<< "TofShower Barrel energy " << energy << endl; 00158 00159 zpos /= 100.; //cm->m 00160 00162 00163 00164 double CalibPar[5]; 00165 00166 CalibPar[0]=m_TofEnergyCalibSvc -> getPara1(); 00167 CalibPar[1]=m_TofEnergyCalibSvc -> getPara2(); 00168 CalibPar[2]=m_TofEnergyCalibSvc -> getPara3(); 00169 CalibPar[3]=m_TofEnergyCalibSvc -> getPara4(); 00170 CalibPar[4]=m_TofEnergyCalibSvc -> getPara5(); 00171 00172 double TofEnCalibConst=CalibPar[0]+CalibPar[1]*zpos+CalibPar[2]*pow(zpos,2)+CalibPar[3]*pow(zpos,3)+CalibPar[4]*pow(zpos,4); 00173 double energy = tofq*TofEnCalibConst; 00174 00175 //cout<<"tofenergy="<<energy<<endl; 00176 //cout<<"tofenergy-old="<<tofq*m_calibConst<<endl; 00178 bTofData->setZpos(zpos); 00179 bTofData->setEnergy(energy); 00180 00181 if(m_output) { 00182 m_part = barrel_ec; 00183 m_layer = layer; 00184 m_im = im; 00185 m_end = end; 00186 m_adc1 = bTofData->adc1(); 00187 m_adc2 = bTofData->adc2(); 00188 m_tdc1 = bTofData->tdc1(); 00189 m_tdc2 = bTofData->tdc2(); 00190 m_zpos = zpos; 00191 m_energy = energy; 00192 m_tuple->write(); 00193 } 00194 00195 } 00196 else { 00197 //cout<<"endcap"<<endl; 00198 //ETofData* eTofData = dynamic_cast<ETofData*>(*it); 00199 //TofData* bTofData = (*it); 00200 //double energy = 2*eTofData->adcChannel()/140; 00201 //eTofData->setEnergy(energy); 00202 } 00203 } 00204 else { 00205 int barrel_ec = TofID::barrel_ec(id); 00206 int endcap = TofID::endcap(id); 00207 int module = TofID::module(id); 00208 int strip = TofID::strip(id); 00209 int end = TofID::end(id); 00210 00211 if( barrel_ec!=3 || ( endcap!=0 && endcap!=1 ) ) { 00212 cout << "TofEnergyRec Get ETF(MRPC) data ERROR !! barrel_ec:" << barrel_ec << " endcap:" << endcap << endl; 00213 } 00214 00215 if(m_output) { 00216 m_part = barrel_ec; 00217 m_layer = endcap; 00218 m_im = module; 00219 m_end = strip; 00220 } 00221 00222 TofData* etfData = (*it); 00223 etfData->setZpos(99.); 00224 etfData->setEnergy(0.); 00225 if(etfData->tdc1()<=0||etfData->tdc1()>8000||etfData->tdc2()<=0||etfData->tdc2()>8000) continue; 00226 00227 double adc1,adc2,tdc1,tdc2; 00228 tdc1 = etfData->tdc1(); 00229 tdc2 = etfData->tdc2(); 00230 adc1 = etfData->adc1(); 00231 adc2 = etfData->adc2(); 00232 00233 //from data CalibSvc 00234 double zpos = tofCaliSvc->ZTDC( tdc1, tdc2, etfData->tofId() ); 00235 if(fabs(zpos)>115) continue; 00236 double tofq = tofCaliSvc->BPh( adc1, adc2, zpos, etfData->tofId()); 00237 if(tofq<100||tofq>10000) continue; 00238 //double energy = q*0.0036; 00239 double energy = tofq*m_calibConst; //new calibration result in 2009.9.27 00240 //cout<< "TofShower Barrel energy " << energy << endl; 00241 zpos /= 100.; //cm->m 00242 00243 etfData->setZpos(zpos); 00244 etfData->setEnergy(energy); 00245 00246 if(m_output) { 00247 m_part = barrel_ec; 00248 m_layer = endcap; 00249 m_im = module; 00250 m_end = strip; 00251 m_adc1 = etfData->adc1(); 00252 m_adc2 = etfData->adc2(); 00253 m_tdc1 = etfData->tdc1(); 00254 m_tdc2 = etfData->tdc2(); 00255 m_zpos = zpos; 00256 m_energy = energy; 00257 m_tuple->write(); 00258 } 00259 } 00260 } 00261 return; 00262 }
void TofShower::findSeed | ( | vector< TofData * > & | tofDataVec | ) |
Definition at line 434 of file TofShower.cxx.
References TofData::energy(), getNextNeighbors(), TofData::identify(), m_seedVec, and max.
Referenced by findShower().
00435 { 00436 bool max=false; 00437 m_seedVec.clear(); 00438 00439 vector<TofData*>::iterator it; 00440 for(it=tofDataVec.begin(); 00441 it!=tofDataVec.end(); 00442 it++) { 00443 00444 if( !((*it)->is_mrpc()) ) { 00445 if((*it)->barrel()) { //barrel 00446 TofData* bTofData = (*it); 00447 00448 //cout << "Identifier(bTofData->identify()) " << Identifier(bTofData->identify()) << endl; 00449 //std::cout << "TofShower bTofData->energy() = " << bTofData->energy() << std::endl; 00450 if(bTofData->energy()<5.) continue; //seed energy cut = 6MeV 00451 00452 max=true; 00453 vector<Identifier> NeighborVec=getNextNeighbors(Identifier(bTofData->identify())); 00454 00455 //const Identifier & help = Identifier(bTofData->identify()); 00456 //cout << "TofShower::findSeed Barrel Track base "<<TofID::layer(help) << " " << TofID::phi_module(help) << endl; 00457 00458 vector<Identifier>::iterator iNeigh; 00459 for(iNeigh=NeighborVec.begin(); 00460 iNeigh!=NeighborVec.end(); 00461 iNeigh++) { 00462 00463 //const Identifier & help2 = Identifier(*iNeigh); 00464 //cout << "TofShower::findSeed Barrel Track neigh "<<TofID::layer(help2) << " " << TofID::phi_module(help2) << endl; 00465 00466 vector<TofData*>::iterator it2; 00467 for(it2=tofDataVec.begin(); 00468 it2!=tofDataVec.end(); 00469 it2++) { 00470 if((*it2)->identify()==*iNeigh) { 00471 TofData* bTofData2 = (*it2); 00472 if(bTofData2->energy()>bTofData->energy()) { 00473 max=false; 00474 } 00475 break; 00476 } 00477 } 00478 00479 } 00480 } 00481 else { //endcap 00482 00483 //cout << "TofShower::findSeed Endcap Track" << endl; 00484 TofData* eTofData = (*it); 00485 if(eTofData->energy()<5.) continue; //seed energy cut = 5MeV 00486 max=true; 00487 vector<Identifier> NeighborVec=getNextNeighbors(Identifier(eTofData->identify())); 00488 vector<Identifier>::iterator iNeigh; 00489 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++) 00490 { 00491 vector<TofData*>::iterator it2; 00492 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++) 00493 { 00494 if((*it2)->identify()==*iNeigh) { 00495 TofData* eTofData2 = (*it2); 00496 if(eTofData2->energy()>eTofData->energy()) { 00497 max=false; 00498 } 00499 break; 00500 } 00501 }//close for 00502 }//Close for 00503 }//close if(!is_mrpc) 00504 00505 } 00506 else 00507 { 00508 00509 TofData* etfData = (*it); 00510 if(etfData->energy()<2.) continue; //Seed energy cut = 2 MeV 00511 max=true; 00512 vector<Identifier> NeighborVec=getNextNeighbors(Identifier(etfData->identify())); 00513 vector<Identifier>::iterator iNeigh; 00514 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++) 00515 { 00516 //cout << "TofShower::findSeed Phimodule MRPC " << TofID::phi_module(*iNeigh) <<endl; 00517 vector<TofData*>::iterator it2; 00518 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++) 00519 { 00520 if((*it2)->identify()==*iNeigh) { 00521 TofData* etfData2 = (*it2); 00522 if(etfData2->energy()>etfData->energy()) { 00523 max=false; 00524 } 00525 break; 00526 } 00527 }//close for 00528 }//Close for 00529 //cout << "TofShower::findSeed Both forloops done" << endl; 00530 }//Close else if(is_mrpc) 00531 00532 if(max) { 00533 m_seedVec.push_back(Identifier((*it)->identify())); 00534 } 00535 00536 }//close loop over tofdata 00537 }//close find seed
void TofShower::findShower | ( | vector< TofData * > & | tofDataVec, | |
RecTofTrackCol * | recTofTrackCol, | |||
double | ||||
) |
Definition at line 540 of file TofShower.cxx.
References abs, TofID::barrel_ec(), TofID::end(), deljobs::end, TofID::endcap(), TofData::energy(), energy, energyCalib(), findSeed(), getNextNeighbors(), TofHitStatus::init(), TofID::is_mrpc(), TofID::layer(), m_output, m_seed_dist, m_seedVec, m_shower_energy, m_shower_im, m_shower_layer, m_shower_part, m_shower_zpos, m_tuple1, m_tuple2, TofID::module(), TofID::phi_module(), DstTofTrack::setEnergy(), DstTofTrack::setStatus(), DstTofTrack::setTofID(), DstTofTrack::setZrHit(), TofID::strip(), and TofHitStatus::value().
Referenced by TofEnergyRec::execute().
00541 { 00542 00543 energyCalib(tofDataVec, recTofTrackCol); 00544 //cout << "TofShower::findShower energycalib OK" << endl; 00545 findSeed(tofDataVec); 00546 //cout << "TofShower::findShower findseed OK" << endl; 00547 00548 vector<Identifier>::iterator iSeed; 00549 00550 for(iSeed=m_seedVec.begin(); iSeed!=m_seedVec.end(); iSeed++) 00551 { 00552 00553 bool is_mrpc = TofID::is_mrpc(*iSeed); 00554 00555 if(!is_mrpc) //Old TofDetector + barrel 00556 { 00557 int barrel_ec = TofID::barrel_ec(*iSeed); 00558 int layer = TofID::layer(*iSeed); 00559 int im = TofID::phi_module(*iSeed); 00560 im += layer * 88; 00561 00562 bool neutral=true; 00563 //match with Tof charged track 00564 int dphi=999; 00565 RecTofTrackCol::iterator iTrack, iMatch; 00566 for(iTrack=recTofTrackCol->begin(); iTrack!=recTofTrackCol->end(); iTrack++) 00567 { 00568 TofHitStatus *status = new TofHitStatus; 00569 status->setStatus((*iTrack)->status()); 00570 if( barrel_ec==1 && status->is_barrel() ) { 00571 dphi=abs(im-(*iTrack)->tofID()); 00572 dphi = dphi>=44 ? 88-dphi : dphi; 00573 } else if( barrel_ec==2 && !(status->is_barrel()) && ((*iTrack)->tofID()>47) ) { 00574 dphi=abs(im-(*iTrack)->tofID()+48); 00575 dphi = dphi>=24 ? 48-dphi : dphi; 00576 } else if( barrel_ec==0 && !(status->is_barrel()) && ((*iTrack)->tofID()<48) ) { 00577 dphi=abs(im-(*iTrack)->tofID()); 00578 dphi = dphi>=24 ? 48-dphi : dphi; 00579 } 00580 if(abs(dphi)<=2) { 00581 iMatch = iTrack; 00582 neutral=false; 00583 break; 00584 } 00585 } 00586 00587 //energy sum of seed and its neighbors 00588 //use avarage mean to calculation position 00589 double zpos=0; 00590 double energy=0; 00591 double seedPos=0; 00592 00593 //cout << "Energhy =0 " << endl; 00594 vector<TofData*>::iterator it; 00595 for(it=tofDataVec.begin(); it!=tofDataVec.end(); it++) 00596 { 00597 if((*it)->identify()==*iSeed) { 00598 //cout<<"iSeed="<<*iSeed<<endl; 00599 if((*it)->barrel()) { 00600 TofData* bTofData = (*it); 00601 zpos+=bTofData->zpos()*bTofData->energy(); 00602 energy+=bTofData->energy(); 00603 seedPos=bTofData->zpos(); 00604 00605 //cout << "Add energy barrel seed "<< TofID::layer(*iSeed) <<" " << TofID::phi_module(*iSeed) << " " << bTofData->energy() << " ---> "<< energy <<endl; 00606 } else { 00607 TofData* eTofData = (*it); 00608 energy+=eTofData->energy(); 00609 00610 //cout << "Add energy" << endl; 00611 } 00612 break; 00613 } 00614 } 00615 00616 vector<Identifier> NeighborVec=getNextNeighbors(*iSeed); 00617 vector<Identifier>::iterator iNeigh; 00618 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++) 00619 { 00620 00621 vector<TofData*>::iterator it2; 00622 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++) 00623 { 00624 if((*it2)->identify()==*iNeigh) { 00625 //cout<<"iNeigh="<<*iNeigh<<endl; 00626 if((*it)->barrel()) { 00627 TofData* bTofData2 = (*it2); 00628 00629 if(fabs(bTofData2->zpos())>2) continue; 00630 if(m_output) { 00631 m_seed_dist = seedPos-bTofData2->zpos(); 00632 m_tuple2->write(); 00633 } 00634 if(fabs(seedPos-bTofData2->zpos())>0.3) continue; 00635 zpos+=bTofData2->zpos()*bTofData2->energy(); 00636 energy+=bTofData2->energy(); 00637 //cout << "Add energy barrel neig " << TofID::layer(*iNeigh) <<" " << TofID::phi_module(*iNeigh) << " " << bTofData2->energy() << " ---> "<< energy <<endl; 00638 } else { 00639 TofData* eTofData2 = (*it2); 00640 energy+=eTofData2->energy(); 00641 } 00642 break; 00643 } 00644 } 00645 } 00646 if(energy>0) zpos/=energy; 00647 00648 //for charged track, set energy 00649 if(neutral==false) { 00650 if(fabs(zpos)<1.15&&energy>5.&&energy<1000) { 00651 (*iMatch)->setEnergy(energy/1000); 00652 } 00653 continue; 00654 } 00655 00656 //for neutral track 00657 if(fabs(zpos)<1.15&&energy>5.&&energy<1000) { //shower energy cut = 10MeV 00658 RecTofTrack* tof = new RecTofTrack; 00659 tof->setTofID(*iSeed); 00660 TofHitStatus* hitStatus = new TofHitStatus; 00661 hitStatus->init(); 00662 tof->setStatus( hitStatus->value()); 00663 tof->setZrHit(zpos); 00664 tof->setEnergy(energy/1000); //MeV-->GeV 00665 recTofTrackCol->push_back(tof); 00666 00667 if(m_output) { 00668 m_shower_part = barrel_ec; 00669 m_shower_layer = layer; 00670 m_shower_im = im; 00671 m_shower_zpos = zpos; 00672 m_shower_energy = energy; 00673 m_tuple1->write(); 00674 } 00675 } 00676 }//close if(!is_mrpc) 00677 else // mrpc_case 00678 { 00679 //Determine wether the track is a neutral one or not:(Compare with charged tracks) 00680 //cout << "TofShower::findShower Seed is mrpc" << endl; 00681 00682 int barrel_ec = TofID::barrel_ec(*iSeed); 00683 int endcap = TofID::endcap(*iSeed); 00684 int im = TofID::module(*iSeed); 00685 int strip = TofID::strip(*iSeed); 00686 int end = TofID::end(*iSeed); 00687 im += endcap * 36; 00688 00689 bool neutral=true; 00690 //match with Tof charged track 00691 int dphi=999, dtheta=999; 00692 RecTofTrackCol::iterator iTrack, iMatch; 00693 for(iTrack=recTofTrackCol->begin(); iTrack!=recTofTrackCol->end(); iTrack++) 00694 { 00695 TofHitStatus *status = new TofHitStatus; 00696 status->setStatus((*iTrack)->status()); 00697 if( barrel_ec==3 && endcap==0 && ((*iTrack)->tofID()<36) ) { 00698 dphi = abs(im-(*iTrack)->tofID()); 00699 dphi = dphi>=18 ? 36-dphi : dphi; 00700 dtheta = abs( strip - status->layer() ); 00701 } else if( barrel_ec==3 && endcap==1 && ((*iTrack)->tofID()>35) ) { 00702 dphi=abs(im-(*iTrack)->tofID()+36); 00703 dphi = dphi>=18 ? 36-dphi : dphi; 00704 dtheta = abs( strip - status->layer() ); 00705 } 00706 if( ( abs(dphi)==0 && abs(dtheta)<=2 ) || ( abs(dphi)==1 && abs(dtheta)<=1 ) ) { 00707 iMatch = iTrack; 00708 neutral = false; 00709 break; 00710 } 00711 } 00712 00713 //energy sum of seed and its neighbors 00714 //use avarage mean to calculation position 00715 double zpos=0; 00716 double energy=0; 00717 double seedPos=0; 00718 00719 //cout << "Energhy =0 " << endl; 00720 vector<TofData*>::iterator it; 00721 for(it=tofDataVec.begin(); it!=tofDataVec.end(); it++) 00722 { 00723 if((*it)->identify()==*iSeed) { 00724 TofData* etfData = (*it); 00725 zpos+=etfData->zpos()*etfData->energy(); 00726 energy+=etfData->energy(); 00727 seedPos=etfData->zpos(); 00728 break; 00729 } 00730 } 00731 00732 vector<Identifier> NeighborVec=getNextNeighbors(*iSeed); 00733 vector<Identifier>::iterator iNeigh; 00734 for(iNeigh=NeighborVec.begin(); iNeigh!=NeighborVec.end(); iNeigh++) 00735 { 00736 vector<TofData*>::iterator it2; 00737 for(it2=tofDataVec.begin(); it2!=tofDataVec.end(); it2++) 00738 { 00739 if((*it)->barrel()) continue; 00740 if((*it2)->identify()==*iNeigh) { 00741 TofData* etfData2 = (*it2); 00742 if(fabs(etfData2->zpos())>2) continue; 00743 if(m_output) { 00744 m_seed_dist = seedPos-etfData2->zpos(); 00745 m_tuple2->write(); 00746 } 00747 if(fabs(seedPos-etfData2->zpos())>0.3) continue; 00748 zpos+=etfData2->zpos()*etfData2->energy(); 00749 energy+=etfData2->energy(); 00750 //cout << "Add energy barrel neig " << TofID::layer(*iNeigh) <<" " << TofID::phi_module(*iNeigh) << " " << bTofData2->energy() << " ---> "<< energy <<endl; 00751 break; 00752 } 00753 } 00754 } 00755 if(energy>0) zpos/=energy; 00756 00757 //for charged track, set energy 00758 if(neutral==false) { 00759 if(fabs(zpos)<1.15&&energy>5.&&energy<1000) { 00760 (*iMatch)->setEnergy(energy/1000); 00761 } 00762 continue; 00763 } 00764 00765 //for neutral track 00766 if(fabs(zpos)<1.15&&energy>5.&&energy<1000) { //shower energy cut = 10MeV 00767 RecTofTrack* tof = new RecTofTrack; 00768 tof->setTofID(*iSeed); 00769 TofHitStatus* hitStatus = new TofHitStatus; 00770 hitStatus->init(); 00771 tof->setStatus( hitStatus->value()); 00772 tof->setZrHit(zpos); 00773 tof->setEnergy(energy/1000); //MeV-->GeV 00774 recTofTrackCol->push_back(tof); 00775 00776 if(m_output) { 00777 m_shower_part = barrel_ec; 00778 m_shower_layer = strip; 00779 m_shower_im = im; 00780 m_shower_zpos = zpos; 00781 m_shower_energy = energy; 00782 m_tuple1->write(); 00783 } 00784 } 00785 } 00786 00787 } 00788 }
vector< Identifier > TofShower::getNeighbors | ( | const Identifier & | id | ) |
Definition at line 264 of file TofShower.cxx.
References TofID::barrel_ec(), TofID::cell_id(), TofID::end(), deljobs::end, TofID::endcap(), genRecEmupikp::i, TofID::is_scin(), ganga-rec::j, TofID::layer(), TofID::module(), num, TofID::phi_module(), delete_small_size::size, and TofID::strip().
Referenced by getNextNeighbors().
00265 { 00266 vector<int> NeighborVec; 00267 vector<Identifier> NeighborIdVec; 00268 NeighborVec.clear(); 00269 NeighborIdVec.clear(); 00270 00271 if( TofID::is_scin(id) ) { 00272 int barrel_ec = TofID::barrel_ec(id); 00273 int layer = TofID::layer(id); 00274 int im = TofID::phi_module(id); 00275 int end = TofID::end(id); 00276 00277 if(barrel_ec==1) { //barrel 00278 int num = im+layer*88; 00279 if(num<88) { //layer1 00280 if(num==0) { 00281 NeighborVec.push_back(1); 00282 NeighborVec.push_back(87); 00283 NeighborVec.push_back(88); 00284 NeighborVec.push_back(89); 00285 } else if(num==87) { 00286 NeighborVec.push_back(0); 00287 NeighborVec.push_back(86); 00288 NeighborVec.push_back(88); 00289 NeighborVec.push_back(175); 00290 } else { 00291 NeighborVec.push_back(num+1); 00292 NeighborVec.push_back(num-1); 00293 NeighborVec.push_back(num+88); 00294 NeighborVec.push_back(num+88+1); 00295 } 00296 } else { 00297 if(num==88) { 00298 NeighborVec.push_back(89); 00299 NeighborVec.push_back(175); 00300 NeighborVec.push_back(0); 00301 NeighborVec.push_back(87); 00302 } else if(num==175) { 00303 NeighborVec.push_back(88); 00304 NeighborVec.push_back(174); 00305 NeighborVec.push_back(86); 00306 NeighborVec.push_back(87); 00307 } else { 00308 NeighborVec.push_back(num+1); 00309 NeighborVec.push_back(num-1); 00310 NeighborVec.push_back(num-88); 00311 NeighborVec.push_back(num-88-1); 00312 } 00313 } 00314 00315 int size=NeighborVec.size(); 00316 for(int i=0;i<size;i++) { 00317 layer = NeighborVec[i]/88; 00318 im = NeighborVec[i]%88; 00319 NeighborIdVec.push_back(TofID::cell_id(barrel_ec,layer,im,end)); 00320 } 00321 } 00322 00323 else { //endcap 00324 if(im==0) { 00325 NeighborVec.push_back(1); 00326 NeighborVec.push_back(47); 00327 } else if(im==47) { 00328 NeighborVec.push_back(0); 00329 NeighborVec.push_back(46); 00330 } else { 00331 NeighborVec.push_back(im-1); 00332 NeighborVec.push_back(im+1); 00333 } 00334 00335 int size=NeighborVec.size(); 00336 for(int i=0;i<size;i++) { 00337 im = NeighborVec[i]; 00338 NeighborIdVec.push_back(TofID::cell_id(barrel_ec,layer,im,end)); 00339 } 00340 } 00341 } 00342 else { // mrpc 00343 int barrel_ec = TofID::barrel_ec(id); 00344 int endcap = TofID::endcap(id); 00345 int module = TofID::module(id); 00346 int strip = TofID::strip(id); 00347 int end = TofID::end(id); 00348 00349 if( module==0 ) { 00350 NeighborVec.push_back(1); 00351 NeighborVec.push_back(35); 00352 } else if( module==35 ) { 00353 NeighborVec.push_back(0); 00354 NeighborVec.push_back(34); 00355 } { 00356 NeighborVec.push_back(module-1); 00357 NeighborVec.push_back(module+1); 00358 } 00359 00360 int size=NeighborVec.size(); 00361 for(int i=0;i<size;i++) { 00362 int im = NeighborVec[i]; 00363 for(int j=-2; j<3; j++ ) { 00364 int ist = strip + j; 00365 if( ist<0 || ist>11 ) continue; 00366 NeighborIdVec.push_back(TofID::cell_id(barrel_ec,endcap,module,ist,end)); 00367 } 00368 } 00369 00370 } 00371 00372 return NeighborIdVec; 00373 }
vector< Identifier > TofShower::getNextNeighbors | ( | const Identifier & | id | ) |
Definition at line 375 of file TofShower.cxx.
References getNeighbors().
Referenced by findSeed(), and findShower().
00376 { 00377 vector<Identifier> NeighborVec,tmpNeighborVec,tmpNextNeighborVec; 00378 vector<Identifier>::iterator ci_NV,ci_tmpNV,ci_tmpNNV; 00379 NeighborVec=getNeighbors(id); 00380 tmpNeighborVec=getNeighbors(id); 00381 bool flag=false; //whether NeighborVec already includes this crystal 00382 bool flagNeighbor=false; //whether this crystal belongs to NeighborVec 00383 00384 //------------------------------------------------------------------ 00385 for(ci_tmpNV=tmpNeighborVec.begin(); 00386 ci_tmpNV!=tmpNeighborVec.end(); 00387 ci_tmpNV++){ 00388 tmpNextNeighborVec=getNeighbors(*ci_tmpNV); 00389 //================================================================ 00390 for(ci_tmpNNV=tmpNextNeighborVec.begin(); 00391 ci_tmpNNV!=tmpNextNeighborVec.end(); 00392 ci_tmpNNV++){ 00393 00394 for(ci_NV=NeighborVec.begin(); 00395 ci_NV!=NeighborVec.end(); 00396 ci_NV++){ 00397 if(*ci_tmpNNV==*ci_NV){ //this crystal is already included 00398 flag=true; 00399 break; 00400 } 00401 } 00402 00403 if(!flag){ //find a new crystal 00404 //for(ci_tmpNV1=tmpNeighborVec.begin(); 00405 // ci_tmpNV1!=tmpNeighborVec.end(); 00406 // ci_tmpNV1++){ 00407 // if(*ci_tmpNNV==*ci_tmpNV1){ //this crystal belongs to NeighborVec 00408 // flagNeighbor=true; 00409 // break; 00410 // } 00411 //} 00412 00413 if(*ci_tmpNNV==id) 00414 flagNeighbor=true; 00415 00416 if(!flagNeighbor) 00417 NeighborVec.push_back(*ci_tmpNNV); 00418 else 00419 flagNeighbor=false; 00420 } 00421 else 00422 flag=false; 00423 } 00424 //================================================================ 00425 } 00426 //------------------------------------------------------------------ 00427 00428 return NeighborVec; 00429 }
bool TofShower::isData | ( | ) | const [inline] |
void TofShower::readCalibPar | ( | ) |
Definition at line 790 of file TofShower.cxx.
References genRecEmupikp::i, m_calib, m_ecalib, and deljobs::string.
00791 { 00792 string paraPath = getenv("TOFENERGYRECROOT"); 00793 paraPath += "/share/peak.dat"; 00794 ifstream in; 00795 in.open(paraPath.c_str()); 00796 assert(in); 00797 for(int i=0;i<176;i++) { 00798 in>>m_ecalib[i]; 00799 } 00800 in.close(); 00801 00802 paraPath = getenv("TOFENERGYRECROOT"); 00803 paraPath += "/share/calib.dat"; 00804 ifstream in1; 00805 in1.open(paraPath.c_str()); 00806 assert(in1); 00807 for(int i=0;i<176;i++) { 00808 in1>>m_calib[i][0]>>m_calib[i][1]>>m_calib[i][2]>>m_calib[i][3]; 00809 } 00810 in1.close(); 00811 }
void TofShower::setCalib | ( | const int | n, | |
const int | m, | |||
const double | ecalib | |||
) |
void TofShower::setCalibConst | ( | const double | cal | ) | [inline] |
Definition at line 39 of file TofShower.h.
References m_calibConst.
Referenced by TofEnergyRec::initialize().
00039 { m_calibConst = cal; }
void TofShower::setEcalib | ( | const int | nsci, | |
const double | ecalib | |||
) |
void TofShower::setIsData | ( | const bool | isData | ) | [inline] |
Definition at line 42 of file TofShower.h.
References m_isData.
Referenced by TofEnergyRec::initialize().
NTuple::Item<double> TofShower::m_adc1 [private] |
NTuple::Item<double> TofShower::m_adc2 [private] |
double TofShower::m_calib[176][4] [private] |
double TofShower::m_calibConst [private] |
Definition at line 48 of file TofShower.h.
Referenced by calibConst(), energyCalib(), and setCalibConst().
double TofShower::m_ecalib[176] [private] |
NTuple::Item<long> TofShower::m_end [private] |
NTuple::Item<double> TofShower::m_energy [private] |
NTuple::Item<long> TofShower::m_im [private] |
bool TofShower::m_isData [private] |
NTuple::Item<long> TofShower::m_layer [private] |
bool TofShower::m_output [private] |
Definition at line 53 of file TofShower.h.
Referenced by BookNtuple(), energyCalib(), and findShower().
NTuple::Item<long> TofShower::m_part [private] |
PropertyMgr TofShower::m_propMgr [private] |
NTuple::Item<double> TofShower::m_seed_dist [private] |
vector<Identifier> TofShower::m_seedVec [private] |
NTuple::Item<double> TofShower::m_shower_energy [private] |
NTuple::Item<long> TofShower::m_shower_im [private] |
NTuple::Item<long> TofShower::m_shower_layer [private] |
NTuple::Item<long> TofShower::m_shower_part [private] |
NTuple::Item<double> TofShower::m_shower_zpos [private] |
NTuple::Item<double> TofShower::m_tdc1 [private] |
NTuple::Item<double> TofShower::m_tdc2 [private] |
NTuple::Tuple* TofShower::m_tuple [private] |
NTuple::Tuple* TofShower::m_tuple1 [private] |
NTuple::Tuple* TofShower::m_tuple2 [private] |
NTuple::Item<double> TofShower::m_zpos [private] |