ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::TrigHisto2D_v1 Class Reference

#include <TrigHisto2D_v1.h>

Inheritance diagram for xAOD::TrigHisto2D_v1:
Collaboration diagram for xAOD::TrigHisto2D_v1:

Public Member Functions

 TrigHisto2D_v1 ()
 ~TrigHisto2D_v1 ()
 Destructor.
 TrigHisto2D_v1 (unsigned int nbins_x, float min_x, float max_x, unsigned int nbins_y, float min_y, float max_y)
 Standard constructor used by FEX algorithms.
const std::vector< float > & contents () const
 Fill a 2D histogram.
unsigned int nbinsX () const
float minX () const
 Return the minimum along the x-axis.
float maxX () const
 Return the maximum along the x-axis.
unsigned int nbinsY () const
 Return the number of bins along the y-axis, not including the under and overflow.
float minY () const
 Return the minimum along the y-axis.
float maxY () const
 Return the maximum along the y-axis.
void initialize (unsigned int nbins_x, float min_x, float max_x, unsigned int nbins_y, float min_y, float max_y)
 creates empty histogram
void fill (float value_x, float value_y, float weight)
 fill histogram
std::vector< floatprofileX () const
 Sum the number of entries within the cut range.
std::vector< floatprofileY () const
 Collapse the x-axis and return a profile from the y-axis.
double sumEntries (float value_x, float value_y, int cutType) const
 Sum the number of entries within the cut range.
void clear ()
 clear m_contents vector
void dump ()
 dump() function, for testing
void setContents (const std::vector< float > &cont)
 contents setter
void setMinX (float val)
void setMaxX (float val)
void setNbinsX (unsigned int nx)
 NbinsX setter.
void setMinY (float val)
void setMaxY (float val)
void setNbinsY (unsigned int ny)
 NbinsY setter.

Private Member Functions

unsigned int findBinX (float val) const
 returns x bin index
unsigned int findBinY (float val) const
 returns y bin index

Private Attributes

float m_binWidthX = 0.0F
float m_binWidthY = 0.0F

Static Private Attributes

static const int EXTRA_BINS =2
 additional bins for underflow and overflow bins

Detailed Description

Definition at line 23 of file TrigHisto2D_v1.h.

Constructor & Destructor Documentation

◆ TrigHisto2D_v1() [1/2]

xAOD::TrigHisto2D_v1::TrigHisto2D_v1 ( )

Definition at line 16 of file TrigHisto2D_v1.cxx.

18 }
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.

◆ ~TrigHisto2D_v1()

xAOD::TrigHisto2D_v1::~TrigHisto2D_v1 ( )

Destructor.

Definition at line 25 of file TrigHisto2D_v1.cxx.

25{}

◆ TrigHisto2D_v1() [2/2]

xAOD::TrigHisto2D_v1::TrigHisto2D_v1 ( unsigned int nbins_x,
float min_x,
float max_x,
unsigned int nbins_y,
float min_y,
float max_y )

Standard constructor used by FEX algorithms.

Definition at line 20 of file TrigHisto2D_v1.cxx.

21 : SG::AuxElement() {
22 initialize(nbins_x, min_x, max_x, nbins_y, min_y, max_y);
23 }
void initialize()

Member Function Documentation

◆ clear()

void xAOD::TrigHisto2D_v1::clear ( )

clear m_contents vector

Definition at line 207 of file TrigHisto2D_v1.cxx.

207 {
208 static const Accessor< std::vector<float> > acc_contents( "contents" );
209
210 for(std::vector<float>::iterator contents_iter = acc_contents(*this).begin(); contents_iter !=acc_contents(*this).end(); ++contents_iter)
211 *contents_iter = 0;
212 }

◆ contents()

const std::vector< float > & xAOD::TrigHisto2D_v1::contents ( ) const

Fill a 2D histogram.

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

◆ dump()

void xAOD::TrigHisto2D_v1::dump ( )

dump() function, for testing

Definition at line 214 of file TrigHisto2D_v1.cxx.

