HerdSoftware  0.4.0
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
20 
21 #ifdef HS_USE_ROOT
22 // Root headers
23 #include "Rtypes.h"
24 #endif
25 
26 // C/C++ headers
27 #include <optional>
28 #include <vector>
29 
30 namespace Herd {
31 
36 public:
38  CaloGeoParams();
39 
41  virtual ~CaloGeoParams() = default;
42 
48  const Point &Position(unsigned int volID) const { return _positions[volID]; };
49 
51 
57  const Point LPDPosition(unsigned int volID) const { return _positions[volID] + _lpdOffset; };
58 
64  const Point SPDPosition(unsigned int volID) const { return _positions[volID] + _spdOffset; };
65 
71  const Indexes &CooIndexes(unsigned int volID) const { return _indexes[volID]; };
72 
75  struct CooIndexRange {
76  unsigned char begin = defaultValue<unsigned char>;
77  unsigned char end = defaultValue<unsigned char>;
78 
79  bool operator==(const CooIndexRange &other) const { return begin == other.begin && end == other.end; }
80  [[nodiscard]] unsigned char Size() const { return end - begin + 1; }
81  };
82 
99  CooIndexRange CooIndexesRange(RefFrame::Axis axis, unsigned char index1, unsigned char index2);
100 
108  bool IsEmpty(unsigned int volID) const { return (_mask.size() == 0 ? false : _mask[volID]); };
109 
114  const float &CubeSize() const { return _cubeSize; };
115 
120  const AxesArray<float> LPDSize() const { return _lpdSize; };
121 
126  const AxesArray<float> SPDSize() const { return _spdSize; };
127 
132  float LYSODensity() const { return _lysoDensity; };
133 
142  float LYSORadiationLength() const { return 8.6728 / _lysoDensity; }; // 8.6728 = 1.172 * 7.4
143 
152  float LYSONuclearInteractionLength() const { return 152.3586 / _lysoDensity; }; // 152.3586 = 20.589 * 7.4
153 
158  const float &CubeSlotSize() const { return _cubeSlotSize; };
159 
164  unsigned int NCubes() const { return _positions.size(); };
165 
179  std::optional<unsigned int> VolumeID(const Indexes &cooIndex) const;
180 
187  std::optional<unsigned int> VolumeID(const Point &point) const;
188 
198  std::optional<std::pair<Point, Point>>
199  CubeIntersections(const Line &track, const unsigned int volID,
200  const Herd::RefFrame::Coo sort_by_coo = Herd::RefFrame::Coo::NONE) const;
201 
206  float SphericalRadius() const { return _sphericalRadius; }
207 
224  bool operator==(const EllipsoidalEnvelope &rhs);
225  [[nodiscard]] float Volume() const;
226  };
227 
237 
242  std::string FillerMaterial() const { return _fillerMaterial; };
243 
250  public:
253 
270  PrismaticEnvelope(Point center, AxesArray<float> sizes, float xFaceYSize, float yFaceXSize);
271 
276  const Point &Center() const { return m_center; }
277 
286 
294  const std::array<Herd::Plane, 2> &ZPlanes() const;
295 
296  bool operator==(const PrismaticEnvelope &rhs);
297 
302  float Volume() const;
303 
304  private:
307  float m_xFaceYSize;
308  float m_yFaceXSize;
310  mutable std::array<Herd::Plane, 2> m_zPlanes;
311  };
312 
321 
329  const AxesArray<float> &Gaps() const { return _gaps; };
330 
338  const AxesArray<float> &Wells() const { return _wells; };
339 
368  void SetCubes(std::vector<Point> positions, std::vector<Indexes> indexes, float cubeSize,
369  float cubeSlotSize = defaultValue<float>, std::vector<bool> mask = {});
370 
384  void SetPDs(Vec3D lpdOffset, Vec3D spdOffset, Herd::AxesArray<float> lpdSize, Herd::AxesArray<float> spdSize);
385 
390  void SetLYSODensity(float density) { _lysoDensity = density; };
391 
398  void SetSphericalRadius(float radius);
399 
404  void SetLPDSize(Herd::AxesArray<float> lpdSize) { _lpdSize = lpdSize; };
405 
410  void SetSPDSize(Herd::AxesArray<float> spdSize) { _spdSize = spdSize; };
411 
413  void SetFillerMaterial(std::string fillerMaterial) { _fillerMaterial = fillerMaterial; };
414 
415 private:
420  void FillCooId2VolIDMatrix();
421  std::vector<Point> _positions;
422  std::vector<Indexes> _indexes;
423  std::vector<bool> _mask;
426  float _cubeSize;
428  float _lysoDensity;
432  mutable EllipsoidalEnvelope
437  std::vector<std::vector<std::vector<unsigned short>>>
439  unsigned int _nMaxCubesPerSide;
440  std::string _fillerMaterial; // name of the filler material: material inside the calo envelope where there's no LYSO
441 
442 #ifdef HS_USE_ROOT
443  ClassDef(CaloGeoParams, 7)
444 #endif
445 };
446 
447 } // namespace Herd
448 
449 #endif /* HERD_PSDGEOPARAMS_H_ */
Herd::CaloGeoParams::_indexes
std::vector< Indexes > _indexes
The indexes of each cube.
Definition: CaloGeoParams.h:422
Herd::CaloGeoParams::Wells
const AxesArray< float > & Wells() const
Gets the wells sizes.
Definition: CaloGeoParams.h:338
Herd::CaloGeoParams::LPDSize
const AxesArray< float > LPDSize() const
Return the LPD size, i.e the side length [cm].
Definition: CaloGeoParams.h:120
Herd::CaloGeoParams::PrismaticEnvelope::m_xFaceYSize
float m_xFaceYSize
The size along Y of the prism faces on X sides (cm).
Definition: CaloGeoParams.h:307
Point.h
Herd::CaloGeoParams::PrismaticEnvelope
Parameters of the prismatic CALO envelope.
Definition: CaloGeoParams.h:249
Herd::CaloGeoParams::EllipsoidalEnvelope::operator==
bool operator==(const EllipsoidalEnvelope &rhs)
Definition: CaloGeoParams.cpp:366
Herd::CaloGeoParams::SetSPDSize
void SetSPDSize(Herd::AxesArray< float > spdSize)
Set the SPD size, i.e the side length [cm].
Definition: CaloGeoParams.h:410
DirectionsArray.h
Herd::CaloGeoParams::LYSODensity
float LYSODensity() const
Return the LYSO density (g/cm3).
Definition: CaloGeoParams.h:132
Herd::CaloGeoParams::SetLYSODensity
void SetLYSODensity(float density)
Set the LYSO density.
Definition: CaloGeoParams.h:390
Herd::Vec3D
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Herd::CaloGeoParams::EllipsoidalEnvelope::EllipsoidalEnvelope
EllipsoidalEnvelope()
The half sizes of the truncated ellipsoid along each axis (cm).
Definition: CaloGeoParams.cpp:363
Herd::CaloGeoParams::_nMaxCubesPerSide
unsigned int _nMaxCubesPerSide
! Maximum number of cubes along each direction.
Definition: CaloGeoParams.h:439
Herd::CooArray< unsigned char >
Herd::CaloGeoParams::~CaloGeoParams
virtual ~CaloGeoParams()=default
Virtual destructor
Herd::CaloGeoParams::Indexes
CooArray< unsigned char > Indexes
Definition: CaloGeoParams.h:50
Herd::CaloGeoParams::SetCubes
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:266
Herd::CaloGeoParams::PrismaticEnvelope::operator==
bool operator==(const PrismaticEnvelope &rhs)
Definition: CaloGeoParams.cpp:492
Herd::CaloGeoParams::CooIndexRange
Helper struct to hold a CooIndex range.
Definition: CaloGeoParams.h:75
Herd::CaloGeoParams::CubeSize
const float & CubeSize() const
Return the cube size, i.e the side length [cm].
Definition: CaloGeoParams.h:114
Herd::RefFrame::Coo::NONE
@ NONE
Herd::CaloGeoParams::LYSONuclearInteractionLength
float LYSONuclearInteractionLength() const
Return the nuclear interaction length of the LYSO material constituting the cube (cm).
Definition: CaloGeoParams.h:152
Herd::Line
Class describing a line in the 3D space.
Definition: Line.h:37
Herd::CaloGeoParams::SphericalRadius
float SphericalRadius() const
Gets the radius of the spherical CALO.
Definition: CaloGeoParams.h:206
Herd::CaloGeoParams::FillerMaterial
std::string FillerMaterial() const
Return the filler material name.
Definition: CaloGeoParams.h:242
Herd::AxesArray< float >
AxesArray.h
Herd::CaloGeoParams::CooIndexRange::end
unsigned char end
Definition: CaloGeoParams.h:77
Herd::CaloGeoParams::CooIndexRange::operator==
bool operator==(const CooIndexRange &other) const
Definition: CaloGeoParams.h:79
Herd::CaloGeoParams::SPDSize
const AxesArray< float > SPDSize() const
Return the SPD size, i.e the side length [cm].
Definition: CaloGeoParams.h:126
Herd::CaloGeoParams::FillCooId2VolIDMatrix
void FillCooId2VolIDMatrix()
Fill the private lookup table which converts indexes into volume ID.
Definition: CaloGeoParams.cpp:23
Herd::CaloGeoParams::SetLPDSize
void SetLPDSize(Herd::AxesArray< float > lpdSize)
Set the SPD size, i.e the side length [cm].
Definition: CaloGeoParams.h:404
Herd::CaloGeoParams::CooIndexesRange
CooIndexRange CooIndexesRange(RefFrame::Axis axis, unsigned char index1, unsigned char index2)
Return the CooIndex range for a given row of crystals.
Definition: CaloGeoParams.cpp:223
Herd::CaloGeoParams::SphericalCaloEnvelope
const EllipsoidalEnvelope & SphericalCaloEnvelope() const
Set the cube indexes.
Definition: CaloGeoParams.cpp:387
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::CaloGeoParams::EllipsoidalEnvelope::halfAxes
AxesArray< float > halfAxes
The center of the ellipsoid (cm).
Definition: CaloGeoParams.h:221
Herd::CaloGeoParams::CubeIntersections
std::optional< 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:79
Herd::CaloGeoParams::IsEmpty
bool IsEmpty(unsigned int volID) const
Return true if the cube is masked.
Definition: CaloGeoParams.h:108
Herd::CaloGeoParams::NCubes
unsigned int NCubes() const
Return the total number of cubes.
Definition: CaloGeoParams.h:164
Herd::CaloGeoParams::_sphericalRadius
float _sphericalRadius
The radius of the spherical CALO expressed in cube ID units.
Definition: CaloGeoParams.h:431
Herd::CaloGeoParams::VolumeID
std::optional< unsigned int > VolumeID(const Indexes &cooIndex) const
Return the volume ID starting from the indexes.
Definition: CaloGeoParams.cpp:46
Line.h
Herd::CaloGeoParams::LYSORadiationLength
float LYSORadiationLength() const
Return the radiation length of the LYSO material constituting the cube (cm).
Definition: CaloGeoParams.h:142
Herd::CaloGeoParams::Gaps
const AxesArray< float > & Gaps() const
Gets the gaps sizes.
Definition: CaloGeoParams.h:329
Herd::CaloGeoParams::_ellipsoidalEnvelopeParams
EllipsoidalEnvelope _ellipsoidalEnvelopeParams
Parameters of the ellipsoidal envelope of the spherical CALO.
Definition: CaloGeoParams.h:433
Herd::CaloGeoParams::CooIndexRange::begin
unsigned char begin
Definition: CaloGeoParams.h:76
Herd::CaloGeoParams::SetFillerMaterial
void SetFillerMaterial(std::string fillerMaterial)
Set the filler material name.
Definition: CaloGeoParams.h:413
Herd::CaloGeoParams::_lpdOffset
Vec3D _lpdOffset
The relative position of the LPD on each cube.
Definition: CaloGeoParams.h:424
Herd::CaloGeoParams::SetPDs
void SetPDs(Vec3D lpdOffset, Vec3D spdOffset, Herd::AxesArray< float > lpdSize, Herd::AxesArray< float > spdSize)
Set the photodiodes.
Definition: CaloGeoParams.cpp:346
Herd::CaloGeoParams::EllipsoidalEnvelope
Parameters of the ellipsoidal CALO envelope.
Definition: CaloGeoParams.h:219
Herd::CaloGeoParams::_prismaticEnvelopeParams
PrismaticEnvelope _prismaticEnvelopeParams
Parameters of the prismatic envelope of the standard CALO.
Definition: CaloGeoParams.h:434
Herd::CaloGeoParams::_lysoDensity
float _lysoDensity
The density the cube (g/cm3).
Definition: CaloGeoParams.h:428
Rectangle.h
Herd::CaloGeoParams::PrismaticEnvelope::LateralFaces
const DirectionsArray< Rectangle > & LateralFaces() const
Gets the lateral faces of the envelope.
Definition: CaloGeoParams.cpp:497
Herd::CaloGeoParams::LPDPosition
const Point LPDPosition(unsigned int volID) const
Return the position of the center of the LPD.
Definition: CaloGeoParams.h:57
Herd::CaloGeoParams
Data structure for the Calo geometry parameters.
Definition: CaloGeoParams.h:35
Herd::CaloGeoParams::PrismaticCaloEnvelope
const PrismaticEnvelope & PrismaticCaloEnvelope() const
Returns the parameters of the prismatic envelope of the standard CALO.
Definition: CaloGeoParams.cpp:539
Herd::CaloGeoParams::_wells
AxesArray< float > _wells
The sizes of the wells (cm).
Definition: CaloGeoParams.h:430
Herd::CaloGeoParams::PrismaticEnvelope::PrismaticEnvelope
PrismaticEnvelope()
Default constructor.
Definition: CaloGeoParams.cpp:457
Herd::CaloGeoParams::PrismaticEnvelope::m_yFaceXSize
float m_yFaceXSize
The size along X of the prism faces on Y sides (cm).
Definition: CaloGeoParams.h:308
Herd::CaloGeoParams::_spdOffset
Vec3D _spdOffset
The relative position of the SPD on each cube.
Definition: CaloGeoParams.h:425
Herd::CaloGeoParams::CooIndexes
const Indexes & CooIndexes(unsigned int volID) const
Return the cube indexes.
Definition: CaloGeoParams.h:71
Herd::CaloGeoParams::Position
const Point & Position(unsigned int volID) const
Return the position of the center of the cube.
Definition: CaloGeoParams.h:48
Herd::CaloGeoParams::EllipsoidalEnvelope::Volume
float Volume() const
Definition: CaloGeoParams.cpp:370
Herd::CaloGeoParams::PrismaticEnvelope::ZPlanes
const std::array< Herd::Plane, 2 > & ZPlanes() const
Gets the top and bottom planes of the envelope.
Definition: CaloGeoParams.cpp:483
Herd::CaloGeoParams::_cubeSize
float _cubeSize
The size of the cube, i.e. the side length (cm).
Definition: CaloGeoParams.h:426
Herd::CaloGeoParams::_lpdSize
AxesArray< float > _lpdSize
The size of the LPD (cm).
Definition: CaloGeoParams.h:435
Herd::DirectionsArray
An array that accepts directions as subscripts.
Definition: DirectionsArray.h:71
Herd::CaloGeoParams::EllipsoidalEnvelope::center
Point center
Definition: CaloGeoParams.h:220
Herd::RefFrame::Axis
Axis
Aliases for the axes.
Definition: RefFrame.h:34
Herd::CaloGeoParams::SPDPosition
const Point SPDPosition(unsigned int volID) const
Return the position of the center of the SPD.
Definition: CaloGeoParams.h:64
Herd::RefFrame::Coo
Coo
Aliases for the three space coordinates.
Definition: RefFrame.h:24
Herd::CaloGeoParams::_cubeSlotSize
float _cubeSlotSize
The size of the cube slot (cm).
Definition: CaloGeoParams.h:427
Herd::CaloGeoParams::PrismaticEnvelope::Volume
float Volume() const
Gets the total volume of the envelope.
Definition: CaloGeoParams.cpp:532
Herd::CaloGeoParams::CubeSlotSize
const float & CubeSlotSize() const
Return the size of the tray slot accommodating a single LYSO cube [cm].
Definition: CaloGeoParams.h:158
Herd::CaloGeoParams::CaloGeoParams
CaloGeoParams()
Default constructor
Definition: CaloGeoParams.cpp:18
Herd::CaloGeoParams::CooIndexRange::Size
unsigned char Size() const
Definition: CaloGeoParams.h:80
Herd::CaloGeoParams::PrismaticEnvelope::m_sizes
AxesArray< float > m_sizes
The size of the prism along each axis (cm).
Definition: CaloGeoParams.h:306
DefaultValues.h
Herd::CaloGeoParams::_cooId2VolIDMatrix
std::vector< std::vector< std::vector< unsigned short > > > _cooId2VolIDMatrix
! Matrix which contains the cooIndexes -> volumeID conversion
Definition: CaloGeoParams.h:438
Herd::CaloGeoParams::_spdSize
AxesArray< float > _spdSize
The size of the SPD (cm).
Definition: CaloGeoParams.h:436
Herd::CaloGeoParams::SetSphericalRadius
void SetSphericalRadius(float radius)
Sets the radius of the spherical CALO.
Definition: CaloGeoParams.cpp:357
Herd::CaloGeoParams::PrismaticEnvelope::m_center
Point m_center
The center of the prism (cm).
Definition: CaloGeoParams.h:305
Herd::CaloGeoParams::PrismaticEnvelope::Center
const Point & Center() const
Gets the center of the envelope.
Definition: CaloGeoParams.h:276
Herd::CaloGeoParams::_gaps
AxesArray< float > _gaps
The gaps between the cubes (cm).
Definition: CaloGeoParams.h:429
Herd::CaloGeoParams::_positions
std::vector< Point > _positions
The positions of each cube.
Definition: CaloGeoParams.h:421
Herd::CaloGeoParams::_mask
std::vector< bool > _mask
The mask flag of each cube.
Definition: CaloGeoParams.h:423
Herd::CaloGeoParams::EllipsoidalEnvelope::halfSizes
AxesArray< float > halfSizes
The half axes of the full ellipsoid along each axis (cm).
Definition: CaloGeoParams.h:222
Herd::CaloGeoParams::PrismaticEnvelope::m_lateralFaces
DirectionsArray< Rectangle > m_lateralFaces
Lateral faces of the envelope.
Definition: CaloGeoParams.h:309
Herd::CaloGeoParams::PrismaticEnvelope::m_zPlanes
std::array< Herd::Plane, 2 > m_zPlanes
Top (first) and bottom (second) envelope planes.
Definition: CaloGeoParams.h:310
Herd::CaloGeoParams::_fillerMaterial
std::string _fillerMaterial
Definition: CaloGeoParams.h:440