ATLAS Offline Software
Loading...
Searching...
No Matches
VariableBinwidthHistogramBin.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef VARIABLEBINWIDTHHISTOGRAMBIN_H
6#define VARIABLEBINWIDTHHISTOGRAMBIN_H
7
8#include <TString.h> // for Form
9
10#include <cstdlib>
11#include <iostream>
12#include <vector>
13
14namespace MuonCalib {
15
23 public:
24 //----------------------------------constructor---------------------------------
25
28
35 inline VariableBinwidthHistogramBin(double center, double width, unsigned int content) :
36 m_center(center), m_width(width), m_content(content) {}
37
38 //-----------------------------------public member functions--------------------
39
46 inline void Set(double center, double width, unsigned int content) {
47 m_center = center;
48 m_width = width;
49 m_content = content;
50 }
51
56 inline void SetContent(unsigned int n) { m_content = n; }
57
63 m_content += n;
64 return *this;
65 }
66
70 inline VariableBinwidthHistogramBin operator+(unsigned int n) {
72 ret += n;
73 return ret;
74 }
75
80 void MoveRight(double new_right) {
81 double left = Left();
82 if (new_right < left) {
83 throw std::runtime_error(
84 Form("File: %s, Line: %d\nVariableBinwidthHistogramBin::MoveRight() - new right is too small!", __FILE__, __LINE__));
85 }
86 m_width = new_right - left;
87 m_center = 0.5 * (left + new_right);
88 }
89
94 void MoveLeft(double new_left) {
95 double right = Right();
96 if (new_left > right) {
97 throw std::runtime_error(
98 Form("File: %s, Line: %d\nVariableBinwidthHistogramBin::MoveRight() - new left is too small!", __FILE__, __LINE__));
99 }
100 m_width = right - new_left;
101 m_center = 0.5 * (new_left + right);
102 }
103
105 inline double Center() const { return m_center; }
106
108 inline double Width() const { return m_width; }
109
111 inline double Left() const { return m_center - 0.5 * m_width; }
112
114 inline double Right() const { return m_center + 0.5 * m_width; }
115
117 inline unsigned int Entries() const { return m_content; }
118
120 inline double Density() const { return static_cast<double>(m_content) / m_width; }
121
122 private:
123 //-----------------------------------------private data members-----------------
124
126 unsigned int m_content;
127 };
128
136 public:
137 //-----------------------------------constructor--------------------------------
139 inline VBHBinPtrSrt() {}
140
146
147 //--------------------------------------public member functions-----------------
148
154
159
164 inline bool operator>(const VBHBinPtrSrt &other) const { return m_bin->Width() > other.m_bin->Width(); }
165
170 inline bool operator<(const VBHBinPtrSrt &other) const { return m_bin->Width() < other.m_bin->Width(); }
171
172 private:
173 //------------------------------private data members----------------------------
174
177 };
178
179} // namespace MuonCalib
180
181#endif
const double width
bool operator<(const VBHBinPtrSrt &other) const
Operator < for sorting bins by content.
bool operator>(const VBHBinPtrSrt &other) const
Operator > for sorting bins by content.
VBHBinPtrSrt(VariableBinwidthHistogramBin *bin)
initializing constructor
void Initialize(VariableBinwidthHistogramBin *bin)
initialize
VariableBinwidthHistogramBin & Bin()
Get reference to bin.
VariableBinwidthHistogramBin * m_bin
pointer to bin
A bin of a VariableBinwidthHistogram.
void MoveLeft(double new_left)
move left bin boarder
unsigned int Entries() const
Get number of entries in the bin.
VariableBinwidthHistogramBin(double center, double width, unsigned int content)
Initializing constructor.
double Left() const
Get left (lower) bin border.
double Density() const
Get density=Entries()/Width()
VariableBinwidthHistogramBin operator+(unsigned int n)
add to bin content
VariableBinwidthHistogramBin operator+=(unsigned int n)
add to bin content
double Right() const
Get right (upper) bin border.
void MoveRight(double new_right)
move right bin boarder
void Set(double center, double width, unsigned int content)
Set bin.
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.