]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/macros/hadEt/CorrPtCut.C
Updating macros for hadronic et
[u/mrichter/AliRoot.git] / PWGLF / totEt / macros / hadEt / CorrPtCut.C
1 //Christine Nattrass, University of Tennessee at Knoxville
2 //This macro is for calculating the correction for the pT cut-off and its systematic error
3 //Uses the output of AliAnalysisTaskHadEt
4 //This is not actually what gets used in the correction class AliAnalysisHadEtCorrections - that is done in the macro GetCorrections.C - but this is useful for making plots and playing around with different options
5
6 float mean=0;
7 float highbound=0;
8 float lowbound=0;
9 float syserr = 0;
10
11 TH1D *GetHisto(float ptcut = 0.15, char *name, char *filename, float etacut){
12   TFile *file = new TFile(filename);
13   TList *list = file->FindObject("out2");
14   //TH2F *allhad = ((TH2F*) out2->FindObject("EtSimulatedAllHadron"))->Clone("allhad");
15   TH2F *allhad = ((TH2F*) out2->FindObject("EtSimulatedChargedHadron"))->Clone("allhad");
16   TH2F *ptlow = ((TH2F*) out2->FindObject("EtSimulatedChargedHadronAssumingNoPt"))->Clone("ptlow");
17   TH2F *pthigh;
18   if(ptcut>0.14){//TPC cut off
19     (TH2F*)pthigh =(TH2F*) ((TH2F*) out2->FindObject("EtSimulatedChargedHadronAssumingPtTPCCut"))->Clone("pthigh");
20   }
21   else{
22     (TH2F*)pthigh =(TH2F*) ((TH2F*) out2->FindObject("EtSimulatedChargedHadronAssumingPtITSCut"))->Clone("pthigh");
23   }
24
25   int lowbin = allhad->GetXaxis()->FindBin(0.0);//make sure we don't accidentally get the wrong bin
26   int highbin = allhad->GetXaxis()->FindBin(ptcut);
27   int nbins = allhad->GetXaxis()->GetNbins();
28   cout<<"Projecting from "<<allhad->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<allhad->GetXaxis()->GetBinLowEdge(highbin+1)<<endl;
29   cout<<"Projecting from "<<allhad->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<allhad->GetXaxis()->GetBinLowEdge(nbins)<<endl;
30
31   //allhad->Sumw2();
32
33
34   TH1D *numerator = allhad->ProjectionY("name",lowbin,highbin);
35   TH1D *denominator = allhad->ProjectionY("denominator",lowbin,nbins);
36   TH1D *numeratorLow = ptlow->ProjectionY("nameLow",lowbin,highbin);
37   TH1D *denominatorLow = allhad->ProjectionY("denominatorLow",highbin,nbins);
38   denominatorLow->Add(ptlow);
39   TH1D *numeratorHigh = pthigh->ProjectionY("nameHigh",lowbin,highbin);
40   TH1D *denominatorHigh = allhad->ProjectionY("denominatorHigh",highbin,nbins);
41   denominatorHigh->Add(pthigh);
42
43   numerator->Divide(denominator);
44   numeratorLow->Divide(denominatorLow);
45   numeratorHigh->Divide(denominatorHigh);
46
47   TF1 *funcLow = new TF1("funcLow","[0]",-.7,.7);
48   funcLow->SetParameter(0,0.01);
49   numeratorLow->Fit(funcLow);
50   TF1 *func = new TF1("func","[0]",-.7,.7);
51   func->SetParameter(0,0.02);
52   numerator->Fit(func);
53   TF1 *funcHigh = new TF1("funcHigh","[0]",-.7,.7);
54   funcHigh->SetParameter(0,0.02);
55   numeratorHigh->Fit(funcHigh);
56
57   mean = 1.0-func->GetParameter(0);
58   lowbound = 1.0-funcHigh->GetParameter(0);
59   highbound = 1.0-funcLow->GetParameter(0);
60   cout<<"fpTcut = "<<mean<<","<<lowbound<<","<<highbound<<endl;
61   cout<<"1/fpTcut = "<<1.0/mean<<","<<1.0/lowbound<<","<<1.0/highbound<<endl;
62   //cout<<"fpTcut = "<<mean<<"-"<<mean-lowbound<<"+"<<highbound-mean<<endl;
63   syserr = highbound-mean;
64   if(mean-lowbound>syserr) syserr = mean-lowbound;
65   cout<<Form("%2.4f^{+%2.4f}_{-%2.4f}",mean,highbound-mean,mean-lowbound)<<endl;
66   cout<<"latex here ";
67   cout<<Form("%2.4f \\pm %2.4f",mean,syserr)<<endl;
68   cout<<"1/fpTcut = "<<1.0/mean<<"+"<<1.0/lowbound-1.0/mean<<"-"<<1.0/mean-1.0/highbound<<endl;
69   numerator->SetYTitle("E_{T}^{had, p_{T}<cut-off}/E_{T}^{had, all p_{T}}");
70   numerator->GetYaxis()->SetTitleOffset(1.);
71   numerator->GetYaxis()->SetTitleSize(0.08);
72   numerator->GetYaxis()->SetLabelSize(0.05);
73   numerator->GetXaxis()->SetTitleSize(0.08);
74   numerator->GetXaxis()->SetLabelSize(0.05);
75   numerator->GetXaxis()->SetTitleOffset(.6);
76   //numerator->Rebin(2);
77   //numerator->Scale(0.5);
78   //numerator->Draw("e");
79   return numerator;
80
81 }
82 void CorrPtCut(char *prodname = "LHC10d4 PYTHIA D6T 7 TeV p+p", char *shortprodname = "LHC10d4", char *filename="Et.ESD.new.sim.LHC10d4.pp.merged.root"){
83
84   gStyle->SetOptTitle(0);
85   gStyle->SetOptStat(0);
86   gStyle->SetOptFit(0);
87   TCanvas *c = new TCanvas("c","c",500,400);
88   c->SetTopMargin(0.04);
89   c->SetRightMargin(0.04);
90   c->SetLeftMargin(0.181452);
91   c->SetBottomMargin(0.134409);
92   c->SetBorderSize(0);
93   c->SetFillColor(0);
94   c->SetFillColor(0);
95   c->SetBorderMode(0);
96   c->SetFrameFillColor(0);
97   c->SetFrameBorderMode(0);
98   float etacut = 0.7;
99   cout<<"Pt cut = 150 MeV/c"<<endl;
100   TH1D *High = GetHisto(0.15-.001,"High",filename,etacut);
101   float tpcHigh=highbound;
102   float tpcLow=lowbound;
103   float tpcsyserr = syserr;
104   float tpcmean = mean;
105   float x1 = High->GetXaxis()->GetBinLowEdge(1);
106   //TBox *tpcBox = new TBox(-x1*.99,1.0-tpcLow,x1*.99,1.0-tpcHigh);
107   TBox *tpcBox = new TBox(-x1*.99,1.0-(mean-syserr),x1*.99,1.0-(mean+syserr));
108   tpcBox->SetFillColor(5);
109   tpcBox->SetLineColor(0);
110   tpcBox->SetFillStyle(1001);
111   cout<<"Pt cut = 100 MeV/c"<<endl;
112   TH1D *Low = GetHisto(0.1-.001,"Low",filename,etacut);
113   float itsHigh=highbound;
114   float itsLow=lowbound;
115   float itssyserr = syserr;
116   float itsmean = mean;
117
118   cout<<Form("dataset & %2.4f \\pm %2.4f &  %2.4f \\pm %2.4f \\",itsmean,itssyserr,tpcmean,tpcsyserr)<<endl;
119   float x = Low->GetXaxis()->GetBinLowEdge(1);
120   //TBox *itsBox = new TBox(-x*.99,1.0-itsLow,x*.99,1.0-itsHigh);
121   TBox *itsBox = new TBox(-x1*.99,1.0-(mean-syserr),x1*.99,1.0-(mean+syserr));
122   itsBox->SetFillColor(5);
123   itsBox->SetLineColor(0);
124   itsBox->SetFillStyle(1001);
125   cout<<"Pt cut = 50 MeV/c"<<endl;
126   TH1D *Lowest = GetHisto(0.05-.001,"Lowest",filename,etacut);
127   TF1 *funcLow = new TF1("funcLow","[0]",-.7,.7);
128   funcLow->SetParameter(0,0.01);
129   Low->Fit(funcLow);
130   TF1 *funcHigh = new TF1("funcHigh","[0]",-.7,.7);
131   funcHigh->SetParameter(0,0.02);
132   High->Fit(funcLow);
133   High->SetMaximum(0.06);
134   High->SetMinimum(0.0);
135   High->SetMarkerColor(2);
136   Low->SetMarkerColor(4);
137   High->SetLineColor(2);
138   Low->SetLineColor(4);
139   High->SetMinimum(0.0);
140   High->SetMarkerStyle(20);
141   Low->SetMarkerStyle(21);
142   Lowest->SetMarkerStyle(22);
143   High->Draw();
144   tpcBox->Draw("f");
145   High->Draw("same");
146   itsBox->Draw("f");
147   //return;
148   Low->Draw("same");
149   //Lowest->Draw("same");
150   TLatex *tex = new TLatex(-0.723444,0.0373593+0.019,prodname);
151   tex->SetTextSize(0.0537634);
152   tex->Draw();
153   TLegend *leg = new TLegend(0.217742,0.696237,0.477823,0.873656);
154   leg->AddEntry(High,"p_{T} cut-off = 0.15 GeV/c");
155   leg->AddEntry(Low,"p_{T} cut-off = 0.1 GeV/c");
156   //leg->AddEntry(Lowest,"p_{T} cut-off = 0.05 GeV/c");
157   leg->SetFillStyle(0);
158   leg->SetFillColor(0);
159   leg->SetBorderSize(0);
160   leg->SetTextSize(0.0537634);
161   leg->Draw();
162   c->SaveAs(Form("pics/%s/fptcut.eps",shortprodname));
163   c->SaveAs(Form("pics/%s/fptcut.png",shortprodname));
164   c->SaveAs(Form("pics/%s/fptcut.pdf",shortprodname));
165 }