23 #ifndef TRestSoft_TRestHits
24 #define TRestSoft_TRestHits
28 #include <TGraphErrors.h>
36 enum REST_HitType { unknown = -1, X = 2, Y = 3, Z = 5, XY = 6, XZ = 10, YZ = 15, XYZ = 30, VETO = 100 };
47 std::vector<Float_t>
fX;
50 std::vector<Float_t>
fY;
53 std::vector<Float_t>
fZ;
62 std::vector<REST_HitType>
fType;
65 void Translate(Int_t n, Double_t x, Double_t y, Double_t z);
66 void RotateIn3D(Int_t n, Double_t alpha, Double_t beta, Double_t gamma,
const TVector3& center);
67 void Rotate(Int_t n, Double_t alpha,
const TVector3& vAxis,
const TVector3& vMean);
69 void AddHit(
const TVector3& position, Double_t energy, Double_t time = 0, REST_HitType type = XYZ);
79 virtual void SwapHits(Int_t i, Int_t j);
82 virtual Bool_t
areXY()
const;
83 virtual Bool_t
areXZ()
const;
84 virtual Bool_t
areYZ()
const;
85 virtual Bool_t
areXYZ()
const;
87 Bool_t
isNaN(Int_t n)
const;
93 inline size_t GetNumberOfHits()
const {
return fEnergy.size(); }
95 inline const std::vector<Float_t>& GetX()
const {
return fX; }
96 inline const std::vector<Float_t>& GetY()
const {
return fY; }
97 inline const std::vector<Float_t>& GetZ()
const {
return fZ; }
98 inline const std::vector<Float_t>& GetTime()
const {
return fTime; }
99 inline const std::vector<Float_t>& GetEnergyVector()
const {
return fEnergy; }
101 inline Double_t GetX(
int n)
const {
return fX[n]; }
102 inline Double_t GetY(
int n)
const {
return fY[n]; }
103 inline Double_t GetZ(
int n)
const {
return fZ[n]; }
104 inline Double_t GetTime(
int n)
const {
return fTime[n]; }
105 inline Double_t GetEnergy(
int n)
const {
return fEnergy[n]; }
107 inline REST_HitType GetType(
int n)
const {
return fType[n]; }
127 Double_t
GetGaussSigmaX(Double_t error = 150.0, Int_t nHitsMin = 100000);
128 Double_t
GetGaussSigmaY(Double_t error = 150.0, Int_t nHitsMin = 100000);
129 Double_t
GetGaussSigmaZ(Double_t error = 150.0, Int_t nHitsMin = 100000);
134 Bool_t
isHitNInsidePrism(Int_t n,
const TVector3& x0,
const TVector3& x1, Double_t sizeX, Double_t sizeY,
135 Double_t theta)
const;
137 Double_t theta)
const;
138 Double_t
GetEnergyInPrism(
const TVector3& x0,
const TVector3& x1, Double_t sizeX, Double_t sizeY,
139 Double_t theta)
const;
141 Double_t theta)
const;
143 Double_t theta)
const;
145 Double_t theta)
const;
147 Double_t theta)
const;
149 Bool_t
isHitNInsideCylinder(Int_t n,
const TVector3& x0,
const TVector3& x1, Double_t radius)
const;
154 Double_t
GetEnergyInCylinder(
const TVector3& x0,
const TVector3& x1, Double_t radius)
const;
162 Bool_t
isHitNInsideSphere(Int_t n, Double_t x0, Double_t y0, Double_t z0, Double_t radius)
const;
165 Double_t
GetEnergyInSphere(Double_t x, Double_t y, Double_t z, Double_t radius)
const;
171 Double_t GetTotalEnergy()
const;
173 inline Double_t GetDistance(
int N,
int M)
const {
return TMath::Sqrt(
GetDistance2(N, M)); }
183 TVector2
GetProjection(Int_t n, Int_t m,
const TVector3& position)
const;
186 const TVector3& position)
const;
190 static void GetBoundaries(std::vector<double>& val,
double& max,
double& min,
int& nBins,
193 virtual void PrintHits(Int_t nHits = -1)
const;
197 using iterator_category = std::random_access_iterator_tag;
199 using difference_type = int;
200 using pointer = void;
201 using reference = void;
207 bool isAccessor =
false;
216 float& x() {
return isAccessor ? _x : fHits->
fX[index]; }
217 float& y() {
return isAccessor ? _y : fHits->
fY[index]; }
218 float& z() {
return isAccessor ? _z : fHits->
fZ[index]; }
219 float& t() {
return isAccessor ? _t : fHits->
fTime[index]; }
220 float& e() {
return isAccessor ? _e : fHits->
fEnergy[index]; }
221 REST_HitType& type() {
return isAccessor ? _type : fHits->
fType[index]; }
223 float x()
const {
return isAccessor ? _x : fHits->
fX[index]; }
224 float y()
const {
return isAccessor ? _y : fHits->
fY[index]; }
225 float z()
const {
return isAccessor ? _z : fHits->
fZ[index]; }
226 float t()
const {
return isAccessor ? _t : fHits->
fTime[index]; }
227 float e()
const {
return isAccessor ? _e : fHits->
fEnergy[index]; }
228 REST_HitType type()
const {
return isAccessor ? _type : fHits->
fType[index]; }
243 return i1.index - i2.index;
246 return i1.fHits == i2.fHits && i1.index == i2.index;
249 return i1.fHits != i2.fHits || i1.index != i2.index;
253 return i1.index > i2.index;
257 return i1.index >= i2.index;
260 return i1.index < i2.index;
263 return i1.index <= i2.index;
266 if (i1.fHits == i2.fHits) {
267 i1.fHits->
SwapHits(i1.index, i2.index);
274 inline TRestHits_Iterator end() {
return {
this,
static_cast<int>(GetNumberOfHits())}; }
275 typedef TRestHits_Iterator iterator;
It saves a 3-coordinate position and an energy for each punctual deposition.
TVector3 GetVector(int i, int j) const
It returns the vector that goes from hit j to hit i.
virtual Bool_t areXYZ() const
It will return true only if all the hits inside are of type XYZ.
Double_t GetEnergyX() const
It calculates the total energy of hits with a valid X coordinate.
Double_t GetDistanceToNode(Int_t n) const
It determines the distance required to travel from the first hit to the hit n adding all the distance...
virtual Bool_t areYZ() const
It will return true only if all the hits inside are of type YZ.
void Rotate(Int_t n, Double_t alpha, const TVector3 &vAxis, const TVector3 &vMean)
It rotates hit n by an angle akpha along the vAxis with center at vMean.
virtual Bool_t areXY() const
It will return true only if all the hits inside are of type XY.
Double_t GetMaximumHitEnergy() const
It returns the maximum hit energy.
Int_t GetNumberOfHitsInsidePrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the total number of hits contained inside a prisma delimited between x0 and y0 vertex,...
Double_t GetMeanPositionZ() const
It calculates the mean Z position weighting with the energy of the hits with a valid Z coordinate.
Double_t GetMeanPositionX() const
It calculates the mean X position weighting with the energy of the hits with a valid X coordinate.
Double_t GetSkewXY() const
It returns the 2-dimensional skewness on the XY-plane which is a measure of the hits distribution asy...
Double_t GetHitsTwistWeighted(Int_t n, Int_t m) const
Same as GetHitsTwist but weighting with the energy.
TVector3 GetMeanPosition() const
It calculates the mean position weighting with the energy of the hits. Each coordinate is calculated ...
Double_t GetMeanPositionY() const
It calculates the mean Y position weighting with the energy of the hits with a valid Y coordinate.
virtual void RemoveHits()
It removes all hits inside the class.
Double_t GetMeanHitEnergy() const
It returns the mean hits energy.
Double_t GetTotalDistance() const
It determines the distance required to travel from the first to the last hit adding all the distances...
TVector3 GetMeanPositionInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the mean position using the hits contained inside a cylinder with a given radius and de...
Double_t GetGaussSigmaX(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the X-coordinate. It adds a hit to the right and a hit to the left,...
Double_t GetMeanPositionYInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the mean Y position of hits contained inside a prisma delimited between x0 and x1 verte...
virtual void MergeHits(int n, int m)
It merges hits n and m being the resulting hit placed at the weighted center and being its final ener...
static void GetBoundaries(std::vector< double > &val, double &max, double &min, int &nBins, double offset=10)
TODO This method is not using any TRestHits member. This probably means that it should be placed some...
Bool_t isSortedByEnergy() const
It returns true if the hits are ordered in increasing energies.
Double_t GetSigmaX() const
It calculates the hits standard deviation in the X-coordinate.
Double_t GetTransversalProjection(const TVector3 &p0, const TVector3 &direction, const TVector3 &position) const
It returns the transversal projection of position to the line defined by position and direction.
Double_t GetEnergyInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the total energy contained inside a cylinder with a given radius and delimited between ...
virtual void RemoveHit(int n)
It removes the hit at position n from the list.
std::vector< REST_HitType > fType
The type of hit X,Y,XY,XYZ, ...
std::vector< Float_t > fZ
Position on Z axis for each punctual deposition (units mm)
Double_t GetEnergyY() const
It calculates the total energy of hits with a valid Y coordinate.
Bool_t isHitNInsidePrism(Int_t n, const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines if hit n is contained inside a prisma delimited between x0 and y0 vertex,...
Double_t GetMeanPositionZInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the mean Z position of hits contained inside a prisma delimited between x0 and x1 verte...
Double_t GetMeanPositionXInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the mean position X using the hits contained inside a cylinder with a given radius and ...
Double_t GetHitsTwist(Int_t n, Int_t m) const
A parameter measuring how straight is a given sequence of hits. If the value is close to zero,...
Double_t GetMeanPositionXInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the mean X position of hits contained inside a prisma delimited between x0 and x1 verte...
std::vector< Float_t > fY
Position on Y axis for each punctual deposition (units mm)
std::vector< Float_t > fX
Position on X axis for each punctual deposition (units mm)
Double_t GetEnergyInSphere(const TVector3 &pos0, Double_t radius) const
It determines the total energy contained in a sphere with position pos0 for a given spherical radius.
Double_t GetGaussSigmaZ(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the Z-coordinate. It adds a hit to the right and a hit to the left,...
Int_t GetMostEnergeticHitInRange(Int_t n, Int_t m) const
It returns the most energetic hit found between hits n and m.
Double_t GetEnergyInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the total hit energy contained inside a prisma delimited between x0 and y0 vertex,...
void WriteHitsToTextFile(TString filename)
It writes the hits to a plain text file.
~TRestHits()
Default destructor.
std::vector< Float_t > fEnergy
Energy deposited at each 3-coordinate position (units keV)
void AddHit(const TVector3 &position, Double_t energy, Double_t time=0, REST_HitType type=XYZ)
Adds a new hit to the list of hits using a TVector3.
TVector2 GetProjection(Int_t n, Int_t m, const TVector3 &position) const
It returns the longitudinal and transversal projections of position to the axis defined by the hits n...
Double_t GetGaussSigmaY(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the Y-coordinate. It adds a hit to the right and a hit to the left,...
std::vector< Float_t > fTime
Absolute time information for each punctual deposition (units us, 0 is time of decay)
TRestHits()
Default constructor.
virtual Bool_t areXZ() const
It will return true only if all the hits inside are of type XZ.
Int_t GetClosestHit(const TVector3 &position) const
It returns the closest hit to a given position.
size_t fNHits
Number of punctual energy depositions, it is the length for all the arrays.
void RotateIn3D(Int_t n, Double_t alpha, Double_t beta, Double_t gamma, const TVector3 ¢er)
It rotates hit n following rotations in Z, Y and X by angles gamma, beta and alpha....
Double_t fTotalEnergy
Event total energy.
Int_t GetNumberOfHitsInsideCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the total number of hits contained inside a cylinder with a given radius and delimited ...
Double_t GetSigmaZ2() const
It returns the hits distribution variance on the Z-axis.
Bool_t isHitNInsideCylinder(Int_t n, const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines if hit n is contained inside a cylinder with a given radius and delimited between x0 an...
Double_t GetSkewZ() const
It returns the hits distribution skewness, or asymmetry on the Z-axis.
TVector3 GetMeanPositionInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the mean position of hits contained inside a prisma delimited between x0 and x1 vertex,...
Double_t GetSigmaY() const
It calculates the hits standard deviation in the Y-coordinate.
virtual void SwapHits(Int_t i, Int_t j)
It exchanges hits n and m affecting to the ordering of the hits inside the list of hits.
Bool_t isNaN(Int_t n) const
It will return true only if all the 3-coordinates of hit number n are not a number,...
Double_t GetMaximumHitDistance() const
It returns the maximum distance between 2-hits.
Double_t GetDistance2(int n, int m) const
It returns the euclidian distance between hits n and m.
TVector3 GetPosition(int n) const
It returns the position of hit number n.
virtual void PrintHits(Int_t nHits=-1) const
It prints on screen the first nHits from the list.
Double_t GetMaximumHitDistance2() const
It returns the maximum squared distance between 2-hits.
Double_t GetSigmaXY2() const
It calculates the 2-dimensional hits variance.
Double_t GetMinimumHitEnergy() const
It returns the minimum hit energy.
Int_t GetNumberOfHitsY() const
It returns the number of hits with a valid Y coordinate.
void Translate(Int_t n, Double_t x, Double_t y, Double_t z)
It moves hit n by a given amount (x,y,z).
Bool_t isHitNInsideSphere(Int_t n, const TVector3 &pos0, Double_t radius) const
It determines if the hit n is contained in a sphere with position pos0 for a given sphereical radius.
Int_t GetNumberOfHitsX() const
It returns the number of hits with a valid X coordinate.
Double_t GetHitsPathLength(Int_t n=0, Int_t m=0) const
It determines the distance required to travel from hit n to hit m adding all the distances of the hit...
Double_t GetMeanPositionYInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the mean position Y using the hits contained inside a cylinder with a given radius and ...
Double_t GetMeanPositionZInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the mean position Z using the hits contained inside a cylinder with a given radius and ...