HerdSoftware  0.3.2
SiliconDetectorGeoParams.h
Go to the documentation of this file.
1 /*
2  * SiliconDetectorGeoParams.h
3  *
4  * Created on: 14 Nov 2018
5  * Author: Nicola Mori
6  */
7 
10 #ifndef HERD_SILICONDETECTORGEOPARAMS_H_
11 #define HERD_SILICONDETECTORGEOPARAMS_H_
12 
13 // HERD headers
14 #include "common/AxesArray.h"
15 #include "common/DefaultValues.h"
16 #include "common/SidesArray.h"
17 #include "common/TypeUtils.h"
18 #include "dataobjects/Point.h"
19 #include "dataobjects/Rectangle.h"
21 
22 #ifdef HS_USE_ROOT
23 #include "Rtypes.h"
24 #endif
25 
26 // C++ headers
27 #include <vector>
28 
29 namespace Herd {
30 
35 public:
50  SiliconDetectorGeoParams(RefFrame::Side dside, size_t layerNumber, RefFrame::Direction stripMainSegm);
51 
53  ~SiliconDetectorGeoParams() override = default;
54 
60  size_t NWafers() const { return _waferPos.size(); }
61 
67  float StripPitch() const { return ElementPitch(); }
68 
74  int NStripsPerLadder() const { return _nStripsPerLadder; }
75 
81  float FirstStripPosition() const { return _firstStripPos; }
82 
91 
98  const AxesArray<int> &NLadders() const { return _nLadders; }
99 
105  const AxesArray<float> &WaferSize() const { return _waferSize; }
106 
113  Point ElementPosition(unsigned int volID) const override;
114 
121  Point StripPosition(unsigned int volID) const { return ElementPosition(volID); };
122 
129  const Point &WaferPosition(unsigned int volID) const { return _waferPos.at(volID); }
130 
137  Point LadderPosition(unsigned int ladderID) const;
138 
149  std::pair<RefFrame::Direction, RefFrame::Direction> StripSegmentationDirections() const {
150  return SegmentationDirections();
151  };
152 
163  std::pair<RefFrame::Direction, RefFrame::Direction> WaferSegmentationDirections() const;
164 
175  std::pair<RefFrame::Direction, RefFrame::Direction> LadderSegmentationDirections() const;
176 
182  unsigned int LadderIDFromStripID(unsigned int stripID) const;
183 
189  unsigned int LadderIDFromWaferID(unsigned int waferID) const;
190 
196  std::pair<unsigned int, unsigned int> WaferIDsFromLadderID(unsigned int ladderID) const;
197 
203  std::pair<unsigned int, unsigned int> StripIDsFromLadderID(unsigned int ladderID) const;
204 
213  unsigned int StripIDOnLadder(unsigned int stripID) const;
214 
222  unsigned int WaferID(const Point &position) const;
223 
231  unsigned int ElementID(const Point &position) const override;
232 
242  unsigned int StripID(const Point &position) const { return ElementID(position); };
243 
252  SetSideAndMainSegmDir(dside, segmDir);
253  };
254 
261  void SetSideAndMainSegmDir(RefFrame::Side dside, RefFrame::Direction segmDir) override;
262 
273  void SetStripPitch(float pitch);
274 
285  void SetNStripsPerLadder(int nStrips);
286 
298  void SetNWafersPerLadder(AxesArray<int> nWafers);
299 
308  void SetNLadders(AxesArray<int> nLadders);
309 
317  void SetWaferSize(const AxesArray<float> &sizes) {
318  _waferSize = sizes;
319  m_waferLUT.isValid = false;
320  }
321 
330  void SetWaferPosition(size_t waferID, Point position) {
331  _waferPos.at(waferID) = position;
332  m_waferLUT.isValid = false;
333  }
334 
335 private:
341  std::vector<Point> _waferPos;
342 
343 protected:
344  void UpdateLUT() const;
345 
353  bool isValid = false;
354  std::array<size_t, 2> ncells;
355  std::array<float, 2> sizes;
356  std::array<float, 2>
358 
360 
361  std::vector<std::vector<unsigned int>> waferIDs;
362 
364 
365  const std::vector<unsigned int> &WaferIDsAtPos(std::array<float, 2> position);
366 
367  size_t PosToCellID(std::array<float, 2> position);
368 
369  void UpdateNCells(std::array<size_t, 2> newNcells);
370  void UpdateSurface(std::array<float, 2> newOrigin, std::array<float, 2> newSizes);
371  void UpdateInternals(std::vector<Point> waferPositions, std::array<float, 2> waferSizes,
372  std::pair<RefFrame::Direction, RefFrame::Direction> segmDirections);
373  } mutable m_waferLUT;
374 
375 #ifdef HS_USE_ROOT
376  ClassDefOverride(SiliconDetectorGeoParams, 1)
377 #endif
378 };
379 
380 } // namespace Herd
381 
382 #endif /* HERD_SILICONDETECTORGEOPARAMS_H_ */
float FirstStripPosition() const
Get distance of first strip from wafer edge.
Definition: SiliconDetectorGeoParams.h:81
virtual std::pair< RefFrame::Direction, RefFrame::Direction > SegmentationDirections() const
Return the segmentation directions of the tracking elements.
Definition: TrackingDetectorGeoParams.h:111
void UpdateNCells(std::array< size_t, 2 > newNcells)
Definition: SiliconDetectorGeoParams.cpp:386
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
A rectangle in 3D space.
Definition: Rectangle.h:26
const std::vector< unsigned int > & WaferIDsAtPos(std::array< float, 2 > position)
Definition: SiliconDetectorGeoParams.cpp:455
struct Herd::SiliconDetectorGeoParams::WaferLookupTable m_waferLUT
Rectangle surface
Physical dimension of the lookup table cell [primary segm dir, secondary segm dir].
Definition: SiliconDetectorGeoParams.h:359
std::pair< RefFrame::Direction, RefFrame::Direction > WaferSegmentationDirections() const
Return the segmentation directions of the silicon Wafers.
Definition: SiliconDetectorGeoParams.cpp:139
AxesArray< int > _nLadders
Number of wafers in each ladder along the three axes.
Definition: SiliconDetectorGeoParams.h:340
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
void SetWaferPosition(size_t waferID, Point position)
Set the wafer position for a given wafer.
Definition: SiliconDetectorGeoParams.h:330
Point StripPosition(unsigned int volID) const
Get position of a given strip.
Definition: SiliconDetectorGeoParams.h:121
void SetNLadders(AxesArray< int > nLadders)
Set the number of ladders along each axis.
Definition: SiliconDetectorGeoParams.cpp:113
void SetWaferSize(const AxesArray< float > &sizes)
Set the wafer sizes along the three axes.
Definition: SiliconDetectorGeoParams.h:317
~SiliconDetectorGeoParams() override=default
Virtual destructor.
Side
Aliases for the five sides. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:113
SiliconDetectorGeoParams()
Default constructor.
Definition: SiliconDetectorGeoParams.h:40
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: SiliconDetectorGeoParams.cpp:205
size_t NWafers() const
Get the total number of wafers in a single layer.
Definition: SiliconDetectorGeoParams.h:60
std::pair< RefFrame::Direction, RefFrame::Direction > LadderSegmentationDirections() const
Return the segmentation directions of the silicon Ladders.
Definition: SiliconDetectorGeoParams.cpp:143
void UpdateLUT() const
Position of all the Si wafers.
Definition: SiliconDetectorGeoParams.cpp:357
A class describing a vector in 3D space.
Definition: Vec3D.h:33
AxesArray< int > _nWafersPerLadder
Dimensions of a Si wafer along the three axes.
Definition: SiliconDetectorGeoParams.h:339
unsigned int ElementID(const Point &position) const override
Utility function to get volumeID from a set of coordinates. Reimplemented in derived classes...
Definition: SiliconDetectorGeoParams.cpp:240
std::vector< std::vector< unsigned int > > waferIDs
Definition: SiliconDetectorGeoParams.h:361
std::array< float, 2 > sizes
Number of cells in the lookup table [primary segm dir, secondary segm dir].
Definition: SiliconDetectorGeoParams.h:355
const Point & WaferPosition(unsigned int volID) const
Get position of a given wafer in layer.
Definition: SiliconDetectorGeoParams.h:129
void SetStripPitch(float pitch)
Set the strip pitch.
Definition: SiliconDetectorGeoParams.cpp:53
bool isValid
Definition: SiliconDetectorGeoParams.h:353
virtual float ElementPitch() const
Get element pitch.
Definition: TrackingDetectorGeoParams.h:75
void UpdateInternals(std::vector< Point > waferPositions, std::array< float, 2 > waferSizes, std::pair< RefFrame::Direction, RefFrame::Direction > segmDirections)
Definition: SiliconDetectorGeoParams.cpp:416
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: SiliconDetectorGeoParams.cpp:197
unsigned int LadderIDFromWaferID(unsigned int waferID) const
Retrieves the volume ID of the ladder containing the wafer with the given volumeID.
Definition: SiliconDetectorGeoParams.cpp:193
size_t PosToCellID(std::array< float, 2 > position)
Definition: SiliconDetectorGeoParams.cpp:400
void SetSideAndMainSegmDir(RefFrame::Side dside, RefFrame::Direction segmDir) override
Set the detector side and the main segmentation direction for channels.
Definition: SiliconDetectorGeoParams.cpp:274
unsigned int WaferID(const Point &position) const
Utility function to get waferID from a set of coordinates.
Definition: SiliconDetectorGeoParams.cpp:216
int NStripsPerLadder() const
Number of strips for each ladder.
Definition: SiliconDetectorGeoParams.h:74
void UpdateSurface(std::array< float, 2 > newOrigin, std::array< float, 2 > newSizes)
Definition: SiliconDetectorGeoParams.cpp:391
void SetNWafersPerLadder(AxesArray< int > nWafers)
Set the number of wafers in each ladder along each axis.
Definition: SiliconDetectorGeoParams.cpp:85
const AxesArray< int > & NLadders() const
Get the number of ladder that make up a layer. This is intended as number of ladders along each direc...
Definition: SiliconDetectorGeoParams.h:98
unsigned int LadderIDFromStripID(unsigned int stripID) const
Retrieves the volume ID of the ladder containing the strip with the given volumeID.
Definition: SiliconDetectorGeoParams.cpp:185
Internal lookup table used to speedup WaferID queries as function of position.
Definition: SiliconDetectorGeoParams.h:352
AxesArray< float > _waferSize
Number of strips in each wafer.
Definition: SiliconDetectorGeoParams.h:338
unsigned int StripIDOnLadder(unsigned int stripID) const
Returns the strip ID on ladder.
Definition: SiliconDetectorGeoParams.cpp:212
std::vector< Point > _waferPos
Number of ladders in each wafer along the three axes.
Definition: SiliconDetectorGeoParams.h:341
Data structure for single silicon layer geometry parameters.
Definition: SiliconDetectorGeoParams.h:34
unsigned int StripID(const Point &position) const
Utility function to get stripID from a set of coordinates. Calls ElementID.
Definition: SiliconDetectorGeoParams.h:242
std::array< size_t, 2 > ncells
Definition: SiliconDetectorGeoParams.h:354
std::array< float, 2 > cellDimension
Total size of the lookup table [primary segm dir, secondary segm dir].
Definition: SiliconDetectorGeoParams.h:357
void SetNStripsPerLadder(int nStrips)
Set the number of strips per ladder.
Definition: SiliconDetectorGeoParams.cpp:69
int _nStripsPerLadder
Position of the first strip w.r.t the left border of the wafer [cm];.
Definition: SiliconDetectorGeoParams.h:337
float StripPitch() const
Get strip pitch.Calls ChannelPitch. Kept for backwards compatibility.
Definition: SiliconDetectorGeoParams.h:67
const AxesArray< float > & WaferSize() const
Get the dimensions of the single wafer.
Definition: SiliconDetectorGeoParams.h:105
const AxesArray< int > & NWafersPerLadder() const
Get the number of wafers that make up a ladder. This is intended as number of wafers along each direc...
Definition: SiliconDetectorGeoParams.h:90
Base data structure for single tracking detector layer geometry parameters.
Definition: TrackingDetectorGeoParams.h:28
float _firstStripPos
Definition: SiliconDetectorGeoParams.h:336
Point ElementPosition(unsigned int volID) const override
Get position of a given strip.
Definition: SiliconDetectorGeoParams.cpp:150
Point LadderPosition(unsigned int ladderID) const
Get position of a given ladder.
Definition: SiliconDetectorGeoParams.cpp:173
std::pair< RefFrame::Direction, RefFrame::Direction > StripSegmentationDirections() const
Return the segmentation directions of the silicon strips.
Definition: SiliconDetectorGeoParams.h:149
void SetSideAndStripMainSegmDir(RefFrame::Side dside, RefFrame::Direction segmDir)
Set the detector side and the main segmentation direction for strips. Calls SetSideAndMainSegmDir. Kept for backwards compatibility.
Definition: SiliconDetectorGeoParams.h:251
Direction
Aliases for the six axis directions. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:57
WaferLookupTable()
map of all the waferIDs covered by each cell.
Definition: SiliconDetectorGeoParams.h:363