214 {
215 static const Accessor< std::vector<float> > acc_contents( "contents" );
216
217 std::cout<<"Dump contets vector of size:: "<<acc_contents(*this).size()<<std::endl;
218 for( unsigned int i = 0 ; i < acc_contents(*this).size(); i++)
219 std::cout<<acc_contents(*this).at(i)<<" ";
220 std::cout<<std::endl;
221
222 std::cout<<"NbinX:: "<< nbinsX()<<"\tRangeX:: ["<<minX()<<","<<maxX()<<"]"<<std::endl;
223 std::cout<<"NbinY:: "<< nbinsY()<<"\tRangeY:: ["<<minY()<<","<<maxY()<<"]"<<std::endl;
224
225
226 for(unsigned int iy = 0 ; iy < nbinsY() + TrigHisto2D_v1::EXTRA_BINS; iy++){
227 std::cout<<std::endl;
228 for(unsigned int ix = 0; ix < nbinsX() + TrigHisto2D_v1::EXTRA_BINS; ix++){
229 std::cout<< acc_contents(*this).at(ix + iy*(nbinsX() + TrigHisto2D_v1::EXTRA_BINS))<<"\t";
230 }
231 }
232 std::cout<<std::endl;
233 }
float maxY() const
Return the maximum along the y-axis.
unsigned int nbinsY() const
Return the number of bins along the y-axis, not including the under and overflow.
float maxX() const
Return the maximum along the x-axis.
static const int EXTRA_BINS
additional bins for underflow and overflow bins
float minX() const
Return the minimum along the x-axis.
float minY() const
Return the minimum along the y-axis.
unsigned int nbinsX() const

◆ fill()

void xAOD::TrigHisto2D_v1::fill ( float value_x,
float value_y,
float weight = 1. )

fill histogram

Definition at line 73 of file TrigHisto2D_v1.cxx.

73 {
74
75 unsigned int ibin_x = findBinX(value_x);
76 unsigned int ibin_y = findBinY(value_y);
77
78 unsigned int ibin = ibin_y*(nbinsX()+TrigHisto2D_v1::EXTRA_BINS) + ibin_x;
79
80 static const Accessor< std::vector<float> > acc_contents( "contents" );
81
82 acc_contents(*this).at(ibin)+= weight;
83 }
unsigned int findBinY(float val) const
returns y bin index
unsigned int findBinX(float val) const
returns x bin index

◆ findBinX()

unsigned int xAOD::TrigHisto2D_v1::findBinX ( float val) const
private

returns x bin index

Definition at line 171 of file TrigHisto2D_v1.cxx.

171 {
172
173 unsigned int ibin = 0;
174
175 if(value < minX()) { // Underflow
176 ibin = 0;
177 }
178 else if( !(value < maxX()) ) { // Overflow (catches NaN)
179 ibin = nbinsX()+1;
180 }
181 else {
182 while(value > (ibin*m_binWidthX+minX()) && ibin <= nbinsX()) { // None under/overflow from 1 to nbins
183 ibin++;
184 }
185 }
186 return ibin;
187 }

◆ findBinY()

unsigned int xAOD::TrigHisto2D_v1::findBinY ( float val) const
private

returns y bin index

Definition at line 189 of file TrigHisto2D_v1.cxx.

189 {
190
191 unsigned int ibin = 0;
192
193 if(value < minY()) { // Underflow
194 ibin = 0;
195 }
196 else if( !(value < maxY()) ) { // Overflow (catches NaN)
197 ibin = nbinsY()+1;
198 }
199 else {
200 while(value > (ibin*m_binWidthY+minY()) && ibin <= nbinsY()) { // None under/overflow from 1 to nbins
201 ibin++;
202 }
203 }
204 return ibin;
205 }

◆ initialize()

void xAOD::TrigHisto2D_v1::initialize ( unsigned int nbins_x,
float min_x,
float max_x,
unsigned int nbins_y,
float min_y,
float max_y )

creates empty histogram

compute contents_size

create empty contents vector

compute binwdiths'

Definition at line 37 of file TrigHisto2D_v1.cxx.

