Belle II Software  release-05-01-25
SVDCalibrationsBitmap.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Giulia Casarosa, Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  * WARNING: PLEASE, PLEASE, PLEASE USE ONLY WITH CAUTION AT YOUR OWN RISK!*
10  **************************************************************************/
11 
12 #pragma once
13 #include <vector>
14 #include <bitset>
15 #include <climits>
16 
17 #include <svd/dbobjects/SVDCalibrationsBase.h>
18 
19 namespace Belle2 {
26  class SVDCalibrationsBitmap {
27 
28  public:
29  typedef bool calibrationType;
30  typedef unsigned long bundleType;
31  typedef std::vector< bundleType > payloadContainerType;
33  static const int nBitsInBundle = CHAR_BIT * sizeof(bundleType);
37 
40 
42  static inline calibrationType get(const payloadContainerType& svdBitmap, unsigned int strip)
43  {
44  std::bitset<nBitsInBundle> bundle = svdBitmap.at(strip / (nBitsInBundle));
45  return bundle[strip % nBitsInBundle];
46  }
47 
49  static inline void set(payloadContainerType& svdBitmap, unsigned int strip,
50  calibrationType value)
51  {
52  std::bitset<nBitsInBundle> bundle = svdBitmap.at(strip / (nBitsInBundle));
53  bundle[strip % nBitsInBundle] = value;
54  svdBitmap.at(strip / (nBitsInBundle)) = bundle.to_ulong();
55  }
56 
58  static void init(payloadContainerType& svdBitmap, unsigned int layer,
59  unsigned int /*ladder*/ , unsigned int /*sensor*/,
60  unsigned int side, bool defaultB)
61  {
62  unsigned int numberOfStrips = 0;
63 
64  if (layer < 3)
65  return;
66 
67  switch (side) {
69  numberOfStrips = 768;
70  break;
71 
73  numberOfStrips = layer == 3 ? 768 : 512;
74  }
75 
76  if (!defaultB)
77  svdBitmap.resize(numberOfStrips / nBitsInBundle, 0);
78  else
79  svdBitmap.resize(numberOfStrips / nBitsInBundle, ULONG_MAX);
80  }
81  };
83 }
Belle2::SVDCalibrationsBitmap::init
static void init(payloadContainerType &svdBitmap, unsigned int layer, unsigned int, unsigned int, unsigned int side, bool defaultB)
initialize the calibration bitmap
Definition: SVDCalibrationsBitmap.h:67
Belle2::SVDCalibrationsBitmap::SVDCalibrationsBitmap
SVDCalibrationsBitmap()
default constructor
Definition: SVDCalibrationsBitmap.h:45
Belle2::SVDCalibrationsBitmap::calibrationType
bool calibrationType
typedef of the calibration value (1/0)
Definition: SVDCalibrationsBitmap.h:38
Belle2::SVDCalibrationsBitmap::~SVDCalibrationsBitmap
~SVDCalibrationsBitmap()
default destructor
Definition: SVDCalibrationsBitmap.h:48
Belle2::SVDCalibrationsBitmap::bundleType
unsigned long bundleType
typedef for the bundle type
Definition: SVDCalibrationsBitmap.h:39
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDCalibrationsBitmap::payloadContainerType
std::vector< bundleType > payloadContainerType
typedef of the vector of bundle type
Definition: SVDCalibrationsBitmap.h:40
Belle2::SVDCalibrationsBitmap::set
static void set(payloadContainerType &svdBitmap, unsigned int strip, calibrationType value)
set the calibration value of the strip
Definition: SVDCalibrationsBitmap.h:58
Belle2::SVDCalibrationsBitmap::nBitsInBundle
static const int nBitsInBundle
nuber of bits in the bundle
Definition: SVDCalibrationsBitmap.h:42
Belle2::SVDCalibrationsBase
base class for calibrations classes
Definition: SVDCalibrationsBase.h:36
Belle2::SVDCalibrationsBitmap::get
static calibrationType get(const payloadContainerType &svdBitmap, unsigned int strip)
get the calibration value of that strip
Definition: SVDCalibrationsBitmap.h:51