Belle II Software  release-05-02-19
DBObjCalibrationConstMapBase.cc
1 #include <calibration/DBObjCalibrationConstMapBase.h>
2 
3 #include <iostream>
4 
5 using namespace Belle2;
6 
8 {
9  for (auto& elementParam : m_constants) {
10  std::cout << " Element " << elementParam.first.first << " Param " << elementParam.first.second << " Value = " << elementParam.second
11  << std::endl;
12  }
13 }
14 
16 {
17  m_constants.clear();
18 }
19 
22 {
23 
24  auto constant = m_constants.find({id, param});
25  if (constant == m_constants.end()) {
26  return 0.;
27  }
28  return constant->second;
29 }
30 
32  double value)
33 {
34  m_constants[ {id, param}] = value;
35 }
36 
38  double value, bool subtractInsteadOfAdd)
39 {
40  double original = get(id, param);
41  double newValue = (subtractInsteadOfAdd) ? (original - value) : (original + value);
42  set(id, param, newValue);
43  return newValue;
44 }
45 /*
46 void DBObjCalibrationConstMapBase::Streamer(TBuffer& R__b)
47 {
48  if (R__b.IsReading()) {
49  m_constants.clear();
50  unsigned int map_size = 0;
51  R__b >> map_size;
52  for (unsigned int i = 0; i < map_size; ++i) {
53  baseType element = 0;
54  baseType param = 0;
55  double value = 0.;
56  R__b >> element >> param >> value;
57  m_constants[ {element, param}] = value;
58  }
59  } else {
60  unsigned int map_size = m_constants.size();
61  R__b << map_size;
62  for (auto& map_entry : m_constants) {
63  R__b << map_entry.first.first << map_entry.first.second << map_entry.second;
64  }
65  }
66 }
67 */
Belle2::DBObjCalibrationConstMapBase::set
virtual void set(baseType id, baseType param, double value)
Set parameter correction for given WireID and parameter number.
Definition: DBObjCalibrationConstMapBase.cc:31
Belle2::DBObjCalibrationConstMapBase::~DBObjCalibrationConstMapBase
virtual ~DBObjCalibrationConstMapBase()
Destructor.
Definition: DBObjCalibrationConstMapBase.cc:15
Belle2::DBObjCalibrationConstMapBase::m_constants
ElementParameterMap m_constants
Map of map of all calibration elements' constants.
Definition: DBObjCalibrationConstMapBase.h:78
Belle2::DBObjCalibrationConstMapBase::add
virtual double add(baseType id, baseType param, double value, bool subtractInsteadOfAdd=false)
Add correction to already stored (or to 0. if not set yet) constant value (optionaly with minus sign)
Definition: DBObjCalibrationConstMapBase.cc:37
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DBObjCalibrationConstMapBase::baseType
int baseType
The underlying element type (also for param id)
Definition: DBObjCalibrationConstMapBase.h:51
Belle2::DBObjCalibrationConstMapBase::dump
virtual void dump() const
Write all elements' parameters' values to standard output.
Definition: DBObjCalibrationConstMapBase.cc:7
Belle2::DBObjCalibrationConstMapBase::get
virtual double get(baseType id, baseType param) const
Get parameter value for given element and parameter number.
Definition: DBObjCalibrationConstMapBase.cc:20