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