added correction for events with vertex but 0 tracks
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / drawSystematics.C
CommitLineData
10ebe68d 1/* $Id$ */
2
3#if !defined(__CINT__) || defined(__MAKECINT__)
4
5#include "AliPWG0Helper.h"
6#include "dNdEtaAnalysis.h"
7#include "AlidNdEtaCorrection.h"
8
9#include <TCanvas.h>
10#include <TFile.h>
11#include <TH1.h>
12#include <TH2F.h>
13#include <TH3F.h>
14#include <TLine.h>
15#include <TSystem.h>
6b7fa615 16#include <TLegend.h>
17#include <TPad.h>
18#include <TF1.h>
19
20extern TPad* gPad;
21
22void Track2Particle1DCreatePlots(const char* fileName = "correction_map.root", const char* folderName = "dndeta_correction", Float_t upperPtLimit = 10);
10ebe68d 23
24#endif
25
8ca1a6d9 26Int_t markers[] = {20,20,21,22,23,28,29};
27Int_t colors[] = {1,2,3,4,6,8,102};
9f469bf5 28
dd367a14 29void loadlibs()
30{
31 gSystem->Load("libTree");
32 gSystem->Load("libVMC");
33
34 gSystem->Load("libSTEERBase");
35 gSystem->Load("libANALYSIS");
36 gSystem->Load("libPWG0base");
37}
38
10ebe68d 39void SetRanges(TAxis* axis)
40{
41 if (strcmp(axis->GetTitle(), "#eta") == 0)
42 axis->SetRangeUser(-1.7999, 1.7999);
43 if (strcmp(axis->GetTitle(), "p_{T} [GeV/c]") == 0)
44 axis->SetRangeUser(0, 9.9999);
45 if (strcmp(axis->GetTitle(), "vtx z [cm]") == 0)
46 axis->SetRangeUser(-15, 14.9999);
47 if (strcmp(axis->GetTitle(), "Ntracks") == 0)
48 axis->SetRangeUser(0, 99.9999);
49}
50
51void SetRanges(TH1* hist)
52{
53 SetRanges(hist->GetXaxis());
54 SetRanges(hist->GetYaxis());
55 SetRanges(hist->GetZaxis());
56}
57
58void Prepare3DPlot(TH3* hist)
59{
60 hist->GetXaxis()->SetTitleOffset(1.5);
61 hist->GetYaxis()->SetTitleOffset(1.5);
62 hist->GetZaxis()->SetTitleOffset(1.5);
63
64 hist->SetStats(kFALSE);
65}
66
67void Prepare2DPlot(TH2* hist)
68{
69 hist->SetStats(kFALSE);
70 hist->GetYaxis()->SetTitleOffset(1.4);
71
72 SetRanges(hist);
73}
74
7af955da 75void Prepare1DPlot(TH1* hist, Bool_t setRanges = kTRUE)
10ebe68d 76{
77 hist->SetLineWidth(2);
78 hist->SetStats(kFALSE);
79
7af955da 80 hist->GetXaxis()->SetTitleOffset(1.2);
81 hist->GetYaxis()->SetTitleOffset(1.2);
82
83 if (setRanges)
84 SetRanges(hist);
10ebe68d 85}
86
87void InitPad()
88{
9f469bf5 89 if (!gPad)
90 return;
91
10ebe68d 92 gPad->Range(0, 0, 1, 1);
93 gPad->SetLeftMargin(0.15);
94 //gPad->SetRightMargin(0.05);
95 //gPad->SetTopMargin(0.13);
96 //gPad->SetBottomMargin(0.1);
97
72e597d7 98 gPad->SetGridx();
99 gPad->SetGridy();
10ebe68d 100}
101
102void InitPadCOLZ()
103{
104 gPad->Range(0, 0, 1, 1);
105 gPad->SetRightMargin(0.15);
106 gPad->SetLeftMargin(0.12);
107
108 gPad->SetGridx();
109 gPad->SetGridy();
110}
111
112void Secondaries()
113{
114 TFile* file = TFile::Open("systematics.root");
115
7af955da 116 TH2F* secondaries = dynamic_cast<TH2F*> (file->Get("fSecondaries"));
10ebe68d 117 if (!secondaries)
118 {
119 printf("Could not read histogram\n");
120 return;
121 }
122
7af955da 123 TCanvas* canvas = new TCanvas("Secondaries", "Secondaries", 1000, 1000);
124 canvas->Divide(3, 3);
125 for (Int_t i=1; i<=8; i++)
10ebe68d 126 {
7af955da 127 TH1D* hist = secondaries->ProjectionY(Form("proj_%d", i), i, i);
128 hist->SetTitle(secondaries->GetXaxis()->GetBinLabel(i));
10ebe68d 129
7af955da 130 canvas->cd(i);
131 hist->Draw();
10ebe68d 132 }
133}
134
6b7fa615 135void Track2Particle1DComposition(const char** fileNames, Int_t folderCount, const char** folderNames, Float_t upperPtLimit = 9.9)
10ebe68d 136{
137 gSystem->Load("libPWG0base");
138
9f469bf5 139 TString canvasName;
140 canvasName.Form("Track2Particle1DComposition");
141 TCanvas* canvas = new TCanvas(canvasName, canvasName, 1200, 400);
142 canvas->Divide(3, 1);
10ebe68d 143
9f469bf5 144 TLegend* legend = new TLegend(0.7, 0.7, 0.95, 0.95);
10ebe68d 145
9f469bf5 146 for (Int_t i=0; i<folderCount; ++i)
10ebe68d 147 {
6b7fa615 148 Track2Particle1DCreatePlots(fileNames[i], folderNames[i], upperPtLimit);
9f469bf5 149
6b7fa615 150 TH1* corrX = dynamic_cast<TH1*> (gROOT->FindObject(Form("gene_%s_nTrackToNPart_x_div_meas_%s_nTrackToNPart_x", folderNames[i], folderNames[i])));
151 TH1* corrY = dynamic_cast<TH1*> (gROOT->FindObject(Form("gene_%s_nTrackToNPart_y_div_meas_%s_nTrackToNPart_y", folderNames[i], folderNames[i])));
152 TH1* corrZ = dynamic_cast<TH1*> (gROOT->FindObject(Form("gene_%s_nTrackToNPart_z_div_meas_%s_nTrackToNPart_z", folderNames[i], folderNames[i])));
9f469bf5 153
154 Prepare1DPlot(corrX);
155 Prepare1DPlot(corrY);
156 Prepare1DPlot(corrZ);
157
158 const char* title = "Track2Particle Correction";
159 corrX->SetTitle(title);
160 corrY->SetTitle(title);
161 corrZ->SetTitle(title);
162
163 corrZ->GetXaxis()->SetRangeUser(0, upperPtLimit);
164
165 corrX->SetLineColor(i+1);
166 corrY->SetLineColor(i+1);
167 corrZ->SetLineColor(i+1);
168
169 canvas->cd(1);
170 InitPad();
171 corrX->DrawCopy(((i>0) ? "SAME" : ""));
172
173 canvas->cd(2);
174 InitPad();
175 corrY->DrawCopy(((i>0) ? "SAME" : ""));
176
177 canvas->cd(3);
178 InitPad();
179 corrZ->DrawCopy(((i>0) ? "SAME" : ""));
180
181 legend->AddEntry(corrZ, folderNames[i]);
10ebe68d 182 }
183
9f469bf5 184 legend->Draw();
185
186 //canvas->SaveAs(Form("Track2Particle1D_%s_%d_%f.gif", fileName, gMax, upperPtLimit));
187 //canvas->SaveAs(Form("Track2Particle1D_%s_%d_%f.eps", fileName, gMax, upperPtLimit));
188}
189
6b7fa615 190TH1** DrawRatios(const char* fileName = "systematics.root")
191{
192 gSystem->Load("libPWG0base");
193
194 TFile* file = TFile::Open(fileName);
195
196 TString canvasName;
197 canvasName.Form("DrawRatios");
198 TCanvas* canvas = new TCanvas(canvasName, canvasName, 800, 400);
199 canvas->Divide(2, 1);
200 canvas->cd(1);
201
202 TH1** ptDists = new TH1*[4];
203
7af955da 204 TLegend* legend = new TLegend(0.73, 0.73, 0.98, 0.98);
6b7fa615 205
206 const char* folderNames[] = { "correction_0", "correction_1", "correction_2", "correction_3" };
207 const char* particleNames[] = { "#pi", "K", "p", "other" };
208 for (Int_t i=0; i<4; ++i)
209 {
210 AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection(folderNames[i], folderNames[i]);
211 dNdEtaCorrection->LoadHistograms(fileName, folderNames[i]);
212
213 TH3F* gene = dNdEtaCorrection->GetTrack2ParticleCorrection()->GetGeneratedHistogram();
214
215 gene->GetYaxis()->SetRangeUser(-0.8, 0.8);
216 gene->GetXaxis()->SetRangeUser(-10, 10);
217
218 ptDists[i] = dynamic_cast<TH1*> (gene->Project3D("z")->Clone(Form("%s_z", folderNames[i])));
219 ptDists[i]->SetTitle(";p_{T};Count");
220 if (!ptDists[i])
221 {
222 printf("Problem getting distribution %d.\n", i);
223 return 0;
224 }
225
226 ptDists[i]->GetYaxis()->SetRangeUser(1, ptDists[i]->GetMaximum()*1.1);
227 ptDists[i]->GetXaxis()->SetRangeUser(0, 9.9);
228 ptDists[i]->SetLineColor(i+1);
229 ptDists[i]->DrawCopy((i == 0) ? "" : "SAME");
230 ptDists[i]->GetYaxis()->SetRange(0, 0);
231
232 legend->AddEntry(ptDists[i], particleNames[i]);
233 }
234 gPad->SetLogy();
235
236 TH1* total = dynamic_cast<TH1*> (ptDists[0]->Clone("total"));
237
238 for (Int_t i=1; i<4; ++i)
239 total->Add(ptDists[i]);
240
241 canvas->cd(2);
242 for (Int_t i=0; i<4; ++i)
243 {
244 ptDists[i]->Divide(total);
7af955da 245 ptDists[i]->SetStats(kFALSE);
246 ptDists[i]->SetTitle(";p_{T};Fraction of total");
6b7fa615 247 ptDists[i]->GetYaxis()->SetRangeUser(0, 1);
248 ptDists[i]->Draw((i == 0) ? "" : "SAME");
249 }
7af955da 250 legend->SetFillColor(0);
6b7fa615 251 legend->Draw();
252
253 canvas->SaveAs("DrawRatios.gif");
254
7af955da 255
256 canvas = new TCanvas("PythiaRatios", "PythiaRatios", 500, 500);
257 for (Int_t i=0; i<4; ++i)
258 {
259 TH1* hist = ptDists[i]->Clone();
260 hist->GetXaxis()->SetRangeUser(0, 1.9);
261 hist->Draw((i == 0) ? "" : "SAME");
262 }
263 legend->Draw();
264
265 canvas->SaveAs("pythiaratios.eps");
266
6b7fa615 267 file->Close();
268
269 return ptDists;
270}
271
8ca1a6d9 272void DrawpiKpAndCombinedZOnly(Float_t upperPtLimit=0.99)
273{
274 gROOT->ProcessLine(".L drawPlots.C");
275 gSystem->Load("libPWG0base");
276
277 const char* fileNames[] = { "systematics.root", "systematics.root", "systematics.root", "correction_map.root" };
278 const char* folderNames[] = { "correction_0", "correction_1", "correction_2", "dndeta_correction" };
279 const char* legendNames[] = { "#pi", "K", "p", "standard" };
280 Int_t folderCount = 3;
281
282 /*const char* fileNames[] = { "systematics.root", "systematics.root", "systematics.root", "systematics.root", "correction_map.root" };
283 const char* folderNames[] = { "correction_0", "correction_1", "correction_2", "correction_3", "dndeta_correction" };
284 const char* legendNames[] = { "#pi", "K", "p", "others", "standard" };
285 Int_t folderCount = 5;*/
286
287 TString canvasName;
288 canvasName.Form("Track2Particle1DComposition");
289 TCanvas* canvas = new TCanvas(canvasName, canvasName, 700, 500);
290 canvas->SetGridx();
291 canvas->SetGridy();
292 canvas->SetBottomMargin(0.12);
293 //InitPad();
294
295 TLegend* legend = new TLegend(0.8, 0.7, 0.95, 0.95);
296 legend->SetFillColor(0);
297
298 Int_t mycolors[] = {1, 2, 4};
299
300 for (Int_t i=0; i<folderCount; ++i)
301 {
302 Track2Particle1DCreatePlots(fileNames[i], folderNames[i], upperPtLimit);
303
304 TH1* corrZ = dynamic_cast<TH1*> (gROOT->FindObject(Form("gene_%s_nTrackToNPart_z_div_meas_%s_nTrackToNPart_z", folderNames[i], folderNames[i])));
305
306 Prepare1DPlot(corrZ);
307
308 corrZ->SetTitle("");
309 corrZ->GetXaxis()->SetRangeUser(0, upperPtLimit);
310 corrZ->GetYaxis()->SetRangeUser(0.51, 6);
311 corrZ->SetMarkerColor(mycolors[i]);
312 corrZ->SetLineColor(mycolors[i]);
313 corrZ->SetMarkerStyle(markers[i+1]);
314 corrZ->GetYaxis()->SetTitle("correction factor");
315
316 corrZ->DrawCopy(((i>0) ? "SAMEP" : "P"));
317
318 legend->AddEntry(corrZ, legendNames[i]);
319 }
320
321 legend->Draw();
322
323 canvas->SaveAs("ptcutoff_species.eps");
324}
325
7af955da 326void DrawCompareToReal()
327{
328 gROOT->ProcessLine(".L drawPlots.C");
329
330 const char* fileNames[] = { "correction_map.root", "new_compositions.root" };
331 const char* folderNames[] = { "dndeta_correction", "PythiaRatios" };
332
333 Track2Particle1DComposition(fileNames, 2, folderNames);
334}
335
9f469bf5 336void DrawDifferentSpecies()
337{
338 gROOT->ProcessLine(".L drawPlots.C");
339
6b7fa615 340 const char* fileNames[] = { "systematics.root", "systematics.root", "systematics.root", "systematics.root" };
9f469bf5 341 const char* folderNames[] = { "correction_0", "correction_1", "correction_2", "correction_3" };
342
6b7fa615 343 Track2Particle1DComposition(fileNames, 4, folderNames);
9f469bf5 344}
10ebe68d 345
8ca1a6d9 346void DrawpiKpAndCombined()
347{
348 gROOT->ProcessLine(".L drawPlots.C");
349
350 const char* fileNames[] = { "systematics.root", "systematics.root", "systematics.root", "correction_map.root" };
351 const char* folderNames[] = { "correction_0", "correction_1", "correction_2", "dndeta_correction" };
352
353 Track2Particle1DComposition(fileNames, 4, folderNames);
354}
355
6b7fa615 356void DrawSpeciesAndCombination()
357{
358 gROOT->ProcessLine(".L drawPlots.C");
359
360 const char* fileNames[] = { "systematics.root", "systematics.root", "systematics.root", "new_compositions.root" };
361 const char* folderNames[] = { "correction_0", "correction_1", "correction_2", "PythiaRatios" };
362
363 Track2Particle1DComposition(fileNames, 4, folderNames);
364}
365
366void DrawSimulatedVsCombined()
367{
368 gROOT->ProcessLine(".L drawPlots.C");
369
370 const char* fileNames[] = { "new_compositions.root", "new_compositions.root" };
371 const char* folderNames[] = { "Pythia", "PythiaRatios" };
372
373 Track2Particle1DComposition(fileNames, 2, folderNames);
374}
375
376void DrawBoosts()
377{
378 gROOT->ProcessLine(".L drawPlots.C");
379
380 const char* fileNames[] = { "new_compositions.root", "new_compositions.root", "new_compositions.root", "new_compositions.root" };
381 const char* folderNames[] = { "PythiaRatios", "PiBoosted", "KBoosted", "pBoosted" };
382
383 Track2Particle1DComposition(fileNames, 4, folderNames);
384}
385
7af955da 386TH2F* HistogramDifferences(const char* filename, const char* folder1, const char* folder2)
6b7fa615 387{
388 gSystem->Load("libPWG0base");
389
390 AlidNdEtaCorrection* fdNdEtaCorrection[2];
391
392 TFile::Open(filename);
393
394 fdNdEtaCorrection[0] = new AlidNdEtaCorrection(folder1, folder1);
395 fdNdEtaCorrection[0]->LoadHistograms(filename, folder1);
396
397 fdNdEtaCorrection[1] = new AlidNdEtaCorrection(folder2, folder2);
398 fdNdEtaCorrection[1]->LoadHistograms(filename, folder2);
399
6b7fa615 400 TH3F* hist1 = fdNdEtaCorrection[0]->GetTrack2ParticleCorrection()->GetCorrectionHistogram();
401 TH3F* hist2 = fdNdEtaCorrection[1]->GetTrack2ParticleCorrection()->GetCorrectionHistogram();
402
7af955da 403 //TH1F* difference = new TH1F("difference", Form(";#DeltaC_{pT, z, #eta} %s / %s;Count", folder2, folder1), 1000, 0.9, 1.1);
404 TH2F* difference = new TH2F(Form("difference_%s_%s", folder1, folder2), Form(";#Sigma (C_{pT, z} %s / C_{pT, z} %s);#eta;Count", folder2, folder1), 100, 0.9, 1.1, hist1->GetYaxis()->GetNbins(), hist1->GetYaxis()->GetXmin(), hist1->GetYaxis()->GetXmax());
405
6b7fa615 406 for (Int_t x=hist1->GetXaxis()->FindBin(-10); x<=hist1->GetXaxis()->FindBin(10); ++x)
407 for (Int_t y=hist1->GetYaxis()->FindBin(-0.8); y<=hist1->GetYaxis()->FindBin(0.8); ++y)
408 for (Int_t z=hist1->GetZaxis()->FindBin(0.3); z<=hist1->GetZaxis()->FindBin(9.9); ++z)
7af955da 409 if (hist1->GetBinContent(x, y, z) != 0)
410 difference->Fill(hist2->GetBinContent(x, y, z) / hist1->GetBinContent(x, y, z), hist1->GetYaxis()->GetBinCenter(y));
411
412 difference->GetYaxis()->SetRangeUser(-0.8, 0.8);
6b7fa615 413
414 printf("Over-/Underflow bins: %d %d\n", difference->GetBinContent(0), difference->GetBinContent(difference->GetNbinsX()+1));
415
416 return difference;
417}
418
419void HistogramDifferences()
420{
7af955da 421 TH2F* KBoosted = HistogramDifferences("new_compositions.root", "PythiaRatios", "KBoosted");
422 TH2F* pBoosted = HistogramDifferences("new_compositions.root", "PythiaRatios", "pBoosted");
423 TH2F* KReduced = HistogramDifferences("new_compositions.root", "PythiaRatios", "KReduced");
424 TH2F* pReduced = HistogramDifferences("new_compositions.root", "PythiaRatios", "pReduced");
6b7fa615 425
7af955da 426 TCanvas* canvas = new TCanvas("HistogramDifferences", "HistogramDifferences", 1000, 1000);
427 canvas->Divide(2, 2);
6b7fa615 428
429 canvas->cd(1);
7af955da 430 KBoosted->GetXaxis()->SetRangeUser(-0.05, 0.05);
431 KBoosted->Draw("COLZ");
6b7fa615 432
433 canvas->cd(2);
7af955da 434 KReduced->GetXaxis()->SetRangeUser(-0.05, 0.05);
435 KReduced->Draw("COLZ");
6b7fa615 436
437 canvas->cd(3);
7af955da 438 pBoosted->GetXaxis()->SetRangeUser(-0.02, 0.02);
439 pBoosted->Draw("COLZ");
440
441 canvas->cd(4);
442 pReduced->GetXaxis()->SetRangeUser(-0.02, 0.02);
443 pReduced->Draw("COLZ");
6b7fa615 444
445 canvas->SaveAs("HistogramDifferences.gif");
7af955da 446
447 canvas = new TCanvas("HistogramDifferencesProfile", "HistogramDifferencesProfile", 1000, 500);
448 canvas->Divide(2, 1);
449
450 canvas->cd(1);
451 gPad->SetBottomMargin(0.13);
452 KBoosted->SetTitle("a) Ratio of correction maps");
453 KBoosted->SetStats(kFALSE);
454 KBoosted->GetXaxis()->SetTitleOffset(1.4);
455 KBoosted->GetXaxis()->SetLabelOffset(0.02);
456 KBoosted->Draw("COLZ");
457
458 canvas->cd(2);
459 gPad->SetGridx();
460 gPad->SetGridy();
461
462 TLegend* legend = new TLegend(0.73, 0.73, 0.98, 0.98);
463
464 for (Int_t i=0; i<4; ++i)
465 {
466 TH2F* hist = 0;
467 TString name;
468 switch (i)
469 {
470 case 0: hist = KBoosted; name = "K enhanced"; break;
471 case 1: hist = KReduced; name = "K reduced"; break;
472 case 2: hist = pBoosted; name = "p enhanced"; break;
473 case 3: hist = pReduced; name = "p reduced"; break;
474 }
475
476 TProfile* profile = hist->ProfileY();
477 profile->SetTitle("b) Mean and RMS");
478 profile->GetXaxis()->SetRange(hist->GetYaxis()->GetFirst(), hist->GetYaxis()->GetLast());
479 profile->GetXaxis()->SetTitleOffset(1.2);
480 profile->GetXaxis()->SetLabelOffset(0.02);
481 profile->GetYaxis()->SetRangeUser(0.98, 1.02);
482 profile->SetStats(kFALSE);
483 profile->SetLineColor(i+1);
484 profile->SetMarkerColor(i+1);
485 profile->DrawCopy(((i > 0) ? "SAME" : ""));
486
487
488 legend->AddEntry(profile, name);
489 }
490
491 legend->Draw();
492 canvas->SaveAs("particlecomposition_result.eps");
6b7fa615 493}
494
495
9f469bf5 496void ScalePtDependent(TH3F* hist, TF1* function)
497{
498 // assumes that pt is the third dimension of hist
499 // scales with function(pt)
10ebe68d 500
9f469bf5 501 for (Int_t z=1; z<=hist->GetNbinsZ(); ++z)
502 {
503 Double_t factor = function->Eval(hist->GetZaxis()->GetBinCenter(z));
504 printf("z = %d, pt = %f, scaling with %f\n", z, hist->GetZaxis()->GetBinCenter(z), factor);
505
506 for (Int_t x=1; x<=hist->GetNbinsX(); ++x)
507 for (Int_t y=1; y<=hist->GetNbinsY(); ++y)
508 hist->SetBinContent(x, y, z, hist->GetBinContent(x, y, z) * factor);
509 }
510}
511
6b7fa615 512void ScalePtDependent(TH3F* hist, TH1* function)
513{
514 // assumes that pt is the third dimension of hist
515 // scales with histogram(pt)
516
517 for (Int_t z=1; z<=hist->GetNbinsZ(); ++z)
518 {
519 Double_t factor = function->GetBinContent(function->GetXaxis()->FindBin(hist->GetZaxis()->GetBinCenter(z)));
520 printf("z = %d, pt = %f, scaling with %f\n", z, hist->GetZaxis()->GetBinCenter(z), factor);
521
522 for (Int_t x=1; x<=hist->GetNbinsX(); ++x)
523 for (Int_t y=1; y<=hist->GetNbinsY(); ++y)
524 hist->SetBinContent(x, y, z, hist->GetBinContent(x, y, z) * factor);
525 }
526}
527
528const char* ChangeComposition(void** correctionPointer, Int_t index)
9f469bf5 529{
530 AlidNdEtaCorrection** fdNdEtaCorrection = (AlidNdEtaCorrection**) correctionPointer;
531
532 switch (index)
533 {
6b7fa615 534 case 0: // result from pp events
535 {
536 TFile::Open("pythiaratios.root");
537
538 for (Int_t i=0; i<4; ++i)
539 {
540 TString name;
541 name.Form("correction_%d", i);
542 fdNdEtaCorrection[i] = new AlidNdEtaCorrection(name, name);
543 fdNdEtaCorrection[i]->LoadHistograms("pythiaratios.root", name);
544 }
545 }
546 return "Pythia";
547 break;
548
549 case 1: // each species rated with pythia ratios
7af955da 550 /*TH1** ptDists = DrawRatios("pythiaratios.root");
6b7fa615 551
552 for (Int_t i=0; i<3; ++i)
553 {
554 ScalePtDependent(fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetMeasuredHistogram(), ptDists[i]);
555 ScalePtDependent(fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetGeneratedHistogram(), ptDists[i]);
7af955da 556 }*/
6b7fa615 557 return "PythiaRatios";
9f469bf5 558 break;
559
7af955da 560 // one species enhanced / reduced
561 case 2: // + 50% pions
562 case 3: // - 50% pions
563 case 4: // + 50% kaons
564 case 5: // - 50% kaons
565 case 6: // + 50% protons
566 case 7: // - 50% protons
567 Int_t correctionIndex = (index - 2) / 2;
568 Double_t scaleFactor = (index % 2 == 0) ? 1.5 : 0.5;
569
570 fdNdEtaCorrection[correctionIndex]->GetTrack2ParticleCorrection()->GetMeasuredHistogram()->Scale(scaleFactor);
571 fdNdEtaCorrection[correctionIndex]->GetTrack2ParticleCorrection()->GetGeneratedHistogram()->Scale(scaleFactor);
572
573 TString* str = new TString;
574 str->Form("%s%s", (correctionIndex == 0) ? "Pi" : ((correctionIndex == 1) ? "K" : "p"), (index % 2 == 0) ? "Boosted" : "Reduced");
575 return str->Data();
576 break;
577
6b7fa615 578 // each species rated with pythia ratios
7af955da 579 case 12: // + 50% pions
580 case 13: // - 50% pions
581 case 14: // + 50% kaons
582 case 15: // - 50% kaons
583 case 16: // + 50% protons
584 case 17: // - 50% protons
6b7fa615 585 TH1** ptDists = DrawRatios("pythiaratios.root");
586 Int_t functionIndex = (index - 2) / 2;
7af955da 587 Double_t scaleFactor = (index % 2 == 0) ? 1.5 : 0.5;
6b7fa615 588 ptDists[functionIndex]->Scale(scaleFactor);
589
590 for (Int_t i=0; i<3; ++i)
591 {
592 ScalePtDependent(fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetMeasuredHistogram(), ptDists[i]);
593 ScalePtDependent(fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetGeneratedHistogram(), ptDists[i]);
594 }
595 TString* str = new TString;
596 str->Form("%s%s", (functionIndex == 0) ? "Pi" : ((functionIndex == 1) ? "K" : "p"), (index % 2 == 0) ? "Boosted" : "Reduced");
597 return str->Data();
9f469bf5 598 break;
599
6b7fa615 600 case 999:
9f469bf5 601 TF1* ptDependence = new TF1("simple", "x", 0, 100);
602 ScalePtDependent(fdNdEtaCorrection[0]->GetTrack2ParticleCorrection()->GetGeneratedHistogram(), ptDependence);
603 ScalePtDependent(fdNdEtaCorrection[0]->GetTrack2ParticleCorrection()->GetMeasuredHistogram(), ptDependence);
604 break;
605
606 }
6b7fa615 607
608 return "noname";
9f469bf5 609}
610
611void Composition()
612{
613 gSystem->Load("libPWG0base");
614
615 gSystem->Unlink("new_compositions.root");
616
6b7fa615 617 Int_t nCompositions = 8;
618 for (Int_t comp = 0; comp < nCompositions; ++comp)
9f469bf5 619 {
620 AlidNdEtaCorrection* fdNdEtaCorrection[4];
621
622 TFile::Open("systematics.root");
623
624 for (Int_t i=0; i<4; ++i)
625 {
626 TString name;
627 name.Form("correction_%d", i);
628 fdNdEtaCorrection[i] = new AlidNdEtaCorrection(name, name);
629 fdNdEtaCorrection[i]->LoadHistograms("systematics.root", name);
630 }
631
6b7fa615 632 const char* newName = ChangeComposition(fdNdEtaCorrection, comp);
9f469bf5 633
634 Double_t geneCount[5];
635 Double_t measCount[5];
636 geneCount[4] = 0;
637 measCount[4] = 0;
638
639 for (Int_t i=0; i<4; ++i)
640 {
641 geneCount[i] = fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetGeneratedHistogram()->Integral();
642 measCount[i] = fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetMeasuredHistogram()->Integral();
643
644 geneCount[4] += geneCount[i];
645 measCount[4] += measCount[i];
646
647 printf("Particle %s: %d gene, %d meas\n", ((i == 0) ? "pi" : (i == 1) ? "K" : (i == 2) ? "p" : "others"), (Int_t) geneCount[i], (Int_t) measCount[i]);
648 }
10ebe68d 649
9f469bf5 650 printf("Generated ratios are: %f pi, %f K, %f p, %f others\n", geneCount[0] / geneCount[4], geneCount[1] / geneCount[4], geneCount[2] / geneCount[4], geneCount[3] / geneCount[4]);
10ebe68d 651
9f469bf5 652 printf("Reconstructed ratios are: %f pi, %f K, %f p, %f others\n", measCount[0] / measCount[4], measCount[1] / measCount[4], measCount[2] / measCount[4], measCount[3] / measCount[4]);
10ebe68d 653
9f469bf5 654 TList* collection = new TList;
10ebe68d 655
9f469bf5 656 for (Int_t i=0; i<4; ++i)
657 collection->Add(fdNdEtaCorrection[i]);
10ebe68d 658
6b7fa615 659 AlidNdEtaCorrection* newComposition = new AlidNdEtaCorrection(newName, newName);
9f469bf5 660 newComposition->Merge(collection);
661 newComposition->Finish();
662
663 delete collection;
664
665 TFile* file = TFile::Open("new_compositions.root", "UPDATE");
666 newComposition->SaveHistograms();
667 //file->Write();
668 file->Close();
669 }
10ebe68d 670
671 gROOT->ProcessLine(".L drawPlots.C");
9f469bf5 672
6b7fa615 673 const char* fileNames[] = {"new_compositions.root", "new_compositions.root", "new_compositions.root", "new_compositions.root", "new_compositions.root", "new_compositions.root", "new_compositions.root", "new_compositions.root" };
674 const char* folderNames[] = { "Pythia", "PythiaRatios", "PiBoosted", "PiReduced", "KBoosted", "KReduced", "pBoosted", "pReduced" };
9f469bf5 675
6b7fa615 676 Track2Particle1DComposition(fileNames, nCompositions, folderNames);
9f469bf5 677}
678
9f469bf5 679
10ebe68d 680void drawSystematics()
681{
9f469bf5 682 //Secondaries();
683 //DrawDifferentSpecies();
684 //Composition();
685
686 Sigma2VertexSimulation();
27c04e01 687
10ebe68d 688}
7af955da 689
690void DrawdNdEtaDifferences()
691{
692 TH1* hists[5];
693
72e597d7 694 TLegend* legend = new TLegend(0.3, 0.73, 0.70, 0.98);
f1076daa 695 legend->SetFillColor(0);
696
7af955da 697 TCanvas* canvas = new TCanvas("DrawdNdEtaDifferences", "DrawdNdEtaDifferences", 1000, 500);
698 canvas->Divide(2, 1);
699
700 canvas->cd(1);
701
702 for (Int_t i=0; i<5; ++i)
703 {
72e597d7 704 hists[i] = 0;
7af955da 705 TFile* file = 0;
f1076daa 706 TString title;
7af955da 707
708 switch(i)
709 {
f1076daa 710 case 0 : file = TFile::Open("systematics_dndeta_reference.root"); title = "standard composition"; break;
711 case 1 : file = TFile::Open("systematics_dndeta_KBoosted.root"); title = "+ 50% kaons"; break;
712 case 2 : file = TFile::Open("systematics_dndeta_KReduced.root"); title = "- 50% kaons"; break;
713 case 3 : file = TFile::Open("systematics_dndeta_pBoosted.root"); title = "+ 50% protons"; break;
714 case 4 : file = TFile::Open("systematics_dndeta_pReduced.root"); title = "- 50% protons"; break;
7af955da 715 default: return;
716 }
717
72e597d7 718 if (file)
719 {
720 hists[i] = (TH1*) file->Get("dndeta/dndeta_dNdEta_corrected_2");
721 hists[i]->SetTitle("a)");
722
723 Prepare1DPlot(hists[i], kFALSE);
724 hists[i]->GetXaxis()->SetRangeUser(-0.7999, 0.7999);
da7acf97 725 hists[i]->GetYaxis()->SetRangeUser(6, 7);
8ca1a6d9 726 hists[i]->SetLineColor(colors[i]);
727 hists[i]->SetMarkerColor(colors[i]);
728 hists[i]->SetMarkerStyle(markers[i]);
72e597d7 729 hists[i]->GetXaxis()->SetLabelOffset(0.015);
730 hists[i]->GetYaxis()->SetTitleOffset(1.5);
731 gPad->SetLeftMargin(0.12);
732 hists[i]->DrawCopy(((i > 0) ? "SAME" : ""));
733
734 legend->AddEntry(hists[i], title);
735 hists[i]->SetTitle(title);
736 }
7af955da 737 }
f1076daa 738 legend->Draw();
7af955da 739
740 canvas->cd(2);
f1076daa 741 gPad->SetLeftMargin(0.14);
742
743 TLegend* legend2 = new TLegend(0.73, 0.73, 0.98, 0.98);
744 legend2->SetFillColor(0);
7af955da 745
746 for (Int_t i=1; i<5; ++i)
747 {
72e597d7 748 if (hists[i])
749 {
750 legend2->AddEntry(hists[i]);
751
752 hists[i]->Divide(hists[0]);
753 hists[i]->SetTitle("b)");
8ca1a6d9 754 hists[i]->SetLineColor(colors[i-1]);
755 hists[i]->SetMarkerColor(colors[i-1]);
da7acf97 756 hists[i]->GetYaxis()->SetRangeUser(0.95, 1.05);
72e597d7 757 hists[i]->GetYaxis()->SetTitle("Ratio to standard composition");
758 hists[i]->GetYaxis()->SetTitleOffset(1.8);
759 hists[i]->DrawCopy(((i > 1) ? "SAME" : ""));
760 }
7af955da 761 }
f1076daa 762
763 legend2->Draw();
764
8ca1a6d9 765 canvas->SaveAs("particlecomposition_result_detail.gif");
766
767 TCanvas* canvas2 = new TCanvas("DrawdNdEtaDifferences2", "DrawdNdEtaDifferences2", 700, 500);
768
769 for (Int_t i=1; i<5; ++i)
770 {
771 if (hists[i])
772 {
773 hists[i]->SetTitle("");
774 hists[i]->GetYaxis()->SetTitleOffset(1.1);
775 hists[i]->DrawCopy(((i > 1) ? "SAME" : ""));
776 }
777 }
778
779 legend2->Draw();
780
781 canvas2->SaveAs("particlecomposition_result.gif");
782 canvas2->SaveAs("particlecomposition_result.eps");
7af955da 783}
27c04e01 784
dd367a14 785mergeCorrectionsWithDifferentCrosssections(Char_t* correctionFileName="correction_map.root", const char* analysisFileName = "analysis_esd_raw.root", const Char_t* outputFileName="systematics_vtxtrigger_compositions.root") {
27c04e01 786 //
787 // Function used to merge standard corrections with vertex
788 // reconstruction corrections obtained by a certain mix of ND, DD
789 // and SD events.
dd367a14 790 //
791 // the dn/deta spectrum is corrected and the ratios
792 // (standard to changed x-section) of the different dN/deta
793 // distributions are saved to a file.
794 //
27c04e01 795
dd367a14 796 loadlibs();
27c04e01 797
da7acf97 798 const Char_t* typeName[] = { "vertexreco", "trigger", "vtxtrigger" };
dd367a14 799 const Char_t* changes[] = { "pythia","ddmore","ddless","sdmore","sdless", "dmore", "dless", "sdmoreddless", "sdlessddmore", "ddmore25","ddless25","sdmore25","sdless25", "dmore25", "dless25", "sdmoreddless25", "sdlessddmore25"};
800 Float_t scalesDD[] = {1.0, 1.5, 0.5, 1.0, 1.0, 1.5, 0.5, 1.5, 0.5, 1.25, 0.75, 1.0, 1.0, 1.25, 0.75, 1.25, 0.75};
801 Float_t scalesSD[] = {1.0, 1.0, 1.0, 1.5, 0.5, 1.5, 0.5, 0.5, 1.5, 1.0, 1.0, 1.25, 0.75, 1.25, 0.75, 0.75, 1.25};
27c04e01 802
803 // cross section from Pythia
804 Float_t sigmaND = 55.2;
805 Float_t sigmaDD = 9.78;
806 Float_t sigmaSD = 14.30;
807
dd367a14 808 // standard correction
809 TFile::Open(correctionFileName);
810 AlidNdEtaCorrection* correctionStandard = new AlidNdEtaCorrection("dndeta_correction","dndeta_correction");
811 correctionStandard->LoadHistograms();
812
813 // dont take vertexreco from this one
814 correctionStandard->GetVertexRecoCorrection()->Reset();
815 // dont take triggerbias from this one
816 correctionStandard->GetTriggerBiasCorrectionINEL()->Reset();
817 correctionStandard->GetTriggerBiasCorrectionNSD()->Reset();
818 correctionStandard->GetTriggerBiasCorrectionND()->Reset();
819
820 AlidNdEtaCorrection* corrections[100];
821 TH1F* hRatios[100];
822
823 Int_t counter = 0;
da7acf97 824 for (Int_t j=0; j<3; j++) { // j = 0 (change vtx), j = 1 (change trg), j = 2 (change both)
27c04e01 825
dd367a14 826 for (Int_t i=0; i<17; i++) {
827 TFile::Open(correctionFileName);
27c04e01 828
da7acf97 829 TString name;
830 name.Form("dndeta_correction_syst_%s_%s", typeName[j], changes[i]);
831 AlidNdEtaCorrection* current = new AlidNdEtaCorrection(name, name);
770a1f1d 832 current->LoadHistograms("dndeta_correction");
833 current->Reset();
da7acf97 834
dd367a14 835 name.Form("dndeta_correction_ND");
836 AlidNdEtaCorrection* dNdEtaCorrectionND = new AlidNdEtaCorrection(name,name);
837 dNdEtaCorrectionND->LoadHistograms();
838 name.Form("dndeta_correction_DD");
839 AlidNdEtaCorrection* dNdEtaCorrectionDD = new AlidNdEtaCorrection(name,name);
840 dNdEtaCorrectionDD->LoadHistograms();
841 name.Form("dndeta_correction_SD");
842 AlidNdEtaCorrection* dNdEtaCorrectionSD = new AlidNdEtaCorrection(name,name);
843 dNdEtaCorrectionSD->LoadHistograms();
da7acf97 844
845 // calculating relative
846 Float_t nd = 100 * sigmaND/(sigmaND + (scalesDD[i]*sigmaDD) + (scalesDD[i]*sigmaSD));
847 Float_t dd = 100 * (scalesDD[i]*sigmaDD)/(sigmaND + (scalesDD[i]*sigmaDD) + (scalesDD[i]*sigmaSD));
848 Float_t sd = 100 * (scalesSD[i]*sigmaSD)/(sigmaND + (scalesDD[i]*sigmaDD) + (scalesDD[i]*sigmaSD));
849
dd367a14 850 printf(Form("%s : ND=%.2f\%, DD=%.2f\%, SD=%.2f\% \n",changes[i],nd,dd,sd));
da7acf97 851 current->SetTitle(Form("ND=%.2f\%,DD=%.2f\%,SD=%.2f\%",nd,dd,sd));
852 current->SetTitle(name);
853
854 // scale
855 if (j == 0 || j == 2)
856 {
dd367a14 857 dNdEtaCorrectionDD->GetVertexRecoCorrection()->Scale(scalesDD[i]);
858 dNdEtaCorrectionSD->GetVertexRecoCorrection()->Scale(scalesSD[i]);
da7acf97 859 }
860 if (j == 1 || j == 2)
861 {
dd367a14 862 dNdEtaCorrectionDD->GetTriggerBiasCorrectionINEL()->Scale(scalesDD[i]);
863 dNdEtaCorrectionSD->GetTriggerBiasCorrectionINEL()->Scale(scalesSD[i]);
864
865 dNdEtaCorrectionDD->GetTriggerBiasCorrectionNSD()->Scale(scalesDD[i]);
866 dNdEtaCorrectionSD->GetTriggerBiasCorrectionNSD()->Scale(scalesSD[i]);
867
868 dNdEtaCorrectionDD->GetTriggerBiasCorrectionND()->Scale(scalesDD[i]);
869 dNdEtaCorrectionSD->GetTriggerBiasCorrectionND()->Scale(scalesSD[i]);
da7acf97 870 }
871
dd367a14 872 //clear track in correction
873 dNdEtaCorrectionND->GetTrack2ParticleCorrection()->Reset();
874 dNdEtaCorrectionDD->GetTrack2ParticleCorrection()->Reset();
875 dNdEtaCorrectionSD->GetTrack2ParticleCorrection()->Reset();
da7acf97 876
877 TList collection;
878 collection.Add(correctionStandard);
dd367a14 879 collection.Add(dNdEtaCorrectionND);
880 collection.Add(dNdEtaCorrectionDD);
881 collection.Add(dNdEtaCorrectionSD);
da7acf97 882
883 current->Merge(&collection);
884 current->Finish();
885
dd367a14 886 corrections[counter] = current;
887
888 // now correct dNdeta distribution with modified correction map
889 TFile::Open(analysisFileName);
890
891 dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis("fdNdEtaAnalysisESD", "fdNdEtaAnalysisESD");
892 fdNdEtaAnalysis->LoadHistograms();
893
894 fdNdEtaAnalysis->Finish(current, 0.3, AlidNdEtaCorrection::kINEL);
895 //fdNdEtaAnalysis->Finish(current, 0.3, AlidNdEtaCorrection::kNSD);
896
897 name = "ratio";
898 if (j==0) name.Append("_vetexReco_");
899 if (j==1) name.Append("_triggerBias_");
900 if (j==2) name.Append("_vertexReco_triggerBias_");
901 name.Append(changes[i]);
902
903 hRatios[counter] = (TH1F*) fdNdEtaAnalysis->GetdNdEtaHistogram()->Clone(name);
904
905 name.Append(Form(" (DD #times %0.2f, SD #times %0.2f)",scalesDD[i],scalesSD[i]));
906 hRatios[counter]->SetTitle(name.Data());
907 hRatios[counter]->SetYTitle("ratio (Pythia x-sections)/(changed x-sections)");
908
909 if (counter > 0)
910 hRatios[counter]->Divide(hRatios[0],hRatios[counter],1,1);
911
912 delete fdNdEtaAnalysis;
913
914 counter++;
da7acf97 915 }
27c04e01 916 }
da7acf97 917
27c04e01 918 TFile* fout = new TFile(outputFileName,"RECREATE");
919
dd367a14 920 // to make everything consistent
921 hRatios[0]->Divide(hRatios[0],hRatios[0],1,1);
922
923 for (Int_t i=0; i<51; i++)
924 {
27c04e01 925 corrections[i]->SaveHistograms();
dd367a14 926 hRatios[i]->Write();
927 }
27c04e01 928
929 fout->Write();
930 fout->Close();
931}
5e08578b 932
933
7f0efb86 934DrawVertexRecoSyst() {
935 // Draws the ratio of the dN/dEta obtained with changed SD and DD
936 // cross-sections vertex reco corrections to the dN/dEta obtained
937 // from the standard pythia cross-sections
938 //
939 // The files with the vertex reco corrections for different
940 // processes (and with the other standard corrections) are expected
941 // to have the names "analysis_esd_X.root", where the Xs are defined
942 // in the array changes below.
5e08578b 943
944 Char_t* changes[] = {"pythia","ddmore","ddless","sdmore","sdless", "dmore", "dless"};
945 Char_t* descr[] = {"",
946 "#sigma_{DD}' = 1.5#times#sigma_{DD}",
947 "#sigma_{DD}' = 0.5#times#sigma_{DD}",
948 "#sigma_{SD}' = 1.5#times#sigma_{SD}",
949 "#sigma_{SD}' = 0.5#times#sigma_{SD}",
950 "#sigma_{D}' = 1.5#times#sigma_{D}",
951 "#sigma_{D}' = 0.5#times#sigma_{D}"};
952
953 Float_t scalesDD[] = {1.0, 1.5, 0.5, 1.5, 0.5, 1.5, 0.5};
954 Float_t scalesSD[] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 0.5};
955
fb30f6e3 956 Int_t markers[] = {20,20,21,22,23,28,29};
5e08578b 957 Int_t colors[] = {1,2,3,4,6,8,102};
958
959 // cross section from Pythia
960 Float_t sigmaND = 55.2;
961 Float_t sigmaDD = 9.78;
962 Float_t sigmaSD = 14.30;
963
5e08578b 964 TH1F* dNdEta[7];
5e08578b 965 TH1F* ratios[7];
966
967 TFile* fin;
968
5e08578b 969 for (Int_t i=0; i<7; i++) {
fb30f6e3 970 // calculating relative
7f0efb86 971 fin = TFile::Open(Form("analysis_esd_%s.root",changes[i]));
fb30f6e3 972
5e08578b 973 dNdEta[i] = (TH1F*)(fin->Get("dndeta/dndeta_dNdEta_corrected_2"))->Clone();
fb30f6e3 974
5e08578b 975 for (Int_t b=0; b<dNdEta[i]->GetNbinsX(); b++) {
976 if (TMath::Abs(dNdEta[i]->GetBinCenter(b))>0.9) {
977 dNdEta[i]->SetBinContent(b,0);
978 dNdEta[i]->SetBinError(b,0);
979 }
980 }
fb30f6e3 981
5e08578b 982 dNdEta[i]->Rebin(4);
fb30f6e3 983
5e08578b 984 dNdEta[i]->SetLineWidth(2);
985 dNdEta[i]->SetLineColor(colors[i]);
986 dNdEta[i]->SetMarkerStyle(markers[i]);
fb30f6e3 987 dNdEta[i]->SetMarkerSize(0.9);
988 dNdEta[i]->SetMarkerColor(colors[i]);
989
5e08578b 990 ratios[i] = (TH1F*)dNdEta[i]->Clone("ratio");
991 ratios[i]->Divide(ratios[i],dNdEta[0],1,1,"B");
992
993 ratios[i]->SetName(changes[i]);
994 ratios[i]->SetTitle(changes[i]);
995 }
996
997 //##########################################################
998
999 gStyle->SetOptStat(0);
1000 gStyle->SetOptTitle(0);
1001 gStyle->SetOptFit(0);
1002
1003 gStyle->SetTextSize(0.2);
1004 gStyle->SetTitleSize(0.05,"xyz");
5e08578b 1005 gStyle->SetLabelOffset(0.01, "xyz");
1006
1007
1008 gStyle->SetTitleOffset(1.2, "y");
1009 gStyle->SetTitleOffset(1.2, "x");
1010 gStyle->SetEndErrorSize(0.0);
1011
1012 //##############################################
1013
1014 //making canvas and pads
da7acf97 1015 TCanvas *c = new TCanvas(Form("vertex_reco_syst_%s", plot), Form("vertex_reco_syst_%s", plot),600,500);
5e08578b 1016
1017 TPad* p1 = new TPad("pad1","", 0, 0.0, 1.0, 1.0, 0, 0, 0);
1018
1019 p1->SetBottomMargin(0.15);
1020 p1->SetTopMargin(0.03);
1021 p1->SetLeftMargin(0.15);
1022 p1->SetRightMargin(0.03);
da7acf97 1023
5e08578b 1024 p1->SetGridx();
1025 p1->SetGridy();
1026
1027 p1->Draw();
1028 p1->cd();
5e08578b 1029
1030
1031 TH2F* null = new TH2F("","",100,-1.5,1.5,100,0.9601,1.099);
1032 null->SetXTitle("#eta");
1033 null->GetXaxis()->CenterTitle(kTRUE);
1034 null->SetYTitle("dN/d#eta / dN/d#eta_{pythia}");
1035 null->GetYaxis()->CenterTitle(kTRUE);
1036 null->Draw();
8ca1a6d9 1037
5e08578b 1038 for (Int_t i=1; i<7; i++)
1039 ratios[i]->Draw("same");
fb30f6e3 1040
1041 TLegend* legend = new TLegend(0.6, 0.6, 0.95, 0.95);
1042 legend->SetFillColor(0);
1043
5e08578b 1044 TLatex* text[7];
1045 for (Int_t i=1; i<7; i++) {
fb30f6e3 1046 legend->AddEntry(dNdEta[i], descr[i]);
5e08578b 1047 }
fb30f6e3 1048
1049 legend->Draw();
da7acf97 1050 //text(0.2,0.88,"Effect of changing",0.045,1,kTRUE);
1051 //text(0.2,0.83,"relative cross-sections",0.045,1,kTRUE);
1052 //text(0.2,0.78,"(vertex reconstruction corr.)",0.043,13,kTRUE);
1053
1054 c->SaveAs(Form("%s.gif", c->GetName()));
fb30f6e3 1055 c->SaveAs(Form("%s.eps", c->GetName()));
5e08578b 1056}
1057
1058
1059
1060DrawTriggerEfficiency(Char_t* fileName) {
1061
1062 gStyle->SetOptStat(0);
1063 gStyle->SetOptTitle(0);
1064 gStyle->SetOptFit(0);
1065
1066 gStyle->SetTextSize(0.04);
1067 gStyle->SetTitleSize(0.05,"xyz");
1068 //gStyle->SetTitleFont(133, "xyz");
1069 //gStyle->SetLabelFont(133, "xyz");
1070 //gStyle->SetLabelSize(17, "xyz");
1071 gStyle->SetLabelOffset(0.01, "xyz");
1072
1073 gStyle->SetTitleOffset(1.1, "y");
1074 gStyle->SetTitleOffset(1.1, "x");
1075 gStyle->SetEndErrorSize(0.0);
1076
1077 //##############################################
1078
1079 //making canvas and pads
1080 TCanvas *c = new TCanvas("trigger_eff", "",600,500);
1081
1082 TPad* p1 = new TPad("pad1","", 0, 0.0, 1.0, 1.0, 0, 0, 0);
1083
1084 p1->SetBottomMargin(0.15);
1085 p1->SetTopMargin(0.03);
1086 p1->SetLeftMargin(0.15);
1087 p1->SetRightMargin(0.03);
1088
1089 p1->SetGridx();
1090 p1->SetGridy();
1091
1092 p1->Draw();
1093 p1->cd();
1094
1095 gSystem->Load("libPWG0base");
1096
1097 AlidNdEtaCorrection* corrections[4];
1098 AliCorrectionMatrix2D* triggerBiasCorrection[4];
1099
1100 TH1F* hTriggerEffInv[4];
1101 TH1F* hTriggerEff[4];
1102
1103 Char_t* names[] = {"triggerBiasND", "triggerBiasDD", "triggerBiasSD", "triggerBiasINEL"};
1104
1105 for (Int_t i=0; i<4; i++) {
1106 corrections[i] = new AlidNdEtaCorrection(names[i], names[i]);
1107 corrections[i]->LoadHistograms(fileName, names[i]);
1108
1109 triggerBiasCorrection[i] = corrections[i]->GetTriggerBiasCorrectionINEL();
1110
1111
1112 hTriggerEffInv[i] = triggerBiasCorrection[i]->Get1DCorrection();
1113 hTriggerEff[i] = (TH1F*)hTriggerEffInv[i]->Clone();
1114
1115 for (Int_t b=0; b<=hTriggerEff[i]->GetNbinsX(); b++) {
1116 hTriggerEff[i]->SetBinContent(b,1);
1117 hTriggerEff[i]->SetBinError(b,0);
1118 }
1119 hTriggerEff[i]->Divide(hTriggerEff[i],hTriggerEffInv[i]);
1120 hTriggerEff[i]->Scale(100);
1121 }
1122
1123 Int_t colors[] = {2,3,4,1};
1124 Float_t effs[4];
1125 for (Int_t i=0; i<4; i++) {
1126 hTriggerEff[i]->Fit("pol0","","",-20,20);
1127 effs[i] = ((TF1*)hTriggerEff[i]->GetListOfFunctions()->At(0))->GetParameter(0);
1128 ((TF1*)hTriggerEff[i]->GetListOfFunctions()->At(0))->SetLineWidth(1);
1129 ((TF1*)hTriggerEff[i]->GetListOfFunctions()->At(0))->SetLineStyle(2);
1130 ((TF1*)hTriggerEff[i]->GetListOfFunctions()->At(0))->SetLineColor(colors[i]);
1131 cout << effs[i] << endl;
1132 }
1133
1134
1135 Char_t* text[] = {"ND", "DD", "SD", "INEL"};
1136 TLatex* latex[4];
1137
1138 TH2F* null = new TH2F("","",100,-25,35,100,0,110);
1139 null->SetXTitle("Vertex z [cm]");
1140 null->GetXaxis()->CenterTitle(kTRUE);
1141 null->SetYTitle("Trigger efficiency [%]");
1142 null->GetYaxis()->CenterTitle(kTRUE);
1143 null->Draw();
1144
1145
1146 for (Int_t i=0; i<4; i++) {
1147 hTriggerEff[i]->SetLineWidth(2);
1148 hTriggerEff[i]->SetLineColor(colors[i]);
1149
1150 hTriggerEff[i]->Draw("same");
1151
1152 latex[i] = new TLatex(22,effs[i]-1.5, Form("%s (%0.1f)",text[i],effs[i]));
1153 latex[i]->SetTextColor(colors[i]);
1154 latex[i]->Draw();
1155 }
1156
1157}
1158
1159
1160DrawSpectraPID(Char_t* fileName) {
1161
1162 gSystem->Load("libPWG0base");
1163
1164 Char_t* names[] = {"correction_0", "correction_1", "correction_2", "correction_3"};
1165 AlidNdEtaCorrection* corrections[4];
1166 AliCorrectionMatrix3D* trackToPartCorrection[4];
1167
1168 TH1F* measuredPt[4];
1169 TH1F* generatedPt[4];
1170 TH1F* ratioPt[4];
1171
1172 for (Int_t i=0; i<4; i++) {
1173 corrections[i] = new AlidNdEtaCorrection(names[i], names[i]);
1174 corrections[i]->LoadHistograms(fileName, names[i]);
1175
1176 trackToPartCorrection[i] = corrections[i]->GetTrack2ParticleCorrection();
1177
1178 Int_t binX1 = (TH1F*)trackToPartCorrection[i]->GetMeasuredHistogram()->GetXaxis()->FindBin(-10);
1179 Int_t binX2 = (TH1F*)trackToPartCorrection[i]->GetMeasuredHistogram()->GetXaxis()->FindBin(10);
1180 Int_t binY1 = (TH1F*)trackToPartCorrection[i]->GetMeasuredHistogram()->GetYaxis()->FindBin(-1);
1181 Int_t binY2 = (TH1F*)trackToPartCorrection[i]->GetMeasuredHistogram()->GetYaxis()->FindBin(1);
1182
1183 measuredPt[i] = (TH1F*)trackToPartCorrection[i]->GetMeasuredHistogram()->ProjectionZ(Form("m_%d",i),binX1,binX2,binY1,binY2);
1184 generatedPt[i] = (TH1F*)trackToPartCorrection[i]->GetGeneratedHistogram()->ProjectionZ(Form("g_%d",i),binX1,binX2,binY1,binY2);
1185 ratioPt[i] = (TH1F*)generatedPt[i]->Clone(Form("r_%d",i));
1186 ratioPt[i]->Divide(measuredPt[i], generatedPt[i], 1,1,"B");
1187 }
1188
1189 ratioPt[0]->Draw();
1190
1191 for (Int_t i=0; i<3; i++) {
1192 ratioPt[i]->SetLineColor(i+1);
1193 ratioPt[i]->SetLineWidth(2);
1194
1195 ratioPt[i]->Draw("same");
1196
1197 }
1198
1199 return;
1200 measuredPt[0]->SetLineColor(2);
1201 measuredPt[0]->SetLineWidth(5);
1202
1203 measuredPt[0]->Draw();
1204 generatedPt[0]->Draw("same");
1205}
da7acf97 1206
8277513e 1207void changePtSpectrum(const char* fileName = "analysis_mc.root")
da7acf97 1208{
8277513e 1209 TFile* file = TFile::Open(fileName);
da7acf97 1210 TH1F* hist = dynamic_cast<TH1F*> (file->Get("dndeta_check_pt"));
1211
8ca1a6d9 1212 //hist->Rebin(3);
1213 //hist->Scale(1.0/3);
da7acf97 1214
1215 TH1F* clone1 = dynamic_cast<TH1F*> (hist->Clone("clone1"));
1216 TH1F* clone2 = dynamic_cast<TH1F*> (hist->Clone("clone2"));
1217
1218 TH1F* scale1 = dynamic_cast<TH1F*> (hist->Clone("scale1"));
1219 TH1F* scale2 = dynamic_cast<TH1F*> (hist->Clone("scale2"));
1220
1221 Float_t ptCutOff = 0.3;
1222
1223 for (Int_t i=1; i <= hist->GetNbinsX(); ++i)
1224 {
1225 if (hist->GetBinCenter(i) > ptCutOff)
1226 {
1227 scale1->SetBinContent(i, 1);
1228 scale2->SetBinContent(i, 1);
1229 }
1230 else
1231 {
1232 // 90 % at pt = 0, 0% at pt = ptcutoff
1233 scale1->SetBinContent(i, 1 - (ptCutOff - hist->GetBinCenter(i)) / ptCutOff * 0.3);
1234
1235 // 110% at pt = 0, ...
1236 scale2->SetBinContent(i, 1 + (ptCutOff - hist->GetBinCenter(i)) / ptCutOff * 0.3);
1237 }
8ca1a6d9 1238 scale1->SetBinError(i, 0);
1239 scale2->SetBinError(i, 0);
da7acf97 1240 }
1241
1242 new TCanvas;
8ca1a6d9 1243
da7acf97 1244 scale1->Draw();
1245 scale2->SetLineColor(kRed);
1246 scale2->Draw("SAME");
1247
1248 clone1->Multiply(scale1);
1249 clone2->Multiply(scale2);
1250
1251 Prepare1DPlot(hist);
1252 Prepare1DPlot(clone1);
1253 Prepare1DPlot(clone2);
1254
8ca1a6d9 1255 /*hist->SetMarkerStyle(markers[0]);
1256 clone1->SetMarkerStyle(markers[0]);
1257 clone2->SetMarkerStyle(markers[0]);*/
1258
8277513e 1259 hist->SetTitle(";p_{T} in GeV/c;dN_{ch}/dp_{T} in c/GeV");
da7acf97 1260 hist->GetXaxis()->SetRangeUser(0, 0.7);
8ca1a6d9 1261 hist->GetYaxis()->SetRangeUser(0.01, clone2->GetMaximum() * 1.1);
da7acf97 1262 hist->GetYaxis()->SetTitleOffset(1);
1263
1264 TCanvas* canvas = new TCanvas;
8ca1a6d9 1265 gPad->SetBottomMargin(0.12);
1266 hist->Draw("H");
da7acf97 1267 clone1->SetLineColor(kRed);
8ca1a6d9 1268 clone1->Draw("HSAME");
da7acf97 1269 clone2->SetLineColor(kBlue);
8ca1a6d9 1270 clone2->Draw("HSAME");
1271 hist->Draw("HSAME");
da7acf97 1272
1273 Float_t fraction = hist->Integral(hist->GetXaxis()->FindBin(ptCutOff), hist->GetNbinsX()) / hist->Integral(1, hist->GetNbinsX());
1274 Float_t fraction1 = clone1->Integral(clone1->GetXaxis()->FindBin(ptCutOff), clone1->GetNbinsX()) / clone1->Integral(1, clone1->GetNbinsX());
1275 Float_t fraction2 = clone2->Integral(clone2->GetXaxis()->FindBin(ptCutOff), clone2->GetNbinsX()) / clone2->Integral(1, clone2->GetNbinsX());
1276
1277 printf("%f %f %f\n", fraction, fraction1, fraction2);
1278 printf("Rel. %f %f\n", fraction1 / fraction, fraction2 / fraction);
1279
1280 canvas->SaveAs("changePtSpectrum.gif");
8ca1a6d9 1281 canvas->SaveAs("changePtSpectrum.eps");
da7acf97 1282}
fb30f6e3 1283
1284void FractionBelowPt()
1285{
1286 gSystem->Load("libPWG0base");
1287
1288 AlidNdEtaCorrection* fdNdEtaCorrection[4];
1289
1290 TFile::Open("systematics.root");
1291
1292 for (Int_t i=0; i<4; ++i)
1293 {
1294 TString name;
1295 name.Form("correction_%d", i);
1296 fdNdEtaCorrection[i] = new AlidNdEtaCorrection(name, name);
1297 fdNdEtaCorrection[i]->LoadHistograms("systematics.root", name);
1298 }
1299
1300 Double_t geneCount[5];
1301 Double_t measCount[5];
1302 geneCount[4] = 0;
1303 measCount[4] = 0;
1304
1305 for (Int_t i=0; i<4; ++i)
1306 {
1307 TH3F* hist = (TH3F*) fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetGeneratedHistogram();
1308 geneCount[i] = hist->Integral(hist->GetXaxis()->FindBin(-10), hist->GetXaxis()->FindBin(10),
1309 hist->GetYaxis()->FindBin(-0.8), hist->GetYaxis()->FindBin(0.8),
1310 1, hist->GetZaxis()->FindBin(0.3));
1311
1312 hist = (TH3F*) fdNdEtaCorrection[i]->GetTrack2ParticleCorrection()->GetMeasuredHistogram();
1313 measCount[i] = hist->Integral(hist->GetXaxis()->FindBin(-10), hist->GetXaxis()->FindBin(10), hist->GetYaxis()->FindBin(-0.8), hist->GetYaxis()->FindBin(0.8), 1, hist->GetZaxis()->FindBin(0.3));
1314
1315 geneCount[4] += geneCount[i];
1316 measCount[4] += measCount[i];
1317
1318 printf("Particle %s: %d gene, %d meas\n", ((i == 0) ? "pi" : (i == 1) ? "K" : (i == 2) ? "p" : "others"), (Int_t) geneCount[i], (Int_t) measCount[i]);
1319 }
1320
1321 printf("Generated ratios are: %f pi, %f K, %f p, %f others\n", geneCount[0] / geneCount[4], geneCount[1] / geneCount[4], geneCount[2] / geneCount[4], geneCount[3] / geneCount[4]);
1322
1323 printf("Reconstructed ratios are: %f pi, %f K, %f p, %f others\n", measCount[0] / measCount[4], measCount[1] / measCount[4], measCount[2] / measCount[4], measCount[3] / measCount[4]);
7f0efb86 1324}
8ca1a6d9 1325
1326
1327mergeCorrectionsMisalignment(Char_t* alignedFile = "correction_map_aligned.root",
1328 Char_t* misalignedFile = "correction_map_misaligned.root",
1329 Char_t* outputFileName="correction_map_misaligned_single.root")
1330{
1331 //
1332 // from the aligned and misaligned corrections, 3 new corrections are created
1333 // in these new corrections only one of the corrections (track2particle, vertex, trigger)
1334 // is taken from the misaligned input to allow study of the effect on the different
1335 // corrections
1336
1337 gSystem->Load("libPWG0base");
1338
1339 const Char_t* typeName[] = { "track2particle", "vertex", "trigger" };
1340
1341 AlidNdEtaCorrection* corrections[3];
1342 for (Int_t j=0; j<3; j++) { // j = 0 (track2particle), j = 1 (vertex), j = 2 (trigger)
1343 AlidNdEtaCorrection* alignedCorrection = new AlidNdEtaCorrection("dndeta_correction","dndeta_correction");
1344 alignedCorrection->LoadHistograms(alignedFile);
1345
1346 AlidNdEtaCorrection* misalignedCorrection = new AlidNdEtaCorrection("dndeta_correction","dndeta_correction");
1347 misalignedCorrection->LoadHistograms(misalignedFile);
1348
1349 TString name;
1350 name.Form("dndeta_correction_alignment_%s", typeName[j]);
1351 AlidNdEtaCorrection* current = new AlidNdEtaCorrection(name, name);
1352
1353 switch (j)
1354 {
1355 case 0:
1356 alignedCorrection->GetTrack2ParticleCorrection()->Reset();
1357 misalignedCorrection->GetTriggerBiasCorrectionNSD()->Reset();
1358 misalignedCorrection->GetTriggerBiasCorrectionND()->Reset();
1359 misalignedCorrection->GetTriggerBiasCorrectionINEL()->Reset();
1360 misalignedCorrection->GetVertexRecoCorrection()->Reset();
1361 break;
1362
1363 case 1:
1364 misalignedCorrection->GetTrack2ParticleCorrection()->Reset();
1365 misalignedCorrection->GetTriggerBiasCorrectionNSD()->Reset();
1366 misalignedCorrection->GetTriggerBiasCorrectionND()->Reset();
1367 misalignedCorrection->GetTriggerBiasCorrectionINEL()->Reset();
1368 alignedCorrection->GetVertexRecoCorrection()->Reset();
1369 break;
1370
1371 case 2:
1372 misalignedCorrection->GetTrack2ParticleCorrection()->Reset();
1373 alignedCorrection->GetTriggerBiasCorrectionNSD()->Reset();
1374 alignedCorrection->GetTriggerBiasCorrectionND()->Reset();
1375 alignedCorrection->GetTriggerBiasCorrectionINEL()->Reset();
1376 misalignedCorrection->GetVertexRecoCorrection()->Reset();
1377 break;
1378
1379 default:
1380 return;
1381 }
1382
1383 TList collection;
1384 collection.Add(misalignedCorrection);
1385 collection.Add(alignedCorrection);
1386
1387 current->Merge(&collection);
1388 current->Finish();
1389
1390 corrections[j] = current;
1391 }
1392
1393 TFile* fout = new TFile(outputFileName, "RECREATE");
1394
1395 for (Int_t i=0; i<3; i++)
1396 corrections[i]->SaveHistograms();
1397
1398 fout->Write();
1399 fout->Close();
1400}
1401
1402
1403void DrawdNdEtaDifferencesAlignment()
1404{
1405 TH1* hists[5];
1406
1407 TLegend* legend = new TLegend(0.3, 0.73, 0.70, 0.98);
1408 legend->SetFillColor(0);
1409
1410 TCanvas* canvas = new TCanvas("DrawdNdEtaDifferences", "DrawdNdEtaDifferences", 1000, 500);
1411 canvas->Divide(2, 1);
1412
1413 canvas->cd(1);
1414
1415 for (Int_t i=0; i<5; ++i)
1416 {
1417 hists[i] = 0;
1418 TFile* file = 0;
1419 TString title;
1420
1421 switch(i)
1422 {
1423 case 0 : file = TFile::Open("systematics_misalignment_aligned.root"); title = "aligned"; break;
1424 case 1 : file = TFile::Open("systematics_misalignment_misaligned.root"); title = "fully misaligned"; break;
1425 case 2 : file = TFile::Open("systematics_misalignment_track2particle.root"); title = "only track2particle"; break;
1426 case 3 : file = TFile::Open("systematics_misalignment_vertex.root"); title = "only vertex rec."; break;
1427 case 4 : file = TFile::Open("systematics_misalignment_trigger.root"); title = "only trigger bias"; break;
1428 default: return;
1429 }
1430
1431 if (file)
1432 {
1433 hists[i] = (TH1*) file->Get("dndeta/dndeta_dNdEta_corrected_2");
1434 hists[i]->SetTitle("");
1435
1436 Prepare1DPlot(hists[i], kFALSE);
1437 hists[i]->GetXaxis()->SetRangeUser(-0.7999, 0.7999);
1438 hists[i]->GetYaxis()->SetRangeUser(6, 7);
1439 hists[i]->SetLineWidth(1);
1440 hists[i]->SetLineColor(colors[i]);
1441 hists[i]->SetMarkerColor(colors[i]);
1442 hists[i]->SetMarkerStyle(markers[i]);
1443 hists[i]->GetXaxis()->SetLabelOffset(0.015);
1444 hists[i]->GetYaxis()->SetTitleOffset(1.5);
1445 gPad->SetLeftMargin(0.12);
1446 hists[i]->DrawCopy(((i > 0) ? "SAME" : ""));
1447
1448 legend->AddEntry(hists[i], title);
1449 hists[i]->SetTitle(title);
1450 }
1451 }
1452 legend->Draw();
1453
1454 canvas->cd(2);
1455 gPad->SetLeftMargin(0.14);
1456
1457 TLegend* legend2 = new TLegend(0.63, 0.73, 0.98, 0.98);
1458 legend2->SetFillColor(0);
1459
1460 for (Int_t i=1; i<5; ++i)
1461 {
1462 if (hists[i])
1463 {
1464 legend2->AddEntry(hists[i]);
1465
1466 hists[i]->Divide(hists[0]);
1467 hists[i]->SetTitle("b)");
1468 hists[i]->GetYaxis()->SetRangeUser(0.9, 1.1);
1469 hists[i]->GetYaxis()->SetTitle("Ratio to standard composition");
1470 hists[i]->GetYaxis()->SetTitleOffset(1.8);
1471 hists[i]->DrawCopy(((i > 1) ? "SAME" : ""));
1472 }
1473 }
1474
1475 legend2->Draw();
1476
1477 canvas->SaveAs("misalignment_result.eps");
1478 canvas->SaveAs("misalignment_result.gif");
1479}
1480
1481void EvaluateMultiplicityEffect()
1482{
1483 gSystem->Load("libPWG0base");
1484
1485 AlidNdEtaCorrection* fdNdEtaCorrectionLow[4];
1486 AlidNdEtaCorrection* fdNdEtaCorrectionHigh[4];
1487
1488 TFile::Open("systematics-low-multiplicity.root");
1489
1490 for (Int_t i=0; i<4; ++i)
1491 {
1492 TString name;
1493 name.Form("correction_%d", i);
1494 fdNdEtaCorrectionLow[i] = new AlidNdEtaCorrection(name, name);
1495 fdNdEtaCorrectionLow[i]->LoadHistograms("systematics-low-multiplicity.root", name);
1496 }
1497
1498 TList list;
1499 for (Int_t i=1; i<4; ++i)
1500 list.Add(fdNdEtaCorrectionLow[i]);
1501
1502 fdNdEtaCorrectionLow[0]->Merge(&list);
1503 fdNdEtaCorrectionLow[0]->Finish();
1504
1505 TFile::Open("systematics-high-multiplicity.root");
1506
1507 for (Int_t i=0; i<4; ++i)
1508 {
1509 TString name;
1510 name.Form("correction_%d", i);
1511 fdNdEtaCorrectionHigh[i] = new AlidNdEtaCorrection(name, name);
1512 fdNdEtaCorrectionHigh[i]->LoadHistograms("systematics-high-multiplicity.root", name);
1513 }
1514
1515 TList list2;
1516 for (Int_t i=1; i<4; ++i)
1517 list2.Add(fdNdEtaCorrectionHigh[i]);
1518
1519 fdNdEtaCorrectionHigh[0]->Merge(&list2);
1520 fdNdEtaCorrectionHigh[0]->Finish();
1521
1522 TH1F* outputLow = new TH1F("Track2ParticleLow", "Track2Particle at low multiplicity", 200, 0, 2);
1523 TH1F* outputHigh = new TH1F("Track2ParticleHigh", "Track2Particle at high multiplicity", 200, 0, 2);
1524
1525 TH3F* hist = fdNdEtaCorrectionLow[0]->GetTrack2ParticleCorrection()->GetCorrectionHistogram();
1526 TH3F* hist2 = fdNdEtaCorrectionHigh[0]->GetTrack2ParticleCorrection()->GetCorrectionHistogram();
1527 for (Int_t x=hist->GetXaxis()->FindBin(-10); x<=hist->GetXaxis()->FindBin(10); ++x)
1528 for (Int_t y=hist->GetYaxis()->FindBin(-0.8); y<=hist->GetYaxis()->FindBin(0.8); ++y)
1529 for (Int_t z=hist->GetZaxis()->FindBin(0.3); z<=hist->GetZaxis()->FindBin(9.9); ++z)
1530 //for (Int_t z=1; z<=hist->GetNbinsZ(); ++z)
1531 {
1532 if (hist->GetBinContent(x, y, z) > 0)
1533 outputLow->Fill(hist->GetBinContent(x, y, z));
1534 //if (hist->GetBinContent(x, y, z) == 1)
1535 // printf("z = %f, eta = %f, pt = %f: %f %f %f\n", hist->GetXaxis()->GetBinCenter(x), hist->GetYaxis()->GetBinCenter(y), hist->GetZaxis()->GetBinCenter(z), hist->GetBinContent(x, y, z), fdNdEtaCorrectionLow[0]->GetTrack2ParticleCorrection()->GetGeneratedHistogram()->GetBinContent(x, y, z), fdNdEtaCorrectionLow[0]->GetTrack2ParticleCorrection()->GetMeasuredHistogram()->GetBinContent(x, y, z));
1536
1537 if (hist2->GetBinContent(x, y, z) > 0)
1538 outputHigh->Fill(hist2->GetBinContent(x, y, z));
1539 }
1540
1541 TCanvas* canvas = new TCanvas("EvaluateMultiplicityEffect", "EvaluateMultiplicityEffect", 1000, 500);
1542 canvas->Divide(2, 1);
1543
1544 canvas->cd(1);
1545 outputLow->Draw();
1546 outputLow->Fit("gaus", "0");
1547 outputLow->GetFunction("gaus")->SetLineColor(2);
1548 outputLow->GetFunction("gaus")->DrawCopy("SAME");
1549
1550 canvas->cd(2);
1551 outputHigh->Draw();
1552 outputHigh->Fit("gaus", "0");
1553 outputHigh->GetFunction("gaus")->DrawCopy("SAME");
1554
1555 canvas->SaveAs(Form("%s.gif", canvas->GetName()));
1556}
1557
1558void PlotErrors(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax, const char* correctionMapFile = "correction_map.root", const char* correctionMapFolder = "dndeta_correction")
1559{
1560 gSystem->Load("libPWG0base");
1561
1562 AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection(correctionMapFolder, correctionMapFolder);
1563 dNdEtaCorrection->LoadHistograms(correctionMapFile, correctionMapFolder);
1564
1565 dNdEtaCorrection->GetTrack2ParticleCorrection()->PlotBinErrors(xmin, xmax, ymin, ymax, zmin, zmax)->Draw();
1566}
9e952c39 1567
1568
1569void runStudy(const char* baseCorrectionMapFile = "correction_map.root", const char* baseCorrectionMapFolder = "dndeta_correction", const char* changedCorrectionMapFile = "correction_map.root", const char* changedCorrectionMapFolder = "dndeta_correction", const char* dataFile = "analysis_esd_raw.root", const char* output = "analysis_esd_syst.root")
1570{
1571 gSystem->Load("libPWG0base");
1572
1573 TFile* file = TFile::Open(output, "RECREATE");
1574
1575 const Int_t max = 5;
1576 dNdEtaAnalysis* fdNdEtaAnalysis[5];
1577
1578 new TCanvas;
1579 TLegend* legend = new TLegend(0.63, 0.73, 0.98, 0.98);
1580 legend->SetFillColor(0);
1581
1582 for (Int_t i = 0; i < max; ++i)
1583 {
1584 TFile::Open(baseCorrectionMapFile);
1585 AlidNdEtaCorrection* baseCorrection = new AlidNdEtaCorrection(baseCorrectionMapFolder, baseCorrectionMapFolder);
1586 baseCorrection->LoadHistograms();
1587
1588 AlidNdEtaCorrection::CorrectionType correctionType = AlidNdEtaCorrection::kNone;
1589 const char* name = 0;
1590
1591 TFile::Open(changedCorrectionMapFile);
1592 switch (i)
1593 {
1594 case 0 :
1595 name = "default";
1596 break;
1597
1598 case 1 :
1599 baseCorrection->GetTrack2ParticleCorrection()->LoadHistograms(Form("%s/Track2Particle", changedCorrectionMapFolder));
1600 name = "Track2Particle";
1601 break;
1602
1603 case 2 :
1604 baseCorrection->GetVertexRecoCorrection()->LoadHistograms(Form("%s/VertexReconstruction", changedCorrectionMapFolder));
1605 name = "VertexReco";
1606 break;
1607
1608 case 3 :
1609 baseCorrection->GetTriggerBiasCorrectionINEL()->LoadHistograms(Form("%s/TriggerBias_MBToINEL", changedCorrectionMapFolder));
1610 name = "TriggerBias_MBToINEL";
1611 break;
1612
1613 case 4 :
1614 baseCorrection->LoadHistograms(changedCorrectionMapFolder);
1615 name = "all";
1616 break;
1617
1618 default: return;
1619 }
1620
1621 TFile::Open(dataFile);
1622 fdNdEtaAnalysis[i] = new dNdEtaAnalysis(name, name);
1623 fdNdEtaAnalysis[i]->LoadHistograms("dndeta");
1624
1625 fdNdEtaAnalysis[i]->Finish(baseCorrection, 0.3, AlidNdEtaCorrection::kINEL);
1626 file->cd();
1627 fdNdEtaAnalysis[i]->SaveHistograms();
1628
1629 TH1* hist = fdNdEtaAnalysis[i]->GetdNdEtaHistogram(0);
1630 hist->SetLineColor(colors[i]);
1631 hist->SetMarkerColor(colors[i]);
1632 hist->SetMarkerStyle(markers[i]+1);
1633 hist->DrawCopy((i == 0) ? "" : "SAME");
1634 legend->AddEntry(hist, name);
1635 }
1636
1637 legend->Draw();
1638}