-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReadNtuple.C
executable file
·76 lines (57 loc) · 1.63 KB
/
ReadNtuple.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
74
75
#include <vector>
#include <stdio.h>
#include <TFile.h>
#include <iostream>
#include <fstream>
// define the fitting function
void ReadNtuple( string fileName ) {
TString theFileName = fileName + ".root" ;
TChain* theChain = new TChain( "CutFlow" ) ;
theChain->Add( theFileName ) ;
TTree* tr = theChain ;
int counter[12] = { 0. } ;
tr->SetBranchAddress("counter", counter);
TH1D* h1 = new TH1D("h1", "cut flows", 12, 0,12 ) ;
int totalN = tr->GetEntries();
for ( int i=0; i < totalN ; i++ ) {
cout<<" ("<<i <<")"<<endl ;
tr->GetEntry( i );
for ( int k=0; k<12; k++ ) {
h1->Fill( k , counter[k] ) ;
}
}
gStyle->SetOptStat("");
/*
TLegend* leg1 = new TLegend(.65, .7, .9, .9 );
leg1->Clear();
leg1->SetTextSize(0.03) ;
char RStr0[30], RStr1[30] ;
sprintf( RStr0, "No Iso (%d)", h0->Integral() ) ;
sprintf( RStr1, "PF Iso (%d)", h1->Integral() ) ;
leg1->AddEntry( h0, RStr0, "L");
leg1->AddEntry( h1, RStr1, "L");
*/
TCanvas *c1 = new TCanvas("c1","",900,720);
c1->cd();
c1->SetFillColor(10);
c1->SetFillColor(10);
//c1->Divide(1,2);
//c1->cd(1) ;
c1->SetLogy() ;
h1->GetXaxis()->SetTitle( " counters " );
h1->SetLineColor(1) ;
h1->Draw() ;
c1->Update() ;
/*
h1->SetLineColor(2) ;
h1->DrawCopy("SAME") ;
c1->Update() ;
h2->SetLineColor(4) ;
h2->DrawCopy("SAME") ;
c1->Update() ;
leg1->Draw("sames") ;
c1->Update() ;
*/
TString plotname = fileName + ".png" ;
c1->Print( plotname ) ;
}