HerdSoftware  0.2.3
CaloGeoParams.h
Go to the documentation of this file.
1 /*
2  * CaloGeoParams.h
3  *
4  * Created on: 19 Set 2019
5  * Author: Lorenzo Pacini
6  */
7 
10 #ifndef HERD_CALOGEOPARAMS_H_
11 #define HERD_CALOGEOPARAMS_H_
12 
13 #include "common/AxesArray.h"
14 #include "common/DefaultValues.h"
15 #include "dataobjects/Line.h"
16 #include "dataobjects/Point.h"
17 
18 #ifdef HS_USE_ROOT
19 #include "Rtypes.h"
20 #endif
21 
22 #include <vector>
23 
24 namespace Herd {
25 
30 public:
35  CaloGeoParams(unsigned int nCubes)
37  _caloCubes.resize(nCubes);
38  }
39 
42 
44  virtual ~CaloGeoParams() = default;
45 
51  const Point &Position(unsigned int volID) const { return _caloCubes[volID]._position; };
52 
58  const CooArray<unsigned char> &CooIndexes(unsigned int volID) const { return _caloCubes[volID]._indexes; };
59 
62  struct CooIndexRange {
63  unsigned char begin = defaultValue<unsigned char>;
64  unsigned char end = defaultValue<unsigned char>;
65 
66  bool operator==(const CooIndexRange &other) const { return begin == other.begin && end == other.end; }
67  unsigned char Size() const { return end - begin + 1; }
68  };
69 
86  CooIndexRange CooIndexesRange(RefFrame::Axis axis, unsigned char index1, unsigned char index2);
87 
93  bool IsEmpty(unsigned int volID) const { return _caloCubes[volID]._isEmpty; };
94 
99  const float &CubeSize() const { return _cubeSize; };
100 
105  float LYSODensity() const { return _lysoDensity; };
106 
115  float LYSORadiationLength() const { return 8.6728 / _lysoDensity; }; // 8.6728 = 1.172 * 7.4
116 
125  float LYSONuclearInteractionLength() const { return 152.3586 / _lysoDensity; }; // 152.3586 = 20.589 * 7.4
126 
131  const float &CubeSlotSize() const { return _cubeSlotSize; };
132 
137  unsigned int NCubes() const { return _caloCubes.size(); };
138 
152  unsigned int VolumeID(const CooArray<unsigned char> &cooIndex);
153 
163  unsigned int VolumeID(const Point &position);
164 
173  std::pair<Point, Point> GetCubeIntersections(const Line &track, const unsigned int volID,
174  const Herd::RefFrame::Coo sort_by_coo = Herd::RefFrame::Coo::NONE) const;
175 
180  void SetNCubes(unsigned int nCubes) { _caloCubes.resize(nCubes); };
181 
187  void SetPosition(unsigned int volID, Point position) { _caloCubes[volID]._position = position; };
188 
194  void SetCooIndexes(unsigned int volID, CooArray<unsigned char> indexes) { _caloCubes[volID]._indexes = indexes; };
195 
203  void SetIsEmpty(unsigned int volID, bool isEmpty) { _caloCubes[volID]._isEmpty = isEmpty; };
204 
209  void SetCubeSize(float cubeSize) { _cubeSize = cubeSize; };
210 
215  void SetCubeSlotSize(float cubeSlotSize) { _cubeSlotSize = cubeSlotSize; };
216 
221  void SetLYSODensity(float density) { _lysoDensity = density; };
222 
224  struct CaloCube {
225 
228  bool _isEmpty;
229 
230  CaloCube() : DEFAULT_INIT(_position), DEFAULT_INIT(_indexes), _isEmpty(false) {}
231  };
232 
233 private:
238  void FillCooId2VolIDMatrix();
239 
240  std::vector<CaloCube> _caloCubes;
241  float _cubeSize;
243  float _lysoDensity;
244  std::vector<std::vector<std::vector<unsigned short>>>
246 
247 #ifdef HS_USE_ROOT
248  ClassDef(CaloGeoParams, 4)
249 #endif
250 };
251 
252 } // namespace Herd
253 
254 #endif /* HERD_PSDGEOPARAMS_H_ */
unsigned char end
Definition: CaloGeoParams.h:64
Coo
Aliases for the three space coordinates. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:26
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
float LYSODensity() const
Return the LYSO density (g/cm3).
Definition: CaloGeoParams.h:105
CaloCube()
Definition: CaloGeoParams.h:230
float LYSONuclearInteractionLength() const
Return the nuclear interaction length of the LYSO material constituting the cube (cm).
Definition: CaloGeoParams.h:125
Helper struct to hold a CooIndex range.
Definition: CaloGeoParams.h:62
void FillCooId2VolIDMatrix()
Fill the private lookup table which converts indexes into volume ID.
Definition: CaloGeoParams.cpp:18
const CooArray< unsigned char > & CooIndexes(unsigned int volID) const
Return the cube indexes.
Definition: CaloGeoParams.h:58
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
std::vector< std::vector< std::vector< unsigned short > > > _cooId2VolIDMatrix
Definition: CaloGeoParams.h:245
CooIndexRange CooIndexesRange(RefFrame::Axis axis, unsigned char index1, unsigned char index2)
Return the CooIndex range for a given row of crystals.
Definition: CaloGeoParams.cpp:208
void SetPosition(unsigned int volID, Point position)
Set the position of the center of the cube.
Definition: CaloGeoParams.h:187
unsigned int VolumeID(const CooArray< unsigned char > &cooIndex)
Return the volume ID starting from the indexes.
Definition: CaloGeoParams.cpp:32
CaloGeoParams()
Default constructor.
Definition: CaloGeoParams.h:41
virtual ~CaloGeoParams()=default
Virtual destructor.
Axis
Aliases for the axes. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:33
CooArray< unsigned char > _indexes
Indexes of the cube for each coordinate.
Definition: CaloGeoParams.h:227
std::vector< CaloCube > _caloCubes
Vector of CaloCube, which contains the cube position and indexes.
Definition: CaloGeoParams.h:240
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Point _position
Position of the center of the cube.
Definition: CaloGeoParams.h:226
Data structure for the Calo geometry parameters.
Definition: CaloGeoParams.h:29
bool operator==(const CooIndexRange &other) const
Definition: CaloGeoParams.h:66
void SetNCubes(unsigned int nCubes)
Set the number of cubes.
Definition: CaloGeoParams.h:180
const Point & Position(unsigned int volID) const
Return the position of the center of the cube.
Definition: CaloGeoParams.h:51
unsigned char begin
Definition: CaloGeoParams.h:63
Class describing a line in the 3D space.
Definition: Line.h:32
float _cubeSize
The size of the cube, i.e. the side length (cm).
Definition: CaloGeoParams.h:241
CaloGeoParams(unsigned int nCubes)
Constructor.
Definition: CaloGeoParams.h:35
unsigned char Size() const
Definition: CaloGeoParams.h:67
const float & CubeSize() const
Return the cube size, i.e the side length [cm].
Definition: CaloGeoParams.h:99
void SetIsEmpty(unsigned int volID, bool isEmpty)
Set the flag which indicates if the cube is empty.
Definition: CaloGeoParams.h:203
void SetCooIndexes(unsigned int volID, CooArray< unsigned char > indexes)
Set the cube indexes.
Definition: CaloGeoParams.h:194
float LYSORadiationLength() const
Return the radiation length of the LYSO material constituting the cube (cm).
Definition: CaloGeoParams.h:115
void SetCubeSize(float cubeSize)
Set the cube size, i.e the side length [cm].
Definition: CaloGeoParams.h:209
bool _isEmpty
True if the cube is empty, true if it is filled with LYSO.
Definition: CaloGeoParams.h:228
void SetLYSODensity(float density)
Set the LYSO density.
Definition: CaloGeoParams.h:221
float _cubeSlotSize
The size of the cube slot (cm).
Definition: CaloGeoParams.h:242
std::pair< Point, Point > GetCubeIntersections(const Line &track, const unsigned int volID, const Herd::RefFrame::Coo sort_by_coo=Herd::RefFrame::Coo::NONE) const
Return the two intersection points between a line and a given cube.
Definition: CaloGeoParams.cpp:66
float _lysoDensity
The density the cube (g/cm3).
Definition: CaloGeoParams.h:243
This struct is used only inside the object, it is public since Root can not save the object otherwise...
Definition: CaloGeoParams.h:224
bool IsEmpty(unsigned int volID) const
Return true if the cube is empty.
Definition: CaloGeoParams.h:93
void SetCubeSlotSize(float cubeSlotSize)
Set the cube slot size [cm].
Definition: CaloGeoParams.h:215
const float & CubeSlotSize() const
Return the size of the tray slot accommodating a single LYSO cube [cm].
Definition: CaloGeoParams.h:131
unsigned int NCubes() const
Return the total number of cubes.
Definition: CaloGeoParams.h:137