ATLAS Offline Software
VariableBinwidthHistogram.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // VariableBinwidthHistogram.h
6 // Header file for class VariableBinwidthHistogram
8 // (c) ATLAS Detector software
10 //
12 
13 #ifndef VARIABLEBINWIDTHHISTOGRAM_H
14 #define VARIABLEBINWIDTHHISTOGRAM_H
15 
16 // c - c++
17 #include <algorithm>
18 #include <iostream>
19 #include <vector>
20 
21 // ROOT
22 //#include "TH1.h"
23 //#include "TGraph.h"
24 
25 class TH1F;
26 class TGraph;
27 
28 // this
30 
31 namespace MuonCalib {
32 
41  public:
42  //----------------------------constructors--------------------------------------
44  inline VariableBinwidthHistogram() : m_binc(0), m_max_bin_width(0), m_error(false), m_sorted(false) {}
45 
48  for (unsigned int i = 0; i < m_bins.size(); i++) { delete m_bins[i]; }
49  }
50 
51  //-----------------------------public member functinos--------------------------
52 
61  bool Initialize(TH1F *hist, double binc_r, double max_bin_width, double min_x = -9e9, double max_x = 9e9);
62 
66  bool Smooth(double width);
67 
71  inline const VariableBinwidthHistogramBin &GetBin(unsigned int bin) const { return *(m_bins[bin]); }
72 
76  inline const VariableBinwidthHistogramBin &GetSortedBin(unsigned int bin) {
77  if (!m_sorted) {
78  sort(m_sort_bins.begin(), m_sort_bins.end());
79  m_sorted = true;
80  }
81  return m_sort_bins[bin].Bin();
82  }
83 
85  inline unsigned int GetNumberOfBins() const { return m_bins.size(); }
86 
88  TGraph *DenistyGraph() const;
89 
91  TGraph *BinWidthGraph() const;
92 
94  TGraph *BinContentGraph() const;
95 
97  TGraph *DiffDensityGraph() const;
98 
100  TGraph *DiffBinwidthGraph() const;
101 
102  private:
103  //----------------------------private data members------------------------------
105  std::vector<VariableBinwidthHistogramBin *> m_bins;
106 
108  std::vector<VBHBinPtrSrt> m_sort_bins;
109 
111  unsigned int m_binc;
112 
115 
117  bool m_error;
118 
119  bool m_sorted;
120 
121  //--------------------------privite member functions----------------------------
122  inline double sign(double val) const {
123  if (val > 0.0) return 1.0;
124  if (val < 0.0) return -1.0;
125  if (val == 0.0) return 0;
126  return 0;
127  }
128  };
129 
130 } // namespace MuonCalib
131 
132 #endif
MuonCalib::VariableBinwidthHistogram
Definition: VariableBinwidthHistogram.h:40
MuonCalib::VariableBinwidthHistogram::GetBin
const VariableBinwidthHistogramBin & GetBin(unsigned int bin) const
Get a bin.
Definition: VariableBinwidthHistogram.h:71
MuonCalib::VariableBinwidthHistogram::m_sort_bins
std::vector< VBHBinPtrSrt > m_sort_bins
bins sorted by content
Definition: VariableBinwidthHistogram.h:108
MuonCalib::VariableBinwidthHistogram::GetSortedBin
const VariableBinwidthHistogramBin & GetSortedBin(unsigned int bin)
Get a bin sorted by content.
Definition: VariableBinwidthHistogram.h:76
plotmaker.hist
hist
Definition: plotmaker.py:148
MuonCalib::VariableBinwidthHistogram::DiffDensityGraph
TGraph * DiffDensityGraph() const
Plot graph with differential density.
Definition: VariableBinwidthHistogram.cxx:151
bin
Definition: BinsDiffFromStripMedian.h:43
MuonCalib::VariableBinwidthHistogram::DenistyGraph
TGraph * DenistyGraph() const
create density graph - density vs bin center
Definition: VariableBinwidthHistogram.cxx:113
MuonCalib::VariableBinwidthHistogram::GetNumberOfBins
unsigned int GetNumberOfBins() const
Get the number of bins
Definition: VariableBinwidthHistogram.h:85
MuonCalib::VariableBinwidthHistogram::~VariableBinwidthHistogram
~VariableBinwidthHistogram()
destructor
Definition: VariableBinwidthHistogram.h:47
VariableBinwidthHistogramBin.h
MuonCalib::VariableBinwidthHistogram::m_bins
std::vector< VariableBinwidthHistogramBin * > m_bins
vector containing histogram bins
Definition: VariableBinwidthHistogram.h:105
MuonCalib::VariableBinwidthHistogram::m_error
bool m_error
error flag
Definition: VariableBinwidthHistogram.h:117
MuonCalib::VariableBinwidthHistogram::DiffBinwidthGraph
TGraph * DiffBinwidthGraph() const
Plot graph with differential binwidth.
Definition: VariableBinwidthHistogram.cxx:166
MuonCalib::VariableBinwidthHistogram::m_max_bin_width
double m_max_bin_width
maximum bin width
Definition: VariableBinwidthHistogram.h:114
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonCalib::VariableBinwidthHistogram::BinContentGraph
TGraph * BinContentGraph() const
Plot bin content graph - bin content vs bin center.
Definition: VariableBinwidthHistogram.cxx:141
MuonCalib::VariableBinwidthHistogram::Smooth
bool Smooth(double width)
Removes steps that origin in a binning effekt.
Definition: VariableBinwidthHistogram.cxx:87
MuonCalib::VariableBinwidthHistogram::sign
double sign(double val) const
Definition: VariableBinwidthHistogram.h:122
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::VariableBinwidthHistogram::m_binc
unsigned int m_binc
number of entries per bin
Definition: VariableBinwidthHistogram.h:111
MuonCalib::VariableBinwidthHistogram::m_sorted
bool m_sorted
Definition: VariableBinwidthHistogram.h:119
MuonCalib::VariableBinwidthHistogram::Initialize
bool Initialize(TH1F *hist, double binc_r, double max_bin_width, double min_x=-9e9, double max_x=9e9)
Initialize with new input histogram Returns on error false.
Definition: VariableBinwidthHistogram.cxx:22
MuonCalib::VariableBinwidthHistogram::VariableBinwidthHistogram
VariableBinwidthHistogram()
Default constructor.
Definition: VariableBinwidthHistogram.h:44
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
MuonCalib::VariableBinwidthHistogramBin
Definition: VariableBinwidthHistogramBin.h:22
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
MuonCalib::VariableBinwidthHistogram::BinWidthGraph
TGraph * BinWidthGraph() const
Plot binwidth graph - binwidth versus bin center.
Definition: VariableBinwidthHistogram.cxx:127
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24