-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.C
61 lines (52 loc) · 1.85 KB
/
test.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
void test()
{
// initialize file and tree
TFile *infile = new TFile("studies_sampKenj/inputs/samples/sample_rootfiles/splines_event_by_event.root");
TTree *tree = (TTree*)infile->Get("spline_tree");
// set parameters from tree
float pmu, trupmu, cs, trucs, peso;
int sample;
const int BINS = 5;
int nevent = tree->GetEntries();
double xmin = tree->GetMinimum("Costhetamu");
double xmax = tree->GetMaximum("CosThetamu");
std::vector<double> binarr;
// set branches
tree->SetBranchAddress("Pmu", &pmu);
tree->SetBranchAddress("CosThetamu", &cs);
tree->SetBranchAddress("TruePmu", &trupmu);
tree->SetBranchAddress("TrueCosThetamu", &trucs);
tree->SetBranchAddress("POTWeight", &peso);
tree->SetBranchAddress("SelectedSample", &sample);
// create histo for binning
TH1D *h = new TH1D("", "", 50, xmin, xmax);
// loop over events
for(int ientry = 0; ientry < nevent; ientry++) {
tree->GetEntry(ientry);
if(peso > 10) peso = 1;
if(sample == 153) {
h->Fill(cs,peso);
}
}
double entriesbin = h->GetEntries()/BINS;
while(h->GetNbins() < BINS) {
for(ibin = 1; ibin < h->GetNbins()+1; ibin++) {
if(h->GetBinContent(ibin) == 0)
if()
if()
}
double edges[binarr.size()];
for(std::vector<double>::iterator it = binarr.begin() ; it != binarr.end(); ++it) {
h->Fill(*it);
}
//h->Reset();
h = (TH1D*) h->Rebin(binarr.size(),"",edges);
}
for(int i=1; i<=BINS;i++){
std::cout <<"Bin content for bin [" << h->GetXaxis()->GetBinLowEdge(i) << "," << h->GetXaxis()->GetBinUpEdge(i) << "] : " << h->GetBinContent(i)<< "\n";
}
TCanvas *c1 = new TCanvas();
gStyle->SetOptStat(0);
h->Draw("HISTTEXT65");
c1->SaveAs("plots/test.png");
}