LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CalibrationExtraInfo.cxx
Go to the documentation of this file.
1 #include "CalibrationExtraInfo.h"
2 #include "IOVDataError.h"
3 
4 namespace lariov {
5 
6  void CalibrationExtraInfo::AddOrReplaceBoolData(std::string const& label, bool const data)
7  {
8  fBoolData[label] = data;
9  }
10 
11  void CalibrationExtraInfo::AddOrReplaceIntData(std::string const& label, int const data)
12  {
13  fIntData[label] = data;
14  }
15 
16  void CalibrationExtraInfo::AddOrReplaceVecIntData(std::string const& label,
17  std::vector<int> const& data)
18  {
19  fVecIntData[label] = data;
20  }
21 
22  void CalibrationExtraInfo::AddOrReplaceFloatData(std::string const& label, float const data)
23  {
24  fFloatData[label] = data;
25  }
26 
27  void CalibrationExtraInfo::AddOrReplaceVecFloatData(std::string const& label,
28  std::vector<float> const& data)
29  {
30  fVecFloatData[label] = data;
31  }
32 
33  void CalibrationExtraInfo::AddOrReplaceStringData(std::string const& label,
34  std::string const& data)
35  {
36  fStringData[label] = data;
37  }
38 
39  void CalibrationExtraInfo::ClearDataByLabel(std::string const& label)
40  {
41  unsigned int n_erased = 0;
42 
43  n_erased += fBoolData.erase(label);
44  n_erased += fIntData.erase(label);
45  n_erased += fVecIntData.erase(label);
46  n_erased += fFloatData.erase(label);
47  n_erased += fVecFloatData.erase(label);
48  n_erased += fStringData.erase(label);
49 
50  if (n_erased > 1) {
51  std::cout << "INFO(CalibrationExtraInfo): Erased more than one entry with label " << label
52  << ". Recommend that you do not use identical labels" << std::endl;
53  }
54  }
55 
57  {
58  fBoolData.clear();
59  fIntData.clear();
60  fVecIntData.clear();
61  fFloatData.clear();
62  fVecFloatData.clear();
63  fStringData.clear();
64  }
65 
66  bool CalibrationExtraInfo::GetBoolData(std::string const& label) const
67  {
68  if (fBoolData.find(label) != fBoolData.end()) { return fBoolData.at(label); }
69 
70  throw IOVDataError("CalibrationExtraInfo: Could not find extra bool data " + label +
71  " for calibration " + fName);
72  }
73 
74  int CalibrationExtraInfo::GetIntData(std::string const& label) const
75  {
76  if (fIntData.find(label) != fIntData.end()) { return fIntData.at(label); }
77 
78  throw IOVDataError("CalibrationExtraInfo: Could not find extra int data " + label +
79  " for calibration " + fName);
80  }
81 
82  std::vector<int> const& CalibrationExtraInfo::GetVecIntData(std::string const& label) const
83  {
84  if (fVecIntData.find(label) != fVecIntData.end()) { return fVecIntData.at(label); }
85 
86  throw IOVDataError("CalibrationExtraInfo: Could not find extra vector int data " + label +
87  " for calibration " + fName);
88  }
89 
90  float CalibrationExtraInfo::GetFloatData(std::string const& label) const
91  {
92  if (fFloatData.find(label) != fFloatData.end()) { return fFloatData.at(label); }
93 
94  throw IOVDataError("CalibrationExtraInfo: Could not find extra float data " + label +
95  " for calibration " + fName);
96  }
97 
98  std::vector<float> const& CalibrationExtraInfo::GetVecFloatData(std::string const& label) const
99  {
100  if (fVecFloatData.find(label) != fVecFloatData.end()) { return fVecFloatData.at(label); }
101 
102  throw IOVDataError("CalibrationExtraInfo: Could not find extra vector float data " + label +
103  " for calibration " + fName);
104  }
105 
106  std::string const& CalibrationExtraInfo::GetStringData(std::string const& label) const
107  {
108  if (fStringData.find(label) != fStringData.end()) { return fStringData.at(label); }
109 
110  throw IOVDataError("CalibrationExtraInfo: Could not find extra string data " + label +
111  " for calibration " + fName);
112  }
113 } //end namesplace lariov
void AddOrReplaceVecIntData(std::string const &label, std::vector< int > const &data)
std::map< std::string, std::vector< float > > fVecFloatData
float GetFloatData(std::string const &label) const
void ClearDataByLabel(std::string const &label)
std::vector< float > const & GetVecFloatData(std::string const &label) const
std::map< std::string, std::string > fStringData
std::map< std::string, int > fIntData
std::string const & GetStringData(std::string const &label) const
void AddOrReplaceBoolData(std::string const &label, bool const data)
void AddOrReplaceVecFloatData(std::string const &label, std::vector< float > const &data)
void AddOrReplaceIntData(std::string const &label, int const data)
void AddOrReplaceStringData(std::string const &label, std::string const &data)
Filters for channels, events, etc.
std::map< std::string, bool > fBoolData
bool GetBoolData(std::string const &label) const
void AddOrReplaceFloatData(std::string const &label, float const data)
Collection of exception classes for IOVData.
std::map< std::string, std::vector< int > > fVecIntData
int GetIntData(std::string const &label) const
std::vector< int > const & GetVecIntData(std::string const &label) const
std::map< std::string, float > fFloatData