Belle II Software  release-08-01-10
CDCWireHitRequirements.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 <TObject.h>
12 #include <framework/logging/Logger.h>
13 #include <boost/property_tree/ptree.hpp>
14 #include <boost/property_tree/json_parser.hpp>
15 
16 namespace Belle2 {
34  class CDCWireHitRequirements: public TObject {
35 
41  typedef std::pair<short, short> intRange_t;
47  typedef std::pair<float, float> floatRange_t;
48 
49  public:
50 
55 
59  explicit CDCWireHitRequirements(boost::property_tree::ptree tree)
60  {
61 
62  try {
63 
64  m_ADCRangeFirstSuperLayer = std::make_pair(tree.get<short>("FirstSuperLayer.ADC.min"),
65  tree.get<short>("FirstSuperLayer.ADC.max"));
66  m_ADCRangeOuterSuperLayers = std::make_pair(tree.get<short>("OuterSuperLayers.ADC.min"),
67  tree.get<short>("OuterSuperLayers.ADC.max"));
68 
69  m_TOTRangeFirstSuperLayer = std::make_pair(tree.get<short>("FirstSuperLayer.TOT.min"),
70  tree.get<short>("FirstSuperLayer.TOT.max"));
71  m_TOTRangeOuterSuperLayers = std::make_pair(tree.get<short>("OuterSuperLayers.TOT.min"),
72  tree.get<short>("OuterSuperLayers.TOT.max"));
73 
74  m_ADCOverTOTRangeFirstSuperLayer = std::make_pair(tree.get<float>("FirstSuperLayer.ADCOverTOT.min"),
75  tree.get<float>("FirstSuperLayer.ADCOverTOT.max"));
76  m_ADCOverTOTRangeOuterSuperLayers = std::make_pair(tree.get<float>("OuterSuperLayers.ADCOverTOT.min"),
77  tree.get<float>("OuterSuperLayers.ADCOverTOT.max"));
78 
79  for (boost::property_tree::ptree::value_type& row : tree.get_child("FirstSuperLayer.MaxADCGivenTOT")) {
80  m_MaxADCGivenTOTFirstSuperLayer.insert(std::make_pair(row.second.get<short>("givenTOT"),
81  row.second.get<short>("maxADC")));
82  }
83  for (boost::property_tree::ptree::value_type& row : tree.get_child("OuterSuperLayers.MaxADCGivenTOT")) {
84  m_MaxADCGivenTOTOuterSuperLayers.insert(std::make_pair(row.second.get<short>("givenTOT"),
85  row.second.get<short>("maxADC")));
86  }
87 
88  } catch (boost::property_tree::ptree_error& e) {
89  // Any problem when parsing the tree?
90  B2FATAL("Cannot parse CDCWireHit requirement information: " << e.what());
91  }
92 
93  }
94 
99 
102  {
104  }
105 
107  void setADCRangeFirstSuperLayer(const intRange_t& ADCRangeFirstSuperLayer)
108  {
109  m_ADCRangeFirstSuperLayer = ADCRangeFirstSuperLayer;
110  }
111 
114  {
116  }
117 
119  void setADCRangeOuterSuperLayers(const intRange_t& ADCRangeOuterSuperLayers)
120  {
121  m_ADCRangeOuterSuperLayers = ADCRangeOuterSuperLayers;
122  }
123 
126  {
128  }
129 
131  void setTOTRangeFirstSuperLayer(const intRange_t& TOTRangeFirstSuperLayer)
132  {
133  m_TOTRangeFirstSuperLayer = TOTRangeFirstSuperLayer;
134  }
135 
138  {
140  }
141 
143  void setTOTRangeOuterSuperLayers(const intRange_t& TOTRangeOuterSuperLayers)
144  {
145  m_TOTRangeOuterSuperLayers = TOTRangeOuterSuperLayers;
146  }
147 
150  {
152  }
153 
155  void setADCOverTOTRangeFirstSuperLayer(const floatRange_t& ADCOverTOTRangeFirstSuperLayer)
156  {
157  m_ADCOverTOTRangeFirstSuperLayer = ADCOverTOTRangeFirstSuperLayer;
158  }
159 
162  {
164  }
165 
167  void setADCOverTOTRangeOuterSuperLayers(const floatRange_t& ADCOverTOTRangeOuterSuperLayers)
168  {
169  m_ADCOverTOTRangeOuterSuperLayers = ADCOverTOTRangeOuterSuperLayers;
170  }
171 
173  const std::map<short, short> getMaxADCGivenTOTFirstSuperLayer() const
174  {
176  }
177 
179  short getMaxADCGivenTOTFirstSuperLayer(short tot) const
180  {
181  // Find maxADC given TOT
182  const auto it = m_MaxADCGivenTOTFirstSuperLayer.find(tot);
183 
184  // Check if TOT exists in map or not
185  if (it != m_MaxADCGivenTOTFirstSuperLayer.end()) {
186  return it->second;
187  } else {
188  // By convention, -1 stands for unbounded
189  return -1;
190  }
191  }
192 
194  void setMaxADCGivenTOTFirstSuperLayer(const std::map<short, short>& MaxADCGivenTOTFirstSuperLayer)
195  {
196  m_MaxADCGivenTOTFirstSuperLayer = MaxADCGivenTOTFirstSuperLayer;
197  }
198 
200  const std::map<short, short> getMaxADCGivenTOTOuterSuperLayers() const
201  {
203  }
204 
206  short getMaxADCGivenTOTOuterSuperLayers(short tot) const
207  {
208  // Find maxADC given TOT
209  const auto it = m_MaxADCGivenTOTOuterSuperLayers.find(tot);
210 
211  // Check if TOT exists in map or not
212  if (it != m_MaxADCGivenTOTOuterSuperLayers.end()) {
213  return it->second;
214  } else {
215  // By convention, -1 stands for unbounded
216  return -1;
217  }
218  }
219 
221  void setMaxADCGivenTOTOuterSuperLayers(const std::map<short, short>& MaxADCGivenTOTOuterSuperLayers)
222  {
223  m_MaxADCGivenTOTOuterSuperLayers = MaxADCGivenTOTOuterSuperLayers;
224  }
225 
227  void dump() const
228  {
229  std::string MaxADCGivenTOTFirstSuperLayer = "";
230  for (auto& v : getMaxADCGivenTOTFirstSuperLayer()) {
231  MaxADCGivenTOTFirstSuperLayer += "If TOT == " + std::to_string(v.first) +
232  ", then ADC <= " + std::to_string(v.second) + "\n";
233  }
234 
235  std::string MaxADCGivenTOTOuterSuperLayers = "";
236  for (auto& v : getMaxADCGivenTOTOuterSuperLayers()) {
237  MaxADCGivenTOTOuterSuperLayers += "If TOT == " + std::to_string(v.first) +
238  ", then ADC <= " + std::to_string(v.second) + "\n";
239  }
240 
241  B2INFO(" " << std::endl
242  << "=======================================================" << std::endl
243  << "CDCWireHit requirements (-1 values stand for unbounded)" << std::endl
244  << "=======================================================" << std::endl
245  << "First Super Layer: " << std::endl
246  << getADCRangeFirstSuperLayer().first << " <= ADC <= " << getADCRangeFirstSuperLayer().second << std::endl
247  << getTOTRangeFirstSuperLayer().first << " <= TOT <= " << getTOTRangeFirstSuperLayer().second << std::endl
248  << getADCOverTOTRangeFirstSuperLayer().first << " <= ADC/TOT <= " << getADCOverTOTRangeFirstSuperLayer().second << std::endl
249  << MaxADCGivenTOTFirstSuperLayer << std::endl
250  << "Outer Super Layers: " << std::endl
251  << getADCRangeOuterSuperLayers().first << " <= ADC <= " << getADCRangeOuterSuperLayers().second << std::endl
252  << getTOTRangeOuterSuperLayers().first << " <= TOT <= " << getTOTRangeOuterSuperLayers().second << std::endl
253  << getADCOverTOTRangeOuterSuperLayers().first << " <= ADC/TOT <= " << getADCOverTOTRangeOuterSuperLayers().second << std::endl
254  << MaxADCGivenTOTOuterSuperLayers
255  << "=======================================================" << std::endl);
256 
257  }
258 
259  private:
260 
269 
278 
287 
291  std::map<short, short> m_MaxADCGivenTOTFirstSuperLayer = {};
295  std::map<short, short> m_MaxADCGivenTOTOuterSuperLayers = {};
296 
299  };
300 
302 } // end namespace Belle2
Database object containing cut values to filter CDCWireHits.
void setTOTRangeFirstSuperLayer(const intRange_t &TOTRangeFirstSuperLayer)
Set allowed TOT range (first super layer of CDC). An upper value of -1 stands for unbounded.
intRange_t m_ADCRangeOuterSuperLayers
Allowed ADC range (outer super layers of CDC).
short getMaxADCGivenTOTOuterSuperLayers(short tot) const
Get maximum allowed ADC given TOT (outer super layers of CDC). An upper value of -1 stands for unboun...
void setADCOverTOTRangeOuterSuperLayers(const floatRange_t &ADCOverTOTRangeOuterSuperLayers)
Set allowed ADC/TOT range (outer super layers of CDC). An upper value of -1 stands for unbounded.
CDCWireHitRequirements(boost::property_tree::ptree tree)
Constructor using a boost::property_tree.
const intRange_t & getADCRangeOuterSuperLayers() const
Get allowed ADC range (outer super layers of CDC). An upper value of -1 stands for unbounded.
void setTOTRangeOuterSuperLayers(const intRange_t &TOTRangeOuterSuperLayers)
Set allowed TOT range (outer super layers of CDC). An upper value of -1 stands for unbounded.
floatRange_t m_ADCOverTOTRangeOuterSuperLayers
Allowed ADC/TOT range (outer super layers of CDC).
const intRange_t & getTOTRangeOuterSuperLayers() const
Get allowed TOT range (outer super layers of CDC). An upper value of -1 stands for unbounded.
void setMaxADCGivenTOTFirstSuperLayer(const std::map< short, short > &MaxADCGivenTOTFirstSuperLayer)
Set map of maximum allowed ADC given TOT (first super layer of CDC). An upper value of -1 stands for ...
intRange_t m_ADCRangeFirstSuperLayer
Allowed ADC range (first super layer of CDC).
intRange_t m_TOTRangeFirstSuperLayer
Allowed TOT range (first super layer of CDC).
ClassDef(CDCWireHitRequirements, 2)
ROOT ClassDef.
const floatRange_t & getADCOverTOTRangeOuterSuperLayers() const
Get allowed ADC/TOT range (outer super layers of CDC). An upper value of -1 stands for unbounded.
std::map< short, short > m_MaxADCGivenTOTOuterSuperLayers
Map of conditions of the type: if TOT==x, then ADC<=y (outer super layers of CDC).
CDCWireHitRequirements()=default
Default constructor.
const std::map< short, short > getMaxADCGivenTOTFirstSuperLayer() const
Get map of maximum allowed ADC given TOT (first super layer of CDC). An upper value of -1 stands for ...
floatRange_t m_ADCOverTOTRangeFirstSuperLayer
Allowed ADC/TOT range (first super layer of CDC).
const intRange_t & getADCRangeFirstSuperLayer() const
Get allowed ADC range (first super layer of CDC). An upper value of -1 stands for unbounded.
std::pair< short, short > intRange_t
Integer range.
std::pair< float, float > floatRange_t
Float range.
std::map< short, short > m_MaxADCGivenTOTFirstSuperLayer
Map of conditions of the type: if TOT==x, then ADC<=y (first super layer of CDC).
void setADCRangeOuterSuperLayers(const intRange_t &ADCRangeOuterSuperLayers)
Set allowed ADC range (outer super layers of CDC). An upper value of -1 stands for unbounded.
const std::map< short, short > getMaxADCGivenTOTOuterSuperLayers() const
Get map of maximum allowed ADC given TOT (outer super layers of CDC). An upper value of -1 stands for...
const floatRange_t & getADCOverTOTRangeFirstSuperLayer() const
Get allowed ADC/TOT range (first super layer of CDC). An upper value of -1 stands for unbounded.
void setADCRangeFirstSuperLayer(const intRange_t &ADCRangeFirstSuperLayer)
Set allowed ADC range (first super layer of CDC). An upper value of -1 stands for unbounded.
intRange_t m_TOTRangeOuterSuperLayers
Allowed TOT range (outer super layers of CDC).
void setADCOverTOTRangeFirstSuperLayer(const floatRange_t &ADCOverTOTRangeFirstSuperLayer)
Set allowed ADC/TOT range (first super layer of CDC). An upper value of -1 stands for unbounded.
void setMaxADCGivenTOTOuterSuperLayers(const std::map< short, short > &MaxADCGivenTOTOuterSuperLayers)
Set map of maximum allowed ADC given TOT (outer super layers of CDC). An upper value of -1 stands for...
~CDCWireHitRequirements()=default
Destructor.
const intRange_t & getTOTRangeFirstSuperLayer() const
Get allowed TOT range (first super layer of CDC). An upper value of -1 stands for unbounded.
void dump() const
Print content.
short getMaxADCGivenTOTFirstSuperLayer(short tot) const
Get maximum allowed ADC given TOT (first super layer of CDC). An upper value of -1 stands for unbound...
Abstract base class for different kinds of events.