Belle II Software development
SVDCalibrationsBase.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10#include <framework/logging/Logger.h>
11
12#include <TObject.h>
13#include <vector>
14#include <TString.h>
15
16namespace Belle2 {
23 template < class T >
24 class SVDCalibrationsBase: public TObject {
25
34 typedef std::vector< typename T::payloadContainerType > SVDSensor;
35
37 typedef std::vector< SVDSensor > SVDLadder;
38
40 typedef std::vector< SVDLadder > SVDLayer;
41
43 typedef std::vector< SVDLayer > SVD;
44
47
48
49 public:
50
53 enum E_side { Vindex = 0, Uindex = 1 };
54
57 SVDCalibrationsBase(typename T::calibrationType defaultT =
58 typename T::calibrationType(),
59 const TString& uniqueID = ""): m_uniqueID(uniqueID) // Add a string as unique identifier for a given configuration dataset
60 {
61
62 calibrations.resize(7); // Layers 0 1 2 3 4 5 6
63 int laddersOnLayer[] = { 0, 0, 0, 8, 11, 13, 17 };
64 for (unsigned int layer = 0 ; layer < calibrations.size() ; layer ++) {
65 calibrations[layer].resize(laddersOnLayer[layer]);
66 int sensorsOnLadder[] = {0, 0, 0, 3, 4, 5, 6};
67 for (unsigned int ladder = 1; ladder < calibrations[layer].size(); ladder ++) {
68 calibrations[layer][ladder].resize(sensorsOnLadder[ layer ]);
69 for (unsigned int sensor = 1; sensor < calibrations[layer][ladder].size() ; sensor ++) {
70 calibrations[layer][ladder][sensor].resize(2);
71 T::init(calibrations[layer][ladder][sensor][ Uindex ], layer, ladder, sensor, Uindex,
72 defaultT);
73 T::init(calibrations[layer][ladder][sensor][ Vindex ], layer, ladder, sensor, Vindex,
74 defaultT);
75 }
76 }
77 }
78 }
79
83
94 typename T::calibrationType get(unsigned int layer,
95 unsigned int ladder,
96 unsigned int sensor,
97 unsigned int side,
98 unsigned int strip) const
99 {
100 if (calibrations.size() <= layer) {
101 B2FATAL("Layers vector is smaller than " << layer);
102 }
103 const auto& ladders = calibrations[layer];
104 if (ladders.size() <= ladder) {
105 B2FATAL("Ladders vector is smaller than " << ladder);
106 }
107 const auto& sensors = ladders[ladder];
108 if (sensors.size() <= sensor) {
109 B2FATAL("Sensors vector is smaller than " << sensor);
110 }
111 const auto& sides = sensors[sensor];
112 if (sides.size() <= side) {
113 B2FATAL("Sides vector is smaller than " << side);
114 }
115
116 return T::get(sides[side], strip);
117 }
118
129 const typename T::calibrationType& getReference(unsigned int layer,
130 unsigned int ladder,
131 unsigned int sensor,
132 unsigned int side,
133 unsigned int strip) const
134 {
135 if (calibrations.size() <= layer) {
136 B2FATAL("Layers vector is smaller than " << layer);
137 }
138 const auto& ladders = calibrations[layer];
139 if (ladders.size() <= ladder) {
140 B2FATAL("Ladders vector is smaller than " << ladder);
141 }
142 const auto& sensors = ladders[ladder];
143 if (sensors.size() <= sensor) {
144 B2FATAL("Sensors vector is smaller than " << sensor);
145 }
146 const auto& sides = sensors[sensor];
147 if (sides.size() <= side) {
148 B2FATAL("Sides vector is smaller than " << side);
149 }
150
151 return T::getReference(sides[side], strip);
152 }
153
157 TString get_uniqueID() const {return m_uniqueID;}
158
170 void set(unsigned int layer,
171 unsigned int ladder,
172 unsigned int sensor,
173 unsigned int side,
174 unsigned int strip,
175 typename T::calibrationType value)
176 {
177 if (calibrations.size() <= layer) {
178 B2FATAL("Layers vector is smaller than " << layer);
179 }
180 auto& ladders = calibrations[layer];
181 if (ladders.size() <= ladder) {
182 B2FATAL("Ladders vector is smaller than " << ladder);
183 }
184 auto& sensors = ladders[ladder];
185 if (sensors.size() <= sensor) {
186 B2FATAL("Sensors vector is smaller than " << sensor);
187 }
188 auto& sides = sensors[sensor];
189 if (sides.size() <= side) {
190 B2FATAL("Sides vector is smaller than " << side);
191 }
192
193 return T::set(sides[side], strip, value);
194 }
195
201 E_side sideIndex(bool isU) const
202 {
203 if (isU)
204 return Uindex;
205 return Vindex;
206 // tertium non datur
207 }
208
210 private:
211
212 TString m_uniqueID;
214 ClassDef(SVDCalibrationsBase, 2)
215 };
216
218}
base class for calibrations classes
TString m_uniqueID
The unique identifier is a private member of SVDCalibrationsBase, whose value is assigned in the cons...
SVD calibrations
an SVD calibration
std::vector< SVDLadder > SVDLayer
An SVDLayer is a vector of SVDLadders.
~SVDCalibrationsBase()
Simple destructor.
E_side sideIndex(bool isU) const
Return the array index of the side.
T t_perSideContainer
typedef of the container of each side
std::vector< SVDLayer > SVD
The SVD is a vector of SVDLayers.
TString get_uniqueID() const
Get the unique ID of the calibration.
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.
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.
SVDCalibrationsBase(typename T::calibrationType defaultT=typename T::calibrationType(), const TString &uniqueID="")
The default constructor initialize all the vectors.
E_side
This enumeration assure the same semantic of the isU methods defined by Peter Kv.
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...
std::vector< SVDSensor > SVDLadder
An SVDLadder is a vector of SVDSensors.
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.
Abstract base class for different kinds of events.