REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
TRestTrack.cxx
1
18
19#include "TRestTrack.h"
20
21using namespace std;
22
23ClassImp(TRestTrack);
24
25TRestTrack::TRestTrack() {
26 // TRestTrack default constructor
27}
28
29TRestTrack::~TRestTrack() {
30 // TRestTrack destructor
31}
32
33void TRestTrack::Initialize() {
34 fTrackID = 0;
35 fParentID = 0;
36 fTrackEnergy = 0;
37 fTrackLength = 0;
39}
40
41void TRestTrack::SetVolumeHits(TRestVolumeHits hits) {
42 fVolumeHits = hits;
43 fTrackEnergy = hits.GetTotalEnergy();
45}
46
47void TRestTrack::RemoveVolumeHits() {
49 fTrackEnergy = 0;
50 fTrackLength = 0;
51}
52
60void 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
90void 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...
TVector3 GetPosition(int n) const
It returns the position of hit number n.
Int_t fTrackID
Track ID.
Definition TRestTrack.h:30
Double_t fTrackEnergy
Total energy of the track.
Definition TRestTrack.h:32
void GetBoundaries(TVector3 &orig, TVector3 &end)
This function retreive the origin and the end of a single track based on the most energetic hit....
Double_t fTrackLength
Total length of the track.
Definition TRestTrack.h:33
Int_t fParentID
Parent ID.
Definition TRestTrack.h:31
TRestVolumeHits fVolumeHits
Hit volumes that define a track.
Definition TRestTrack.h:36
void RemoveHits()
It removes all hits inside the class.