HerdSoftware  0.4.0
PsdGeoParams.h
Go to the documentation of this file.
1 /*
2  * PsdGeoParams.h
3  *
4  * Created on: 7 Dec 2018
5  * Author: Nicola Mori
6  */
7 
10 #ifndef HERD_PSDGEOPARAMS_H_
11 #define HERD_PSDGEOPARAMS_H_
12 
19 
20 #ifdef HS_USE_ROOT
21 #include "Rtypes.h"
22 #endif
23 
24 #include <vector>
25 
26 namespace Herd {
27 
31 struct PsdGeoParams {
32 
37 
39  PsdGeoParams(unsigned int nTotElements)
41  DEFAULT_INIT(_secSegmDir), _psdElements{nTotElements} {}
42 
44  virtual ~PsdGeoParams() = default;
45 
51  const Parallelepiped &BoundingBox() const;
52 
62  [[nodiscard]] const AxesArray<unsigned int> &NElements() const { return _nElements; };
63 
68  [[nodiscard]] unsigned int NTotElements() const { return _psdElements.size(); };
69 
74  [[nodiscard]] RefFrame::Direction NormalDirection() const { return _normal; };
75 
81  [[nodiscard]] const AxesArray<float> &Sizes() const { return _sizes; };
82 
88  [[nodiscard]] const Point &Position(unsigned int volID) const { return _psdElements[volID]._position; };
89 
95  [[nodiscard]] const CooArray<unsigned char> &CooIndexes(unsigned int volID) const {
96  return _psdElements[volID]._indexes;
97  };
98 
105  [[nodiscard]] TrapezoidalPrism ElementShape(unsigned int volID) const;
106 
111  [[nodiscard]] float BaseAngle() const { return _baseAngle; };
112 
117  bool IsSmallerFaceOutward(unsigned int volID) { return (bool)(volID % 2); };
118 
129  [[nodiscard]] std::pair<RefFrame::Direction, RefFrame::Direction> SegmentationDirections() const {
130  return std::make_pair(_mainSegmDir, _secSegmDir);
131  };
132 
139  void SetNElements(AxesArray<unsigned int> nElements);
140 
145  void SetNormal(RefFrame::Direction normal) { _normal = normal; };
146 
152  void SetSizes(AxesArray<float> sizes) { _sizes = sizes; };
153 
159  void SetPosition(unsigned int volID, Point position) { _psdElements[volID]._position = position; };
160 
165  void SetBaseAngle(float baseAngle) { _baseAngle = baseAngle; };
166 
173  _mainSegmDir = mainSegmDir;
174  _secSegmDir = secSegmDir;
175  };
176 
178  struct PsdElement {
181 
183  _indexes[RefFrame::Coo::X] = std::numeric_limits<unsigned char>::max();
184  _indexes[RefFrame::Coo::Y] = std::numeric_limits<unsigned char>::max();
185  _indexes[RefFrame::Coo::Z] = std::numeric_limits<unsigned char>::max();
186  };
187  };
188 
189 private:
195  float _baseAngle;
196  std::vector<PsdElement> _psdElements;
197  bool mutable _bbIsValid{false};
199 
200  void ComputeBoundingBox() const;
201 
202  void SetDefaultSegmDirections(); // backward-compatibility fallback setting of default directions
203 
204 #ifdef HS_USE_ROOT
205  ClassDef(PsdGeoParams, 3)
206 #endif
207 };
208 
209 } // namespace Herd
210 
211 #endif /* HERD_PSDGEOPARAMS_H_ */
Herd::RefFrame::Coo::Y
@ Y
Herd::PsdGeoParams::BaseAngle
float BaseAngle() const
Return the base angle of the PSD elements.
Definition: PsdGeoParams.h:111
Herd::PsdGeoParams::ElementShape
TrapezoidalPrism ElementShape(unsigned int volID) const
Utility function to get the shape in space of a particular tile/bar.
Definition: PsdGeoParams.cpp:112
Herd::PsdGeoParams::NElements
const AxesArray< unsigned int > & NElements() const
Return the number of PSD elements along each segmentation axis.
Definition: PsdGeoParams.h:62
Point.h
Herd::PsdGeoParams::SegmentationDirections
std::pair< RefFrame::Direction, RefFrame::Direction > SegmentationDirections() const
Return the segmentation directions of the PSD tiles.
Definition: PsdGeoParams.h:129
Herd::Vec3D
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Herd::RefFrame::Coo::X
@ X
Herd::CooArray< unsigned char >
Herd::PsdGeoParams::_nElements
AxesArray< unsigned int > _nElements
Number of PSD elements along each segmentation axis.
Definition: PsdGeoParams.h:190
Herd::PsdGeoParams::PsdElement::PsdElement
PsdElement()
Definition: PsdGeoParams.h:182
Herd::PsdGeoParams::NormalDirection
RefFrame::Direction NormalDirection() const
Return the normal to the PSD surface, which points outside the full detector.
Definition: PsdGeoParams.h:74
DEFAULT_INIT
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
Herd::PsdGeoParams::Sizes
const AxesArray< float > & Sizes() const
Return the size of a PSD element, one value for each direction. Size in trapezoidal shapes refers to ...
Definition: PsdGeoParams.h:81
Herd::PsdGeoParams::SetSegmentationDirections
void SetSegmentationDirections(RefFrame::Direction mainSegmDir, RefFrame::Direction secSegmDir)
Set the base segmentation directions of the PSD elements.
Definition: PsdGeoParams.h:172
Herd::PsdGeoParams::_baseAngle
float _baseAngle
Secondary segmentation direction for elements.
Definition: PsdGeoParams.h:195
Herd::PsdGeoParams::SetPosition
void SetPosition(unsigned int volID, Point position)
Set the position of a PSD element.
Definition: PsdGeoParams.h:159
Herd::AxesArray< unsigned int >
AxesArray.h
Herd::PsdGeoParams::PsdElement::_position
Point _position
Position of the center of the PSD element.
Definition: PsdGeoParams.h:179
Herd::PsdGeoParams::~PsdGeoParams
virtual ~PsdGeoParams()=default
Virtual destructor
Herd::RefFrame::Direction
Direction
Aliases for the six axis directions.
Definition: RefFrame.h:55
Herd::PsdGeoParams::PsdElement::_indexes
CooArray< unsigned char > _indexes
Indexes of the PSD element for each coordinate.
Definition: PsdGeoParams.h:180
Herd::PsdGeoParams::NTotElements
unsigned int NTotElements() const
Return the total number of PSD elements.
Definition: PsdGeoParams.h:68
Herd::PsdGeoParams::BoundingBox
const Parallelepiped & BoundingBox() const
Get the layer bounding box for quick geometric checks (intersections and such).
Definition: PsdGeoParams.cpp:57
Herd::PsdGeoParams::SetSizes
void SetSizes(AxesArray< float > sizes)
Set the size of a PSD element, one value for each direction. Size in trapezoidal shapes refers to the...
Definition: PsdGeoParams.h:152
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::PsdGeoParams::PsdElement
This struct is used only inside the object, it is public since Root can not save the object otherwise...
Definition: PsdGeoParams.h:178
Herd::PsdGeoParams::ComputeBoundingBox
void ComputeBoundingBox() const
Bounding box for this layer, to use for quick intersection checks.
Definition: PsdGeoParams.cpp:64
CooArray.h
Herd::PsdGeoParams::PsdGeoParams
PsdGeoParams(unsigned int nTotElements)
Constructor.
Definition: PsdGeoParams.h:39
Herd::PsdGeoParams::PsdGeoParams
PsdGeoParams()
PsdGeoParams constructor.
Definition: PsdGeoParams.h:34
Herd::PsdGeoParams::CooIndexes
const CooArray< unsigned char > & CooIndexes(unsigned int volID) const
Return the indexes of a PSD element.
Definition: PsdGeoParams.h:95
Herd::PsdGeoParams::_boundingBox
Parallelepiped _boundingBox
Flag to signal Bounding box must be recomputed.
Definition: PsdGeoParams.h:198
Herd::PsdGeoParams::_bbIsValid
bool _bbIsValid
Definition: PsdGeoParams.h:197
Herd::RefFrame::Coo::Z
@ Z
Herd::PsdGeoParams
Data structure for PSD geometry parameters.
Definition: PsdGeoParams.h:31
Herd::PsdGeoParams::_psdElements
std::vector< PsdElement > _psdElements
Vector of PSD elements, which include the position and the indexes.
Definition: PsdGeoParams.h:196
Herd::TrapezoidalPrism
A trapezoidal prism in 3D space.
Definition: TrapezoidalPrism.h:27
Herd::PsdGeoParams::SetNormal
void SetNormal(RefFrame::Direction normal)
Set the normal to the PSD surface, which points outside the full detector.
Definition: PsdGeoParams.h:145
Herd::PsdGeoParams::_mainSegmDir
RefFrame::Direction _mainSegmDir
Definition: PsdGeoParams.h:193
Herd::PsdGeoParams::_normal
RefFrame::Direction _normal
Normal of the PSD which points outside the full detector.
Definition: PsdGeoParams.h:192
DefaultValues.h
Herd::PsdGeoParams::SetDefaultSegmDirections
void SetDefaultSegmDirections()
Definition: PsdGeoParams.cpp:12
Herd::PsdGeoParams::_sizes
AxesArray< float > _sizes
Size of a PSD element, one value for each direction.
Definition: PsdGeoParams.h:191
Herd::PsdGeoParams::SetBaseAngle
void SetBaseAngle(float baseAngle)
Set the base angle of the PSD elements.
Definition: PsdGeoParams.h:165
Herd::PsdGeoParams::_secSegmDir
RefFrame::Direction _secSegmDir
Main segmentation direction for elements.
Definition: PsdGeoParams.h:194
Herd::PsdGeoParams::SetNElements
void SetNElements(AxesArray< unsigned int > nElements)
Set the number of PSD elements along each segmentation axis and compute the indexes.
Definition: PsdGeoParams.cpp:38
Herd::Parallelepiped
A parallelepiped in 3D space.
Definition: Parallelepiped.h:25
Herd::PsdGeoParams::Position
const Point & Position(unsigned int volID) const
Return the position of a PSD element.
Definition: PsdGeoParams.h:88
Parallelepiped.h
TrapezoidalPrism.h
Herd::PsdGeoParams::IsSmallerFaceOutward
bool IsSmallerFaceOutward(unsigned int volID)
Specifies if the PSD element has the smaller basis of the trapezoidal pointing outward.
Definition: PsdGeoParams.h:117