Public Member Functions | Private Attributes | Static Private Attributes | List of all members
gar::rec::Track Class Reference

#include <Track.h>

Public Member Functions

 Track ()
 
 Track (const float length, const float momentum_beg, const float momentum_end, const float *vtx, const float *end, const float *vtxDir, const float *endDir, const size_t nhits, const int charge, const double time)
 
 Track (const float lengthforwards, const float lengthbackwards, const size_t nhits, const float xbeg, const float *trackparbeg, const float *covmatbeg, const float chisqforward, const float xend, const float *trackparend, const float *covmatend, const float chisqbackward, const double time)
 
bool operator== (const Track &rhs) const
 
bool operator!= (const Track &rhs) const
 
gar::rec::IDNumber getIDNumber () const
 
const float * Vertex () const
 
const float * End () const
 
const float * VtxDir () const
 
const float * EndDir () const
 
float Length ()
 
float const & LengthForward () const
 
float const & LengthBackward () const
 
float const & Momentum_beg () const
 
float const & Momentum_end () const
 
float const & ChisqForward () const
 
float const & ChisqBackward () const
 
size_t const & NHits () const
 
const float * TrackParBeg () const
 
const float * TrackParEnd () const
 
void CovMatBegSymmetric (float *cmb) const
 
void CovMatEndSymmetric (float *cme) const
 
const float * CovMatBegPacked () const
 
const float * CovMatEndPacked () const
 
int ChargeBeg () const
 
int ChargeEnd () const
 
double const & Time () const
 

Private Attributes

gar::rec::IDNumber fIDnumero
 
float fLengthforwards
 length of the track in cm from forwards fit More...
 
float fLengthbackwards
 length of the track in cm from backwards fit More...
 
float fMomentum_beg
 momentum of the track at the vertex in GeV/c More...
 
float fMomentum_end
 momentum of the track at the end in GeV/c More...
 
float fVertex [3]
 track vertex position in cm – == "beginning" of track. Arbitrary choice made by patrec More...
 
float fEnd [3]
 track end position in cm More...
 
float fVtxDir [3]
 track vertex direction More...
 
float fEndDir [3]
 track end direction More...
 
float fChisqForward
 chisquared forward fit More...
 
float fChisqBackward
 chisquared backward fit More...
 
size_t fNHits
 number of hits More...
 
double fTime
 time in ns from trigger More...
 
float fTrackParBeg [5]
 Track parameters at beginning of track y, z, curvature, phi, lambda – 5-parameter track (cm, cm, cm-1, radians, radians) More...
 
float fTrackParEnd [5]
 Track parameters at end of track y, z, curvature, phi, lambda – 5-parameter track (cm, cm, cm-1, radians, radians) More...
 
float fCovMatBeg [15]
 covariance matrix at beginning of track – packed in a 1D array, assuming symmetry More...
 
float fCovMatEnd [15]
 covariance matrix at end of track More...
 

Static Private Attributes

static gar::rec::IDNumber const FirstNumber = 100000
 

Detailed Description

Definition at line 37 of file Track.h.

Constructor & Destructor Documentation

gar::rec::Track::Track ( )

Definition at line 22 of file Track.cxx.

23  {
24  // The default constructor is used e.g. by art::DataViewImpl::getHandle
25  // Make sure all Track objects are numbered, lest art deep-copy uninitialized
26  // Track instances and then operator==() evaluates meaninglessly true.
29  return;
30  }
static gar::rec::IDNumber const FirstNumber
Definition: Track.h:47
static IDNumberGen * create(IDNumber iniValue=std::numeric_limits< IDNumber >::max())
Definition: IDNumberGen.cxx:18
gar::rec::IDNumber fIDnumero
Definition: Track.h:48
gar::rec::Track::Track ( const float  length,
const float  momentum_beg,
const float  momentum_end,
const float *  vtx,
const float *  end,
const float *  vtxDir,
const float *  endDir,
const size_t  nhits,
const int  charge,
const double  time 
)

Definition at line 49 of file Track.cxx.

