ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HSCPValidation/scripts/MakeHLT.C
Revision: 1.3
Committed: Thu Feb 4 14:55:19 2010 UTC (15 years, 3 months ago) by carrillo
Content type: text/plain
Branch: MAIN
CVS Tags: for_CMSSW_3_4_2, HEAD
Changes since 1.2: +3 -3 lines
Log Message:
correcting number of bin

File Contents

# Content
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(),91,0.5,91+0.5);
26 int bin = 0;
27
28 while(!data.eof() && bin<90){
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.02);
49 histo->GetYaxis()->SetTitle("Efficiency(%)");
50 Ca0->SaveAs((name+".png").c_str());
51
52 exit(0);
53 }