Track.cxx
Go to the documentation of this file.
1 /*
2  * Track.cxx
3  *
4  * Created on: Feb 22, 2021
5  * Author: chilgenb
6  */
7 
9 #include <iostream>
10 
11 using std::vector;
12 using std::pair;
13 using namespace garana;
14 
15 
17  fLenFwd(FLT_MAX),
18  fLenBac(FLT_MAX),
19  fMomBeg(FLT_MAX),
20  fMomEnd(FLT_MAX),
21  fChiFwd(FLT_MAX),
22  fChiBac(FLT_MAX),
23  fNHits (UINT_MAX),
24  fChgFwd(INT_MAX),
25  fChgBac(INT_MAX),
26  fIonFwd(FLT_MAX),
27  fIonBac(FLT_MAX)
28 
29 {
30  fVtx.SetXYZT(FLT_MAX,FLT_MAX,FLT_MAX,FLT_MAX);
31  fEnd.SetXYZT(FLT_MAX,FLT_MAX,FLT_MAX,FLT_MAX);
32  fVtxDir.SetXYZ(FLT_MAX,FLT_MAX,FLT_MAX);
33  fEndDir.SetXYZ(FLT_MAX,FLT_MAX,FLT_MAX);
34 
35  //fTrackParBeg = new float[5];
36  //fTrackParEnd = new float[5];
37  for(size_t i=0; i<5; i++) {
38  fTrackParBeg[i] = FLT_MAX;
39  fTrackParEnd[i] = FLT_MAX;
40  }
41 
42  // fCovMatBeg = new float[15];
43  //fCovMatEnd = new float[15];
44  for(size_t i=0; i<15; i++) {
45  fCovMatBeg[i] = FLT_MAX;
46  fCovMatEnd[i] = FLT_MAX;
47  }
48 }//
49 
50 Track::Track(const float& lenFw, const float& lenBk, const float& pBeg, const float& pEnd,
51  const TLorentzVector& vtx, const TLorentzVector& end, const TVector3& vtxDir, const TVector3& endDir,
52  const float& chiFwd, const float& chiBac, const size_t& nHit,
53  const float* trkParBeg, const float* trkParEnd, const float* covarBeg, const float* covarEnd,
54  const int& chargeFwd, const int& chargeBac, const vector<pair<int,float>>& pidf,
55  const vector<pair<int,float>>& pidb, const float& ionf, const float& ionb, const vector<pair<UInt_t,TLorentzVector>>& truePosVtx,
56  const vector<pair<UInt_t,TLorentzVector>>& truePosEnd, const vector<pair<UInt_t,TLorentzVector>>& trueMomVtx,
57  const vector<pair<UInt_t,TLorentzVector>>& trueMomEnd, const vector<std::pair<int,float>>& trueEnergy ) :
58  fLenFwd(lenFw),
59  fLenBac(lenBk),
60  fMomBeg(pBeg),
61  fMomEnd(pEnd),
62  fVtx (vtx),
63  fEnd (end),
64  fVtxDir(vtxDir),
65  fEndDir(endDir),
66  fChiFwd(chiFwd),
67  fChiBac(chiBac),
68  fNHits (nHit),
69  fChgFwd(chargeFwd),
70  fChgBac(chargeBac),
71  fIonFwd(ionf),
72  fIonBac(ionb),
73  fPidFwd(pidf),
74  fPidBac(pidb),
75  fTruePosVtx(truePosVtx),
76  fTruePosEnd(truePosEnd),
77  fTrueMomVtx(trueMomVtx),
78  fTrueMomEnd(trueMomEnd),
79  fTrueEnergy(trueEnergy)
80 {
81 
82  //std::cout << "about to fill fTrackPar" << std::endl;
83 
84  //fTrackParBeg = new float[5];
85  //fTrackParEnd = new float[5];
86  for(size_t i=0; i<5; i++) {
87  fTrackParBeg[i] = trkParBeg[i];
88  fTrackParEnd[i] = trkParEnd[i];
89  }
90 
91  //fCovMatBeg = new float[15];
92  //fCovMatEnd = new float[15];
93  for(size_t i=0; i<15; i++) {
94  fCovMatBeg[i] = covarBeg[i];
95  fCovMatEnd[i] = covarEnd[i];
96  }
97 }//constructor
98 
99 /*int Track::TruthMatchID() {
100  auto it = std::max_element(fTrueEnergy.begin(),fTrueEnergy.end(),
101  [](const std::pair<int,float>& lhs,const std::pair<int,float>& rhs) -> bool {return lhs.second > rhs.second; }
102  );
103  return (*it).first;
104 }
105 
106 float Track::TruthMatchEDep() { //TODO check if we actually want total EDep rather than just from the leading contributor
107  auto it = std::max_element(fTrueEnergy.begin(),fTrueEnergy.end(),
108  [](const std::pair<int,float>& lhs,const std::pair<int,float>& rhs) -> bool {return lhs.second > rhs.second; }
109  );
110  return (*it).second;
111 }
112 
113 float Track::TruthMatchEDepFrac() {
114  float tot = 0.;
115  for(auto const& pair : fTrueEnergy) {
116  tot += pair.second;
117 
118  }
119 
120  return TruthMatchEDep()/tot;
121 }*/
122 
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
float fCovMatEnd[15]
covariance matrix at end of track
Definition: Track.h:61
int fChgFwd
Definition: Track.h:63
vector< pair< int, float > > fPidBac
Definition: Track.h:68
float fTrackParBeg[5]
Track parameters at beginning of track y, z, curvature, phi, lambda – 5-param track (cm...
Definition: Track.h:58
float fCovMatBeg[15]
covariance matrix at beginning of track – packed in a 1D array, assuming symmetry ...
Definition: Track.h:60
int fChgBac
Definition: Track.h:64
struct vector vector
vector< pair< UInt_t, TLorentzVector > > fTrueMomEnd
4-momentum for each assc&#39;d MCParticle at track end
Definition: Track.h:73
TVector3 fVtxDir
track vertex direction
Definition: Track.h:52
float fIonBac
Definition: Track.h:66
float fMomBeg
momentum of the track at the vertex in GeV/c
Definition: Track.h:48
float fLenBac
length of the track in cm from backwards fit
Definition: Track.h:47
size_t fNHits
number of hits
Definition: Track.h:56
vector< pair< UInt_t, TLorentzVector > > fTruePosVtx
4-position for each assc&#39;d MCParticle at track vertex
Definition: Track.h:70
float fTrackParEnd[5]
Track parameters at end of track y, z, curvature, phi, lambda – 5-param track (cm, cm, cm-1, rad, rad)
Definition: Track.h:59
float fChiBac
chisquared backward fit
Definition: Track.h:55
vector< pair< int, float > > fPidFwd
Definition: Track.h:67
float fLenFwd
< returns the fraction of the total energy contributed to this track that was deposited by the partic...
Definition: Track.h:46
vector< pair< UInt_t, TLorentzVector > > fTruePosEnd
4-position for each assc&#39;d MCParticle at track end
Definition: Track.h:71
float fIonFwd
Definition: Track.h:65
float fMomEnd
momentum of the track at the end in GeV/c
Definition: Track.h:49
vector< pair< UInt_t, TLorentzVector > > fTrueMomVtx
4-momentum for each assc&#39;d MCParticle at track vertex
Definition: Track.h:72
TLorentzVector fVtx
track vertex position 4-vector cm,ns
Definition: Track.h:50
TLorentzVector fEnd
track end position 4-vector cm,ns
Definition: Track.h:51
TVector3 fEndDir
track end direction
Definition: Track.h:53
vector< std::pair< int, float > > fTrueEnergy
true energy (second) [GeV] deposited by MCParticle with trackID (first)
Definition: Track.h:74
float fChiFwd
chisquared forward fit
Definition: Track.h:54