Belle II Software development
FilterValueDataSet.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
11#include <framework/logging/Logger.h>
12#include <string>
13#include <vector>
14#include <map>
15#include <limits> // std::numeric_limits
16
17
18namespace Belle2 {
25 class SecIDPair {
26 public:
27 unsigned outer;
28 unsigned inner;
32
34 void reset()
35 {
36 outer = std::numeric_limits<unsigned>::max();
37 inner = std::numeric_limits<unsigned>::max();
38 }
39
42 bool isValid()
43 {
44 return ((outer == std::numeric_limits<unsigned>::max())
45 or (inner == std::numeric_limits<unsigned>::max()))
46 ? false : true;
47 }
48 };
49
50
51
54 public:
55 unsigned outer;
56 unsigned center;
57 unsigned inner;
61
63 void reset()
64 {
65 outer = std::numeric_limits<unsigned>::max();
66 center = std::numeric_limits<unsigned>::max();
67 inner = std::numeric_limits<unsigned>::max();
68 }
69
72 bool isValid()
73 {
74 return ((outer == std::numeric_limits<unsigned>::max())
75 or (center == std::numeric_limits<unsigned>::max())
76 or (inner == std::numeric_limits<unsigned>::max()))
77 ? false : true;
78 }
79 };
80
81
82
85 public:
86 unsigned outer;
87 unsigned outerCenter;
88 unsigned innerCenter;
89 unsigned inner;
93
95 void reset()
96 {
97 outer = std::numeric_limits<unsigned>::max();
98 outerCenter = std::numeric_limits<unsigned>::max();
99 innerCenter = std::numeric_limits<unsigned>::max();
100 inner = std::numeric_limits<unsigned>::max();
101 }
102
105 bool isValid()
106 {
107 return ((outer == std::numeric_limits<unsigned>::max())
108 or (outerCenter == std::numeric_limits<unsigned>::max())
109 or (innerCenter == std::numeric_limits<unsigned>::max())
110 or (inner == std::numeric_limits<unsigned>::max()))
111 ? false : true;
112 }
113 };
114
115
116
118 template <class SecIDSetType>
120 protected:
122 std::map<std::string, double> m_values;
123
124 public:
125
127 unsigned expNo;
128
130 unsigned runNo;
131
133 unsigned evtNo;
134
136 unsigned trackNo;
137
139 int pdg;
140
142 SecIDSetType secIDs;
143
144
146
148 explicit FilterValueDataSet(std::vector<std::string> filterNames) :
149 expNo(std::numeric_limits<unsigned>::max()),
150 runNo(std::numeric_limits<unsigned>::max()),
151 evtNo(std::numeric_limits<unsigned>::max()),
152 trackNo(std::numeric_limits<unsigned>::max()),
153 pdg(std::numeric_limits<int>::max())
154 {
155 for (auto name : filterNames) {
156 m_values.insert({name, std::numeric_limits<double>::max()});
157 B2DEBUG(26, "FilterValueDataSet::constructor: filterName " << name << " has been added.");
158 }
159 B2DEBUG(25, "FilterValueDataSet::constructor: " << m_values.size() << " filters have been added.");
160 }
161
163 void setValueOfFilter(std::string filterName, double value)
164 {
165 auto it = m_values.find(filterName);
166 if (it == m_values.end()) {
167 B2ERROR("FilterValueDataSet::setValueOfFilter: filterName " << filterName
168 << "is not known, value " << value
169 << " will NOT be added!");
170 return;
171 }
172 it->second = value;
173 }
174
176 double* getValuePtr(std::string filterName)
177 {
178 double* valuePtr = nullptr;
179 auto it = m_values.find(filterName);
180 if (it != m_values.end()) {
181 valuePtr = &it->second;
182 } else { B2WARNING("filter could not be found, returning nullptr instead!"); }
183 return valuePtr;
184 }
185
187 void reset()
188 {
189 expNo = std::numeric_limits<unsigned>::max();
190 runNo = std::numeric_limits<unsigned>::max();
191 evtNo = std::numeric_limits<unsigned>::max();
192 trackNo = std::numeric_limits<unsigned>::max();
193 pdg = std::numeric_limits<int>::max();
194 secIDs.reset();
195 for (auto& entry : m_values) {
196 entry.second = std::numeric_limits<double>::max();
197 }
198 }
199
202 bool isValid()
203 {
204 if (expNo == std::numeric_limits<unsigned>::max()) return false;
205 if (runNo == std::numeric_limits<unsigned>::max()) return false;
206 if (evtNo == std::numeric_limits<unsigned>::max()) return false;
207 if (trackNo == std::numeric_limits<unsigned>::max()) return false;
208 if (pdg == std::numeric_limits<int>::max()) return false;
209 for (auto& entry : m_values) {
210 if (entry.second == std::numeric_limits<double>::max()) return false;
211 }
212 return secIDs.isValid();
213 }
214 };
215
217}
218
contains the relevant information needed for filling a TTree containing train-data for the secMap.
std::map< std::string, double > m_values
map containing a value for each key==name of filter.
unsigned runNo
number of the run this dataset is taken from.
SecIDSetType secIDs
contains the secIDs.
double * getValuePtr(std::string filterName)
returns pointer to value of given filterName, nullptr if filterName has not been found.
int pdg
Pdg given by reference track.
unsigned trackNo
number of the reference track this dataset is taken from (its ID in the datastore).
unsigned evtNo
number of the event this dataset is taken from.
unsigned expNo
number of the experiment this dataset is taken from.
void setValueOfFilter(std::string filterName, double value)
for given filterName a value is set.
FilterValueDataSet(std::vector< std::string > filterNames)
constructor, expects to get a vector of names for filters.
void reset()
resets all values stored to std::numeric_limits< double>::max().
bool isValid()
checks if any value is still not set and returns false if that is the case.
allows to set outer and inner secID.
unsigned outer
id of outer sector.
void reset()
sets all values to outer = std::numeric_limits< unsigned>::max();
SecIDPair()
constructor - resets all values to outer = std::numeric_limits< unsigned>::max();
bool isValid()
checks if any value is still not set and returns false if that is the case.
unsigned inner
id of inner sector.
allows to set outer, outerCenter, innerCenter and inner secID.
unsigned outer
id of outer sector.
unsigned innerCenter
id of inner-center sector.
void reset()
sets all values to outer = std::numeric_limits< unsigned>::max();
unsigned outerCenter
id of outer-center sector.
SecIDQuadruplet()
constructor - resets all values to outer = std::numeric_limits< unsigned>::max();
bool isValid()
checks if any value is still not set and returns false if that is the case.
unsigned inner
id of inner sector.
allows to set outer, center and inner secID.
unsigned center
id of center sector.
unsigned outer
id of outer sector.
SecIDTriplet()
constructor - resets all values to outer = std::numeric_limits< unsigned>::max();
void reset()
sets all values to outer = std::numeric_limits< unsigned>::max();
bool isValid()
checks if any value is still not set and returns false if that is the case.
unsigned inner
id of inner sector.
Abstract base class for different kinds of events.
STL namespace.