59  : fLengthforwards (length )
60  , fLengthbackwards (length )
61  , fMomentum_beg(momentum_beg)
62  , fMomentum_end(momentum_end)
63  , fChisqForward(0)
64  , fChisqBackward(0)
65  , fNHits(nhits)
66  , fTime(time)
67  {
70 
71  auto const* magFieldService = gar::providerFrom<mag::MagneticFieldService>();
72  G4ThreeVector zerovec(0,0,0);
73  G4ThreeVector magfield = magFieldService->FieldAtPoint(zerovec);
74 
75  fVertex[0] = vtx[0];
76  fVertex[1] = vtx[1];
77  fVertex[2] = vtx[2];
78 
79  fVtxDir[0] = vtxDir[0];
80  fVtxDir[1] = vtxDir[1];
81  fVtxDir[2] = vtxDir[2];
82 
83  fEnd[0] = end[0];
84  fEnd[1] = end[1];
85  fEnd[2] = end[2];
86 
87  fEndDir[0] = endDir[0];
88  fEndDir[1] = endDir[1];
89  fEndDir[2] = endDir[2];
90 
91  for (size_t i=0; i<15; ++i)
92  {
93  fCovMatBeg[i] = 0;
94  fCovMatEnd[i] = 0;
95  }
96 
97  // calculate track parameters from information we have
98 
99  fTrackParBeg[0] = vtx[1];
100  fTrackParBeg[1] = vtx[2];
101  float Pt_beg = momentum_beg * TMath::Sqrt(std::max(1E-6,1-TMath::Sq(vtxDir[0])));
102  if (momentum_beg > 0)
103  {
104  fTrackParBeg[2] = (1.0E-2)*0.3*magfield[0]/Pt_beg;
105  }
106  else
107  {
108  fTrackParBeg[2] = 0;
109  }
110  fTrackParBeg[3] = TMath::ATan2(vtxDir[1],vtxDir[2]);
111 
112  if (vtxDir[1] != 0 || vtxDir[2] != 0)
113  {
114  fTrackParBeg[4] = TMath::ATan(vtxDir[0]/TMath::Sqrt(vtxDir[1]*vtxDir[1] + vtxDir[2]*vtxDir[2]));
115  }
116  else
117  {
118  fTrackParBeg[4] = -TMath::Pi()/2.0;
119  }
120 
121  fTrackParEnd[0] = end[1];
122  fTrackParEnd[1] = end[2];
123  float Pt_end = momentum_end * TMath::Sqrt(std::max(1E-6,1-TMath::Sq(endDir[0])));
124  if (momentum_end > 0)
125  {
126  fTrackParEnd[2] = (1.0E-2)*0.3*magfield[0]/Pt_end;
127  }
128  else
129  {
130  fTrackParEnd[2] = 0;
131  }
132  fTrackParEnd[3] = TMath::ATan2(endDir[1],endDir[2]);
133 
134  if (endDir[1] != 0 || endDir[2] != 0)
135  {
136  fTrackParEnd[4] = TMath::ATan(endDir[0]/TMath::Sqrt(endDir[1]*endDir[1] + endDir[2]*endDir[2]));
137  }
138  else
139  {
140  fTrackParEnd[4] = -TMath::Pi()/2.0;
141  }
142 
143  return;
144  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
float fChisqBackward
chisquared backward fit
Definition: Track.h:59
float fChisqForward
chisquared forward fit
Definition: Track.h:58
float fCovMatBeg[15]
covariance matrix at beginning of track – packed in a 1D array, assuming symmetry ...
Definition: Track.h:68
float fMomentum_beg
momentum of the track at the vertex in GeV/c
Definition: Track.h:52
float fCovMatEnd[15]
covariance matrix at end of track
Definition: Track.h:69
double fTime
time in ns from trigger
Definition: Track.h:61
float fTrackParBeg[5]
Track parameters at beginning of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:65
float fLengthforwards
length of the track in cm from forwards fit
Definition: Track.h:50
static gar::rec::IDNumber const FirstNumber
Definition: Track.h:47
float fLengthbackwards
length of the track in cm from backwards fit
Definition: Track.h:51
size_t fNHits
number of hits
Definition: Track.h:60
static IDNumberGen * create(IDNumber iniValue=std::numeric_limits< IDNumber >::max())
Definition: IDNumberGen.cxx:18
float fMomentum_end
momentum of the track at the end in GeV/c
Definition: Track.h:53
float fVertex[3]
track vertex position in cm – == "beginning" of track. Arbitrary choice made by patrec ...
Definition: Track.h:54
static int max(int a, int b)
float fEndDir[3]
track end direction
Definition: Track.h:57
float fTrackParEnd[5]
Track parameters at end of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:66
float fEnd[3]
track end position in cm
Definition: Track.h:55
float fVtxDir[3]
track vertex direction
Definition: Track.h:56
gar::rec::IDNumber fIDnumero
Definition: Track.h:48
gar::rec::Track::Track ( const float  lengthforwards,
const float  lengthbackwards,
const size_t  nhits,
const float  xbeg,
const float *  trackparbeg,
const float *  covmatbeg,
const float  chisqforward,
const float  xend,
const float *  trackparend,
const float *  covmatend,
const float  chisqbackward,
const double  time 
)

Definition at line 147 of file Track.cxx.

159  : fLengthforwards(lengthforwards)
160  , fLengthbackwards(lengthbackwards)
161  , fChisqForward(chisqforward)
162  , fChisqBackward(chisqbackward)
163  , fNHits(nhits)
164  , fTime(time)
165  {
168 
169  auto const* magFieldService = gar::providerFrom<mag::MagneticFieldService>();
170  G4ThreeVector zerovec(0,0,0);
171  G4ThreeVector magfield = magFieldService->FieldAtPoint(zerovec);
172 
173  size_t icov = 0;
174  for (size_t i=0; i< 5; ++i)
175  {
176  fTrackParBeg[i] = trackparbeg[i];
177  fTrackParEnd[i] = trackparend[i];
178  for (size_t j=i; j<5; ++j)
179  {
180  fCovMatBeg[icov] = covmatbeg[i+5*j];
181  fCovMatEnd[icov] = covmatend[i+5*j];
182  ++icov;
183  }
184  }
185 
186  fVertex[0] = xbeg;
187  fVertex[1] = trackparbeg[0];
188  fVertex[2] = trackparbeg[1];
189 
190  FindDirectionFromTrackParameters(trackparbeg, xbeg,xend, fVtxDir);
191 
192  if (trackparbeg[2] != 0)
193  {
194  float poverpt = 1.0/TMath::Sqrt(std::max(1E-6,1.0-TMath::Sq(fVtxDir[0])));
195  fMomentum_beg = poverpt * TMath::Abs((1.0E-2)*0.3*magfield[0]/trackparbeg[2]); // check constant (kG or T?)
196  }
197  else
198  {
199  fMomentum_beg = 0;
200  }
201 
202  fEnd[0] = xend;
203  fEnd[1] = trackparend[0];
204  fEnd[2] = trackparend[1];
205 
206  FindDirectionFromTrackParameters(trackparend, xend,xbeg, fEndDir);
207 
208  if (trackparend[2] != 0)
209  {
210  float poverpt = 1.0/TMath::Sqrt(std::max(1E-6,1.0-TMath::Sq(fEndDir[0])));
211  fMomentum_end = poverpt * TMath::Abs((1.0E-2)*0.3*magfield[0]/trackparend[2]); // check constant (kG or T?)
212  }
213  else
214  {
215  fMomentum_end = 0;
216  }
217 
218  }
float fChisqBackward
chisquared backward fit
Definition: Track.h:59
float fChisqForward
chisquared forward fit
Definition: Track.h:58
float fCovMatBeg[15]
covariance matrix at beginning of track – packed in a 1D array, assuming symmetry ...
Definition: Track.h:68
float fMomentum_beg
momentum of the track at the vertex in GeV/c
Definition: Track.h:52
float fCovMatEnd[15]
covariance matrix at end of track
Definition: Track.h:69
double fTime
time in ns from trigger
Definition: Track.h:61
float fTrackParBeg[5]
Track parameters at beginning of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:65
float fLengthforwards
length of the track in cm from forwards fit
Definition: Track.h:50
static gar::rec::IDNumber const FirstNumber
Definition: Track.h:47
float fLengthbackwards
length of the track in cm from backwards fit
Definition: Track.h:51
size_t fNHits
number of hits
Definition: Track.h:60
static IDNumberGen * create(IDNumber iniValue=std::numeric_limits< IDNumber >::max())
Definition: IDNumberGen.cxx:18
float fMomentum_end
momentum of the track at the end in GeV/c
Definition: Track.h:53
float fVertex[3]
track vertex position in cm – == "beginning" of track. Arbitrary choice made by patrec ...
Definition: Track.h:54
static int max(int a, int b)
float fEndDir[3]
track end direction
Definition: Track.h:57
float fTrackParEnd[5]
Track parameters at end of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:66
float fEnd[3]
track end position in cm
Definition: Track.h:55
float fVtxDir[3]
track vertex direction
Definition: Track.h:56
void FindDirectionFromTrackParameters(const float *tparms, const float thisXend, const float farXend, float *dir)
Definition: Track.cxx:269
gar::rec::IDNumber fIDnumero
Definition: Track.h:48

Member Function Documentation

int gar::rec::Track::ChargeBeg ( ) const

Definition at line 229 of file Track.cxx.

229  {
230  float Zlever = +TMath::Sin(fTrackParBeg[3]) / fTrackParBeg[2];
231  float Ylever = -TMath::Cos(fTrackParBeg[3]) / fTrackParBeg[2];
232  float Xcross = Ylever * fVtxDir[2] - Zlever * fVtxDir[1];
233  return ( Xcross>0 ? -1 : +1 );
234  }
float fTrackParBeg[5]
Track parameters at beginning of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:65
float fVtxDir[3]
track vertex direction
Definition: Track.h:56
int gar::rec::Track::ChargeEnd ( ) const

Definition at line 236 of file Track.cxx.

236  {
237  float Zlever = +TMath::Sin(fTrackParEnd[3]) / fTrackParEnd[2];
238  float Ylever = -TMath::Cos(fTrackParEnd[3]) / fTrackParEnd[2];
239  float Xcross = Ylever * fEndDir[2] - Zlever * fEndDir[1];
240  return ( Xcross>0 ? -1 : +1 );
241  }
float fEndDir[3]
track end direction
Definition: Track.h:57
float fTrackParEnd[5]
Track parameters at end of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:66
float const & gar::rec::Track::ChisqBackward ( ) const
inline

Definition at line 149 of file Track.h.

149 { return fChisqBackward; }
float fChisqBackward
chisquared backward fit
Definition: Track.h:59
float const & gar::rec::Track::ChisqForward ( ) const
inline

Definition at line 148 of file Track.h.

148 { return fChisqForward; }
float fChisqForward
chisquared forward fit
Definition: Track.h:58
const float * gar::rec::Track::CovMatBegPacked ( ) const
inline

Definition at line 153 of file Track.h.

153 { return fCovMatBeg; }
float fCovMatBeg[15]
covariance matrix at beginning of track – packed in a 1D array, assuming symmetry ...
Definition: Track.h:68
void gar::rec::Track::CovMatBegSymmetric ( float *  cmb) const

Definition at line 246 of file Track.cxx.

246  {
247  size_t ic=0;
248  for (size_t i=0; i<5; ++i) {
249  for (size_t j=i; j<5; ++j) {
250  cmb[i + 5*j] = fCovMatBeg[ic];
251  cmb[j + 5*i] = fCovMatBeg[ic];
252  ++ic;
253  }
254  }
255  }
float fCovMatBeg[15]
covariance matrix at beginning of track – packed in a 1D array, assuming symmetry ...
Definition: Track.h:68
const float * gar::rec::Track::CovMatEndPacked ( ) const
inline

Definition at line 154 of file Track.h.

154 { return fCovMatEnd; }
float fCovMatEnd[15]
covariance matrix at end of track
Definition: Track.h:69
void gar::rec::Track::CovMatEndSymmetric ( float *  cme) const

Definition at line 257 of file Track.cxx.

257  {
258  size_t ic=0;
259  for (size_t i=0; i<5; ++i) {
260  for (size_t j=i; j<5; ++j) {
261  cmb[i + 5*j] = fCovMatEnd[ic];
262  cmb[j + 5*i] = fCovMatEnd[ic];
263  ++ic;
264  }
265  }
266  }
float fCovMatEnd[15]
covariance matrix at end of track
Definition: Track.h:69
const float * gar::rec::Track::End ( ) const
inline

Definition at line 140 of file Track.h.

140 { return fEnd; }
float fEnd[3]
track end position in cm
Definition: Track.h:55
const float * gar::rec::Track::EndDir ( ) const
inline

Definition at line 142 of file Track.h.

142 { return fEndDir; }
float fEndDir[3]
track end direction
Definition: Track.h:57
gar::rec::IDNumber gar::rec::Track::getIDNumber ( ) const

Definition at line 42 of file Track.cxx.

42 {return fIDnumero;}
gar::rec::IDNumber fIDnumero
Definition: Track.h:48
float gar::rec::Track::Length ( )
inline

Definition at line 143 of file Track.h.

143 { return 0.5*(fLengthforwards+fLengthbackwards); }
float fLengthforwards
length of the track in cm from forwards fit
Definition: Track.h:50
float fLengthbackwards
length of the track in cm from backwards fit
Definition: Track.h:51
float const & gar::rec::Track::LengthBackward ( ) const
inline

Definition at line 145 of file Track.h.

145 { return fLengthbackwards; }
float fLengthbackwards
length of the track in cm from backwards fit
Definition: Track.h:51
float const & gar::rec::Track::LengthForward ( ) const
inline

Definition at line 144 of file Track.h.

144 { return fLengthforwards; }
float fLengthforwards
length of the track in cm from forwards fit
Definition: Track.h:50
float const & gar::rec::Track::Momentum_beg ( ) const
inline

Definition at line 146 of file Track.h.

146 { return fMomentum_beg; }
float fMomentum_beg
momentum of the track at the vertex in GeV/c
Definition: Track.h:52
float const & gar::rec::Track::Momentum_end ( ) const
inline

Definition at line 147 of file Track.h.

147 { return fMomentum_end; }
float fMomentum_end
momentum of the track at the end in GeV/c
Definition: Track.h:53
size_t const & gar::rec::Track::NHits ( ) const
inline

Definition at line 150 of file Track.h.

150 { return fNHits; }
size_t fNHits
number of hits
Definition: Track.h:60
bool gar::rec::Track::operator!= ( const Track rhs) const

Definition at line 38 of file Track.cxx.

38  {
39  return (this->fIDnumero != rhs.fIDnumero);
40  }
gar::rec::IDNumber fIDnumero
Definition: Track.h:48
bool gar::rec::Track::operator== ( const Track rhs) const

Definition at line 34 of file Track.cxx.

34  {
35  return (this->fIDnumero == rhs.fIDnumero);
36  }
gar::rec::IDNumber fIDnumero
Definition: Track.h:48
double const & gar::rec::Track::Time ( ) const
inline

Definition at line 155 of file Track.h.

155 { return fTime; }
double fTime
time in ns from trigger
Definition: Track.h:61
const float * gar::rec::Track::TrackParBeg ( ) const
inline

Definition at line 151 of file Track.h.

151 { return fTrackParBeg; }
float fTrackParBeg[5]
Track parameters at beginning of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:65
const float * gar::rec::Track::TrackParEnd ( ) const
inline

Definition at line 152 of file Track.h.

152 { return fTrackParEnd; }
float fTrackParEnd[5]
Track parameters at end of track y, z, curvature, phi, lambda – 5-parameter track (cm...
Definition: Track.h:66
const float * gar::rec::Track::Vertex ( ) const
inline

Definition at line 139 of file Track.h.

139 { return fVertex; }
float fVertex[3]
track vertex position in cm – == "beginning" of track. Arbitrary choice made by patrec ...
Definition: Track.h:54
const float * gar::rec::Track::VtxDir ( ) const
inline

Definition at line 141 of file Track.h.

141 { return fVtxDir; }
float fVtxDir[3]
track vertex direction
Definition: Track.h:56

Member Data Documentation

float gar::rec::Track::fChisqBackward
private

chisquared backward fit

Definition at line 59 of file Track.h.

float gar::rec::Track::fChisqForward
private

chisquared forward fit

Definition at line 58 of file Track.h.

float gar::rec::Track::fCovMatBeg[15]
private

covariance matrix at beginning of track – packed in a 1D array, assuming symmetry

Definition at line 68 of file Track.h.

float gar::rec::Track::fCovMatEnd[15]
private

covariance matrix at end of track

Definition at line 69 of file Track.h.

float gar::rec::Track::fEnd[3]
private

track end position in cm

Definition at line 55 of file Track.h.

float gar::rec::Track::fEndDir[3]
private

track end direction

Definition at line 57 of file Track.h.

gar::rec::IDNumber gar::rec::Track::fIDnumero
private

Definition at line 48 of file Track.h.

gar::rec::IDNumber const gar::rec::Track::FirstNumber = 100000
staticprivate

Definition at line 47 of file Track.h.

float gar::rec::Track::fLengthbackwards
private

length of the track in cm from backwards fit

Definition at line 51 of file Track.h.

float gar::rec::Track::fLengthforwards
private

length of the track in cm from forwards fit

Definition at line 50 of file Track.h.

float gar::rec::Track::fMomentum_beg
private

momentum of the track at the vertex in GeV/c

Definition at line 52 of file Track.h.

float gar::rec::Track::fMomentum_end
private

momentum of the track at the end in GeV/c

Definition at line 53 of file Track.h.

size_t gar::rec::Track::fNHits
private

number of hits

Definition at line 60 of file Track.h.

double gar::rec::Track::fTime
private

time in ns from trigger

Definition at line 61 of file Track.h.

float gar::rec::Track::fTrackParBeg[5]
private

Track parameters at beginning of track y, z, curvature, phi, lambda – 5-parameter track (cm, cm, cm-1, radians, radians)

Definition at line 65 of file Track.h.

float gar::rec::Track::fTrackParEnd[5]
private

Track parameters at end of track y, z, curvature, phi, lambda – 5-parameter track (cm, cm, cm-1, radians, radians)

Definition at line 66 of file Track.h.

float gar::rec::Track::fVertex[3]
private

track vertex position in cm – == "beginning" of track. Arbitrary choice made by patrec

Definition at line 54 of file Track.h.

float gar::rec::Track::fVtxDir[3]
private

track vertex direction

Definition at line 56 of file Track.h.


The documentation for this class was generated from the following files: