HerdSoftware  0.3.2
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 // HerdSoftware headers
14 #include "common/AxesArray.h"
15 #include "common/DefaultValues.h"
16 #include "common/DirectionsArray.h"
17 #include "dataobjects/Line.h"
18 #include "dataobjects/Point.h"
19 #include "dataobjects/Rectangle.h"
20 
21 #ifdef HS_USE_ROOT
22 // Root headers
23 #include "Rtypes.h"
24 #endif
25 
26 // C/C++ headers
27 #include <vector>
28 
29 namespace Herd {
30 
35 public:
37  CaloGeoParams();
38 
40  virtual ~CaloGeoParams() = default;
41 
47  const Point &Position(unsigned int volID) const { return _positions[volID]; };
48 
50 
56  const Indexes &CooIndexes(unsigned int volID) const { return _indexes[volID]; };
57 
60  struct CooIndexRange {
61  unsigned char begin = defaultValue<unsigned char>;
62  unsigned char end = defaultValue<unsigned char>;
63 
64  bool operator==(const CooIndexRange &other) const { return begin == other.begin && end == other.end; }
65  unsigned char Size() const { return end - begin + 1; }
66  };
67 
84  CooIndexRange CooIndexesRange(RefFrame::Axis axis, unsigned char index1, unsigned char index2);
85 
93  bool IsEmpty(unsigned int volID) const { return (_mask.size() == 0 ? false : _mask[volID]); };
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 _positions.size(); };
138 
153  unsigned int VolumeID(const Indexes &cooIndex) const;
154 
162  unsigned int VolumeID(const Point &point) const;
163 
172  std::pair<Point, Point> CubeIntersections(const Line &track, const unsigned int volID,
173  const Herd::RefFrame::Coo sort_by_coo = Herd::RefFrame::Coo::NONE) const;
174 
179  float SphericalRadius() const { return _sphericalRadius; }
180 
197  bool operator==(const EllipsoidalEnvelope &rhs);
198  float Volume() const;
199  };
200 
210 
217  public:
220 
237  PrismaticEnvelope(Point center, AxesArray<float> sizes, float xFaceYSize, float yFaceXSize);
238 
243  const Point &Center() const { return m_center; }
244 
252  const DirectionsArray<Rectangle> &LateralFaces() const;
253 
261  const std::array<Herd::Plane, 2> &ZPlanes() const;
262 
263  bool operator==(const PrismaticEnvelope &rhs);
264 
269  float Volume() const;
270 
271  private:
274  float m_xFaceYSize;
275  float m_yFaceXSize;
277  mutable std::array<Herd::Plane, 2> m_zPlanes;
278  };
279 
288 
296  const AxesArray<float> &Gaps() const { return _gaps; };
297 
305  const AxesArray<float> &Wells() const { return _wells; };
306 
335  void SetCubes(std::vector<Point> positions, std::vector<Indexes> indexes, float cubeSize,
336  float cubeSlotSize = defaultValue<float>, std::vector<bool> mask = {});
337 
342  void SetLYSODensity(float density) { _lysoDensity = density; };
343 
350  void SetSphericalRadius(float radius);
351 
352 private:
357  void FillCooId2VolIDMatrix();
358  std::vector<Point> _positions;
359  std::vector<Indexes> _indexes;
360  std::vector<bool> _mask;
361  float _cubeSize;
363  float _lysoDensity;
367  mutable EllipsoidalEnvelope
370 
371  std::vector<std::vector<std::vector<unsigned short>>>
373  unsigned int _nMaxCubesPerSide;
374 
375 #ifdef HS_USE_ROOT
376  ClassDef(CaloGeoParams, 5)
377 #endif
378 };
379 
380 } // namespace Herd
381 
382 #endif /* HERD_PSDGEOPARAMS_H_ */
unsigned char end
Definition: CaloGeoParams.h:62
AxesArray< float > _gaps
The gaps between the cubes (cm).
Definition: CaloGeoParams.h:364
const Point & Center() const
Gets the center of the envelope.
Definition: CaloGeoParams.h:243
Coo
Aliases for the three space coordinates. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:26
const AxesArray< float > & Gaps() const
Gets the gaps sizes.
Definition: CaloGeoParams.h:296
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
float m_yFaceXSize
The size along X of the prism faces on Y sides (cm).
Definition: CaloGeoParams.h:275
void SetSphericalRadius(float radius)
Sets the radius of the spherical CALO.
Definition: CaloGeoParams.cpp:343
float LYSODensity() const
Return the LYSO density (g/cm3).
Definition: CaloGeoParams.h:105
AxesArray< float > halfSizes
The half axes of the full ellipsoid along each axis (cm).
Definition: CaloGeoParams.h:195
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:60
EllipsoidalEnvelope _ellipsoidalEnvelopeParams
Parameters of the ellipsoidal envelope of the spherical CALO.
Definition: CaloGeoParams.h:368
float _sphericalRadius
The radius of the spherical CALO expressed in cube ID units.
Definition: CaloGeoParams.h:366
void FillCooId2VolIDMatrix()
Fill the private lookup table which converts indexes into volume ID.
Definition: CaloGeoParams.cpp:22
std::vector< std::vector< std::vector< unsigned short > > > _cooId2VolIDMatrix
Definition: CaloGeoParams.h:372
CooIndexRange CooIndexesRange(RefFrame::Axis axis, unsigned char index1, unsigned char index2)
Return the CooIndex range for a given row of crystals.
Definition: CaloGeoParams.cpp:224
const PrismaticEnvelope & PrismaticCaloEnvelope() const
Returns the parameters of the prismatic envelope of the standard CALO.
Definition: CaloGeoParams.cpp:525
const EllipsoidalEnvelope & SphericalCaloEnvelope() const
Returns the parameters of the ellipsoidal envelope of the spherical CALO.
Definition: CaloGeoParams.cpp:373
AxesArray< float > _wells
The sizes of the wells (cm).
Definition: CaloGeoParams.h:365
CaloGeoParams()
Default constructor.
Definition: CaloGeoParams.cpp:18
AxesArray< float > halfAxes
The center of the ellipsoid (cm).
Definition: CaloGeoParams.h:194
virtual ~CaloGeoParams()=default
Virtual destructor.
Axis
Aliases for the axes. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:36
unsigned int _nMaxCubesPerSide
Matrix which contains the cooIndexes -> volumeID conversion.
Definition: CaloGeoParams.h:373
AxesArray< float > m_sizes
The size of the prism along each axis (cm).
Definition: CaloGeoParams.h:273
std::vector< Indexes > _indexes
The indexes of each cube.
Definition: CaloGeoParams.h:359
Point center
Definition: CaloGeoParams.h:193
Point m_center
The center of the prism (cm).
Definition: CaloGeoParams.h:272
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Data structure for the Calo geometry parameters.
Definition: CaloGeoParams.h:34
bool operator==(const CooIndexRange &other) const
Definition: CaloGeoParams.h:64
Parameters of the ellipsoidal CALO envelope.
Definition: CaloGeoParams.h:192
std::array< Herd::Plane, 2 > m_zPlanes
Top (first) and bottom (second) envelope planes.
Definition: CaloGeoParams.h:277
const Point & Position(unsigned int volID) const
Return the position of the center of the cube.
Definition: CaloGeoParams.h:47
unsigned char begin
Definition: CaloGeoParams.h:61
Class describing a line in the 3D space.
Definition: Line.h:34
float _cubeSize
The size of the cube, i.e. the side length (cm).
Definition: CaloGeoParams.h:361
void SetCubes(std::vector< Point > positions, std::vector< Indexes > indexes, float cubeSize, float cubeSlotSize=defaultValue< float >, std::vector< bool > mask={})
Set the cubes.
Definition: CaloGeoParams.cpp:267
std::vector< Point > _positions
The positions of each cube.
Definition: CaloGeoParams.h:358
unsigned char Size() const
Definition: CaloGeoParams.h:65
const float & CubeSize() const
Return the cube size, i.e the side length [cm].
Definition: CaloGeoParams.h:99
DirectionsArray< Rectangle > m_lateralFaces
Lateral faces of the envelope.
Definition: CaloGeoParams.h:276
An array that accepts directions as subscripts.
Definition: DirectionsArray.h:71
float m_xFaceYSize
The size along Y of the prism faces on X sides (cm).
Definition: CaloGeoParams.h:274
float LYSORadiationLength() const
Return the radiation length of the LYSO material constituting the cube (cm).
Definition: CaloGeoParams.h:115
std::vector< bool > _mask
The mask flag of each cube.
Definition: CaloGeoParams.h:360
std::pair< Point, Point > CubeIntersections(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:82
void SetLYSODensity(float density)
Set the LYSO density.
Definition: CaloGeoParams.h:342
float _cubeSlotSize
The size of the cube slot (cm).
Definition: CaloGeoParams.h:362
float _lysoDensity
The density the cube (g/cm3).
Definition: CaloGeoParams.h:363
const AxesArray< float > & Wells() const
Gets the wells sizes.
Definition: CaloGeoParams.h:305
float SphericalRadius() const
Gets the radius of the spherical CALO.
Definition: CaloGeoParams.h:179
bool IsEmpty(unsigned int volID) const
Return true if the cube is masked.
Definition: CaloGeoParams.h:93
const float & CubeSlotSize() const
Return the size of the tray slot accommodating a single LYSO cube [cm].
Definition: CaloGeoParams.h:131
unsigned int VolumeID(const Indexes &cooIndex) const
Return the volume ID starting from the indexes.
Definition: CaloGeoParams.cpp:45
Parameters of the prismatic CALO envelope.
Definition: CaloGeoParams.h:216
unsigned int NCubes() const
Return the total number of cubes.
Definition: CaloGeoParams.h:137
PrismaticEnvelope _prismaticEnvelopeParams
Parameters of the prismatic envelope of the standard CALO.
Definition: CaloGeoParams.h:369
const Indexes & CooIndexes(unsigned int volID) const
Return the cube indexes.
Definition: CaloGeoParams.h:56