ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HSCPValidation/scripts/MakeHLT.C
Revision: 1.1
Committed: Fri Jan 29 08:49:44 2010 UTC (15 years, 3 months ago) by carrillo
Content type: text/plain
Branch: MAIN
Log Message:
First release

File Contents

# User Rev Content
1 carrillo 1.1 #include "Riostream.h"
2     #include <fstream>
3     #include <iomanip>
4     #include <vector>
5     #include <string>
6    
7     void MakeHLT(){
8     gROOT->Reset();
9     gStyle->SetOptStat(0);
10    
11     ifstream data;
12     float value;
13    
14     string name = "HLT"; //name withtout .txt
15     data.open((name+".txt").c_str());
16    
17     string label;
18     float eff;
19     float err;
20     float exp;
21     float obs;
22    
23     const int N = 101;
24    
25     TH1F * histo = new TH1F("histo",name.c_str(),101,0.5,101+0.5);
26     int bin = 0;
27    
28     while(!data.eof() && bin<101){
29     bin++;
30     data >>label>>obs>>exp;
31     histo->GetXaxis()->SetBinLabel(bin,label.c_str());
32     cout<<label<<" "<<obs<<" "<<exp<<endl;
33    
34     if(exp!=0){
35     eff = obs/exp;
36     err = sqrt(eff*(1-eff)/exp);
37     histo->SetBinContent(bin,eff);
38     histo->SetBinError(bin,err);
39     }
40     }
41    
42     TCanvas * Ca0 = new TCanvas("Ca0","Canvas",1200,800);
43     Ca0->SetBottomMargin(0.45);
44     histo->Draw();
45     histo->SetMaximum(1.1);
46     histo->SetMinimum(0.);
47     histo->GetXaxis()->LabelsOption("v");
48     histo->SetLabelSize(0.03);
49     Ca0->SaveAs((name+".png").c_str());
50    
51     exit(0);
52     }