1 #if !defined(__CINT__) || defined(__MAKECINT__)
4 #include "TGraphErrors.h"
6 #include "AliBWTools.h"
9 #include "TDatabasePDG.h"
14 #include "AliLatexTable.h"
16 #include "TVirtualFitter.h"
25 #include "TPaveText.h"
26 #include "StarPPSpectra.C"
27 #include "GetE735Ratios.C"
34 // A bunch of useful enums and constants
35 enum {kPion=0,kKaon,kProton,kNPart};
36 enum {kTPC=0,kTOF,kITS,kITSTPC,kK0,kKinks,kCombTOFTPC,kCombAll,kNHist};// "k0" listed here as a kind of PID method...
37 const Int_t kNDet = kITS+2;
38 enum {kPos=0,kNeg,kNCharge};
39 enum {kPhojet=0,kPyTuneAtlasCSC, kPyTuneCMS6D6T, kPyTunePerugia0, kNTunes} ;
40 enum {kFitLevi=0, kFitUA1, kFitPowerLaw,
41 kFitPhojet, kFitAtlasCSC, kFitCMS6D6T, kFitPerugia0,
43 enum {kDoFits=0, kDoRatios, kDoSuperposition, kDoDrawWithModels, kDoCompareToStar, kDoHelp};
45 // flags, labels and names
46 const char * partFlag[] = {"Pion", "Kaon", "Proton"};
47 const char * detFlag[] = {"TPC", "TOF", "ITS", "ITS Global", "K0", "Kinks", "Combined TOF + TPC", "Combined TOF + TPC + ITS"};
48 const char * chargeFlag[] = {"Pos", "Neg"};
49 const char * chargeLabel[] = {"Positive", "Negative"};
50 const char * partLabel[kNPart][kNCharge] = {{"#pi^{+}", "#pi^{-}"},
51 // {"K^{+} (#times 2)", "K^{-} (#times 2)"},
54 const char * partLatex[kNPart][kNCharge] = {{"$\\pi^{+}$", "$\\pi^{-}$"},
55 // {"K^{+} (#times 2)", "K^{-} (#times 2)"},
56 {"$K^{+}$", "$K^{-}$"},
57 {"$p$" , "$\\bar{p}$"}};
58 const char * mcTuneName[] = {"Phojet",
61 "Pythia - Perugia0 - 320", };
62 const char * funcName[] = { "Levi", "UA1", "PowerLaw", "Phojet", "AtlasCSC", "CMS6D6T", "Perugia0"};
65 //const Int_t marker[] = {25,24,28,20,21}; // set for highlithining marek
66 const Int_t marker[] = {20,24,25,28,21}; // standard set
67 const Int_t color [] = {1,2,4};
69 const Int_t mcLineColor[] = {kGreen,kRed,kBlue,kBlack};
70 const Int_t mcLineStyle[] = {1,2,3,4};
73 // Template needed to combine different detectors
74 const Float_t templBins[] = {0.05,0.1,0.12,0.14,0.16,0.18,0.20,0.25,0.30,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,2,2.2,2.4,2.6};
77 TH1F * htemplate = new TH1F("htemplate", "htemplate",nbinsTempl, templBins );
80 TH1F * hSpectra[kNHist][kNPart][kNCharge];
81 TH1F * hSpectraMC[kNTunes][kNPart][kNCharge];
82 Double_t mass[kNPart];
89 // Additional tasks (may be uncommented below)
90 void DrawStar(Int_t icharge);
91 void GetITSResiduals();
92 void DrawWithModels() ;
93 void DrawAllAndKaons();
95 void DrawRatioToStar();
101 void ALICEWorkInProgress(TCanvas *c,TString today="11/05/2010", TString label = "ALICE performance"){
103 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",0.72,0.79,0.82,0.89);
104 myPadLogo->SetFillColor(0);
105 myPadLogo->SetBorderMode(0);
106 myPadLogo->SetBorderSize(2);
107 myPadLogo->SetFrameBorderMode(0);
108 myPadLogo->SetLeftMargin(0.0);
109 myPadLogo->SetTopMargin(0.0);
110 myPadLogo->SetBottomMargin(0.0);
111 myPadLogo->SetRightMargin(0.0);
112 myPadLogo->SetFillStyle(0);
115 TASImage *myAliceLogo = new TASImage("alice_logo.png");
118 TPaveText* t1=new TPaveText(0.65,0.73,0.89,0.78,"NDC");
120 t1->SetBorderSize(0);
121 t1->AddText(0.,0.,label);
122 t1->SetTextColor(kRed);
125 TPaveText* t2=new TPaveText(0.65,0.65,0.89,0.7,"NDC");
127 t2->SetBorderSize(0);
128 t2->SetTextColor(kRed);
130 t2->AddText(0.,0.,today.Data());
141 Bool_t convertToMT = 0;
143 Bool_t scaleKaons = kFALSE;
144 Bool_t drawStar = kTRUE; // Overlay star when doing fits
145 Bool_t correctSecondaries = 1;
146 Bool_t correctGeantFlukaXS = 1;
147 Int_t iCombInStudy = kCombAll; //kCombTOFTPC
148 Int_t fitFuncID = kFitLevi;
150 Bool_t showE735=kTRUE;
151 Bool_t useSecCorrFromDCA=kFALSE;
153 void CombineSpectra(Int_t analysisType=kDoHelp, Int_t locfitFuncID = kFitLevi) { //kDoSuperposition;//kDoDrawWithModels;// kDoFits; //kDoRatios;
155 // This macro is used to combine the 900 GeV spectra from 2009
157 fitFuncID=locfitFuncID;
160 gSystem->Load("libTree.so");
161 gSystem->Load("libVMC.so");
162 gSystem->Load("libMinuit.so");
163 gSystem->Load("libSTEERBase.so");
164 gSystem->Load("libESD.so");
165 gSystem->Load("libAOD.so");
166 gSystem->Load("libANALYSIS.so");
167 gSystem->Load("libANALYSISalice.so");
168 gSystem->Load("libCORRFW.so");
169 gSystem->Load("libPWG2spectra.so");
171 // Print Help and quit
172 if (analysisType == kDoHelp) {
179 today = today + long(dt.GetDay()) +"/" + long(dt.GetMonth()) +"/"+ long(dt.GetYear());
183 mass[kPion] = TDatabasePDG::Instance()->GetParticle("pi+")->Mass();
184 mass[kKaon] = TDatabasePDG::Instance()->GetParticle("K+")->Mass();
185 mass[kProton] = TDatabasePDG::Instance()->GetParticle("proton")->Mass();
193 // GetITSResiduals();
194 if(analysisType==kDoSuperposition) DrawAllAndKaons();
195 else if(analysisType==kDoDrawWithModels) DrawWithModels() ;
197 else if(analysisType==kDoCompareToStar) DrawRatioToStar();
198 else if(analysisType==kDoRatios) DrawRatios();
199 else if(analysisType==kDoFits) FitCombined();
205 gStyle->SetOptTitle(0);
206 gStyle->SetOptStat(0);
208 // Draw combined & Fit
209 AliBWFunc * fm = new AliBWFunc;
210 fm->SetVarType(AliBWFunc::kdNdpt);
211 if (convertToMT) fm->SetVarType(AliBWFunc::kOneOverMtdNdmt);
213 // table to print results
214 AliLatexTable table(10,"c|ccccccccc");
215 if (fitFuncID == kFitLevi) {
216 table.InsertCustomRow("Part & Yield & Yield (FIT) & T Slope & n & $\\chi^2$/NDF & Min X & Frac Above & $\\langle p_{t} \\rangle$ & $\\langle p_{t}^{2} \\rangle$ \\\\");
217 } else if (fitFuncID == kFitPowerLaw) {
218 table.InsertCustomRow("Part & Yield & Norm & n & pt0 & $\\chi^2$/NDF & Min X & Frac Above & $\\langle p_{t} \\rangle$ & $\\langle p_{t}^{2} \\rangle$ \\\\");
220 table.InsertCustomRow("Part & Yield & Par0 & Par2 & Par1 & $\\chi^2$/NDF & Min X & Frac Above & $\\langle p_{t} \\rangle$ & $\\langle p_{t}^{2} \\rangle$ \\\\");
224 AliLatexTable tempTable(4,"c|ccc");
225 tempTable.InsertCustomRow("Part & Yield & Yield Below & Frac Above\\\\");
228 TH1F* hRatiosToFit[kNPart][kNCharge];
230 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
232 TCanvas * c2 = new TCanvas(TString("cCombined")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombined")+chargeFlag[icharge],700,700);
235 c2->SetLeftMargin(0.14);
236 TCanvas * c2r = new TCanvas(TString("cCombinedRatio")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombinedRatio")+chargeFlag[icharge],700,700);
239 TH2F * hempty = new TH2F(TString("hempty")+long(icharge),"hempty",100,0.,2.9, 100, 0.0005,5);
240 hempty->SetXTitle("p_{t} (GeV/c)");
241 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
242 hempty->GetYaxis()->SetTitleOffset(1.35);
243 hempty->GetXaxis()->SetTitleOffset(1.1);
247 TH2F * hemptyR = new TH2F(TString("hemptyR")+long(icharge),"hemptyR",100,0.,2.9, 100, 0.5,1.5);
248 hemptyR->SetXTitle("p_{t} (GeV/c)");
249 hemptyR->SetYTitle("Data/Fit");
252 TLegend * l = new TLegend(0.516779, 0.7, 0.89094 ,0.916084, chargeLabel[icharge]);
253 l->SetFillColor(kWhite);
254 l->SetTextSize(0.035);
255 TPaveText* tf=new TPaveText(0.18,0.14,0.56,0.29,"NDC");
256 if(fitFuncID == kFitLevi){
257 tf->AddText("#frac{dN}{dp_{t}} #propto p_{t} #left(1+#frac{#sqrt{m^{2}+p_{t}^{2}} -m}{nT} #right)^{-n}");
260 tf->SetTextSize(0.035);
262 for(Int_t ipart = 0; ipart < kNPart; ipart++){
263 printf(" ----- Fit %s %s ------\n",partFlag[ipart],chargeFlag[icharge]);
270 if(fitFuncID == kFitLevi) {
271 normPar = 0; // The levi is normalized by parameter 0
273 func = fm->GetLevi(mass[ipart], 0.12, 7, 1.5);
275 func = fm->GetLevi(mass[ipart], 0.17, 7, 0.17);
276 if (ipart == kProton)
277 func = fm->GetLevi(mass[ipart], 0.15, 8.5, 0.09);
279 else if(fitFuncID == kFitUA1) func = fm->GetUA1(mass[ipart],0.2,1.25,1.25,0.2,1.5);
280 else if(fitFuncID == kFitPowerLaw) {
282 func = fm->GetPowerLaw(1.0, 8.6, 7);
284 func = fm->GetPowerLaw(3.0, 12, 2.6);
285 if (ipart == kProton)
286 func = fm->GetPowerLaw(24, 72, 0.8);
288 else if(fitFuncID == kFitPhojet) func = fm->GetHistoFunc(hSpectraMC[kPhojet] [ipart][icharge]);
289 else if(fitFuncID == kFitAtlasCSC) func = fm->GetHistoFunc(hSpectraMC[kPyTuneAtlasCSC][ipart][icharge]);
290 else if(fitFuncID == kFitPerugia0) func = fm->GetHistoFunc(hSpectraMC[kPyTunePerugia0][ipart][icharge]);
291 else if(fitFuncID == kFitCMS6D6T) func = fm->GetHistoFunc(hSpectraMC[kPyTuneCMS6D6T] [ipart][icharge]);
293 cout << "Unknown fit ID " << fitFuncID << endl;
297 if(fitFuncID >= kFitPhojet){
302 if(!AliBWTools::Fit(hSpectra[iCombInStudy][ipart][icharge],func,fitmin,fitmax)) {
303 cout << " FIT ERROR " << endl;
307 hSpectra[iCombInStudy][ipart][icharge]->Draw("same");
308 TF1* fitfunc=(TF1*)hSpectra[iCombInStudy][ipart][icharge]->GetListOfFunctions()->At(0);
309 fitfunc->Draw("same");
310 fitfunc->SetRange(0,4);
311 fitfunc->SetLineColor(hSpectra[iCombInStudy][ipart][icharge]->GetLineColor());
312 if(drawStar) DrawStar(icharge);
313 hRatiosToFit[ipart][icharge]=(TH1F*)hSpectra[iCombInStudy][ipart][icharge]->Clone(Form("hRatio%s%s",chargeFlag[icharge],partFlag[icharge])); // Ratio data/fit
314 for(Int_t iBin=1; iBin<hSpectra[iCombInStudy][ipart][icharge]->GetNbinsX(); iBin++){
315 Double_t lowLim=hSpectra[iCombInStudy][ipart][icharge]->GetBinLowEdge(iBin);
316 Double_t highLim=hSpectra[iCombInStudy][ipart][icharge]->GetBinLowEdge(iBin+1);
317 Double_t contFunc=fitfunc->Integral(lowLim,highLim)/(highLim-lowLim);
318 Double_t ratio=hSpectra[iCombInStudy][ipart][icharge]->GetBinContent(iBin)/contFunc;
319 Double_t eratio=hSpectra[iCombInStudy][ipart][icharge]->GetBinError(iBin)/contFunc;
320 hRatiosToFit[ipart][icharge]->SetBinContent(iBin,ratio);
321 hRatiosToFit[ipart][icharge]->SetBinError(iBin,eratio);
323 // hSpectra[iCombInStudy][ipart][icharge]->GetListOfFunctions()->At(0)->Draw("same");
324 // ((TF1*)hSpectra[iCombInStudy][ipart][icharge]->GetListOfFunctions()->At(0))->SetRange(0,4);
325 // ((TF1*)hSpectra[iCombInStudy][ipart][icharge]->GetListOfFunctions()->At(0))->SetLineColor(hSpectra[iCombInStudy][ipart][icharge]->GetLineColor());
327 l->AddEntry(hSpectra[iCombInStudy][ipart][icharge],
328 scaleKaons && ipart == kKaon ?
329 (TString(partLabel[ipart][icharge])+" #times 2").Data()
330 : partLabel[ipart][icharge]);
331 // TF1 * fClone = (TF1*) hSpectra[iCombInStudy][ipart][icharge]->GetListOfFunctions()->At(0)->Clone();
332 // hSpectra[iCombInStudy][ipart][icharge]->GetListOfFunctions()->Add(fClone);
333 // fClone->SetLineStyle(kDashed);
334 // fClone->SetRange(0,100);
335 // fClone->Draw("same");
338 // Float_t yield = func->Integral(0.45,1.05);
339 // Float_t yieldE = func->IntegralError(0.45,1.05);
341 Float_t yield = func->Integral(0.,100);
342 //Float_t yieldE = func->IntegralError(0.,100);
344 Double_t yieldTools, yieldETools;
345 Double_t partialYields[3],partialYieldsErrors[3];
346 AliBWTools::GetYield(hSpectra[iCombInStudy][ipart][icharge], func, yieldTools, yieldETools,
347 0, 100, partialYields,partialYieldsErrors);
348 Double_t tslope = func->GetParameter(2);
349 Double_t tslopeE = func->GetParError(2);
351 table.SetNextCol(partLatex[ipart][icharge]);
352 //table.SetNextCol(yield,yieldE,-4);
353 table.SetNextCol(yieldTools, yieldETools,-4);
354 table.SetNextCol(func->GetParameter(0));
355 table.SetNextCol(tslope,tslopeE,-4);
356 table.SetNextCol(func->GetParameter(1),func->GetParError(1));
357 table.SetNextCol(Form("%2.2f/%d",func->GetChisquare(),func->GetNDF()));
358 Float_t lowestPoint = AliBWTools::GetLowestNotEmptyBinEdge(hSpectra[iCombInStudy][ipart][icharge]);
359 //Float_t lowestPoint = AliBWTools::GetLowestNotEmptyBinEdge(hSpectra[kITS][ipart][icharge]);
360 Float_t yieldAbove = func->Integral(lowestPoint,100);
361 table.SetNextCol(lowestPoint,-2);
362 table.SetNextCol(yieldAbove/yield,-2);
364 Float_t mean2, mean2e;
365 AliBWTools::GetMean (func, mean, meane , 0.,100., normPar);
366 AliBWTools::GetMeanSquare(func, mean2, mean2e, 0.,100., normPar);
367 table.SetNextCol(mean, meane ,-4);
368 table.SetNextCol(mean2, mean2e,-4);
370 // fMean2->IntegralError(0,100)/func->Integral(0,100),-7);
375 tempTable.SetNextCol(partLabel[ipart][icharge]);
376 tempTable.SetNextCol(yieldTools, yieldETools, -4);
377 tempTable.SetNextCol(partialYields[1], partialYieldsErrors[1], -4);
378 tempTable.SetNextCol(yieldAbove/yield,-2);
379 tempTable.InsertRow();
381 hRatiosToFit[ipart][icharge]->Draw("esame");
391 gSystem->ProcessEvents();
393 c2->Print(TString(c2->GetName()) + ".eps");
394 ALICEWorkInProgress(c2,"","#splitline{ALICE Preliminary}{Statistical Error Only}");
396 c2->Print(TString(c2->GetName()) + ".png");
398 gSystem->ProcessEvents();
399 c2r->Print(TString(c2r->GetName()) + ".eps");
400 c2r->Print(TString(c2r->GetName()) + ".png");
407 table.PrintTable("");
410 tempTable.PrintTable("ASCII");
425 f = new TFile("./Files/effhistos.root");
426 TH1D * hEffTrackTOF[kNPart][kNCharge];
427 TH1D * hEffMatchTOF[kNPart][kNCharge];
428 hEffTrackTOF[kPion] [kPos] = (TH1D*) f->Get("hpitrk_pos");
429 hEffTrackTOF[kKaon] [kPos] = (TH1D*) f->Get("hkatrk_pos");
430 hEffTrackTOF[kProton][kPos] = (TH1D*) f->Get("hprtrk_pos");
431 hEffMatchTOF[kPion] [kPos] = (TH1D*) f->Get("hpieff_pos");
432 hEffMatchTOF[kKaon] [kPos] = (TH1D*) f->Get("hkaeff_pos");
433 hEffMatchTOF[kProton][kPos] = (TH1D*) f->Get("hpreff_pos");
434 hEffTrackTOF[kPion] [kNeg] = (TH1D*) f->Get("hpitrk_neg");
435 hEffTrackTOF[kKaon] [kNeg] = (TH1D*) f->Get("hkatrk_neg");
436 hEffTrackTOF[kProton][kNeg] = (TH1D*) f->Get("hprtrk_neg");
437 hEffMatchTOF[kPion] [kNeg] = (TH1D*) f->Get("hpieff_neg");
438 hEffMatchTOF[kKaon] [kNeg] = (TH1D*) f->Get("hkaeff_neg");
439 hEffMatchTOF[kProton][kNeg] = (TH1D*) f->Get("hpreff_neg");
441 // f = new TFile("./Files/spectra-pos-y.root");
442 f = new TFile("./Files/spectraRaw-pos-y.root");
443 hSpectra[kTOF][kPion] [kPos]= (TH1F*) f->Get("hpi");
444 hSpectra[kTOF][kProton][kPos]= (TH1F*) f->Get("hpr");
445 hSpectra[kTOF][kKaon] [kPos]= (TH1F*) f->Get("hka");
446 hSpectra[kTOF][kPion] [kPos]->SetName("hpiPos");
447 hSpectra[kTOF][kProton][kPos]->SetName("hprPos");
448 hSpectra[kTOF][kKaon] [kPos]->SetName("hkaPos");
449 //f = new TFile("./Files/spectra-neg-y.root");
450 f = new TFile("./Files/spectraRaw-neg-y.root");
451 hSpectra[kTOF][kPion] [kNeg]= (TH1F*) f->Get("hpi");
452 hSpectra[kTOF][kProton][kNeg]= (TH1F*) f->Get("hpr");
453 hSpectra[kTOF][kKaon] [kNeg]= (TH1F*) f->Get("hka");
454 hSpectra[kTOF][kPion] [kNeg]->SetName("hpiNeg");
455 hSpectra[kTOF][kProton][kNeg]->SetName("hprNeg");
456 hSpectra[kTOF][kKaon] [kNeg]->SetName("hkaNeg");
458 // Divide for efficiency
459 hSpectra[kTOF][kPion] [kPos]->Divide(hEffTrackTOF[kPion] [kPos]);
460 hSpectra[kTOF][kKaon] [kPos]->Divide(hEffTrackTOF[kKaon] [kPos]);
461 hSpectra[kTOF][kProton][kPos]->Divide(hEffTrackTOF[kProton][kPos]);
462 hSpectra[kTOF][kPion] [kPos]->Divide(hEffMatchTOF[kPion] [kPos]);
463 hSpectra[kTOF][kKaon] [kPos]->Divide(hEffMatchTOF[kKaon] [kPos]);
464 hSpectra[kTOF][kProton][kPos]->Divide(hEffMatchTOF[kProton][kPos]);
465 hSpectra[kTOF][kPion] [kNeg]->Divide(hEffTrackTOF[kPion] [kNeg]);
466 hSpectra[kTOF][kKaon] [kNeg]->Divide(hEffTrackTOF[kKaon] [kNeg]);
467 hSpectra[kTOF][kProton][kNeg]->Divide(hEffTrackTOF[kProton][kNeg]);
468 hSpectra[kTOF][kPion] [kNeg]->Divide(hEffMatchTOF[kPion] [kNeg]);
469 hSpectra[kTOF][kKaon] [kNeg]->Divide(hEffMatchTOF[kKaon] [kNeg]);
470 hSpectra[kTOF][kProton][kNeg]->Divide(hEffMatchTOF[kProton][kNeg]);
473 // Clean UP TOF spectra, removing unwanted points
474 cout << "Cleaning Up TOF spectra" << endl;
475 Int_t nbin = hSpectra[kTOF][kKaon][kPos]->GetNbinsX();
476 for(Int_t ibin = 1; ibin <= nbin; ibin++){
477 Float_t pt = hSpectra[kTOF][kKaon][kPos]->GetBinCenter(ibin);
478 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
480 hSpectra[kTOF][kKaon][icharge]->SetBinContent(ibin,0);
481 hSpectra[kTOF][kKaon][icharge]->SetBinError (ibin,0);
482 hSpectra[kTOF][kProton][icharge]->SetBinContent(ibin,0);
483 hSpectra[kTOF][kProton][icharge]->SetBinError (ibin,0);
487 // cout << "Scaling TOF to TPC" << endl;
488 // // Scale protons to TPC
489 // hSpectra[kTOF][kProton][kPos]->Scale(1./1.05);
490 // // Scale pbar so that pbar/p is compatible with Panos
491 // hSpectra[kTOF][kProton][kNeg]->Scale(1./1.1);
496 f = new TFile("./Files/ITSsaSpectraCorr_20100727.root");
497 hSpectra[kITS][kPion] [kPos]= (TH1F*) f->Get("hSpectraPos0");
498 hSpectra[kITS][kKaon] [kPos]= (TH1F*) f->Get("hSpectraPos1");
499 hSpectra[kITS][kProton][kPos]= (TH1F*) f->Get("hSpectraPos2");
500 hSpectra[kITS][kPion] [kNeg]= (TH1F*) f->Get("hSpectraNeg0");
501 hSpectra[kITS][kKaon] [kNeg]= (TH1F*) f->Get("hSpectraNeg1");
502 hSpectra[kITS][kProton][kNeg]= (TH1F*) f->Get("hSpectraNeg2");
504 for(Int_t ipart = 0; ipart < kNPart; ipart++){
505 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
506 Int_t nbin = hSpectra[kITS][ipart][icharge]->GetNbinsX();
507 for(Int_t ibin = 1; ibin <= nbin; ibin++){
508 if(hSpectra[kITS][ipart][icharge]->GetBinContent(ibin) < 0 ) {
509 hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
510 hSpectra[kITS][ipart][icharge]->SetBinError (ibin,0);
512 if(ipart == kProton && ibin==9){
513 printf("Kill bin %d (%f - %f GeV/c)for ITS protons\n",ibin,hSpectra[kITS][ipart][icharge]->GetBinLowEdge(ibin),hSpectra[kITS][ipart][icharge]->GetBinLowEdge(ibin)+hSpectra[kITS][ipart][icharge]->GetBinWidth(ibin));
514 hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
515 hSpectra[kITS][ipart][icharge]->SetBinError (ibin,0);
517 // if ((ipart == kKaon && ibin >= 12) || (ipart == kProton && ibin >= 20)) {
518 // hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
519 // hSpectra[kITS][ipart][icharge]->SetBinError (ibin,0);
526 if(useSecCorrFromDCA){
527 TFile* fseccorr = new TFile("./Files/CorrFac-SecProtonsFromDCA-ITSsa.root");
528 TH1F* hcorrp=(TH1F*)fseccorr->Get("hSecPCorrFromDCA");
529 TH1F* hcorrpbar=(TH1F*)fseccorr->Get("hSecPbarCorrFromDCA");
530 hSpectra[kITS][kProton][kPos]->Multiply(hcorrp);
531 hSpectra[kITS][kProton][kNeg]->Multiply(hcorrpbar);
536 f = TFile::Open("./Files/SpectraCorrectedITSBeforeProtons20100720.root");
537 TList * list = (TList*) gDirectory->Get("output");
538 hSpectra[kITSTPC][kPion] [kPos]= (TH1F*) list->FindObject("Pions");
539 hSpectra[kITSTPC][kKaon] [kPos]= (TH1F*) list->FindObject("Kaons");
540 hSpectra[kITSTPC][kProton][kPos]= (TH1F*) list->FindObject("Protons");
541 hSpectra[kITSTPC][kPion] [kNeg]= (TH1F*) list->FindObject("AntiPions");
542 hSpectra[kITSTPC][kKaon] [kNeg]= (TH1F*) list->FindObject("AntiKaons");
543 hSpectra[kITSTPC][kProton][kNeg]= (TH1F*) list->FindObject("AntiProtons");
546 f = new TFile("./Files/protonSpectra_20100615.root");
547 hSpectra[kTPC][kProton][kPos]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("protonPosClassic"),htemplate);
548 hSpectra[kTPC][kProton][kNeg]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("protonNegClassic"),htemplate);
549 f = new TFile("./Files/pionSpectra_20100615.root");
550 hSpectra[kTPC][kPion][kPos]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("pionPosClassic"),htemplate);
551 hSpectra[kTPC][kPion][kNeg]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("pionNegClassic"),htemplate);
552 f = new TFile("./Files/kaonSpectra_20100615.root");
553 hSpectra[kTPC][kKaon][kPos]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("kaonPosClassic"),htemplate);
554 hSpectra[kTPC][kKaon][kNeg]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("kaonNegClassic"),htemplate);
556 // Clean UP TPC spectra, removing unwanted points
557 cout << "Cleaning Up TPC spectra" << endl;
558 nbin = hSpectra[kTPC][kKaon][kPos]->GetNbinsX();
559 for(Int_t ibin = 0; ibin < nbin; ibin++){
560 Float_t pt = hSpectra[kTPC][kKaon][kPos]->GetBinCenter(ibin);
561 if (pt > 0.45){ // || pt<0.25) {
562 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
563 hSpectra[kTPC][kKaon][icharge]->SetBinContent(ibin,0);
564 hSpectra[kTPC][kKaon][icharge]->SetBinError (ibin,0);
568 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
569 hSpectra[kTPC][kProton][icharge]->SetBinContent(ibin,0);
570 hSpectra[kTPC][kProton][icharge]->SetBinError (ibin,0);
580 f = new TFile ("./Files/PtSpectraCorrectedK0sOff.root");
581 // hSpectra[kK0][kKaon][kPos] = (TH1F*) AliBWTools::GetdNdPtFromOneOverPt((TH1*) gDirectory->Get("hSpectraOff"));
582 hSpectra[kK0][kKaon][kPos] = (TH1F*) gDirectory->Get("hSpectraOff");
583 // hSpectra[kK0][kKaon][kPos]->Scale(2*TMath::Pi());
584 // hSpectra[kK0][kKaon][kPos]->Scale(1./272463);
585 hSpectra[kK0][kKaon][kNeg] = hSpectra[kK0][kKaon][kPos];
587 // Kinks: TO BE FIXED WITH POSITIVES AND NEGATIVES
588 // f = new TFile ("./Files/PtAllKaonKinkRap6Apr24.root");
589 f = new TFile ("./Files/PtKaonKinkJune13AllPN_20100615.root");
590 hSpectra[kKinks][kKaon][kPos] = (TH1F*)gDirectory->Get("fptallKPA");
591 hSpectra[kKinks][kKaon][kNeg] = (TH1F*)gDirectory->Get("fptallKNA");
592 hSpectra[kKinks][kKaon][kPos]->Scale(0.5/0.7); // different rapidity range for kinks
593 hSpectra[kKinks][kKaon][kNeg]->Scale(0.5/0.7); // different rapidity range for kinks
594 hSpectra[kKinks][kKaon][kPos]->Scale(276004./263345.); // different N of events
595 hSpectra[kKinks][kKaon][kNeg]->Scale(276004./263345.); // different N of events
597 // Apply correction factors
598 // Secondaries for protons
600 f = new TFile ("./Files/corrFactorProtons_20100615.root");
601 TH1F * hCorrSecondaries = (TH1F*) gDirectory->Get("corrFactorProtons");
602 if(correctSecondaries) {
603 cout << "CORRECTING SECONDARIES" << endl;
605 for(Int_t idet = 0; idet <= kTOF; idet++){ // TPC and TOF only
606 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
607 Int_t ipart = kProton;
608 TH1* h = hSpectra[idet][ipart][icharge]; // lighter notation below
610 Int_t nbins = h->GetNbinsX();
611 for(Int_t ibin = 0; ibin < nbins; ibin++){
612 // Float_t pt = convertToMT ? TMath::Sqrt(h->GetBinCenter(ibin)*h->GetBinCenter(ibin)-mass[kProton]*mass[kProton]) : h->GetBinCenter(ibin);
613 Float_t pt = h->GetBinCenter(ibin);
614 if (icharge == kNeg) pt = -pt;
615 Int_t binCorrection = hCorrSecondaries->FindBin(pt);
616 Float_t correction = hCorrSecondaries->GetBinContent(binCorrection);
617 // cout << pt << " " << correction << endl;
619 if (correction) {// If the bin is empty this is a 0
620 h->SetBinContent(ibin,h->GetBinContent(ibin)/correction);
621 h->SetBinError (ibin,h->GetBinError (ibin)/correction);
622 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
623 cout << "Not correcting bin "<<ibin << " for protons secondaries, " << detFlag[idet] << " " << chargeFlag[icharge] << endl;
624 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
632 // geant/fluka absorption
633 if(correctGeantFlukaXS) {
634 cout << "CORRECTING GEANT3/FLUKA" << endl;
635 // common file for Kaons
636 TFile *fFlukakaons = TFile::Open("./Files/correctionForCrossSection.321.root");
637 TH1D * hCorrFlukakaon[kNCharge];
638 hCorrFlukakaon[kPos] = (TH1D*)fFlukakaons->Get("gHistCorrectionForCrossSectionParticles");
639 hCorrFlukakaon[kNeg] = (TH1D*)fFlukakaons->Get("gHistCorrectionForCrossSectionAntiParticles");
641 for(Int_t idet = 0; idet < kNDet; idet++){
642 if( idet != kITS) continue; // comment to use fluka for kaons for all dets
643 if (idet == kTOF) continue; // TOF already corrected
644 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
646 TH1 * h = hSpectra[idet][ipart][icharge]; // only ITS sa
648 Int_t nbins = h->GetNbinsX();
649 Int_t nbinsy=hCorrFlukakaon[icharge]->GetNbinsY();
650 for(Int_t ibin = 0; ibin < nbins; ibin++){
651 Float_t pt = h->GetBinCenter(ibin);
652 Float_t minPtCorrection = hCorrFlukakaon[icharge]->GetXaxis()->GetBinLowEdge(1);
653 Float_t maxPtCorrection = hCorrFlukakaon[icharge]->GetXaxis()->GetBinLowEdge(nbinsy+1);
654 if (pt < minPtCorrection) pt = minPtCorrection+0.0001;
655 if (pt > maxPtCorrection) pt = maxPtCorrection;
656 Float_t correction = hCorrFlukakaon[icharge]->GetBinContent(hCorrFlukakaon[icharge]->GetXaxis()->FindBin(pt));
657 if (correction != 0) {// If the bin is empty this is a 0
658 h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
659 h->SetBinError (ibin,h->GetBinError (ibin)*correction);
660 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
661 cout << "Fluka/GEANT: Not correcting bin "<<ibin << " for protons secondaries, ITS, " << chargeFlag[icharge] << endl;
662 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
671 // ITS specific file for protons/antiprotons
672 TFile* fITS = new TFile ("./Files/correctionForCrossSectionITS_20100719.root");
673 TH2D * hCorrFlukaITS[kNCharge];
674 hCorrFlukaITS[kPos] = (TH2D*)fITS->Get("gHistCorrectionForCrossSectionProtons");
675 hCorrFlukaITS[kNeg] = (TH2D*)fITS->Get("gHistCorrectionForCrossSectionAntiProtons");
677 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
678 Int_t ipart = kProton;
679 TH1 * h = hSpectra[kITS][ipart][icharge]; // only ITS sa
681 Int_t nbins = h->GetNbinsX();
682 Int_t nbinsy=hCorrFlukaITS[icharge]->GetNbinsY();
683 for(Int_t ibin = 0; ibin < nbins; ibin++){
684 Float_t pt = h->GetBinCenter(ibin);
685 Float_t minPtCorrection = hCorrFlukaITS[icharge]->GetYaxis()->GetBinLowEdge(1);
686 Float_t maxPtCorrection = hCorrFlukaITS[icharge]->GetYaxis()->GetBinLowEdge(nbinsy+1);
687 if (pt < minPtCorrection) pt = minPtCorrection+0.0001;
688 if (pt > maxPtCorrection) pt = maxPtCorrection;
689 Float_t correction = hCorrFlukaITS[icharge]->GetBinContent(1,hCorrFlukaITS[icharge]->GetYaxis()->FindBin(pt));
690 if (correction != 0) {// If the bin is empty this is a 0
691 h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
692 h->SetBinError (ibin,h->GetBinError (ibin)*correction);
693 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
694 cout << "Fluka/GEANT: Not correcting bin "<<ibin << " for protons secondaries, ITS, " << chargeFlag[icharge] << endl;
695 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
702 f = new TFile ("./Files/correctionForCrossSection_20100615.root");
703 TH2D * hCorrFluka[kNCharge];
704 hCorrFluka[kPos] = (TH2D*)gDirectory->Get("gHistCorrectionForCrossSectionProtons");
705 hCorrFluka[kNeg] = (TH2D*)gDirectory->Get("gHistCorrectionForCrossSectionAntiProtons");
706 for(Int_t idet = 0; idet < kNDet; idet++){
707 if (idet == kITS) continue; // skip ITS sa
708 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
709 Int_t ipart = kProton;
710 TH1 * h = hSpectra[idet][ipart][icharge]; // lighter notation below
712 Int_t nbins = h->GetNbinsX();
713 for(Int_t ibin = 0; ibin < nbins; ibin++){
714 // Float_t pt = convertToMT ?
715 // TMath::Sqrt(h->GetBinCenter(ibin)*h->GetBinCenter(ibin)-mass[kProton]*mass[kProton]) :
716 // h->GetBinCenter(ibin);
717 Float_t pt = h->GetBinCenter(ibin);
718 Float_t minPtCorrection = hCorrFluka[icharge]->GetYaxis()->GetBinLowEdge(1);
719 Float_t maxPtCorrection = hCorrFluka[icharge]->GetYaxis()->GetBinLowEdge(h->GetNbinsY()+1);
720 if (pt < minPtCorrection) pt = minPtCorrection+0.0001;
721 if (pt > maxPtCorrection) pt = maxPtCorrection;
722 Float_t correction = hCorrFluka[icharge]->GetBinContent(1,hCorrFluka[icharge]->GetYaxis()->FindBin(pt));
724 // already in the efficiency correction (F. Noferini)
725 // if (idet == kTOF && icharge == kNeg) {
728 // // Apply parametrized correction computed by francesco
729 // // Fitted panos correction and using momentum at the outer radius of the TPC
731 // Float_t ptav = pt; // Just to use the same name francesco uses...
733 // // from pT constrained at P.V. (ptav) to pT TPC outer (ptTPCout)
734 // Float_t ptTPCout=ptav*(1-6.81059e-01*TMath::Exp(-ptav*4.20094));
736 // // traking correction (fit to Panos)
737 // Float_t antiprotonEC = 1 - 0.129758 *TMath::Exp(-ptav*0.679612);
739 // // TOF matching efficiency correction (derived from Panos one scaled for M.B.(TOF)/M.B.(TPC)).
740 // Float_t antiprotonEC2 = TMath::Power(1 - 0.129758*TMath::Exp(-ptTPCout*0.679612),0.07162/0.03471);
741 // correction = antiprotonEC * antiprotonEC2;
744 // cout << icharge<< " " << h->GetBinCenter(ibin) << " " << pt << " " << correction << endl;
745 if (correction != 0) {// If the bin is empty this is a 0
746 h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
747 h->SetBinError (ibin,h->GetBinError (ibin)*correction);
748 // if (idet == kTOF) {
749 // cout << "CORRECTING TOF TWICE" << endl;
750 // h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
751 // h->SetBinError (ibin,h->GetBinError (ibin)*correction);
753 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
754 cout << "Fluka/GEANT: Not correcting bin "<<ibin << " for protons secondaries, " << detFlag[idet] << " " << chargeFlag[icharge] << endl;
755 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
766 // Set style and scale
767 for(Int_t idet = 0; idet < kNDet; idet++){
768 for(Int_t ipart = 0; ipart < kNPart; ipart++){
769 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
770 if (hSpectra[idet][ipart][icharge]){
771 hSpectra[idet][ipart][icharge]->SetStats(0); // disable stats
772 hSpectra[idet][ipart][icharge]->SetMarkerColor (color[ipart] );
773 hSpectra[idet][ipart][icharge]->SetLineColor (color[ipart] );
774 hSpectra[idet][ipart][icharge]->SetMarkerStyle (marker[ipart]);
775 hSpectra[idet][ipart][icharge]->SetXTitle("p_{t} (GeV/c)");
776 hSpectra[idet][ipart][icharge]->SetYTitle("1/N_{ev} dN/dp_{t} (GeV/c)^{-1}");
778 TH1F * htmp = (TH1F*) AliBWTools::GetOneOverPtdNdPt(hSpectra[idet][ipart][icharge]);
779 hSpectra[idet][ipart][icharge] = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
780 hSpectra[idet][ipart][icharge]->SetXTitle("m_{t} (GeV)");
781 hSpectra[idet][ipart][icharge]->SetYTitle("1/N_{ev} 1/m_{t} dN/dp_{t} (GeV)^{-1}");
783 // if (idet == kTOF || idet == kTPC) {
784 // hSpectra[idet][ipart][icharge]->Scale(1./236763);
786 // if (idet == kITS){
787 // hSpectra[idet][ipart][icharge]->Scale(202945./236763);
789 if (scaleKaons && ipart == kKaon) {
790 hSpectra[idet][ipart][icharge]->Scale(2.);
793 printf("Cannot load %s,%s,%s\n",detFlag[idet],partFlag[ipart],chargeFlag[icharge]);
800 // Create fake weights for the mean; To be update once we have syst errors
801 // Using syste from table in paper. It would be better to have this as a function of pt.
802 TH1F * hWeights[3][kNPart];
803 const Double_t kWeights[3][kNPart] =
804 {{4, 3, 10.2}, // TPC
805 {4.1,8.8,7.0 }, //TOF
806 {4.5,5.6,7.0 }}; // ITS
807 // {{0.1,0.1,0.1}, // TPC
808 // {0.1,0.1,0.1}, //TOF
809 // {0.1,0.1,0.1}}; // ITS
810 for(Int_t ipart = 0; ipart <= kNPart ; ipart++){
811 for(Int_t idet = 0; idet <= kITS ; idet++){
812 hWeights[idet][ipart] = (TH1F*) hSpectra[idet][ipart][kPos]->Clone();
813 Int_t nbin = hWeights[idet][ipart]->GetNbinsX();
814 for(Int_t ibin = 1; ibin <= nbin; ibin++){
815 hWeights[idet][ipart]->SetBinError(ibin, kWeights[idet][ipart]);
819 const Double_t scaleDet[] = {0.98,1,0.98}; // Scaling factor for the different detectors. Estimated from ratios, it has an estimated uncertainty of ~2%
820 // const Double_t scaleDet[] = {0.88,1,0.88}; // Scaling factor for the different detectors. Estimated from ratios, it has an estimated uncertainty of ~2%
824 for(Int_t ipart = 0; ipart < kNPart; ipart++){
825 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
826 TH1F * htemplLocal = htemplate; // If we are converting to 1/mt dNdmt we need to convert the template as well...
829 TH1F * htmp = (TH1F*) AliBWTools::GetOneOverPtdNdPt(htemplate);
830 htemplLocal = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
833 hSpectra[kCombTOFTPC][ipart][icharge] = AliBWTools::CombineHistos(hSpectra[kTOF][ipart][icharge],
834 hSpectra[kTPC][ipart][icharge],
836 hSpectra[kCombAll][ipart][icharge] =
837 AliBWTools::Combine3HistosWithErrors(hSpectra[kITS][ipart][icharge],
838 hSpectra[kTPC][ipart][icharge],
839 hSpectra[kTOF][ipart][icharge],
840 hWeights[kITS][ipart],
841 hWeights[kTPC][ipart],
842 hWeights[kTOF][ipart],
848 // if (convertToMT) {
849 // TH1F * htmp = (TH1F*) AliBWTools::GetOneOverPtdNdPt(hSpectra[kCombTOFTPC][ipart][icharge]);
850 // hSpectra[kCombTOFTPC][ipart][icharge] = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
851 // hSpectra[kCombTOFTPC][ipart][icharge]->SetXTitle("m_{t} (GeV)");
852 // hSpectra[kCombTOFTPC][ipart][icharge]->SetYTitle("1/N_{ev} 1/m_{t} dN/dp_{t} (GeV)^{-1}");
858 // Scale for the number of inelastic collisions and correct for
859 // efficiency losses due to physics selection:
861 Double_t effPhysSel[kNPart];
862 effPhysSel[kPion] = 1.012;
863 effPhysSel[kKaon] = 1.013;
864 effPhysSel[kProton] = 1.014;
867 for(Int_t idet = 0; idet < kNHist; idet++){
868 for(Int_t ipart = 0; ipart < kNPart; ipart++){
869 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
870 if(hSpectra[idet][ipart][icharge]) {
871 // cout << "Scaling!" << endl;
873 hSpectra[idet][ipart][icharge]->Scale(1.*effPhysSel[ipart]/278366.15); // Scale PhysSel tutti? // FIXME
886 const char * evClass= "INEL";
887 const char * files[] = {"./Files/dndeta_Phojet_10M_900GeV.root",
888 "./Files/dndeta_AtlasCSC306_10M_900GeV.root",
889 "./Files/dndeta_CMSD6T109_10M_900GeV.root",
890 "./Files/dndeta_Perugia0320_10M_900GeV.root", };
893 for(Int_t itune = 0; itune < kNTunes; itune++){
894 f = new TFile(files[itune]);
895 for(Int_t ipart = 0; ipart < kNPart; ipart++){
896 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
897 hSpectraMC[itune][ipart][icharge] = (TH1F*) f->Get(Form("fHistPtID_%s_%s%s",evClass,partFlag[ipart],icharge==0 ? "Pos" : "Neg"));
904 for(Int_t itune = 0; itune < kNTunes; itune++){
905 for(Int_t ipart = 0; ipart < kNPart; ipart++){
906 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
907 if (hSpectraMC[itune][ipart][icharge]){
908 hSpectraMC[itune][ipart][icharge]->SetName(TString(hSpectraMC[itune][ipart][icharge]->GetName())+mcTuneName[itune]);
909 hSpectraMC[itune][ipart][icharge]->SetMarkerColor (mcLineColor[itune] );
910 hSpectraMC[itune][ipart][icharge]->SetLineColor (mcLineColor[itune] );
911 hSpectraMC[itune][ipart][icharge]->SetLineStyle (mcLineStyle[itune] );
912 hSpectraMC[itune][ipart][icharge]->SetMarkerStyle (1);
914 TH1F * htmp = (TH1F*)AliBWTools::GetOneOverPtdNdPt(hSpectraMC[itune][ipart][icharge]);
915 hSpectraMC[itune][ipart][icharge] = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
916 hSpectraMC[itune][ipart][icharge]->SetXTitle("m_{t} (GeV)");
917 hSpectraMC[itune][ipart][icharge]->SetYTitle("1/N_{ev} 1/m_{t} dN/dp_{t} (GeV)^{-1}");
921 printf("Cannot load MC # %d,%s,%s\n",itune,partFlag[ipart],chargeFlag[icharge]);
929 void DrawStar(Int_t icharge) {
930 // cout << icharge << endl;
932 // gROOT->LoadMacro("StarPPSpectra.C");
933 TGraphErrors ** gStar = StarPPSpectra();
935 for(Int_t istar = 0; istar < 6; istar++){
936 gStar[istar]->SetMarkerStyle(kOpenStar);
937 if (icharge==kPos && (istar%2) ) gStar[istar]->Draw("P");
938 else if (icharge==kNeg && !(istar%2) ) gStar[istar]->Draw("P");
939 else cout << "Skipping Star " << istar << endl;
943 void GetITSResiduals() {
946 for(Int_t ipart = 0; ipart < kNPart; ipart++){
947 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
948 // cout << "1 " << ipart << " " << icharge << endl;
950 // gSystem->ProcessEvents();
951 // gSystem->Sleep(1000);
952 TF1* f = (TF1*) hSpectra[kCombTOFTPC][ipart][icharge]->GetListOfFunctions()->At(0);
953 TH1F * hres1, *hres2;
954 AliBWTools::GetResiduals(hSpectra[kITS][ipart][icharge], f, &hres1, &hres2);
956 TCanvas * c1 = new TCanvas(TString(partFlag[ipart])+"_"+chargeFlag[icharge],TString(partFlag[ipart])+"_"+chargeFlag[icharge]);
958 hSpectra[kCombTOFTPC][ipart][icharge]->Draw();
959 hSpectra[kITS][ipart][icharge]->SetMarkerStyle(24);
960 hSpectra[kCombTOFTPC][ipart][icharge]->SetMarkerStyle(20);
961 hSpectra[kITS][ipart][icharge]->Draw("same");
962 hSpectra[kCombTOFTPC][ipart][icharge]->GetListOfFunctions()->At(0)->Draw("same");
963 TLegend* l = new TLegend( 0.182886, 0.192308, 0.505034,0.384615, TString(partLabel[ipart][icharge])+" "+chargeFlag[icharge]);
964 l->AddEntry(hSpectra[kCombTOFTPC][ipart][icharge], "TOF+TPC");
965 l->AddEntry(hSpectra[kITS][ipart][icharge], "ITS");
966 l->AddEntry(f, "Fit to TOF+TPC");
969 TCanvas * c2 = new TCanvas(TString(partFlag[ipart])+"_"+chargeFlag[icharge]+"_res",
970 TString(partFlag[ipart])+"_"+chargeFlag[icharge]+"_res");
972 hres2->SetMinimum(-1);
973 hres2->SetMaximum(1);
975 hres2->GetYaxis()->SetTitleOffset(1.2);
976 Float_t x = AliBWTools::GetLowestNotEmptyBinEdge(hSpectra[kCombTOFTPC][ipart][icharge]);
977 TLine * line = new TLine(x,-1,x,1);
978 line->SetLineStyle(kDashed);
984 gSystem->ProcessEvents();
985 c1->Print(TString(c1->GetName()) + ".png");
986 c2->Print(TString(c2->GetName()) + ".png");
992 void DrawWithModels() {
994 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
997 for(Int_t ipart = 0; ipart < kNPart; ipart++){
999 TCanvas * c1 = new TCanvas(TString("cSpectra")+partFlag[ipart]+chargeFlag[icharge],TString("cSpectra")+partFlag[ipart]+chargeFlag[icharge],700,700);
1000 TPad *p1 = new TPad(TString("p1")+partFlag[ipart]+chargeFlag[icharge], "p1", 0.0, 0.35, 1.0, 0.95, 0, 0, 0);
1001 p1->SetBottomMargin(0);
1004 TPad *p2 = new TPad(TString("p2")+partFlag[ipart]+chargeFlag[icharge], "p2", 0.0, 0.05, 1.0, 0.35, 0, 0, 0);
1005 p2->SetTopMargin(0);
1006 p2->SetBottomMargin(0.3);
1009 Float_t scaleFonts = (0.95-0.3)/(0.3-0.05);
1014 TH2F * hempty = new TH2F(TString("hempty")+long(icharge)+long(ipart),"hempty",100,0.,4, 100, 0.0015,5);
1015 hempty->SetXTitle("p_{t} (GeV/c)");
1016 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
1021 TLegend * l =new TLegend( 0.543624, 0.431818, 0.892617,0.629371);
1022 l->SetFillColor(kWhite);
1023 hSpectra[iCombInStudy][ipart][icharge]->Draw("same");
1024 l->AddEntry(hSpectra[kTOF][ipart][icharge],TString ("Data: ")+partLabel[ipart][icharge]);
1025 for(Int_t itune = 0; itune < kNTunes; itune++){
1026 l->AddEntry(hSpectraMC[itune][ipart][icharge],mcTuneName[itune]);
1027 hSpectraMC[itune][ipart][icharge]->SetLineWidth(2);
1028 hSpectraMC[itune][ipart][icharge]->Draw("same,chist");
1034 TH2F * hemptyr = new TH2F(TString("hemptyratio")+long(icharge)+long(ipart),"hempty",100,0.,4, 100, 0.01,2.99);
1035 hemptyr->SetXTitle("p_{t} (GeV/c)");
1036 hemptyr->SetYTitle("Data/MC");
1037 hemptyr->GetXaxis()->SetLabelSize(0.04*scaleFonts);
1038 hemptyr->GetYaxis()->SetLabelSize(0.04*scaleFonts);
1039 hemptyr->GetYaxis()->SetTitleSize(0.05*scaleFonts);
1040 hemptyr->GetYaxis()->SetTitleOffset(1.4/scaleFonts);
1041 hemptyr->GetXaxis()->SetTitleSize(0.05*scaleFonts);
1042 hemptyr->SetTickLength(0.03*scaleFonts, "X");
1043 hemptyr->SetTickLength(0.02*scaleFonts, "Y");
1044 // hemptyr->GetXaxis()->SetTitleOffset(1.4/scaleFonts);
1045 hemptyr->GetYaxis()->SetNdivisions(5);
1049 for(Int_t itune = 0; itune < kNTunes; itune++){
1050 TF1* f = fm.GetHistoFunc(hSpectraMC[itune][ipart][icharge], TString("f")+mcTuneName[itune]);
1052 // l->AddEntry(hSpectraMC[itune][ipart][icharge],mcTuneName[itune]);
1053 TH1F* hRatio = AliBWTools::DivideHistoByFunc(hSpectra[iCombInStudy][ipart][icharge],f);
1054 hRatio->SetLineStyle(hSpectraMC[itune][ipart][icharge]->GetLineStyle());
1055 hRatio->SetLineColor(hSpectraMC[itune][ipart][icharge]->GetLineColor());
1056 hRatio->SetLineWidth(hSpectraMC[itune][ipart][icharge]->GetLineWidth());
1057 hRatio->Draw("lhist,same");
1064 gSystem->ProcessEvents();
1065 c1->Print(TString(c1->GetName())+".eps");
1066 ALICEWorkInProgress(c1,"","#splitline{ALICE Preliminary}{Statistical Error Only}");
1067 c1->Print(TString(c1->GetName())+".png");
1077 void DrawAllAndKaons() {
1080 // gROOT->LoadMacro("ALICEWorkInProgress.C");
1082 // gStyle->SetOptFit(0);
1083 gStyle->SetStatX(0.9);
1084 gStyle->SetStatY(0.88);
1085 gStyle->SetStatW(0.4);
1086 gStyle->SetStatH(0.1);
1088 TH1F * hKaonsAllTPCTOF = (TH1F*) hSpectra[iCombInStudy][kKaon][kPos]->Clone();
1089 hKaonsAllTPCTOF->Add(hSpectra[iCombInStudy][kKaon][kNeg]);
1091 TH1F * hK0Scaled = (TH1F*) hSpectra[kK0][kKaon][kPos]->Clone();
1092 hK0Scaled->Add(hSpectra[kK0][kKaon][kPos]);
1094 hSpectra[kKinks][kKaon][kPos]->SetMarkerStyle(25);
1095 hSpectra[kKinks][kKaon][kPos]->SetLineColor(4);
1096 hSpectra[kKinks][kKaon][kPos]->SetStats(0);
1097 TH1F * hKinksAll = (TH1F*) hSpectra[kKinks][kKaon][kPos]->Clone();
1098 hKinksAll->Add(hSpectra[kKinks][kKaon][kNeg]);
1100 TCanvas * c1 = new TCanvas("cKaons","cKaons",700,700);
1102 TH2F * hempty = new TH2F("hempty_allkaons","hempty",100,0.,3, 100, 1e-3,6);
1103 hempty->SetXTitle("p_{t} (GeV/c)");
1104 hempty->SetYTitle("dN / dp_{t} (A.U.)");
1106 hK0Scaled->Draw("same");
1107 hKaonsAllTPCTOF->Draw("same");
1108 hKinksAll->Draw("same");
1110 TLegend * leg = new TLegend(0.2013423,0.2255245,0.5503356,0.4335664,NULL,"brNDC");
1111 // leg->SetBorderSize(0);
1112 // leg->SetLineColor(1);
1113 // leg->SetLineStyle(1);
1114 // leg->SetLineWidth(1);
1115 // leg->SetFillColor(19);
1116 leg->SetFillColor(0);
1117 TLegendEntry *entry=leg->AddEntry(hKaonsAllTPCTOF,"K^{+} + K^{-}, ITS+TPC+TOF ","lpf");
1118 entry=leg->AddEntry(hK0Scaled,"K^{0} #times 2","lpf");
1119 entry=leg->AddEntry(hKinksAll,"K^{+} + K ^{-}, Kinks","lpf");
1122 ALICEWorkInProgress(c1,today.Data(),"#splitline{ALICE Prelimiary}{Statistical Error Only}");
1123 TLatex * tex = new TLatex(0.2120805,0.01288336,"Statistical error only");
1124 tex->SetTextColor(2);
1125 tex->SetTextFont(42);
1126 tex->SetTextSize(0.03496503);
1130 if(doPrint) c1->Print(TString(c1->GetName())+".png");
1132 // Draw all "stable" hadrons
1133 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1134 TCanvas * c1 = new TCanvas(TString("cAll_")+chargeFlag[icharge],TString("cAll_")+chargeFlag[icharge],700,700);
1136 c1->SetLeftMargin(0.14);
1137 TH2F * hempty = new TH2F(TString("hempty")+long(icharge),"hempty",100,0.,4, 100, 1e-4,10);
1138 hempty->SetXTitle("p_{t} (GeV/c)");
1139 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
1140 hempty->GetYaxis()->SetTitleOffset(1.35);
1141 hempty->GetXaxis()->SetTitleOffset(1.1);
1143 leg = new TLegend( 0.645973, 0.2, 0.892617,0.636364, NULL,"brNDC");
1144 leg->SetFillColor(0);
1145 for(Int_t ipart = 0; ipart < kNPart; ipart++) {
1146 for(Int_t idet = 0; idet <= kITSTPC; idet++){
1147 // if (idet == kITS) continue;
1148 // if (idet == kITSTPC) hSpectra[idet][ipart][icharge]->SetMarkerColor(kGreen);
1149 hSpectra[idet][ipart][icharge]->SetMarkerStyle(marker[idet]);
1150 hSpectra[idet][ipart][icharge]->Draw("same");
1151 leg->AddEntry(hSpectra[idet][ipart][icharge],TString(partLabel[ipart][icharge])+" (" + detFlag[idet] + ")","lpf");
1156 ALICEWorkInProgress(c1,today.Data(),"#splitline{ALICE Preliminary}{Statistical Error Only}");
1158 if(doPrint) c1->Print(TString(c1->GetName())+".png");
1164 // K-/K+ in the different detectors
1165 TCanvas * cpm=new TCanvas("cpm","Kminus/Kplus",700,700);
1168 TH1F* hRatioKPKM_TPC=new TH1F(*(hSpectra[kTPC][kKaon][kNeg]));
1169 hRatioKPKM_TPC->SetMinimum(0.5);
1170 hRatioKPKM_TPC->SetMaximum(1.5);
1171 hRatioKPKM_TPC->Divide(hSpectra[kTPC][kKaon][kPos]);
1172 hRatioKPKM_TPC->GetYaxis()->SetTitle("K-/K+ (TPC)");
1173 hRatioKPKM_TPC->Draw();
1175 TH1F* hRatioKPKM_ITS=new TH1F(*(hSpectra[kITS][kKaon][kNeg]));
1176 hRatioKPKM_ITS->Divide(hSpectra[kITS][kKaon][kPos]);
1177 hRatioKPKM_ITS->SetMinimum(0.5);
1178 hRatioKPKM_ITS->SetMaximum(1.5);
1179 hRatioKPKM_ITS->GetYaxis()->SetTitle("K-/K+ (ITSsa)");
1180 hRatioKPKM_ITS->Draw("");
1182 TH1F* hRatioKPKM_TOF=new TH1F(*(hSpectra[kTOF][kKaon][kNeg]));
1183 hRatioKPKM_TOF->Divide(hSpectra[kTOF][kKaon][kPos]);
1184 hRatioKPKM_TOF->SetMinimum(0.5);
1185 hRatioKPKM_TOF->SetMaximum(1.5);
1186 hRatioKPKM_TOF->GetYaxis()->SetTitle("K-/K+ (TOF)");
1187 hRatioKPKM_TOF->Draw("");
1189 TH1F* hRatioKPKM_ITSTPC=new TH1F(*(hSpectra[kITSTPC][kKaon][kNeg]));
1190 hRatioKPKM_ITSTPC->Divide(hSpectra[kITSTPC][kKaon][kPos]);
1191 hRatioKPKM_ITSTPC->SetMinimum(0.5);
1192 hRatioKPKM_ITSTPC->SetMaximum(1.5);
1193 hRatioKPKM_ITSTPC->GetYaxis()->SetTitle("K-/K+ (ITS Global)");
1194 hRatioKPKM_ITSTPC->Draw("");
1198 TH1F * hRatioITSTPC[kNPart][kNCharge];
1199 for(Int_t icharge = 0; icharge < kNCharge; icharge++){ // loop over charges
1201 TCanvas * c1 = new TCanvas(TString("cITSTPCRatio_")+chargeFlag[icharge],TString("cITSTPCRatio_")+chargeFlag[icharge],1200,500);
1204 TH2F * hempty = new TH2F(TString("hemptyR")+long(icharge),"ITSsa/TPC ",100,0.,1., 100, 0.5,1.5);
1205 hempty->SetXTitle("p_{t} (GeV/c)");
1206 hempty->SetYTitle("ITSsa / TPC");
1207 // Loop over particles
1208 for(Int_t ipart = 0; ipart < kNPart; ipart++) {
1210 hRatioITSTPC[ipart][icharge]=new TH1F(*hSpectra[kITS][ipart][icharge]);
1211 Int_t nBinsITS=hSpectra[kITS][ipart][icharge]->GetNbinsX();
1212 Int_t nBinsTPC=hSpectra[kTPC][ipart][icharge]->GetNbinsX();
1213 // Loop over ITS bins,
1214 for(Int_t iBin=1; iBin<=nBinsITS; iBin++){
1215 hRatioITSTPC[ipart][icharge]->SetBinContent(iBin,0.);
1216 hRatioITSTPC[ipart][icharge]->SetBinContent(iBin,0.);
1217 Float_t lowPtITS=hSpectra[kITS][ipart][icharge]->GetBinLowEdge(iBin);
1218 Float_t binWidITS=hSpectra[kITS][ipart][icharge]->GetBinWidth(iBin);
1219 // Loop over TPC bins and find overlapping bins to ITS
1220 for(Int_t jBin=1; jBin<=nBinsTPC; jBin++){
1221 Float_t lowPtTPC=hSpectra[kTPC][ipart][icharge]->GetBinLowEdge(jBin);
1222 Float_t binWidTPC=hSpectra[kTPC][ipart][icharge]->GetBinWidth(jBin);
1223 if(TMath::Abs(lowPtITS-lowPtTPC)<0.001 && TMath::Abs(binWidTPC-binWidITS)<0.001){
1224 Float_t numer=hSpectra[kITS][ipart][icharge]->GetBinContent(iBin);
1225 Float_t denom=hSpectra[kTPC][ipart][icharge]->GetBinContent(jBin);
1226 Float_t enumer=hSpectra[kITS][ipart][icharge]->GetBinError(iBin);
1227 Float_t edenom=hSpectra[kTPC][ipart][icharge]->GetBinError(jBin);
1230 if(numer>0. && denom>0.){
1232 eratio=ratio*TMath::Sqrt((enumer/numer)*(enumer/numer)+(edenom/denom)*(edenom/denom));
1234 hRatioITSTPC[ipart][icharge]->SetBinContent(iBin,ratio);
1235 hRatioITSTPC[ipart][icharge]->SetBinError(iBin,eratio);
1241 // hempty->SetStats(1);
1243 hRatioITSTPC[ipart][icharge]->SetStats(1);
1244 hRatioITSTPC[ipart][icharge]->GetYaxis()->SetRangeUser(0.5,1.5);
1245 hRatioITSTPC[ipart][icharge]->Draw("");
1246 hRatioITSTPC[ipart][icharge]->Fit("pol0","","same");
1249 if(doPrint) c1->Print(TString(c1->GetName())+".png");
1253 TH1F * hRatioTOFTPC[kNPart][kNCharge];
1254 for(Int_t icharge = 0; icharge < kNCharge; icharge++){ // loop over charges
1256 TCanvas * c1t = new TCanvas(TString("cTOFTPCRatio_")+chargeFlag[icharge],TString("cTOFTPCRatio_")+chargeFlag[icharge],1200,500);
1259 TH2F * hemptyt = new TH2F(TString("hemptyRt")+long(icharge),"TOF/TPC ",100,0.,1., 100, 0.5,1.5);
1260 hemptyt->SetXTitle("p_{t} (GeV/c)");
1261 hemptyt->SetYTitle("TOF / TPC");
1263 for(Int_t ipart = 0; ipart < kNPart; ipart++) { // loop over particles
1265 hRatioTOFTPC[ipart][icharge]=new TH1F(*hSpectra[kTOF][ipart][icharge]);
1266 Int_t nBinsTOF=hSpectra[kTOF][ipart][icharge]->GetNbinsX();
1267 Int_t nBinsTPC=hSpectra[kTPC][ipart][icharge]->GetNbinsX();
1268 // Loop over TOF bins
1269 for(Int_t iBin=1; iBin<=nBinsTOF; iBin++){
1270 hRatioTOFTPC[ipart][icharge]->SetBinContent(iBin,0.);
1271 hRatioTOFTPC[ipart][icharge]->SetBinContent(iBin,0.);
1272 Float_t lowPtTOF=hSpectra[kTOF][ipart][icharge]->GetBinLowEdge(iBin);
1273 Float_t binWidTOF=hSpectra[kTOF][ipart][icharge]->GetBinWidth(iBin);
1274 // Loop over TPC bins and find overlapping bins to ITS
1275 for(Int_t jBin=1; jBin<=nBinsTPC; jBin++){
1276 Float_t lowPtTPC=hSpectra[kTPC][ipart][icharge]->GetBinLowEdge(jBin);
1277 Float_t binWidTPC=hSpectra[kTPC][ipart][icharge]->GetBinWidth(jBin);
1278 if(TMath::Abs(lowPtTOF-lowPtTPC)<0.001 && TMath::Abs(binWidTPC-binWidTOF)<0.001){
1279 Float_t numer=hSpectra[kTOF][ipart][icharge]->GetBinContent(iBin);
1280 Float_t denom=hSpectra[kTPC][ipart][icharge]->GetBinContent(jBin);
1281 Float_t enumer=hSpectra[kTOF][ipart][icharge]->GetBinError(iBin);
1282 Float_t edenom=hSpectra[kTPC][ipart][icharge]->GetBinError(jBin);
1285 if(numer>0. && denom>0.){
1287 eratio=ratio*TMath::Sqrt((enumer/numer)*(enumer/numer)+(edenom/denom)*(edenom/denom));
1289 hRatioTOFTPC[ipart][icharge]->SetBinContent(iBin,ratio);
1290 hRatioTOFTPC[ipart][icharge]->SetBinError(iBin,eratio);
1296 hRatioITSTPC[ipart][icharge]->SetStats(1);
1297 hRatioITSTPC[ipart][icharge]->GetYaxis()->SetRangeUser(0.5,1.5);
1298 hRatioITSTPC[ipart][icharge]->Draw("");
1299 hRatioITSTPC[ipart][icharge]->Fit("pol0","","same");
1301 if(doPrint) c1t->Print(TString(c1t->GetName())+".png");
1306 void DrawWithJacek() {
1308 //1. Convert spectra to dNdeta and sum
1309 TH1F * hsum = (TH1F*) htemplate->Clone();
1311 Int_t idet= iCombInStudy;
1312 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1313 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1314 TH1 * h = hSpectra[idet][ipart][icharge];
1315 Int_t nbin = h->GetNbinsX();
1316 for(Int_t ibin = 1; ibin <= nbin; ibin++){
1317 Double_t pt = h->GetBinCenter(ibin);
1318 Double_t mt = TMath::Sqrt(pt*pt + mass[ipart]*mass[ipart]);
1319 Double_t jacobian = pt/mt;
1320 h->SetBinContent(ibin,h->GetBinContent(ibin)*jacobian);
1321 h->SetBinError (ibin,h->GetBinError (ibin)*jacobian);
1322 Int_t ibinSum = hsum->FindBin(pt);
1323 Double_t epsilon = 0.0001;
1324 if ( h->GetBinContent(ibin) > 0 &&
1325 (TMath::Abs(h->GetBinLowEdge(ibin) - hsum->GetBinLowEdge(ibinSum)) > epsilon ||
1326 TMath::Abs(h->GetBinLowEdge(ibin+1) - hsum->GetBinLowEdge(ibinSum+1)) )
1328 cout << "DISCREPANCY IN BIN RANGES" << endl;
1329 cout << pt << " " << ibinSum << " " << ibin << "; " << h->GetBinContent(ibin) << endl
1330 << h->GetBinLowEdge(ibin) << "-" << h->GetBinLowEdge(ibin+1) << endl
1331 << hsum->GetBinLowEdge(ibinSum) << "-" << hsum->GetBinLowEdge(ibinSum+1) << endl;
1336 hsum->SetBinContent(ibinSum,hsum->GetBinContent(ibinSum)+h->GetBinContent(ibin)); // EROOR FIXME
1337 hsum->SetBinError (ibinSum,0);
1344 // Load Jacek and Draw both:
1345 // new TFile ("./Files/dNdPt_Data_Points_ALICE_900GeV.root");
1346 // TGraphErrors * gJacek = (TGraphErrors*) gDirectory->Get("inel");
1347 // gJacek->Draw("AP");
1348 // hsum->Draw("same");
1350 // TGraphErrors * gRatio = AliBWTools::DivideGraphByHisto(gJacek,hsum);
1354 // gRatio->Draw("AP");
1361 void DrawRatioToStar() {
1364 // gROOT->LoadMacro("StarPPSpectra.C");
1365 TGraphErrors ** gStar = StarPPSpectra();
1366 gStar[0]->SetMarkerStyle(kOpenStar);
1367 gStar[1]->SetMarkerStyle(kFullStar);
1368 gStar[2]->SetMarkerStyle(kOpenStar);
1369 gStar[3]->SetMarkerStyle(kFullStar);
1370 gStar[4]->SetMarkerStyle(kOpenStar);
1371 gStar[5]->SetMarkerStyle(kFullStar);
1373 // ALICE, INEL -> NSD
1374 Double_t scaleYield = 3.58/3.02; // from paper 2
1375 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1376 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1377 hSpectra[iCombInStudy][ipart][icharge]->Scale(scaleYield);
1382 TCanvas * c1 = new TCanvas("cRatioToStarNeg","cRatioToStarNeg");
1383 TH2F * hempty = new TH2F(TString("hemptyNeg"),"hemptyNeg",100,0.,1.5, 100, 0.001,1.8);
1384 hempty->SetXTitle("p_{t} (GeV/c)");
1385 hempty->SetYTitle("ALICE/STAR (NSD)");
1388 TCanvas * c1Comp = new TCanvas("cCompToStarNeg","cCompToStarNeg");
1390 TH2F * hempty2 = new TH2F(TString("hemptyCompNeg"),"hemptyCompNeg",100,0.,1.5, 100, 0.001,10);
1391 hempty2->SetXTitle("p_{t} (GeV/c)");
1392 hempty2->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1} [NSD]");
1395 TLegend *leg = new TLegend(0.6510067,0.1853147,0.8892617,0.4178322,"Negative","brNDC");
1396 leg->SetBorderSize(0);
1397 leg->SetLineColor(1);
1398 leg->SetLineStyle(1);
1399 leg->SetLineWidth(1);
1400 leg->SetFillColor(0);
1401 leg->SetFillStyle(1001);
1407 g = AliBWTools::DivideGraphByHisto(gStar[0],hSpectra[iCombInStudy][kPion][kNeg],1);
1408 g->SetMarkerStyle(kFullCircle);
1409 g->SetMarkerColor(kBlack);
1411 leg->AddEntry(g,"#pi^{-}","lp");
1412 g = AliBWTools::DivideGraphByHisto(gStar[2],hSpectra[iCombInStudy][kKaon][kNeg],1);
1413 g->SetMarkerStyle(kOpenCircle);
1414 g->SetMarkerColor(kRed);
1416 leg->AddEntry(g,"K^{-}","lp");
1417 g = AliBWTools::DivideGraphByHisto(gStar[4],hSpectra[iCombInStudy][kProton][kNeg],1);
1418 g->SetMarkerStyle(kOpenSquare);
1419 g->SetMarkerColor(kBlue);
1421 leg->AddEntry(g,"#bar{p}","lp");
1425 gStar[0]->Draw("p");
1426 hSpectra[iCombInStudy][kPion][kNeg]->Draw("same");
1427 gStar[2]->Draw("p");
1428 hSpectra[iCombInStudy][kKaon][kNeg]->Draw("same");
1429 gStar[4]->Draw("p");
1430 hSpectra[iCombInStudy][kProton][kNeg]->Draw("same");
1434 TCanvas * c2 = new TCanvas("cRatioToStarPos","cRatioToStarPos");
1436 leg = new TLegend(0.6510067,0.1853147,0.8892617,0.4178322,"Positive","brNDC");
1437 leg->SetBorderSize(0);
1438 leg->SetLineColor(1);
1439 leg->SetLineStyle(1);
1440 leg->SetLineWidth(1);
1441 leg->SetFillColor(0);
1442 leg->SetFillStyle(1001);
1444 TCanvas * c2Comp = new TCanvas("cCompToStarPos","cCompToStarPos");
1449 // TGraphErrors * g ;
1450 g = AliBWTools::DivideGraphByHisto(gStar[1],hSpectra[iCombInStudy][kPion][kPos],1);
1451 g->SetMarkerStyle(kFullCircle);
1452 g->SetMarkerColor(kBlack);
1454 leg->AddEntry(g,"#pi^{+}","lp");
1455 g = AliBWTools::DivideGraphByHisto(gStar[3],hSpectra[iCombInStudy][kKaon][kPos],1);
1456 g->SetMarkerStyle(kOpenCircle);
1457 g->SetMarkerColor(kRed);
1459 leg->AddEntry(g,"K^{+}","lp");
1460 g = AliBWTools::DivideGraphByHisto(gStar[5],hSpectra[iCombInStudy][kProton][kPos],1);
1461 g->SetMarkerStyle(kOpenSquare);
1462 g->SetMarkerColor(kBlue);
1464 leg->AddEntry(g,"p","lp");
1469 gStar[1]->Draw("p");
1470 hSpectra[iCombInStudy][kPion][kPos]->Draw("same");
1471 gStar[3]->Draw("p");
1472 hSpectra[iCombInStudy][kKaon][kPos]->Draw("same");
1473 gStar[5]->Draw("p");
1474 hSpectra[iCombInStudy][kProton][kPos]->Draw("same");
1479 gSystem->ProcessEvents();
1480 c1->Print(TString(c1->GetName()) + ".eps");
1481 c2->Print(TString(c2->GetName()) + ".eps");
1482 ALICEWorkInProgress(c1,today.Data(),"#splitline{ALICE Preliminary}{Statistical Error Only}");
1483 ALICEWorkInProgress(c2,today.Data(),"#splitline{ALICE Preliminary}{Statistical Error Only}");
1486 c1->Print(TString(c1->GetName()) + ".png");
1487 c2->Print(TString(c2->GetName()) + ".png");
1498 // Draws ratios of combined spectra
1501 TH1F * hPosNegRatio[kNPart];
1503 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1504 hPosNegRatio[ipart] = (TH1F*) hSpectra[iCombInStudy][ipart][kPos]->Clone();
1505 hPosNegRatio[ipart]->Divide(hSpectra[iCombInStudy][ipart][kNeg]);
1506 hPosNegRatio[ipart]->SetYTitle(TString(partLabel[ipart][kPos])+"/"+partLabel[ipart][kNeg]);
1507 hPosNegRatio[ipart]->SetMinimum(0.5);
1508 hPosNegRatio[ipart]->SetMaximum(1.5);
1511 TH1F * hKPiRatio = (TH1F*) hSpectra[iCombInStudy][kKaon][kPos]->Clone();
1512 hKPiRatio->Add(hSpectra[iCombInStudy][kKaon][kNeg]);
1513 TH1F * htmp = (TH1F*) hSpectra[iCombInStudy][kPion][kPos]->Clone();
1514 htmp->Add(hSpectra[iCombInStudy][kPion][kNeg]);
1515 hKPiRatio->Divide(htmp);
1516 hKPiRatio->SetYTitle("(K^{+}+K^{-})/(#pi^{+}+#pi^{-})");
1518 TH1F * hKPiRatioMC[kNTunes];
1520 for(Int_t itune = 0; itune < kNTunes; itune++){
1521 hKPiRatioMC[itune] = (TH1F*) hSpectraMC[itune][kKaon][kPos]->Clone();
1522 hKPiRatioMC[itune]->Add(hSpectraMC[itune][kKaon][kNeg]);
1523 TH1F * htmp = (TH1F*) hSpectraMC[itune][kPion][kPos]->Clone();
1524 htmp->Add(hSpectraMC[itune][kPion][kNeg]);
1525 hKPiRatioMC[itune]->Divide(htmp);
1526 hKPiRatioMC[itune]->SetYTitle("(K^{+}+K^{-})/(#pi^{+}+#pi^{-})");
1532 TH1F * hPPiRatio = (TH1F*) hSpectra[iCombInStudy][kProton][kPos]->Clone();
1533 hPPiRatio->Add(hSpectra[iCombInStudy][kProton][kNeg]);
1534 htmp = (TH1F*) hSpectra[iCombInStudy][kPion][kPos]->Clone();
1535 htmp->Add(hSpectra[iCombInStudy][kPion][kNeg]);
1536 hPPiRatio->Divide(htmp);
1537 hPPiRatio->SetYTitle("(p+#bar{p})/(#pi^{+}+#pi^{-})");
1540 TH1F * hPPiRatioMC[kNTunes];
1541 for(Int_t itune = 0; itune < kNTunes; itune++){
1542 hPPiRatioMC[itune] = (TH1F*) hSpectraMC[itune][kProton][kPos]->Clone();
1543 hPPiRatioMC[itune]->Add(hSpectraMC[itune][kProton][kNeg]);
1544 TH1F * htmp = (TH1F*) hSpectraMC[itune][kPion][kPos]->Clone();
1545 htmp->Add(hSpectraMC[itune][kPion][kNeg]);
1546 hPPiRatioMC[itune]->Divide(htmp);
1547 hPPiRatioMC[itune]->SetYTitle("(p+#bar{p})/(#pi^{+}+#pi^{-})");
1552 // TH2F * hempty = new TH2F(TString("hempty"),"hempty",100,0.,1.5, 100, 0.001,1.8);
1553 // hempty->SetXTitle("p_{t} (GeV/c)");
1554 // hempty->SetYTitle("");
1556 // tmp: overlay levi fits
1557 AliBWFunc * fm2 = new AliBWFunc;
1558 fm2->SetVarType(AliBWFunc::kdNdpt);
1559 TF1 * fLevi[kNPart] [kNCharge];
1560 fLevi[kPion] [kPos] = fm2->GetLevi (mass[0], 0.1243, 7.614785, 1.524167, "fLeviPiPlus");
1561 fLevi[kKaon] [kPos] = fm2->GetLevi (mass[1], 0.1625, 5.869318, 0.186361, "fLeviKPlus");
1562 fLevi[kProton][kPos] = fm2->GetLevi (mass[2], 0.1773, 6.918065, 0.086389, "fLeviPPlus");
1563 fLevi[kPion] [kNeg] = fm2->GetLevi (mass[0], 0.1267, 7.979582, 1.515908, "fLeviPiNeg");
1564 fLevi[kKaon] [kNeg] = fm2->GetLevi (mass[1], 0.1721, 6.927956, 0.191140, "fLeviKNeg");
1565 fLevi[kProton][kNeg] = fm2->GetLevi (mass[2], 0.1782, 8.160362, 0.082091, "fLeviPNeg");
1566 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1567 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1568 fLevi[ipart][icharge]->SetRange(0,4);
1573 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1574 TString detName = detFlag[iCombInStudy];
1575 detName.ReplaceAll(" ", "_");
1576 detName.ReplaceAll("+", "");
1578 TCanvas * c1 = new TCanvas(TString("cRatio_")+detName+TString("_")+partFlag[ipart], TString("cRatio_")+detName+partFlag[ipart]);
1580 hPosNegRatio[ipart]->Draw();
1581 TF1 * fRatio = new TF1 (TString("fRatio")+partFlag[ipart], TString(fLevi[ipart][kPos]->GetName())+"/"+fLevi[ipart][kNeg]->GetName());
1582 // fRatio->Draw("same");
1583 fRatio->SetRange(0,5);
1586 gSystem->ProcessEvents();
1587 c1->Print(TString(c1->GetName()) + ".png");
1593 TCanvas * c2 = new TCanvas(TString("cRatio_KPi"),TString("cRatio_KPi"));
1596 TLegend * lMC = new TLegend(0.526846, 0.18007, 0.887584,0.407343);
1597 lMC->SetFillColor(kWhite);
1600 gROOT->LoadMacro("GetE735Ratios.C");
1601 GetE735Ratios(0,0)->Draw("EX0,same");
1602 GetE735Ratios(0,1)->Draw("EX0,same");
1603 GetE735Ratios(0,2)->Draw("EX0,same");
1604 GetE735Ratios(0,3)->Draw("EX0,same");
1606 hKPiRatio->SetMarkerStyle(20);
1607 hKPiRatio->Draw("same");
1610 for(Int_t itune = 0; itune < kNTunes; itune++){
1611 lMC->AddEntry(hKPiRatioMC[itune],mcTuneName[itune]);
1612 hKPiRatioMC[itune]->SetLineWidth(2);
1613 hKPiRatioMC[itune]->Draw("same,chist");
1620 TLegend * l = new TLegend( 0.1879, 0.68, 0.54,0.92);
1621 l->SetFillColor(kWhite);
1622 l->AddEntry(hKPiRatio, "ALICE, #sqrt{s} = 900 GeV","lpf");
1623 l->AddEntry(GetE735Ratios(0,0), "E735, #sqrt{s} = 300 GeV","lpf");
1624 l->AddEntry(GetE735Ratios(0,1), "E735, #sqrt{s} = 540 GeV","lpf");
1625 l->AddEntry(GetE735Ratios(0,2), "E735, #sqrt{s} = 1000 GeV","lpf");
1626 l->AddEntry(GetE735Ratios(0,3), "E735, #sqrt{s} = 1800 GeV","lpf");
1631 TCanvas * c3 = new TCanvas(TString("cRatio_PPi"),TString("cRatio_PPi"));
1634 hPPiRatio->SetMaximum(0.39);
1636 lMC = new TLegend(0.526846, 0.18007, 0.887584,0.407343);
1637 lMC->SetFillColor(kWhite);
1639 for(Int_t itune = 0; itune < kNTunes; itune++){
1640 lMC->AddEntry(hKPiRatioMC[itune],mcTuneName[itune]);
1641 hKPiRatioMC[itune]->SetLineWidth(2);
1642 hKPiRatioMC[itune]->Draw("same,chist");
1650 gSystem->ProcessEvents();
1651 c2->Print(TString(c2->GetName()) + ".png");
1652 c2->Print(TString(c2->GetName()) + ".eps");
1654 gSystem->ProcessEvents();
1655 c3->Print(TString(c3->GetName()) + ".png");
1656 c3->Print(TString(c3->GetName()) + ".eps");
1665 cout << "Macro: void CombineSpectra(Int_t analysisType=kDoFits, Int_t fitFuncID = kFitLevi) " << endl;
1668 cout << "Possible Arguments" << endl;
1669 cout << "- analysisType:" << endl;
1670 cout << " kDoFits: Fit Combined Spectra " << endl;
1671 cout << " kDoRatios: Particle ratios K/pi and p/pi" << endl;
1672 cout << " kDoSuperposition: Compare different detectors (superimpose and ratios)" << endl;
1673 cout << " kDoCompareStar: Compare combined spectra to star results" << endl;
1674 cout << " kDoDrawWithModels: Compare combined spectra and models" << endl;
1675 cout << " kDoHelp: This help" << endl;
1676 cout << "- fitFuncID, function used to extrapolate and compute yields" << endl;
1677 cout << " An analitic fit function [kFitLevi, kFitUA1, kFitPowerLaw]" << endl;
1678 cout << " Or a shape from a MC moder [kFitPhojet, kFitAtlasCSC, kFitCMS6D6T, kFitPerugia0]" << endl;
1679 cout << " Which is fitted to the data at low pt and used to extrapolate at low pt" << endl;