ATLAS Offline Software
PixelHistoConverter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3  */
11 #ifndef PIXELCONDITIONSDATA_PIXELHISTOCONVRTER_H
12 #define PIXELCONDITIONSDATA_PIXELHISTOCONVRTER_H
13 
15 #include "GaudiKernel/StatusCode.h"
16 
17 #include <vector>
18 
20 class TAxis;
21 class TH1;
22 class TH2;
23 class TH3;
24 
26 public:
28  virtual ~PixelHistoConverter() = default;
29 
30  StatusCode setHisto1D(const TH1* histo);
31  StatusCode setHisto2D(const TH2* histo);
32  StatusCode setHisto3D(const TH3* histo);
33 
34  inline float getContent(std::size_t x) const {
35  return m_content[x];
36  }
37  inline float getContent(std::size_t x, std::size_t y) const {
38  return m_content[x + y*(m_xAxis.nBins)];
39  }
40  inline float getContent(std::size_t x, std::size_t y, std::size_t z) const {
41  return m_content[x + m_xAxis.nBins*(y + (m_yAxis.nBins * z))];
42  }
43 
44  inline bool isOverflowZ(const float value) const {
45  return (value >= m_zAxis.max);
46  }
47  bool isFirstZ(const float value) const;
48 
49 private:
50  struct Axis {
51  std::size_t nBins;
52  float min;
53  float max;
54  float width;
55  };
56 
60 
61  std::vector<float> m_content;
62 
63  static bool setAxis(Axis& axis, const TAxis* rootAxis);
64 
65  inline std::size_t findBin(const Axis& axis, const float value) const {
66  if (value <= axis.min) return 0;
67  if (value >= axis.max) return (axis.nBins - 1);
68  return ((value - axis.min) * axis.width);
69  }
70 
71 public:
72 
73  template<typename... Args>
74  std::size_t getBinX(Args&& ...args) const {
75  return findBin(m_xAxis, std::forward<Args>(args)...);
76  }
77 
78  template<typename... Args>
79  std::size_t getBinY(Args&& ...args) const {
80  return findBin(m_yAxis, std::forward<Args>(args)...);
81  }
82 
83  template<typename... Args>
84  std::size_t getBinZ(Args&& ...args) const {
85  return findBin(m_zAxis, std::forward<Args>(args)...);
86  }
87 };
88 
89 #endif
PixelHistoConverter::getBinY
std::size_t getBinY(Args &&...args) const
Definition: PixelHistoConverter.h:79
PixelHistoConverter::Axis
Definition: PixelHistoConverter.h:50
PixelHistoConverter::m_zAxis
Axis m_zAxis
Definition: PixelHistoConverter.h:59
PixelHistoConverter::findBin
std::size_t findBin(const Axis &axis, const float value) const
Definition: PixelHistoConverter.h:65
PixelHistoConverter::setAxis
static bool setAxis(Axis &axis, const TAxis *rootAxis)
Definition: PixelHistoConverter.cxx:105
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
PixelHistoConverter::PixelHistoConverter
PixelHistoConverter()
athena.value
value
Definition: athena.py:124
PixelHistoConverter::getContent
float getContent(std::size_t x, std::size_t y, std::size_t z) const
Definition: PixelHistoConverter.h:40
Args
Definition: test_lwtnn_fastgraph.cxx:12
x
#define x
PixelHistoConverter::m_content
std::vector< float > m_content
Definition: PixelHistoConverter.h:61
PixelHistoConverter::setHisto1D
StatusCode setHisto1D(const TH1 *histo)
Definition: PixelHistoConverter.cxx:20
PixelHistoConverter::getBinZ
std::size_t getBinZ(Args &&...args) const
Definition: PixelHistoConverter.h:84
PixelHistoConverter::getContent
float getContent(std::size_t x, std::size_t y) const
Definition: PixelHistoConverter.h:37
PixelHistoConverter
Definition: PixelHistoConverter.h:25
PixelHistoConverter::Axis::min
float min
Definition: PixelHistoConverter.h:52
z
#define z
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PixelHistoConverter::isFirstZ
bool isFirstZ(const float value) const
Definition: PixelHistoConverter.cxx:101
PixelHistoConverter::setHisto2D
StatusCode setHisto2D(const TH2 *histo)
Definition: PixelHistoConverter.cxx:41
PixelHistoConverter::isOverflowZ
bool isOverflowZ(const float value) const
Definition: PixelHistoConverter.h:44
y
#define y
AthMessaging.h
PixelHistoConverter::setHisto3D
StatusCode setHisto3D(const TH3 *histo)
Definition: PixelHistoConverter.cxx:68
PixelHistoConverter::Axis::nBins
std::size_t nBins
Definition: PixelHistoConverter.h:51
PixelHistoConverter::m_yAxis
Axis m_yAxis
Definition: PixelHistoConverter.h:58
PixelHistoConverter::~PixelHistoConverter
virtual ~PixelHistoConverter()=default
PixelHistoConverter::Axis::width
float width
Definition: PixelHistoConverter.h:54
PixelHistoConverter::getBinX
std::size_t getBinX(Args &&...args) const
Definition: PixelHistoConverter.h:74
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
PixelHistoConverter::Axis::max
float max
Definition: PixelHistoConverter.h:53
PixelHistoConverter::m_xAxis
Axis m_xAxis
Definition: PixelHistoConverter.h:57
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
PixelHistoConverter::getContent
float getContent(std::size_t x) const
Definition: PixelHistoConverter.h:34