HerdSoftware  0.4.0
ScdGeoParams.h
Go to the documentation of this file.
1 /*
2  * ScdGeoParams.h
3  *
4  * Created on: 14 Nov 2018
5  * Author: Nicola Mori
6  */
7 
10 #ifndef HERD_SCDGEOPARAMS_H_
11 #define HERD_SCDGEOPARAMS_H_
12 
13 // HERD headers
22 
23 #ifdef HS_USE_ROOT
24 #include "Rtypes.h"
25 #endif
26 
27 // C++ headers
28 #include <vector>
29 
30 namespace Herd {
31 
36 public:
41  ScdGeoParams();
42 
51  ScdGeoParams(RefFrame::Side dside, size_t layerNumber, RefFrame::Direction stripMainSegm);
52 
54  ~ScdGeoParams() override = default;
55 
61  const Parallelepiped &BoundingBox() const;
62 
68  [[nodiscard]] size_t NWafers() const { return _waferPos.size(); }
69 
75  [[nodiscard]] size_t NTotElements() const;
76 
82  float StripPitch() const { return ElementPitch(); }
83 
89  int NStripsPerWafer() const { return _nStripsPerWafer; }
90 
96  int NStripsPerBondedLadder() const {
99  } else {
100  return _nStripsPerWafer;
101  }
102  }
103 
109  int NStripsPerPhysLadder() const {
112  } else {
113  return _nStripsPerWafer;
114  }
115  }
116 
122  float FirstStripPosition() const { return _firstStripPos; }
123 
137 
149  const AxesArray<int> &NBondedLadders() const { return _nBondedLadders; }
150 
161 
172  const AxesArray<int> &NPhysLadders() const { return _nPhysLadders; }
173 
179  const AxesArray<float> &WaferSize() const { return _waferSize; }
180 
187  Point ElementPosition(unsigned int volID) const override;
188 
195  Point StripPosition(unsigned int volID) const { return ElementPosition(volID); };
196 
203  const Point &WaferPosition(unsigned int volID) const { return _waferPos.at(volID); }
204 
211  Point LadderPosition(unsigned int ladderID) const;
212 
223  std::pair<RefFrame::Direction, RefFrame::Direction> StripSegmentationDirections() const {
224  return SegmentationDirections();
225  };
226 
237  std::pair<RefFrame::Direction, RefFrame::Direction> WaferSegmentationDirections() const;
238 
249  std::pair<RefFrame::Direction, RefFrame::Direction> LadderSegmentationDirections() const;
250 
256  unsigned int LadderIDFromStripID(unsigned int stripID) const;
257 
263  unsigned int LadderIDFromWaferID(unsigned int waferID) const;
264 
270  std::pair<unsigned int, unsigned int> WaferIDsFromLadderID(unsigned int ladderID) const;
271 
279  unsigned int WaferIDFromStripID(unsigned int stripID) const;
280 
286  std::pair<unsigned int, unsigned int> StripIDsFromLadderID(unsigned int ladderID) const;
287 
296  unsigned int StripIDOnLadder(unsigned int stripID) const;
297 
305  [[nodiscard]] std::optional<unsigned int> WaferID(const Point &position) const;
306 
314  [[nodiscard]] std::optional<unsigned int> ElementID(const Point &position) const override;
315 
325  [[nodiscard]] std::optional<unsigned int> StripID(const Point &position) const { return ElementID(position); };
326 
333  [[nodiscard]] Parallelepiped ElementShape(size_t volID) const;
334 
338  enum class BondingType {
339  NONE,
340  STRAIGHT,
341  ZIGZAG
342  };
343 
344  [[nodiscard]] BondingType LadderBonding() const { return m_ladderBonding; }
345 
354  SetSideAndMainSegmDir(dside, segmDir);
355  };
356 
363  void SetSideAndMainSegmDir(RefFrame::Side dside, RefFrame::Direction segmDir) override;
364 
375  void SetStripPitch(float pitch);
376 
387  void SetNStripsPerWafer(int nStrips);
388 
408  void SetBondedLadders(const AxesArray<int> &nLadders, const AxesArray<int> &nWafersPerLadder, BondingType bType);
409 
425  void SetPhysLadders(const AxesArray<int> &nLadders, const AxesArray<int> &nWafersPerLadder) {
426  SetLaddersHelper(nLadders, nWafersPerLadder, 0);
427  };
428 
436  void SetWaferSize(const AxesArray<float> &sizes) {
437  _waferSize = sizes;
438  m_waferLUT.isValid = false;
439  }
440 
449  void SetWaferPosition(size_t waferID, Point position) {
450  _waferPos.at(waferID) = position;
451  m_waferLUT.isValid = false;
452  }
453 
466  void SetLadderNormalToStrips(bool value = true) { m_ladderNormalToStrips = value; };
467 
468 private:
469  float _firstStripPos;
474  std::vector<Point> _waferPos;
475  bool mutable _bbIsValid{false};
481 
482  void ComputeBoundingBox() const;
483  void SetLaddersHelper(const AxesArray<int> &nLadders, const AxesArray<int> &nWafersPerLadder,
484  int type); // 0->physical, 1->bonded
485 
486 protected:
487  void UpdateLUT() const;
488 
496  bool isValid = false;
497  std::array<size_t, 2>
499  std::array<float, 2> sizes;
500  std::array<float, 2> cellDimension;
501 
504 
505  std::vector<std::vector<unsigned int>> waferIDs;
506 
508 
509  const std::vector<unsigned int> &WaferIDsAtPos(std::array<float, 2> position);
510 
511  size_t PosToCellID(std::array<float, 2> position);
512 
513  void UpdateNCells(std::array<size_t, 2> newNcells);
514  void UpdateSurface(std::array<float, 2> newOrigin, std::array<float, 2> newSizes);
515  void UpdateInternals(std::vector<Point> waferPositions, std::array<float, 2> waferSizes,
516  std::pair<RefFrame::Direction, RefFrame::Direction> segmDirections);
517  } mutable m_waferLUT;
518 
519 #ifdef HS_USE_ROOT
520  ClassDefOverride(ScdGeoParams, 2)
521 #endif
522 };
523 
524 } // namespace Herd
525 
526 #endif /* HERD_SCDGEOPARAMS_H_ */
Herd::ScdGeoParams::NBondedLadders
const AxesArray< int > & NBondedLadders() const
Get the number of ladders that make up a layer.
Definition: ScdGeoParams.h:149
TrackingDetectorGeoParams.h
Herd::ScdGeoParams::WaferLookupTable::surface
Rectangle surface
Definition: ScdGeoParams.h:503
Herd::ScdGeoParams::_bbIsValid
bool _bbIsValid
Position of all the Si wafers.
Definition: ScdGeoParams.h:475
Herd::ScdGeoParams::StripIDsFromLadderID
std::pair< unsigned int, unsigned int > StripIDsFromLadderID(unsigned int ladderID) const
Retrieves the volume ID of the first and last strip contained in the ladder with the given volumeID.
Definition: ScdGeoParams.cpp:235
Herd::TrackingDetectorGeoParams::ElementPitch
virtual float ElementPitch() const
Get element pitch.
Definition: TrackingDetectorGeoParams.h:78
Herd::TrackingDetectorGeoParams
Base data structure for single tracking detector layer geometry parameters.
Definition: TrackingDetectorGeoParams.h:31
Point.h
Herd::ScdGeoParams::BondingType::STRAIGHT
@ STRAIGHT
No bonding has been applied.
Herd::ScdGeoParams::FirstStripPosition
float FirstStripPosition() const
Get distance of first strip from wafer edge.
Definition: ScdGeoParams.h:122
Herd::ScdGeoParams::WaferID
std::optional< unsigned int > WaferID(const Point &position) const
Utility function to get waferID from a set of coordinates.
Definition: ScdGeoParams.cpp:256
Herd::ScdGeoParams::_nWafersPerPhysLadder
AxesArray< int > _nWafersPerPhysLadder
true if the strips are normal to the ladder
Definition: ScdGeoParams.h:479
Herd::Vec3D
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Herd::ScdGeoParams::SetLaddersHelper
void SetLaddersHelper(const AxesArray< int > &nLadders, const AxesArray< int > &nWafersPerLadder, int type)
Definition: ScdGeoParams.cpp:60
Herd::ScdGeoParams::WaferLookupTable::PosToCellID
size_t PosToCellID(std::array< float, 2 > position)
Definition: ScdGeoParams.cpp:516
Herd::ScdGeoParams::_nWafersPerBondedLadder
AxesArray< int > _nWafersPerBondedLadder
Dimensions of a Si wafer along the three axes.
Definition: ScdGeoParams.h:472
Herd::Rectangle
A rectangle in 3D space.
Definition: Rectangle.h:26
Herd::ScdGeoParams::WaferLookupTable::cellDimension
std::array< float, 2 > cellDimension
Total size of the lookup table [primary strip segm dir, secondary strip segm dir].
Definition: ScdGeoParams.h:500
Herd::ScdGeoParams::m_ladderNormalToStrips
bool m_ladderNormalToStrips
Type of bonding applied to wafer strips of a ladder.
Definition: ScdGeoParams.h:478
Herd::ScdGeoParams::WaferLookupTable::UpdateNCells
void UpdateNCells(std::array< size_t, 2 > newNcells)
Definition: ScdGeoParams.cpp:503
DEFAULT_INIT
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
Herd::ScdGeoParams::NPhysLadders
const AxesArray< int > & NPhysLadders() const
Get the number of physical ladders that make up a layer.
Definition: ScdGeoParams.h:172
Herd::ScdGeoParams::StripID
std::optional< unsigned int > StripID(const Point &position) const
Utility function to get stripID from a set of coordinates. Calls ElementID.
Definition: ScdGeoParams.h:325
Herd::ScdGeoParams::m_waferLUT
struct Herd::ScdGeoParams::WaferLookupTable m_waferLUT
! ROOT-transient
Herd::AxesArray< int >
AxesArray.h
Herd::ScdGeoParams::BondingType::ZIGZAG
@ ZIGZAG
Strips are aligned along the ladder and bonded straightly.
Herd::ScdGeoParams::NWafersPerBondedLadder
const AxesArray< int > & NWafersPerBondedLadder() const
Get the number of wafers that make up a ladder.
Definition: ScdGeoParams.h:136
Herd::ScdGeoParams::NWafersPerPhysLadder
const AxesArray< int > & NWafersPerPhysLadder() const
Get the number of wafers that make up a physical ladder.
Definition: ScdGeoParams.h:160
Herd::ScdGeoParams::ComputeBoundingBox
void ComputeBoundingBox() const
Number of physical ladders along the three axes.
Definition: ScdGeoParams.cpp:434
Herd::RefFrame::Direction
Direction
Aliases for the six axis directions.
Definition: RefFrame.h:55
Herd::ScdGeoParams::SetLadderNormalToStrips
void SetLadderNormalToStrips(bool value=true)
Sets a flag for ladders normal to strips.
Definition: ScdGeoParams.h:466
Herd::TrackingDetectorGeoParams::SegmentationDirections
virtual std::pair< RefFrame::Direction, RefFrame::Direction > SegmentationDirections() const
Return the segmentation directions of the tracking elements.
Definition: TrackingDetectorGeoParams.h:114
Herd::ScdGeoParams::WaferLookupTable::sizes
std::array< float, 2 > sizes
Number of cells in the lookup table [primary strip segm dir, secondary strip segm dir].
Definition: ScdGeoParams.h:499
Herd::ScdGeoParams::WaferLookupTable::ncells
std::array< size_t, 2 > ncells
Definition: ScdGeoParams.h:498
Herd::ScdGeoParams::NStripsPerPhysLadder
int NStripsPerPhysLadder() const
Number of strips for each physical ladder.
Definition: ScdGeoParams.h:109
Herd::RefFrame::Side
Side
Aliases for the five sides.
Definition: RefFrame.h:111
Herd::ScdGeoParams::BondingType
BondingType
Enum class for the different bonding types.
Definition: ScdGeoParams.h:338
Herd::ScdGeoParams::SetSideAndStripMainSegmDir
void SetSideAndStripMainSegmDir(RefFrame::Side dside, RefFrame::Direction segmDir)
Set the detector side and the main segmentation direction for strips. Calls SetSideAndMainSegmDir....
Definition: ScdGeoParams.h:353
Herd::ScdGeoParams::_firstStripPos
float _firstStripPos
Definition: ScdGeoParams.h:466
TypeUtils.h
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::ScdGeoParams::m_ladderBonding
BondingType m_ladderBonding
Bounding box for this layer, to use for quick intersection checks.
Definition: ScdGeoParams.h:477
Herd::ScdGeoParams::LadderPosition
Point LadderPosition(unsigned int ladderID) const
Get position of a given ladder.
Definition: ScdGeoParams.cpp:186
Herd::ScdGeoParams::_waferPos
std::vector< Point > _waferPos
Number of bonded ladders along the three axes.
Definition: ScdGeoParams.h:474
Herd::ScdGeoParams::SetStripPitch
void SetStripPitch(float pitch)
Set the strip pitch.
Definition: ScdGeoParams.cpp:28
Herd::ScdGeoParams::WaferIDsFromLadderID
std::pair< unsigned int, unsigned int > WaferIDsFromLadderID(unsigned int ladderID) const
Retrieves the volume ID of the first and last wafers contained in the ladder with the given volumeID.
Definition: ScdGeoParams.cpp:210
Herd::ScdGeoParams::WaferLookupTable::WaferIDsAtPos
const std::vector< unsigned int > & WaferIDsAtPos(std::array< float, 2 > position)
Definition: ScdGeoParams.cpp:569
Herd::ScdGeoParams::ElementID
std::optional< unsigned int > ElementID(const Point &position) const override
Utility function to get volumeID from a set of coordinates. Reimplemented in derived classes.
Definition: ScdGeoParams.cpp:281
Herd::ScdGeoParams::StripPosition
Point StripPosition(unsigned int volID) const
Get position of a given strip.
Definition: ScdGeoParams.h:195
Herd::ScdGeoParams::ElementShape
Parallelepiped ElementShape(size_t volID) const
Utility function to get the shape in space of a particular strip.
Definition: ScdGeoParams.cpp:472
Herd::ScdGeoParams::NStripsPerWafer
int NStripsPerWafer() const
Number of strips for each wafer.
Definition: ScdGeoParams.h:89
Herd::ScdGeoParams::SetWaferPosition
void SetWaferPosition(size_t waferID, Point position)
Set the wafer position for a given wafer.
Definition: ScdGeoParams.h:449
Herd::ScdGeoParams::StripPitch
float StripPitch() const
Get strip pitch.Calls ChannelPitch. Kept for backwards compatibility.
Definition: ScdGeoParams.h:82
Herd::ScdGeoParams::WaferLookupTable::isValid
bool isValid
Definition: ScdGeoParams.h:496
Herd::ScdGeoParams::SetWaferSize
void SetWaferSize(const AxesArray< float > &sizes)
Set the wafer sizes along the three axes.
Definition: ScdGeoParams.h:436
Rectangle.h
Herd::ScdGeoParams::_waferSize
AxesArray< float > _waferSize
Number of strips in each wafer.
Definition: ScdGeoParams.h:471
Herd::ScdGeoParams::WaferPosition
const Point & WaferPosition(unsigned int volID) const
Get position of a given wafer in layer.
Definition: ScdGeoParams.h:203
Herd::ScdGeoParams::StripSegmentationDirections
std::pair< RefFrame::Direction, RefFrame::Direction > StripSegmentationDirections() const
Return the segmentation directions of the silicon strips.
Definition: ScdGeoParams.h:223
Herd::ScdGeoParams::LadderBonding
BondingType LadderBonding() const
Definition: ScdGeoParams.h:344
Herd::ScdGeoParams::LadderIDFromStripID
unsigned int LadderIDFromStripID(unsigned int stripID) const
Retrieves the volume ID of the ladder containing the strip with the given volumeID.
Definition: ScdGeoParams.cpp:191
SidesArray.h
Herd::ScdGeoParams::WaferLookupTable::WaferLookupTable
WaferLookupTable()
map of all the waferIDs covered by each cell.
Definition: ScdGeoParams.h:507
Herd::ScdGeoParams::_nPhysLadders
AxesArray< int > _nPhysLadders
Number of wafers in each physical ladder along the three axes.
Definition: ScdGeoParams.h:480
Herd::ScdGeoParams::SetSideAndMainSegmDir
void SetSideAndMainSegmDir(RefFrame::Side dside, RefFrame::Direction segmDir) override
Set the detector side and the main segmentation direction for channels.
Definition: ScdGeoParams.cpp:314
Herd::ScdGeoParams::WaferLookupTable
Internal lookup table used to speedup WaferID queries as function of position.
Definition: ScdGeoParams.h:495
Herd::ScdGeoParams::SetBondedLadders
void SetBondedLadders(const AxesArray< int > &nLadders, const AxesArray< int > &nWafersPerLadder, BondingType bType)
Set the ladders bonding.
Definition: ScdGeoParams.cpp:105
Herd::ScdGeoParams::NWafers
size_t NWafers() const
Get the total number of wafers in a single la_boundingBoxyer.
Definition: ScdGeoParams.h:68
Herd::RefFrame::ToAxis
constexpr Axis ToAxis(Coo coo)
Associates an axis to a coordinate .
Definition: RefFrame.h:189
Herd::ScdGeoParams::LadderIDFromWaferID
unsigned int LadderIDFromWaferID(unsigned int waferID) const
Retrieves the volume ID of the ladder containing the wafer with the given volumeID.
Definition: ScdGeoParams.cpp:206
Herd::ScdGeoParams::WaferLookupTable::UpdateInternals
void UpdateInternals(std::vector< Point > waferPositions, std::array< float, 2 > waferSizes, std::pair< RefFrame::Direction, RefFrame::Direction > segmDirections)
Definition: ScdGeoParams.cpp:531
Herd::ScdGeoParams::_nBondedLadders
AxesArray< int > _nBondedLadders
Number of wafers in each bonded ladder along the three axes.
Definition: ScdGeoParams.h:473
Herd::ScdGeoParams::ElementPosition
Point ElementPosition(unsigned int volID) const override
Get position of a given strip.
Definition: ScdGeoParams.cpp:152
Herd::ScdGeoParams::WaferIDFromStripID
unsigned int WaferIDFromStripID(unsigned int stripID) const
Retrieves the ID of the wafer containing the given unbonded strip.
Definition: ScdGeoParams.cpp:218
Herd::ScdGeoParams::~ScdGeoParams
~ScdGeoParams() override=default
Virtual destructor
Herd::ScdGeoParams::NStripsPerBondedLadder
int NStripsPerBondedLadder() const
Number of strips for each bonded ladder.
Definition: ScdGeoParams.h:96
Herd::ScdGeoParams::WaferLookupTable::waferIDs
std::vector< std::vector< unsigned int > > waferIDs
Definition: ScdGeoParams.h:505
Herd::ScdGeoParams::_nStripsPerWafer
int _nStripsPerWafer
Position of the first strip w.r.t the left border of the wafer [cm];.
Definition: ScdGeoParams.h:470
DefaultValues.h
Herd::ScdGeoParams::BondingType::NONE
@ NONE
Herd::ScdGeoParams::LadderSegmentationDirections
std::pair< RefFrame::Direction, RefFrame::Direction > LadderSegmentationDirections() const
Return the segmentation directions of the silicon Ladders.
Definition: ScdGeoParams.cpp:144
Herd::ScdGeoParams::SetPhysLadders
void SetPhysLadders(const AxesArray< int > &nLadders, const AxesArray< int > &nWafersPerLadder)
Set the number of physical ladders and of wafers per physical ladder along each axis.
Definition: ScdGeoParams.h:425
Herd::ScdGeoParams::WaferLookupTable::UpdateSurface
void UpdateSurface(std::array< float, 2 > newOrigin, std::array< float, 2 > newSizes)
Definition: ScdGeoParams.cpp:508
Herd::ScdGeoParams::SetNStripsPerWafer
void SetNStripsPerWafer(int nStrips)
Set the number of strips per wafer.
Definition: ScdGeoParams.cpp:44
Herd::ScdGeoParams::WaferSegmentationDirections
std::pair< RefFrame::Direction, RefFrame::Direction > WaferSegmentationDirections() const
Return the segmentation directions of the silicon Wafers.
Definition: ScdGeoParams.cpp:139
Herd::Parallelepiped
A parallelepiped in 3D space.
Definition: Parallelepiped.h:25
Herd::ScdGeoParams
Data structure for single silicon layer geometry parameters.
Definition: ScdGeoParams.h:35
Herd::ScdGeoParams::_boundingBox
Parallelepiped _boundingBox
Flag to signal Bounding box must be recomputed.
Definition: ScdGeoParams.h:476
Parallelepiped.h
Herd::ScdGeoParams::NTotElements
size_t NTotElements() const
Get the total number of strips (sensitive elements) in a single layer.
Definition: ScdGeoParams.cpp:493
Herd::ScdGeoParams::UpdateLUT
void UpdateLUT() const
Definition: ScdGeoParams.cpp:398
Herd::ScdGeoParams::StripIDOnLadder
unsigned int StripIDOnLadder(unsigned int stripID) const
Returns the strip ID on ladder.
Definition: ScdGeoParams.cpp:252
Herd::ScdGeoParams::ScdGeoParams
ScdGeoParams()
Default constructor.
Definition: ScdGeoParams.cpp:12
Herd::ScdGeoParams::BoundingBox
const Parallelepiped & BoundingBox() const
Get the layer bounding box for quick geometric checks (intersections and such).
Definition: ScdGeoParams.cpp:427
Herd::ScdGeoParams::WaferSize
const AxesArray< float > & WaferSize() const
Get the dimensions of the single wafer.
Definition: ScdGeoParams.h:179