-
Notifications
You must be signed in to change notification settings - Fork 1
/
RCMap.C
74 lines (52 loc) · 1.49 KB
/
RCMap.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef RCMap_C
#define RCMap_C
#include "RCMap.h"
///////////////////////////////////////////////////
double RCMap::getRowSum(TH2D* h, int irow){
int nbinsx = h->GetNbinsX();
double sum = 0.;
for (int xbin=1; xbin<=nbinsx; xbin++){
int gbin = h->GetBin(xbin,irow);
sum += h->GetBinContent(gbin);
}
return sum;
}
///////////////////////////////////////////////////
void RCMap::scaleRow(TH2D* h, int irow, double scale){
int nbinsx = h->GetNbinsX();
for (int xbin=1; xbin<=nbinsx; xbin++){
int gbin = h->GetBin(xbin,irow);
h->SetBinContent(gbin, (h->GetBinContent(gbin)*scale));
}
return ;
}
///////////////////////////////////////////////////
void RCMap::getConditionalX(){
int nbinsx = hweight->GetNbinsX();
int nbinsy = hweight->GetNbinsY();
for (int ybin=1; ybin<=nbinsy; ybin++){
double rowsum = getRowSum(hweight, ybin);
double norm = 1.0;
if (rowsum!=0){
norm = 1./rowsum;
}
scaleRow(hweight,ybin,norm);
}
return;
}
///////////////////////////////////////////////////
double RCMap::get1RWeight(double rcpar){
int ybin = hweight->GetYaxis()->FindBin(rcpar);
return hweight->GetBinContent(2,ybin);
}
///////////////////////////////////////////////////
RCMap::RCMap(const char* fname){
TFile* file = new TFile(fname);
hmap = (TH2D*)file->Get("hmap");
init();
}
void RCMap::init(){
hweight = (TH2D*)hmap->Clone("hweight");
getConditionalX();
}
#endif /* ----- #ifndef RCMap_INC ----- */