thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.2.1
Analysis
LWH
Histogram2D.h
1
// -*- C++ -*-
2
#ifndef LWH_Histogram2D_H
3
#define LWH_Histogram2D_H
4
//
5
// This is the declaration of the Histogram1D class.
6
//
7
8
#include "AIHistogram2D.h"
9
#include "ManagedObject.h"
10
#include "Axis.h"
11
#include "VariAxis.h"
12
#include <vector>
13
#include <stdexcept>
14
15
#include <iostream>
16
17
namespace
LWH
{
18
19
using namespace
AIDA
;
20
21
25
class
Histogram2D
:
public
IHistogram2D,
public
ManagedObject
{
26
27
public
:
28
30
friend
class
HistogramFactory
;
31
32
public
:
33
37
Histogram2D
(
int
nx,
double
lox,
double
upx,
38
int
ny,
double
loy,
double
upy)
39
: xfax(new
Axis
(nx, lox, upx)), xvax(0), yfax(new
Axis
(ny, loy, upy)),
40
sum(nx + 2,
std
::vector<int>(ny + 2)),
41
sumw(nx + 2,
std
::vector<double>(ny + 2)),
42
sumw2(nx + 2,
std
::vector<double>(ny + 2)),
43
sumxw(nx + 2,
std
::vector<double>(ny + 2)),
44
sumx2w(nx + 2,
std
::vector<double>(ny + 2)),
45
sumyw(nx + 2,
std
::vector<double>(ny + 2)),
46
sumy2w(nx + 2,
std
::vector<double>(ny + 2)) {
47
xax = xfax;
48
yax = yfax;
49
}
50
54
Histogram2D
(
const
std::vector<double> & xedges,
55
const
std::vector<double> & yedges)
56
: xfax(0), xvax(new
VariAxis
(xedges)),
57
yfax(0), yvax(new
VariAxis
(xedges)),
58
sum(xedges.size() + 1,
std
::vector<int>(yedges.size() + 1)),
59
sumw(xedges.size() + 1,
std
::vector<double>(yedges.size() + 1)),
60
sumw2(xedges.size() + 1,
std
::vector<double>(yedges.size() + 1)),
61
sumxw(xedges.size() + 1,
std
::vector<double>(yedges.size() + 1)),
62
sumx2w(xedges.size() + 1,
std
::vector<double>(yedges.size() + 1)),
63
sumyw(xedges.size() + 1,
std
::vector<double>(yedges.size() + 1)),
64
sumy2w(xedges.size() + 1,
std
::vector<double>(yedges.size() + 1)) {
65
xax = xvax;
66
yax = yvax;
67
}
68
72
Histogram2D
(
const
Histogram2D
& h)
73
: IBaseHistogram(h), IHistogram(h), IHistogram2D(h),
ManagedObject
(h),
74
xfax(0), xvax(0), yfax(0), yvax(0),
75
sum(h.sum), sumw(h.sumw), sumw2(h.sumw2),
76
sumxw(h.sumxw), sumx2w(h.sumx2w) ,
77
sumyw(h.sumyw), sumy2w(h.sumy2w){
78
const
VariAxis
* hxvax =
dynamic_cast<
const
VariAxis
*
>
(h.
xax
);
79
if
( hxvax ) xax = xvax =
new
VariAxis
(*hxvax);
80
else
xax = xfax =
new
Axis
(dynamic_cast<const Axis &>(*h.
xax
));
81
const
VariAxis
* hyvax =
dynamic_cast<
const
VariAxis
*
>
(h.
yax
);
82
if
( hyvax ) yax = yvax =
new
VariAxis
(*hyvax);
83
else
yax = yfax =
new
Axis
(dynamic_cast<const Axis &>(*h.
yax
));
84
}
85
87
virtual
~Histogram2D
() {
88
delete
xax;
89
delete
yax;
90
}
91
96
std::string
title
()
const
{
97
return
theTitle;
98
}
99
104
std::string
name
()
const
{
105
return
title();
106
}
107
113
bool
setTitle
(
const
std::string & title) {
114
theTitle = title;
115
return
true
;
116
}
117
121
IAnnotation &
annotation
() {
122
throw
std::runtime_error(
"LWH cannot handle annotations"
);
123
return
*anno;
124
}
125
129
const
IAnnotation &
annotation
()
const
{
130
throw
std::runtime_error(
"LWH cannot handle annotations"
);
131
return
*anno;
132
}
133
138
int
dimension
()
const
{
139
return
2;
140
}
141
146
bool
reset
() {
147
const
int
nx = xax->bins() + 2;
148
const
int
ny = yax->bins() + 2;
149
sum = std::vector< std::vector<int> >(nx, std::vector<int>(ny));
150
sumw = std::vector< std::vector<double> >(nx, std::vector<double>(ny));
151
sumw2 = sumw;
152
sumxw = sumw;
153
sumx2w = sumw;
154
sumyw = sumw;
155
sumy2w = sumw;
156
return
true
;
157
}
158
164
int
entries
()
const
{
165
int
si = 0;
166
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
167
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) si += sum[ix][iy];
168
return
si;
169
}
170
178
int
allEntries
()
const
{
179
return
entries() + extraEntries();
180
}
181
186
int
extraEntries
()
const
{
187
int
esum = sum[0][0] + sum[1][0] + sum[0][1] + sum[1][1];
188
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
189
esum += sum[ix][0] + sum[ix][1];
190
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
191
esum += sum[0][iy] + sum[1][iy];
192
return
esum;
193
}
194
200
double
equivalentBinEntries
()
const
{
201
double
sw = 0.0;
202
double
sw2 = 0.0;
203
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
204
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) {
205
sw += sumw[ix][iy];
206
sw2 += sumw2[ix][iy];
207
}
208
return
sw2/(sw*sw);
209
}
210
217
double
sumBinHeights
()
const
{
218
double
sw = 0.0;
219
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
220
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) sw += sumw[ix][iy];
221
return
sw;
222
}
223
229
double
sumAllBinHeights
()
const
{
230
return
sumBinHeights() + sumExtraBinHeights();
231
}
232
237
double
sumExtraBinHeights
()
const
{
238
int
esum = sumw[0][0] + sumw[1][0] + sumw[0][1] + sumw[1][1];
239
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
240
esum += sumw[ix][0] + sumw[ix][1];
241
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
242
esum += sumw[0][iy] + sumw[1][iy];
243
return
esum;
244
}
245
251
double
minBinHeight
()
const
{
252
double
minw = sumw[2][2];
253
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
254
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
255
minw = std::min(minw, sumw[ix][iy]);
256
return
minw;
257
}
258
264
double
maxBinHeight
()
const
{
265
double
maxw = sumw[2][2];
266
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
267
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
268
maxw = std::max(maxw, sumw[ix][iy]);
269
return
maxw;
270
}
271
279
bool
fill
(
double
x,
double
y,
double
weight = 1.) {
280
int
ix = xax->coordToIndex(x) + 2;
281
int
iy = yax->coordToIndex(y) + 2;
282
++sum[ix][iy];
283
sumw[ix][iy] += weight;
284
sumxw[ix][iy] += x*weight;
285
sumx2w[ix][iy] += x*x*weight;
286
sumyw[ix][iy] += y*weight;
287
sumy2w[ix][iy] += y*y*weight;
288
sumw2[ix][iy] += weight*weight;
289
return
weight >= 0 && weight <= 1;
290
}
291
298
double
binMeanX
(
int
xindex,
int
yindex)
const
{
299
int
ix = xindex + 2;
300
int
iy = yindex + 2;
301
return
sumw[ix][iy] != 0.0? sumxw[ix][iy]/sumw[ix][iy]:
302
( xvax? xvax->binMidPoint(xindex): xfax->binMidPoint(xindex) );
303
};
304
311
double
binMeanY
(
int
xindex,
int
yindex)
const
{
312
int
ix = xindex + 2;
313
int
iy = yindex + 2;
314
return
sumw[ix][iy] != 0.0? sumyw[ix][iy]/sumw[ix][iy]:
315
( yvax? yvax->binMidPoint(yindex): xfax->binMidPoint(yindex) );
316
};
317
324
double
binRmsX
(
int
xindex,
int
yindex)
const
{
325
int
ix = xindex + 2;
326
int
iy = yindex + 2;
327
return
sumw[ix][iy] == 0.0 || sum[ix][iy] < 2? xax->binWidth(xindex):
328
std::sqrt(std::max(sumw[ix][iy]*sumx2w[ix][iy] -
329
sumxw[ix][iy]*sumxw[ix][iy], 0.0))/sumw[ix][iy];
330
};
331
338
double
binRmsY
(
int
xindex,
int
yindex)
const
{
339
int
ix = xindex + 2;
340
int
iy = yindex + 2;
341
return
sumw[ix][iy] == 0.0 || sum[ix][iy] < 2? yax->binWidth(yindex):
342
std::sqrt(std::max(sumw[ix][iy]*sumy2w[ix][iy] -
343
sumyw[ix][iy]*sumyw[ix][iy], 0.0))/sumw[ix][iy];
344
};
345
352
int
binEntries
(
int
xindex,
int
yindex)
const
{
353
return
sum[xindex + 2][yindex + 2];
354
}
355
363
virtual
int
binEntriesX
(
int
index)
const
{
364
int
ret = 0;
365
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
366
ret += sum[index + 2][iy];
367
return
ret;
368
}
369
377
virtual
int
binEntriesY
(
int
index)
const
{
378
int
ret = 0;
379
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
380
ret += sum[ix][index + 2];
381
return
ret;
382
}
383
390
double
binHeight
(
int
xindex,
int
yindex)
const
{
393
return
sumw[xindex + 2][yindex + 2];
394
}
395
403
virtual
double
binHeightX
(
int
index)
const
{
404
double
ret = 0;
405
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
406
ret += sumw[index + 2][iy];
407
return
ret;
408
}
409
417
virtual
double
binHeightY
(
int
index)
const
{
418
double
ret = 0;
419
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
420
ret += sumw[ix][index + 2];
421
return
ret;
422
}
423
430
double
binError
(
int
xindex,
int
yindex)
const
{
431
return
std::sqrt(sumw2[xindex + 2][yindex + 2]);
432
}
433
439
double
meanX
()
const
{
440
double
s = 0.0;
441
double
sx = 0.0;
442
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
443
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) {
444
s += sumw[ix][iy];
445
sx += sumxw[ix][iy];
446
}
447
return
s != 0.0? sx/s: 0.0;
448
}
449
455
double
meanY
()
const
{
456
double
s = 0.0;
457
double
sy = 0.0;
458
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
459
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) {
460
s += sumw[ix][iy];
461
sy += sumyw[ix][iy];
462
}
463
return
s != 0.0? sy/s: 0.0;
464
}
465
471
double
rmsX
()
const
{
472
double
s = 0.0;
473
double
sx = 0.0;
474
double
sx2 = 0.0;
475
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
476
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) {
477
s += sumw[ix][iy];
478
sx += sumxw[ix][iy];
479
sx2 += sumx2w[ix][iy];
480
}
481
return
s != 0.0? std::sqrt(std::max(s*sx2 - sx*sx, 0.0))/s:
482
xax->upperEdge() - xax->lowerEdge();
483
}
484
490
double
rmsY
()
const
{
491
double
s = 0.0;
492
double
sy = 0.0;
493
double
sy2 = 0.0;
494
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix )
495
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy ) {
496
s += sumw[ix][iy];
497
sy += sumyw[ix][iy];
498
sy2 += sumy2w[ix][iy];
499
}
500
return
s != 0.0? std::sqrt(std::max(s*sy2 - sy*sy, 0.0))/s:
501
yax->upperEdge() - yax->lowerEdge();
502
}
503
505
double
getSumW
(
int
xindex,
int
yindex)
const
{
506
return
sumw[xindex + 2][yindex + 2];
507
}
508
510
double
getSumW2
(
int
xindex,
int
yindex)
const
{
511
return
sumw2[xindex + 2][yindex + 2];
512
}
513
515
double
getSumXW
(
int
xindex,
int
yindex)
const
{
516
return
sumxw[xindex + 2][yindex + 2];
517
}
518
520
double
getSumX2W
(
int
xindex,
int
yindex)
const
{
521
return
sumx2w[xindex + 2][yindex + 2];
522
}
523
525
double
getSumYW
(
int
xindex,
int
yindex)
const
{
526
return
sumyw[xindex + 2][yindex + 2];
527
}
528
530
double
getSumY2W
(
int
xindex,
int
yindex)
const
{
531
return
sumy2w[xindex + 2][yindex + 2];
532
}
533
538
const
IAxis &
xAxis
()
const
{
539
return
*xax;
540
}
541
546
const
IAxis &
yAxis
()
const
{
547
return
*yax;
548
}
549
557
int
coordToIndexX
(
double
coord)
const
{
558
return
xax->coordToIndex(coord);
559
}
560
568
int
coordToIndexY
(
double
coord)
const
{
569
return
yax->coordToIndex(coord);
570
}
571
577
bool
add
(
const
Histogram2D
& h) {
578
if
( xax->upperEdge() != h.
xax
->upperEdge() ||
579
xax->lowerEdge() != h.
xax
->lowerEdge() ||
580
xax->bins() != h.
xax
->bins() )
return
false
;
581
if
( yax->upperEdge() != h.
yax
->upperEdge() ||
582
yax->lowerEdge() != h.
yax
->lowerEdge() ||
583
yax->bins() != h.
yax
->bins() )
return
false
;
584
for
(
int
ix = 0; ix < xax->bins() + 2; ++ix )
585
for
(
int
iy = 0; iy < yax->bins() + 2; ++iy ) {
586
sum[ix][iy] += h.
sum
[ix][iy];
587
sumw[ix][iy] += h.
sumw
[ix][iy];
588
sumxw[ix][iy] += h.
sumxw
[ix][iy];
589
sumx2w[ix][iy] += h.
sumx2w
[ix][iy];
590
sumyw[ix][iy] += h.
sumyw
[ix][iy];
591
sumy2w[ix][iy] += h.
sumy2w
[ix][iy];
592
sumw2[ix][iy] += h.
sumw2
[ix][iy];
593
}
594
return
true
;
595
}
596
602
bool
add
(
const
IHistogram2D & hist) {
603
return
add(dynamic_cast<const Histogram2D &>(hist));
604
}
605
610
bool
scale
(
double
s) {
611
for
(
int
ix = 0; ix < xax->bins() + 2; ++ix )
612
for
(
int
iy = 0; iy < yax->bins() + 2; ++iy ) {
613
sumw[ix][iy] *= s;
614
sumxw[ix][iy] *= s;
615
sumx2w[ix][iy] *= s;
616
sumyw[ix][iy] *= s;
617
sumy2w[ix][iy] *= s;
618
sumw2[ix][iy] *= s*s;
619
}
620
return
true
;
621
}
622
630
void
normalize
(
double
intg) {
631
double
oldintg = sumAllBinHeights();
632
if
( oldintg == 0.0 )
return
;
633
for
(
int
ix = 0; ix < xax->bins() + 2; ++ix )
634
for
(
int
iy = 0; iy < yax->bins() + 2; ++iy ) {
635
double
fac = intg/oldintg;
636
if
( ix >= 2 && iy >= 2 )
637
fac /= (xax->binUpperEdge(ix - 2) - xax->binLowerEdge(ix - 2))*
638
(yax->binUpperEdge(iy - 2) - yax->binLowerEdge(iy - 2));
639
sumw[ix][iy] *= fac;
640
sumxw[ix][iy] *= fac;
641
sumx2w[ix][iy] *= fac;
642
sumyw[ix][iy] *= fac;
643
sumy2w[ix][iy] *= fac;
644
sumw2[ix][iy] *= fac*fac;
645
}
646
}
647
652
// double integral() const {
653
// double intg = sumw[0] + sumw[1];
654
// for ( int i = 2; i < ax->bins() + 2; ++i )
655
656
// is this right? Leave out bin width factor?
657
658
// intg += sumw[ix][iy]*(ax->binUpperEdge(i - 2) - ax->binLowerEdge(i - 2));
659
// return intg;
660
// }
661
666
void
*
cast
(
const
std::string &)
const
{
667
return
0;
668
}
669
673
bool
writeXML
(std::ostream & os, std::string path, std::string name) {
674
//std::cout << "Writing out histogram " << name << " in AIDA file format!" << std::endl;
675
os <<
" <histogram2d name=\""
<< name
676
<<
"\"\n title=\""
<< title()
677
<<
"\" path=\""
<< path
678
<<
"\">\n <axis max=\""
<< xax->upperEdge()
679
<<
"\" numberOfBins=\""
<< xax->bins()
680
<<
"\" min=\""
<< xax->lowerEdge()
681
<<
"\" direction=\"x\""
;
682
if
( xvax ) {
683
os <<
">\n"
;
684
for
(
int
i = 0, N = xax->bins() - 1; i < N; ++i )
685
os <<
" <binBorder value=\""
<< xax->binUpperEdge(i) <<
"\"/>\n"
;
686
os <<
" </axis>\n"
;
687
}
else
{
688
os <<
"/>\n"
;
689
}
690
os <<
" <axis max=\""
<< yax->upperEdge()
691
<<
"\" numberOfBins=\""
<< yax->bins()
692
<<
"\" min=\""
<< yax->lowerEdge()
693
<<
"\" direction=\"y\""
;
694
if
( yvax ) {
695
os <<
">\n"
;
696
for
(
int
i = 0, N = yax->bins() - 1; i < N; ++i )
697
os <<
" <binBorder value=\""
<< yax->binUpperEdge(i) <<
"\"/>\n"
;
698
os <<
" </axis>\n"
;
699
}
else
{
700
os <<
"/>\n"
;
701
}
702
os <<
" <statistics entries=\""
<< entries()
703
<<
"\">\n <statistic mean=\""
<< meanX()
704
<<
"\" direction=\"x\"\n rms=\""
<< rmsX()
705
<<
"\"/>\n </statistics>\n <statistic mean=\""
<< meanY()
706
<<
"\" direction=\"y\"\n rms=\""
<< rmsY()
707
<<
"\"/>\n </statistics>\n <data2d>\n"
;
708
for
(
int
ix = 0; ix < xax->bins() + 2; ++ix )
709
for
(
int
iy = 0; iy < yax->bins() + 2; ++iy )
710
if
( sum[ix][iy] ) {
711
os <<
" <bin2d binNumX=\""
;
712
if
( ix == 0 ) os <<
"UNDERFLOW"
;
713
else
if
( ix == 1 ) os <<
"OVERFLOW"
;
714
else
os << ix - 2;
715
os <<
"\" binNumY=\""
;
716
if
( iy == 0 ) os <<
"UNDERFLOW"
;
717
else
if
( iy == 1 ) os <<
"OVERFLOW"
;
718
else
os << iy - 2;
719
os <<
"\" entries=\""
<< sum[ix][iy]
720
<<
"\" height=\""
<< sumw[ix][iy]
721
<<
"\"\n error=\""
<< std::sqrt(sumw2[ix][iy])
722
<<
"\" error2=\""
<< sumw2[ix][iy]
723
<<
"\"\n weightedMeanX=\""
<< binMeanX(ix - 2, iy - 2)
724
<<
"\" weightedRmsX=\""
<< binRmsX(ix - 2, iy - 2)
725
<<
"\"\n weightedMeanY=\""
<< binMeanY(ix - 2, iy - 2)
726
<<
"\" weightedRmsY=\""
<< binRmsY(ix - 2, iy - 2)
727
<<
"\"/>\n"
;
728
}
729
os <<
" </data2d>\n </histogram2d>"
<< std::endl;
730
return
true
;
731
}
732
733
738
bool
writeFLAT
(std::ostream & os, std::string path, std::string name) {
739
os <<
"#2D "
<< path <<
"/"
<< name <<
" "
<< xax->lowerEdge()
740
<<
" "
<< xax->bins() <<
" "
<< xax->upperEdge() <<
" "
741
<< yax->lowerEdge() <<
" "
<< yax->bins() <<
" "
<< yax->upperEdge()
742
<<
" \""
<< title() <<
"\""
<< std::endl;
743
for
(
int
ix = 2; ix < xax->bins() + 2; ++ix ) {
744
for
(
int
iy = 2; iy < yax->bins() + 2; ++iy )
745
os << 0.5*(xax->binLowerEdge(ix - 2)+xax->binUpperEdge(ix - 2)) <<
" "
746
<< 0.5*(yax->binLowerEdge(iy - 2)+yax->binUpperEdge(iy - 2))
747
<<
" "
<< sumw[ix][iy] <<
" "
<< sqrt(sumw2[ix][iy])
748
<<
" "
<< sum[ix][iy] << std::endl;
749
os << std::endl;
750
}
751
os << std::endl;
752
return
true
;
753
}
754
755
756
757
#ifdef HAVE_ROOT
758
761
//bool writeROOT(std::ostream & os, std::string path, std::string name) {
762
bool
writeROOT(TFile* file, std::string path, std::string name) {
763
764
//std::cout << "Writing out histogram " << name.c_str() << " in ROOT file format" << std::endl;
765
766
TH1D* hist1d;
767
int
nbins;
768
if
(!vax || vax->isFixedBinning() ) {
//equidistant binning (easier case)
769
nbins = ax->bins();
770
hist1d =
new
TH1D(name.c_str(), title().c_str(), nbins, ax->lowerEdge(), ax->upperEdge());
771
}
772
else
{
773
nbins = vax->bins();
774
double
* bins =
new
double
[nbins+1];
775
for
(
int
i=0; i<nbins; ++i) {
776
bins[ix][iy] = vax->binEdges(i).first;
777
}
778
bins[nbins] = vax->binEdges(nbins-1).second;
//take last bin right border
779
hist1d =
new
TH1D(name.c_str(), title().c_str(), nbins, bins);
780
delete
[] bins;
781
}
782
783
784
double
entries = 0;
785
for
(
int
i = 0; i < nbins + 2; ++i ) {
786
if
( sum[ix][iy] ) {
787
//i==0: underflow->RootBin(0), i==1: overflow->RootBin(NBins+1)
788
entries = entries + sum[ix][iy];
789
int
j=i;
790
if
(i==0) j=0;
//underflow
791
else
if
(i==1) j=nbins+1;
//overflow
792
if
(i>=2) j=i-1;
//normal bin entries
793
hist1d->SetBinContent(j, sumw[ix][iy]);
794
hist1d->SetBinError(j, sqrt(sumw2[ix][iy]));
795
//hist1d->Fill(binMean(i), sumw[ix][iy]);
796
}
797
}
798
799
hist1d->Sumw2();
800
hist1d->SetEntries(entries);
801
802
std::string DirName;
//remove preceding slash from directory name, else ROOT error
803
for
(
unsigned
int
i=1; i<path.size(); ++i) DirName += path[i];
804
if
(!file->Get(DirName.c_str())) file->mkdir(DirName.c_str());
805
file->cd(DirName.c_str());
806
hist1d->Write();
807
808
delete
hist1d;
809
810
return
true
;
811
}
812
813
#endif
814
815
816
817
private
:
818
820
std::string
theTitle
;
821
823
IAxis *
xax
;
824
826
Axis
*
xfax
;
827
829
VariAxis
*
xvax
;
830
832
IAxis *
yax
;
833
835
Axis
*
yfax
;
836
838
VariAxis
*
yvax
;
839
841
std::vector< std::vector<int> >
sum
;
842
844
std::vector< std::vector<double> >
sumw
;
845
847
std::vector< std::vector<double> >
sumw2
;
848
850
std::vector< std::vector<double> >
sumxw
;
851
853
std::vector< std::vector<double> >
sumx2w
;
854
856
std::vector< std::vector<double> >
sumyw
;
857
859
std::vector< std::vector<double> >
sumy2w
;
860
862
IAnnotation *
anno
;
863
864
};
865
866
}
867
868
#endif
/* LWH_Histogram1D_H */
LWH::Histogram2D::normalize
void normalize(double intg)
Scale the given histogram so that the integral over all bins (including overflow) gives intg...
Definition:
Histogram2D.h:630
LWH::Histogram2D::cast
void * cast(const std::string &) const
Return the integral over the histogram bins assuming it has been normalize()d.
Definition:
Histogram2D.h:666
LWH::Histogram2D::sumBinHeights
double sumBinHeights() const
Sum of in-range bin heights in the IHistogram, UNDERFLOW and OVERFLOW bins are excluded.
Definition:
Histogram2D.h:217
LWH::Histogram2D::yvax
VariAxis * yvax
Pointer (possibly null) to a axis with fixed bin width.
Definition:
Histogram2D.h:838
LWH::Histogram2D::Histogram2D
Histogram2D(int nx, double lox, double upx, int ny, double loy, double upy)
Standard constructor.
Definition:
Histogram2D.h:37
LWH::Histogram2D::meanY
double meanY() const
The mean of the IHistogram2D along the y axis.
Definition:
Histogram2D.h:455
LWH::Histogram2D::~Histogram2D
virtual ~Histogram2D()
Destructor.
Definition:
Histogram2D.h:87
LWH::Histogram2D::xvax
VariAxis * xvax
Pointer (possibly null) to a axis with fixed bin width.
Definition:
Histogram2D.h:829
LWH::Histogram2D::getSumW
double getSumW(int xindex, int yindex) const
The weights.
Definition:
Histogram2D.h:505
LWH::Histogram2D::annotation
const IAnnotation & annotation() const
Not implemented in LWH.
Definition:
Histogram2D.h:129
LWH::Histogram2D::sumAllBinHeights
double sumAllBinHeights() const
Sum of the heights of all the IHistogram's bins, i.e in-range bins, UNDERFLOW and OVERFLOW...
Definition:
Histogram2D.h:229
LWH::Histogram2D::setTitle
bool setTitle(const std::string &title)
Set the histogram title.
Definition:
Histogram2D.h:113
LWH::Histogram2D::binHeight
double binHeight(int xindex, int yindex) const
Total height of the corresponding bin (ie the sum of the weights in this bin).
Definition:
Histogram2D.h:390
LWH::Histogram2D::binRmsX
double binRmsX(int xindex, int yindex) const
The weighted x-RMS of a bin.
Definition:
Histogram2D.h:324
LWH::Histogram2D::binHeightX
virtual double binHeightX(int index) const
Sum of all the heights of the bins along a given x bin.
Definition:
Histogram2D.h:403
std
STL namespace.
LWH::Histogram2D::sumyw
std::vector< std::vector< double > > sumyw
The weighted y-values.
Definition:
Histogram2D.h:856
LWH::Histogram2D::title
std::string title() const
Get the Histogram's title.
Definition:
Histogram2D.h:96
LWH::Histogram2D
User level interface to 1D Histogram.
Definition:
Histogram2D.h:25
LWH::Histogram2D::getSumY2W
double getSumY2W(int xindex, int yindex) const
The weighted x-square-values.
Definition:
Histogram2D.h:530
LWH::Histogram2D::yAxis
const IAxis & yAxis() const
Get the y axis of the IHistogram2D.
Definition:
Histogram2D.h:546
LWH::Histogram2D::binMeanX
double binMeanX(int xindex, int yindex) const
The weighted mean along the x-axis of a bin.
Definition:
Histogram2D.h:298
LWH::Histogram2D::binRmsY
double binRmsY(int xindex, int yindex) const
The weighted y-RMS of a bin.
Definition:
Histogram2D.h:338
LWH::Histogram2D::sumExtraBinHeights
double sumExtraBinHeights() const
Sum of heights in the UNDERFLOW and OVERFLOW bins.
Definition:
Histogram2D.h:237
LWH::Histogram2D::extraEntries
int extraEntries() const
Number of entries in the UNDERFLOW and OVERFLOW bins.
Definition:
Histogram2D.h:186
LWH::Histogram2D::theTitle
std::string theTitle
The title.
Definition:
Histogram2D.h:820
LWH::Histogram2D::add
bool add(const Histogram2D &h)
Add to this Histogram2D the contents of another IHistogram2D.
Definition:
Histogram2D.h:577
LWH::Histogram2D::getSumYW
double getSumYW(int xindex, int yindex) const
The weighted x-values.
Definition:
Histogram2D.h:525
LWH::Histogram2D::getSumXW
double getSumXW(int xindex, int yindex) const
The weighted x-values.
Definition:
Histogram2D.h:515
LWH::Histogram2D::rmsX
double rmsX() const
The RMS of the IHistogram2D along the x axis.
Definition:
Histogram2D.h:471
LWH::Histogram2D::meanX
double meanX() const
The mean of the IHistogram2D along the x axis.
Definition:
Histogram2D.h:439
LWH::Histogram2D::maxBinHeight
double maxBinHeight() const
Maximum height of the in-range bins, i.e.
Definition:
Histogram2D.h:264
LWH::Histogram2D::minBinHeight
double minBinHeight() const
Minimum height of the in-range bins, i.e.
Definition:
Histogram2D.h:251
LWH::Histogram2D::rmsY
double rmsY() const
The RMS of the IHistogram2D along the x axis.
Definition:
Histogram2D.h:490
LWH::Histogram2D::binEntriesX
virtual int binEntriesX(int index) const
Sum of all the entries of the bins along a given x bin.
Definition:
Histogram2D.h:363
LWH::Histogram2D::getSumW2
double getSumW2(int xindex, int yindex) const
The squared weights.
Definition:
Histogram2D.h:510
LWH::Histogram2D::sumw2
std::vector< std::vector< double > > sumw2
The squared weights.
Definition:
Histogram2D.h:847
LWH::Histogram2D::binEntriesY
virtual int binEntriesY(int index) const
Sum of all the entries of the bins along a given y bin.
Definition:
Histogram2D.h:377
LWH::Histogram2D::Histogram2D
Histogram2D(const Histogram2D &h)
Copy constructor.
Definition:
Histogram2D.h:72
LWH::Histogram2D::sumw
std::vector< std::vector< double > > sumw
The weights.
Definition:
Histogram2D.h:844
LWH::Histogram2D::allEntries
int allEntries() const
Sum of the entries in all the IHistogram's bins, i.e in-range bins, UNDERFLOW and OVERFLOW...
Definition:
Histogram2D.h:178
LWH::Histogram2D::xax
IAxis * xax
The axis.
Definition:
Histogram2D.h:823
LWH::Histogram2D::binMeanY
double binMeanY(int xindex, int yindex) const
The weighted mean along the y-axis of a bin.
Definition:
Histogram2D.h:311
LWH::Histogram2D::add
bool add(const IHistogram2D &hist)
Add to this IHistogram1D the contents of another IHistogram1D.
Definition:
Histogram2D.h:602
LWH::Histogram2D::writeFLAT
bool writeFLAT(std::ostream &os, std::string path, std::string name)
Write out the histogram in a flat text file suitable for eg.
Definition:
Histogram2D.h:738
LWH::Histogram2D::binEntries
int binEntries(int xindex, int yindex) const
Number of entries in the corresponding bin (ie the number of times fill was called for this bin)...
Definition:
Histogram2D.h:352
LWH::Histogram2D::binError
double binError(int xindex, int yindex) const
The error of a given bin.
Definition:
Histogram2D.h:430
LWH::Histogram2D::Histogram2D
Histogram2D(const std::vector< double > &xedges, const std::vector< double > &yedges)
Standard constructor for variable bin width.
Definition:
Histogram2D.h:54
LWH::VariAxis
An VariAxis represents a binned histogram axis.
Definition:
VariAxis.h:31
LWH::Histogram2D::yfax
Axis * yfax
Pointer (possibly null) to a axis with fixed bin width.
Definition:
Histogram2D.h:835
LWH::Histogram2D::annotation
IAnnotation & annotation()
Not implemented in LWH.
Definition:
Histogram2D.h:121
LWH::HistogramFactory
User level interface for factory classes of Histograms (binned, unbinned, and profile).
Definition:
HistogramFactory.h:32
LWH::Histogram2D::getSumX2W
double getSumX2W(int xindex, int yindex) const
The weighted x-square-values.
Definition:
Histogram2D.h:520
LWH::Histogram2D::equivalentBinEntries
double equivalentBinEntries() const
Number of equivalent entries, i.e.
Definition:
Histogram2D.h:200
LWH::Histogram2D::coordToIndexX
int coordToIndexX(double coord) const
Get the bin number corresponding to a given coordinate along the x axis.
Definition:
Histogram2D.h:557
LWH::Histogram2D::sumx2w
std::vector< std::vector< double > > sumx2w
The weighted x-square-values.
Definition:
Histogram2D.h:853
LWH::Axis
An Axis represents a binned histogram axis.
Definition:
Axis.h:30
LWH::Histogram2D::yax
IAxis * yax
The axis.
Definition:
Histogram2D.h:832
LWH::Histogram2D::sum
std::vector< std::vector< int > > sum
The counts.
Definition:
Histogram2D.h:841
LWH::Histogram2D::sumy2w
std::vector< std::vector< double > > sumy2w
The weighted y-square-values.
Definition:
Histogram2D.h:859
LWH::Histogram2D::scale
bool scale(double s)
Scale the contents of this histogram with the given factor.
Definition:
Histogram2D.h:610
LWH
The LWH namespace contains a Light-Weight Histogram package which implements the most rudimentary his...
Definition:
AnalysisFactory.h:35
LWH::Histogram2D::dimension
int dimension() const
Get the Histogram's dimension.
Definition:
Histogram2D.h:138
LWH::Histogram2D::name
std::string name() const
Get the Histogram's name.
Definition:
Histogram2D.h:104
LWH::Histogram2D::writeXML
bool writeXML(std::ostream &os, std::string path, std::string name)
Write out the histogram in the AIDA xml format.
Definition:
Histogram2D.h:673
LWH::Histogram2D::anno
IAnnotation * anno
dummy pointer to non-existen annotation.
Definition:
Histogram2D.h:862
LWH::Histogram2D::reset
bool reset()
Reset the Histogram; as if just created.
Definition:
Histogram2D.h:146
LWH::Histogram2D::coordToIndexY
int coordToIndexY(double coord) const
Get the bin number corresponding to a given coordinate along the y axis.
Definition:
Histogram2D.h:568
LWH::Histogram2D::entries
int entries() const
Get the number of in-range entries in the Histogram.
Definition:
Histogram2D.h:164
LWH::Histogram2D::fill
bool fill(double x, double y, double weight=1.)
Fill the IHistogram1D with a value and the corresponding weight.
Definition:
Histogram2D.h:279
LWH::ManagedObject
The creator of trees.
Definition:
ManagedObject.h:25
LWH::Histogram2D::sumxw
std::vector< std::vector< double > > sumxw
The weighted x-values.
Definition:
Histogram2D.h:850
LWH::Histogram2D::xAxis
const IAxis & xAxis() const
Get the x axis of the IHistogram2D.
Definition:
Histogram2D.h:538
AIDA
Definition:
FactoryBase.h:18
LWH::Histogram2D::binHeightY
virtual double binHeightY(int index) const
Sum of all the heights of the bins along a given y bin.
Definition:
Histogram2D.h:417
LWH::Histogram2D::xfax
Axis * xfax
Pointer (possibly null) to a axis with fixed bin width.
Definition:
Histogram2D.h:826
Generated on Sat Apr 11 2020 14:31:17 for ThePEG by
1.8.13