]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/PHOSTasks/PHOS_PbPb/macros/production/MakeRawProduction.C
Added more pTbins, fixed a bug in MakeRawProductionAllpPb().
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_PbPb / macros / production / MakeRawProduction.C
CommitLineData
47747ea2 1/* $Id$ */
2
3#include "TFile.h"
6aa36480 4#include "TCanvas.h"
47747ea2 5#include "TDirectory.h"
6#include "TNamed.h"
7#include "TF1.h"
8#include "TAttLine.h"
9#include "TAttMarker.h"
20fb7b55 10#include "TH1.h"
47747ea2 11#include "TH1F.h"
12#include "TH2F.h"
13#include "TSystem.h"
14#include "TStyle.h"
47747ea2 15#include "TMath.h"
16#include "TList.h"
17#include <TString.h>
18#include <TObject.h>
19#include <TROOT.h>
20#include <THashList.h>
21#include <Rtypes.h>
22#include <TPRegexp.h>
23#include "TFitResult.h"
d1f44d99 24#include <TMap.h>
25#include <TObjString.h>
6aa36480 26#include "TPad.h"
20fb7b55 27#include "TAxis.h"
e99d0b36 28#include <TArrayD.h>
29#include <TMath.h>
30#include <TMathBase.h>
47747ea2 31
32namespace RawProduction {
33
a9e9e511 34 bool ignoreErrors = false;
e99d0b36 35 enum CentBinVersion { PbPb1, PbPb2, pPb1 };
36 CentBinVersion centBinVersion = PbPb2; // default
47747ea2 37
38 // Fit range
39 Double_t rangeMin=0.05 ;
40 Double_t rangeMax=0.3 ;
55d70042 41 void FitRanges(double lowerEdge=0, double upperEdge=0);
42
a9e9e511 43
47747ea2 44 // Fit limits
45 double lowerMass = 0.110; double upperMass = 0.145;
46 double lowerWidth = 0.001; double upperWidth = 0.012;
47
04df14a2 48 // Scale integral range
49 double scalarEMBSFrom = 0.2, scalarEMBSTo = 0.4;
9583e896 50 double AFrom = 0.125, ATo = 0.16;
51 double B1From = 0.1, B1To = 0.12;
52 double B2From = 0.2, B2To = 0.25;
53 double GetA(TH1* hist, double from=AFrom, double to=ATo);
54 double GetADiffB(TH1* hist=0, TH1* scaledMixHist=0);
55 double GetP0(TH1* hist=0);
56 double GetP1(TH1* hist=0);
04df14a2 57
47747ea2 58 Double_t PeakPosition(Double_t pt){
59 //Fit to the measured peak position
60 return 4.99292e-003*exp(-pt*9.32300e-001)+1.34944e-001 ;
61 }
62 //-----------------------------------------------------------------------------
63 Double_t PeakWidth(Double_t pt){
64 //fit to the measured peak width
65 Double_t a=0.0068, b=0.0025, c=0.000319 ;
66 return TMath::Sqrt(a*a+b*b/pt/pt+c*c*pt*pt) ;
67 }
68
69 // Pt bin parameters
e0a7b32f 70 Int_t nPtBins=25; //Z PWGGA commenly agreed upon binnings
71 Double_t ptBinEdges[26] = {0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,3.0,3.5,4.0,5.0,6.0,8.0,10.,12.,15.,20.,25.,30.,35.,40.};
e99d0b36 72
296f7669 73 //Double_t ptBinEdges[1000] = {0};
e99d0b36 74 // old:
47747ea2 75 double GetPtBin(int bin);
76 void MakePtBins();
a9e9e511 77
78 // various parameters
47747ea2 79 const Double_t kMean=0.136 ; //Approximate peak position to facilitate error estimate
80 const char format[] = ".pdf"; // say if you want .pdf
a9e9e511 81
47747ea2 82 class Input;
83
e99d0b36 84 TH1* GetHistogram_cent(Input& input, const TString& name, int fromCent, int toCent);
85 TH1* MergeHistogram_cent(Input& input, const TString& name, int fromCent, int toCent, int fromCentIndex, int toCentIndex);
47747ea2 86 int kNCentralityBins = 3;
87
88 Double_t CGausPol1(Double_t * x, Double_t * par);
89 Double_t CGausPol2(Double_t * x, Double_t * par);
90 Double_t CGausPol0(Double_t * x, Double_t * par);
91 Double_t CPol1(Double_t * x, Double_t * par);
92 Double_t CPol2(Double_t * x, Double_t * par);
a9e9e511 93
94
d1f44d99 95 // Output Bin
a53ea5d3 96 class TriggerBin {
d1f44d99 97 public:
a53ea5d3 98 TriggerBin(const TString& trigger = "kCentral" );
99 TriggerBin(const char* trigger);
3374aa5b 100 const TString& Dir() const {return fDir;}
d1f44d99 101 const TString& Key() const {return fKey;}
102 const TString& Trigger() const {return fTrigger;}
a9e9e511 103 protected:
d1f44d99 104 TString fTrigger;
3374aa5b 105 TString fDir;
d1f44d99 106 TString fKey;
107 };
47747ea2 108 // Object describing the input for the macros
109 class Input {
110 public:
a53ea5d3 111 Input(const TString& fileName, const TriggerBin& inputBin, TString listPath = "");
47747ea2 112 TH1 * GetHistogram(const char* name="");
a53ea5d3 113 const TriggerBin& Bin() const {return fBin;}
47747ea2 114 private:
115 static TFile* fFile;
116 TList* fList;
a53ea5d3 117 TriggerBin fBin;
47747ea2 118 };
a9e9e511 119
d1f44d99 120 // Output Bin
a53ea5d3 121 class TriCenPidBin : public TriggerBin {
d1f44d99 122 public:
e99d0b36 123 TriCenPidBin(Int_t centFrom, Int_t centTo, const TString& pid, const TString& trigger);
124 Int_t FromCent() const {return fCentFrom; }
125 Int_t ToCent() const { return fCentTo; }
d1f44d99 126 const TString& PID() const {return fPID;}
127 private:
e99d0b36 128 Int_t fCentFrom;
129 Int_t fCentTo;
d1f44d99 130 TString fPID;
131 };
132 // Object describing the output of the macros
133 class Output {
134 public:
6b5d1b53 135 Output(const TString& fileName = "RawProduction.root", const char* options = "UPDATE");
8375919f 136 ~Output();
a53ea5d3 137 TH1* GetHistogram(const TString& name, const TriggerBin& inBin);
baacba22 138 TH1* GetHistogram(const TString& name);
a53ea5d3 139 void SetDir(const TriggerBin& inBin);
d1f44d99 140 void Write();
141 private:
d1f44d99 142 TFile* fFile;
d1f44d99 143 };
47747ea2 144
5e8d81ec 145 void MakePi0Fit(Input& input, const TriggerBin& outBin, Output& output);
146 void MakePi0FitTCP(Input& input, const TriCenPidBin& outBin, Output& output);
147
148 void MakePi0Fit(Input& input, const TriggerBin& outBin, Output& output) {
296f7669 149 //MakePtBins();
5e8d81ec 150 Printf("\nMakePi0Fit(%s)", outBin.Key().Data());
151 output.SetDir(outBin);
152
153 for(int m1i = 1; m1i <=3; ++m1i) {
154 for(int m2i = m1i; m2i <=3; ++m2i) {
155 TStringToken names("A;M;W;p0;p1;p2", ";");
156 TStringToken titles("Amplitude;Mass;Width;p0;p1;p2", ";");
157 while( names.NextToken() && titles.NextToken() ) {
158 TString name(Form("%s_M%i%i", names.Data(), m1i, m2i));
159 TString title(Form("%s_M%i%i", titles.Data(), m1i, m2i));
160 new TH1D(name.Data(), title.Data(), nPtBins,ptBinEdges);
161 new TH1D(Form("%s_error", name.Data()), title.Data(), nPtBins,ptBinEdges);
162 }
163 }
164 }
165
166 TF1 * pol2Gaus = new TF1("pol2Gaus", CGausPol2, 0., 1., 6);
167 pol2Gaus->SetParNames("A", "m_{0}", "#sigma", "a_{0}", "a_{1}", "a_{2}");
168 for(int m1i = 1; m1i <=3; ++m1i) {
169 for(int m2i = m1i; m2i <=3; ++m2i) {
170 TH2F* hPi0MNN = (TH2F*) input.GetHistogram(Form("hPi0M%i%i", m1i, m2i));
171 for(Int_t ptBin=1; ptBin<=nPtBins; ptBin++){
172 Int_t imin = hPi0MNN->GetYaxis()->FindBin(ptBinEdges[ptBin-1]+0.0001);
173 Int_t imax = hPi0MNN->GetYaxis()->FindBin(ptBinEdges[ptBin]+0.0001) -1;
174 TH1D* hPi0MNNProj = hPi0MNN->ProjectionX(Form("pt%03i_hPi0M%i%i",ptBin, m1i, m2i), imin, imax);
175 hPi0MNNProj->SetTitle(Form("M_{#gamma#gamma}, M%i%i, %.1f<p_{T}<%.1f, %s", m1i, m2i, ptBinEdges[ptBin-1], ptBinEdges[ptBin], outBin.Trigger().Data()));
176 hPi0MNNProj->Sumw2();
177 int entries = hPi0MNNProj->Integral(hPi0MNNProj->FindBin(lowerMass), hPi0MNNProj->FindBin(upperMass));
178 Printf("pt bin %i, %3.1f to %3.1f, entries: %i", ptBin, ptBinEdges[ptBin-1], ptBinEdges[ptBin], entries);
179 if( entries < 10 ) continue;
180
181
182 // Error Fix
183 for(Int_t ib=1; ib<=hPi0MNNProj->GetNbinsX();ib++){if(hPi0MNNProj ->GetBinContent(ib)==0)hPi0MNNProj ->SetBinError(ib,1.);}
184
185 pol2Gaus->SetParameters(entries, 0.134, 0.006, entries, 0, 0);
186 pol2Gaus->SetParLimits(1, lowerMass, upperMass);
187 pol2Gaus->SetParLimits(2, lowerWidth, upperWidth);
188 TFitResultPtr resPtr = hPi0MNNProj->Fit(pol2Gaus, "MSQ", "", rangeMin, rangeMax);
189 Int_t error = int(resPtr) != 4000;
190 error = error || TMath::Abs(pol2Gaus->GetParameter(1) - lowerMass) < 0.0001 || TMath::Abs(pol2Gaus->GetParameter(1) - upperMass) <0.0001;
191 error = error || TMath::Abs(pol2Gaus->GetParameter(2) - lowerWidth) < 0.0001 || TMath::Abs(pol2Gaus->GetParameter(2) - upperWidth) <0.0001;
192
193 if(error) {
194 ((TH1D*) output.GetHistogram(Form("A_M%i%i_error", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(0));
195 ((TH1D*) output.GetHistogram(Form("M_M%i%i_error", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(1));
196 ((TH1D*) output.GetHistogram(Form("W_M%i%i_error", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(2));
197 ((TH1D*) output.GetHistogram(Form("p0_M%i%i_error", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(3));
198 ((TH1D*) output.GetHistogram(Form("p1_M%i%i_error", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(4));
199 ((TH1D*) output.GetHistogram(Form("p2_M%i%i_error", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(5));
200 ((TH1D*) output.GetHistogram(Form("A_M%i%i_error", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(0));
201 ((TH1D*) output.GetHistogram(Form("M_M%i%i_error", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(1));
202 ((TH1D*) output.GetHistogram(Form("W_M%i%i_error", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(2));
203 ((TH1D*) output.GetHistogram(Form("p0_M%i%i_error", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(3));
204 ((TH1D*) output.GetHistogram(Form("p1_M%i%i_error", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(4));
205 ((TH1D*) output.GetHistogram(Form("p2_M%i%i_error", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(5));
206 } else {
207 ((TH1D*) output.GetHistogram(Form("A_M%i%i", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(0));
208 ((TH1D*) output.GetHistogram(Form("M_M%i%i", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(1));
209 ((TH1D*) output.GetHistogram(Form("W_M%i%i", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(2));
210 ((TH1D*) output.GetHistogram(Form("p0_M%i%i", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(3));
211 ((TH1D*) output.GetHistogram(Form("p1_M%i%i", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(4));
212 ((TH1D*) output.GetHistogram(Form("p2_M%i%i", m1i, m2i), outBin))->SetBinContent(ptBin, pol2Gaus->GetParameter(5));
213 ((TH1D*) output.GetHistogram(Form("A_M%i%i", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(0));
214 ((TH1D*) output.GetHistogram(Form("M_M%i%i", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(1));
215 ((TH1D*) output.GetHistogram(Form("W_M%i%i", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(2));
216 ((TH1D*) output.GetHistogram(Form("p0_M%i%i", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(3));
217 ((TH1D*) output.GetHistogram(Form("p1_M%i%i", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(4));
218 ((TH1D*) output.GetHistogram(Form("p2_M%i%i", m1i, m2i), outBin))->SetBinError(ptBin, pol2Gaus->GetParError(5));
219 }
220 }
221 }
222 }
223 }
224 void MakePi0FitTCP(Input& input, const TriCenPidBin& outBin, Output& output) {
296f7669 225 //MakePtBins();
6df36c35 226 Printf("MakePi0FitTCP(%s)", outBin.Key().Data());
6aa36480 227 output.SetDir(outBin);
a9e9e511 228
47747ea2 229 TH1F * hTotSelEvents = (TH1F*) input.GetHistogram("hTotSelEvents");
230 TH2F * hCentrality = (TH2F*) input.GetHistogram("hCenPHOSCells");
231 TH1D * hCentralityX = hCentrality->ProjectionX();
e99d0b36 232 TH2F *hPi0 = (TH2F*)GetHistogram_cent(input, Form("hPi0%s", outBin.PID().Data()), outBin.FromCent(), outBin.ToCent());
233 TH2F *hPi0Mix = (TH2F*)GetHistogram_cent(input, Form("hMiPi0%s", outBin.PID().Data()), outBin.FromCent(), outBin.ToCent());
47747ea2 234
235 printf("TotSelEvents (4): %.0f \n", hTotSelEvents->GetBinContent(4)) ;
236 printf("Centrality: %.0f \n", hCentralityX->Integral()) ;
a9e9e511 237
47747ea2 238 if( !hPi0 || !hPi0Mix ) {
239 Printf(Form("no histogram(0x%p, 0x%p), returning", hPi0, hPi0Mix));
240 return;
241 }
242
243 // for temp convas for drawing/monitoring
6aa36480 244 TCanvas* canvas = new TCanvas("cMakePi0Fit", Form("MakePi0Fit Canvas, %s", outBin.Key().Data()),10,10,1200,800);
a9e9e511 245
246
47747ea2 247 // Peak Parameterization
248 // 1. Linear Bg
249 TF1 * funcRatioFit1 = new TF1("funcRatioFit1",CGausPol1,0.,1.,5) ;
250 funcRatioFit1->SetParNames("A", "m_{0}", "#sigma", "a_{0}", "a_{1}");
251 funcRatioFit1->SetLineWidth(2) ;
252 funcRatioFit1->SetLineColor(2) ;
253 // 2. Quadratic Bg
254 TF1 * funcRatioFit2 = new TF1("funcRatioFit2",CGausPol2,0.,1.,6) ;
255 funcRatioFit2->SetParNames("A", "m_{0}", "#sigma", "a_{0}", "a_{1}", "a_{2}");
256 funcRatioFit2->SetLineWidth(2) ;
257 funcRatioFit2->SetLineColor(4) ;
258 funcRatioFit2->SetLineStyle(2) ;
259 // Other
260 TF1 * fgs = new TF1("gs",CGausPol0,0.,1.,4) ;
261 fgs->SetParNames("A", "m_{0}", "#sigma", "B") ;
262 fgs->SetLineColor(2) ;
263 fgs->SetLineWidth(1) ;
264 TF1 * fbg1 = new TF1("bg1",CPol1,0.,1.,2) ;
265 TF1 * fbg2 = new TF1("bg2",CPol2,0.,1.,3) ;
266
267 // Adding Histograms:
268 // 1. Linear Bg
269 TStringToken names("mr1;mr1r;sr1;sr1r;ar1;br1;yr1;yr1int", ";");
270 TStringToken titles("Mass;Mass, Ratio Fit;Width;Width, Ratio Fit;a;b;Raw Yield; Raw Yield, integrated", ";");
6aa36480 271 while( names.NextToken() && titles.NextToken() ) {
272 new TH1D(names.Data(), titles.Data(), nPtBins,ptBinEdges);
273 new TH1D(Form("%s_error", names.Data()), titles.Data(), nPtBins,ptBinEdges);
274 }
47747ea2 275 // 2. Quadratic Bg
276 TStringToken names2("mr2;mr2r;sr2;sr2r;ar2;br2;cr2;yr2;yr2int", ";");
277 TStringToken titles2("Mass;Mass, Ratio Fit;Width;Width, Ratio Fit;a;b;c;Raw Yield; Raw Yield, integrated", ";");
6aa36480 278 while( names2.NextToken() && titles2.NextToken() ) {
279 new TH1D(names2.Data(), titles2.Data(), nPtBins,ptBinEdges);
280 new TH1D(Form("%s_error", names2.Data()), titles2.Data(), nPtBins,ptBinEdges);
281 }
a9e9e511 282
6aa36480 283 TH1D* hMixRawRatio =new TH1D("hMixRawRatio", "ratio of statistics in RAW and Mixed", nPtBins, ptBinEdges);
a9e9e511 284
47747ea2 285 // Pt slice loop
286 for(Int_t ptBin=1; ptBin<=nPtBins; ptBin++){
287 //gSystem->Sleep(2000);
288 canvas->Clear();
289 canvas->Divide(2,2);
290 canvas->cd(1);
291 printf("pt bin %i, %3.1f to %3.1f, ", ptBin, ptBinEdges[ptBin-1], ptBinEdges[ptBin]);
a9e9e511 292
47747ea2 293 //TList* ptBinOutputList = outputList;
294 TAxis * ptAxis=hPi0->GetYaxis() ;
295 Int_t imin=ptAxis->FindBin(ptBinEdges[ptBin-1]+0.0001);
296 Int_t imax=ptAxis->FindBin(ptBinEdges[ptBin]+0.0001) -1;
297 if( TMath::Abs( ptAxis->GetBinLowEdge(imin) - ptBinEdges[ptBin -1] ) >0.0001 ) {
298 Printf("\nError: hPi0 lower bin edge (%f) different from ptBinEdges lower (%f)", ptAxis->GetBinLowEdge(imin), ptBinEdges[ptBin -1]);
299 continue;
300 }
301 if( TMath::Abs( ptAxis->GetBinLowEdge(imax+1) - ptBinEdges[ptBin] ) >0.0001 ) {
302 Printf("\nError: hPi0 upper bin edge (%f) different from ptBinEdges upper (%f)", ptAxis->GetBinLowEdge(imax+1), ptBinEdges[ptBin]);
303 continue;
304 }
a9e9e511 305
47747ea2 306 Double_t pt=(ptBinEdges[ptBin]+ptBinEdges[ptBin-1])/2. ;
307 Double_t dpt= ptBinEdges[ptBin] - ptBinEdges[ptBin-1];
308
309 TH1D * hPi0Proj = hPi0->ProjectionX(Form("pt%03i_hPi0",ptBin), imin, imax);
310 hPi0Proj->Sumw2();
311 TH1D * hPi0ProjMix= hPi0Mix->ProjectionX(Form("pt%03i_hPi0Mix",ptBin), imin, imax) ;
312 hPi0ProjMix->Sumw2();
a9e9e511 313
47747ea2 314 const Int_t pi0Entries = hPi0Proj->Integral(hPi0Proj->FindBin(lowerMass), hPi0Proj->FindBin(upperMass));
315 const Int_t mixEntries = hPi0ProjMix->Integral(hPi0Proj->FindBin(lowerMass), hPi0Proj->FindBin(upperMass));
6aa36480 316 if( pi0Entries >0) {
317 hMixRawRatio->SetBinContent(ptBin, mixEntries/pi0Entries);
318 hMixRawRatio->SetBinError(ptBin, TMath::Sqrt(mixEntries/pi0Entries/pi0Entries + mixEntries*mixEntries/pi0Entries/pi0Entries/pi0Entries));
319 }
47747ea2 320 printf("statistics in bin is %i, mixed %i, ", pi0Entries, mixEntries);
321 if( pi0Entries < 10 ) {
322 Printf("to few entries");
323 continue;
324 }
a9e9e511 325
47747ea2 326 const bool rebin = pi0Entries < 1000;
327 if( rebin && pi0Entries >= 500 ) {
328 printf("rebin by factor 2, ");
329 hPi0Proj->Rebin(2);
330 hPi0ProjMix->Rebin(2);
331 } else if( rebin && pi0Entries >= 200) {
332 printf("rebin by factor 4, ");
333 hPi0Proj->Rebin(4);
334 hPi0ProjMix->Rebin(4);
335 } else if( rebin && pi0Entries >= 10) {
336 printf("rebin by factor 5, ");
337 hPi0Proj->Rebin(5);
338 hPi0ProjMix->Rebin(5);
339 }
340 std::cout << std::endl;
a9e9e511 341
342 hPi0Proj->SetTitle(Form("M_{#gamma#gamma}, %.1f<p_{T}<%.1f, PID=%s, %s", ptBinEdges[ptBin-1], ptBinEdges[ptBin], outBin.PID().Data(), outBin.Trigger().Data()));
47747ea2 343 hPi0Proj->SetXTitle("M_{#gamma#gamma} (GeV/c^{2})");
a9e9e511 344 hPi0ProjMix->SetTitle(Form("M_{#gamma#gamma}^{Mix}, %.1f<p_{T}<%.1f, PID=%s, %s",ptBinEdges[ptBin-1],ptBinEdges[ptBin],outBin.PID().Data(), outBin.Trigger().Data()));
47747ea2 345 hPi0ProjMix->SetXTitle("M_{#gamma#gamma}^{Mix} (GeV/c^{2})");
346
347
348 // Error Fix
349 for(Int_t ib=1; ib<=hPi0Proj->GetNbinsX();ib++){if(hPi0Proj ->GetBinContent(ib)==0)hPi0Proj ->SetBinError(ib,1.);}
350 for(Int_t ib=1; ib<=hPi0Proj->GetNbinsX();ib++){if(hPi0ProjMix->GetBinContent(ib)==0)hPi0ProjMix->SetBinError(ib,1.);}
a9e9e511 351
47747ea2 352 // Signal-Mix Ratio
353 canvas->cd(2);
354 TH1D * hPi0Ratio = (TH1D*)hPi0Proj->Clone( Form("pt%03i_hPi0Ratio",ptBin) ) ;
355 hPi0Ratio->SetTitle(Form("#frac{M_{#gamma#gamma}}{M_{#gamma#gamma}^{Mix}}, %.1f<p_{T}<%.1f GeV/c", ptBinEdges[ptBin-1], ptBinEdges[ptBin]));
356 hPi0Ratio->Divide(hPi0ProjMix) ;
357 hPi0Ratio->SetMarkerStyle(20) ;
358 hPi0Ratio->SetMarkerSize(0.7) ;
359
55d70042 360 FitRanges(ptBinEdges[ptBin-1],ptBinEdges[ptBin]);//Sets the Fit ranges in the relevant pT bin
a9e9e511 361
47747ea2 362 // ================================================
363 // Fit Pol1 ratio
364 // ================================================
365 printf("Pol1 ratio Fit, ");
366 canvas->cd(2);
a9e9e511 367
9583e896 368 funcRatioFit1->SetParameters(GetADiffB(hPi0Ratio), 0.136, 0.0055, GetP0(hPi0Ratio), GetP1(hPi0Ratio)) ;
47747ea2 369 funcRatioFit1->SetParLimits(0,0.000,1.000) ;
370 funcRatioFit1->SetParLimits(1,lowerMass,upperMass) ;
371 funcRatioFit1->SetParLimits(2,lowerWidth,upperWidth) ;
372
a9e9e511 373
d1f44d99 374 TFitResultPtr ratioFitResultPtr1 = hPi0Ratio->Fit(funcRatioFit1,"MSQ" ,"",rangeMin,rangeMax) ;
47747ea2 375 if( int(ratioFitResultPtr1) % 4000 ) // "More" error is acceptable
d1f44d99 376 ratioFitResultPtr1 = hPi0Ratio->Fit(funcRatioFit1,"MSQ" ,"",rangeMin,rangeMax) ;
47747ea2 377
378 Int_t ratioFitError1 = ratioFitResultPtr1;
379 ratioFitError1 = ratioFitError1 % 4000; // "More" error is acceptable
6aa36480 380 ratioFitError1 = ratioFitError1 || TMath::Abs( funcRatioFit1->GetParameter(1) - lowerMass) < 0.0001 || TMath::Abs( funcRatioFit1->GetParameter(1) - upperMass) < 0.0001;// "center" mass converged to limit
381 ratioFitError1 = ratioFitError1 || funcRatioFit1->GetParError(1) > (upperMass - lowerMass)/2; // to large of an error
382 ratioFitError1 = ratioFitError1 || TMath::Abs( funcRatioFit1->GetParameter(2) - lowerWidth) < 0.0001 || TMath::Abs( funcRatioFit1->GetParameter(2) - upperWidth) < 0.0001;// st. error converged to limit
383 ratioFitError1 = ratioFitError1 || funcRatioFit1->GetParError(2) > (upperWidth - lowerWidth)/2; // to large of an error
a9e9e511 384
47747ea2 385 if( ratioFitError1) {
386 Printf("in ERROR, %i", ratioFitError1);
6aa36480 387 ((TH1D*) output.GetHistogram("mr1r_error", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
388 ((TH1D*) output.GetHistogram("mr1r_error", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
389 ((TH1D*) output.GetHistogram("sr1r_error", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
390 ((TH1D*) output.GetHistogram("sr1r_error", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
391 ((TH1D*) output.GetHistogram("ar1_error", outBin))->SetBinContent(ptBin,funcRatioFit1->GetParameter(3)) ;
392 ((TH1D*) output.GetHistogram("ar1_error", outBin))->SetBinError (ptBin,funcRatioFit1->GetParError(3)) ;
393 ((TH1D*) output.GetHistogram("br1_error", outBin))->SetBinContent(ptBin,funcRatioFit1->GetParameter(4)) ;
394 ((TH1D*) output.GetHistogram("br1_error", outBin))->SetBinError (ptBin,funcRatioFit1->GetParError(4)) ;
a9e9e511 395 }
6aa36480 396 if( !ratioFitError1 || ignoreErrors ) {
47747ea2 397 Printf("converged, status:%i, covMatrixStatus: %i", ratioFitResultPtr1->Status(), ratioFitResultPtr1->CovMatrixStatus());
6aa36480 398 ((TH1D*) output.GetHistogram("mr1r", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
399 ((TH1D*) output.GetHistogram("mr1r", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
400 ((TH1D*) output.GetHistogram("sr1r", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
401 ((TH1D*) output.GetHistogram("sr1r", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
20fb7b55 402 ((TH1D*) output.GetHistogram("ar1", outBin))->SetBinContent(ptBin,funcRatioFit1->GetParameter(3)) ;
403 ((TH1D*) output.GetHistogram("ar1", outBin))->SetBinError (ptBin,funcRatioFit1->GetParError(3)) ;
404 ((TH1D*) output.GetHistogram("br1", outBin))->SetBinContent(ptBin,funcRatioFit1->GetParameter(4)) ;
405 ((TH1D*) output.GetHistogram("br1", outBin))->SetBinError (ptBin,funcRatioFit1->GetParError(4)) ;
47747ea2 406 }
407
a9e9e511 408
409
47747ea2 410 // ================================================
411 // Fit Pol2 ratio
412 // ================================================
413 printf("Pol2 ratio Fit, ");
414 if( ratioFitError1 ) {
9583e896 415 funcRatioFit2->SetParameters(GetADiffB(hPi0Ratio), 0.136, 0.0055, GetP0(hPi0Ratio),GetP1(hPi0Ratio), 0.) ;
47747ea2 416 funcRatioFit2->SetParLimits(0,0.000,1.000) ;
417 funcRatioFit2->SetParLimits(1,lowerMass,upperMass) ;
418 funcRatioFit2->SetParLimits(2,lowerWidth,upperWidth) ;
419 } else {
420 funcRatioFit2->SetParameters(funcRatioFit1->GetParameters()) ;
421 funcRatioFit2->SetParameter(5, 0);
422 funcRatioFit2->SetParLimits(0,0.000,1.000) ;
423 funcRatioFit2->SetParLimits(1,lowerMass,upperMass) ;
424 funcRatioFit2->SetParLimits(2,lowerWidth,upperWidth) ;
425 }
d1f44d99 426 TFitResultPtr ratioFitResultPtr2 = hPi0Ratio->Fit(funcRatioFit2,"+MSQ" ,"",rangeMin,rangeMax) ;
47747ea2 427 if( int(ratioFitResultPtr2) != 4000 ) // if error, "More" error is acceptable
d1f44d99 428 ratioFitResultPtr2 = hPi0Ratio->Fit(funcRatioFit2,"MSQ" ,"",rangeMin,rangeMax) ;
47747ea2 429
430 Int_t ratioFitError2 = ratioFitResultPtr2;
431 ratioFitError2 = ratioFitError2 % 4000; // "More" error is acceptable
6aa36480 432 ratioFitError2 = ratioFitError2 || TMath::Abs( funcRatioFit2->GetParameter(1) - lowerMass) < 0.0001 || TMath::Abs( funcRatioFit2->GetParameter(1) - upperMass) < 0.0001; // "center" mass converged to limit
433 //ratioFitError2 = ratioFitError2 || funcRatioFit2->GetParError(1) > (upperMass - lowerMass)/2; // to large of an error
434 ratioFitError2 = ratioFitError2 || TMath::Abs( funcRatioFit2->GetParameter(2) - lowerWidth) < 0.0001 || TMath::Abs( funcRatioFit2->GetParameter(2) - upperWidth) < 0.0001; // st. error converged to limit
435 //ratioFitError2 = ratioFitError2 || funcRatioFit2->GetParError(2) > (upperWidth - lowerWidth)/2; // to large of an error
47747ea2 436
437 if( ratioFitError2) {
438 Printf("in ERROR, %i", ratioFitError2);
6aa36480 439 ((TH1D*) output.GetHistogram("mr2r_error", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
440 ((TH1D*) output.GetHistogram("mr2r_error", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
441 ((TH1D*) output.GetHistogram("sr2r_error", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
442 ((TH1D*) output.GetHistogram("sr2r_error", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
443 ((TH1D*) output.GetHistogram("ar2_error", outBin))->SetBinContent(ptBin,funcRatioFit2->GetParameter(3)) ;
444 ((TH1D*) output.GetHistogram("ar2_error", outBin))->SetBinError (ptBin,funcRatioFit2->GetParError(3)) ;
445 ((TH1D*) output.GetHistogram("br2_error", outBin))->SetBinContent(ptBin,funcRatioFit2->GetParameter(4)) ;
446 ((TH1D*) output.GetHistogram("br2_error", outBin))->SetBinError (ptBin,funcRatioFit2->GetParError(4)) ;
447 ((TH1D*) output.GetHistogram("cr2_error", outBin))->SetBinContent(ptBin,funcRatioFit2->GetParameter(5)) ;
448 ((TH1D*) output.GetHistogram("cr2_error", outBin))->SetBinError (ptBin,funcRatioFit2->GetParError(5)) ;
a9e9e511 449 }
6aa36480 450 if( !ratioFitError2 || ignoreErrors ) {
47747ea2 451 Printf("converged, status:%i, covMatrixStatus: %i", ratioFitResultPtr2->Status(), ratioFitResultPtr2->CovMatrixStatus());
6aa36480 452 ((TH1D*) output.GetHistogram("mr2r", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
453 ((TH1D*) output.GetHistogram("mr2r", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
454 ((TH1D*) output.GetHistogram("sr2r", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
455 ((TH1D*) output.GetHistogram("sr2r", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
20fb7b55 456 ((TH1D*) output.GetHistogram("ar2", outBin))->SetBinContent(ptBin,funcRatioFit2->GetParameter(3)) ;
457 ((TH1D*) output.GetHistogram("ar2", outBin))->SetBinError (ptBin,funcRatioFit2->GetParError(3)) ;
458 ((TH1D*) output.GetHistogram("br2", outBin))->SetBinContent(ptBin,funcRatioFit2->GetParameter(4)) ;
459 ((TH1D*) output.GetHistogram("br2", outBin))->SetBinError (ptBin,funcRatioFit2->GetParError(4)) ;
460 ((TH1D*) output.GetHistogram("cr2", outBin))->SetBinContent(ptBin,funcRatioFit2->GetParameter(5)) ;
461 ((TH1D*) output.GetHistogram("cr2", outBin))->SetBinError (ptBin,funcRatioFit2->GetParError(5)) ;
47747ea2 462 }
47747ea2 463
a9e9e511 464
465
47747ea2 466 // ================================================
467 // Plot Ratio Fits
468 // ================================================
469 hPi0Ratio->GetXaxis()->SetRangeUser(rangeMin, rangeMax);
470 hPi0Ratio->Draw();
471 canvas->Update();
472
473
a9e9e511 474
47747ea2 475 // ================================================
476 // Pol1 Scaled Background Subtraction
477 // ================================================
478 canvas->cd(3);
479 Double_t intRangeMin = PeakPosition(pt)-3.*PeakWidth(pt) ;
480 Double_t intRangeMax = PeakPosition(pt)+3.*PeakWidth(pt) ;
481 Int_t intBinMin = hPi0Proj->GetXaxis()->FindBin(intRangeMin) ;
482 Int_t intBinMax = hPi0Proj->GetXaxis()->FindBin(intRangeMax) ;
483 Double_t mixInt = hPi0ProjMix->Integral(intBinMin,intBinMax);
484
6aa36480 485 if( ! ratioFitError1 || true) {
47747ea2 486 printf("Pol1 BS Fit, ");
487 TH1D * hPi0MixScaledPol1 = (TH1D*)hPi0ProjMix->Clone(Form("pt%03i_hPi0MixScaledPol1", ptBin)) ;
488 TH1D * hPi0BSPol1 = (TH1D*)hPi0Proj->Clone(Form("pt%03i_hPi0BSPol1", ptBin)) ;
489
490 // Scale Mix by linear part of ratio, yielding approx background
491 fbg1->SetParameters(funcRatioFit1->GetParameter(3), funcRatioFit1->GetParameter(4));
492 hPi0MixScaledPol1 ->Multiply(fbg1) ;
493 hPi0BSPol1->Add(hPi0MixScaledPol1 ,-1.) ;
494
e99d0b36 495 //Int_t binPi0 = hPi0BSPol1->FindBin(funcRatioFit1->GetParameter(1));
496 //Int_t nWidPi0 = 2 * (Int_t) (funcRatioFit1->GetParameter(2)/hPi0BSPol1->GetBinWidth(1));
497 //Int_t integral = TMath::Abs(hPi0BSPol1->Integral(binPi0-nWidPi0,binPi0+nWidPi0));
9583e896 498 fgs->SetParameters(GetADiffB(hPi0BSPol1), funcRatioFit1->GetParameter(1), funcRatioFit1->GetParameter(2)) ;
47747ea2 499 fgs->SetParLimits(0,0.,pi0Entries) ;
500 fgs->SetParLimits(1,lowerMass,upperMass) ;
501 fgs->SetParLimits(2,lowerWidth,upperWidth) ;
502
503 // Fit
d1f44d99 504 TFitResultPtr bs1FitResultPtr = hPi0BSPol1->Fit(fgs,"MSQ","",rangeMin,rangeMax) ;
47747ea2 505 if( int(bs1FitResultPtr) != 4000 ) // if error, "More" error is acceptable
d1f44d99 506 bs1FitResultPtr = hPi0BSPol1->Fit(fgs,"MSQ","",rangeMin,rangeMax) ;
a9e9e511 507
47747ea2 508 Int_t bs1FitError = bs1FitResultPtr;
509 bs1FitError = bs1FitError % 4000; // "More" error is acceptable
6aa36480 510 bs1FitError = bs1FitError || TMath::Abs( fgs->GetParameter(1) - lowerMass) < 0.0001 || TMath::Abs( fgs->GetParameter(1) - upperMass) < 0.0001; // "center" mass converged to limit
511 //bs1FitError = bs1FitError || fgs->GetParError(1) > (upperMass - lowerMass)/2; // to large of an error
512 bs1FitError = bs1FitError || TMath::Abs( fgs->GetParameter(2) - lowerWidth) < 0.0001 || TMath::Abs( fgs->GetParameter(2) - upperWidth) < 0.0001; // st. error converged to limit
513 //bs1FitError = bs1FitError || fgs->GetParError(2) > (upperWidth - lowerWidth)/2; // to large of an error
47747ea2 514
6aa36480 515 Double_t y=fgs->GetParameter(0)/hPi0BSPol1->GetXaxis()->GetBinWidth(1) ;
516 Double_t ey=fgs->GetParError(0)/hPi0BSPol1->GetXaxis()->GetBinWidth(1) ;
517 Double_t npiInt = hPi0BSPol1->Integral(intBinMin,intBinMax) ;
518 Double_t norm = fbg1->GetParameter(0) ;
519 Double_t normErr= fbg1->GetParError(0) ;
47747ea2 520 if( bs1FitError) {
521 Printf("in ERROR, %i", bs1FitError);
6aa36480 522 ((TH1D*) output.GetHistogram("mr1_error", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
523 ((TH1D*) output.GetHistogram("mr1_error", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
524 ((TH1D*) output.GetHistogram("sr1_error", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
525 ((TH1D*) output.GetHistogram("sr1_error", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
526
6139ccc1 527 ((TH1D*) output.GetHistogram("yr1_error", outBin))->SetBinContent(ptBin,y/dpt/pt) ;
528 ((TH1D*) output.GetHistogram("yr1_error", outBin))->SetBinError(ptBin,ey/dpt/pt) ;
6aa36480 529 if(npiInt>0.){
6139ccc1 530 ((TH1D*) output.GetHistogram("yr1int_error", outBin))->SetBinContent(ptBin,npiInt/dpt/pt) ;
531 ((TH1D*) output.GetHistogram("yr1int_error", outBin))->SetBinError(ptBin,TMath::Sqrt(npiInt + norm*mixInt + normErr*normErr*mixInt*mixInt + norm*norm*mixInt)/dpt/pt) ;
6aa36480 532 }
a9e9e511 533 }
6aa36480 534 if( !bs1FitError || ignoreErrors ) {
47747ea2 535 Printf("converged, status:%i, covMatrixStatus: %i", bs1FitResultPtr->Status(), bs1FitResultPtr->CovMatrixStatus());
20fb7b55 536 ((TH1D*) output.GetHistogram("mr1", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
537 ((TH1D*) output.GetHistogram("mr1", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
538 ((TH1D*) output.GetHistogram("sr1", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
539 ((TH1D*) output.GetHistogram("sr1", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
47747ea2 540
6139ccc1 541 ((TH1D*) output.GetHistogram("yr1", outBin))->SetBinContent(ptBin,y/dpt/pt) ;
542 ((TH1D*) output.GetHistogram("yr1", outBin))->SetBinError(ptBin,ey/dpt/pt) ;
47747ea2 543 if(npiInt>0.){
6139ccc1 544 ((TH1D*) output.GetHistogram("yr1int", outBin))->SetBinContent(ptBin,npiInt/dpt/pt) ;
545 ((TH1D*) output.GetHistogram("yr1int", outBin))->SetBinError(ptBin,TMath::Sqrt(npiInt + norm*mixInt + normErr*normErr*mixInt*mixInt + norm*norm*mixInt)/dpt/pt) ;
47747ea2 546 // maybe we should use TH1::IntegralAndError
547 }
548 }
549 // Ploting
550 hPi0BSPol1->SetAxisRange(rangeMin, rangeMax);
551 hPi0BSPol1->SetMaximum(hPi0BSPol1->GetMaximum()*1.5) ;
552 hPi0BSPol1->SetMinimum(hPi0BSPol1->GetMinimum()*0.9) ;
553 hPi0BSPol1->SetMarkerStyle(20) ;
554 hPi0BSPol1->SetMarkerSize(0.7) ;
555 hPi0BSPol1->Draw();
556 canvas->Update();
557 //printf("end pt");
558 }
a9e9e511 559
560
47747ea2 561 // ================================================
a9e9e511 562 // Pol2 Scaled Background Subtraction
47747ea2 563 // ================================================
564 canvas->cd(4);
565 fbg2->SetParameters(funcRatioFit2->GetParameter(3),funcRatioFit2->GetParameter(4),funcRatioFit2->GetParameter(5));
6aa36480 566 if( ! ratioFitError2 || true) {
47747ea2 567 printf("Pol1 Scaled Background Subtraction, ");
568 TH1D * hPi0MixScaledPol2 = (TH1D*)hPi0ProjMix->Clone(Form("pt%03i_hPi0MixScaledPol2", ptBin)) ;
569 TH1D * hPi0BSPol2 = (TH1D*)hPi0Proj ->Clone(Form("pt%03i_hPi0BSPol2", ptBin)) ;
a9e9e511 570
47747ea2 571 hPi0MixScaledPol2->Multiply(fbg2) ;
572 hPi0BSPol2 ->Add(hPi0MixScaledPol2,-1.) ;
6aa36480 573 hPi0BSPol2->SetOption();
47747ea2 574
e99d0b36 575// Int_t binPi0 = hPi0BSPol2->FindBin(funcRatioFit2->GetParameter(1));
576// Int_t nWidPi0 = 2 * (Int_t) (funcRatioFit2->GetParameter(2)/hPi0BSPol2->GetBinWidth(1));
577// Int_t integral = TMath::Abs(hPi0BSPol2->Integral(binPi0-nWidPi0,binPi0+nWidPi0));
9583e896 578 fgs->SetParameters(GetADiffB(hPi0BSPol2), funcRatioFit2->GetParameter(1), funcRatioFit2->GetParameter(2)) ;
47747ea2 579 fgs->SetParLimits(0,0.,pi0Entries) ;
580 fgs->SetParLimits(1,lowerMass,upperMass) ;
581 fgs->SetParLimits(2,lowerWidth,upperWidth) ;
582
583 // Fit
d1f44d99 584 TFitResultPtr bs2FitResultPtr = hPi0BSPol2->Fit(fgs,"MSQ","",rangeMin,rangeMax) ;
47747ea2 585 if( int(bs2FitResultPtr) != 4000 ) // if error, "More" error is acceptable
d1f44d99 586 bs2FitResultPtr = hPi0BSPol2->Fit(fgs,"MSQ","",rangeMin,rangeMax) ;
a9e9e511 587
47747ea2 588 Int_t bs2FitError = bs2FitResultPtr;
589 bs2FitError = bs2FitError % 4000; // "More" error is acceptable
6aa36480 590 bs2FitError = bs2FitError || TMath::Abs( fgs->GetParameter(1) - lowerMass) < 0.0001 || TMath::Abs( fgs->GetParameter(1) - upperMass) < 0.0001; // "center" mass converged to limit
47747ea2 591// bs2FitError = bs2FitError || fgs->GetParError(1) > (upperMass - lowerMass)/2; // to large of an error
6aa36480 592 bs2FitError = bs2FitError || TMath::Abs( fgs->GetParameter(2) - lowerWidth) < 0.0001 || TMath::Abs( fgs->GetParameter(2) - upperWidth) < 0.0001; // st. error converged to limit
47747ea2 593// bs2FitError = bs2FitError || fgs->GetParError(2) > (upperWidth - lowerWidth)/2; // to large of an error
594
6aa36480 595 Double_t y=fgs->GetParameter(0)/hPi0BSPol2->GetXaxis()->GetBinWidth(1) ;
596 Double_t ey=fgs->GetParError(0)/hPi0BSPol2->GetXaxis()->GetBinWidth(1) ;
597 Double_t npiInt = hPi0BSPol2->Integral(intBinMin,intBinMax) ;
598 Double_t norm = fbg2->GetParameter(0) ;
599 Double_t normErr= fbg2->GetParError(0) ;
47747ea2 600 if( bs2FitError ) {
601 Printf("in ERROR, %i", bs2FitError);
6aa36480 602 ((TH1D*) output.GetHistogram("mr2_error", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
603 ((TH1D*) output.GetHistogram("mr2_error", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
604 ((TH1D*) output.GetHistogram("sr2_error", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
605 ((TH1D*) output.GetHistogram("sr2_error", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
606
6139ccc1 607 ((TH1D*) output.GetHistogram("yr2_error", outBin))->SetBinContent(ptBin,y/dpt/pt) ;
608 ((TH1D*) output.GetHistogram("yr2_error", outBin))->SetBinError(ptBin,ey/dpt/pt) ;
6aa36480 609 if(npiInt>0.){
6139ccc1 610 ((TH1D*) output.GetHistogram("yr2int_error", outBin))->SetBinContent(ptBin,npiInt/dpt/pt) ;
611 ((TH1D*) output.GetHistogram("yr2int_error", outBin))->SetBinError(ptBin,TMath::Sqrt(npiInt + norm*mixInt + normErr*normErr*mixInt*mixInt + norm*norm*mixInt)/dpt/pt) ;
6aa36480 612 // maybe we should use TH1::IntegralAndError
613 }
a9e9e511 614 }
6aa36480 615 if( !bs2FitError || ignoreErrors ) {
47747ea2 616 Printf("converged, status:%i, covMatrixStatus: %i", bs2FitResultPtr->Status(), bs2FitResultPtr->CovMatrixStatus());
20fb7b55 617 ((TH1D*) output.GetHistogram("mr2", outBin))->SetBinContent(ptBin,fgs->GetParameter(1)) ;
618 ((TH1D*) output.GetHistogram("mr2", outBin))->SetBinError (ptBin,fgs->GetParError(1) ) ;
619 ((TH1D*) output.GetHistogram("sr2", outBin))->SetBinContent(ptBin,TMath::Abs(fgs->GetParameter(2))) ;
620 ((TH1D*) output.GetHistogram("sr2", outBin))->SetBinError (ptBin,fgs->GetParError(2) ) ;
47747ea2 621
6139ccc1 622 ((TH1D*) output.GetHistogram("yr2", outBin))->SetBinContent(ptBin,y/dpt/pt) ;
623 ((TH1D*) output.GetHistogram("yr2", outBin))->SetBinError(ptBin,ey/dpt/pt) ;
47747ea2 624 if(npiInt>0.){
6139ccc1 625 ((TH1D*) output.GetHistogram("yr2int", outBin))->SetBinContent(ptBin,npiInt/dpt/pt) ;
626 ((TH1D*) output.GetHistogram("yr2int", outBin))->SetBinError(ptBin,TMath::Sqrt(npiInt + norm*mixInt + normErr*normErr*mixInt*mixInt + norm*norm*mixInt)/dpt/pt) ;
47747ea2 627 // maybe we should use TH1::IntegralAndError
628 }
629 }
630 // Plotting
631 hPi0BSPol2->SetAxisRange(rangeMin, rangeMax);
632 hPi0BSPol2->SetMaximum(hPi0BSPol2->GetMaximum()*1.5) ;
633 hPi0BSPol2->SetMinimum(hPi0BSPol2->GetMinimum()*0.9) ;
634 hPi0BSPol2->SetMarkerStyle(20) ;
635 hPi0BSPol2->SetMarkerSize(0.7) ;
636 hPi0BSPol2->Draw();
637 canvas->Update();
638
639 }
a9e9e511 640
47747ea2 641 canvas->cd(1);
642 TH1D * hPi0MixScaled = (TH1D*)hPi0ProjMix ->Clone(Form("%sScaled", hPi0Proj->GetName())) ;
04df14a2 643 int fromBin = hPi0Proj->FindBin(scalarEMBSFrom);
644 int toBin = TMath::Min(hPi0Proj->FindBin(scalarEMBSTo), hPi0Proj->GetNbinsX());
645 Double_t scalar = hPi0Proj->Integral(fromBin, toBin) / hPi0ProjMix->Integral(fromBin, toBin);
646 hPi0MixScaled->Scale(scalar);
47747ea2 647 hPi0MixScaled->SetLineColor(kRed);
648 hPi0MixScaled->SetTitle(Form("%s, Scaled", hPi0Proj->GetName()));
649 hPi0Proj->SetAxisRange(rangeMin, 1.);
47747ea2 650 hPi0Proj->Draw();
651 hPi0MixScaled->Draw("same");
a9e9e511 652
47747ea2 653 canvas->Update();
a9e9e511 654
20fb7b55 655 canvas->Print(Form("imgs/%s_ptBin:%03i.pdf", outBin.Key().Data(), ptBin));
656 canvas->Print(Form("imgs/%s_ptBin:%03i.png", outBin.Key().Data(), ptBin));
a9e9e511 657
47747ea2 658 std::cout << std::endl;
659 }// end of Pt slice loop
660
661
662 //Normalize by the number of events
e99d0b36 663 Int_t cMin=outBin.FromCent();
664 Int_t cMax=outBin.ToCent();
47747ea2 665 Double_t nevents = hCentralityX->Integral(cMin,cMax);
e99d0b36 666
47747ea2 667 if ( nevents > 0.9 ) {
6139ccc1 668 TStringToken yhists("yr1 yr1int yr2 yr2int yr1_error yr1int_error yr2_error yr2int_error", " ");
669 while( yhists.NextToken() ) {
670 ((TH1D*) output.GetHistogram(yhists.Data(), outBin))->Scale(1./nevents) ;
671 ((TH1D*) output.GetHistogram(yhists.Data(), outBin))->GetYaxis()->SetTitle("#frac{dN^{RAW}_{#pi^{0}}}{p_{T}dp_{T} N_{ev}}");
672 }
47747ea2 673 } else {
674 Printf("WARNING: non positive nEvents in centrality range, cMin:%d, cMax:%d, nEvents:%f", cMin, cMax, nevents );
675
676 }
677
a9e9e511 678
47747ea2 679 // store to file
680 // TFile* outputFile = TFile::Open(saveToFileName.Data(), "UPDATE");
681 //outputList->Write(input.KeySuggestion(), TObject::kSingleKey);
682 //outputList->Write();
20fb7b55 683// outputFile->Write();
684// outputFile->Close();
685// delete outputFile;
47747ea2 686 // delete list and content from memory
687 //outputList->SetOwner(kTRUE);
688 //outputList->Delete("slow");
689 //delete outputList;
20fb7b55 690 //output.Write();
6aa36480 691 delete canvas;
47747ea2 692 }
693
9583e896 694 double GetA(TH1* hist, double from, double to)
695 {
696 int fbin = hist->FindBin(from);
697 if( from > (hist->GetBinLowEdge(fbin)+hist->GetBinLowEdge(fbin+1)) )
698 fbin=fbin+1;
699 int tbin = hist->FindBin(to);
700 if( to < (hist->GetBinLowEdge(tbin)+hist->GetBinLowEdge(tbin+1)) )
701 tbin=tbin-1;
702 double integer = hist->Integral(fbin, tbin);
703 return integer/(tbin-fbin+1);
704 }
705
706 double GetADiffB(TH1* hist, TH1* mixHist)
707 {
708 double rawSig = GetA(hist);
709 // If we have SCALED Event Mixing Histogram
710 if(mixHist) {
711 double mixSig = GetA(mixHist);
712 double A = TMath::Abs(rawSig - mixSig );
713 return A;
714 }
715 // else, interpolate between B1 and B2.
716 double background = GetP0(hist)*(ATo-AFrom) + GetP1(hist)*(ATo*ATo-AFrom*AFrom)/2;
717 double A = GetA(hist);
718 return TMath::Abs(A-background);
719 }
720
721 double GetP0(TH1* hist)
722 {
723 double b1=GetA(hist,B1From,B1To)*(B1To-B1From);
724 double b2=GetA(hist,B2From,B2To)*(B2To-B2From);
725 double a11 = B1To - B1From;
726 double a12 = (B1To*B1To - B1From*B1From)/2;
727 double a21 = B2To - B2From;
728 double a22 = (B2To*B2To - B2From*B2From)/2;
729 return (a22*b1-a12*b2)/(a11*a22-a12*a21);
730 }
731 double GetP1(TH1* hist)
732 {
733 double b1=GetA(hist,B1From,B1To)*(B1To-B1From);
734 double b2=GetA(hist,B2From,B2To)*(B2To-B2From);
735 double a11 = B1To - B1From;
736 double a12 = (B1To*B1To - B1From*B1From)/2;
737 double a21 = B2To - B2From;
738 double a22 = (B2To*B2To - B2From*B2From)/2;
739 return (-a21*b1+a11*b2)/(a11*a22-a12*a21);
740 }
741
47747ea2 742
743 //-----------------------------------------------------------------------------
744 double GetPtBin(int bin){
745 // recusive function used by MakePtBins
746
747 if( bin==0 )
748 return 1.;
749
750 // return GetPtBin(bin-1) * 1.1;
751
752 // if ( bin % 2 )
753 // return GetPtBin(bin-1) + 0.4;
754 // else
755 // return GetPtBin(bin-1) + 0.2;
756
757 double previousBin = GetPtBin(bin-1);
758 double linInc = 1.;
759 double threshold = 5.;
760 double logFact = 1 + linInc/threshold;
761 if ( previousBin < threshold ) // linear
762 return double(int((previousBin + linInc)*10))/10;
763 else { // logarithmic
764 return double(int((previousBin * logFact)*10))/10;
765 }
766 }
767
768 //-----------------------------------------------------------------------------
769 void MakePtBins() {
770 // function for setting Pt bins
771
772 int bin = -1;
773 do {
774 ++bin;
775 ptBinEdges[bin] = GetPtBin(bin);
776 } while(ptBinEdges[bin] < 40.);
777 nPtBins = bin -2;
778
779 printf("Making Pt Bins:\n");
780 for(int b=0; b < nPtBins+1; ++b)
781 printf("%.1f, ", ptBinEdges[b]);
782 printf("\n N. Bins: %d\n", nPtBins);
783
784
785 // for(int bin = 0; bin <= nPtBins; ++bin){
786 // ptBinEdges[bin] = GetPtBin(bin);
787 // printf("%.1f, ", ptBinEdges[bin]);
788 // }
789 // printf("\n");
790 }
791
792 //-----------------------------------------------------------------------------
793 Double_t CGausPol1(Double_t * x, Double_t * par){
794 //Parameterization of Real/Mixed ratio
795 Double_t m=par[1] ;
796 Double_t s=par[2] ;
797 Double_t dx=(x[0]-m)/s ;
798 return par[0]*exp(-dx*dx/2.)+par[3]+par[4]*(x[0]-kMean) ;
799 }
800
801 //-----------------------------------------------------------------------------
802 Double_t CGausPol2(Double_t * x, Double_t * par){
803 //Another parameterization of Real/Mixed ratio7TeV/README
804 Double_t m=par[1] ;
805 Double_t s=par[2] ;
806 Double_t dx=(x[0]-m)/s ;
807 return par[0]*exp(-dx*dx/2.)+par[3]+par[4]*(x[0]-kMean)+par[5]*(x[0]-kMean)*(x[0]-kMean) ;
808 }
809 //-----------------------------------------------------------------------------
810 Double_t CGausPol0(Double_t * x, Double_t * par){
811 //Parameterizatin of signal
812 Double_t m=par[1] ;
813 Double_t s=par[2] ;
814 Double_t dx=(x[0]-m)/s ;
815 return par[0]*exp(-dx*dx/2.)/TMath::Sqrt(TMath::TwoPi())/s+par[3] ;
816 }
817 //-----------------------------------------------------------------------------
818 Double_t CPol1(Double_t * x, Double_t * par){
819 //Normalizatino of Mixed
820 return par[0]+par[1]*(x[0]-kMean) ;
821 }
822 //-----------------------------------------------------------------------------
823 Double_t CPol2(Double_t * x, Double_t * par){
824 //Another normalization of Mixed
825 return par[0]+par[1]*(x[0]-kMean)+par[2]*(x[0]-kMean)*(x[0]-kMean) ;
826 }
827
a9e9e511 828
47747ea2 829 // Input Definitions
830 TFile* Input::fFile = 0;
a9e9e511 831 Input::Input(const TString& fileName, const RawProduction::TriggerBin& inputBin, TString listPath)
d1f44d99 832 : fList(0x0), fBin(inputBin.Trigger())
47747ea2 833 {
834 // File
835 if(fFile && !fileName.EqualTo(fFile->GetName())){
836 fFile->Close();
837 delete fFile;
838 fFile = 0x0;
8f90c6d5 839 }
840
841 if(! fFile) {
47747ea2 842 Printf("Opening %s", fileName.Data());
a9e9e511 843 fFile = TFile::Open(fileName.Data(), "READ");
47747ea2 844 }
a9e9e511 845
47747ea2 846 if( listPath.EqualTo("") ) {
847 char cstr[256] = "";
53d92dab 848 if( pPb1 == centBinVersion ) {
849 sprintf(cstr, "PHOSPi0pPb_%s/PHOSPi0pPb_%sCoutput1", fBin.Trigger().Data(), fBin.Trigger().Data());
850 }
851 if(PbPb1 == centBinVersion || PbPb2 == centBinVersion ){
852 sprintf(cstr, "PHOSPi0Flow_%s/PHOSPi0Flow_%sCoutput1", fBin.Trigger().Data(), fBin.Trigger().Data());
853 }
47747ea2 854 listPath = cstr;
855 }
a9e9e511 856
47747ea2 857 Printf("Getting list, %s", listPath.Data());
858 fFile->GetObject(listPath.Data(), fList);
a9e9e511 859 if( !fList )
47747ea2 860 Printf("ERROR: list not found");
861 }
a9e9e511 862
47747ea2 863 TH1* Input::GetHistogram(const char* name){
864 TObject* obj = fList->FindObject(name);
865 TH1* hist = dynamic_cast<TH1*> (obj);
866 if( ! hist)
867 Printf("MakePi0FitInput::GetHistogram: Error, could not find object of name: %s or cast to hist", name);
868 return hist;
869 }
870
d1f44d99 871 //OutputBin Definitions
a53ea5d3 872 TriggerBin::TriggerBin(const TString& trigger)
3374aa5b 873 : fTrigger(trigger), fDir(trigger), fKey(trigger)
d1f44d99 874 { }
875
a53ea5d3 876 TriggerBin::TriggerBin(const char* trigger)
3374aa5b 877 : fTrigger(trigger), fDir(trigger), fKey(trigger)
d1f44d99 878 { }
879
e99d0b36 880 TriCenPidBin::TriCenPidBin(Int_t centFrom, Int_t centTo, const TString& pid, const TString& trigger)
881 : TriggerBin(trigger), fCentFrom(centFrom), fCentTo(centTo), fPID(pid)
d1f44d99 882 {
e99d0b36 883 fDir.Form("%s/c%02i-%02i/%s", trigger.Data(), centFrom, fCentTo, pid.Data());
884 fKey.Form("%s_c%02i-%02i_%s", trigger.Data(), centFrom, fCentTo, pid.Data());
d1f44d99 885 }
886
887 Output::Output(const TString& fileName, const char* options)
6aa36480 888 : fFile(0x0)
d1f44d99 889 {
6df36c35 890 TDirectory* priorDir = gDirectory;
d1f44d99 891 fFile = TFile::Open(fileName.Data(), options);
6df36c35 892 priorDir->cd();
d1f44d99 893 }
8375919f 894 Output::~Output()
895 {
4a78c315 896 if( fFile )
897 fFile->DeleteAll();
8375919f 898 delete fFile;
899 }
900
a9e9e511 901
a53ea5d3 902 void Output::SetDir(const TriggerBin& inBin)
d1f44d99 903 {
3374aa5b 904 TDirectory* dir = (TDirectoryFile*) fFile;
905 TStringToken dirs(inBin.Dir(), "/");
906 while( dirs.NextToken() ) {
907 Printf("%s", dirs.Data());
908 TDirectory* ndir = dir->GetDirectory(dirs.Data());
909 if(!ndir)
910 dir = dir->mkdir(dirs.Data());
911 else
912 dir = ndir;
d1f44d99 913 }
3374aa5b 914 dir->cd();
d1f44d99 915 }
a9e9e511 916
a53ea5d3 917 TH1* Output::GetHistogram(const TString& name, const RawProduction::TriggerBin& inBin)
d1f44d99 918 {
3374aa5b 919 TDirectory* dir = fFile->GetDirectory(inBin.Dir().Data(), true);
a9e9e511 920 TH1* hist = dynamic_cast<TH1*>( dir->Get(name.Data()) );
d1f44d99 921 if( hist )
922 return hist;
923 else {
a53ea5d3 924 Printf("ERROR: Output::GetHistogram: %s could not be found", name.Data());
d1f44d99 925 return 0x0;
926 }
927 }
baacba22 928
929 TH1* Output::GetHistogram(const TString& name) {
930 TH1* hist = dynamic_cast<TH1*>( fFile->Get(name.Data()) );
931 if( hist )
932 return hist;
933 else {
934 Printf("ERROR: Output::GetHistogram: %s could not be found", name.Data());
935 return 0x0;
936 }
937 }
938
6aa36480 939
940
d1f44d99 941
942 void Output::Write()
943 {
6aa36480 944 fFile->Write();
d1f44d99 945 }
946
e99d0b36 947 const TArrayD& GetBinEdges( const TString& trigger )
47747ea2 948 {
e99d0b36 949 static TArrayD binEdges;
950
951 if( pPb1 == centBinVersion ) {
952 const int nbins = 5;
953 Double_t cbin[nbins+1] = {0., 20., 40., 60., 80., 100.};
954 binEdges = TArrayD(nbins+1, cbin);
955 }
956 if( PbPb2 == centBinVersion ) {
957 if ( trigger.EqualTo("kCentral") ) {
958 const int nbins = 4;
959 Double_t cbin[nbins+1] = {0., 5., 8., 9., 10.};
960 binEdges = TArrayD(nbins+1, cbin);
961 }
962 else if ( trigger.EqualTo("kSemiCentral") ) {
963 const int nbins = 8;
964 Double_t cbin[nbins+1] = {10., 11., 12., 13., 15., 20., 30., 40., 50.};
965 binEdges = TArrayD(nbins+1, cbin);
966 }
967 else if( trigger.EqualTo("kMB") || trigger.EqualTo("kPHOSPb") ) {
968 const int nbins = 8;
969 Double_t cbin[nbins+1] = {0., 10., 20., 30., 40., 50., 60., 70., 80.};
970 binEdges = TArrayD(nbins+1, cbin);
971 }
972 }
973 if ( PbPb1 == centBinVersion ) {
974 Printf("ERROR:GetBinEdges PbPb1 no longer in use!");
47747ea2 975 }
e99d0b36 976
977 return binEdges;
978 }
979
55d70042 980 void FitRanges(double lowerEdge, double upperEdge)
981 {
982 if(PbPb1 == centBinVersion || PbPb2 == centBinVersion )
983 {
984 if( upperEdge < 2.1 ) {
985 rangeMin = 0.1;
986 rangeMax = 0.2;
987 } else if( upperEdge < 3.1 ) {
988 rangeMin = 0.08;
989 rangeMax = 0.22;
990 } else if( upperEdge < 5.1 ) {
991 rangeMin = 0.08;
992 rangeMax = 0.25;
993 } else if( upperEdge < 10.1 ) {
994 rangeMin = 0.07;
995 rangeMax = 0.3;
996 } else {
997 rangeMin = 0.05;
998 rangeMax = 0.3;
999 }
1000 }
1001 else if( pPb1 == centBinVersion)
1002 {
1003 if( upperEdge < 2.1 ) {
1004 rangeMin = 0.1;
1005 rangeMax = 0.2;
1006 } else if( upperEdge < 3.1 ) {
1007 rangeMin = 0.08;
1008 rangeMax = 0.22;
1009 } else if( upperEdge < 5.1 ) {
1010 rangeMin = 0.08;
1011 rangeMax = 0.25;
1012 } else if( upperEdge < 10.1 ) {
1013 rangeMin = 0.07;
1014 rangeMax = 0.3;
1015 } else {
1016 rangeMin = 0.05;
1017 rangeMax = 0.3;
1018 }
1019 }
1020 }
1021
1022
a9e9e511 1023
e99d0b36 1024 TH1* GetHistogram_cent(Input& input, const TString& name, int fromCent, int toCent)
1025 {
1026 // Gets Histogram of name with centrality selection [fromCent,toCent)
1027
47747ea2 1028 TH1* hist = 0x0;
e99d0b36 1029
1030 // Bin edges such as in LEGO Train
1031 TArrayD binEdges = GetBinEdges(input.Bin().Trigger());
1032
1033 // from bin edges and [fromCent,toCent): determine [fromBin,toBin]
1034 int fromBin = -1;
1035 int toBin = -1;
1036 for(int idx = 0; idx < binEdges.GetSize()-1; ++idx) {
1037 if(fromCent == binEdges[idx])
1038 fromBin = idx;
1039 if( toCent == binEdges[idx+1])
1040 toBin = idx;
47747ea2 1041 }
e99d0b36 1042 // if found, Merge:
1043 if( fromBin >= 0 && toBin >= fromBin )
1044 hist = MergeHistogram_cent(input, name, fromCent, toCent, fromBin, toBin);
1045
47747ea2 1046 if( ! hist ) {
e99d0b36 1047 Printf("ERROR:GetHistogram_cent: %02i-%02i not possible for %s trigger", fromCent, toCent, input.Bin().Trigger().Data());
47747ea2 1048 return 0x0;
1049 }
a9e9e511 1050
e99d0b36 1051 hist->SetTitle(Form("%s, %02i-%02i%%", hist->GetTitle(), fromCent, toCent));
47747ea2 1052 return hist;
1053 }
a9e9e511 1054
e99d0b36 1055 TH1* MergeHistogram_cent(Input& input, const TString& name, int fromCent, int toCent, int fromCentIndex, int toCentIndex)
47747ea2 1056 {
e99d0b36 1057 // Merger (All cent) for histograms following the naming patern of %s_cen%i,
47747ea2 1058 //
e99d0b36 1059 // Merges centralites bins into one histogram, from including to including, and names the histogram using the patern above.
47747ea2 1060 // If an histogram with that name Allready exist in the current directory (gDirectory), then no merge
1061 // occurs and this hist. is simply returned.
e99d0b36 1062 // take note that toCent is assumed exclusive, and toCentIndex is inclusive.
a9e9e511 1063
47747ea2 1064 char mergeHistName[256] = "";
e99d0b36 1065 sprintf(mergeHistName, "%s_cen%02i-%02i", name.Data(), fromCent, toCent);
a9e9e511 1066
47747ea2 1067 // Check if histogram allready exists in current directory.
1068 TH1* mergeHist = dynamic_cast<TH1*>( gDirectory->FindObject(mergeHistName) );
1069 if ( mergeHist )
1070 return mergeHist;
a9e9e511 1071
47747ea2 1072 // If not so; get the first hist, clone, and add the others
1073 char cname[256] = "";
1074 sprintf(cname, "%s_cen%i", name.Data(), fromCentIndex);
1075 TH1* hist0 = input.GetHistogram(cname);
e99d0b36 1076 TH1 * histMerged = (TH1*) hist0->Clone(mergeHistName);
a9e9e511 1077
e99d0b36 1078 Printf(cname);
47747ea2 1079 for(int cent=fromCentIndex+1; cent < toCentIndex; ++cent) {
1080 sprintf(cname, "%s_cen%i", name.Data(), cent);
e99d0b36 1081 Printf(cname);
47747ea2 1082 TH1* nextHist = input.GetHistogram(cname);
1083 if( ! nextHist ) {Printf("ERROR: Merge of histograms failed"); delete histMerged; return 0x0; }
1084 histMerged->Add(nextHist);
1085 }
1086 return histMerged;
1087 }
1088
1089
a9e9e511 1090
47747ea2 1091 //-----------------------------------------------------------------------------
1092 void PPRstyle()
1093 {
1094
1095 //////////////////////////////////////////////////////////////////////
1096 //
1097 // ROOT style macro for the TRD TDR
1098 //
1099 //////////////////////////////////////////////////////////////////////
1100
1101 gStyle->SetPalette(1);
1102 gStyle->SetCanvasBorderMode(-1);
1103 gStyle->SetCanvasBorderSize(1);
1104 gStyle->SetCanvasColor(10);
1105
1106 gStyle->SetFrameFillColor(10);
1107 gStyle->SetFrameBorderSize(1);
1108 gStyle->SetFrameBorderMode(-1);
1109 gStyle->SetFrameLineWidth(1.2);
1110 gStyle->SetFrameLineColor(1);
1111
1112 gStyle->SetHistFillColor(0);
1113 gStyle->SetHistLineWidth(1);
1114 gStyle->SetHistLineColor(1);
1115
1116 gStyle->SetPadColor(10);
1117 gStyle->SetPadBorderSize(1);
1118 gStyle->SetPadBorderMode(-1);
1119
1120 gStyle->SetStatColor(10);
1121 gStyle->SetTitleColor(kBlack,"X");
1122 gStyle->SetTitleColor(kBlack,"Y");
1123
1124 gStyle->SetLabelSize(0.04,"X");
1125 gStyle->SetLabelSize(0.04,"Y");
1126 gStyle->SetLabelSize(0.04,"Z");
1127 gStyle->SetTitleSize(0.04,"X");
1128 gStyle->SetTitleSize(0.04,"Y");
1129 gStyle->SetTitleSize(0.04,"Z");
1130 gStyle->SetTitleFont(42,"X");
1131 gStyle->SetTitleFont(42,"Y");
1132 gStyle->SetTitleFont(42,"X");
1133 gStyle->SetLabelFont(42,"X");
1134 gStyle->SetLabelFont(42,"Y");
1135 gStyle->SetLabelFont(42,"Z");
1136 gStyle->SetStatFont(42);
1137
1138 gStyle->SetTitleOffset(1.0,"X");
1139 gStyle->SetTitleOffset(1.4,"Y");
1140
1141 gStyle->SetFillColor(kWhite);
1142 gStyle->SetTitleFillColor(kWhite);
1143
1144 gStyle->SetOptDate(0);
1145 gStyle->SetOptTitle(1);
1146 gStyle->SetOptStat(0);
1147 gStyle->SetOptFit(111);
1148
1149 }
1150}
1151
1152
6aa36480 1153
1154void MakeRawProductionAll()
1155{
1156 //gStyle->SetOptStat(0);
1157 gStyle->SetOptFit(1);
6aa36480 1158
a9e9e511 1159 RawProduction::Output output;
e99d0b36 1160
1161 TArrayD tbin;
6aa36480 1162
e99d0b36 1163 TStringToken triggers("kCentral kMB kSemiCentral kPHOSPb", " ");
26d3ece9 1164 //TStringToken triggers("kCentral", " ");
6aa36480 1165 while(triggers.NextToken()) {
a9e9e511 1166 RawProduction::TriggerBin triggerBin(triggers);
1167 RawProduction::Input input("AnalysisResults.root", triggerBin);
1168
e99d0b36 1169 //RawProduction::MakePi0Fit(input, triggerBin, output);
1170
b06cd7b3 1171 TStringToken pids("All Allcore Allwou Disp Disp2 Dispcore Disp2core Dispwou CPV CPVcore CPV2 CPV2core Both Bothcore Both2 Both2core", " ");
6aa36480 1172 while(pids.NextToken()) {
e99d0b36 1173 if(triggers.EqualTo("kMB") || triggers.EqualTo("kPHOSPb")) {
1174 RawProduction::TriCenPidBin tcpBin(0, 10, pids, triggerBin.Trigger());
1175 RawProduction::MakePi0FitTCP(input, tcpBin, output);
1176 }
1177 if(triggers.EqualTo("kCentral") ) {
1178 RawProduction::TriCenPidBin tcpBin2(5, 10, pids, triggerBin.Trigger());
1179 RawProduction::MakePi0FitTCP(input, tcpBin2, output);
1180 RawProduction::TriCenPidBin tcpBin(0, 5, pids, triggerBin.Trigger());
1181 RawProduction::MakePi0FitTCP(input, tcpBin, output);
1182 }
1183 if(triggers.EqualTo("kSemiCentral") ) {
1184 RawProduction::TriCenPidBin tcpBin(10, 50, pids, triggerBin.Trigger());
1185 RawProduction::MakePi0FitTCP(input, tcpBin, output);
1186 }
b06cd7b3 1187 } // pid
1188 } // trigger
20fb7b55 1189 output.Write();
47747ea2 1190}
8375919f 1191
e99d0b36 1192void MakeRawProductionAllpPb()
8375919f 1193{
e99d0b36 1194 RawProduction::centBinVersion = RawProduction::pPb1;
1195 RawProduction::Output output;
1196
1197 TArrayD tbin;
8375919f 1198
e99d0b36 1199 TStringToken triggers("kINT7 kPHI7", " ");
1200 //TStringToken triggers("kCentral", " ");
4a78c315 1201 while(triggers.NextToken()) {
1202 RawProduction::TriggerBin triggerBin(triggers);
1203 RawProduction::Input input("AnalysisResults.root", triggerBin);
8375919f 1204
e99d0b36 1205 RawProduction::MakePi0Fit(input, triggerBin, output);
e0a7b32f 1206
1207
1208 TStringToken pids("All Disp CPV Both", " ");
1209 //TStringToken pids("All Allcore Allwou Disp Disp2 Dispcore Disp2core Dispwou CPV CPVcore CPV2 CPV2core Both Bothcore Both2 Both2core", " ");
e99d0b36 1210 while(pids.NextToken()) {
1211 if(triggers.EqualTo("kINT7") || triggers.EqualTo("kPHI7")) {
1212 RawProduction::TriCenPidBin tcpBin(0, 20, pids, triggerBin.Trigger());
1213 RawProduction::MakePi0FitTCP(input, tcpBin, output);
1214 RawProduction::TriCenPidBin tcpBin2(20, 40, pids, triggerBin.Trigger());
1215 RawProduction::MakePi0FitTCP(input, tcpBin2, output);
1216 RawProduction::TriCenPidBin tcpBin3(40, 60, pids, triggerBin.Trigger());
1217 RawProduction::MakePi0FitTCP(input, tcpBin3, output);
1218 RawProduction::TriCenPidBin tcpBin4(60, 80, pids, triggerBin.Trigger());
1219 RawProduction::MakePi0FitTCP(input, tcpBin4, output);
1220 RawProduction::TriCenPidBin tcpBin5(80, 100, pids, triggerBin.Trigger());
e0a7b32f 1221 RawProduction::MakePi0FitTCP(input, tcpBin5, output);
1222 RawProduction::TriCenPidBin tcpBin6(0, 100, pids, triggerBin.Trigger());
1223 RawProduction::MakePi0FitTCP(input, tcpBin6, output);
4a78c315 1224 }
e99d0b36 1225 } // pid
1226 } // trigger
1227 output.Write();
1228
8375919f 1229}
e99d0b36 1230
1231// void MakeRawProductionRanges()
1232// {
1233// //gStyle->SetOptStat(0);
1234// gStyle->SetOptFit(1);
1235//
1236// float fromRanges[4] = {0.04, 0.05, 0.07, 0.1};
1237// float toRanges[4] = {0.2, 0.25, 0.3, 0.4};
1238//
1239// TStringToken triggers("kMB kCentral kSemiCentral kPHOSPb", " ");
1240// while(triggers.NextToken()) {
1241// RawProduction::TriggerBin triggerBin(triggers);
1242// RawProduction::Input input("AnalysisResults.root", triggerBin);
1243// for(int fidx=0; fidx<4; fidx++) {
1244// for(int tidx=0; tidx<4; tidx++) {
1245// RawProduction::rangeMin = fromRanges[fidx];
1246// RawProduction::rangeMax = toRanges[tidx];
1247//
1248// Printf(" RawProduction_%.2f_%.2f.root", RawProduction::rangeMin, RawProduction::rangeMax);
1249// RawProduction::Output output(Form("RawProduction_%.2f_%.2f.root", RawProduction::rangeMin, RawProduction::rangeMax));
1250//
1251//
1252// RawProduction::MakePi0Fit(input, triggerBin, output);
1253//
1254// TStringToken pids("All Allcore Allwou Disp Disp2 Dispcore Disp2core Dispwou CPV CPVcore CPV2 CPV2core Both Bothcore Both2 Both2core", " ");
1255// while(pids.NextToken()) {
1256// for(int cent = -11; cent < 0; ++cent) {
1257// RawProduction::TriCenPidBin tcpBin(cent, pids, triggerBin.Trigger());
1258// if(triggers.EqualTo("kMB") || triggers.EqualTo("kPHOSPb")) {
1259// if( -1 == cent || -11 == cent || -10 == cent || -6 == cent )
1260// RawProduction::MakePi0FitTCP(input, tcpBin, output);
1261// }
1262// if(triggers.EqualTo("kCentral") ) {
1263// if( -1 == cent )
1264// RawProduction::MakePi0FitTCP(input, tcpBin, output);
1265// }
1266// if(triggers.EqualTo("kSemiCentral") ) {
1267// if( -11 == cent )
1268// RawProduction::MakePi0FitTCP(input, tcpBin, output);
1269// }
1270// } // cent
1271// } // pid
1272// output.Write();
1273// }
1274// }
1275// }// trigger
1276// }