Belle II Software  release-05-01-25
SVDCalibrationsBase.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Laura Zani, Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  * WARNING EXPLOSIVE: PLEASE, WEAR PROTECTIVE SUIT BEFORE USE *
10  **************************************************************************/
11 
12 #pragma once
13 #include <framework/logging/Logger.h>
14 
15 #include <TObject.h>
16 #include <vector>
17 #include <TString.h>
18 
19 namespace Belle2 {
26  template < class T >
27  class SVDCalibrationsBase: public TObject {
28 
37  typedef std::vector< typename T::payloadContainerType > SVDSensor;
38 
40  typedef std::vector< SVDSensor > SVDLadder;
41 
43  typedef std::vector< SVDLadder > SVDLayer;
44 
46  typedef std::vector< SVDLayer > SVD;
47 
50 
51 
52  public:
53 
56  enum E_side { Vindex = 0 , Uindex = 1 };
57 
60  SVDCalibrationsBase(typename T::calibrationType defaultT =
61  typename T::calibrationType(),
62  const TString& uniqueID = ""): m_uniqueID(uniqueID) // Add a string as unique identifier for a given configuration dataset
63  {
64 
65  calibrations.resize(7); // Layers 0 1 2 3 4 5 6
66  int laddersOnLayer[] = { 0, 0, 0, 8, 11, 13, 17 };
67  for (unsigned int layer = 0 ; layer < calibrations.size() ; layer ++) {
68  calibrations[layer].resize(laddersOnLayer[layer]);
69  int sensorsOnLadder[] = {0, 0, 0, 3, 4, 5, 6};
70  for (unsigned int ladder = 1; ladder < calibrations[layer].size(); ladder ++) {
71  calibrations[layer][ladder].resize(sensorsOnLadder[ layer ]);
72  for (unsigned int sensor = 1; sensor < calibrations[layer][ladder].size() ; sensor ++) {
73  calibrations[layer][ladder][sensor].resize(2);
74  T::init(calibrations[layer][ladder][sensor][ Uindex ], layer, ladder, sensor, Uindex ,
75  defaultT);
76  T::init(calibrations[layer][ladder][sensor][ Vindex ], layer, ladder, sensor, Vindex ,
77  defaultT);
78  }
79  }
80  }
81  }
82 
86 
97  typename T::calibrationType get(unsigned int layer,
98  unsigned int ladder,
99  unsigned int sensor,
100  unsigned int side,
101  unsigned int strip) const
102  {
103  if (calibrations.size() <= layer) {
104  B2FATAL("Layers vector is smaller than " << layer);
105  }
106  const auto& ladders = calibrations[layer];
107  if (ladders.size() <= ladder) {
108  B2FATAL("Ladders vector is smaller than " << ladder);
109  }
110  const auto& sensors = ladders[ladder];
111  if (sensors.size() <= sensor) {
112  B2FATAL("Sensors vector is smaller than " << sensor);
113  }
114  const auto& sides = sensors[sensor];
115  if (sides.size() <= side) {
116  B2FATAL("Sides vector is smaller than " << side);
117  }
118 
119  return T::get(sides[side] , strip);
120  }
121 
132  const typename T::calibrationType& getReference(unsigned int layer,
133  unsigned int ladder,
134  unsigned int sensor,
135  unsigned int side,
136  unsigned int strip) const
137  {
138  if (calibrations.size() <= layer) {
139  B2FATAL("Layers vector is smaller than " << layer);
140  }
141  const auto& ladders = calibrations[layer];
142  if (ladders.size() <= ladder) {
143  B2FATAL("Ladders vector is smaller than " << ladder);
144  }
145  const auto& sensors = ladders[ladder];
146  if (sensors.size() <= sensor) {
147  B2FATAL("Sensors vector is smaller than " << sensor);
148  }
149  const auto& sides = sensors[sensor];
150  if (sides.size() <= side) {
151  B2FATAL("Sides vector is smaller than " << side);
152  }
153 
154  return T::getReference(sides[side] , strip);
155  }
156 
160  TString get_uniqueID() const {return m_uniqueID;}
161 
172  void set(unsigned int layer,
173  unsigned int ladder,
174  unsigned int sensor,
175  unsigned int side,
176  unsigned int strip,
177  typename T::calibrationType value)
178  {
179  if (calibrations.size() <= layer) {
180  B2FATAL("Layers vector is smaller than " << layer);
181  }
182  auto& ladders = calibrations[layer];
183  if (ladders.size() <= ladder) {
184  B2FATAL("Ladders vector is smaller than " << ladder);
185  }
186  auto& sensors = ladders[ladder];
187  if (sensors.size() <= sensor) {
188  B2FATAL("Sensors vector is smaller than " << sensor);
189  }
190  auto& sides = sensors[sensor];
191  if (sides.size() <= side) {
192  B2FATAL("Sides vector is smaller than " << side);
193  }
194 
195  return T::set(sides[side] , strip, value);
196  }
197 
203  E_side sideIndex(bool isU) const
204  {
205  if (isU)
206  return Uindex;
207  return Vindex;
208  // tertium non datur
209  }
210 
211  typedef T t_perSideContainer;
212  private:
213 
214  TString m_uniqueID;
216  ClassDef(SVDCalibrationsBase, 2)
217  };
218 
220 }
Belle2::SVDCalibrationsBase::getReference
const T::calibrationType & getReference(unsigned int layer, unsigned int ladder, unsigned int sensor, unsigned int side, unsigned int strip) const
Return a reference to the calibration associated to a given strip.
Definition: SVDCalibrationsBase.h:141
Belle2::SVDCalibrationsBase::E_side
E_side
This enumeration assure the same semantic of the isU methods defined by Peter Kv.
Definition: SVDCalibrationsBase.h:65
Belle2::SVDCalibrationsBase::get_uniqueID
TString get_uniqueID() const
Get the unique ID of the calibration.
Definition: SVDCalibrationsBase.h:169
Belle2::SVDCalibrationsBase::m_uniqueID
TString m_uniqueID
The unique identifier is a private member of SVDCalibrationsBase, whose value is assigned in the cons...
Definition: SVDCalibrationsBase.h:223
Belle2::SVDCalibrationsBase::get
T::calibrationType get(unsigned int layer, unsigned int ladder, unsigned int sensor, unsigned int side, unsigned int strip) const
Return the calibration associated to a given strip.
Definition: SVDCalibrationsBase.h:106
Belle2::SVDCalibrationsBase::set
void set(unsigned int layer, unsigned int ladder, unsigned int sensor, unsigned int side, unsigned int strip, typename T::calibrationType value)
Set the calibration associated to a given strip.
Definition: SVDCalibrationsBase.h:181
Belle2::SVDCalibrationsBase::SVDLadder
std::vector< SVDSensor > SVDLadder
An SVDLadder is a vector of SVDSensors.
Definition: SVDCalibrationsBase.h:49
Belle2::SVDCalibrationsBase::~SVDCalibrationsBase
~SVDCalibrationsBase()
Simple destructor.
Definition: SVDCalibrationsBase.h:94
Belle2::SVDCalibrationsBase::SVD
std::vector< SVDLayer > SVD
The SVD is a vector of SVDLayers.
Definition: SVDCalibrationsBase.h:55
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDCalibrationsBase::calibrations
SVD calibrations
an SVD calibration
Definition: SVDCalibrationsBase.h:58
Belle2::SVDCalibrationsBase::SVDSensor
std::vector< typename T::payloadContainerType > SVDSensor
T::payloadContainerType can be a vector whose length is the number of strips per side or a list of de...
Definition: SVDCalibrationsBase.h:46
Belle2::SVDCalibrationsBase::SVDLayer
std::vector< SVDLadder > SVDLayer
An SVDLayer is a vector of SVDLadders.
Definition: SVDCalibrationsBase.h:52
Belle2::SVDCalibrationsBase::t_perSideContainer
T t_perSideContainer
typedef of the container of each side
Definition: SVDCalibrationsBase.h:220
Belle2::SVDCalibrationsBase
base class for calibrations classes
Definition: SVDCalibrationsBase.h:36
Belle2::SVDCalibrationsBase::SVDCalibrationsBase
SVDCalibrationsBase(typename T::calibrationType defaultT=typename T::calibrationType(), const TString &uniqueID="")
The default constructor initialize all the vectors.
Definition: SVDCalibrationsBase.h:69
Belle2::SVDCalibrationsBase::sideIndex
E_side sideIndex(bool isU) const
Return the array index of the side.
Definition: SVDCalibrationsBase.h:212