Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
KFPHistogram1D.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file KFPHistogram1D.h
1
/*
2
* This file is part of KFParticle package
3
* Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
4
* 2007-2019 Goethe University of Frankfurt
5
* 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
6
* 2007-2019 Maksym Zyzak
7
*
8
* KFParticle is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* KFParticle is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*/
21
22
#ifndef KFPHISTOGRAM1D
23
#define KFPHISTOGRAM1D
24
25
#include <vector>
26
#include <string>
27
#include <cmath>
28
#include <iostream>
29
#include <cstdlib>
30
44
class
KFPHistogram1D
45
{
46
public
:
47
48
KFPHistogram1D
():
fHistogram
(0),
fSize
(0),
fName
(
""
),
fMinBin
(0),
fMaxBin
(0) {}
49
KFPHistogram1D
(
std::string
name
,
int
nBins,
float
minX,
float
maxX):
50
fHistogram
(0),
fSize
(nBins+2),
fName
(name),
fMinBin
(minX),
fMaxBin
(maxX) {}
51
~KFPHistogram1D
() {}
52
53
int
*
GetHistogram
()
const
{
return
fHistogram
; }
54
std::string
Name
()
const
{
return
fName
; }
55
float
MinBin
()
const
{
return
fMinBin
; }
56
float
MaxBin
()
const
{
return
fMaxBin
; }
57
int
NBins
()
const
{
return
(
fSize
-2); }
58
int
DataSize
()
const
{
return
fSize
; }
59
int
Size
()
const
{
return
fSize
; }
60
61
inline
void
SetBinContent
(
int
iBin,
int
value
) {
fHistogram
[iBin] =
value
; }
62
inline
void
SetHistogramMemory
(
int
* pointer) {
fHistogram
= pointer; }
63
65
void
Fill
(
float
value
)
66
{
67
int
iBin = floor(
float
(value -
fMinBin
)/
float
(
fMaxBin
-
fMinBin
) *
float
(
fSize
-2)) + 1;
68
69
if
(iBin >
fSize
-1)
70
iBin =
fSize
-1;
71
if
(iBin < 1)
72
iBin = 0;
73
74
if
( !(iBin==iBin) || !(std::isfinite(iBin)) ) iBin = 0;
75
76
fHistogram
[iBin]++;
77
}
78
80
inline
void
operator +=
(
const
KFPHistogram1D
&
h
)
81
{
82
if
(
fSize
!= h.
fSize
)
83
{
84
std::cout <<
"Size of 1D histogram "
<<
fName
<<
" is incorrect. Stop the program."
<< std::endl;
85
}
86
else
87
{
88
for
(
int
i
=0;
i
<
fSize
;
i
++)
89
fHistogram
[
i
] += h.
fHistogram
[
i
];
90
}
91
}
92
94
KFPHistogram1D
(
const
KFPHistogram1D
&
h
):
fHistogram
(h.
fHistogram
),
fSize
(h.
fSize
),
fName
(h.
fName
),
fMinBin
(h.
fMinBin
),
fMaxBin
(h.
fMaxBin
)
95
{
96
}
97
99
const
KFPHistogram1D
&
operator=
(
const
KFPHistogram1D
&
h
)
100
{
101
fHistogram
= h.
fHistogram
;
102
fSize
= h.
fSize
;
103
fName
= h.
fName
;
104
fMinBin
= h.
fMinBin
;
105
fMaxBin
= h.
fMaxBin
;
106
107
return
*
this
;
108
}
109
110
private
:
111
int
*
fHistogram
;
112
int
fSize
;
113
114
std::string
fName
;
115
float
fMinBin
;
116
float
fMaxBin
;
117
};
118
119
#endif
KFParticle
blob
master
KFParticlePerformance
KFPHistogram
KFPHistogram1D.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:26
using
1.8.2 with
sPHENIX GitHub integration