REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTrack.cxx
1 
19 #include "TRestTrack.h"
20 
21 using namespace std;
22 
23 ClassImp(TRestTrack);
24 
25 TRestTrack::TRestTrack() {
26  // TRestTrack default constructor
27 }
28 
29 TRestTrack::~TRestTrack() {
30  // TRestTrack destructor
31 }
32 
33 void TRestTrack::Initialize() {
34  fTrackID = 0;
35  fParentID = 0;
36  fTrackEnergy = 0;
37  fTrackLength = 0;
38  fVolumeHits.RemoveHits();
39 }
40 
41 void TRestTrack::SetVolumeHits(TRestVolumeHits hits) {
42  fVolumeHits = hits;
43  fTrackEnergy = hits.GetTotalEnergy();
44  fTrackLength = hits.GetTotalDistance();
45 }
46 
47 void TRestTrack::RemoveVolumeHits() {
48  fVolumeHits.RemoveHits();
49  fTrackEnergy = 0;
50  fTrackLength = 0;
51 }
52 
60 void TRestTrack::GetBoundaries(TVector3& orig, TVector3& end) {
61  const int nHits = fVolumeHits.GetNumberOfHits();
62  int maxBin = 0;
63  double maxEn = 0;
64 
65  for (int i = 0; i < nHits; i++) {
66  double en = fVolumeHits.GetEnergy(i);
67  if (en > maxEn) {
68  maxEn = en;
69  maxBin = i;
70  }
71  }
72 
73  TVector3 maxPos = fVolumeHits.GetPosition(maxBin);
74 
75  TVector3 pos0 = fVolumeHits.GetPosition(0);
76  TVector3 posE = fVolumeHits.GetPosition(nHits - 1);
77 
78  const double maxToFirst = (pos0 - maxPos).Mag();
79  const double maxToLast = (posE - maxPos).Mag();
80 
81  if (maxToFirst < maxToLast) {
82  end = pos0;
83  orig = posE;
84  } else {
85  orig = pos0;
86  end = posE;
87  }
88 }
89 
90 void TRestTrack::PrintTrack(Bool_t fullInfo) {
91  Double_t x = GetMeanPosition().X();
92  Double_t y = GetMeanPosition().Y();
93  Double_t z = GetMeanPosition().Z();
94 
95  cout << "Track ID : " << fTrackID << " Parent ID : " << fParentID;
96 
97  if (isXY()) cout << " is XY " << endl;
98  if (isXZ()) cout << " is XZ " << endl;
99  if (isYZ()) cout << " is YZ " << endl;
100  if (isXYZ()) cout << " is XYZ " << endl;
101  cout << "Energy : " << fTrackEnergy << endl;
102  cout << "Length : " << fTrackLength << endl;
103  cout << "Mean position : ( " << x << " , " << y << " , " << z << " ) " << endl;
104  cout << "Number of track hits : " << fVolumeHits.GetNumberOfHits() << endl;
105  cout << "----------------------------------------" << endl;
106 
107  if (fullInfo) {
108  fVolumeHits.PrintHits();
109  cout << "----------------------------------------" << endl;
110  }
111 }
Double_t GetTotalDistance() const
It determines the distance required to travel from the first to the last hit adding all the distances...
Definition: TRestHits.cxx:1192
void GetBoundaries(TVector3 &orig, TVector3 &end)
This function retreive the origin and the end of a single track based on the most energetic hit....
Definition: TRestTrack.cxx:60