Belle II Software development
DBObjCalibrationConstMapBase.cc
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#include <calibration/DBObjCalibrationConstMapBase.h>
9
10#include <iostream>
11
12using namespace Belle2;
13
15{
16 for (auto& elementParam : m_constants) {
17 std::cout << " Element " << elementParam.first.first << " Param " << elementParam.first.second << " Value = " << elementParam.second
18 << std::endl;
19 }
20}
21
23{
24 m_constants.clear();
25}
26
29{
30
31 auto constant = m_constants.find({id, param});
32 if (constant == m_constants.end()) {
33 return 0.;
34 }
35 return constant->second;
36}
37
39 double value)
40{
41 m_constants[ {id, param}] = value;
42}
43
45 double value, bool subtractInsteadOfAdd)
46{
47 double original = get(id, param);
48 double newValue = (subtractInsteadOfAdd) ? (original - value) : (original + value);
49 set(id, param, newValue);
50 return newValue;
51}
52/*
53void DBObjCalibrationConstMapBase::Streamer(TBuffer& R__b)
54{
55 if (R__b.IsReading()) {
56 m_constants.clear();
57 unsigned int map_size = 0;
58 R__b >> map_size;
59 for (unsigned int i = 0; i < map_size; ++i) {
60 baseType element = 0;
61 baseType param = 0;
62 double value = 0.;
63 R__b >> element >> param >> value;
64 m_constants[ {element, param}] = value;
65 }
66 } else {
67 unsigned int map_size = m_constants.size();
68 R__b << map_size;
69 for (auto& map_entry : m_constants) {
70 R__b << map_entry.first.first << map_entry.first.second << map_entry.second;
71 }
72 }
73}
74*/
virtual void set(baseType id, baseType param, double value)
Set parameter correction for given WireID and parameter number.
int baseType
The underlying element type (also for param id)
ElementParameterMap m_constants
Map of map of all calibration elements' constants.
virtual double get(baseType id, baseType param) const
Get parameter value for given element and parameter number.
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 (optionally with minus sign...
virtual void dump() const
Write all elements' parameters' values to standard output.
Abstract base class for different kinds of events.