ROOTPWA
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
src
rootscripts
equalbins.C
Go to the documentation of this file.
1
2
//
3
// Copyright 2009 Sebastian Neubert
4
//
5
// This file is part of rootpwa
6
//
7
// rootpwa is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// rootpwa is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU General Public License
18
// along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19
//
21
// script to calculate binning with equal amount of data
22
void
equalbins
(TGraph* h,
int
n
){
23
int
nbinsOrig=h->GetN();
24
double
ntot=0;
25
double
* data=h->GetY();
26
double
* x=h->GetX();
27
for
(
int
j=0; j<nbinsOrig; ++j)ntot+=data[j];
28
29
int
perbin=(
int
)floor((
double
)ntot/(double)n);
30
31
32
33
std::cout<<
"Integral: "
<<ntot
34
<<
" binsOrig: "
35
<<nbinsOrig<<
" PerBin: "
<<perbin<<endl;
36
37
int
content=0;
38
int
laststart=1;
39
for
(
int
i
=1;
i
<nbinsOrig; ++
i
){
40
content+=data[
i
];
41
if
(content>perbin){
42
std::cout<<laststart<<
"."
<<
i
<<endl;
43
laststart=
i
+1;
44
content=0;
45
}
46
}
47
std::cout<<laststart<<
"."
<<
i
<<endl;
48
}
Generated by
1.8.1.2