Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaTrack.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 29 March 2001
2
4//
5// THaTrack
6//
7// A generic track.
8//
10
11#include "THaTrack.h"
12#include "THaCluster.h"
13#include "THaTrackID.h"
14#include <iostream>
15
16using namespace std;
17
18//_____________________________________________________________________________
20{
21 // Destructor. Delete objects owned by this track.
22
23 delete fID;
24}
25
26//_____________________________________________________________________________
28{
29 // If *opt == 'F' then reset all track quantities, else just
30 // delete memory managed by this track.
31 // (We need this behavior so we can Clear("C") the track TClonesArray
32 // without the overhead of clearing everything.)
33
34 //FIXME: too complicated. Do we really need to reallocate the trackID?
35
36 if( opt && (*opt == 'F') ) {
37 fTheta = fPhi = fX = fY = fP = fDp = kBig;
38 fRX = fRY = fRTheta = fRPhi = kBig;
39 fTX = fTY = fTTheta = fTPhi = kBig;
40 fDX = fDY = fDTheta = fDPhi = kBig;
41 fNclusters = 0; fFlag = fType = 0U;
42 fIndex = -1;
43 if( fPIDinfo ) fPIDinfo->Clear( opt );
48 fChi2 = kBig; fNDoF = 0;
49 memset( fClusters, 0, kMAXCL*sizeof(void*) );
50 }
51 delete fID; fID = nullptr;
52}
53
54//_____________________________________________________________________________
56{
57 // Add a cluster to the internal list of pointers.
58 // (Clusters are memory-managed by tracking detectors, not by tracks.)
59
60 if( fNclusters >= kMAXCL )
61 return 1;
62
63 fClusters[ fNclusters++ ] = c;
64 return 0;
65}
66
67//_____________________________________________________________________________
68void THaTrack::Print( Option_t* opt ) const
69{
70 // Print track parameters
71 TObject::Print( opt );
72 cout << "Momentum = " << fP << " GeV/c" << endl;
73 cout << "x_fp = " << fX << " m" << endl;
74 cout << "y_fp = " << fY << " m" << endl;
75 cout << "theta_fp = " << fTheta << " rad" << endl;
76 cout << "phi_fp = " << fPhi << " rad" << endl;
77
78 for( int i=0; i<fNclusters; i++ )
79 fClusters[i]->Print();
80 if( fPIDinfo ) fPIDinfo->Print( opt );
81}
82
83//_____________________________________________________________________________
84static Double_t SafeNDoF( Int_t dof )
85{
86 if( dof <= 0 )
87 return 1e-10;
88 return static_cast<Double_t>(dof);
89}
90
91//_____________________________________________________________________________
93{
94 // compare two tracks by chi2/ndof
95 // for track array sorting
96
97 const auto* tr = dynamic_cast<const THaTrack*>(obj);
98 if (!tr) return 0;
99
101 Double_t v2 = tr->GetChi2()/ SafeNDoF( tr->GetNDoF() );
102
103 if( v1<v2 ) return -1;
104 else if( v1==v2 ) return 0;
105 else return 1;
106}
107
108
109//_____________________________________________________________________________
110
int Int_t
const Data_t kBig
Definition DataType.h:15
#define c(i)
#define e(i)
double Double_t
const char Option_t
static Double_t SafeNDoF(Int_t dof)
Definition THaTrack.cxx:84
virtual void Print(Option_t *opt="") const
virtual void Clear(Option_t *opt="")
Double_t fTime
Definition THaTrack.h:225
Double_t fPathl
Definition THaTrack.h:223
TVector3 fVertexError
Definition THaTrack.h:221
UInt_t fType
Definition THaTrack.h:240
Double_t fdTime
Definition THaTrack.h:226
Double_t GetChi2() const
Definition THaTrack.h:95
Double_t fX
Definition THaTrack.h:194
Double_t fRTheta
Definition THaTrack.h:209
Double_t fTheta
Definition THaTrack.h:196
Double_t fdBeta
Definition THaTrack.h:228
void Clear(Option_t *opt="")
Definition THaTrack.cxx:27
Double_t fRPhi
Definition THaTrack.h:210
Int_t GetNDoF() const
Definition THaTrack.h:96
Double_t fY
Definition THaTrack.h:195
void Print(Option_t *opt="") const
Definition THaTrack.cxx:68
Double_t fRY
Definition THaTrack.h:208
Double_t fTTheta
Definition THaTrack.h:215
TVector3 fPvect
Definition THaTrack.h:219
Int_t AddCluster(THaCluster *c)
Definition THaTrack.cxx:55
Double_t fTX
Definition THaTrack.h:213
virtual Int_t Compare(const TObject *obj) const
Definition THaTrack.cxx:92
Int_t fNDoF
Definition THaTrack.h:243
virtual ~THaTrack()
Definition THaTrack.cxx:19
Int_t fNclusters
Definition THaTrack.h:231
Double_t fBeta
Definition THaTrack.h:227
Double_t fTPhi
Definition THaTrack.h:216
Double_t fDX
Definition THaTrack.h:201
Double_t fTY
Definition THaTrack.h:214
TVector3 fVertex
Definition THaTrack.h:220
Double_t fPhi
Definition THaTrack.h:197
Int_t fIndex
Detector creating this track.
Definition THaTrack.h:235
THaPIDinfo * fPIDinfo
Clusters of this track.
Definition THaTrack.h:233
Double_t fDTheta
Definition THaTrack.h:203
Double_t fChi2
Definition THaTrack.h:242
Double_t fDp
Definition THaTrack.h:217
UInt_t fFlag
Track identifier.
Definition THaTrack.h:239
Double_t fRX
Definition THaTrack.h:207
THaCluster * fClusters[kMAXCL]
Number of clusters.
Definition THaTrack.h:232
Double_t fDY
Definition THaTrack.h:202
THaTrackID * fID
Definition THaTrack.h:238
Double_t fP
Definition THaTrack.h:198
Double_t fDPhi
Definition THaTrack.h:204
virtual void Print(Option_t *option="") const
void SetXYZ(Double_t x, Double_t y, Double_t z)
STL namespace.
v2
v1
ClassImp(TPyArg)