ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/QCDPATExample/test/PlotResolution.C
Revision: 1.1
Committed: Thu Sep 3 23:18:34 2009 UTC (15 years, 8 months ago) by vchetlur
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 vchetlur 1.1 //Macro to plot the resolution of the jets
2    
3     void PlotResolution(Char_t *strFileName){
4    
5     gROOT->SetStyle("Plain");
6     gStyle->SetOptStat(0);
7     gStyle->SetOptTitle(0);
8     gStyle->SetOptFit(111);
9     gStyle->SetPalette(1);
10     gStyle->SetStatFont(40);
11     gStyle->SetTitleFont(40);
12     gStyle->SetStatX(0.98);
13     gStyle->SetStatY(0.99);
14     gStyle->SetStatH(0.35);
15     gStyle->SetStatW(0.2);
16     gStyle->SetTitleBorderSize(0);
17     gStyle->SetStatBorderSize(0);
18     gStyle->SetStatFontSize(0.045);
19    
20     TCanvas *EventProfile = new TCanvas("CanResponse","CanResponse",500,500);
21     EventProfile->SetFillColor(0);
22     EventProfile->SetBorderMode(0);
23     EventProfile->SetBorderSize(0);
24     EventProfile->SetTickx();
25     EventProfile->SetTicky();
26     EventProfile->SetLeftMargin(0.2);
27     EventProfile->SetRightMargin(0.04);
28     EventProfile->SetTopMargin(0.05);
29     EventProfile->SetBottomMargin(0.18);
30     EventProfile->SetFrameBorderMode(0);
31     EventProfile->SetFrameBorderSize(0);
32    
33     TH1F *hFrame=(TH1F *)EventProfile->DrawFrame(25,0,500,0.5);
34     initFrameProperties(hFrame);
35    
36     TFile *fInput=new TFile(strFileName);
37     fInput->ls();
38    
39    
40     TKey *dirKey = (TKey *)fInput->GetKey("demo");
41     TDirectoryFile *idir = (TDirectoryFile *)dirKey->ReadObj();
42     idir->ls();
43    
44     dirKey = (TKey *)idir->GetKey("histJetResolutionVspT");
45     TH2F *hResolutionDistVsGenJetPt=(TH2F*)dirKey->ReadObj();
46    
47     TGraphErrors *gResolutionVsPt=new TGraphErrors();
48    
49     Int_t incr=2.;
50     for(Int_t i=1,iPt=0;i<hResolutionDistVsGenJetPt->GetXaxis()->GetNbins();i+=incr,incr+=1.){
51     TH1F *hResDist=(TH1F *)hResolutionDistVsGenJetPt->ProjectionY("hResDist",i,i+incr);
52     TF1 *f1=new TF1("f1","gaus");
53     f1->SetRange(hResDist->GetMean()-(2.5*hResDist->GetRMS()),hResDist->GetMean()+(2.5*hResDist->GetRMS()));
54     hResDist->Fit(f1,"NRQ");
55     cout<<hResolutionDistVsGenJetPt->GetXaxis()->GetBinCenter((i+incr)/2)<<" Mean : "<<f1->GetParameter(1)<<" - Sigma : "<<f1->GetParameter(2)<<endl;
56     if(f1->GetParameter(1)>0.){
57     Float_t fResolution=f1->GetParameter(2)/f1->GetParameter(1);
58     gResolutionVsPt->SetPoint(iPt,hResolutionDistVsGenJetPt->GetXaxis()->GetBinCenter((i+incr)/2),fResolution);
59     Double_t dTempError = ((f1->GetParError(2)*f1->GetParError(2))/(f1->GetParameter(2)*f1->GetParameter(2))) +((f1->GetParError(1)*f1->GetParError(1))/(f1->GetParameter(1)*f1->GetParameter(1)));
60     dTempError = TMath::Sqrt(dTempError);
61     gResolutionVsPt->SetPointError(iPt,0.0,dTempError * fResolution);
62     iPt++;
63     }
64    
65     }
66    
67     gResolutionVsPt->SetMarkerStyle(20);
68     gResolutionVsPt->Draw("P");
69    
70     EventProfile->SetLogx();
71    
72     TLatex *l1 = new TLatex();
73     l1->SetNDC();
74     l1->SetTextFont(42);
75     l1->SetTextSize(0.05);
76     l1->DrawLatex(0.3,0.8,"IterativeCone5 Calo Jets");
77    
78     EventProfile->Print("CaloJetResolution.gif","gif");
79    
80     fInput->Close();
81    
82    
83     }
84    
85    
86     void initFrameProperties(TH1F *hTemp)
87     {
88    
89     hTemp->GetYaxis()->CenterTitle();
90     hTemp->GetXaxis()->CenterTitle();
91     hTemp->GetYaxis()->SetTitleFont(42);
92     hTemp->GetXaxis()->SetTitleFont(42);
93     hTemp->GetYaxis()->SetTitleSize(0.06);
94     hTemp->GetYaxis()->SetTitleOffset(1.4);
95     hTemp->GetXaxis()->SetTitleSize(0.07);
96     hTemp->GetYaxis()->SetLabelFont(42);
97     hTemp->GetXaxis()->SetLabelFont(42);
98     hTemp->GetYaxis()->SetLabelSize(0.04);
99     hTemp->GetXaxis()->SetLabelSize(0.04);
100     hTemp->GetYaxis()->SetDecimals();
101     hTemp->GetXaxis()->SetDecimals();
102     hTemp->GetYaxis()->SetTitle("#sigma_{gaus}(p_{T}^{calo}/p_{T}^{Ref})/<p_{T}^{calo}/p_{T}^{Ref}>");
103     hTemp->GetXaxis()->SetTitle("p_{T}^{ref} GeV/c");
104     }
105