ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TrigHisto1D Class Reference

A very basic one dimensional histogram to provide storage of HLT distributions, allowing constraints but preventing excessive memory usage for busy events. The histogram data is compressed during persistification according to the type of template instantiated. More...

#include <TrigHisto1D.h>

Inheritance diagram for TrigHisto1D:
Collaboration diagram for TrigHisto1D:

Public Member Functions

 TrigHisto1D (void)
 Default constructor used by T/P converters. More...
 
 TrigHisto1D (unsigned int nbins_x, float min_x, float max_x)
 Standard constructor used by FEX algorithms. More...
 
 TrigHisto1D (unsigned int nbins_x, float min_x, float max_x, const std::vector< float > &contents)
 Constructor used by TrigHisto2D. More...
 
virtual ~TrigHisto1D (void)
 Destructor. More...
 
 TrigHisto1D (const TrigHisto1D &trigHisto)
 Copy Constructor. More...
 
 TrigHisto1D (TrigHisto1D &&trigHisto)
 
TrigHisto1Doperator= (const TrigHisto1D &trigHisto)
 Assignment operator. More...
 
TrigHisto1Doperator= (TrigHisto1D &&trigHisto)
 
void fill (float value_x, float weight)
 Fill a 1D histogram. More...
 
double sumEntries (float value_x, int cutType) const
 Sum the number of entries within the cut range. More...
 
void clear (void)
 Zero all histogram bins. More...
 
unsigned int nbins_x (void) const
 Return the number of bins along the y-axis, not including the under and overflow. More...
 
float min_x (void) const
 Return the minimum along the x-axis. More...
 
float max_x (void) const
 Return the maximum along the x-axis. More...
 
const std::vector< float > & contents (void) const
 Return the bin contents of the histogram, including the under and overflow bins. More...
 

Protected Member Functions

unsigned int findBin (unsigned int nbins, float h_min, float h_max, float binSize, float value) const
 

Protected Attributes

std::vector< float > m_contents
 
std::vector< float >::iterator m_itr
 
std::vector< float >::iterator m_itr_end
 
unsigned int m_nbins_x
 
unsigned int m_underflowBin_x
 
unsigned int m_overflowBin_x
 
float m_min_x
 
float m_max_x
 
float m_binSize_x
 

Detailed Description

A very basic one dimensional histogram to provide storage of HLT distributions, allowing constraints but preventing excessive memory usage for busy events. The histogram data is compressed during persistification according to the type of template instantiated.

Author
W. H. Bell W.Bel.nosp@m.l@ce.nosp@m.rn.ch

Definition at line 23 of file TrigHisto1D.h.

Constructor & Destructor Documentation

◆ TrigHisto1D() [1/5]

TrigHisto1D::TrigHisto1D ( void  )

Default constructor used by T/P converters.

Definition at line 11 of file TrigHisto1D.cxx.

11  : TrigHisto() {
12 }

◆ TrigHisto1D() [2/5]

TrigHisto1D::TrigHisto1D ( unsigned int  nbins_x,
float  min_x,
float  max_x 
)

Standard constructor used by FEX algorithms.

Definition at line 16 of file TrigHisto1D.cxx.

18  : TrigHisto() {
19 
21  m_min_x = min_x;
22  m_max_x = max_x;
23 
24  m_contents.clear();
25  m_contents.resize(m_nbins_x+2, 0); // Two additional bins for under and overflow.
26 
27  if(m_nbins_x != 0) {
28  m_binSize_x = (m_max_x - m_min_x)/((float)m_nbins_x); // Calculate bin size.
29  }
30  else {
31  m_binSize_x = 0.;
32  }
33 
34  m_underflowBin_x = 0; // Cache this to make the code more readable.
35  m_overflowBin_x = m_nbins_x+1; // Cache this to make the code more readable and faster.
36 }

◆ TrigHisto1D() [3/5]

TrigHisto1D::TrigHisto1D ( unsigned int  nbins_x,
float  min_x,
float  max_x,
const std::vector< float > &  contents 
)

Constructor used by TrigHisto2D.

Definition at line 40 of file TrigHisto1D.cxx.

43  {
45  m_min_x = min_x;
46  m_max_x = max_x;
47 
49  m_contents.resize(m_nbins_x+2, 0); // Resize if it not the correct size.
50 
51  m_binSize_x = (m_max_x - m_min_x)/((float)m_nbins_x); // Calculate bin size.
52 
53  m_underflowBin_x = 0; // Cache this to make the code more readable.
54  m_overflowBin_x = m_nbins_x+1; // Cache this to make the code more readable and faster.
55 }

◆ ~TrigHisto1D()

TrigHisto1D::~TrigHisto1D ( void  )
virtual

Destructor.

Definition at line 59 of file TrigHisto1D.cxx.

59  {
60 }

