#include <MdcCalRecTrk.h>
Public Member Functions | |
MdcCalRecTrk (int pid) | |
~MdcCalRecTrk () | |
void | setGeomSvc (IMdcGeomSvc *mdcGeomSvc) |
void | setUtilSvc (IMdcUtilitySvc *mdcUtilitySvc) |
void | setRecTrk (RecMdcTrackCol::iterator it_trk) |
void | setKalTrk (RecMdcKalTrackCol::iterator it_trk) |
double | getDr () const |
double | getPhi0 () const |
double | getKappa () const |
double | getDz () const |
double | getTanLamda () const |
double | getPt () const |
double | getP () const |
double | getChisq () const |
int | getNHits () const |
HepLorentzVector | getP4 () const |
MdcCalRecHit * | getRecHit (int index) const |
HepVector | getHelix () const |
HepSymMatrix | getHelixErr () const |
bool | fgNoiseRatio (double phi0) |
bool | getFgNoiseRatio () const |
Public Attributes | |
bool | m_fgNoiseRatio |
Private Attributes | |
IMdcGeomSvc * | m_mdcGeomSvc |
IMdcUtilitySvc * | m_mdcUtilitySvc |
int | m_pid |
double | m_dr |
double | m_phi0 |
double | m_kappa |
double | m_dz |
double | m_tanl |
double | m_pt |
double | m_p |
double | m_chisq |
int | m_nhits |
HepLorentzVector | m_p4 |
std::vector< MdcCalRecHit * > | m_rechit |
HepVector | m_helix |
HepSymMatrix | m_helixerr |
Definition at line 19 of file MdcCalRecTrk.h.
MdcCalRecTrk::MdcCalRecTrk | ( | int | pid | ) |
MdcCalRecTrk::~MdcCalRecTrk | ( | ) |
Definition at line 18 of file MdcCalRecTrk.cxx.
References genRecEmupikp::i, and m_rechit.
00018 { 00019 unsigned int i; 00020 for(i=0; i<m_rechit.size(); i++){ 00021 delete m_rechit[i]; 00022 } 00023 m_rechit.clear(); 00024 }
bool MdcCalRecTrk::fgNoiseRatio | ( | double | phi0 | ) |
Definition at line 129 of file MdcCalRecTrk.cxx.
References MdcGeoWire::Backward(), IMdcUtilitySvc::doca(), calibUtil::ERROR, Bes_Common::FATAL, iter(), IMdcGeomSvc::Layer(), MdcID::layer(), m_mdcGeomSvc, m_mdcUtilitySvc, msgSvc(), MdcGeoLayer::NCell(), pi, and MdcID::wire().
Referenced by setKalTrk(), and setRecTrk().
00129 { 00130 IMessageSvc* msgSvc; 00131 Gaudi::svcLocator() -> service("MessageSvc", msgSvc); 00132 MsgStream log(msgSvc, "MdcCalib"); 00133 00134 IDataProviderSvc* eventSvc = NULL; 00135 Gaudi::svcLocator()->service("EventDataSvc", eventSvc); 00136 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc,"/Event/Digi/MdcDigiCol"); 00137 if (!mdcDigiCol) { 00138 log << MSG::FATAL << "Could not find event" << endreq; 00139 } 00140 00141 int lay; 00142 int cel; 00143 bool hitCel[43][288]; 00144 for(lay=0; lay<43; lay++){ 00145 for(cel=0; cel<288; cel++){ 00146 hitCel[lay][cel] = false; 00147 } 00148 } 00149 00150 MdcDigiCol::iterator iter = mdcDigiCol->begin(); 00151 unsigned fgOverFlow; 00152 int digiId = 0; 00153 Identifier id; 00154 for(; iter != mdcDigiCol->end(); iter++, digiId++) { 00155 MdcDigi *aDigi = (*iter); 00156 id = (aDigi)->identify(); 00157 lay = MdcID::layer(id); 00158 cel = MdcID::wire(id); 00159 fgOverFlow = (aDigi) -> getOverflow(); 00160 00161 bool goodTQ = true; 00162 if ( ((fgOverFlow & 3) !=0 ) || ((fgOverFlow & 12) != 0) || 00163 (aDigi->getTimeChannel() == 0x7FFFFFFF) || 00164 (aDigi->getChargeChannel() == 0x7FFFFFFF) ) goodTQ = false; 00165 00166 bool goodT = true; 00167 if ( ((fgOverFlow & 1) !=0 ) || (aDigi->getTimeChannel() == 0x7FFFFFFF) ) goodT = false; 00168 00169 // if(!goodTQ) continue; 00170 if(!goodT) continue; 00171 00172 hitCel[lay][cel] = true; 00173 } 00174 00175 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc, "/Event/Recon/RecMdcTrackCol"); 00176 if(!newtrkCol){ 00177 log << MSG::ERROR << "Could not find RecMdcTrackCol" << endreq; 00178 return -1; 00179 } 00180 00181 int nNoiRange = 4; // number of cells 00182 double dphi = 1.0; 00183 RecMdcTrackCol::iterator it_trk = newtrkCol->begin(); 00184 for(it_trk = newtrkCol->begin(); it_trk != newtrkCol->end(); it_trk++){ 00185 HitRefVec gothits = (*it_trk) -> getVecHits(); 00186 HitRefVec::iterator it_hit = gothits.begin(); 00187 HepVector helix = (*it_trk)->helix(); 00188 HepSymMatrix helixErr = (*it_trk)->err(); 00189 double phi0Rec = (*it_trk)->helix(1); 00190 double delphi; 00191 if(phi0Rec>phi0) delphi = phi0Rec - phi0; 00192 else delphi = phi0 - phi0Rec; 00193 if(delphi > CLHEP::pi) delphi -= CLHEP::pi; 00194 if(delphi > (CLHEP::pi*0.17)) continue; 00195 00196 int nhitLay1 = 0; // lay0-3 00197 int nhitLay2 = 0; // lay4-7 00198 int nhitLay3 = 0; // lay8-19 00199 int nhitLay4 = 0; // lay20-42 00200 int nhitT1 = 0; 00201 int nhitT2 = 0; 00202 int nhitT3 = 0; 00203 int nhitT4 = 0; 00204 for(lay=0; lay<8; lay++){ 00205 double docamin = 0.7; // cm 00206 if(lay>7) docamin = 0.9; 00207 int celmin = -1; 00208 int ncel = m_mdcGeomSvc->Layer(lay)->NCell(); 00209 for(cel=0; cel<ncel; cel++){ 00210 double wphi; 00211 const MdcGeoWire* pWire = m_mdcGeomSvc -> Wire(lay, cel); 00212 double xx = pWire->Backward().x(); 00213 double yy = pWire->Backward().y(); 00214 double rr = sqrt( (xx * xx) + (yy * yy) ); 00215 if( yy >= 0 ) wphi = acos(xx / rr); 00216 else wphi = CLHEP::twopi - acos(xx / rr); 00217 00218 double phiTrk = phi0 + CLHEP::halfpi; 00219 if(phiTrk > CLHEP::twopi) phiTrk -= CLHEP::twopi; 00220 if( !( (fabs(wphi-phiTrk) < dphi) || (fabs(wphi+CLHEP::twopi-phiTrk) < dphi) || 00221 (fabs(wphi-CLHEP::twopi-phiTrk) < dphi) ) ){ 00222 continue; 00223 } 00224 00225 double doca = m_mdcUtilitySvc->doca(lay, cel, helix, helixErr); 00226 // cout << setw(5) << lay << setw(5) << cel << setw(15) << doca << endl; 00227 if(fabs(doca) < fabs(docamin)){ 00228 docamin = doca; 00229 celmin = cel; 00230 } 00231 } 00232 if(celmin > -1){ 00233 if(lay<4) nhitLay1++; 00234 else if(lay<8) nhitLay2++; 00235 else if(lay<20) nhitLay3++; 00236 else nhitLay4++; 00237 for(int ii=(-nNoiRange); ii<=nNoiRange; ii++){ 00238 if(0==ii) continue; 00239 int icell = celmin + ii; 00240 if(icell >= ncel) icell -= ncel; 00241 if(icell < 0) icell += ncel; 00242 // cout << "hit " << setw(5) << lay << setw(5) << celmin << setw(5) << icell << setw(5) << hitCel[lay][icell]<<endl; 00243 if(hitCel[lay][icell]){ 00244 if(lay<4) nhitT1++; 00245 else if(lay<8) nhitT2++; 00246 else if(lay<20) nhitT3++; 00247 else nhitT4++; 00248 } 00249 } 00250 } 00251 } 00252 if((nhitLay1<=0) || (nhitLay2<=0) || (nhitLay3<=0) || (nhitLay4<=0)) return false; 00253 double ratio1 = (double)nhitT1 / ((double)nhitLay1 * (double)nNoiRange*2.0); 00254 double ratio2 = (double)nhitT2 / ((double)nhitLay2 * (double)nNoiRange*2.0); 00255 double ratio3 = (double)nhitT3 / ((double)nhitLay3 * (double)nNoiRange*2.0); 00256 double ratio4 = (double)nhitT4 / ((double)nhitLay4 * (double)nNoiRange*2.0); 00257 00258 if((ratio1>0.08) || (ratio2>0.08) || (ratio3>0.03) || (ratio4>0.03)) return false; 00259 else return true; 00260 } 00261 return false; 00262 }
double MdcCalRecTrk::getChisq | ( | ) | const [inline] |
double MdcCalRecTrk::getDr | ( | ) | const [inline] |
Definition at line 30 of file MdcCalRecTrk.h.
References m_dr.
Referenced by XtMdcCalib::fillHist(), XtInteMdcCalib::fillHist(), WrMdcCalib::fillHist(), T0MdcCalib::fillHist(), QtMdcCalib::fillHist(), MdcCalib::fillHist(), and GrXtMdcCalib::fillHist().
00030 { return m_dr; }
double MdcCalRecTrk::getDz | ( | ) | const [inline] |
Definition at line 33 of file MdcCalRecTrk.h.
References m_dz.
Referenced by XtMdcCalib::fillHist(), XtInteMdcCalib::fillHist(), WrMdcCalib::fillHist(), T0MdcCalib::fillHist(), QtMdcCalib::fillHist(), MdcCalib::fillHist(), and GrXtMdcCalib::fillHist().
00033 { return m_dz; }
bool MdcCalRecTrk::getFgNoiseRatio | ( | ) | const [inline] |
Definition at line 46 of file MdcCalRecTrk.h.
References m_fgNoiseRatio.
Referenced by T0MdcCalib::fillHist(), and QtMdcCalib::fillHist().
00046 { return m_fgNoiseRatio; }
HepVector MdcCalRecTrk::getHelix | ( | ) | const [inline] |
HepSymMatrix MdcCalRecTrk::getHelixErr | ( | ) | const [inline] |
double MdcCalRecTrk::getKappa | ( | ) | const [inline] |
int MdcCalRecTrk::getNHits | ( | ) | const [inline] |
double MdcCalRecTrk::getP | ( | ) | const [inline] |
HepLorentzVector MdcCalRecTrk::getP4 | ( | ) | const [inline] |
Definition at line 39 of file MdcCalRecTrk.h.
References m_p4.
Referenced by MdcCalib::fillHist().
00039 {return m_p4;}
double MdcCalRecTrk::getPhi0 | ( | ) | const [inline] |
double MdcCalRecTrk::getPt | ( | ) | const [inline] |
MdcCalRecHit* MdcCalRecTrk::getRecHit | ( | int | index | ) | const [inline] |
Definition at line 40 of file MdcCalRecTrk.h.
References m_rechit.
Referenced by MdcCalib::getCellTrkPass().
00040 { return m_rechit[index]; }
double MdcCalRecTrk::getTanLamda | ( | ) | const [inline] |
void MdcCalRecTrk::setGeomSvc | ( | IMdcGeomSvc * | mdcGeomSvc | ) | [inline] |
Definition at line 24 of file MdcCalRecTrk.h.
References m_mdcGeomSvc.
00024 { m_mdcGeomSvc = mdcGeomSvc; }
void MdcCalRecTrk::setKalTrk | ( | RecMdcKalTrackCol::iterator | it_trk | ) |
Definition at line 69 of file MdcCalRecTrk.cxx.
References cos(), Bes_Common::DEBUG, DstMdcKalTrack::electron, Bes_Common::FATAL, fgNoiseRatio(), DstMdcKalTrack::kaon, m_chisq, m_dr, m_dz, m_fgNoiseRatio, m_kappa, m_nhits, m_p, m_p4, m_phi0, m_pid, m_pt, m_rechit, m_tanl, mass, msgSvc(), DstMdcKalTrack::muon, DstMdcKalTrack::pion, DstMdcKalTrack::proton, MdcCalRecHit::setKalHit(), DstMdcKalTrack::setPidType(), and sin().
00069 { 00070 IMessageSvc *msgSvc; 00071 Gaudi::svcLocator()->service("MessageSvc", msgSvc); 00072 MsgStream log(msgSvc, "MdcCalRecTrk"); 00073 log << MSG::DEBUG << "MdcCalRecTrk::setKalTrk()" << endreq; 00074 00075 if(0 == m_pid) RecMdcKalTrack::setPidType(RecMdcKalTrack::electron); 00076 else if(1 == m_pid) RecMdcKalTrack::setPidType(RecMdcKalTrack::muon); 00077 else if(2 == m_pid) RecMdcKalTrack::setPidType(RecMdcKalTrack::pion); 00078 else if(3 == m_pid) RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon); 00079 else if(4 == m_pid) RecMdcKalTrack::setPidType(RecMdcKalTrack::proton); 00080 else if(5 == m_pid) RecMdcKalTrack::setPidType(RecMdcKalTrack::muon); // cosmic-ray 00081 else log << MSG::FATAL << "wrong particle type" << endreq; 00082 00083 m_dr = (*it_trk)->dr(); 00084 m_phi0 = (*it_trk)->fi0(); 00085 m_kappa = (*it_trk)->kappa(); 00086 m_dz = (*it_trk)->dz(); 00087 m_tanl = (*it_trk)->tanl(); 00088 m_chisq = (*it_trk)->chi2(); 00089 m_fgNoiseRatio = fgNoiseRatio(m_phi0); 00090 00091 m_p4.setPx(- sin(m_phi0) / fabs(m_kappa)); 00092 m_p4.setPy(cos(m_phi0) / fabs(m_kappa)); 00093 m_p4.setPz(m_tanl / fabs(m_kappa)); 00094 double p3 = m_p4.mag(); 00095 double mass; 00096 if(0 == m_pid) mass = 0.000511; 00097 else if(1 == m_pid) mass = 0.105658; 00098 else if(2 == m_pid) mass = 0.139570; 00099 else if(3 == m_pid) mass = 0.493677; 00100 else if(4 == m_pid) mass = 0.938272; 00101 else if(5 == m_pid) mass = 0.139570; // cosmic-ray 00102 m_p4.setE(sqrt(p3 * p3 + mass * mass)); 00103 00104 m_dr *= 10.0; // cm -> mm 00105 m_dz *= 10.0; // cm -> mm 00106 00107 m_pt = 1.0 / m_kappa; 00108 m_p = m_pt * sqrt( m_tanl * m_tanl + 1.0 ); 00109 00110 // cout << setw(15) << m_p << setw(15) << m_dr << setw(15) << m_phi0 00111 // << setw(15) << m_kappa << setw(15) << m_dz << setw(15) << m_tanl << endl; 00112 00113 HelixSegRefVec gothelixsegs = (*it_trk)->getVecHelixSegs(); 00114 HelixSegRefVec::iterator it_hit = gothelixsegs.begin(); 00115 MdcCalRecHit* rechit; 00116 00117 int k = 0; 00118 for(; it_hit != gothelixsegs.end(); it_hit++){ 00119 rechit = new MdcCalRecHit(); 00120 rechit->setKalHit(it_hit); 00121 m_rechit.push_back(rechit); 00122 00123 k++; 00124 } 00125 m_nhits = k; 00126 // cout<<"hits "<<m_nhits <<endl; 00127 }
void MdcCalRecTrk::setRecTrk | ( | RecMdcTrackCol::iterator | it_trk | ) |
Definition at line 26 of file MdcCalRecTrk.cxx.
References Bes_Common::DEBUG, Bes_Common::FATAL, fgNoiseRatio(), m_chisq, m_dr, m_dz, m_fgNoiseRatio, m_helix, m_helixerr, m_kappa, m_nhits, m_p, m_p4, m_phi0, m_pid, m_pt, m_rechit, m_tanl, mass, msgSvc(), and MdcCalRecHit::setRecHit().
00026 { 00027 IMessageSvc *msgSvc; 00028 Gaudi::svcLocator()->service("MessageSvc", msgSvc); 00029 MsgStream log(msgSvc, "MdcCalRecTrk"); 00030 log << MSG::DEBUG << "MdcCalRecTrk::setRecTrk()" << endreq; 00031 00032 m_dr = (*it_trk)->helix(0); 00033 m_phi0 = (*it_trk)->helix(1); 00034 m_kappa = (*it_trk)->helix(2); 00035 m_dz = (*it_trk)->helix(3); 00036 m_tanl = (*it_trk)->helix(4); 00037 m_chisq = (*it_trk)->chi2(); 00038 m_nhits = (*it_trk)->getNhits(); 00039 m_helix = (*it_trk)->helix(); 00040 m_helixerr = (*it_trk)->err(); 00041 m_fgNoiseRatio = fgNoiseRatio(m_phi0); 00042 00043 double mass; 00044 if(0 == m_pid) mass = 0.000511; 00045 else if(1 == m_pid) mass = 0.105658; 00046 else if(2 == m_pid) mass = 0.139570; 00047 else if(3 == m_pid) mass = 0.493677; 00048 else if(4 == m_pid) mass = 0.938272; 00049 else if(5 == m_pid) mass = 0.139570; // cosmic-ray 00050 else log << MSG::FATAL << "wrong particle type" << endreq; 00051 m_p4 = (*it_trk)->p4(mass); 00052 00053 m_dr *= 10.0; // cm -> mm 00054 m_dz *= 10.0; // cm -> mm 00055 00056 m_pt = 1.0 / m_kappa; 00057 m_p = m_pt * sqrt( m_tanl * m_tanl + 1.0 ); 00058 00059 HitRefVec gothits = (*it_trk) -> getVecHits(); 00060 HitRefVec::iterator it_hit = gothits.begin(); 00061 MdcCalRecHit* rechit; 00062 for(; it_hit != gothits.end(); it_hit++){ 00063 rechit = new MdcCalRecHit(); 00064 rechit->setRecHit(it_hit); 00065 m_rechit.push_back(rechit); 00066 } 00067 }
void MdcCalRecTrk::setUtilSvc | ( | IMdcUtilitySvc * | mdcUtilitySvc | ) | [inline] |
Definition at line 25 of file MdcCalRecTrk.h.
References m_mdcUtilitySvc.
00025 { m_mdcUtilitySvc = mdcUtilitySvc; }
double MdcCalRecTrk::m_chisq [private] |
Definition at line 60 of file MdcCalRecTrk.h.
Referenced by getChisq(), setKalTrk(), and setRecTrk().
double MdcCalRecTrk::m_dr [private] |
double MdcCalRecTrk::m_dz [private] |
Definition at line 44 of file MdcCalRecTrk.h.
Referenced by getFgNoiseRatio(), setKalTrk(), and setRecTrk().
HepVector MdcCalRecTrk::m_helix [private] |
HepSymMatrix MdcCalRecTrk::m_helixerr [private] |
double MdcCalRecTrk::m_kappa [private] |
Definition at line 55 of file MdcCalRecTrk.h.
Referenced by getKappa(), setKalTrk(), and setRecTrk().
IMdcGeomSvc* MdcCalRecTrk::m_mdcGeomSvc [private] |
IMdcUtilitySvc* MdcCalRecTrk::m_mdcUtilitySvc [private] |
int MdcCalRecTrk::m_nhits [private] |
Definition at line 61 of file MdcCalRecTrk.h.
Referenced by getNHits(), setKalTrk(), and setRecTrk().
double MdcCalRecTrk::m_p [private] |
HepLorentzVector MdcCalRecTrk::m_p4 [private] |
double MdcCalRecTrk::m_phi0 [private] |
Definition at line 54 of file MdcCalRecTrk.h.
Referenced by getPhi0(), setKalTrk(), and setRecTrk().
int MdcCalRecTrk::m_pid [private] |
Definition at line 52 of file MdcCalRecTrk.h.
Referenced by MdcCalRecTrk(), setKalTrk(), and setRecTrk().
double MdcCalRecTrk::m_pt [private] |
std::vector<MdcCalRecHit*> MdcCalRecTrk::m_rechit [private] |
Definition at line 63 of file MdcCalRecTrk.h.
Referenced by getRecHit(), setKalTrk(), setRecTrk(), and ~MdcCalRecTrk().
double MdcCalRecTrk::m_tanl [private] |
Definition at line 57 of file MdcCalRecTrk.h.
Referenced by getTanLamda(), setKalTrk(), and setRecTrk().