Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
Utilities
BinningTools
src
ClusterizingHistogram.cc
Go to the documentation of this file.
1
#include "
Utilities/BinningTools/interface/ClusterizingHistogram.h
"
2
#include <iostream>
3
4
using namespace
std;
5
6
ClusterizingHistogram::ClusterizingHistogram
(
int
nb,
float
xmi,
float
xma)
7
: my_nbins(nb),
xmin
(xmi),
xmax
(xma), my_entries(0), my_underflows(0), my_overflows(0) {
8
bin_entries
=
new
int
[
my_nbins
];
9
bin_means
=
new
float
[
my_nbins
];
10
binsiz
= (
xmax
-
xmin
) /
my_nbins
;
11
for
(
int
i
= 0;
i
<
my_nbins
;
i
++) {
12
bin_entries
[
i
] = 0;
13
bin_means
[
i
] = 0.;
14
}
15
}
16
ClusterizingHistogram::~ClusterizingHistogram
() {
17
delete
[]
bin_entries
;
18
delete
[]
bin_means
;
19
}
20
21
int
ClusterizingHistogram::bin
(
float
x
)
const
{
22
if
(x <
xmin
)
23
return
-1;
24
else
if
(x >
xmax
)
25
return
my_nbins
;
26
else
27
return
int((x -
xmin
) /
binsiz
);
28
}
29
int
ClusterizingHistogram::bin
(
double
x
)
const
{
30
if
(x <
xmin
)
31
return
-1;
32
else
if
(x >
xmax
)
33
return
my_nbins
;
34
else
35
return
int((x -
xmin
) /
binsiz
);
36
}
37
38
void
ClusterizingHistogram::fill
(
float
x
) {
39
if
(x <
xmin
)
40
my_underflows
++;
41
else
if
(x >
xmax
)
42
my_overflows
++;
43
else
{
44
int
bin
= int((x -
xmin
) /
binsiz
);
45
if
(bin >
my_nbins
- 1)
46
bin =
my_nbins
- 1;
47
++
bin_entries
[
bin
];
48
bin_means
[
bin
] +=
x
;
49
my_entries
++;
50
// may be problematic for negative x; check!
51
}
52
}
53
54
vector<float>
ClusterizingHistogram::clusterize
(
float
resol
) {
55
vector<float> clust;
56
int
nclust
= 0;
57
bool
inclust =
false
;
58
float
last_pos =
xmin
- 1000. *
resol
;
59
int
sum = 0;
60
float
sumx = 0;
61
for
(
int
i
= 0;
i
<
my_nbins
;
i
++) {
62
if
(
bin_entries
[
i
] != 0) {
63
if
(fabs(
bin_pos
(
i
) - last_pos) > resol) {
64
inclust =
false
;
65
if
(nclust != 0)
66
clust.push_back(sumx / sum);
// create cluster
67
}
68
if
(!inclust) {
69
nclust++;
70
sumx = 0.;
71
sum = 0;
72
}
73
sum +=
bin_entries
[
i
];
74
sumx +=
bin_means
[
i
];
75
last_pos =
bin_pos
(
i
);
76
inclust =
true
;
77
}
78
}
79
if
(nclust != 0)
80
clust.push_back(sumx / sum);
// create last cluster
81
return
clust;
82
}
83
84
void
ClusterizingHistogram::dump
()
const
{
dump
(0,
my_nbins
); }
85
86
void
ClusterizingHistogram::dump
(
int
i1,
int
i2)
const
{
87
cout
<<
"Dumping ClusterizingHistogram contents:"
<< endl;
88
for
(
int
i
=
max
(i1, 0);
i
<
min
(i2,
my_nbins
);
i
++) {
89
cout
<<
i
<<
" "
<<
bin_entries
[
i
] <<
" "
<<
bin_pos
(
i
) << endl;
90
}
91
cout
<<
"Underflows: "
<<
my_underflows
<< endl;
92
cout
<<
"Overflows: "
<<
my_overflows
<< endl;
93
cout
<<
"Total number of entries: "
<<
my_entries
<< endl;
94
}
95
96
void
ClusterizingHistogram::dump
(
float
x1,
float
x2)
const
{
dump
(
bin
(x1),
bin
(x2)); }
97
void
ClusterizingHistogram::dump
(
double
x1,
double
x2)
const
{
dump
(
bin
(x1),
bin
(x2)); }
98
void
ClusterizingHistogram::dump
(
float
x1,
double
x2)
const
{
dump
(
bin
(x1),
bin
(x2)); }
99
void
ClusterizingHistogram::dump
(
double
x1,
float
x2)
const
{
dump
(
bin
(x1),
bin
(x2)); }
100
101
void
ClusterizingHistogram::reset
() {
102
my_entries
= 0;
103
my_underflows
= 0;
104
my_overflows
= 0;
105
for
(
int
i
= 0;
i
<
my_nbins
;
i
++) {
106
bin_entries
[
i
] = 0;
107
bin_means
[
i
] = 0.;
108
}
109
}
ClusterizingHistogram::my_nbins
int my_nbins
Definition:
ClusterizingHistogram.h:40
mps_fire.i
i
Definition:
mps_fire.py:428
ClusterizingHistogram.h
ClusterizingHistogram::dump
void dump() const
Definition:
ClusterizingHistogram.cc:84
ClusterizingHistogram::~ClusterizingHistogram
~ClusterizingHistogram()
Definition:
ClusterizingHistogram.cc:16
ClusterizingHistogram::bin_entries
int * bin_entries
Definition:
ClusterizingHistogram.h:46
ClusterizingHistogram::my_overflows
int my_overflows
Definition:
ClusterizingHistogram.h:45
ClusterizingHistogram::clusterize
std::vector< float > clusterize(float resolution)
Definition:
ClusterizingHistogram.cc:54
ClusterizingHistogram::bin
int bin(float x) const
Definition:
ClusterizingHistogram.cc:21
SiStripPI::min
Definition:
SiStripPayloadInspectorHelper.h:169
gpuClustering::x
uint16_t const *__restrict__ x
Definition:
gpuClustering.h:43
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:169
ClusterizingHistogram::fill
void fill(float x)
Definition:
ClusterizingHistogram.cc:38
ClusterizingHistogram::bin_pos
float bin_pos(int i) const
Definition:
ClusterizingHistogram.h:25
hlt_dqm_clientPB-live_cfg.xmax
tuple xmax
Definition:
hlt_dqm_clientPB-live_cfg.py:52
l1ParticleFlow_cff.resol
tuple resol
Definition:
l1ParticleFlow_cff.py:25
ClusterizingHistogram::my_entries
int my_entries
Definition:
ClusterizingHistogram.h:43
ClusterizingHistogram::xmax
float xmax
Definition:
ClusterizingHistogram.h:42
DeadROCCounter.nclust
tuple nclust
Definition:
DeadROCCounter.py:66
ClusterizingHistogram::my_underflows
int my_underflows
Definition:
ClusterizingHistogram.h:44
ClusterizingHistogram::ClusterizingHistogram
ClusterizingHistogram()
Definition:
ClusterizingHistogram.h:39
gather_cfg.cout
tuple cout
Definition:
gather_cfg.py:144
ClusterizingHistogram::xmin
float xmin
Definition:
ClusterizingHistogram.h:41
ClusterizingHistogram::binsiz
float binsiz
Definition:
ClusterizingHistogram.h:48
DDAxes::x
ClusterizingHistogram::bin_means
float * bin_means
Definition:
ClusterizingHistogram.h:47
hlt_dqm_clientPB-live_cfg.xmin
tuple xmin
Definition:
hlt_dqm_clientPB-live_cfg.py:51
ClusterizingHistogram::reset
void reset()
Definition:
ClusterizingHistogram.cc:101
Generated for CMSSW Reference Manual by
1.8.5