◆ TrigHisto1D() [4/5]

TrigHisto1D::TrigHisto1D ( const TrigHisto1D trigHisto)

Copy Constructor.

Definition at line 64 of file TrigHisto1D.cxx.

64  : TrigHisto() {
65  m_nbins_x = trigHisto.m_nbins_x;
66  m_min_x = trigHisto.m_min_x;
67  m_max_x = trigHisto.m_max_x;
68  m_contents = trigHisto.m_contents;
69  m_binSize_x = trigHisto.m_binSize_x;
71  m_overflowBin_x = trigHisto.m_overflowBin_x;
72 }

◆ TrigHisto1D() [5/5]

TrigHisto1D::TrigHisto1D ( TrigHisto1D &&  trigHisto)

Definition at line 76 of file TrigHisto1D.cxx.

76  : TrigHisto() {
77  m_nbins_x = trigHisto.m_nbins_x;
78  m_min_x = trigHisto.m_min_x;
79  m_max_x = trigHisto.m_max_x;
80  m_contents = std::move(trigHisto.m_contents);
81  m_binSize_x = trigHisto.m_binSize_x;
83  m_overflowBin_x = trigHisto.m_overflowBin_x;
84 }

Member Function Documentation

◆ clear()

void TrigHisto::clear ( void  )
inherited

Zero all histogram bins.

Definition at line 24 of file TrigHisto.cxx.

24  {
25  m_itr = m_contents.begin();
26  m_itr_end = m_contents.end();
27  for(; m_itr != m_itr_end; ++m_itr) (*m_itr) = 0.;
28 }

◆ contents()

const std::vector<float>& TrigHisto::contents ( void  ) const
inlineinherited

Return the bin contents of the histogram, including the under and overflow bins.

Definition at line 58 of file TrigHisto.h.

58  {
59  return m_contents;
60  }

◆ fill()

void TrigHisto1D::fill ( float  value_x,
float  weight 
)

Fill a 1D histogram.

Definition at line 118 of file TrigHisto1D.cxx.

118  {
119  const unsigned int ibin = findBin(m_nbins_x, m_min_x, m_max_x, m_binSize_x, value_x);
120 
121  m_contents[ibin] += weight; // Append the weight to this bin.
122 }

◆ findBin()

unsigned int TrigHisto::findBin ( unsigned int  nbins,
float  h_min,
float  h_max,
float  binSize,
float  value 
) const
protectedinherited
Returns
which bin this value corresponds to. (Supply bin limits such that it might be used for 1D or 2D derived class.)

Definition at line 33 of file TrigHisto.cxx.

37  {
38  unsigned int ibin = 0;
39 
40  if(value < h_min) { // Underflow
41  ibin = 0;
42  }
43  else if( !(value < h_max)) { // Overflow (catches NaN)
44  ibin = nbins+1;
45  }
46  else {
47  while(value > (ibin*binSize+h_min) && ibin <= nbins) { // None under/overflow from 1 to nbins
48  ibin++;
49  }
50  }
51 
52  return ibin;
53 }

◆ max_x()

float TrigHisto::max_x ( void  ) const
inlineinherited

Return the maximum along the x-axis.

Definition at line 52 of file TrigHisto.h.

52  {
53  return m_max_x;
54  }

◆ min_x()

float TrigHisto::min_x ( void  ) const
inlineinherited

Return the minimum along the x-axis.

Definition at line 47 of file TrigHisto.h.

47  {
48  return m_min_x;
49  }

◆ nbins_x()

unsigned int TrigHisto::nbins_x ( void  ) const
inlineinherited

Return the number of bins along the y-axis, not including the under and overflow.

Definition at line 42 of file TrigHisto.h.

42  {
43  return m_nbins_x;
44  }

◆ operator=() [1/2]

TrigHisto1D & TrigHisto1D::operator= ( const TrigHisto1D trigHisto)

Assignment operator.

Definition at line 88 of file TrigHisto1D.cxx.

88  {
89  if (this != &trigHisto) {
90  m_nbins_x = trigHisto.m_nbins_x;
91  m_min_x = trigHisto.m_min_x;
92  m_max_x = trigHisto.m_max_x;
93  m_contents = trigHisto.m_contents;
94  m_binSize_x = trigHisto.m_binSize_x;
96  m_overflowBin_x = trigHisto.m_overflowBin_x;
97  }
98  return *this;
99 }

◆ operator=() [2/2]

TrigHisto1D & TrigHisto1D::operator= ( TrigHisto1D &&  trigHisto)

Definition at line 103 of file TrigHisto1D.cxx.

103  {
104  if (this != &trigHisto) {
105  m_nbins_x = trigHisto.m_nbins_x;
106  m_min_x = trigHisto.m_min_x;
107  m_max_x = trigHisto.m_max_x;
108  m_contents = std::move(trigHisto.m_contents);
109  m_binSize_x = trigHisto.m_binSize_x;
111  m_overflowBin_x = trigHisto.m_overflowBin_x;
112  }
113  return *this;
114 }

◆ sumEntries()

double TrigHisto1D::sumEntries ( float  value_x,
int  cutType 
) const

Sum the number of entries within the cut range.

Definition at line 126 of file TrigHisto1D.cxx.

126  {
127  // Find which bin contains the value_x.
128  const unsigned int ibin_x_selected = findBin(m_nbins_x, m_min_x, m_max_x, m_binSize_x, value_x);
129 
130  double entries = 0.;
131 
132  if( m_nbins_x==0 ){
133  return 0;
134  }
135  else{
136 
137  if (cutType == BELOW_X) {
138  for(unsigned int ibin_x = m_underflowBin_x; ibin_x <= ibin_x_selected; ibin_x++) {
139  entries += m_contents[ibin_x];
140  }
141  }
142  else if(cutType == ABOVE_X) {
143  for(unsigned int ibin_x = ibin_x_selected; ibin_x <= m_overflowBin_x; ibin_x++) {
144  entries += m_contents[ibin_x];
145  }
146  }
147  else {
148  return 0; //<! Should report error message.
149  }
150  }
151 
152  return entries;
153 }

Member Data Documentation

◆ m_binSize_x

float TrigHisto::m_binSize_x
protectedinherited

Definition at line 81 of file TrigHisto.h.

◆ m_contents

std::vector<float> TrigHisto::m_contents
protectedinherited

Definition at line 71 of file TrigHisto.h.

◆ m_itr

std::vector<float>::iterator TrigHisto::m_itr
protectedinherited

Definition at line 72 of file TrigHisto.h.

◆ m_itr_end

std::vector<float>::iterator TrigHisto::m_itr_end
protectedinherited

Definition at line 73 of file TrigHisto.h.

◆ m_max_x

float TrigHisto::m_max_x
protectedinherited

Definition at line 80 of file TrigHisto.h.

◆ m_min_x

float TrigHisto::m_min_x
protectedinherited

Definition at line 79 of file TrigHisto.h.

◆ m_nbins_x

unsigned int TrigHisto::m_nbins_x
protectedinherited

Definition at line 76 of file TrigHisto.h.

◆ m_overflowBin_x

unsigned int TrigHisto::m_overflowBin_x
protectedinherited

Definition at line 78 of file TrigHisto.h.

◆ m_underflowBin_x

unsigned int TrigHisto::m_underflowBin_x
protectedinherited

Definition at line 77 of file TrigHisto.h.


The documentation for this class was generated from the following files:
TrigHisto::m_overflowBin_x
unsigned int m_overflowBin_x
Definition: TrigHisto.h:78
TrigHisto::min_x
float min_x(void) const
Return the minimum along the x-axis.
Definition: TrigHisto.h:47
TrigHisto::m_nbins_x
unsigned int m_nbins_x
Definition: TrigHisto.h:76
athena.value
value
Definition: athena.py:124
xAOD::TrigHistoCutType::ABOVE_X
@ ABOVE_X
Definition: TrigHisto2D_v1.h:15
TrigHisto::m_itr_end
std::vector< float >::iterator m_itr_end
Definition: TrigHisto.h:73
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
TrigHisto::TrigHisto
TrigHisto(void)
Definition: TrigHisto.cxx:9
TrigHisto::max_x
float max_x(void) const
Return the maximum along the x-axis.
Definition: TrigHisto.h:52
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
TrigHisto::m_contents
std::vector< float > m_contents
Definition: TrigHisto.h:71
TrigHisto::m_itr
std::vector< float >::iterator m_itr
Definition: TrigHisto.h:72
TrigHisto::m_min_x
float m_min_x
Definition: TrigHisto.h:79
TrigHisto::contents
const std::vector< float > & contents(void) const
Return the bin contents of the histogram, including the under and overflow bins.
Definition: TrigHisto.h:58
TrigHisto::findBin
unsigned int findBin(unsigned int nbins, float h_min, float h_max, float binSize, float value) const
Definition: TrigHisto.cxx:33
xAOD::TrigHistoCutType::BELOW_X
@ BELOW_X
Definition: TrigHisto2D_v1.h:14
entries
double entries
Definition: listroot.cxx:49
TrigHisto::m_binSize_x
float m_binSize_x
Definition: TrigHisto.h:81
TrigHisto::m_underflowBin_x
unsigned int m_underflowBin_x
Definition: TrigHisto.h:77
TrigHisto::m_max_x
float m_max_x
Definition: TrigHisto.h:80
TrigHisto::nbins_x
unsigned int nbins_x(void) const
Return the number of bins along the y-axis, not including the under and overflow.
Definition: TrigHisto.h:42