Belle II Software development
SVDCalibrationsBitmap.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 <vector>
11#include <bitset>
12#include <climits>
13
14#include <svd/dbobjects/SVDCalibrationsBase.h>
15
16namespace Belle2 {
24
25 public:
26 typedef bool calibrationType;
27 typedef unsigned long bundleType;
28 typedef std::vector< bundleType > payloadContainerType;
30 static const int nBitsInBundle = CHAR_BIT * sizeof(bundleType);
34
37
39 static inline calibrationType get(const payloadContainerType& svdBitmap, unsigned int strip)
40 {
41 std::bitset<nBitsInBundle> bundle = svdBitmap.at(strip / (nBitsInBundle));
42 return bundle[strip % nBitsInBundle];
43 }
44
46 static inline void set(payloadContainerType& svdBitmap, unsigned int strip,
47 calibrationType value)
48 {
49 std::bitset<nBitsInBundle> bundle = svdBitmap.at(strip / (nBitsInBundle));
50 bundle[strip % nBitsInBundle] = value;
51 svdBitmap.at(strip / (nBitsInBundle)) = bundle.to_ulong();
52 }
53
55 static void init(payloadContainerType& svdBitmap, unsigned int layer,
56 unsigned int /*ladder*/, unsigned int /*sensor*/,
57 unsigned int side, bool defaultB)
58 {
59 unsigned int numberOfStrips = 0;
60
61 if (layer < 3)
62 return;
63
64 switch (side) {
66 numberOfStrips = 768;
67 break;
68
70 numberOfStrips = layer == 3 ? 768 : 512;
71 }
72
73 if (!defaultB)
74 svdBitmap.resize(numberOfStrips / nBitsInBundle, 0);
75 else
76 svdBitmap.resize(numberOfStrips / nBitsInBundle, ULONG_MAX);
77 }
78 };
80}
base class for calibrations classes
class for digital (0/1) calibration values per srtip
std::vector< bundleType > payloadContainerType
typedef of the vector of bundle type
SVDCalibrationsBitmap()
default constructor
static calibrationType get(const payloadContainerType &svdBitmap, unsigned int strip)
get the calibration value of that strip
unsigned long bundleType
typedef for the bundle type
bool calibrationType
typedef of the calibration value (1/0)
~SVDCalibrationsBitmap()
default destructor
static void set(payloadContainerType &svdBitmap, unsigned int strip, calibrationType value)
set the calibration value of the strip
static void init(payloadContainerType &svdBitmap, unsigned int layer, unsigned int, unsigned int, unsigned int side, bool defaultB)
initialize the calibration bitmap
static const int nBitsInBundle
nuber of bits in the bundle
Abstract base class for different kinds of events.