ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigEvent
TrigInDetEvent
src
TrigHisto1D.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigInDetEvent/TrigHisto1D.h
"
6
7
using namespace
TrigHistoCutType
;
8
9
//---------------------------------------------------------------
10
11
TrigHisto1D::TrigHisto1D
():
TrigHisto
() {
12
}
13
14
//---------------------------------------------------------------
15
16
TrigHisto1D::TrigHisto1D
(
unsigned
int
nbins_x
,
17
float
min_x
,
18
float
max_x
):
TrigHisto
() {
19
20
m_nbins_x
=
nbins_x
;
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
}
37
38
//---------------------------------------------------------------
39
40
TrigHisto1D::TrigHisto1D
(
unsigned
int
nbins_x
,
41
float
min_x
,
42
float
max_x
,
43
const
std::vector<float>&
contents
) {
44
m_nbins_x
=
nbins_x
;
45
m_min_x
=
min_x
;
46
m_max_x
=
max_x
;
47
48
m_contents
=
contents
;
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
}
56
57
//---------------------------------------------------------------
58
59
TrigHisto1D::~TrigHisto1D
() {
60
}
61
62
//---------------------------------------------------------------
63
64
TrigHisto1D::TrigHisto1D
(
const
TrigHisto1D
& trigHisto):
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
;
70
m_underflowBin_x
= trigHisto.
m_underflowBin_x
;
71
m_overflowBin_x
= trigHisto.
m_overflowBin_x
;
72
}
73
74
//---------------------------------------------------------------
75
76
TrigHisto1D::TrigHisto1D
(
TrigHisto1D
&& trigHisto):
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;
82
m_underflowBin_x
= trigHisto.m_underflowBin_x;
83
m_overflowBin_x
= trigHisto.m_overflowBin_x;
84
}
85
86
//---------------------------------------------------------------
87
88
TrigHisto1D
&
TrigHisto1D::operator=
(
const
TrigHisto1D
& trigHisto) {
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
;
95
m_underflowBin_x
= trigHisto.
m_underflowBin_x
;
96
m_overflowBin_x
= trigHisto.
m_overflowBin_x
;
97
}
98
return
*
this
;
99
}
100
101
//---------------------------------------------------------------
102
103
TrigHisto1D
&
TrigHisto1D::operator=
(
TrigHisto1D
&& trigHisto) {
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;
110
m_underflowBin_x
= trigHisto.m_underflowBin_x;
111
m_overflowBin_x
= trigHisto.m_overflowBin_x;
112
}
113
return
*
this
;
114
}
115
116
//---------------------------------------------------------------
117
118
void
TrigHisto1D::fill
(
float
value_x,
float
weight) {
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
}
123
124
//---------------------------------------------------------------
125
126
double
TrigHisto1D::sumEntries
(
float
value_x,
int
cutType)
const
{
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
}
154
155
//---------------------------------------------------------------
156
TrigHisto1D.h
TrigHisto1D::fill
void fill(float value_x, float weight)
Fill a 1D histogram.
Definition
TrigHisto1D.cxx:118
TrigHisto1D::operator=
TrigHisto1D & operator=(const TrigHisto1D &trigHisto)
Assignment operator.
Definition
TrigHisto1D.cxx:88
TrigHisto1D::~TrigHisto1D
virtual ~TrigHisto1D(void)
Destructor.
Definition
TrigHisto1D.cxx:59
TrigHisto1D::sumEntries
double sumEntries(float value_x, int cutType) const
Sum the number of entries within the cut range.
Definition
TrigHisto1D.cxx:126
TrigHisto1D::TrigHisto1D
TrigHisto1D(void)
Default constructor used by T/P converters.
Definition
TrigHisto1D.cxx:11
TrigHisto::max_x
float max_x() const
Return the maximum along the x-axis.
Definition
TrigHisto.h:55
TrigHisto::m_nbins_x
unsigned int m_nbins_x
Definition
TrigHisto.h:77
TrigHisto::m_underflowBin_x
unsigned int m_underflowBin_x
Definition
TrigHisto.h:78
TrigHisto::m_overflowBin_x
unsigned int m_overflowBin_x
Definition
TrigHisto.h:79
TrigHisto::m_binSize_x
float m_binSize_x
Definition
TrigHisto.h:82
TrigHisto::findBin
unsigned int findBin(unsigned int nbins, float h_min, float h_max, float binSize, float value) const
Definition
TrigHisto.cxx:21
TrigHisto::min_x
float min_x() const
Return the minimum along the x-axis.
Definition
TrigHisto.h:50
TrigHisto::m_min_x
float m_min_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:45
TrigHisto::contents
const std::vector< float > & contents() const
Return the bin contents of the histogram, including the under and overflow bins.
Definition
TrigHisto.h:61
TrigHisto::TrigHisto
TrigHisto()=default
TrigHisto::m_max_x
float m_max_x
Definition
TrigHisto.h:81
TrigHisto::m_contents
std::vector< float > m_contents
Definition
TrigHisto.h:74
entries
double entries
Definition
listroot.cxx:49
TrigHistoCutType
Definition
TrigHisto.h:12
TrigHistoCutType::BELOW_X
@ BELOW_X
Definition
TrigHisto.h:14
TrigHistoCutType::ABOVE_X
@ ABOVE_X
Definition
TrigHisto.h:15
Generated on
for ATLAS Offline Software by
1.17.0