#include <TTrackMC.h>
Public Member Functions | |
virtual | ~TTrackMC () |
Destructor. | |
void | dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const |
dumps debug information. | |
int | hepId (void) const |
returns HEP ID. | |
const TTrackHEP *const | hep (void) const |
returns a pointer to TTrackHEP. | |
bool | charge (void) const |
returns charge matching. | |
double | wireFraction (void) const |
returns wire fraction(F1). | |
double | wireFractionHEP (void) const |
returns wire fraction(F2). | |
double | ptFraction (void) const |
returns pt fraction. | |
double | pzFraction (void) const |
returns pz fraction. | |
const Hep3Vector & | residual (void) const |
returns residual of momentum. | |
double | ptResidual (void) const |
returns residual of pt. | |
double | pzResidual (void) const |
returns residual of pz. | |
double | ptPull (void) const |
returns pull of pt. | |
double | pzPull (void) const |
returns pull of pz. | |
unsigned | state (void) const |
returns state. | |
unsigned | quality (void) const |
returns quality. | |
std::string | qualityString (void) const |
returns quality. | |
void | update (void) |
updates information. | |
Private Member Functions | |
TTrackMC (const TTrack &) | |
Constructor. | |
void | compare (void) |
checks matching of charge. | |
void | classify (void) |
classifies itself. | |
Private Attributes | |
unsigned | _state |
unsigned | _quality |
const TTrack & | _t |
TTrackHEP * | _hep |
int | _hepID |
double | _wireFraction |
double | _wireFractionHEP |
bool | _charge |
double | _ptFraction |
double | _pzFraction |
Hep3Vector | _residual |
double | _cosOpen |
double | _ptResidual |
double | _pzResidual |
double | _ptPull |
double | _pzPull |
Friends | |
class | TrkReco |
Definition at line 54 of file TTrackMC.h.
TTrackMC::TTrackMC | ( | const TTrack & | ) | [private] |
Constructor.
Definition at line 46 of file TTrackMC.cxx.
00047 : _t(t), 00048 _hep(0), 00049 _hepID(-1), 00050 _wireFraction(-999.), 00051 _wireFractionHEP(-999.), 00052 _charge(false), 00053 _ptFraction(-999.), 00054 _pzFraction(-999.), 00055 _ptResidual(-999.), 00056 _pzResidual(-999.), 00057 _ptPull(-999.), 00058 _pzPull(-999.), 00059 _state(0), 00060 _quality(0) { 00061 }
TTrackMC::~TTrackMC | ( | ) | [virtual] |
bool TTrackMC::charge | ( | void | ) | const [inline] |
returns charge matching.
Definition at line 181 of file TTrackMC.h.
References _charge.
Referenced by TTrackManager::saveMCTables().
00181 { 00182 return _charge; 00183 }
void TTrackMC::classify | ( | void | ) | [private] |
classifies itself.
Definition at line 251 of file TTrackMC.cxx.
References _charge, _cosOpen, _hep, _ptFraction, _ptResidual, _pzFraction, _pzResidual, _quality, _state, _wireFraction, TTrackBad, TTrackCharge, TTrackClassified, TTrackGarbage, TTrackGhost, TTrackHep, TTrackMatchingLoose, TTrackMatchingTight, TTrackPt, TTrackPz, and TTrackWire.
00251 { 00252 _state |= TTrackClassified; 00253 _quality = TTrackGarbage; 00254 00255 //...HEP matching... 00256 if (! _hep) return; 00257 _quality |= TTrackHep; 00258 if (fabs(_ptFraction) < .1) _quality |= TTrackPt; 00259 if (fabs(_pzFraction) < .1) _quality |= TTrackPz; 00260 float momResidual = sqrt(_ptResidual * _ptResidual + 00261 _pzResidual * _pzResidual); 00262 00263 if ((momResidual < 0.100) && (_cosOpen > 0.99)) 00264 _quality |= TTrackMatchingLoose; 00265 if ((momResidual < 0.020) && (_cosOpen > 0.998)) 00266 _quality |= TTrackMatchingTight; 00267 00268 //...Wire fraction... 00269 if (_wireFraction < 0.8) return; 00270 _quality |= TTrackWire; 00271 _quality |= TTrackCharge; 00272 00273 //...Charge matching... 00274 if (! _charge) return; 00275 _quality |= TTrackBad; 00276 00277 //...Momentum matching... 00278 if (_quality & TTrackMatchingLoose) 00279 _quality |= TTrackGhost; 00280 00281 //...TTrackGood is set by TrkReco after checking uniqueness... 00282 }
void TTrackMC::compare | ( | void | ) | [private] |
checks matching of charge.
Definition at line 159 of file TTrackMC.cxx.
References _charge, _cosOpen, _hep, _ptFraction, _ptPull, _ptResidual, _pzFraction, _pzPull, _pzResidual, _residual, _t, abs, TTrack::charge(), Helix::Ea(), TTrack::finalHits(), TTrack::helix(), Helix, TMLink::hit(), genRecEmupikp::i, InnerMost(), Helix::kappa(), TMDCWireHit::mc(), Helix::momentum(), TMDCWireHitMC::momentum(), TTrack::p(), Helix::pivot(), TTrack::pt(), TTrackHEP::pType(), TTrack::pz(), and Helix::tanl().
00159 { 00160 if (! _hep) return; 00161 00162 //...Get charge of HEP particle(This part should be done by LUCHARGE)... 00163 int id = _hep->pType(); 00164 int aId = abs(id); 00165 if (aId == 11 || aId == 13 || aId == 15) id *= -1; 00166 00167 //...Compare charge... 00168 if ((int) _t.charge() * id > 0) _charge = true; 00169 00170 //...Get hep mom. at the inner-most hit... 00171 // AList<TMLink> list = _t.cores(); 00172 AList<TMLink> list = _t.finalHits(); 00173 unsigned n = list.length(); 00174 bool found = false; 00175 Vector3 pHep; 00176 Vector3 vHep; 00177 for (unsigned i = 0; i < n; i++) { 00178 TMLink * inner = InnerMost(list); 00179 if (inner->hit()->mc()->hep() == _hep) { 00180 pHep = inner->hit()->mc()->momentum(); 00181 vHep = inner->hit()->mc()->entrance(); 00182 found = true; 00183 break; 00184 } 00185 list.remove(inner); 00186 } 00187 Helix hHep = Helix(vHep, pHep, copysign(1., id)); 00188 hHep.pivot(_t.helix().pivot()); 00189 pHep = hHep.momentum(); 00190 00191 //...For debug... 00192 if (! found) { 00193 std::cout << "TTrackMC::compare !!! something wrong with mc hits" 00194 << std::endl; 00195 00196 //...For debug... 00197 // list = _t.cores(); 00198 // for (unsigned i = 0; i < list.length(); i++) { 00199 // TMLink * inner = innerMost(list); 00200 // std::cout << i << " " << inner << ":" << inner->hit()->mc()->hep(); 00201 // std::cout << " " << _hep << std::endl; 00202 // if (inner->hit()->mc()->hep() == _hep) { 00203 // pHep = inner->hit()->mc()->momentum(); 00204 // break; 00205 // } 00206 // list.remove(inner); 00207 // } 00208 // TMLink * t = 0; 00209 // t->hit(); 00210 //...For debug end... 00211 00212 return; 00213 } 00214 00215 //...Fill caches... 00216 _residual = _t.p() - pHep; 00217 _cosOpen = pHep.unit().dot(_t.p().unit()); 00218 00219 //...Compare pt... 00220 double pt = _t.pt(); 00221 double ptHep = sqrt(pHep.x() * pHep.x() + pHep.y() * pHep.y()); 00222 _ptResidual = pt - ptHep; 00223 const Helix & h = _t.helix(); 00224 Vector dPt(5, 0); 00225 dPt[2] = - 1. / (h.kappa() * h.kappa()); 00226 double ptError2 = h.Ea().similarity(dPt); 00227 if(ptError2<0.0) { 00228 std::cout << h.kappa() << " " << h.Ea() << " dPt=" << dPt << std::endl; 00229 } 00230 double ptError = (ptError2 > 0.) ? sqrt(ptError2) : (DBL_MIN); 00231 _ptPull = (ptError2 > 0.) ? (_ptResidual) / ptError : (FLT_MAX); 00232 _ptFraction = (fabs(ptHep)>(FLT_MIN)) ? _ptResidual / ptHep : 0.0; 00233 00234 //...Compare pz... 00235 double pz = _t.pz(); 00236 double pzHep = pHep.z(); 00237 _pzResidual = pz - pzHep; 00238 Vector dPz(5, 0); 00239 dPz[2] = - h.tanl() / (h.kappa() * h.kappa()); 00240 dPz[4] = 1. / h.kappa(); 00241 double pzError2 = h.Ea().similarity(dPz); 00242 if(pzError2<0.0) { 00243 std::cout << h.kappa() << " " << h.Ea() << " dPz=" << dPz << std::endl; 00244 } 00245 double pzError = (pzError2 > 0.) ? sqrt(pzError2) : (DBL_MIN); 00246 _pzPull = (pzError2 > 0.) ? (_pzResidual) / pzError : (FLT_MAX); 00247 _pzFraction = (abs(pzHep)>FLT_MIN) ? (_pzResidual / pzHep) : (FLT_MAX); 00248 }
void TTrackMC::dump | ( | const std::string & | message = std::string("") , |
|
const std::string & | prefix = std::string("") | |||
) | const |
dumps debug information.
Definition at line 141 of file TTrackMC.cxx.
References _hepID, _ptFraction, _pzFraction, _quality, _state, _t, _wireFraction, _wireFractionHEP, bitDisplay(), TTrack::name(), TTrackBad, TTrackCharge, TTrackGarbage, TTrackGhost, and TTrackGood.
00141 { 00142 std::cout << msg; 00143 std::cout << _t.name() << ":"; 00144 std::cout << "state=" << _state << ":"; 00145 if (_quality & TTrackGood) std::cout << "good :"; 00146 else if (_quality & TTrackGhost) std::cout << "ghost :"; 00147 else if (_quality & TTrackBad) std::cout << "bad :"; 00148 else if (_quality & TTrackCharge) std::cout << "bad :"; 00149 else if (_quality & TTrackGarbage) std::cout << "garbage:"; 00150 else std::cout << "classification error:"; 00151 bitDisplay(_quality, 23, 15); std::cout << ":"; 00152 std::cout << _hepID << ":"; 00153 std::cout << _wireFraction << "," << _wireFractionHEP << ":"; 00154 std::cout << _ptFraction << "," << _pzFraction; 00155 std::cout << std::endl; 00156 }
const TTrackHEP *const TTrackMC::hep | ( | void | ) | const [inline] |
returns a pointer to TTrackHEP.
Definition at line 175 of file TTrackMC.h.
References _hep.
Referenced by TTrackManager::saveMCTables().
00175 { 00176 return _hep; 00177 }
int TTrackMC::hepId | ( | void | ) | const [inline] |
returns HEP ID.
Definition at line 169 of file TTrackMC.h.
References _hepID.
00169 { 00170 return _hepID; 00171 }
double TTrackMC::ptFraction | ( | void | ) | const [inline] |
returns pt fraction.
Definition at line 187 of file TTrackMC.h.
References _ptFraction.
Referenced by TTrackManager::saveMCTables().
00187 { 00188 return _ptFraction; 00189 }
double TTrackMC::ptPull | ( | void | ) | const [inline] |
returns pull of pt.
Definition at line 241 of file TTrackMC.h.
References _ptPull.
00241 { 00242 return _ptPull; 00243 }
double TTrackMC::ptResidual | ( | void | ) | const [inline] |
returns residual of pt.
Definition at line 229 of file TTrackMC.h.
References _ptResidual.
00229 { 00230 return _ptResidual; 00231 }
double TTrackMC::pzFraction | ( | void | ) | const [inline] |
returns pz fraction.
Definition at line 193 of file TTrackMC.h.
References _pzFraction.
Referenced by TTrackManager::saveMCTables().
00193 { 00194 return _pzFraction; 00195 }
double TTrackMC::pzPull | ( | void | ) | const [inline] |
returns pull of pz.
Definition at line 247 of file TTrackMC.h.
References _pzPull.
00247 { 00248 return _pzPull; 00249 }
double TTrackMC::pzResidual | ( | void | ) | const [inline] |
returns residual of pz.
Definition at line 235 of file TTrackMC.h.
References _pzResidual.
00235 { 00236 return _pzResidual; 00237 }
unsigned TTrackMC::quality | ( | void | ) | const [inline] |
returns quality.
Definition at line 217 of file TTrackMC.h.
References _quality.
Referenced by TTrackManager::saveMCTables(), and TrackMCStatus().
00217 { 00218 return _quality; 00219 }
std::string TTrackMC::qualityString | ( | void | ) | const |
returns quality.
Definition at line 285 of file TTrackMC.cxx.
References _quality, and TrackMCQualityString().
00285 { 00286 return TrackMCQualityString(_quality); 00287 }
const Hep3Vector & TTrackMC::residual | ( | void | ) | const [inline] |
returns residual of momentum.
Definition at line 223 of file TTrackMC.h.
References _residual.
00223 { 00224 return _residual; 00225 }
unsigned TTrackMC::state | ( | void | ) | const [inline] |
returns state.
Definition at line 211 of file TTrackMC.h.
References _state.
00211 { 00212 return _state; 00213 }
void TTrackMC::update | ( | void | ) |
updates information.
Definition at line 67 of file TTrackMC.cxx.
References _quality, and _state.
00067 { 00068 _state = 0; 00069 _quality = 0; 00070 /* 00071 //...Prepare counters... 00072 unsigned nHep = TTrackHEP::list().length(); 00073 unsigned nTrk = TrkReco::getTrkReco()->tracks().length(); 00074 unsigned * N1 = (unsigned *) malloc(nHep * sizeof(unsigned)); 00075 float * F1 = (float *) malloc(nHep * sizeof(float)); 00076 unsigned N2 = 0; 00077 for (unsigned i = 0; i < nHep; i++) { 00078 N1[i] = 0; 00079 F1[i] = 0.; 00080 } 00081 00082 //...Prepare for fraction F1... 00083 // const AList<TMLink> & cores = _t.cores(); 00084 const AList<TMLink> & cores = _t.finalHits(); 00085 unsigned nCores = cores.length(); 00086 for (unsigned i = 0; i < nCores; i++) { 00087 TMLink * t = cores[i]; 00088 int hepID = t->hit()->mc()->hep()->id(); 00089 ++N1[hepID]; 00090 } 00091 00092 //...Calculate fraction F1 and find the best HEP... 00093 int bestHep = -1; 00094 TTrackHEP * hep = 0; 00095 float bestF1 = 0.; 00096 for (unsigned i = 0; i < nHep; i++) { 00097 if (nCores) F1[i] = (float) N1[i] / (float) nCores; 00098 if (F1[i] > bestF1) { 00099 bestHep = i; 00100 bestF1 = F1[i]; 00101 } 00102 } 00103 00104 //...Check HEP... 00105 float F2 = 0.; 00106 if (bestHep != -1) { 00107 hep = TTrackHEP::list()[bestHep]; 00108 unsigned nAll = 0; 00109 for (unsigned i = 0; i < hep->hits().length(); i++) { 00110 const TMDCWireHit * hit = hep->hits()[i]->hit(); 00111 if (! hit) continue; 00112 if (hit->state() & WireHitInvalidForFit) continue; 00113 00114 ++nAll; 00115 if (hit->track() == & _t) ++N2; 00116 } 00117 00118 //...Calculate fraction F2... 00119 if (nAll) F2 = (float) N2 / (float) nAll; 00120 } 00121 00122 //...Store results... 00123 _hepID = bestHep; 00124 _hep = hep; 00125 _wireFraction = bestF1; 00126 _wireFractionHEP = F2; 00127 00128 //...Compare charge and momentum... 00129 compare(); 00130 00131 //...Classification... 00132 classify(); 00133 00134 //...Termination... 00135 free(N1); 00136 free(F1); 00137 */ 00138 }
double TTrackMC::wireFraction | ( | void | ) | const [inline] |
returns wire fraction(F1).
Definition at line 199 of file TTrackMC.h.
References _wireFraction.
Referenced by TTrackManager::saveMCTables().
00199 { 00200 return _wireFraction; 00201 }
double TTrackMC::wireFractionHEP | ( | void | ) | const [inline] |
returns wire fraction(F2).
Definition at line 205 of file TTrackMC.h.
References _wireFractionHEP.
Referenced by TTrackManager::saveMCTables().
00205 { 00206 return _wireFractionHEP; 00207 }
friend class TrkReco [friend] |
Definition at line 144 of file TTrackMC.h.
bool TTrackMC::_charge [private] |
double TTrackMC::_cosOpen [private] |
TTrackHEP* TTrackMC::_hep [private] |
int TTrackMC::_hepID [private] |
double TTrackMC::_ptFraction [private] |
Definition at line 135 of file TTrackMC.h.
Referenced by classify(), compare(), dump(), and ptFraction().
double TTrackMC::_ptPull [private] |
double TTrackMC::_ptResidual [private] |
double TTrackMC::_pzFraction [private] |
Definition at line 136 of file TTrackMC.h.
Referenced by classify(), compare(), dump(), and pzFraction().
double TTrackMC::_pzPull [private] |
double TTrackMC::_pzResidual [private] |
unsigned TTrackMC::_quality [private] |
Definition at line 127 of file TTrackMC.h.
Referenced by classify(), dump(), quality(), qualityString(), and update().
Hep3Vector TTrackMC::_residual [private] |
unsigned TTrackMC::_state [private] |
const TTrack& TTrackMC::_t [private] |
double TTrackMC::_wireFraction [private] |
double TTrackMC::_wireFractionHEP [private] |