REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Protected Attributes
TRestMesh Class Reference

Detailed Description

A basic class inheriting from TObject to help creating a node grid definition.

TRestMesh is a helper class allowing to define a uniform grid that can be filled directly with a TRestHits structure.

The class keeps track only of those nodes (cells in the grid) where a hit was found. TRestMesh also includes grouping algorithms allowing to define a node group id. Assigning a unique group id to those cells that are neighbours.

This class was originally created to be used at TRestAxionMagneticField and TRestDetectorHitsToTrackFastProcess.

If spherical coordinates are enabled, the X,Y,Z dimensions will relate to R, Theta, and Phi. The interface with the class still keeps using X,Y,Z coordinates, but the nodes (nX,nY,nZ) will make reference to the position in a grid divided at uniform steps in R, Theta and Phi, where GetX( nX, nY, nZ), GetY( nX, nY, nZ) andGetZ( nX, nY, nZ)` will return the cartesian coordinates, but nX, nY and nZ will make reference to the cell at a given radius, and theta and phi angles.


RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2016-February: First concept and implementation of TRestMesh.

Author
Javier Galan

2021-Abril: Including spherical coordinates capability

Author
Javier Galan

Definition at line 38 of file TRestMesh.h.

#include <TRestMesh.h>

Inheritance diagram for TRestMesh:

Public Member Functions

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.
 
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 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 cell=(nx,ny,nz) it will return the neighbour index with different group id.
 
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,ny,nz).
 
TVector3 GetBottomVertex () const
 It returns the bottom boundary vertex.
 
Double_t GetEnergyAtNode (Int_t nx, Int_t ny, Int_t nz)
 Returns the energy at a particular node.
 
Double_t GetGroupEnergy (Int_t index)
 It returns the total energy of all nodes corresponding to the group id given by argument.
 
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-initialized node, it will return GROUP_NOT_FOUND.
 
Int_t GetGroupId (Int_t index)
 Returns the group id using the position inside the nodes vector.
 
TVector3 GetGroupPosition (Int_t index)
 It returns the average position for all nodes weighted with their corresponding energy.
 
TVector3 GetNetCenter ()
 It returns the position of the mesh center.
 
TVector3 GetNetSize () const
 Returns a std::vector with the size/dimensions of the bounding box.
 
Double_t GetNetSizeX () const
 Returns the net size on X-dimension.
 
Double_t GetNetSizeY () const
 Returns the net size on Y-dimension.
 
Double_t GetNetSizeZ () const
 Returns the net size on Z-dimension.
 
TVector3 GetNodeByIndex (Int_t index)
 Returns a node by its position in the std::vector.
 
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 GetNodesX () const
 Returns the number of nodes defined in the X-dimension.
 
Int_t GetNodesY () const
 Returns the number of nodes defined in the Y-dimension.
 
Int_t GetNodesZ () const
 Returns the number of nodes defined in the Z-dimension.
 
Int_t GetNodeX (Double_t x, Bool_t relative=false)
 Gets the node index corresponding to the x-coordinate. More...
 
Int_t GetNodeX (TVector3 v, Bool_t relative=false)
 Gets the node index corresponding to the x-coordinate or r-coordinate in spherical coordinates. More...
 
Int_t GetNodeY (Double_t y, Bool_t relative=false)
 Gets the node index corresponding to the y-coordinate. More...
 
Int_t GetNodeY (TVector3 v, Bool_t relative=false)
 Gets the node index corresponding to the x-coordinate or theta-coordinate in spherical coordinates. More...
 
Int_t GetNodeZ (Double_t z, Bool_t relative=false)
 Gets the node index corresponding to the z-coordinate. More...
 
Int_t GetNodeZ (TVector3 v, Bool_t relative=false)
 Gets the node index corresponding to the x-coordinate or theta-coordinate in spherical coordinates. More...
 
Int_t GetNumberOfGroups () const
 Returns the total number of groups identified.
 
Int_t GetNumberOfNodes () const
 Returns the total number of nodes added.
 
TVector3 GetOrigin () const
 Returns the origin of the grid (bottom-left corner)
 
TVector3 GetPosition (Int_t nX, Int_t nY, Int_t nZ)
 Gets the position of the corresponding node.
 
TVector3 GetTopVertex () const
 It returns the top boundary 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, a position pos and direction dir) with the boundary box defined by the mesh. More...
 
std::vector< TVector3 > GetTrackBoundariesCylinder (TVector3 pos, TVector3 dir, Bool_t particle=true)
 Needs TO BE documented.
 
TVector3 GetVertex (Int_t id) const
 It returns the position of both boundary vertex, bottom vertex identified with id = 0 and top vertex identified with id = 1.
 
Double_t GetX (Int_t nX)
 Gets the cartesian position of nodeX.
 
Double_t GetY (Int_t nY)
 Gets the cartesian position of nodeY.
 
Double_t GetZ (Int_t nZ)
 Gets the cartesian position of nodeZ.
 
Bool_t IsCylindrical ()
 Returns true if the coordinate system is set to cylindrical.
 
Bool_t IsInside (TVector3 pos)
 It returns true if the position is found inside the grid (box,sphere or cylinder).
 
Bool_t IsInsideBoundingBox (TVector3 pos)
 It returns true if the position is found inside the bounding box.
 
Bool_t IsSpherical ()
 Returns true if the coordinate system is set to spherical.
 
void Print ()
 Prints the nodes information.
 
void Regrouping ()
 Needs TO BE documented.
 
void RemoveNodes ()
 It initializes all node vectors to zero.
 
void SetCylindrical (Bool_t v)
 Sets the coordinate system to cylindrical.
 
void SetNodes (Int_t nX, Int_t nY, Int_t nZ)
 Sets the number of nodes and initializes the nodes vector to zero.
 
void SetNodesFromHits (TRestHits *hits)
 It initializes the nodes using the hit coordinates found inside a TRestHits structure.
 
void SetNodesFromSphericalHits (TRestHits *hits)
 It initializes the nodes using the hit coordinates found inside a TRestHits structure. This method will assume that the hit coordinates are expressed in spherical coordinates. (R, Theta, Phi).
 
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 SetOrigin (TVector3 pos)
 Sets the origin of the bounding-box and initializes the nodes vector to zero.
 
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.
 
void SetSpherical (Bool_t v)
 Sets the coordinate system to spherical.
 
 TRestMesh ()
 Default constructor.
 
 TRestMesh (Double_t size, Int_t nodes)
 Constructor specifying the size (sX=sY=sZ=size) and the number of nodes (nX=nY=nZ=nodes).
 
 TRestMesh (TVector3 size, TVector3 position, Int_t nx, Int_t ny, Int_t nz)
 Constructor specifying the size, origin, and number of nodes in each dimension.
 
 ~TRestMesh ()
 Default destructor.
 

Protected Attributes

std::vector< Double_t > fEnergy
 A std::vector storing the total energy inside the cell id.
 
Bool_t fIsCylindrical = false
 A flag to indentify if we use cylindrical coordinates.
 
Bool_t fIsSpherical = false
 A flag to indentify if we use spherical coordinates.
 
TVector3 fNetOrigin = TVector3(0, 0, 0)
 The bottom-left corner of the bounding-box grid.
 
Double_t fNetSizeX = 0
 The size of the grid in X dimension.
 
Double_t fNetSizeY = 0
 The size of the grid in Y dimension.
 
Double_t fNetSizeZ = 0
 The size of the grid in Z dimension.
 
std::vector< Int_t > fNodeGroupID
 A std::vector storing the group ID of the corresponding nodes activated.
 
Int_t fNodesX = 0
 Number of nodes in X-dimension (R in spherical coordinates)
 
Int_t fNodesY = 0
 Number of nodes in Y-dimension (Theta in spherical coordinates)
 
Int_t fNodesZ = 0
 Number of nodes in Z-dimension (Phi in spherical coordinates)
 
std::vector< Int_t > fNodeX
 A std::vector storing the X-dimension cell id.
 
std::vector< Int_t > fNodeY
 A std::vector storing the Y-dimension cell id.
 
std::vector< Int_t > fNodeZ
 A std::vector storing the Z-dimension cell id.
 
Int_t fNumberOfGroups = 0
 Total number of groups found.
 
Int_t fNumberOfNodes = 0
 Total number of nodes filled.
 

Member Function Documentation

◆ GetNodeX() [1/2]

Int_t TRestMesh::GetNodeX ( Double_t  x,
Bool_t  relative = false 
)

Gets the node index corresponding to the x-coordinate.

If relative it is true it means the x-coordinate is already relative to the origin of the mesh. By default the x-coordinate is given in absolute coordinates, i.e. relative=false.

Definition at line 160 of file TRestMesh.cxx.

◆ GetNodeX() [2/2]

Int_t TRestMesh::GetNodeX ( TVector3  v,
Bool_t  relative = false 
)

Gets the node index corresponding to the x-coordinate or r-coordinate in spherical coordinates.

If relative it is true it means the x-coordinate is already relative to the origin of the mesh. By default the x-coordinate is given in absolute coordinates, i.e. relative=false.

Definition at line 187 of file TRestMesh.cxx.

◆ GetNodeY() [1/2]

Int_t TRestMesh::GetNodeY ( Double_t  y,
Bool_t  relative = false 
)

Gets the node index corresponding to the y-coordinate.

If relative it is true it means the y-coordinate is already relative to the origin of the mesh. By default the y-coordinate is given in absolute coordinates, i.e. relative=false.

Definition at line 214 of file TRestMesh.cxx.

◆ GetNodeY() [2/2]

Int_t TRestMesh::GetNodeY ( TVector3  v,
Bool_t  relative = false 
)

Gets the node index corresponding to the x-coordinate or theta-coordinate in spherical coordinates.

If relative it is true it means the x-coordinate is already relative to the origin of the mesh. By default the x-coordinate is given in absolute coordinates, i.e. relative=false.

Definition at line 243 of file TRestMesh.cxx.

◆ GetNodeZ() [1/2]

Int_t TRestMesh::GetNodeZ ( Double_t  z,
Bool_t  relative = false 
)

Gets the node index corresponding to the z-coordinate.

If relative it is true it means the z-coordinate is already relative to the origin of the mesh. By default the z-coordinate must be given in absolute coordinates, i.e. relative=false.

Definition at line 268 of file TRestMesh.cxx.

◆ GetNodeZ() [2/2]

Int_t TRestMesh::GetNodeZ ( TVector3  v,
Bool_t  relative = false 
)

Gets the node index corresponding to the x-coordinate or theta-coordinate in spherical coordinates.

If relative it is true it means the x-coordinate is already relative to the origin of the mesh. By default the x-coordinate is given in absolute coordinates, i.e. relative=false.

Definition at line 296 of file TRestMesh.cxx.

◆ GetTrackBoundaries()

std::vector< TVector3 > TRestMesh::GetTrackBoundaries ( TVector3  pos,
TVector3  dir,
Bool_t  particle = true 
)

Finds the intersection of the straight line (track defined by the input arguments given, a position pos and direction dir) with the boundary box defined by the mesh.

It is done by searching for the points where the particle trajectory intersects the boundary planes of that region.

If the optional parameter particle is true (which is the default behaviour) this method will return the found boundaries only if the particle is moving towards the volume. On top of that it will be assured that the first boundary element corresponds with the boundary closer to the position of the particle.

If the particle parameter is false, valid boundaries will be returned as soon as the track crosses the volume without being crosschecked the relative positions of the boundaries respect to the particle position.

Definition at line 710 of file TRestMesh.cxx.


The documentation for this class was generated from the following files: