REST-for-Physics
v2.3
Rare Event Searches ToolKit for Physics
|
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) and
GetZ( 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.
2021-Abril: Including spherical coordinates capability
Definition at line 38 of file TRestMesh.h.
#include <TRestMesh.h>
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. More... | |
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. More... | |
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. More... | |
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). More... | |
TVector3 | GetBottomVertex () const |
It returns the bottom boundary vertex. More... | |
Double_t | GetEnergyAtNode (Int_t nx, Int_t ny, Int_t nz) |
Returns the energy at a particular node. More... | |
Double_t | GetGroupEnergy (Int_t index) |
It returns the total energy of all nodes corresponding to the group id given by argument. More... | |
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. More... | |
Int_t | GetGroupId (Int_t index) |
Returns the group id using the position inside the nodes vector. More... | |
TVector3 | GetGroupPosition (Int_t index) |
It returns the average position for all nodes weighted with their corresponding energy. More... | |
TVector3 | GetNetCenter () |
It returns the position of the mesh center. More... | |
TVector3 | GetNetSize () const |
Returns a std::vector with the size/dimensions of the bounding box. More... | |
Double_t | GetNetSizeX () const |
Returns the net size on X-dimension. More... | |
Double_t | GetNetSizeY () const |
Returns the net size on Y-dimension. More... | |
Double_t | GetNetSizeZ () const |
Returns the net size on Z-dimension. More... | |
TVector3 | GetNodeByIndex (Int_t index) |
Returns a node by its position in the std::vector. More... | |
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. More... | |
Int_t | GetNodesX () const |
Returns the number of nodes defined in the X-dimension. More... | |
Int_t | GetNodesY () const |
Returns the number of nodes defined in the Y-dimension. More... | |
Int_t | GetNodesZ () const |
Returns the number of nodes defined in the Z-dimension. More... | |
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. More... | |
Int_t | GetNumberOfNodes () const |
Returns the total number of nodes added. More... | |
TVector3 | GetOrigin () const |
Returns the origin of the grid (bottom-left corner) More... | |
TVector3 | GetPosition (Int_t nX, Int_t nY, Int_t nZ) |
Gets the position of the corresponding node. More... | |
TVector3 | GetTopVertex () const |
It returns the top boundary vertex. More... | |
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. More... | |
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. More... | |
Double_t | GetX (Int_t nX) |
Gets the cartesian position of nodeX. More... | |
Double_t | GetY (Int_t nY) |
Gets the cartesian position of nodeY. More... | |
Double_t | GetZ (Int_t nZ) |
Gets the cartesian position of nodeZ. More... | |
Bool_t | IsCylindrical () |
Returns true if the coordinate system is set to cylindrical. More... | |
Bool_t | IsInside (TVector3 pos) |
It returns true if the position is found inside the grid (box,sphere or cylinder). More... | |
Bool_t | IsInsideBoundingBox (TVector3 pos) |
It returns true if the position is found inside the bounding box. More... | |
Bool_t | IsSpherical () |
Returns true if the coordinate system is set to spherical. More... | |
void | Print () |
Prints the nodes information. More... | |
void | Regrouping () |
Needs TO BE documented. More... | |
void | RemoveNodes () |
It initializes all node vectors to zero. More... | |
void | SetCylindrical (Bool_t v) |
Sets the coordinate system to cylindrical. More... | |
void | SetNodes (Int_t nX, Int_t nY, Int_t nZ) |
Sets the number of nodes and initializes the nodes vector to zero. More... | |
void | SetNodesFromHits (TRestHits *hits) |
It initializes the nodes using the hit coordinates found inside a TRestHits structure. More... | |
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). More... | |
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. More... | |
void | SetOrigin (TVector3 pos) |
Sets the origin of the bounding-box and initializes the nodes vector to zero. More... | |
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. More... | |
void | SetSpherical (Bool_t v) |
Sets the coordinate system to spherical. More... | |
TRestMesh () | |
Default constructor. More... | |
TRestMesh (Double_t size, Int_t nodes) | |
Constructor specifying the size (sX=sY=sZ=size) and the number of nodes (nX=nY=nZ=nodes). More... | |
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. More... | |
~TRestMesh () | |
Default destructor. More... | |
Protected Attributes | |
std::vector< Double_t > | fEnergy |
A std::vector storing the total energy inside the cell id. More... | |
Bool_t | fIsCylindrical = false |
A flag to indentify if we use cylindrical coordinates. More... | |
Bool_t | fIsSpherical = false |
A flag to indentify if we use spherical coordinates. More... | |
TVector3 | fNetOrigin = TVector3(0, 0, 0) |
The bottom-left corner of the bounding-box grid. More... | |
Double_t | fNetSizeX = 0 |
The size of the grid in X dimension. More... | |
Double_t | fNetSizeY = 0 |
The size of the grid in Y dimension. More... | |
Double_t | fNetSizeZ = 0 |
The size of the grid in Z dimension. More... | |
std::vector< Int_t > | fNodeGroupID |
A std::vector storing the group ID of the corresponding nodes activated. More... | |
Int_t | fNodesX = 0 |
Number of nodes in X-dimension (R in spherical coordinates) More... | |
Int_t | fNodesY = 0 |
Number of nodes in Y-dimension (Theta in spherical coordinates) More... | |
Int_t | fNodesZ = 0 |
Number of nodes in Z-dimension (Phi in spherical coordinates) More... | |
std::vector< Int_t > | fNodeX |
A std::vector storing the X-dimension cell id. More... | |
std::vector< Int_t > | fNodeY |
A std::vector storing the Y-dimension cell id. More... | |
std::vector< Int_t > | fNodeZ |
A std::vector storing the Z-dimension cell id. More... | |
Int_t | fNumberOfGroups = 0 |
Total number of groups found. More... | |
Int_t | fNumberOfNodes = 0 |
Total number of nodes filled. More... | |
TRestMesh::TRestMesh | ( | ) |
Default constructor.
Definition at line 72 of file TRestMesh.cxx.
TRestMesh::TRestMesh | ( | Double_t | size, |
Int_t | nodes | ||
) |
Constructor specifying the size (sX=sY=sZ=size) and the number of nodes (nX=nY=nZ=nodes).
Definition at line 77 of file TRestMesh.cxx.
TRestMesh::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.
Definition at line 93 of file TRestMesh.cxx.
TRestMesh::~TRestMesh | ( | ) |
Default destructor.
Definition at line 109 of file TRestMesh.cxx.
void TRestMesh::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.
Definition at line 551 of file TRestMesh.cxx.
void TRestMesh::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.
Definition at line 588 of file TRestMesh.cxx.
Int_t TRestMesh::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.
Definition at line 485 of file TRestMesh.cxx.
Int_t TRestMesh::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).
Definition at line 466 of file TRestMesh.cxx.
|
inline |
It returns the bottom boundary vertex.
Definition at line 169 of file TRestMesh.h.
|
inline |
Returns the energy at a particular node.
Definition at line 111 of file TRestMesh.h.
Double_t TRestMesh::GetGroupEnergy | ( | Int_t | index | ) |
It returns the total energy of all nodes corresponding to the group id given by argument.
Definition at line 435 of file TRestMesh.cxx.
Int_t TRestMesh::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.
Definition at line 404 of file TRestMesh.cxx.
Int_t TRestMesh::GetGroupId | ( | Int_t | index | ) |
Returns the group id using the position inside the nodes vector.
Definition at line 426 of file TRestMesh.cxx.
TVector3 TRestMesh::GetGroupPosition | ( | Int_t | index | ) |
It returns the average position for all nodes weighted with their corresponding energy.
Definition at line 448 of file TRestMesh.cxx.
TVector3 TRestMesh::GetNetCenter | ( | ) |
It returns the position of the mesh center.
Definition at line 676 of file TRestMesh.cxx.
|
inline |
Returns a std::vector with the size/dimensions of the bounding box.
Definition at line 164 of file TRestMesh.h.
|
inline |
Returns the net size on X-dimension.
Definition at line 155 of file TRestMesh.h.
|
inline |
Returns the net size on Y-dimension.
Definition at line 157 of file TRestMesh.h.
|
inline |
Returns the net size on Z-dimension.
Definition at line 159 of file TRestMesh.h.
|
inline |
Returns a node by its position in the std::vector.
Definition at line 105 of file TRestMesh.h.
Int_t TRestMesh::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.
Definition at line 393 of file TRestMesh.cxx.
|
inline |
Returns the number of nodes defined in the X-dimension.
Definition at line 148 of file TRestMesh.h.
|
inline |
Returns the number of nodes defined in the Y-dimension.
Definition at line 150 of file TRestMesh.h.
|
inline |
Returns the number of nodes defined in the Z-dimension.
Definition at line 152 of file TRestMesh.h.
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.
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.
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.
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.
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.
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.
|
inline |
Returns the total number of groups identified.
Definition at line 87 of file TRestMesh.h.
|
inline |
Returns the total number of nodes added.
Definition at line 85 of file TRestMesh.h.
|
inline |
Returns the origin of the grid (bottom-left corner)
Definition at line 162 of file TRestMesh.h.
TVector3 TRestMesh::GetPosition | ( | Int_t | nX, |
Int_t | nY, | ||
Int_t | nZ | ||
) |
Gets the position of the corresponding node.
Definition at line 131 of file TRestMesh.cxx.
|
inline |
It returns the top boundary vertex.
Definition at line 171 of file TRestMesh.h.
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.
std::vector< TVector3 > TRestMesh::GetTrackBoundariesCylinder | ( | TVector3 | pos, |
TVector3 | dir, | ||
Bool_t | particle = true |
||
) |
Needs TO BE documented.
Definition at line 794 of file TRestMesh.cxx.
TVector3 TRestMesh::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.
Definition at line 684 of file TRestMesh.cxx.
Double_t TRestMesh::GetX | ( | Int_t | nX | ) |
Gets the cartesian position of nodeX.
Definition at line 116 of file TRestMesh.cxx.
Double_t TRestMesh::GetY | ( | Int_t | nY | ) |
Gets the cartesian position of nodeY.
Definition at line 121 of file TRestMesh.cxx.
Double_t TRestMesh::GetZ | ( | Int_t | nZ | ) |
Gets the cartesian position of nodeZ.
Definition at line 126 of file TRestMesh.cxx.
|
inline |
Returns true if the coordinate system is set to cylindrical.
Definition at line 100 of file TRestMesh.h.
Bool_t TRestMesh::IsInside | ( | TVector3 | pos | ) |
It returns true if the position is found inside the grid (box,sphere or cylinder).
Definition at line 633 of file TRestMesh.cxx.
Bool_t TRestMesh::IsInsideBoundingBox | ( | TVector3 | pos | ) |
It returns true if the position is found inside the bounding box.
Definition at line 665 of file TRestMesh.cxx.
|
inline |
Returns true if the coordinate system is set to spherical.
Definition at line 102 of file TRestMesh.h.
void TRestMesh::Print | ( | ) |
Prints the nodes information.
Definition at line 875 of file TRestMesh.cxx.
void TRestMesh::Regrouping | ( | ) |
Needs TO BE documented.
Definition at line 350 of file TRestMesh.cxx.
void TRestMesh::RemoveNodes | ( | ) |
It initializes all node vectors to zero.
Definition at line 621 of file TRestMesh.cxx.
|
inline |
Sets the coordinate system to cylindrical.
Definition at line 136 of file TRestMesh.h.
void TRestMesh::SetNodes | ( | Int_t | nX, |
Int_t | nY, | ||
Int_t | nZ | ||
) |
Sets the number of nodes and initializes the nodes vector to zero.
Definition at line 539 of file TRestMesh.cxx.
void TRestMesh::SetNodesFromHits | ( | TRestHits * | hits | ) |
It initializes the nodes using the hit coordinates found inside a TRestHits structure.
Definition at line 318 of file TRestMesh.cxx.
void TRestMesh::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).
Definition at line 335 of file TRestMesh.cxx.
void TRestMesh::SetOrigin | ( | Double_t | oX, |
Double_t | oY, | ||
Double_t | oZ | ||
) |
Sets the origin of the bounding-box and initializes the nodes vector to zero.
Definition at line 507 of file TRestMesh.cxx.
void TRestMesh::SetOrigin | ( | TVector3 | pos | ) |
Sets the origin of the bounding-box and initializes the nodes vector to zero.
Definition at line 517 of file TRestMesh.cxx.
void TRestMesh::SetSize | ( | Double_t | sX, |
Double_t | sY, | ||
Double_t | sZ | ||
) |
Sets the origin of the bounding-box and initializes the nodes vector to zero.
Definition at line 527 of file TRestMesh.cxx.
|
inline |
Sets the coordinate system to spherical.
Definition at line 139 of file TRestMesh.h.
|
protected |
A std::vector storing the total energy inside the cell id.
Definition at line 72 of file TRestMesh.h.
|
protected |
A flag to indentify if we use cylindrical coordinates.
Definition at line 75 of file TRestMesh.h.
|
protected |
A flag to indentify if we use spherical coordinates.
Definition at line 77 of file TRestMesh.h.
|
protected |
The bottom-left corner of the bounding-box grid.
Definition at line 41 of file TRestMesh.h.
|
protected |
The size of the grid in X dimension.
Definition at line 44 of file TRestMesh.h.
|
protected |
The size of the grid in Y dimension.
Definition at line 46 of file TRestMesh.h.
|
protected |
The size of the grid in Z dimension.
Definition at line 48 of file TRestMesh.h.
|
protected |
A std::vector storing the group ID of the corresponding nodes activated.
Definition at line 63 of file TRestMesh.h.
|
protected |
Number of nodes in X-dimension (R in spherical coordinates)
Definition at line 51 of file TRestMesh.h.
|
protected |
Number of nodes in Y-dimension (Theta in spherical coordinates)
Definition at line 53 of file TRestMesh.h.
|
protected |
Number of nodes in Z-dimension (Phi in spherical coordinates)
Definition at line 55 of file TRestMesh.h.
|
protected |
A std::vector storing the X-dimension cell id.
Definition at line 65 of file TRestMesh.h.
|
protected |
A std::vector storing the Y-dimension cell id.
Definition at line 67 of file TRestMesh.h.
|
protected |
A std::vector storing the Z-dimension cell id.
Definition at line 69 of file TRestMesh.h.
|
protected |
Total number of groups found.
Definition at line 60 of file TRestMesh.h.
|
protected |
Total number of nodes filled.
Definition at line 58 of file TRestMesh.h.