forked from isobelojalvo/openAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompAnalyzer_PlottingScript.cpp
74 lines (47 loc) · 1.92 KB
/
compAnalyzer_PlottingScript.cpp
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
74
#include <cstring>
#include <string>
void compAnalyzer_PlottingScript () {
// Open the file
std::unique_ptr<TFile> myFile(TFile::Open ("/nfs_scratch/jorgeeh/test_compAnalyzer.root"));
//Get the file
TTree* efficiencyTree = (TTree*) myFile -> Get("demo/EfficiencyTree");
TH1F *Cal = new TH1F("Cal", "Cal_Energy", 20, 0.0 ,20.0 );
// TH1F *script_compRegionEt = new TH1F ("vcompRegionEt", "Transverse_Energy", 50, 0 ,3);
// TH1F *script_compRegionPhi = new TH1F ("vcompRegionPhi" , "Phi" , 50 , 0, 3);
// TH1F *script_compRegionEta = new TH1F ("vcompRegionEta" , "Eta", 50 , 0 , 3);
std::vector<float>* vCal = nullptr;
efficiencyTree->SetBranchAddress("vRegionCal", &vCal);
// Draw one of the branches
Int_t nentries = (Int_t)efficiencyTree->GetEntries();
// std::cout << "number of entries :" << nentries << std::endl;
for(Int_t i = 1; i<nentries; i++){
// std::cout << "Entry :" << i << std::endl;
efficiencyTree -> GetEntry(i);
// std::cout << "check to see if the code got here" << std::endl;
for(auto vi = vCal->begin(); vi != vCal->end(); vi++) {
double value = *vi ;
// std::cout << "value :" << value << std::endl;
if (!std::isnan(value)){
if (value > 0){
Cal->Fill(value);
}
//std::cout << "Filling Th1F with " << value << std::endl;
}
}
}
// efficiencyTree -> Draw("vcompRegionPhi" , "script_compRegionPhi" );
// efficiencyTree -> Draw("vcompRegionEta", "script_compRegionEta");
// efficiencyTree -> Draw("vcompRegionEt","script_compRegionEt")
// Create TCanvas
TCanvas* TCan = new TCanvas("TCan", "" , 100, 20, 800, 600) ;
//Generally we need this line before we draw anything
TCan->cd();
//Draw the histogram
Cal->SetMarkerColor(0);
Cal->SetLineWidth(1);
Cal->SetFillStyle(1000);
Cal->Draw("HIST");
TCan->SaveAs("./compAnalyzer_testplot3.pdf");
//Clean up
delete TCan;
}