23#ifndef RestCore_TRestMesh
24#define RestCore_TRestMesh
33constexpr int NODE_NOT_SET = -1;
34constexpr int GROUP_NOT_FOUND = -1;
35constexpr int NODE_NOT_FOUND = -1;
80 Double_t
GetX(Int_t nX);
81 Double_t
GetY(Int_t nY);
82 Double_t
GetZ(Int_t nZ);
91 Int_t
GetNodeX(Double_t x, Bool_t relative =
false);
92 Int_t
GetNodeY(Double_t y, Bool_t relative =
false);
93 Int_t
GetNodeZ(Double_t z, Bool_t relative =
false);
95 Int_t
GetNodeX(TVector3 v, Bool_t relative =
false);
96 Int_t
GetNodeY(TVector3 v, Bool_t relative =
false);
97 Int_t
GetNodeZ(TVector3 v, Bool_t relative =
false);
119 Int_t
GetGroupId(Double_t x, Double_t y, Double_t z);
128 void SetOrigin(Double_t oX, Double_t oY, Double_t oZ);
131 void SetSize(Double_t sX, Double_t sY, Double_t sZ);
133 void SetNodes(Int_t nX, Int_t nY, Int_t nZ);
141 std::cout <<
"Warning!! The net size should be the same in X, Y and Z for spherical net!"
173 void AddNode(Double_t x, Double_t y, Double_t z, Double_t en = 0);
181 std::vector<TVector3>
GetTrackBoundaries(TVector3 pos, TVector3 dir, Bool_t particle =
true);
190 TRestMesh(TVector3 size, TVector3 position, Int_t nx, Int_t ny, Int_t nz);
It saves a 3-coordinate position and an energy for each punctual deposition.
A basic class inheriting from TObject to help creating a node grid definition.
void SetSize(Double_t sX, Double_t sY, Double_t sZ)
Sets the origin of the bounding-box and initializes the nodes vector to zero.
TVector3 GetVertex(Int_t id) const
It returns the position of both boundary vertex, bottom vertex identified with id = 0 and top vertex ...
std::vector< TVector3 > GetTrackBoundaries(TVector3 pos, TVector3 dir, Bool_t particle=true)
Finds the intersection of the straight line (track defined by the input arguments given,...
void SetSpherical(Bool_t v)
Sets the coordinate system to spherical.
void RemoveNodes()
It initializes all node vectors to zero.
Bool_t IsInside(TVector3 pos)
It returns true if the position is found inside the grid (box,sphere or cylinder).
Int_t FindNeighbourGroup(Int_t nx, Int_t ny, Int_t nz)
Returns the group id of the first node identified in the neighbour cell from cell=(nx,...
Int_t GetNodeY(Double_t y, Bool_t relative=false)
Gets the node index corresponding to the y-coordinate.
TRestMesh()
Default constructor.
std::vector< Int_t > fNodeY
A std::vector storing the Y-dimension cell id.
TVector3 GetNetSize() const
Returns a std::vector with the size/dimensions of the bounding box.
Int_t GetNodeZ(Double_t z, Bool_t relative=false)
Gets the node index corresponding to the z-coordinate.
void SetNodesFromSphericalHits(TRestHits *hits)
It initializes the nodes using the hit coordinates found inside a TRestHits structure....
Double_t fNetSizeZ
The size of the grid in Z dimension.
Double_t GetY(Int_t nY)
Gets the cartesian position of nodeY.
void SetOrigin(Double_t oX, Double_t oY, Double_t oZ)
Sets the origin of the bounding-box and initializes the nodes vector to zero.
void Regrouping()
Needs TO BE documented.
void AddSphericalNode(Double_t x, Double_t y, Double_t z, Double_t en=0)
If adds corresponding node to xyz-coordinates if not previously defined.
Int_t fNodesX
Number of nodes in X-dimension (R in spherical coordinates)
Int_t GetNodeIndex(Int_t nx, Int_t ny, Int_t nz)
Returns the vector position for a given node index. If the node is not found, -1 will be returned.
Int_t GetNodesZ() const
Returns the number of nodes defined in the Z-dimension.
std::vector< Int_t > fNodeZ
A std::vector storing the Z-dimension cell id.
Int_t GetNodesX() const
Returns the number of nodes defined in the X-dimension.
std::vector< Int_t > fNodeX
A std::vector storing the X-dimension cell id.
Int_t fNumberOfGroups
Total number of groups found.
std::vector< TVector3 > GetTrackBoundariesCylinder(TVector3 pos, TVector3 dir, Bool_t particle=true)
Needs TO BE documented.
void AddNode(Double_t x, Double_t y, Double_t z, Double_t en=0)
If adds corresponding node to xyz-coordinates if not previously defined.
Int_t fNumberOfNodes
Total number of nodes filled.
TVector3 GetGroupPosition(Int_t index)
It returns the average position for all nodes weighted with their corresponding energy.
Int_t GetNumberOfNodes() const
Returns the total number of nodes added.
Double_t fNetSizeX
The size of the grid in X dimension.
TVector3 GetBottomVertex() const
It returns the bottom boundary vertex.
void SetCylindrical(Bool_t v)
Sets the coordinate system to cylindrical.
TVector3 GetTopVertex() const
It returns the top boundary vertex.
Int_t FindForeignNeighbour(Int_t nx, Int_t ny, Int_t nz)
It identifies a foreign neighbour. I.e. if the group id of the neighbour cell is different to the cel...
Bool_t IsSpherical()
Returns true if the coordinate system is set to spherical.
Bool_t fIsCylindrical
A flag to indentify if we use cylindrical coordinates.
Int_t fNodesZ
Number of nodes in Z-dimension (Phi in spherical coordinates)
Int_t GetNodesY() const
Returns the number of nodes defined in the Y-dimension.
Double_t GetNetSizeZ() const
Returns the net size on Z-dimension.
Bool_t IsInsideBoundingBox(TVector3 pos)
It returns true if the position is found inside the bounding box.
Int_t fNodesY
Number of nodes in Y-dimension (Theta in spherical coordinates)
TVector3 GetOrigin() const
Returns the origin of the grid (bottom-left corner)
Double_t GetNetSizeX() const
Returns the net size on X-dimension.
void SetNodesFromHits(TRestHits *hits)
It initializes the nodes using the hit coordinates found inside a TRestHits structure.
TVector3 GetNetCenter()
It returns the position of the mesh center.
void Print()
Prints the nodes information.
Double_t GetGroupEnergy(Int_t index)
It returns the total energy of all nodes corresponding to the group id given by argument.
Int_t GetNodeX(Double_t x, Bool_t relative=false)
Gets the node index corresponding to the x-coordinate.
Double_t GetZ(Int_t nZ)
Gets the cartesian position of nodeZ.
TVector3 GetNodeByIndex(Int_t index)
Returns a node by its position in the std::vector.
TVector3 fNetOrigin
The bottom-left corner of the bounding-box grid.
Int_t GetGroupId(Double_t x, Double_t y, Double_t z)
Returns the group id corresponding to the x,y,z coordinate. If the coordinate falls at a non-initiali...
Bool_t IsCylindrical()
Returns true if the coordinate system is set to cylindrical.
std::vector< Int_t > fNodeGroupID
A std::vector storing the group ID of the corresponding nodes activated.
Double_t GetEnergyAtNode(Int_t nx, Int_t ny, Int_t nz)
Returns the energy at a particular node.
Int_t GetNumberOfGroups() const
Returns the total number of groups identified.
Double_t fNetSizeY
The size of the grid in Y dimension.
void SetNodes(Int_t nX, Int_t nY, Int_t nZ)
Sets the number of nodes and initializes the nodes vector to zero.
Bool_t fIsSpherical
A flag to indentify if we use spherical coordinates.
Double_t GetX(Int_t nX)
Gets the cartesian position of nodeX.
std::vector< Double_t > fEnergy
A std::vector storing the total energy inside the cell id.
Double_t GetNetSizeY() const
Returns the net size on Y-dimension.
TVector3 GetPosition(Int_t nX, Int_t nY, Int_t nZ)
Gets the position of the corresponding node.
~TRestMesh()
Default destructor.