REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsEvent.h
1 
2 #ifndef TRestSoft_TRestDetectorHitsEvent
3 #define TRestSoft_TRestDetectorHitsEvent
4 
5 #include <TAxis.h>
6 #include <TGraph.h>
7 #include <TGraph2D.h>
8 #include <TH2F.h>
9 #include <TMath.h>
10 #include <TRestEvent.h>
11 #include <TRestHits.h>
12 #include <TVector3.h>
13 
14 #include <iostream>
15 
19  private:
24 
27 
28  protected:
29  // TODO These graphs should be placed in TRestHits?
30  // (following similar GetGraph implementation in TRestDetectorSignal)
31 
33  TGraph* fXYHitGraph;
35  TGraph* fXZHitGraph;
37  TGraph* fYZHitGraph;
38 
40  TH2F* fXYHisto;
42  TH2F* fYZHisto;
44  TH2F* fXZHisto;
45 
47  TH1F* fXHisto;
49  TH1F* fYHisto;
51  TH1F* fZHisto;
52 
55 
56  public:
57  void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t = 0, REST_HitType type = XYZ);
58  void AddHit(const TVector3& position, Double_t energy, Double_t time, REST_HitType type = XYZ);
59 
60  void Sort(bool(compareCondition)(const TRestHits::iterator& hit1,
61  const TRestHits::iterator& hit2) = nullptr);
62  void Shuffle(int NLoop);
63 
64  inline size_t GetNumberOfHits() const { return fHits->GetNumberOfHits(); }
65 
66  inline TRestHits* GetHits() const { return fHits; }
67 
69  inline Double_t GetX(int n) const { return fHits->GetX(n); }
70 
72  inline Double_t GetY(int n) const { return fHits->GetY(n); }
73 
75  inline Double_t GetZ(int n) const { return fHits->GetZ(n); }
76 
77  inline REST_HitType GetType(int n) const { return fHits->GetType(n); }
78 
80  inline Double_t GetDistance2(int n, int m) const { return fHits->GetDistance2(n, m); }
81 
85 
86  virtual void Initialize();
87 
88  inline virtual void PrintEvent() const { TRestDetectorHitsEvent::PrintEvent(-1); };
89  virtual void PrintEvent(Int_t nHits) const;
90 
91  inline TVector3 GetPosition(int n) const { return fHits->GetPosition(n); }
92 
93  inline TVector3 GetMeanPosition() const { return fHits->GetMeanPosition(); }
94 
95  inline Int_t GetNumberOfHitsX() const { return fHits->GetNumberOfHitsX(); }
96  inline Int_t GetNumberOfHitsY() const { return fHits->GetNumberOfHitsY(); }
97 
98  inline Double_t GetMeanPositionX() const { return fHits->GetMeanPositionX(); }
99  inline Double_t GetMeanPositionY() const { return fHits->GetMeanPositionY(); }
100  inline Double_t GetMeanPositionZ() const { return fHits->GetMeanPositionZ(); }
101  inline Double_t GetSigmaXY2() const { return fHits->GetSigmaXY2(); }
102  inline Double_t GetSigmaX() const { return fHits->GetSigmaX(); }
103  inline Double_t GetSigmaY() const { return fHits->GetSigmaY(); }
104 
105  inline Double_t GetGaussSigmaX(Double_t error, Int_t nHitsMin) {
106  return GetXZHits()->GetGaussSigmaX(error, nHitsMin);
107  }
108  inline Double_t GetGaussSigmaY(Double_t error, Int_t nHitsMin) {
109  return GetYZHits()->GetGaussSigmaY(error, nHitsMin);
110  }
111  inline Double_t GetGaussSigmaZ(Double_t error, Int_t nHitsMin) const {
112  return fHits->GetGaussSigmaZ(error, nHitsMin);
113  }
114 
115  inline Double_t GetSigmaZ2() const { return fHits->GetSigmaZ2(); }
116  inline Double_t GetSkewXY() const { return fHits->GetSkewXY(); }
117  inline Double_t GetSkewZ() const { return fHits->GetSkewZ(); }
118 
119  inline Double_t GetMaximumHitEnergy() const { return fHits->GetMaximumHitEnergy(); }
120  inline Double_t GetMinimumHitEnergy() const { return fHits->GetMinimumHitEnergy(); }
121  inline Double_t GetMeanHitEnergy() const { return fHits->GetMeanHitEnergy(); }
122 
123  inline Double_t GetEnergyX() const { return fHits->GetEnergyX(); }
124  inline Double_t GetEnergyY() const { return fHits->GetEnergyY(); }
125  inline Double_t GetTotalEnergy() const { return fHits->GetTotalEnergy(); }
126  inline Double_t GetEnergy() const { return fHits->GetTotalEnergy(); }
127 
128  inline Double_t GetEnergy(int n) const { return fHits->GetEnergy(n); }
129  inline Double_t GetTime(int n) const { return GetHits()->GetTime(n); } // return value in us
130 
131  inline Int_t GetClosestHit(const TVector3& position) const { return fHits->GetClosestHit(position); }
132 
133  // Inside Cylinder methods
134  Bool_t anyHitInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius);
135  Bool_t allHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius);
136  Double_t GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius);
137  Int_t GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius);
138  TVector3 GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius);
139 
140  // Inside Prim methods
141  Bool_t anyHitInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta);
142  Bool_t allHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sX, Double_t sY, Double_t theta);
143 
144  Double_t GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta);
145  Int_t GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
146  Double_t theta);
147  TVector3 GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta);
148 
149  // Get distance to cylinder walls methods
150  Double_t GetClosestHitInsideDistanceToCylinderWall(TVector3 x0, TVector3 x1, Double_t radius);
151  Double_t GetClosestHitInsideDistanceToCylinderTop(TVector3 x0, TVector3 x1, Double_t radius);
152  Double_t GetClosestHitInsideDistanceToCylinderBottom(TVector3 x0, TVector3 x1, Double_t radius);
153 
154  // Get distance to prism walls methods
155  Double_t GetClosestHitInsideDistanceToPrismWall(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
156  Double_t theta);
157  Double_t GetClosestHitInsideDistanceToPrismTop(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
158  Double_t theta);
159  Double_t GetClosestHitInsideDistanceToPrismBottom(const TVector3& x0, const TVector3& x1, Double_t sizeX,
160  Double_t sizeY, Double_t theta);
161 
162  TPad* DrawEvent(const TString& option = "");
163 
164  TH2F* GetXYHistogram(std::vector<float> ranges, Double_t pitch = 3, Double_t border = 5);
165  TH2F* GetXZHistogram(std::vector<float> ranges, Double_t pitch = 3, Double_t border = 5);
166  TH2F* GetYZHistogram(std::vector<float> ranges, Double_t pitch = 3, Double_t border = 5);
167 
168  void DrawHistograms(Int_t& column, const TString& histOption = "", double pitch = 0);
169  void DrawGraphs(Int_t& column);
170 
171  // Constructor
173  // Destructor
175 
176  ClassDef(TRestDetectorHitsEvent, 1);
177 };
178 #endif
TH2F * GetXZHistogram(std::vector< float > ranges, Double_t pitch=3, Double_t border=5)
This method draws the hits found on XY as a TH2F and it returns the generated histogram.
TRestHits * GetXYZHits()
This method collects all hits which are compatible with a XYZ hit.
virtual void PrintEvent() const
TVector3 GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the mean position of the hits found inside the cylinder volume given by argument.
TRestHits * GetXZHits()
This method collects all hits which are compatible with a XZ-projected hit.
Double_t GetClosestHitInsideDistanceToCylinderTop(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the distance to the cylinder top face from the closest hit contained inside the c...
void DrawGraphs(Int_t &column)
This method draw the hits events as a graph.
TH1F * fZHisto
An auxiliary TH1F histogram to visualize hits on Z-projection.
TPad * DrawEvent(const TString &option="")
This method draws the hits event structure into a TPad.
Double_t GetX(int n) const
Returns the X-coordinate of hit entry n in mm.
TH2F * fXYHisto
An auxiliary TH2F histogram to visualize hits on XY-projection.
Double_t GetClosestHitInsideDistanceToPrismBottom(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the distance to the prism bottom face from the closest hit contained inside the p...
Int_t GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the total number hits found inside the cylinder volume given by argument.
TH2F * GetXYHistogram(std::vector< float > ranges, Double_t pitch=3, Double_t border=5)
This method draws the hits found on XY as a TH2F and it returns the generated histogram.
Bool_t anyHitInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns true if at least 1 hit is found inside the cylinder volume given by argument.
TH2F * fYZHisto
An auxiliary TH2F histogram to visualize hits on YZ-projection.
Bool_t allHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sX, Double_t sY, Double_t theta)
This method returns true if all hits are found inside the prism volume given by argument.
void DrawHistograms(Int_t &column, const TString &histOption="", double pitch=0)
This method draw the hits events as an histogram.
Double_t GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the total integrated energy of all hits found inside the prism volume given by ar...
Double_t GetClosestHitInsideDistanceToCylinderWall(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the distance to the cylinder wall from the closest hit contained inside the cylin...
TGraph * fYZHitGraph
An auxiliary TGraph pointer to visualize hits on YZ-projection.
Double_t GetY(int n) const
Returns the Y-coordinate of hit entry n in mm.
Double_t GetZ(int n) const
Returns the Z-coordinate of hit entry n in mm.
TRestHits * fHits
The hits structure that is is saved to disk.
TRestHits * fXZHits
An auxiliary TRestHits structure to register hits on XZ projection.
TH2F * fXZHisto
An auxiliary TH2F histogram to visualize hits on XZ-projection.
TRestDetectorHitsEvent()
TRestDetectorHitsEvent default constructor.
Double_t GetDistance2(int n, int m) const
Returns the squared distance between hits n and m.
Int_t GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the total number of hits found inside the prism volume given by argument.
Double_t GetClosestHitInsideDistanceToCylinderBottom(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the distance to the cylinder bottom face from the closest hit contained inside th...
TH1F * fYHisto
An auxiliary TH1F histogram to visualize hits on Y-projection.
TRestHits * fXYZHits
An auxiliary TRestHits structure to register hits on XYZ projection.
TVector3 GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the mean position of all hits found inside the prism volume given by argument.
Bool_t allHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns true if all hits are contained inside the cylinder volume given by argument.
Double_t GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the total integrated energy of all hits found inside the cylinder volume given by...
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t=0, REST_HitType type=XYZ)
Adds a new hit to this event.
TRestHits * GetYZHits()
This method collects all hits which are compatible with a YZ-projected hit.
TGraph * fXZHitGraph
An auxiliary TGraph pointer to visualize hits on XZ-projection.
TH2F * GetYZHistogram(std::vector< float > ranges, Double_t pitch=3, Double_t border=5)
This method draws the hits found on YZ as a TH2F and it returns the generated histogram.
TH1F * fXHisto
An auxiliary TH1F histogram to visualize hits on X-projection.
Double_t GetClosestHitInsideDistanceToPrismTop(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the distance to the prism top face from the closest hit contained inside the pris...
Bool_t anyHitInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns true if at least 1 hit is found inside the prism volume given by argument.
virtual void Initialize()
Removes all hits from this event, and clears all auxiliar variables.
TGraph * fXYHitGraph
An auxiliary TGraph pointer to visualize hits on XY-projection.
Double_t GetClosestHitInsideDistanceToPrismWall(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the distance to the prism wall from the closest hit contained inside the prism vo...
~TRestDetectorHitsEvent()
TRestDetectorHitsEvent default destructor.
TRestHits * fYZHits
An auxiliary TRestHits structure to register hits on YZ projection.
A base class for any REST event.
Definition: TRestEvent.h:38
It saves a 3-coordinate position and an energy for each punctual deposition.
Definition: TRestHits.h:39
Double_t GetEnergyX() const
It calculates the total energy of hits with a valid X coordinate.
Definition: TRestHits.cxx:564
Double_t GetMaximumHitEnergy() const
It returns the maximum hit energy.
Definition: TRestHits.cxx:426
Double_t GetMeanPositionZ() const
It calculates the mean Z position weighting with the energy of the hits with a valid Z coordinate.
Definition: TRestHits.cxx:637
Double_t GetMeanPositionX() const
It calculates the mean X position weighting with the energy of the hits with a valid X coordinate.
Definition: TRestHits.cxx:593
Double_t GetSkewXY() const
It returns the 2-dimensional skewness on the XY-plane which is a measure of the hits distribution asy...
Definition: TRestHits.cxx:979
TVector3 GetMeanPosition() const
It calculates the mean position weighting with the energy of the hits. Each coordinate is calculated ...
Definition: TRestHits.cxx:658
Double_t GetMeanPositionY() const
It calculates the mean Y position weighting with the energy of the hits with a valid Y coordinate.
Definition: TRestHits.cxx:615
Double_t GetMeanHitEnergy() const
It returns the mean hits energy.
Definition: TRestHits.cxx:452
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,...
Definition: TRestHits.cxx:762
Double_t GetSigmaX() const
It calculates the hits standard deviation in the X-coordinate.
Definition: TRestHits.cxx:685
Double_t GetEnergyY() const
It calculates the total energy of hits with a valid Y coordinate.
Definition: TRestHits.cxx:578
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,...
Definition: TRestHits.cxx:907
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,...
Definition: TRestHits.cxx:836
Int_t GetClosestHit(const TVector3 &position) const
It returns the closest hit to a given position.
Definition: TRestHits.cxx:1244
Double_t GetSigmaZ2() const
It returns the hits distribution variance on the Z-axis.
Definition: TRestHits.cxx:997
Double_t GetSkewZ() const
It returns the hits distribution skewness, or asymmetry on the Z-axis.
Definition: TRestHits.cxx:1013
Double_t GetSigmaY() const
It calculates the hits standard deviation in the Y-coordinate.
Definition: TRestHits.cxx:703
Double_t GetDistance2(int n, int m) const
It returns the euclidian distance between hits n and m.
Definition: TRestHits.cxx:1201
TVector3 GetPosition(int n) const
It returns the position of hit number n.
Definition: TRestHits.cxx:515
Double_t GetSigmaXY2() const
It calculates the 2-dimensional hits variance.
Definition: TRestHits.cxx:666
Double_t GetMinimumHitEnergy() const
It returns the minimum hit energy.
Definition: TRestHits.cxx:439
Int_t GetNumberOfHitsY() const
It returns the number of hits with a valid Y coordinate.
Definition: TRestHits.cxx:550
Int_t GetNumberOfHitsX() const
It returns the number of hits with a valid X coordinate.
Definition: TRestHits.cxx:536