37 {
38
39 //the aux store has to exist if we wont to write anything there
40 if(!this->hasStore())
41 this->makePrivateStore();
42
44 unsigned int contents_size = (nbins_x+TrigHisto2D_v1::EXTRA_BINS)*(nbins_y+TrigHisto2D_v1::EXTRA_BINS);
45#ifdef DBG
46 std::cout<<"Creating Thist2D with :"<<contents_size<< " elements"<<std::endl<<"nbins_x+2="<< nbins_x+TrigHisto2D_v1::EXTRA_BINS<<std::endl<<"nbins_y+2="<<nbins_y+TrigHisto2D_v1::EXTRA_BINS<<std::endl;
47#endif
49 setContents(std::vector<float>(contents_size,0.));
50 setMinX(min_x);
51 setMaxX(max_x);
52 setNbinsX(nbins_x);
53 setMinY(min_y);
54 setMaxY(max_y);
55 setNbinsY(nbins_y);
56
58 if(nbins_x != 0) {
59 m_binWidthX = (max_x - min_x)/((float)nbins_x); // Calculate bin size.
60 }
61 else {
62 m_binWidthX = 0.;
63 }
64
65 if(nbins_y != 0) {
66 m_binWidthY = (max_y - min_y)/((float)nbins_y); // Calculate bin size.
67 }
68 else {
69 m_binWidthY = 0.;
70 }
71 }
void setNbinsX(unsigned int nx)
NbinsX setter.
void setMaxY(float val)
void setContents(const std::vector< float > &cont)
contents setter
void setMinY(float val)
void setMaxX(float val)
void setMinX(float val)
void setNbinsY(unsigned int ny)
NbinsY setter.
void makePrivateStore()
Create a new (empty) private store for this object.
bool hasStore() const
Return true if this object has an associated store.

◆ maxX()

float xAOD::TrigHisto2D_v1::maxX ( ) const

Return the maximum along the x-axis.

◆ maxY()

float xAOD::TrigHisto2D_v1::maxY ( ) const

Return the maximum along the y-axis.

◆ minX()

float xAOD::TrigHisto2D_v1::minX ( ) const

Return the minimum along the x-axis.

◆ minY()

float xAOD::TrigHisto2D_v1::minY ( ) const

Return the minimum along the y-axis.

◆ nbinsX()

unsigned int xAOD::TrigHisto2D_v1::nbinsX ( ) const

◆ nbinsY()

unsigned int xAOD::TrigHisto2D_v1::nbinsY ( ) const

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

◆ profileX()

std::vector< float > xAOD::TrigHisto2D_v1::profileX ( ) const

Sum the number of entries within the cut range.

Collapse the y-axis and return a profile from the x-axis

Definition at line 85 of file TrigHisto2D_v1.cxx.

85 {
86 std::vector<float> contentsX(nbinsX()+TrigHisto2D_v1::EXTRA_BINS,0.);
87
88 static const Accessor< std::vector<float> > acc_contents( "contents" );
89
90 for(unsigned int ix = 0 ; ix < nbinsX() + TrigHisto2D_v1::EXTRA_BINS; ix++){
91 for(unsigned int iy = 0; iy < nbinsY() + TrigHisto2D_v1::EXTRA_BINS; iy++){
92 contentsX.at(ix) += acc_contents(*this).at(ix + iy*(nbinsX() + TrigHisto2D_v1::EXTRA_BINS));
93 }
94 }
95 return contentsX;
96 }

◆ profileY()

std::vector< float > xAOD::TrigHisto2D_v1::profileY ( ) const

Collapse the x-axis and return a profile from the y-axis.

Definition at line 98 of file TrigHisto2D_v1.cxx.

98 {
99 std::vector<float> contentsY(nbinsY()+TrigHisto2D_v1::EXTRA_BINS);
100
101 static const Accessor< std::vector<float> > acc_contents( "contents" );
102
103 for(unsigned int iy = 0 ; iy < nbinsY() + TrigHisto2D_v1::EXTRA_BINS; iy++){
104 for(unsigned int ix = 0; ix < nbinsX() + TrigHisto2D_v1::EXTRA_BINS; ix++){
105 contentsY.at(iy) += acc_contents(*this).at(ix + iy*(nbinsX() + TrigHisto2D_v1::EXTRA_BINS));
106 }
107 }
108 return contentsY;
109 }

◆ setContents()

void xAOD::TrigHisto2D_v1::setContents ( const std::vector< float > & cont)

contents setter

◆ setMaxX()

void xAOD::TrigHisto2D_v1::setMaxX ( float val)

◆ setMaxY()

void xAOD::TrigHisto2D_v1::setMaxY ( float val)

◆ setMinX()

void xAOD::TrigHisto2D_v1::setMinX ( float val)

◆ setMinY()

void xAOD::TrigHisto2D_v1::setMinY ( float val)

◆ setNbinsX()

void xAOD::TrigHisto2D_v1::setNbinsX ( unsigned int nx)

NbinsX setter.

◆ setNbinsY()

void xAOD::TrigHisto2D_v1::setNbinsY ( unsigned int ny)

NbinsY setter.

◆ sumEntries()

double xAOD::TrigHisto2D_v1::sumEntries ( float value_x,
float value_y,
int cutType ) const

Sum the number of entries within the cut range.

Definition at line 111 of file TrigHisto2D_v1.cxx.

111 {
112
113 unsigned int ibin, ibin_x, ibin_y, ibin_x_selected, ibin_y_selected;
114 double entries;
115
116 static const Accessor< std::vector<float> > acc_contents( "contents" );
117
118 // Find the x bin index that the cut corresponds to.
119 ibin_x_selected = findBinX(value_x);
120
121 // Find the y bin index that the cut corresponds to.
122 ibin_y_selected = findBinY(value_y);
123 entries = 0.;
124
125
126 if( nbinsX()==0 || nbinsY()==0 ){
127 return 0;
128 }
129 else{
130
131 if(cutType == TrigHistoCutType::BELOW_X_BELOW_Y) {
132 for(ibin_x = 0; ibin_x <= ibin_x_selected; ibin_x++) {
133 for(ibin_y = 0; ibin_y <= ibin_y_selected; ibin_y++) {
134 ibin = ibin_y*(nbinsX()+2) + ibin_x; // Find position in 1d data array
135 entries += acc_contents(*this).at(ibin);
136 }
137 }
138 }
139 else if(cutType == TrigHistoCutType::ABOVE_X_BELOW_Y) {
140 for(ibin_x = ibin_x_selected; ibin_x < nbinsX()+ TrigHisto2D_v1::EXTRA_BINS; ibin_x++) {
141 for(ibin_y = 0; ibin_y <= ibin_y_selected; ibin_y++) {
142 ibin = ibin_y*(nbinsX()+ TrigHisto2D_v1::EXTRA_BINS) + ibin_x; // Find position in 1d data array
143 entries += acc_contents(*this).at(ibin);
144 }
145 }
146 }
147 else if(cutType == TrigHistoCutType::BELOW_X_ABOVE_Y) {
148 for(ibin_x = 0; ibin_x <= ibin_x_selected; ibin_x++) {
149 for(ibin_y = ibin_y_selected; ibin_y < nbinsY()+ TrigHisto2D_v1::EXTRA_BINS; ibin_y++) {
150 ibin = ibin_y*(nbinsX()+ TrigHisto2D_v1::EXTRA_BINS) + ibin_x; // Find position in 1d data array
151 entries += acc_contents(*this).at(ibin);
152 }
153 }
154 }
155 else if(cutType == TrigHistoCutType::ABOVE_X_ABOVE_Y) {
156 for(ibin_x = ibin_x_selected; ibin_x < nbinsX()+ TrigHisto2D_v1::EXTRA_BINS; ibin_x++) {
157 for(ibin_y = ibin_y_selected; ibin_y < nbinsY()+ TrigHisto2D_v1::EXTRA_BINS; ibin_y++) {
158 ibin = ibin_y*(nbinsX()+ TrigHisto2D_v1::EXTRA_BINS) + ibin_x; // Find position in 1d data array
159 entries += acc_contents(*this).at(ibin);
160 }
161 }
162 }
163 else {
164 return 0;
165 }
166 }// else of m_nbins!=0
167
168 return entries;
169 }
double entries
Definition listroot.cxx:49

Member Data Documentation

◆ EXTRA_BINS

const int xAOD::TrigHisto2D_v1::EXTRA_BINS =2
staticprivate

additional bins for underflow and overflow bins

Definition at line 108 of file TrigHisto2D_v1.h.

◆ m_binWidthX

float xAOD::TrigHisto2D_v1::m_binWidthX = 0.0F
private

Definition at line 111 of file TrigHisto2D_v1.h.

◆ m_binWidthY

float xAOD::TrigHisto2D_v1::m_binWidthY = 0.0F
private

Definition at line 114 of file TrigHisto2D_v1.h.


The documentation for this class was generated from the following files: