- Rebbined ratios in the TOF range
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / Fit / CombineSpectra.C
CommitLineData
5f2ca1e6 1#if !defined(__CINT__) || defined(__MAKECINT__)
4c0d7bc7 2#include <iostream>
3#include "TH1F.h"
4#include "TGraphErrors.h"
5#include "AliBWFunc.h"
6#include "AliBWTools.h"
7#include "TF1.h"
8#include "TFile.h"
9#include "TDatabasePDG.h"
10#include "TROOT.h"
11#include "TCanvas.h"
12#include "TFolder.h"
13#include "TStyle.h"
14#include "AliLatexTable.h"
15#include "TLegend.h"
16#include "TVirtualFitter.h"
17#include "TMath.h"
18#include "TH2F.h"
19#include "TSystem.h"
20#include "TLine.h"
21#include "TLatex.h"
22#include "TMath.h"
23
24#include "TASImage.h"
25#include "TPaveText.h"
4c0d7bc7 26#include "StarPPSpectra.C"
27#include "GetE735Ratios.C"
3472a634 28#include "TString.h"
3725266c 29#include "TObjString.h"
77233d47 30#include "TGraphAsymmErrors.h"
31
5f2ca1e6 32#endif
4c0d7bc7 33
3725266c 34
4c0d7bc7 35using namespace std;
36
37
38// A bunch of useful enums and constants
39enum {kPion=0,kKaon,kProton,kNPart};
ee08b77d 40enum {kTPC=0,kTOF,kITS,kITSTPC,kK0,kKinks,kCombTOFTPC,kCombAll,kNHist};// "k0" listed here as a kind of PID method...
4c0d7bc7 41const Int_t kNDet = kITS+2;
42enum {kPos=0,kNeg,kNCharge};
43enum {kPhojet=0,kPyTuneAtlasCSC, kPyTuneCMS6D6T, kPyTunePerugia0, kNTunes} ;
44enum {kFitLevi=0, kFitUA1, kFitPowerLaw,
45 kFitPhojet, kFitAtlasCSC, kFitCMS6D6T, kFitPerugia0,
46 kNFit};
77233d47 47enum {kDoFits=0, kDoRatios, kDoSuperposition, kDoDrawWithModels, kDoCompareToStar, kDoDrawSyst, kDoCompareToAllCharged, kDoHelp};
058137a6 48enum {kStatErrors = 0, kSystErrors, kStatSystErrors}; // which errors do we put in the histo that we fit? stat,syst or stat+syst?
4c0d7bc7 49
50// flags, labels and names
51const char * partFlag[] = {"Pion", "Kaon", "Proton"};
d8e6677d 52const char * detFlag[] = {"TPC", "TOF", "ITS standalone", "ITS-TPC", "K0", "Kinks", "Combined TOF + TPC", "Combined TOF + TPC + ITS"};
4c0d7bc7 53const char * chargeFlag[] = {"Pos", "Neg"};
54const char * chargeLabel[] = {"Positive", "Negative"};
55const char * partLabel[kNPart][kNCharge] = {{"#pi^{+}", "#pi^{-}"},
56 // {"K^{+} (#times 2)", "K^{-} (#times 2)"},
57 {"K^{+}", "K^{-}"},
58 {"p" , "#bar{p}"}};
5f2ca1e6 59const char * partLatex[kNPart][kNCharge] = {{"$\\pi^{+}$", "$\\pi^{-}$"},
60 // {"K^{+} (#times 2)", "K^{-} (#times 2)"},
61 {"$K^{+}$", "$K^{-}$"},
62 {"$p$" , "$\\bar{p}$"}};
4c0d7bc7 63const char * mcTuneName[] = {"Phojet",
64 "Pythia - CSC 306",
65 "Pythia - D6T 109",
66 "Pythia - Perugia0 - 320", };
67const char * funcName[] = { "Levi", "UA1", "PowerLaw", "Phojet", "AtlasCSC", "CMS6D6T", "Perugia0"};
68
69// Style
70//const Int_t marker[] = {25,24,28,20,21}; // set for highlithining marek
d8e6677d 71//const Int_t marker[] = {20,24,25,28,21}; // standard set
72const Int_t marker[] = {24,25,28,27,21}; // No full symbols
4c0d7bc7 73const Int_t color [] = {1,2,4};
74
75const Int_t mcLineColor[] = {kGreen,kRed,kBlue,kBlack};
76const Int_t mcLineStyle[] = {1,2,3,4};
77
78
79// Template needed to combine different detectors
ee08b77d 80const 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};
81Int_t nbinsTempl=34;
4c0d7bc7 82
83TH1F * htemplate = new TH1F("htemplate", "htemplate",nbinsTempl, templBins );
84
85// Globals
86TH1F * hSpectra[kNHist][kNPart][kNCharge];
87TH1F * hSpectraMC[kNTunes][kNPart][kNCharge];
3725266c 88TH1F * hSystError[kNHist][kNPart][kNCharge];
4c0d7bc7 89Double_t mass[kNPart];
90
91// Functions:
92// Loading
93void LoadSpectra() ;
94void LoadMC() ;
95
96// Additional tasks (may be uncommented below)
3725266c 97void LoadLibs();
4c0d7bc7 98void DrawStar(Int_t icharge);
99void GetITSResiduals();
100void DrawWithModels() ;
101void DrawAllAndKaons();
102void DrawWithJacek();
103void DrawRatioToStar();
104void DrawRatios();
3725266c 105void DrawWithSyst();
5f2ca1e6 106void FitCombined();
3725266c 107void PrintCanvas(TCanvas* c,const TString formats) ;
4d4a268c 108void RebinHistosForRatios() ;
c4fe358b 109void Help();
4c0d7bc7 110
111// External stuff
5f2ca1e6 112void ALICEWorkInProgress(TCanvas *c,TString today="11/05/2010", TString label = "ALICE performance"){
113
55056a39 114 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",0.72,0.72,0.89,0.89);
115 //TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",0.72,0.62,0.85,0.75);
5f2ca1e6 116 myPadLogo->SetFillColor(0);
117 myPadLogo->SetBorderMode(0);
118 myPadLogo->SetBorderSize(2);
119 myPadLogo->SetFrameBorderMode(0);
120 myPadLogo->SetLeftMargin(0.0);
121 myPadLogo->SetTopMargin(0.0);
122 myPadLogo->SetBottomMargin(0.0);
123 myPadLogo->SetRightMargin(0.0);
124 myPadLogo->SetFillStyle(0);
125 myPadLogo->Draw();
126 myPadLogo->cd();
127 TASImage *myAliceLogo = new TASImage("alice_logo.png");
128 myAliceLogo->Draw();
55056a39 129 c->cd();
130 TPaveText* t1=new TPaveText(0.418103, 0.837798, 0.656609, 0.888393,"NDC");
5f2ca1e6 131 t1->SetFillStyle(0);
132 t1->SetBorderSize(0);
133 t1->AddText(0.,0.,label);
134 t1->SetTextColor(kRed);
135 t1->SetTextFont(42);
55056a39 136 t1->SetTextSize(0.04);
5f2ca1e6 137 t1->Draw();
55056a39 138 TPaveText* t2=new TPaveText(0.418103, 0.80, 0.656609, 0.84,"NDC");
5f2ca1e6 139 t2->SetFillStyle(0);
140 t2->SetBorderSize(0);
55056a39 141 t2->AddText(0.,0.,"pp at #sqrt{s} = 900 GeV (2009 data)");
5f2ca1e6 142 t2->SetTextColor(kRed);
55056a39 143 t2->SetTextFont(42);
144 t2->SetTextSize(0.027);
5f2ca1e6 145 t2->Draw();
55056a39 146 TPaveText* t3=new TPaveText(0.418103, 0.76, 0.656609, 0.80,"NDC");
147 t3->SetFillStyle(0);
148 t3->SetBorderSize(0);
149 t3->AddText(0.,0.,"Statistical and systematic errors");
150 t3->SetTextColor(kRed);
151 t3->SetTextFont(42);
152 t3->SetTextSize(0.027);
153 t3->Draw();
154 // TPaveText* t2=new TPaveText(0.65,0.65,0.89,0.7,"NDC");
155 // t2->SetFillStyle(0);
156 // t2->SetBorderSize(0);
157 // t2->SetTextColor(kRed);
158 // t2->SetTextFont(52);
159 // t2->AddText(0.,0.,today.Data());
160 // t2->Draw();
5f2ca1e6 161}
4c0d7bc7 162
163// Used to tag plots
164TDatime dt;
165TString today = "";
166
167
168
169// Switches
170Bool_t convertToMT = 0;
77233d47 171Bool_t sumCharge = 0;
058137a6 172Int_t whatToFit = kStatErrors;
4c0d7bc7 173Bool_t scaleKaons = kFALSE;
0e6f7392 174Bool_t drawStar = kFALSE; // Overlay star when doing fits
4c0d7bc7 175Bool_t correctSecondaries = 1;
176Bool_t correctGeantFlukaXS = 1;
5f2ca1e6 177Int_t iCombInStudy = kCombAll; //kCombTOFTPC
c4fe358b 178Int_t fitFuncID = kFitLevi;
5f2ca1e6 179Bool_t showMC=kTRUE;
180Bool_t showE735=kTRUE;
77233d47 181Bool_t useSecCorrFromDCA=kTRUE;
2210b002 182Bool_t flagPreliminary=kFALSE; // Add "preliminary" flag and logo to the plots
183Bool_t doPrint = 0;
184TString printFormats = "C,eps,root"; // format in which canvases will be printed, if PrintCanvas is called (not all prints are based on printcanvas at the moment). This is a comma separated list.
22abbb27 185
4c0d7bc7 186
eea641de 187void CombineSpectra(Int_t analysisType=kDoHelp, Int_t locfitFuncID = kFitLevi) { //kDoSuperposition;//kDoDrawWithModels;// kDoFits; //kDoRatios;
4c0d7bc7 188
189 // This macro is used to combine the 900 GeV spectra from 2009
190
c4fe358b 191 fitFuncID=locfitFuncID;
192
4c0d7bc7 193 // Load stuff
3725266c 194 LoadLibs();
4c0d7bc7 195
eea641de 196 // Print Help and quit
197 if (analysisType == kDoHelp) {
198 Help();
199 return;
200 }
201
202
4c0d7bc7 203 // Set date
204 today = today + long(dt.GetDay()) +"/" + long(dt.GetMonth()) +"/"+ long(dt.GetYear());
205
206
207 // Set Masses
208 mass[kPion] = TDatabasePDG::Instance()->GetParticle("pi+")->Mass();
209 mass[kKaon] = TDatabasePDG::Instance()->GetParticle("K+")->Mass();
210 mass[kProton] = TDatabasePDG::Instance()->GetParticle("proton")->Mass();
211
212 // Load histos
213 LoadSpectra();
214 LoadMC();
215
216 // Additional tasks
217 //DrawStar(icharge);
218 // GetITSResiduals();
5f2ca1e6 219 if(analysisType==kDoSuperposition) DrawAllAndKaons();
220 else if(analysisType==kDoDrawWithModels) DrawWithModels() ;
77233d47 221 else if(analysisType==kDoCompareToAllCharged) DrawWithJacek();
c4fe358b 222 else if(analysisType==kDoCompareToStar) DrawRatioToStar();
5f2ca1e6 223 else if(analysisType==kDoRatios) DrawRatios();
3725266c 224 else if(analysisType==kDoDrawSyst) DrawWithSyst();
5f2ca1e6 225 else if(analysisType==kDoFits) FitCombined();
b7018bc7 226 return;
5f2ca1e6 227}
4c0d7bc7 228
229
5f2ca1e6 230void FitCombined() {
eea641de 231 gStyle->SetOptTitle(0);
232 gStyle->SetOptStat(0);
233
4c0d7bc7 234 // Draw combined & Fit
235 AliBWFunc * fm = new AliBWFunc;
236 fm->SetVarType(AliBWFunc::kdNdpt);
237 if (convertToMT) fm->SetVarType(AliBWFunc::kOneOverMtdNdmt);
238
239 // table to print results
2f7f947e 240 AliLatexTable table(10,"c|ccccccccc");
4c0d7bc7 241 if (fitFuncID == kFitLevi) {
55056a39 242 table.InsertCustomRow("Part & Yield & Yield (FIT) & T Slope & n & $\\chi^2$/NDF & Min X & Extrap (%) & $\\langle p_{t} \\rangle (Fit)$ & $\\langle p_{t} \\rangle$ (FIT+DATA)\\\\");
4c0d7bc7 243 } else if (fitFuncID == kFitPowerLaw) {
55056a39 244 table.InsertCustomRow("Part & Yield & Norm & n & pt0 & $\\chi^2$/NDF & Min X & Frac Above & $\\langle p_{t} \\rangle (Fit)$ & $\\langle p_{t} \\rangle$ (FIT+DATA) \\\\");
4c0d7bc7 245 } else {
55056a39 246 table.InsertCustomRow("Part & Yield & Par0 & Par2 & Par1 & $\\chi^2$/NDF & Min X & Frac Above & $\\langle p_{t} \\rangle (Fit)$ & $\\langle p_{t} \\rangle$ (FIT+DATA) \\\\");
4c0d7bc7 247
248 }
2f7f947e 249 table.InsertHline();
49ad829f 250 AliLatexTable tempTable(3,"c|cc");
251 tempTable.InsertCustomRow("Part & Yield & $\\langle p_{t} \\rangle$ \\\\");
252 tempTable.InsertHline();
4c0d7bc7 253
2210b002 254 TH1F* hRatiosToFit[kNPart][kNCharge]; // Ratio data/fit function, stat error by default
255 TH1F* hRatiosToFitSyst[kNPart][kNCharge]; // Ratio data/fit, stat + syst
058137a6 256 // Fit all
257 Int_t chargeLoop = sumCharge ? 1 : 2;
258 for(Int_t icharge = 0; icharge < chargeLoop; icharge++){
5f2ca1e6 259
260 TCanvas * c2 = new TCanvas(TString("cCombined")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombined")+chargeFlag[icharge],700,700);
261 c2->SetTickx();
262 c2->SetTicky();
263 c2->SetLeftMargin(0.14);
264 TCanvas * c2r = new TCanvas(TString("cCombinedRatio")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombinedRatio")+chargeFlag[icharge],700,700);
5f2ca1e6 265 c2->cd();
266 gPad->SetLogy();
267 TH2F * hempty = new TH2F(TString("hempty")+long(icharge),"hempty",100,0.,2.9, 100, 0.0005,5);
4c0d7bc7 268 hempty->SetXTitle("p_{t} (GeV/c)");
269 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
5f2ca1e6 270 hempty->GetYaxis()->SetTitleOffset(1.35);
271 hempty->GetXaxis()->SetTitleOffset(1.1);
4c0d7bc7 272 hempty->Draw();
5f2ca1e6 273 c2r->cd();
274 gPad->SetGridy();
275 TH2F * hemptyR = new TH2F(TString("hemptyR")+long(icharge),"hemptyR",100,0.,2.9, 100, 0.5,1.5);
276 hemptyR->SetXTitle("p_{t} (GeV/c)");
277 hemptyR->SetYTitle("Data/Fit");
278 hemptyR->Draw();
279
22abbb27 280
281 TLegend * l = new TLegend(0.176724, 0.153274, 0.475575, 0.434524,chargeLabel[icharge]);
4c0d7bc7 282 l->SetFillColor(kWhite);
5f2ca1e6 283 l->SetTextSize(0.035);
55056a39 284
285
286
287 TPaveText* tf=new TPaveText(0.321839, 0.175595, 0.685345, 0.299107,"NDC");
5f2ca1e6 288 if(fitFuncID == kFitLevi){
289 tf->AddText("#frac{dN}{dp_{t}} #propto p_{t} #left(1+#frac{#sqrt{m^{2}+p_{t}^{2}} -m}{nT} #right)^{-n}");
290 // tf->SetNDC();
291 tf->SetTextFont(12);
55056a39 292 tf->SetTextSize(0.032);
5f2ca1e6 293 }
4c0d7bc7 294 for(Int_t ipart = 0; ipart < kNPart; ipart++){
5f2ca1e6 295 printf(" ----- Fit %s %s ------\n",partFlag[ipart],chargeFlag[icharge]);
4c0d7bc7 296 Float_t fitmin = 0;
297 Float_t fitmax = 3;
298
299 // Get functions
300 TF1 * func = 0;
3472a634 301 Int_t normPar = -1;
4c0d7bc7 302 if(fitFuncID == kFitLevi) {
3472a634 303 normPar = 0; // The levi is normalized by parameter 0
4c0d7bc7 304 if (ipart == kPion)
305 func = fm->GetLevi(mass[ipart], 0.12, 7, 1.5);
306 if (ipart == kKaon)
307 func = fm->GetLevi(mass[ipart], 0.17, 7, 0.17);
308 if (ipart == kProton)
5f2ca1e6 309 func = fm->GetLevi(mass[ipart], 0.15, 8.5, 0.09);
310 }
4c0d7bc7 311 else if(fitFuncID == kFitUA1) func = fm->GetUA1(mass[ipart],0.2,1.25,1.25,0.2,1.5);
312 else if(fitFuncID == kFitPowerLaw) {
22abbb27 313 // fitmin=0;
314 // fitmax=1;
4c0d7bc7 315 if (ipart == kPion)
316 func = fm->GetPowerLaw(1.0, 8.6, 7);
317 if (ipart == kKaon)
318 func = fm->GetPowerLaw(3.0, 12, 2.6);
319 if (ipart == kProton)
320 func = fm->GetPowerLaw(24, 72, 0.8);
321 }
322 else if(fitFuncID == kFitPhojet) func = fm->GetHistoFunc(hSpectraMC[kPhojet] [ipart][icharge]);
323 else if(fitFuncID == kFitAtlasCSC) func = fm->GetHistoFunc(hSpectraMC[kPyTuneAtlasCSC][ipart][icharge]);
324 else if(fitFuncID == kFitPerugia0) func = fm->GetHistoFunc(hSpectraMC[kPyTunePerugia0][ipart][icharge]);
325 else if(fitFuncID == kFitCMS6D6T) func = fm->GetHistoFunc(hSpectraMC[kPyTuneCMS6D6T] [ipart][icharge]);
326 else {
327 cout << "Unknown fit ID " << fitFuncID << endl;
328 return;
329 }
330
331 if(fitFuncID >= kFitPhojet){
332 fitmin = 0.0;
333 fitmax = 1.0;
334 }
335
058137a6 336 // Temp: fit histo with sist errors
22abbb27 337 TH1F * hsyst = new TH1F(*htemplate);
338 TH1F * hsyststat = 0;
55056a39 339 hsyst->SetFillColor(kGray);
3725266c 340 AliBWTools::GetValueAndError(hsyst,hSpectra[iCombInStudy][ipart][icharge],hSystError[iCombInStudy][ipart][icharge],kTRUE);
22abbb27 341 hsyststat= new TH1F(*hsyst);
342 AliBWTools::GetHistoCombinedErrors(hsyststat,hSpectra[iCombInStudy][ipart][icharge]); // combine syst and stat
55056a39 343 hsyststat->SetFillColor(kGray);
3725266c 344
058137a6 345 TH1F * hToFit = 0;
346 if (whatToFit == kStatErrors) hToFit = hSpectra[iCombInStudy][ipart][icharge]; // Shorthand
347 if (sumCharge) hToFit->Add(hSpectra[iCombInStudy][ipart][1]);
348 if (whatToFit == kStatSystErrors) {
22abbb27 349 hToFit = hsyststat;// Shorthand
058137a6 350 }
351 if (whatToFit == kSystErrors) hToFit = hsyst;
352
3725266c 353
354 if(!AliBWTools::Fit(hToFit,func,fitmin,fitmax)) {
4c0d7bc7 355 cout << " FIT ERROR " << endl;
356 return;
357 }
3725266c 358 cout << "DRAWING" << endl;
22abbb27 359 c2->cd();
360 hsyststat->Draw("same,e2");
361 // TH1F * hsyststat2 = new TH1F(*hsyststat);
362 // hsyststat2->SetFillColor(kWhite);
363 // hsyststat2->SetLineColor(kBlack);
364 // hsyststat2->Draw("same,e2");
058137a6 365 hToFit->Draw("same");
3725266c 366 TF1* fitfunc=(TF1*)hToFit->GetListOfFunctions()->At(0);
5f2ca1e6 367 fitfunc->Draw("same");
368 fitfunc->SetRange(0,4);
369 fitfunc->SetLineColor(hSpectra[iCombInStudy][ipart][icharge]->GetLineColor());
c4fe358b 370 if(drawStar) DrawStar(icharge);
058137a6 371 hRatiosToFit[ipart][icharge]=(TH1F*)hToFit->Clone(Form("hRatio%s%s",chargeFlag[icharge],partFlag[icharge])); // Ratio data/fit
2210b002 372 hRatiosToFitSyst[ipart][icharge]=(TH1F*)hsyststat->Clone(Form("hRatioSyst%s%s",chargeFlag[icharge],partFlag[icharge])); // Ratio data/fit
4d4a268c 373 // Compute ratio data/function integrating the function in the bin width
058137a6 374 for(Int_t iBin=1; iBin<hToFit->GetNbinsX(); iBin++){
375 Double_t lowLim=hToFit->GetBinLowEdge(iBin);
376 Double_t highLim=hToFit->GetBinLowEdge(iBin+1);
5f2ca1e6 377 Double_t contFunc=fitfunc->Integral(lowLim,highLim)/(highLim-lowLim);
058137a6 378 Double_t ratio=hToFit->GetBinContent(iBin)/contFunc;
379 Double_t eratio=hToFit->GetBinError(iBin)/contFunc;
2210b002 380 Double_t eratioSyst=hsyststat->GetBinError(iBin)/contFunc;
381 hRatiosToFitSyst[ipart][icharge]->SetBinContent(iBin,ratio);
382 hRatiosToFitSyst[ipart][icharge]->SetBinError(iBin,eratioSyst);
5f2ca1e6 383 hRatiosToFit[ipart][icharge]->SetBinContent(iBin,ratio);
384 hRatiosToFit[ipart][icharge]->SetBinError(iBin,eratio);
385 }
5f2ca1e6 386 c2->Update();
058137a6 387 l->AddEntry(hToFit,
4c0d7bc7 388 scaleKaons && ipart == kKaon ?
389 (TString(partLabel[ipart][icharge])+" #times 2").Data()
390 : partLabel[ipart][icharge]);
4c0d7bc7 391
392 // populate table
393 // Float_t yield = func->Integral(0.45,1.05);
394 // Float_t yieldE = func->IntegralError(0.45,1.05);
395
396 Float_t yield = func->Integral(0.,100);
397 //Float_t yieldE = func->IntegralError(0.,100);
398
399 Double_t yieldTools, yieldETools;
400 Double_t partialYields[3],partialYieldsErrors[3];
058137a6 401 AliBWTools::GetYield(hToFit, func, yieldTools, yieldETools,
4c0d7bc7 402 0, 100, partialYields,partialYieldsErrors);
403 Double_t tslope = func->GetParameter(2);
404 Double_t tslopeE = func->GetParError(2);
405
5f2ca1e6 406 table.SetNextCol(partLatex[ipart][icharge]);
4c0d7bc7 407 //table.SetNextCol(yield,yieldE,-4);
408 table.SetNextCol(yieldTools, yieldETools,-4);
409 table.SetNextCol(func->GetParameter(0));
410 table.SetNextCol(tslope,tslopeE,-4);
55056a39 411 table.SetNextCol(func->GetParameter(1),func->GetParError(1),-2);
4c0d7bc7 412 table.SetNextCol(Form("%2.2f/%d",func->GetChisquare(),func->GetNDF()));
058137a6 413 Float_t lowestPoint = AliBWTools::GetLowestNotEmptyBinEdge(hToFit);
4c0d7bc7 414 //Float_t lowestPoint = AliBWTools::GetLowestNotEmptyBinEdge(hSpectra[kITS][ipart][icharge]);
415 Float_t yieldAbove = func->Integral(lowestPoint,100);
416 table.SetNextCol(lowestPoint,-2);
55056a39 417 table.SetNextCol((1 - yieldAbove/yield)*100,-1);
418 Float_t mean, meane; // Mean using only fit function
419 Double_t meanDF, meanDFe; // Mean from data + fit
4c0d7bc7 420 Float_t mean2, mean2e;
55056a39 421 if (fitFuncID < kFitPhojet) {
422 AliBWTools::GetMean (func, mean, meane , 0.,100., normPar);
423 AliBWTools::GetMeanSquare(func, mean2, mean2e, 0.,100., normPar);
424 }
ffcaf7be 425 // AliBWTools::GetMeanDataAndExtrapolation(hToFit, func, meanDF, meanDFe, 0.,100.);
55056a39 426 AliBWTools::GetMeanDataAndExtrapolation(hToFit, func, meanDF, meanDFe, 0.,100.);
55056a39 427 table.SetNextCol(mean, meane ,-4);
428 table.SetNextCol(meanDF, meanDFe,-4);
4c0d7bc7 429
430 // fMean2->IntegralError(0,100)/func->Integral(0,100),-7);
431 table.InsertRow();
432
433
434 /// TEMP TABLE
49ad829f 435 tempTable.SetNextCol(partLatex[ipart][icharge]);
4c0d7bc7 436 tempTable.SetNextCol(yieldTools, yieldETools, -4);
55056a39 437 tempTable.SetNextCol(meanDF, meanDFe ,-4);
49ad829f 438 // tempTable.SetNextCol(partialYields[1], partialYieldsErrors[1], -4);
439 // tempTable.SetNextCol(yieldAbove/yield,-2);
4c0d7bc7 440 tempTable.InsertRow();
5f2ca1e6 441 c2r->cd();
2210b002 442 hRatiosToFitSyst[ipart][icharge]->Draw("e2same");
5f2ca1e6 443 hRatiosToFit[ipart][icharge]->Draw("esame");
444
4c0d7bc7 445 }
5f2ca1e6 446 c2->cd();
2210b002 447 if (flagPreliminary) ALICEWorkInProgress(c2,"","ALICE Preliminary");
5f2ca1e6 448 l->Draw();
2210b002 449 if (flagPreliminary) tf->Draw();
5f2ca1e6 450 c2r->cd();
2210b002 451 if(flagPreliminary) ALICEWorkInProgress(c2r,"","ALICE Preliminary");
4c0d7bc7 452 l->Draw();
0e019ec6 453 PrintCanvas(c2,printFormats);
454 PrintCanvas(c2r,printFormats);
4c0d7bc7 455
5f2ca1e6 456
4c0d7bc7 457 }
458
459
55056a39 460 table.PrintTable("ASCII");
4c0d7bc7 461
462 cout << "" << endl;
463 tempTable.PrintTable("ASCII");
464
5f2ca1e6 465
466
4c0d7bc7 467}
468
469void LoadSpectra() {
470
3725266c 471 // Loads spectra for different detectors and corresponding systematic errors.
472
4c0d7bc7 473 TFile * f=0;
474
3725266c 475 // Systematic errors: initialize histos
476 gROOT->cd();
477 for(Int_t ipart = 0; ipart < kNPart; ipart++){
478 for(Int_t idet = 0; idet < kNHist; idet++){
479 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
480 hSystError[idet][ipart][icharge] = new TH1F (TString("hSyst_")+detFlag[idet]+partFlag[ipart]+chargeFlag[icharge],
481 TString("hSyst_")+detFlag[idet]+partFlag[ipart]+chargeFlag[icharge],
482 nbinsTempl,templBins);
483 hSystError[idet][ipart][icharge]->SetMarkerColor (color[ipart] );
484 hSystError[idet][ipart][icharge]->SetLineColor (color[ipart] );
485
486 }
487
488 }
489
490 }
491
4c0d7bc7 492 // Load
493
494
495 // TOF
5f2ca1e6 496 // Load Efficiencies
4d4a268c 497 f = new TFile("./Files/effTOFhistosSmooth.root");
498 TFile * ftrk = new TFile("./Files/effhistos.root");
5f2ca1e6 499 TH1D * hEffTrackTOF[kNPart][kNCharge];
500 TH1D * hEffMatchTOF[kNPart][kNCharge];
4d4a268c 501 hEffTrackTOF[kPion] [kPos] = (TH1D*) ftrk->Get("hpitrk_pos");
502 hEffTrackTOF[kKaon] [kPos] = (TH1D*) ftrk->Get("hkatrk_pos");
503 hEffTrackTOF[kProton][kPos] = (TH1D*) ftrk->Get("hprtrk_pos");
5f2ca1e6 504 hEffMatchTOF[kPion] [kPos] = (TH1D*) f->Get("hpieff_pos");
505 hEffMatchTOF[kKaon] [kPos] = (TH1D*) f->Get("hkaeff_pos");
506 hEffMatchTOF[kProton][kPos] = (TH1D*) f->Get("hpreff_pos");
4d4a268c 507 hEffTrackTOF[kPion] [kNeg] = (TH1D*) ftrk->Get("hpitrk_neg");
508 hEffTrackTOF[kKaon] [kNeg] = (TH1D*) ftrk->Get("hkatrk_neg");
509 hEffTrackTOF[kProton][kNeg] = (TH1D*) ftrk->Get("hprtrk_neg");
5f2ca1e6 510 hEffMatchTOF[kPion] [kNeg] = (TH1D*) f->Get("hpieff_neg");
511 hEffMatchTOF[kKaon] [kNeg] = (TH1D*) f->Get("hkaeff_neg");
512 hEffMatchTOF[kProton][kNeg] = (TH1D*) f->Get("hpreff_neg");
513
4c0d7bc7 514 // f = new TFile("./Files/spectra-pos-y.root");
5f2ca1e6 515 f = new TFile("./Files/spectraRaw-pos-y.root");
4c0d7bc7 516 hSpectra[kTOF][kPion] [kPos]= (TH1F*) f->Get("hpi");
517 hSpectra[kTOF][kProton][kPos]= (TH1F*) f->Get("hpr");
518 hSpectra[kTOF][kKaon] [kPos]= (TH1F*) f->Get("hka");
519 hSpectra[kTOF][kPion] [kPos]->SetName("hpiPos");
520 hSpectra[kTOF][kProton][kPos]->SetName("hprPos");
521 hSpectra[kTOF][kKaon] [kPos]->SetName("hkaPos");
522 //f = new TFile("./Files/spectra-neg-y.root");
5f2ca1e6 523 f = new TFile("./Files/spectraRaw-neg-y.root");
4c0d7bc7 524 hSpectra[kTOF][kPion] [kNeg]= (TH1F*) f->Get("hpi");
525 hSpectra[kTOF][kProton][kNeg]= (TH1F*) f->Get("hpr");
526 hSpectra[kTOF][kKaon] [kNeg]= (TH1F*) f->Get("hka");
527 hSpectra[kTOF][kPion] [kNeg]->SetName("hpiNeg");
528 hSpectra[kTOF][kProton][kNeg]->SetName("hprNeg");
529 hSpectra[kTOF][kKaon] [kNeg]->SetName("hkaNeg");
530
5f2ca1e6 531 // Divide for efficiency
532 hSpectra[kTOF][kPion] [kPos]->Divide(hEffTrackTOF[kPion] [kPos]);
533 hSpectra[kTOF][kKaon] [kPos]->Divide(hEffTrackTOF[kKaon] [kPos]);
534 hSpectra[kTOF][kProton][kPos]->Divide(hEffTrackTOF[kProton][kPos]);
535 hSpectra[kTOF][kPion] [kPos]->Divide(hEffMatchTOF[kPion] [kPos]);
536 hSpectra[kTOF][kKaon] [kPos]->Divide(hEffMatchTOF[kKaon] [kPos]);
537 hSpectra[kTOF][kProton][kPos]->Divide(hEffMatchTOF[kProton][kPos]);
538 hSpectra[kTOF][kPion] [kNeg]->Divide(hEffTrackTOF[kPion] [kNeg]);
539 hSpectra[kTOF][kKaon] [kNeg]->Divide(hEffTrackTOF[kKaon] [kNeg]);
540 hSpectra[kTOF][kProton][kNeg]->Divide(hEffTrackTOF[kProton][kNeg]);
541 hSpectra[kTOF][kPion] [kNeg]->Divide(hEffMatchTOF[kPion] [kNeg]);
542 hSpectra[kTOF][kKaon] [kNeg]->Divide(hEffMatchTOF[kKaon] [kNeg]);
543 hSpectra[kTOF][kProton][kNeg]->Divide(hEffMatchTOF[kProton][kNeg]);
544
545
546 // Clean UP TOF spectra, removing unwanted points
4c0d7bc7 547 cout << "Cleaning Up TOF spectra" << endl;
548 Int_t nbin = hSpectra[kTOF][kKaon][kPos]->GetNbinsX();
549 for(Int_t ibin = 1; ibin <= nbin; ibin++){
550 Float_t pt = hSpectra[kTOF][kKaon][kPos]->GetBinCenter(ibin);
551 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
552 if (pt > 2.35) {
553 hSpectra[kTOF][kKaon][icharge]->SetBinContent(ibin,0);
554 hSpectra[kTOF][kKaon][icharge]->SetBinError (ibin,0);
555 hSpectra[kTOF][kProton][icharge]->SetBinContent(ibin,0);
556 hSpectra[kTOF][kProton][icharge]->SetBinError (ibin,0);
4d4a268c 557 }
558 if (pt < 0.7) {
559 hSpectra[kTOF][kProton][icharge]->SetBinContent(ibin,0);
560 hSpectra[kTOF][kProton][icharge]->SetBinError (ibin,0);
561 }
4c0d7bc7 562 }
563 }
564// cout << "Scaling TOF to TPC" << endl;
565// // Scale protons to TPC
566// hSpectra[kTOF][kProton][kPos]->Scale(1./1.05);
567// // Scale pbar so that pbar/p is compatible with Panos
568// hSpectra[kTOF][kProton][kNeg]->Scale(1./1.1);
569
3725266c 570 // TOF: systematics
571 // Load TOF systematic errors:
572 f = new TFile ("./Files/systMatchingPos.root");
573 AliBWTools::AddHisto(hSystError[kTOF][kPion][kPos] ,(TH1*)gDirectory->Get("hErrPionMatch") );
574 AliBWTools::AddHisto(hSystError[kTOF][kProton][kPos],(TH1*)gDirectory->Get("hErrProtonMatch"));
575 AliBWTools::AddHisto(hSystError[kTOF][kKaon][kPos] ,(TH1*)gDirectory->Get("hErrKaonMatch") );
576 f = new TFile ("./Files/systMatchingNeg.root");
577 AliBWTools::AddHisto(hSystError[kTOF][kPion] [kNeg],(TH1*)gDirectory->Get("hErrPionMatch"));
578 AliBWTools::AddHisto(hSystError[kTOF][kProton][kNeg],(TH1*)gDirectory->Get("hErrProtonMatch"));
579 AliBWTools::AddHisto(hSystError[kTOF][kKaon] [kNeg],(TH1*)gDirectory->Get("hErrKaonMatch"));
580 f = new TFile ("./Files/systPIDall.root");
581 AliBWTools::AddHisto(hSystError[kTOF][kPion] [kPos],(TH1*)gDirectory->Get("hpiCorr"));
582 AliBWTools::AddHisto(hSystError[kTOF][kProton][kPos],(TH1*)gDirectory->Get("hpCorr"));
583 AliBWTools::AddHisto(hSystError[kTOF][kKaon] [kPos],(TH1*)gDirectory->Get("hkCorr"));
584 AliBWTools::AddHisto(hSystError[kTOF][kPion] [kNeg],(TH1*)gDirectory->Get("hpiCorr"));
585 AliBWTools::AddHisto(hSystError[kTOF][kProton][kNeg],(TH1*)gDirectory->Get("hpCorr"));
586 AliBWTools::AddHisto(hSystError[kTOF][kKaon] [kNeg],(TH1*)gDirectory->Get("hkCorr"));
4c0d7bc7 587
588
5f2ca1e6 589 // ITS SA
2210b002 590 f = new TFile("./Files/ITSsaSpectraCorr-28Sep10.root");
4c0d7bc7 591 hSpectra[kITS][kPion] [kPos]= (TH1F*) f->Get("hSpectraPos0");
592 hSpectra[kITS][kKaon] [kPos]= (TH1F*) f->Get("hSpectraPos1");
593 hSpectra[kITS][kProton][kPos]= (TH1F*) f->Get("hSpectraPos2");
594 hSpectra[kITS][kPion] [kNeg]= (TH1F*) f->Get("hSpectraNeg0");
595 hSpectra[kITS][kKaon] [kNeg]= (TH1F*) f->Get("hSpectraNeg1");
596 hSpectra[kITS][kProton][kNeg]= (TH1F*) f->Get("hSpectraNeg2");
597
4d4a268c 598 // Remove unwanted bins
4c0d7bc7 599 for(Int_t ipart = 0; ipart < kNPart; ipart++){
600 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
2210b002 601 Int_t nbinITS = hSpectra[kITS][ipart][icharge]->GetNbinsX();
602 for(Int_t ibin = 1; ibin <= nbinITS; ibin++){
4c0d7bc7 603 if(hSpectra[kITS][ipart][icharge]->GetBinContent(ibin) < 0 ) {
604 hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
605 hSpectra[kITS][ipart][icharge]->SetBinError (ibin,0);
606 }
5f2ca1e6 607 if(ipart == kProton && ibin==9){
608 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));
609 hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
610 hSpectra[kITS][ipart][icharge]->SetBinError (ibin,0);
611 }
4c0d7bc7 612// if ((ipart == kKaon && ibin >= 12) || (ipart == kProton && ibin >= 20)) {
613// hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
614// hSpectra[kITS][ipart][icharge]->SetBinError (ibin,0);
615// }
616 }
617
618 }
619 }
620
eea641de 621 if(useSecCorrFromDCA){
77233d47 622 TFile* fseccorr = new TFile("./Files/CorrFac-SecProtons3Meth-ITSsa.root");
623 TH1F* hcorrp=(TH1F*)fseccorr->Get("hSecPCorrFromDCAexpo");
624 TH1F* hcorrpbar=(TH1F*)fseccorr->Get("hSecPbarCorrFromDCAexpo");
eea641de 625 hSpectra[kITS][kProton][kPos]->Multiply(hcorrp);
626 hSpectra[kITS][kProton][kNeg]->Multiply(hcorrpbar);
627 fseccorr->Close();
628 }
4c0d7bc7 629
3725266c 630 // Load ITS sa systematics, only pt dependent ones
4d4a268c 631 // f = TFile::Open("./Files/ITSsa-systematics_20100930.root");
632 f = TFile::Open("./Files/ITSsa-systematics-20101014.root");
3725266c 633 for(Int_t ipart = 0; ipart < kNPart; ipart++){
634 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
635 AliBWTools::AddHisto(hSystError[kITS][ipart][icharge], (TH1*) gDirectory->Get(Form("hSystTot%s%s",chargeFlag[icharge],partFlag[ipart]))); // Using total error
636 }
637 }
638
4c0d7bc7 639 // ITS + TPC (Marek)
0e019ec6 640 //f = TFile::Open("./Files/SpectraCorrectedITSBeforeProtons20100720.root");
5b103cfc 641 f = TFile::Open("./Files/SpectraCorrectedITSBeforeProtons14092010new.root");
4c0d7bc7 642 TList * list = (TList*) gDirectory->Get("output");
643 hSpectra[kITSTPC][kPion] [kPos]= (TH1F*) list->FindObject("Pions");
644 hSpectra[kITSTPC][kKaon] [kPos]= (TH1F*) list->FindObject("Kaons");
645 hSpectra[kITSTPC][kProton][kPos]= (TH1F*) list->FindObject("Protons");
646 hSpectra[kITSTPC][kPion] [kNeg]= (TH1F*) list->FindObject("AntiPions");
647 hSpectra[kITSTPC][kKaon] [kNeg]= (TH1F*) list->FindObject("AntiKaons");
648 hSpectra[kITSTPC][kProton][kNeg]= (TH1F*) list->FindObject("AntiProtons");
649
650 // TPC
4c0d7bc7 651 f = new TFile("./Files/protonSpectra_20100615.root");
652 hSpectra[kTPC][kProton][kPos]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("protonPosClassic"),htemplate);
653 hSpectra[kTPC][kProton][kNeg]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("protonNegClassic"),htemplate);
654 f = new TFile("./Files/pionSpectra_20100615.root");
655 hSpectra[kTPC][kPion][kPos]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("pionPosClassic"),htemplate);
656 hSpectra[kTPC][kPion][kNeg]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("pionNegClassic"),htemplate);
5b103cfc 657 // f = new TFile("./Files/kaonSpectra_20100615.root");
658 f = new TFile("./Files/kaonsTPCcorr_2010_08_31.root");
4c0d7bc7 659 hSpectra[kTPC][kKaon][kPos]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("kaonPosClassic"),htemplate);
660 hSpectra[kTPC][kKaon][kNeg]= AliBWTools::GetHistoFromGraph((TGraphErrors*)f->Get("kaonNegClassic"),htemplate);
661
662 // Clean UP TPC spectra, removing unwanted points
663 cout << "Cleaning Up TPC spectra" << endl;
664 nbin = hSpectra[kTPC][kKaon][kPos]->GetNbinsX();
665 for(Int_t ibin = 0; ibin < nbin; ibin++){
666 Float_t pt = hSpectra[kTPC][kKaon][kPos]->GetBinCenter(ibin);
5f2ca1e6 667 if (pt > 0.45){ // || pt<0.25) {
4c0d7bc7 668 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
669 hSpectra[kTPC][kKaon][icharge]->SetBinContent(ibin,0);
670 hSpectra[kTPC][kKaon][icharge]->SetBinError (ibin,0);
671 }
672 }
0e019ec6 673 if (pt < 0.25) {
674 hSpectra[kTPC][kKaon][kNeg]->SetBinContent(ibin,0);
675 hSpectra[kTPC][kKaon][kNeg]->SetBinError (ibin,0);
676 }
4c0d7bc7 677 if (pt < 0.45) {
678 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
679 hSpectra[kTPC][kProton][icharge]->SetBinContent(ibin,0);
680 hSpectra[kTPC][kProton][icharge]->SetBinError (ibin,0);
681 }
682 }
683 }
684
3725266c 685 // Load TPC systematics
686 cout << "WARNING: TPC SYST FOR NEGATIVES TO BE CORRECTED" << endl;
687 f = TFile ::Open("./Files/pionsSystSum.root");
688 AliBWTools::AddHisto(hSystError[kTPC][kPion][kPos],(TH1*) gDirectory->Get("pionsSyst"));
689 AliBWTools::AddHisto(hSystError[kTPC][kPion][kNeg],(TH1*) gDirectory->Get("pionsSyst"));
690 f = TFile ::Open("./Files/kaonsSystSum.root");
691 AliBWTools::AddHisto(hSystError[kTPC][kKaon][kPos],(TH1*) gDirectory->Get("kaonsSyst"));
692 AliBWTools::AddHisto(hSystError[kTPC][kKaon][kNeg],(TH1*) gDirectory->Get("kaonsSyst"));
693 f = TFile ::Open("./Files/ProtonsSystSum.root");
694 AliBWTools::AddHisto(hSystError[kTPC][kProton][kPos],(TH1*) gDirectory->Get("ProtonsSyst"));
695 AliBWTools::AddHisto(hSystError[kTPC][kProton][kNeg],(TH1*) gDirectory->Get("ProtonsSyst"));
696
4c0d7bc7 697 // K0s
49ad829f 698 f = new TFile ("./Files/PtSpectraCorrectedK0sOff_20100803.root");
4c0d7bc7 699 // hSpectra[kK0][kKaon][kPos] = (TH1F*) AliBWTools::GetdNdPtFromOneOverPt((TH1*) gDirectory->Get("hSpectraOff"));
700 hSpectra[kK0][kKaon][kPos] = (TH1F*) gDirectory->Get("hSpectraOff");
701 // hSpectra[kK0][kKaon][kPos]->Scale(2*TMath::Pi());
702 // hSpectra[kK0][kKaon][kPos]->Scale(1./272463);
703 hSpectra[kK0][kKaon][kNeg] = hSpectra[kK0][kKaon][kPos];
704
49ad829f 705 // Kinks
4c0d7bc7 706 // f = new TFile ("./Files/PtAllKaonKinkRap6Apr24.root");
49ad829f 707 // f = new TFile ("./Files/PtKaonKinkJune13AllPN_20100615.root");
22abbb27 708 // f = new TFile ("./Files/KaonKinkJun16PhySel2N.root");
709 f = new TFile ("./Files/KaonKinkJun16PhySel2NRebPass6.root");
4c0d7bc7 710 hSpectra[kKinks][kKaon][kPos] = (TH1F*)gDirectory->Get("fptallKPA");
711 hSpectra[kKinks][kKaon][kNeg] = (TH1F*)gDirectory->Get("fptallKNA");
49ad829f 712 // hSpectra[kKinks][kKaon][kPos]->Scale(0.5/0.7); // different rapidity range for kinks
713 // hSpectra[kKinks][kKaon][kNeg]->Scale(0.5/0.7); // different rapidity range for kinks
714 // hSpectra[kKinks][kKaon][kPos]->Scale(276004./263345.); // different N of events
715 // hSpectra[kKinks][kKaon][kNeg]->Scale(276004./263345.); // different N of events
22abbb27 716 // This normalization if for KaonKinkJun16PhySel2N
717 // hSpectra[kKinks][kKaon][kPos]->Scale(1./303214); // different N of events
718 // hSpectra[kKinks][kKaon][kNeg]->Scale(1./303214); // different N of events
719 // This normalization is for KaonKinkJun16PhySel2NRebPass6
720 hSpectra[kKinks][kKaon][kPos]->Scale(1./260432.26); // different N of events
721 hSpectra[kKinks][kKaon][kNeg]->Scale(1./260432.26); // different N of events
4c0d7bc7 722
5f2ca1e6 723 // Apply correction factors
4c0d7bc7 724 // Secondaries for protons
5f2ca1e6 725
0e019ec6 726 //f = new TFile ("./Files/corrFactorProtons_20100615.root");
2210b002 727 f = new TFile ("./Files/corrFactorProtons_2010_09_24.root");
4c0d7bc7 728 TH1F * hCorrSecondaries = (TH1F*) gDirectory->Get("corrFactorProtons");
729 if(correctSecondaries) {
730 cout << "CORRECTING SECONDARIES" << endl;
731
732 for(Int_t idet = 0; idet <= kTOF; idet++){ // TPC and TOF only
733 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
734 Int_t ipart = kProton;
735 TH1* h = hSpectra[idet][ipart][icharge]; // lighter notation below
736 if (h){
737 Int_t nbins = h->GetNbinsX();
738 for(Int_t ibin = 0; ibin < nbins; ibin++){
739 // Float_t pt = convertToMT ? TMath::Sqrt(h->GetBinCenter(ibin)*h->GetBinCenter(ibin)-mass[kProton]*mass[kProton]) : h->GetBinCenter(ibin);
740 Float_t pt = h->GetBinCenter(ibin);
741 if (icharge == kNeg) pt = -pt;
742 Int_t binCorrection = hCorrSecondaries->FindBin(pt);
743 Float_t correction = hCorrSecondaries->GetBinContent(binCorrection);
744 // cout << pt << " " << correction << endl;
745
c4fe358b 746 if (correction) {// If the bin is empty this is a 0
4c0d7bc7 747 h->SetBinContent(ibin,h->GetBinContent(ibin)/correction);
748 h->SetBinError (ibin,h->GetBinError (ibin)/correction);
749 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
750 cout << "Not correcting bin "<<ibin << " for protons secondaries, " << detFlag[idet] << " " << chargeFlag[icharge] << endl;
751 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
752
753 }
754 }
755 }
756 }
757 }
758 }
759 // geant/fluka absorption
760 if(correctGeantFlukaXS) {
761 cout << "CORRECTING GEANT3/FLUKA" << endl;
eea641de 762 // common file for Kaons
763 TFile *fFlukakaons = TFile::Open("./Files/correctionForCrossSection.321.root");
764 TH1D * hCorrFlukakaon[kNCharge];
765 hCorrFlukakaon[kPos] = (TH1D*)fFlukakaons->Get("gHistCorrectionForCrossSectionParticles");
766 hCorrFlukakaon[kNeg] = (TH1D*)fFlukakaons->Get("gHistCorrectionForCrossSectionAntiParticles");
767
768 for(Int_t idet = 0; idet < kNDet; idet++){
769 if( idet != kITS) continue; // comment to use fluka for kaons for all dets
770 if (idet == kTOF) continue; // TOF already corrected
771 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
772 Int_t ipart = kKaon;
2f7f947e 773 TH1 * h = hSpectra[idet][ipart][icharge]; // only ITS sa
eea641de 774 if (h){
775 Int_t nbins = h->GetNbinsX();
776 Int_t nbinsy=hCorrFlukakaon[icharge]->GetNbinsY();
777 for(Int_t ibin = 0; ibin < nbins; ibin++){
778 Float_t pt = h->GetBinCenter(ibin);
779 Float_t minPtCorrection = hCorrFlukakaon[icharge]->GetXaxis()->GetBinLowEdge(1);
780 Float_t maxPtCorrection = hCorrFlukakaon[icharge]->GetXaxis()->GetBinLowEdge(nbinsy+1);
781 if (pt < minPtCorrection) pt = minPtCorrection+0.0001;
782 if (pt > maxPtCorrection) pt = maxPtCorrection;
783 Float_t correction = hCorrFlukakaon[icharge]->GetBinContent(hCorrFlukakaon[icharge]->GetXaxis()->FindBin(pt));
784 if (correction != 0) {// If the bin is empty this is a 0
785 h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
786 h->SetBinError (ibin,h->GetBinError (ibin)*correction);
787 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
788 cout << "Fluka/GEANT: Not correcting bin "<<ibin << " for protons secondaries, ITS, " << chargeFlag[icharge] << endl;
789 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
790 }
791 }
792 }
793 }
794 }
795
2f7f947e 796 // PROTONS
797
eea641de 798 // ITS specific file for protons/antiprotons
5f2ca1e6 799 TFile* fITS = new TFile ("./Files/correctionForCrossSectionITS_20100719.root");
800 TH2D * hCorrFlukaITS[kNCharge];
801 hCorrFlukaITS[kPos] = (TH2D*)fITS->Get("gHistCorrectionForCrossSectionProtons");
802 hCorrFlukaITS[kNeg] = (TH2D*)fITS->Get("gHistCorrectionForCrossSectionAntiProtons");
803
804 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
805 Int_t ipart = kProton;
806 TH1 * h = hSpectra[kITS][ipart][icharge]; // only ITS sa
807 if (h){
808 Int_t nbins = h->GetNbinsX();
809 Int_t nbinsy=hCorrFlukaITS[icharge]->GetNbinsY();
810 for(Int_t ibin = 0; ibin < nbins; ibin++){
811 Float_t pt = h->GetBinCenter(ibin);
812 Float_t minPtCorrection = hCorrFlukaITS[icharge]->GetYaxis()->GetBinLowEdge(1);
813 Float_t maxPtCorrection = hCorrFlukaITS[icharge]->GetYaxis()->GetBinLowEdge(nbinsy+1);
814 if (pt < minPtCorrection) pt = minPtCorrection+0.0001;
815 if (pt > maxPtCorrection) pt = maxPtCorrection;
816 Float_t correction = hCorrFlukaITS[icharge]->GetBinContent(1,hCorrFlukaITS[icharge]->GetYaxis()->FindBin(pt));
817 if (correction != 0) {// If the bin is empty this is a 0
818 h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
819 h->SetBinError (ibin,h->GetBinError (ibin)*correction);
820 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
821 cout << "Fluka/GEANT: Not correcting bin "<<ibin << " for protons secondaries, ITS, " << chargeFlag[icharge] << endl;
822 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
823 }
824 }
825 }
826 }
827
4c0d7bc7 828
77233d47 829
830 //f = new TFile ("./Files/correctionForCrossSection_20100615.root");
831 f = new TFile ("./Files/correctionForCrossSection_20100920.root");
4c0d7bc7 832 TH2D * hCorrFluka[kNCharge];
833 hCorrFluka[kPos] = (TH2D*)gDirectory->Get("gHistCorrectionForCrossSectionProtons");
834 hCorrFluka[kNeg] = (TH2D*)gDirectory->Get("gHistCorrectionForCrossSectionAntiProtons");
835 for(Int_t idet = 0; idet < kNDet; idet++){
836 if (idet == kITS) continue; // skip ITS sa
837 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
838 Int_t ipart = kProton;
839 TH1 * h = hSpectra[idet][ipart][icharge]; // lighter notation below
840 if (h){
841 Int_t nbins = h->GetNbinsX();
842 for(Int_t ibin = 0; ibin < nbins; ibin++){
843// Float_t pt = convertToMT ?
844// TMath::Sqrt(h->GetBinCenter(ibin)*h->GetBinCenter(ibin)-mass[kProton]*mass[kProton]) :
845// h->GetBinCenter(ibin);
846 Float_t pt = h->GetBinCenter(ibin);
847 Float_t minPtCorrection = hCorrFluka[icharge]->GetYaxis()->GetBinLowEdge(1);
2210b002 848 // hCorrFluka[icharge]->Draw();
849 TH1D * htmpFluka=hCorrFluka[icharge]->ProjectionY();
850 Float_t maxPtCorrection = AliBWTools::GetHighestNotEmptyBinEdge(htmpFluka);//->GetYaxis()->GetBinLowEdge(hCorrFluka[icharge]->GetNbinsY()+1);
4c0d7bc7 851 if (pt < minPtCorrection) pt = minPtCorrection+0.0001;
2210b002 852 if (pt > maxPtCorrection) pt = maxPtCorrection-0.0001;
4c0d7bc7 853 Float_t correction = hCorrFluka[icharge]->GetBinContent(1,hCorrFluka[icharge]->GetYaxis()->FindBin(pt));
77233d47 854
5f2ca1e6 855 // already in the efficiency correction (F. Noferini)
2f7f947e 856 if (idet == kTOF) {
49ad829f 857 if (icharge == kNeg) correction = 1; // antiprotons already corrected in efficiency
858 // Scale correction for the different material budget. Recipe by Francesco Noferini
2210b002 859 else {
860 correction = TMath::Power(correction,0.07162/0.03471);
861 }
49ad829f 862 }
4c0d7bc7 863 if (correction != 0) {// If the bin is empty this is a 0
77233d47 864
4c0d7bc7 865 h->SetBinContent(ibin,h->GetBinContent(ibin)*correction);
866 h->SetBinError (ibin,h->GetBinError (ibin)*correction);
4c0d7bc7 867 } else if (h->GetBinContent(ibin) > 0) { // If we are skipping a non-empty bin, we notify the user
868 cout << "Fluka/GEANT: Not correcting bin "<<ibin << " for protons secondaries, " << detFlag[idet] << " " << chargeFlag[icharge] << endl;
869 cout << " Bin content: " << h->GetBinContent(ibin) << endl;
870 }
871
872 }
873
874 }
875 }
876 }
877 }
878
879
880 // Set style and scale
881 for(Int_t idet = 0; idet < kNDet; idet++){
882 for(Int_t ipart = 0; ipart < kNPart; ipart++){
883 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
884 if (hSpectra[idet][ipart][icharge]){
885 hSpectra[idet][ipart][icharge]->SetStats(0); // disable stats
886 hSpectra[idet][ipart][icharge]->SetMarkerColor (color[ipart] );
887 hSpectra[idet][ipart][icharge]->SetLineColor (color[ipart] );
888 hSpectra[idet][ipart][icharge]->SetMarkerStyle (marker[ipart]);
889 hSpectra[idet][ipart][icharge]->SetXTitle("p_{t} (GeV/c)");
890 hSpectra[idet][ipart][icharge]->SetYTitle("1/N_{ev} dN/dp_{t} (GeV/c)^{-1}");
891 if (convertToMT) {
892 TH1F * htmp = (TH1F*) AliBWTools::GetOneOverPtdNdPt(hSpectra[idet][ipart][icharge]);
893 hSpectra[idet][ipart][icharge] = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
894 hSpectra[idet][ipart][icharge]->SetXTitle("m_{t} (GeV)");
895 hSpectra[idet][ipart][icharge]->SetYTitle("1/N_{ev} 1/m_{t} dN/dp_{t} (GeV)^{-1}");
896 }
897// if (idet == kTOF || idet == kTPC) {
898// hSpectra[idet][ipart][icharge]->Scale(1./236763);
899// }
900// if (idet == kITS){
901// hSpectra[idet][ipart][icharge]->Scale(202945./236763);
902// }
903 if (scaleKaons && ipart == kKaon) {
904 hSpectra[idet][ipart][icharge]->Scale(2.);
905 }
906 } else {
907 printf("Cannot load %s,%s,%s\n",detFlag[idet],partFlag[ipart],chargeFlag[icharge]);
908 }
909 }
910 }
911 }
912
ee08b77d 913
914 // Create fake weights for the mean; To be update once we have syst errors
2f7f947e 915 // Using syste from table in paper. It would be better to have this as a function of pt.
916 TH1F * hWeights[3][kNPart];
917 const Double_t kWeights[3][kNPart] =
3725266c 918 // {{4, 3, 10.2}, // TPC
919 // {4.1,8.8,7.0 }, //TOF
920 // {4.5,5.6,7.0 }}; // ITS
921 {{0.1,0.1,0.1}, // TPC
922 {0.1,0.1,0.1}, //TOF
923 {0.1,0.1,0.1}}; // ITS
2f7f947e 924 for(Int_t ipart = 0; ipart <= kNPart ; ipart++){
925 for(Int_t idet = 0; idet <= kITS ; idet++){
926 hWeights[idet][ipart] = (TH1F*) hSpectra[idet][ipart][kPos]->Clone();
2210b002 927 Int_t nbinW = hWeights[idet][ipart]->GetNbinsX();
928 for(Int_t ibin = 1; ibin <= nbinW; ibin++){
2f7f947e 929 hWeights[idet][ipart]->SetBinError(ibin, kWeights[idet][ipart]);
930 }
931 }
ee08b77d 932 }
49ad829f 933 const Double_t scaleDet[] = {1.00,1.00,1.00}; // During the weekly meeting 19/08/2010 we decided not to apply any scaling.
934 // const Double_t scaleDet[] = {0.98,1,1.00}; // Scaling factor for the different detectors. Estimated from ratios, it has an estimated uncertainty of ~2%
2f7f947e 935 // 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%
ee08b77d 936
937
4c0d7bc7 938 // Combine detectors
939 for(Int_t ipart = 0; ipart < kNPart; ipart++){
940 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
941 TH1F * htemplLocal = htemplate; // If we are converting to 1/mt dNdmt we need to convert the template as well...
942
943 if (convertToMT) {
944 TH1F * htmp = (TH1F*) AliBWTools::GetOneOverPtdNdPt(htemplate);
945 htemplLocal = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
946
947 }
948 hSpectra[kCombTOFTPC][ipart][icharge] = AliBWTools::CombineHistos(hSpectra[kTOF][ipart][icharge],
949 hSpectra[kTPC][ipart][icharge],
950 htemplLocal,1.);;
3725266c 951
ee08b77d 952 hSpectra[kCombAll][ipart][icharge] =
3725266c 953 AliBWTools::Combine3HistosWithErrors(hSpectra[kITS][ipart][icharge], // Histos to combine
ee08b77d 954 hSpectra[kTPC][ipart][icharge],
955 hSpectra[kTOF][ipart][icharge],
3725266c 956 hSystError[kITS][ipart][icharge], // Errors (weights) used for the average
957 hSystError[kTPC][ipart][icharge],
958 hSystError[kTOF][ipart][icharge],
959 // hWeights[kITS][ipart],
960 // hWeights[kTPC][ipart],
961 // hWeights[kTOF][ipart],
962 htemplLocal,1, // template, take statistical error from TPC in overlap
963 scaleDet[kITS], // relative scaling
2f7f947e 964 scaleDet[kTPC],
3725266c 965 scaleDet[kTOF],
966 (TH1**)&hSystError[kCombAll][ipart][icharge], // put combined syst error here
967 1 // weights histos contain error in bin content
2f7f947e 968 );
4c0d7bc7 969// if (convertToMT) {
970// TH1F * htmp = (TH1F*) AliBWTools::GetOneOverPtdNdPt(hSpectra[kCombTOFTPC][ipart][icharge]);
971// hSpectra[kCombTOFTPC][ipart][icharge] = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
972// hSpectra[kCombTOFTPC][ipart][icharge]->SetXTitle("m_{t} (GeV)");
973// hSpectra[kCombTOFTPC][ipart][icharge]->SetYTitle("1/N_{ev} 1/m_{t} dN/dp_{t} (GeV)^{-1}");
974// }
975 }
976 }
977
978
979 // Scale for the number of inelastic collisions and correct for
980 // efficiency losses due to physics selection:
981
982 Double_t effPhysSel[kNPart];
983 effPhysSel[kPion] = 1.012;
984 effPhysSel[kKaon] = 1.013;
985 effPhysSel[kProton] = 1.014;
986
987
988 for(Int_t idet = 0; idet < kNHist; idet++){
989 for(Int_t ipart = 0; ipart < kNPart; ipart++){
990 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
991 if(hSpectra[idet][ipart][icharge]) {
992 // cout << "Scaling!" << endl;
49ad829f 993 if(idet != kKinks && idet != kK0){ // Kinks use a different run list, k0s normalized by Helene
4d4a268c 994 hSpectra[idet][ipart][icharge]->Scale(1.*effPhysSel[ipart]/278366.15); // Scale PhysSel efficiency (computed by Alexander)
5f2ca1e6 995 }
4c0d7bc7 996 }
997 }
998 }
999 }
1000
1001
1002}
1003
1004void LoadMC() {
1005
1006 TFile * f = 0;
1007 const char * evClass= "INEL";
1008 const char * files[] = {"./Files/dndeta_Phojet_10M_900GeV.root",
1009 "./Files/dndeta_AtlasCSC306_10M_900GeV.root",
1010 "./Files/dndeta_CMSD6T109_10M_900GeV.root",
1011 "./Files/dndeta_Perugia0320_10M_900GeV.root", };
1012
1013 // Phojet
1014 for(Int_t itune = 0; itune < kNTunes; itune++){
1015 f = new TFile(files[itune]);
1016 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1017 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1018 hSpectraMC[itune][ipart][icharge] = (TH1F*) f->Get(Form("fHistPtID_%s_%s%s",evClass,partFlag[ipart],icharge==0 ? "Pos" : "Neg"));
1019 }
1020 }
1021 }
1022
1023
1024 // Set style
1025 for(Int_t itune = 0; itune < kNTunes; itune++){
1026 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1027 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1028 if (hSpectraMC[itune][ipart][icharge]){
1029 hSpectraMC[itune][ipart][icharge]->SetName(TString(hSpectraMC[itune][ipart][icharge]->GetName())+mcTuneName[itune]);
1030 hSpectraMC[itune][ipart][icharge]->SetMarkerColor (mcLineColor[itune] );
1031 hSpectraMC[itune][ipart][icharge]->SetLineColor (mcLineColor[itune] );
1032 hSpectraMC[itune][ipart][icharge]->SetLineStyle (mcLineStyle[itune] );
1033 hSpectraMC[itune][ipart][icharge]->SetMarkerStyle (1);
1034 if (convertToMT) {
1035 TH1F * htmp = (TH1F*)AliBWTools::GetOneOverPtdNdPt(hSpectraMC[itune][ipart][icharge]);
1036 hSpectraMC[itune][ipart][icharge] = (TH1F*)AliBWTools::GetdNdmtFromdNdpt(htmp,mass[ipart]);
1037 hSpectraMC[itune][ipart][icharge]->SetXTitle("m_{t} (GeV)");
1038 hSpectraMC[itune][ipart][icharge]->SetYTitle("1/N_{ev} 1/m_{t} dN/dp_{t} (GeV)^{-1}");
1039 }
1040
1041 } else {
1042 printf("Cannot load MC # %d,%s,%s\n",itune,partFlag[ipart],chargeFlag[icharge]);
1043 }
1044 }
1045 }
1046 }
1047
1048}
1049
1050void DrawStar(Int_t icharge) {
1051 // cout << icharge << endl;
1052
1053 // gROOT->LoadMacro("StarPPSpectra.C");
1054 TGraphErrors ** gStar = StarPPSpectra();
1055
1056 for(Int_t istar = 0; istar < 6; istar++){
1057 gStar[istar]->SetMarkerStyle(kOpenStar);
1058 if (icharge==kPos && (istar%2) ) gStar[istar]->Draw("P");
1059 else if (icharge==kNeg && !(istar%2) ) gStar[istar]->Draw("P");
1060 else cout << "Skipping Star " << istar << endl;
1061 }
1062}
1063
1064void GetITSResiduals() {
1065
1066
1067 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1068 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1069 // cout << "1 " << ipart << " " << icharge << endl;
1070
1071// gSystem->ProcessEvents();
1072// gSystem->Sleep(1000);
1073 TF1* f = (TF1*) hSpectra[kCombTOFTPC][ipart][icharge]->GetListOfFunctions()->At(0);
1074 TH1F * hres1, *hres2;
1075 AliBWTools::GetResiduals(hSpectra[kITS][ipart][icharge], f, &hres1, &hres2);
1076
1077 TCanvas * c1 = new TCanvas(TString(partFlag[ipart])+"_"+chargeFlag[icharge],TString(partFlag[ipart])+"_"+chargeFlag[icharge]);
1078 c1->SetLogy();
1079 hSpectra[kCombTOFTPC][ipart][icharge]->Draw();
1080 hSpectra[kITS][ipart][icharge]->SetMarkerStyle(24);
1081 hSpectra[kCombTOFTPC][ipart][icharge]->SetMarkerStyle(20);
1082 hSpectra[kITS][ipart][icharge]->Draw("same");
1083 hSpectra[kCombTOFTPC][ipart][icharge]->GetListOfFunctions()->At(0)->Draw("same");
1084 TLegend* l = new TLegend( 0.182886, 0.192308, 0.505034,0.384615, TString(partLabel[ipart][icharge])+" "+chargeFlag[icharge]);
1085 l->AddEntry(hSpectra[kCombTOFTPC][ipart][icharge], "TOF+TPC");
1086 l->AddEntry(hSpectra[kITS][ipart][icharge], "ITS");
1087 l->AddEntry(f, "Fit to TOF+TPC");
1088 l->Draw();
1089
1090 TCanvas * c2 = new TCanvas(TString(partFlag[ipart])+"_"+chargeFlag[icharge]+"_res",
1091 TString(partFlag[ipart])+"_"+chargeFlag[icharge]+"_res");
1092 c2->SetGridy();
1093 hres2->SetMinimum(-1);
1094 hres2->SetMaximum(1);
1095 hres2->Draw();
1096 hres2->GetYaxis()->SetTitleOffset(1.2);
1097 Float_t x = AliBWTools::GetLowestNotEmptyBinEdge(hSpectra[kCombTOFTPC][ipart][icharge]);
1098 TLine * line = new TLine(x,-1,x,1);
1099 line->SetLineStyle(kDashed);
1100 line->Draw("same");
1101
1102 if (doPrint) {
1103 c1->Update();
1104 c2->Update();
1105 gSystem->ProcessEvents();
1106 c1->Print(TString(c1->GetName()) + ".png");
1107 c2->Print(TString(c2->GetName()) + ".png");
1108 }
1109 }
1110 }
1111}
1112
1113void DrawWithModels() {
1114
4d4a268c 1115 Int_t chargeLoop = sumCharge ? 1 : 2;
1116 for(Int_t icharge = 0; icharge < chargeLoop; icharge++){
4c0d7bc7 1117
1118 // Draw with models
1119 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1120 // Multipad canvas
4d4a268c 1121 TString chargeFlagLocal = chargeFlag[icharge];
1122 if(sumCharge) chargeFlagLocal += chargeFlag[1];
1123 TCanvas * c1 = new TCanvas(TString("cSpectra")+partFlag[ipart]+chargeFlagLocal,TString("cSpectra")+partFlag[ipart]+chargeFlagLocal,700,700);
1124 TPad *p1 = new TPad(TString("p1")+partFlag[ipart]+chargeFlagLocal, "p1", 0.0, 0.35, 1.0, 0.95, 0, 0, 0);
4c0d7bc7 1125 p1->SetBottomMargin(0);
1126 p1->Draw();
1127
4d4a268c 1128 TPad *p2 = new TPad(TString("p2")+partFlag[ipart]+chargeFlagLocal, "p2", 0.0, 0.05, 1.0, 0.35, 0, 0, 0);
4c0d7bc7 1129 p2->SetTopMargin(0);
5f2ca1e6 1130 p2->SetBottomMargin(0.3);
4c0d7bc7 1131 p2->Draw();
1132
1133 Float_t scaleFonts = (0.95-0.3)/(0.3-0.05);
1134
1135 // Draw spectra
1136 p1->cd();
1137 p1->SetLogy();
4d4a268c 1138 Float_t maxy = sumCharge ? 10 : 5;
1139 TH2F * hempty = new TH2F(TString("hempty")+long(icharge)+long(ipart),"hempty",100,0.,3, 100, 0.0015,maxy);
4c0d7bc7 1140 hempty->SetXTitle("p_{t} (GeV/c)");
1141 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
1142 hempty->Draw();
1143 c1->SetLogy();
d8e6677d 1144
4c0d7bc7 1145
1146
d8e6677d 1147 TLegend * l =new TLegend(0.502874, 0.493056, 0.892241, 0.904762);
4d4a268c 1148 l->SetFillColor(kWhite);
1149 if(sumCharge) {
1150 hSpectra[iCombInStudy][ipart][kPos]->Add(hSpectra[iCombInStudy][ipart][kNeg]); // Draw pos+neg
1151 }
ee08b77d 1152 hSpectra[iCombInStudy][ipart][icharge]->Draw("same");
d8e6677d 1153 l->AddEntry(hSpectra[kTOF][ipart][icharge],TString ("Data"));
4c0d7bc7 1154 for(Int_t itune = 0; itune < kNTunes; itune++){
4d4a268c 1155 if(sumCharge) hSpectraMC[itune][ipart][icharge]->Add(hSpectraMC[itune][ipart][kNeg]); // Draw pos+neg;
4c0d7bc7 1156 l->AddEntry(hSpectraMC[itune][ipart][icharge],mcTuneName[itune]);
1157 hSpectraMC[itune][ipart][icharge]->SetLineWidth(2);
d8e6677d 1158 AliBWTools::GetGraphFromHisto(hSpectraMC[itune][ipart][icharge])->Draw("CX");
4c0d7bc7 1159 }
1160 l->Draw("same");
d8e6677d 1161
4d4a268c 1162 TLatex * tex = new TLatex(0.6712643,2.353486,sumCharge ? Form("%s+%s",partLabel[ipart][icharge],partLabel[ipart][1]) : partLabel[ipart][icharge]);
d8e6677d 1163 tex->SetTextFont(42);
1164 tex->SetTextSize(0.07936508);
1165 tex->SetLineWidth(2);
1166 tex->Draw();
4c0d7bc7 1167
1168 // Draw ratio
1169 p2->cd();
4d4a268c 1170 Float_t maxyr = sumCharge ? 3.99 : 2.99;
1171 TH2F * hemptyr = new TH2F(TString("hemptyratio")+long(icharge)+long(ipart),"hempty",100,0.,3, 100, 0.01,maxyr);
4c0d7bc7 1172 hemptyr->SetXTitle("p_{t} (GeV/c)");
1173 hemptyr->SetYTitle("Data/MC");
1174 hemptyr->GetXaxis()->SetLabelSize(0.04*scaleFonts);
1175 hemptyr->GetYaxis()->SetLabelSize(0.04*scaleFonts);
1176 hemptyr->GetYaxis()->SetTitleSize(0.05*scaleFonts);
1177 hemptyr->GetYaxis()->SetTitleOffset(1.4/scaleFonts);
1178 hemptyr->GetXaxis()->SetTitleSize(0.05*scaleFonts);
d8e6677d 1179 hemptyr->GetXaxis()->SetTitleOffset(1.05);
4c0d7bc7 1180 hemptyr->SetTickLength(0.03*scaleFonts, "X");
1181 hemptyr->SetTickLength(0.02*scaleFonts, "Y");
1182 // hemptyr->GetXaxis()->SetTitleOffset(1.4/scaleFonts);
1183 hemptyr->GetYaxis()->SetNdivisions(5);
1184 hemptyr->Draw("");
1185
1186 AliBWFunc fm;
1187 for(Int_t itune = 0; itune < kNTunes; itune++){
1188 TF1* f = fm.GetHistoFunc(hSpectraMC[itune][ipart][icharge], TString("f")+mcTuneName[itune]);
1189
1190 // l->AddEntry(hSpectraMC[itune][ipart][icharge],mcTuneName[itune]);
ee08b77d 1191 TH1F* hRatio = AliBWTools::DivideHistoByFunc(hSpectra[iCombInStudy][ipart][icharge],f);
4c0d7bc7 1192 hRatio->SetLineStyle(hSpectraMC[itune][ipart][icharge]->GetLineStyle());
1193 hRatio->SetLineColor(hSpectraMC[itune][ipart][icharge]->GetLineColor());
1194 hRatio->SetLineWidth(hSpectraMC[itune][ipart][icharge]->GetLineWidth());
4d4a268c 1195 hRatio->SetMarkerStyle(0);
1196 hRatio->Draw("same");
1197 // AliBWTools::GetGraphFromHisto(hRatio)->Draw("CX");
4c0d7bc7 1198 }
1199
1200
1201 // print
4d4a268c 1202 PrintCanvas(c1,printFormats);
4c0d7bc7 1203 }
1204 }
1205
1206
1207
1208}
1209
1210void DrawAllAndKaons() {
1211
22abbb27 1212
4c0d7bc7 1213
1214 // gROOT->LoadMacro("ALICEWorkInProgress.C");
1215
eea641de 1216 // gStyle->SetOptFit(0);
1217 gStyle->SetStatX(0.9);
1218 gStyle->SetStatY(0.88);
1219 gStyle->SetStatW(0.4);
1220 gStyle->SetStatH(0.1);
4c0d7bc7 1221
ee08b77d 1222 TH1F * hKaonsAllTPCTOF = (TH1F*) hSpectra[iCombInStudy][kKaon][kPos]->Clone();
1223 hKaonsAllTPCTOF->Add(hSpectra[iCombInStudy][kKaon][kNeg]);
4c0d7bc7 1224
1225 TH1F * hK0Scaled = (TH1F*) hSpectra[kK0][kKaon][kPos]->Clone();
1226 hK0Scaled->Add(hSpectra[kK0][kKaon][kPos]);
1227
1228 hSpectra[kKinks][kKaon][kPos]->SetMarkerStyle(25);
5f2ca1e6 1229 hSpectra[kKinks][kKaon][kPos]->SetLineColor(4);
4c0d7bc7 1230 hSpectra[kKinks][kKaon][kPos]->SetStats(0);
1231 TH1F * hKinksAll = (TH1F*) hSpectra[kKinks][kKaon][kPos]->Clone();
1232 hKinksAll->Add(hSpectra[kKinks][kKaon][kNeg]);
1233
5f2ca1e6 1234 TCanvas * c1 = new TCanvas("cKaons","cKaons",700,700);
4c0d7bc7 1235 c1->SetLogy();
5f2ca1e6 1236 TH2F * hempty = new TH2F("hempty_allkaons","hempty",100,0.,3, 100, 1e-3,6);
4c0d7bc7 1237 hempty->SetXTitle("p_{t} (GeV/c)");
22abbb27 1238 // hempty->SetYTitle("dN / dp_{t} (A.U.)");
1239 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
4c0d7bc7 1240 hempty->Draw();
4c0d7bc7 1241 hK0Scaled->Draw("same");
5f2ca1e6 1242 hKaonsAllTPCTOF->Draw("same");
4c0d7bc7 1243 hKinksAll->Draw("same");
22abbb27 1244
4c0d7bc7 1245
22abbb27 1246 TLegend * leg = new TLegend(0.456897, 0.71875, 0.892241, 0.936012,NULL,"brNDC");
5f2ca1e6 1247 // leg->SetBorderSize(0);
4c0d7bc7 1248// leg->SetLineColor(1);
1249// leg->SetLineStyle(1);
1250// leg->SetLineWidth(1);
1251// leg->SetFillColor(19);
5f2ca1e6 1252 leg->SetFillColor(0);
1253 TLegendEntry *entry=leg->AddEntry(hKaonsAllTPCTOF,"K^{+} + K^{-}, ITS+TPC+TOF ","lpf");
1254 entry=leg->AddEntry(hK0Scaled,"K^{0} #times 2","lpf");
1255 entry=leg->AddEntry(hKinksAll,"K^{+} + K ^{-}, Kinks","lpf");
4c0d7bc7 1256 leg->Draw();
1257
22abbb27 1258 // ALICEWorkInProgress(c1,today.Data(),"#splitline{ALICE Prelimiary}{Statistical Error Only}");
49ad829f 1259 // TLatex * tex = new TLatex(0.2120805,0.01288336,"Statistical error only");
1260 // tex->SetTextColor(2);
1261 // tex->SetTextFont(42);
1262 // tex->SetTextSize(0.03496503);
1263 // tex->Draw();
4c0d7bc7 1264
1265 c1->Update();
22abbb27 1266 PrintCanvas(c1, printFormats);
4c0d7bc7 1267
1268 // Draw all "stable" hadrons
1269 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
2210b002 1270 TCanvas * c1h = new TCanvas(TString("cAll_")+chargeFlag[icharge],TString("cAll_")+chargeFlag[icharge],700,700);
1271 c1h->SetLogy();
1272 c1h->SetLeftMargin(0.14);
1273 TH2F * hemptyLoc = new TH2F(TString("hempty")+long(icharge),"hempty",100,0.,4, 100, 1e-3,10);
1274 hemptyLoc->SetXTitle("p_{t} (GeV/c)");
1275 hemptyLoc->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
1276 hemptyLoc->GetYaxis()->SetTitleOffset(1.35);
1277 hemptyLoc->GetXaxis()->SetTitleOffset(1.1);
1278 hemptyLoc->Draw();
d8e6677d 1279 leg = new TLegend(0.482759, 0.489583, 0.896552, 0.925595, NULL,"brNDC");
5f2ca1e6 1280 leg->SetFillColor(0);
4c0d7bc7 1281 for(Int_t ipart = 0; ipart < kNPart; ipart++) {
1282 for(Int_t idet = 0; idet <= kITSTPC; idet++){
1283 // if (idet == kITS) continue;
1284 // if (idet == kITSTPC) hSpectra[idet][ipart][icharge]->SetMarkerColor(kGreen);
1285 hSpectra[idet][ipart][icharge]->SetMarkerStyle(marker[idet]);
1286 hSpectra[idet][ipart][icharge]->Draw("same");
1287 leg->AddEntry(hSpectra[idet][ipart][icharge],TString(partLabel[ipart][icharge])+" (" + detFlag[idet] + ")","lpf");
1288 }
1289 // leg->AddLine();
1290 }
1291 leg->Draw();
2210b002 1292 // ALICEWorkInProgress(c1h,today.Data(),"#splitline{ALICE Preliminary}{Statistical Error Only}");
1293 PrintCanvas(c1h,printFormats);
4c0d7bc7 1294 }
1295
1296
eea641de 1297 // Draw ratios
4c0d7bc7 1298
eea641de 1299 // K-/K+ in the different detectors
5f2ca1e6 1300 TCanvas * cpm=new TCanvas("cpm","Kminus/Kplus",700,700);
1301 cpm->Divide(2,2);
1302 cpm->cd(1);
1303 TH1F* hRatioKPKM_TPC=new TH1F(*(hSpectra[kTPC][kKaon][kNeg]));
1304 hRatioKPKM_TPC->SetMinimum(0.5);
1305 hRatioKPKM_TPC->SetMaximum(1.5);
1306 hRatioKPKM_TPC->Divide(hSpectra[kTPC][kKaon][kPos]);
1307 hRatioKPKM_TPC->GetYaxis()->SetTitle("K-/K+ (TPC)");
1308 hRatioKPKM_TPC->Draw();
1309 cpm->cd(2);
1310 TH1F* hRatioKPKM_ITS=new TH1F(*(hSpectra[kITS][kKaon][kNeg]));
1311 hRatioKPKM_ITS->Divide(hSpectra[kITS][kKaon][kPos]);
1312 hRatioKPKM_ITS->SetMinimum(0.5);
1313 hRatioKPKM_ITS->SetMaximum(1.5);
1314 hRatioKPKM_ITS->GetYaxis()->SetTitle("K-/K+ (ITSsa)");
1315 hRatioKPKM_ITS->Draw("");
1316 cpm->cd(3);
1317 TH1F* hRatioKPKM_TOF=new TH1F(*(hSpectra[kTOF][kKaon][kNeg]));
1318 hRatioKPKM_TOF->Divide(hSpectra[kTOF][kKaon][kPos]);
1319 hRatioKPKM_TOF->SetMinimum(0.5);
1320 hRatioKPKM_TOF->SetMaximum(1.5);
1321 hRatioKPKM_TOF->GetYaxis()->SetTitle("K-/K+ (TOF)");
1322 hRatioKPKM_TOF->Draw("");
1323 cpm->cd(4);
1324 TH1F* hRatioKPKM_ITSTPC=new TH1F(*(hSpectra[kITSTPC][kKaon][kNeg]));
1325 hRatioKPKM_ITSTPC->Divide(hSpectra[kITSTPC][kKaon][kPos]);
1326 hRatioKPKM_ITSTPC->SetMinimum(0.5);
1327 hRatioKPKM_ITSTPC->SetMaximum(1.5);
1328 hRatioKPKM_ITSTPC->GetYaxis()->SetTitle("K-/K+ (ITS Global)");
1329 hRatioKPKM_ITSTPC->Draw("");
4c0d7bc7 1330
eea641de 1331
1332 // ITS/TPC
5f2ca1e6 1333 TH1F * hRatioITSTPC[kNPart][kNCharge];
eea641de 1334 for(Int_t icharge = 0; icharge < kNCharge; icharge++){ // loop over charges
1335 // Create canvas
2210b002 1336 TCanvas * c1h = new TCanvas(TString("cITSTPCRatio_")+chargeFlag[icharge],TString("cITSTPCRatio_")+chargeFlag[icharge],1200,500);
1337 c1h->Divide(3,1);
1338 c1h->SetGridy();
1339 TH2F * hemptyLoc = new TH2F(TString("hemptyR")+long(icharge),"ITSsa/TPC ",100,0.,1., 100, 0.5,1.5);
1340 hemptyLoc->SetXTitle("p_{t} (GeV/c)");
1341 hemptyLoc->SetYTitle("ITSsa / TPC");
eea641de 1342 // Loop over particles
5f2ca1e6 1343 for(Int_t ipart = 0; ipart < kNPart; ipart++) {
eea641de 1344 // Clone histo
5f2ca1e6 1345 hRatioITSTPC[ipart][icharge]=new TH1F(*hSpectra[kITS][ipart][icharge]);
1346 Int_t nBinsITS=hSpectra[kITS][ipart][icharge]->GetNbinsX();
1347 Int_t nBinsTPC=hSpectra[kTPC][ipart][icharge]->GetNbinsX();
eea641de 1348 // Loop over ITS bins,
5f2ca1e6 1349 for(Int_t iBin=1; iBin<=nBinsITS; iBin++){
1350 hRatioITSTPC[ipart][icharge]->SetBinContent(iBin,0.);
1351 hRatioITSTPC[ipart][icharge]->SetBinContent(iBin,0.);
1352 Float_t lowPtITS=hSpectra[kITS][ipart][icharge]->GetBinLowEdge(iBin);
1353 Float_t binWidITS=hSpectra[kITS][ipart][icharge]->GetBinWidth(iBin);
eea641de 1354 // Loop over TPC bins and find overlapping bins to ITS
5f2ca1e6 1355 for(Int_t jBin=1; jBin<=nBinsTPC; jBin++){
1356 Float_t lowPtTPC=hSpectra[kTPC][ipart][icharge]->GetBinLowEdge(jBin);
1357 Float_t binWidTPC=hSpectra[kTPC][ipart][icharge]->GetBinWidth(jBin);
1358 if(TMath::Abs(lowPtITS-lowPtTPC)<0.001 && TMath::Abs(binWidTPC-binWidITS)<0.001){
1359 Float_t numer=hSpectra[kITS][ipart][icharge]->GetBinContent(iBin);
1360 Float_t denom=hSpectra[kTPC][ipart][icharge]->GetBinContent(jBin);
1361 Float_t enumer=hSpectra[kITS][ipart][icharge]->GetBinError(iBin);
1362 Float_t edenom=hSpectra[kTPC][ipart][icharge]->GetBinError(jBin);
1363 Double_t ratio=0.;
1364 Double_t eratio=0.;
1365 if(numer>0. && denom>0.){
1366 ratio=numer/denom;
1367 eratio=ratio*TMath::Sqrt((enumer/numer)*(enumer/numer)+(edenom/denom)*(edenom/denom));
1368 }
1369 hRatioITSTPC[ipart][icharge]->SetBinContent(iBin,ratio);
1370 hRatioITSTPC[ipart][icharge]->SetBinError(iBin,eratio);
1371 break;
1372 }
1373 }
1374 }
2210b002 1375 c1h->cd(ipart+1);
1376 // hemptyLoc->SetStats(1);
1377 // hemptyLoc->Draw();
1378 hRatioITSTPC[ipart][icharge]->SetYTitle("ITSsa/TPC");
eea641de 1379 hRatioITSTPC[ipart][icharge]->SetStats(1);
1380 hRatioITSTPC[ipart][icharge]->GetYaxis()->SetRangeUser(0.5,1.5);
1381 hRatioITSTPC[ipart][icharge]->Draw("");
1382 hRatioITSTPC[ipart][icharge]->Fit("pol0","","same");
1383
5f2ca1e6 1384 }
2210b002 1385 PrintCanvas(c1h,printFormats);
5f2ca1e6 1386 }
1387
5b103cfc 1388 // ITS/TPC
1389 TH1F * hRatioITSGlobalTPC[kNPart][kNCharge];
1390 for(Int_t icharge = 0; icharge < kNCharge; icharge++){ // loop over charges
1391 // Create canvas
2210b002 1392 TCanvas * c1h = new TCanvas(TString("cITSGlobalTPCRatio_")+chargeFlag[icharge],TString("cITSGlobalTPCRatio_")+chargeFlag[icharge],1200,500);
1393 c1h->Divide(3,1);
1394 c1h->SetGridy();
1395 TH2F * hemptyLoc = new TH2F(TString("hemptyR")+long(icharge),"ITS Global/TPC ",100,0.,1., 100, 0.5,1.5);
1396 hemptyLoc->SetXTitle("p_{t} (GeV/c)");
1397 hemptyLoc->SetYTitle("ITS Global / TPC");
5b103cfc 1398 // Loop over particles
1399 for(Int_t ipart = 0; ipart < kNPart; ipart++) {
1400 // Clone histo
1401 hRatioITSGlobalTPC[ipart][icharge]=new TH1F(*hSpectra[kITSTPC][ipart][icharge]);
1402 Int_t nBinsITS=hSpectra[kITSTPC][ipart][icharge]->GetNbinsX();
1403 Int_t nBinsTPC=hSpectra[kTPC][ipart][icharge]->GetNbinsX();
1404 // Loop over ITS bins,
1405 for(Int_t iBin=1; iBin<=nBinsITS; iBin++){
1406 hRatioITSGlobalTPC[ipart][icharge]->SetBinContent(iBin,0.);
1407 hRatioITSGlobalTPC[ipart][icharge]->SetBinContent(iBin,0.);
1408 Float_t lowPtITS=hSpectra[kITSTPC][ipart][icharge]->GetBinLowEdge(iBin);
1409 Float_t binWidITS=hSpectra[kITSTPC][ipart][icharge]->GetBinWidth(iBin);
1410 // Loop over TPC bins and find overlapping bins to ITS
1411 for(Int_t jBin=1; jBin<=nBinsTPC; jBin++){
1412 Float_t lowPtTPC=hSpectra[kTPC][ipart][icharge]->GetBinLowEdge(jBin);
1413 Float_t binWidTPC=hSpectra[kTPC][ipart][icharge]->GetBinWidth(jBin);
1414 if(TMath::Abs(lowPtITS-lowPtTPC)<0.001 && TMath::Abs(binWidTPC-binWidITS)<0.001){
1415 Float_t numer=hSpectra[kITSTPC][ipart][icharge]->GetBinContent(iBin);
1416 Float_t denom=hSpectra[kTPC][ipart][icharge]->GetBinContent(jBin);
1417 Float_t enumer=hSpectra[kITSTPC][ipart][icharge]->GetBinError(iBin);
1418 Float_t edenom=hSpectra[kTPC][ipart][icharge]->GetBinError(jBin);
1419 Double_t ratio=0.;
1420 Double_t eratio=0.;
1421 if(numer>0. && denom>0.){
1422 ratio=numer/denom;
1423 eratio=ratio*TMath::Sqrt((enumer/numer)*(enumer/numer)+(edenom/denom)*(edenom/denom));
1424 }
1425 hRatioITSGlobalTPC[ipart][icharge]->SetBinContent(iBin,ratio);
1426 hRatioITSGlobalTPC[ipart][icharge]->SetBinError(iBin,eratio);
1427 break;
1428 }
1429 }
1430 }
2210b002 1431 c1h->cd(ipart+1);
1432 // hemptyLoc->SetStats(1);
1433 // hemptyLoc->Draw();
1434 hRatioITSGlobalTPC[ipart][icharge]->SetYTitle("ITS Global/TPC");
5b103cfc 1435 hRatioITSGlobalTPC[ipart][icharge]->SetStats(1);
1436 hRatioITSGlobalTPC[ipart][icharge]->GetYaxis()->SetRangeUser(0.5,1.5);
1437 hRatioITSGlobalTPC[ipart][icharge]->Draw("");
1438 hRatioITSGlobalTPC[ipart][icharge]->Fit("pol0","","same");
1439
1440 }
2210b002 1441 PrintCanvas(c1h,printFormats);
5b103cfc 1442 }
1443
eea641de 1444 // TOF/TPC
5f2ca1e6 1445 TH1F * hRatioTOFTPC[kNPart][kNCharge];
eea641de 1446 for(Int_t icharge = 0; icharge < kNCharge; icharge++){ // loop over charges
1447 // create canvas
1448 TCanvas * c1t = new TCanvas(TString("cTOFTPCRatio_")+chargeFlag[icharge],TString("cTOFTPCRatio_")+chargeFlag[icharge],1200,500);
5f2ca1e6 1449 c1t->SetGridy();
eea641de 1450 c1t->Divide(3,1);
5f2ca1e6 1451 TH2F * hemptyt = new TH2F(TString("hemptyRt")+long(icharge),"TOF/TPC ",100,0.,1., 100, 0.5,1.5);
1452 hemptyt->SetXTitle("p_{t} (GeV/c)");
1453 hemptyt->SetYTitle("TOF / TPC");
eea641de 1454 // hemptyt->Draw();
1455 for(Int_t ipart = 0; ipart < kNPart; ipart++) { // loop over particles
1456 // Clone histo
5f2ca1e6 1457 hRatioTOFTPC[ipart][icharge]=new TH1F(*hSpectra[kTOF][ipart][icharge]);
1458 Int_t nBinsTOF=hSpectra[kTOF][ipart][icharge]->GetNbinsX();
1459 Int_t nBinsTPC=hSpectra[kTPC][ipart][icharge]->GetNbinsX();
eea641de 1460 // Loop over TOF bins
5f2ca1e6 1461 for(Int_t iBin=1; iBin<=nBinsTOF; iBin++){
1462 hRatioTOFTPC[ipart][icharge]->SetBinContent(iBin,0.);
1463 hRatioTOFTPC[ipart][icharge]->SetBinContent(iBin,0.);
1464 Float_t lowPtTOF=hSpectra[kTOF][ipart][icharge]->GetBinLowEdge(iBin);
1465 Float_t binWidTOF=hSpectra[kTOF][ipart][icharge]->GetBinWidth(iBin);
eea641de 1466 // Loop over TPC bins and find overlapping bins to ITS
5f2ca1e6 1467 for(Int_t jBin=1; jBin<=nBinsTPC; jBin++){
1468 Float_t lowPtTPC=hSpectra[kTPC][ipart][icharge]->GetBinLowEdge(jBin);
1469 Float_t binWidTPC=hSpectra[kTPC][ipart][icharge]->GetBinWidth(jBin);
1470 if(TMath::Abs(lowPtTOF-lowPtTPC)<0.001 && TMath::Abs(binWidTPC-binWidTOF)<0.001){
1471 Float_t numer=hSpectra[kTOF][ipart][icharge]->GetBinContent(iBin);
1472 Float_t denom=hSpectra[kTPC][ipart][icharge]->GetBinContent(jBin);
1473 Float_t enumer=hSpectra[kTOF][ipart][icharge]->GetBinError(iBin);
1474 Float_t edenom=hSpectra[kTPC][ipart][icharge]->GetBinError(jBin);
1475 Double_t ratio=0.;
1476 Double_t eratio=0.;
1477 if(numer>0. && denom>0.){
1478 ratio=numer/denom;
1479 eratio=ratio*TMath::Sqrt((enumer/numer)*(enumer/numer)+(edenom/denom)*(edenom/denom));
1480 }
1481 hRatioTOFTPC[ipart][icharge]->SetBinContent(iBin,ratio);
1482 hRatioTOFTPC[ipart][icharge]->SetBinError(iBin,eratio);
1483 break;
1484 }
1485 }
1486 }
eea641de 1487 c1t->cd(ipart+1);
2210b002 1488 hRatioTOFTPC[ipart][icharge]->SetYTitle("TOF/TPC");
0e6f7392 1489 hRatioTOFTPC[ipart][icharge]->SetStats(1);
1490 hRatioTOFTPC[ipart][icharge]->GetYaxis()->SetRangeUser(0.5,1.5);
1491 hRatioTOFTPC[ipart][icharge]->Draw("");
1492 hRatioTOFTPC[ipart][icharge]->Fit("pol0","","same");
5f2ca1e6 1493 }
22abbb27 1494 PrintCanvas(c1t,printFormats);
5f2ca1e6 1495 }
1496
4c0d7bc7 1497}
1498
1499void DrawWithJacek() {
1500
1501 //1. Convert spectra to dNdeta and sum
1502 TH1F * hsum = (TH1F*) htemplate->Clone();
1503 hsum->Reset();
ee08b77d 1504 Int_t idet= iCombInStudy;
4c0d7bc7 1505 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1506 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1507 TH1 * h = hSpectra[idet][ipart][icharge];
1508 Int_t nbin = h->GetNbinsX();
1509 for(Int_t ibin = 1; ibin <= nbin; ibin++){
1510 Double_t pt = h->GetBinCenter(ibin);
1511 Double_t mt = TMath::Sqrt(pt*pt + mass[ipart]*mass[ipart]);
1512 Double_t jacobian = pt/mt;
1513 h->SetBinContent(ibin,h->GetBinContent(ibin)*jacobian);
1514 h->SetBinError (ibin,h->GetBinError (ibin)*jacobian);
1515 Int_t ibinSum = hsum->FindBin(pt);
1516 Double_t epsilon = 0.0001;
1517 if ( h->GetBinContent(ibin) > 0 &&
1518 (TMath::Abs(h->GetBinLowEdge(ibin) - hsum->GetBinLowEdge(ibinSum)) > epsilon ||
1519 TMath::Abs(h->GetBinLowEdge(ibin+1) - hsum->GetBinLowEdge(ibinSum+1)) )
1520 ) {
1521 cout << "DISCREPANCY IN BIN RANGES" << endl;
1522 cout << pt << " " << ibinSum << " " << ibin << "; " << h->GetBinContent(ibin) << endl
1523 << h->GetBinLowEdge(ibin) << "-" << h->GetBinLowEdge(ibin+1) << endl
1524 << hsum->GetBinLowEdge(ibinSum) << "-" << hsum->GetBinLowEdge(ibinSum+1) << endl;
1525 cout << "" << endl;
1526 }
1527
1528
1529 hsum->SetBinContent(ibinSum,hsum->GetBinContent(ibinSum)+h->GetBinContent(ibin)); // EROOR FIXME
1530 hsum->SetBinError (ibinSum,0);
1531 }
1532 // hsum->Add(h);
1533 }
1534 }
1535
1536
1537 // Load Jacek and Draw both:
77233d47 1538 new TFile ("./Files/pt_allcharged_published.root");
1539 TGraphErrors * gJacek = (TGraphErrors*) gDirectory->Get("dndpt");
1540 gJacek->SetMarkerStyle(20);
1541 gJacek->SetMarkerColor(kGray);
1542 gJacek->Draw("AP");
1543 gJacek->GetHistogram()->SetXTitle("p_{t} (GeV)");
1544 gJacek->GetHistogram()->SetYTitle("d^{2}N/dp_{t}d#eta (GeV^{-1})");
1545 hsum->Draw("same");
1546
1547 TGraphErrors * gRatio = AliBWTools::DivideGraphByHisto(gJacek,hsum);
1548 new TCanvas();
1549 gRatio->Draw("AP");
4c0d7bc7 1550
1551
1552
1553}
1554
1555
1556void DrawRatioToStar() {
1557
1558 // Star data
1559 // gROOT->LoadMacro("StarPPSpectra.C");
1560 TGraphErrors ** gStar = StarPPSpectra();
c4fe358b 1561 gStar[0]->SetMarkerStyle(kOpenStar);
1562 gStar[1]->SetMarkerStyle(kFullStar);
1563 gStar[2]->SetMarkerStyle(kOpenStar);
1564 gStar[3]->SetMarkerStyle(kFullStar);
1565 gStar[4]->SetMarkerStyle(kOpenStar);
1566 gStar[5]->SetMarkerStyle(kFullStar);
4c0d7bc7 1567
1568 // ALICE, INEL -> NSD
1569 Double_t scaleYield = 3.58/3.02; // from paper 2
1570 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1571 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
ee08b77d 1572 hSpectra[iCombInStudy][ipart][icharge]->Scale(scaleYield);
4c0d7bc7 1573 }
1574 }
1575
1576
1577 TCanvas * c1 = new TCanvas("cRatioToStarNeg","cRatioToStarNeg");
1578 TH2F * hempty = new TH2F(TString("hemptyNeg"),"hemptyNeg",100,0.,1.5, 100, 0.001,1.8);
1579 hempty->SetXTitle("p_{t} (GeV/c)");
1580 hempty->SetYTitle("ALICE/STAR (NSD)");
c4fe358b 1581 hempty->Draw();
1582
1583 TCanvas * c1Comp = new TCanvas("cCompToStarNeg","cCompToStarNeg");
1584 c1Comp->SetLogy();
1585 TH2F * hempty2 = new TH2F(TString("hemptyCompNeg"),"hemptyCompNeg",100,0.,1.5, 100, 0.001,10);
1586 hempty2->SetXTitle("p_{t} (GeV/c)");
1587 hempty2->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1} [NSD]");
1588 hempty2->Draw();
4c0d7bc7 1589
1590 TLegend *leg = new TLegend(0.6510067,0.1853147,0.8892617,0.4178322,"Negative","brNDC");
1591 leg->SetBorderSize(0);
1592 leg->SetLineColor(1);
1593 leg->SetLineStyle(1);
1594 leg->SetLineWidth(1);
1595 leg->SetFillColor(0);
1596 leg->SetFillStyle(1001);
1597
1598
c4fe358b 1599
1600 c1->cd();
4c0d7bc7 1601 TGraphErrors * g ;
ee08b77d 1602 g = AliBWTools::DivideGraphByHisto(gStar[0],hSpectra[iCombInStudy][kPion][kNeg],1);
4c0d7bc7 1603 g->SetMarkerStyle(kFullCircle);
1604 g->SetMarkerColor(kBlack);
1605 g->Draw("p");
1606 leg->AddEntry(g,"#pi^{-}","lp");
ee08b77d 1607 g = AliBWTools::DivideGraphByHisto(gStar[2],hSpectra[iCombInStudy][kKaon][kNeg],1);
4c0d7bc7 1608 g->SetMarkerStyle(kOpenCircle);
1609 g->SetMarkerColor(kRed);
1610 g->Draw("p");
1611 leg->AddEntry(g,"K^{-}","lp");
ee08b77d 1612 g = AliBWTools::DivideGraphByHisto(gStar[4],hSpectra[iCombInStudy][kProton][kNeg],1);
4c0d7bc7 1613 g->SetMarkerStyle(kOpenSquare);
1614 g->SetMarkerColor(kBlue);
1615 g->Draw("p");
1616 leg->AddEntry(g,"#bar{p}","lp");
1617 leg->Draw();
1618
c4fe358b 1619 c1Comp->cd();
1620 gStar[0]->Draw("p");
1621 hSpectra[iCombInStudy][kPion][kNeg]->Draw("same");
1622 gStar[2]->Draw("p");
1623 hSpectra[iCombInStudy][kKaon][kNeg]->Draw("same");
1624 gStar[4]->Draw("p");
1625 hSpectra[iCombInStudy][kProton][kNeg]->Draw("same");
4c0d7bc7 1626
1627
1628
1629 TCanvas * c2 = new TCanvas("cRatioToStarPos","cRatioToStarPos");
1630 hempty->Draw();
1631 leg = new TLegend(0.6510067,0.1853147,0.8892617,0.4178322,"Positive","brNDC");
1632 leg->SetBorderSize(0);
1633 leg->SetLineColor(1);
1634 leg->SetLineStyle(1);
1635 leg->SetLineWidth(1);
1636 leg->SetFillColor(0);
1637 leg->SetFillStyle(1001);
c4fe358b 1638
1639 TCanvas * c2Comp = new TCanvas("cCompToStarPos","cCompToStarPos");
1640 c2Comp->SetLogy();
1641 hempty2->Draw();
1642
1643 c2->cd();
4c0d7bc7 1644 // TGraphErrors * g ;
ee08b77d 1645 g = AliBWTools::DivideGraphByHisto(gStar[1],hSpectra[iCombInStudy][kPion][kPos],1);
4c0d7bc7 1646 g->SetMarkerStyle(kFullCircle);
1647 g->SetMarkerColor(kBlack);
1648 g->Draw("p");
1649 leg->AddEntry(g,"#pi^{+}","lp");
ee08b77d 1650 g = AliBWTools::DivideGraphByHisto(gStar[3],hSpectra[iCombInStudy][kKaon][kPos],1);
4c0d7bc7 1651 g->SetMarkerStyle(kOpenCircle);
1652 g->SetMarkerColor(kRed);
1653 g->Draw("p");
1654 leg->AddEntry(g,"K^{+}","lp");
ee08b77d 1655 g = AliBWTools::DivideGraphByHisto(gStar[5],hSpectra[iCombInStudy][kProton][kPos],1);
4c0d7bc7 1656 g->SetMarkerStyle(kOpenSquare);
1657 g->SetMarkerColor(kBlue);
1658 g->Draw("p");
1659 leg->AddEntry(g,"p","lp");
c4fe358b 1660 leg->Draw();
4c0d7bc7 1661
1662
c4fe358b 1663 c2Comp->cd();
1664 gStar[1]->Draw("p");
1665 hSpectra[iCombInStudy][kPion][kPos]->Draw("same");
1666 gStar[3]->Draw("p");
1667 hSpectra[iCombInStudy][kKaon][kPos]->Draw("same");
1668 gStar[5]->Draw("p");
1669 hSpectra[iCombInStudy][kProton][kPos]->Draw("same");
1670
4c0d7bc7 1671
1672 c1->Update();
1673 c2->Update();
1674 gSystem->ProcessEvents();
1675 c1->Print(TString(c1->GetName()) + ".eps");
1676 c2->Print(TString(c2->GetName()) + ".eps");
1677 ALICEWorkInProgress(c1,today.Data(),"#splitline{ALICE Preliminary}{Statistical Error Only}");
1678 ALICEWorkInProgress(c2,today.Data(),"#splitline{ALICE Preliminary}{Statistical Error Only}");
1679 c1->Update();
1680 c2->Update();
1681 c1->Print(TString(c1->GetName()) + ".png");
1682 c2->Print(TString(c2->GetName()) + ".png");
1683
1684
1685
1686
1687}
1688
1689
1690
1691void DrawRatios() {
1692
1693 // Draws ratios of combined spectra
1694
4d4a268c 1695 // Rebin histograms (hi pt was fluctuating too much in the TOF)
1696 RebinHistosForRatios();
1697
4c0d7bc7 1698 // Compute ratios
1699 TH1F * hPosNegRatio[kNPart];
1700
1701 for(Int_t ipart = 0; ipart < kNPart; ipart++){
ee08b77d 1702 hPosNegRatio[ipart] = (TH1F*) hSpectra[iCombInStudy][ipart][kPos]->Clone();
1703 hPosNegRatio[ipart]->Divide(hSpectra[iCombInStudy][ipart][kNeg]);
4c0d7bc7 1704 hPosNegRatio[ipart]->SetYTitle(TString(partLabel[ipart][kPos])+"/"+partLabel[ipart][kNeg]);
1705 hPosNegRatio[ipart]->SetMinimum(0.5);
1706 hPosNegRatio[ipart]->SetMaximum(1.5);
1707 }
1708
4d4a268c 1709
ee08b77d 1710 TH1F * hKPiRatio = (TH1F*) hSpectra[iCombInStudy][kKaon][kPos]->Clone();
1711 hKPiRatio->Add(hSpectra[iCombInStudy][kKaon][kNeg]);
1712 TH1F * htmp = (TH1F*) hSpectra[iCombInStudy][kPion][kPos]->Clone();
1713 htmp->Add(hSpectra[iCombInStudy][kPion][kNeg]);
4c0d7bc7 1714 hKPiRatio->Divide(htmp);
1715 hKPiRatio->SetYTitle("(K^{+}+K^{-})/(#pi^{+}+#pi^{-})");
4d4a268c 1716 // Get ratio of syst errors
1717 // FIXME: commented combined error
1718 TH1F * hKPiRatioSyst = new TH1F(*htemplate);;
1719 AliBWTools::GetValueAndError(hKPiRatioSyst,hSpectra[iCombInStudy][kKaon][kPos],hSystError[iCombInStudy][kKaon][kPos],kTRUE);
1720 // AliBWTools::GetHistoCombinedErrors(hKPiRatioSyst,hSpectra[iCombInStudy][kKaon][kPos]);
1721 AliBWTools::GetValueAndError(htmp,hSpectra[iCombInStudy][kKaon][kNeg],hSystError[iCombInStudy][kKaon][kNeg],kTRUE);
1722 // // AliBWTools::GetHistoCombinedErrors(htmp,hSpectra[iCombInStudy][kKaon][kNeg]);
1723 hKPiRatioSyst->Add(htmp);
1724 AliBWTools::GetValueAndError(htmp,hSpectra[iCombInStudy][kPion][kNeg],hSystError[iCombInStudy][kPion][kNeg],kTRUE);
1725 // AliBWTools::GetHistoCombinedErrors(htmp,hSpectra[iCombInStudy][kPion][kNeg]);
1726 TH1F * htmp2 = new TH1F(*htemplate);
1727 AliBWTools::GetValueAndError(htmp2,hSpectra[iCombInStudy][kPion][kPos],hSystError[iCombInStudy][kPion][kPos],kTRUE);
1728 // AliBWTools::GetHistoCombinedErrors(htmp2,hSpectra[iCombInStudy][kPion][kPos]);
1729 htmp->Add(htmp2);
1730 hKPiRatioSyst->Divide(htmp);
1731 hKPiRatioSyst->SetYTitle("(K^{+}+K^{-})/(#pi^{+}+#pi^{-})");
1732 // Multiply error for sqrt(2): the syst is not reduced by combining positive and negative charges
1733 Int_t nbin = hKPiRatioSyst->GetNbinsX();
1734 for(Int_t ibin = 1; ibin <= nbin; ibin++){
1735 hKPiRatioSyst->SetBinError(ibin, hKPiRatioSyst->GetBinError(ibin)*TMath::Sqrt(2));
1736 }
1737
1738
1739
4c0d7bc7 1740
1741 TH1F * hKPiRatioMC[kNTunes];
5f2ca1e6 1742 if(showMC){
1743 for(Int_t itune = 0; itune < kNTunes; itune++){
1744 hKPiRatioMC[itune] = (TH1F*) hSpectraMC[itune][kKaon][kPos]->Clone();
1745 hKPiRatioMC[itune]->Add(hSpectraMC[itune][kKaon][kNeg]);
2210b002 1746 TH1F * htmpLoc = (TH1F*) hSpectraMC[itune][kPion][kPos]->Clone();
1747 htmpLoc->Add(hSpectraMC[itune][kPion][kNeg]);
1748 hKPiRatioMC[itune]->Divide(htmpLoc);
5f2ca1e6 1749 hKPiRatioMC[itune]->SetYTitle("(K^{+}+K^{-})/(#pi^{+}+#pi^{-})");
1750 }
4c0d7bc7 1751 }
1752
1753
1754
ee08b77d 1755 TH1F * hPPiRatio = (TH1F*) hSpectra[iCombInStudy][kProton][kPos]->Clone();
1756 hPPiRatio->Add(hSpectra[iCombInStudy][kProton][kNeg]);
1757 htmp = (TH1F*) hSpectra[iCombInStudy][kPion][kPos]->Clone();
1758 htmp->Add(hSpectra[iCombInStudy][kPion][kNeg]);
4c0d7bc7 1759 hPPiRatio->Divide(htmp);
1760 hPPiRatio->SetYTitle("(p+#bar{p})/(#pi^{+}+#pi^{-})");
1761
55056a39 1762 TH1F * hPPiRatioMC[kNTunes];
5f2ca1e6 1763 if(showMC){
5f2ca1e6 1764 for(Int_t itune = 0; itune < kNTunes; itune++){
1765 hPPiRatioMC[itune] = (TH1F*) hSpectraMC[itune][kProton][kPos]->Clone();
1766 hPPiRatioMC[itune]->Add(hSpectraMC[itune][kProton][kNeg]);
2210b002 1767 TH1F * htmpLoc = (TH1F*) hSpectraMC[itune][kPion][kPos]->Clone();
1768 htmpLoc->Add(hSpectraMC[itune][kPion][kNeg]);
1769 hPPiRatioMC[itune]->Divide(htmpLoc);
5f2ca1e6 1770 hPPiRatioMC[itune]->SetYTitle("(p+#bar{p})/(#pi^{+}+#pi^{-})");
1771 }
4c0d7bc7 1772 }
1773
d8e6677d 1774 // Phenix ratio
1775 TFile * fPhenix = new TFile("./Files/phenixdata.root");
1776 TH1F * hPPiRatioPhenix = (TH1F*) fPhenix->Get("ProtonPHNX");
1777 hPPiRatioPhenix->Add((TH1F*) fPhenix->Get("PbarPHNX"));
1778 htmp = (TH1F*) fPhenix->Get("PiPlusPHNX");
1779 htmp->Add((TH1F*) fPhenix->Get("PiMinusPHNX"));
1780 hPPiRatioPhenix = AliBWTools::DivideHistosDifferentBins(hPPiRatioPhenix,htmp);
1781 hPPiRatioPhenix->SetMarkerStyle(24);
1782
4c0d7bc7 1783 // Draw
1784// TH2F * hempty = new TH2F(TString("hempty"),"hempty",100,0.,1.5, 100, 0.001,1.8);
1785// hempty->SetXTitle("p_{t} (GeV/c)");
1786 // hempty->SetYTitle("");
1787
1788 // tmp: overlay levi fits
1789 AliBWFunc * fm2 = new AliBWFunc;
1790 fm2->SetVarType(AliBWFunc::kdNdpt);
1791 TF1 * fLevi[kNPart] [kNCharge];
1792 fLevi[kPion] [kPos] = fm2->GetLevi (mass[0], 0.1243, 7.614785, 1.524167, "fLeviPiPlus");
1793 fLevi[kKaon] [kPos] = fm2->GetLevi (mass[1], 0.1625, 5.869318, 0.186361, "fLeviKPlus");
1794 fLevi[kProton][kPos] = fm2->GetLevi (mass[2], 0.1773, 6.918065, 0.086389, "fLeviPPlus");
1795 fLevi[kPion] [kNeg] = fm2->GetLevi (mass[0], 0.1267, 7.979582, 1.515908, "fLeviPiNeg");
1796 fLevi[kKaon] [kNeg] = fm2->GetLevi (mass[1], 0.1721, 6.927956, 0.191140, "fLeviKNeg");
1797 fLevi[kProton][kNeg] = fm2->GetLevi (mass[2], 0.1782, 8.160362, 0.082091, "fLeviPNeg");
1798 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1799 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1800 fLevi[ipart][icharge]->SetRange(0,4);
1801 }
1802 }
1803
1804
1805 for(Int_t ipart = 0; ipart < kNPart; ipart++){
b7018bc7 1806 TString detName = detFlag[iCombInStudy];
1807 detName.ReplaceAll(" ", "_");
1808 detName.ReplaceAll("+", "");
1809
5f2ca1e6 1810 TCanvas * c1 = new TCanvas(TString("cRatio_")+detName+TString("_")+partFlag[ipart], TString("cRatio_")+detName+partFlag[ipart]);
1811 c1->SetGridy();
4c0d7bc7 1812 hPosNegRatio[ipart]->Draw();
1813 TF1 * fRatio = new TF1 (TString("fRatio")+partFlag[ipart], TString(fLevi[ipart][kPos]->GetName())+"/"+fLevi[ipart][kNeg]->GetName());
1814 // fRatio->Draw("same");
1815 fRatio->SetRange(0,5);
4d4a268c 1816 PrintCanvas(c1,printFormats);
4c0d7bc7 1817
1818 }
1819
1820
1821 TCanvas * c2 = new TCanvas(TString("cRatio_KPi"),TString("cRatio_KPi"));
d8e6677d 1822 // c2->SetGridy();
4d4a268c 1823
1824 hKPiRatioSyst->SetMaximum(0.62);
1825 hKPiRatioSyst->SetFillColor(kGray);
1826 hKPiRatioSyst->SetMarkerStyle(24);
1827 // hKPiRatioSyst->Draw("e2");
1828 // TMP FIXME: ERROR FROM FP:
1829 TFile * f = TFile::Open("./Files/ITSsa-systematics-20101014.root");
1830 TH1F * hsystRatio = (TH1F*) f->Get("hSystRatioKpi");
1831 TH1F * hsyst = new TH1F(*htemplate);
1832 AliBWTools::GetValueAndError(hsyst,hKPiRatio,hsystRatio,1);
1833 // AliBWTools::GetHistoCombinedErrors(hsyst,hKPiRatio);
1834 // hsyst->Draw("samee1");
1835 // END TMP
1836 hKPiRatio->SetMaximum(0.62);
1837 hKPiRatio->Draw("");
4c0d7bc7 1838 TLegend * lMC = new TLegend(0.526846, 0.18007, 0.887584,0.407343);
1839 lMC->SetFillColor(kWhite);
4d4a268c 1840 TGraphErrors ** gStar = StarPPSpectra();
1841 cout << gStar[6] << endl;
1842
1843 gStar[6]->SetMarkerStyle(kOpenStar);
1844 gStar[6]->Draw("P");
1845
5f2ca1e6 1846 if(showE735){
1847 gROOT->LoadMacro("GetE735Ratios.C");
4d4a268c 1848 // GetE735Ratios(0,0)->Draw("EX0,same");
1849 // GetE735Ratios(0,1)->Draw("EX0,same");
1850 // GetE735Ratios(0,2)->Draw("EX0,same");
5f2ca1e6 1851 GetE735Ratios(0,3)->Draw("EX0,same");
1852 }
4c0d7bc7 1853 hKPiRatio->SetMarkerStyle(20);
d8e6677d 1854 hKPiRatio->SetMarkerColor(kRed);
1855 hKPiRatio->SetLineColor(kRed);
4d4a268c 1856 //hKPiRatio->Draw("same");
4c0d7bc7 1857
5f2ca1e6 1858 if(showMC){
1859 for(Int_t itune = 0; itune < kNTunes; itune++){
1860 lMC->AddEntry(hKPiRatioMC[itune],mcTuneName[itune]);
1861 hKPiRatioMC[itune]->SetLineWidth(2);
1862 hKPiRatioMC[itune]->Draw("same,chist");
1863 }
4c0d7bc7 1864
5f2ca1e6 1865 lMC->Draw();
1866 }
4d4a268c 1867 cout << "12" << endl;
4c0d7bc7 1868
5f2ca1e6 1869 if(showE735){
1870 TLegend * l = new TLegend( 0.1879, 0.68, 0.54,0.92);
1871 l->SetFillColor(kWhite);
1872 l->AddEntry(hKPiRatio, "ALICE, #sqrt{s} = 900 GeV","lpf");
4d4a268c 1873 l->AddEntry(gStar[6], "STAR, #sqrt{s} = 200 GeV", "lp");
1874 // l->AddEntry(GetE735Ratios(0,0), "E735, #sqrt{s} = 300 GeV","lpf");
1875 // l->AddEntry(GetE735Ratios(0,1), "E735, #sqrt{s} = 540 GeV","lpf");
1876 // l->AddEntry(GetE735Ratios(0,2), "E735, #sqrt{s} = 1000 GeV","lpf");
5f2ca1e6 1877 l->AddEntry(GetE735Ratios(0,3), "E735, #sqrt{s} = 1800 GeV","lpf");
1878 l->Draw();
1879 }
4c0d7bc7 1880
1881
1882 TCanvas * c3 = new TCanvas(TString("cRatio_PPi"),TString("cRatio_PPi"));
4d4a268c 1883 cout << "DRAWING" << endl;
d8e6677d 1884 // c3->SetGridy();
1885 hPPiRatio->SetMarkerStyle(20);
1886 hPPiRatio->SetMarkerColor(kRed);
1887 hPPiRatio->SetLineColor(kRed);
4c0d7bc7 1888 hPPiRatio->Draw();
1889 hPPiRatio->SetMaximum(0.39);
5f2ca1e6 1890 if(showMC){
1891 lMC = new TLegend(0.526846, 0.18007, 0.887584,0.407343);
1892 lMC->SetFillColor(kWhite);
1893
1894 for(Int_t itune = 0; itune < kNTunes; itune++){
1895 lMC->AddEntry(hKPiRatioMC[itune],mcTuneName[itune]);
55056a39 1896 hPPiRatioMC[itune]->SetLineWidth(2);
1897 hPPiRatioMC[itune]->Draw("same,chist");
5f2ca1e6 1898 }
4c0d7bc7 1899
5f2ca1e6 1900 lMC->Draw();
1901 }
d8e6677d 1902 hPPiRatioPhenix->Draw("same");
1903
1904
1905 TLegend * l = new TLegend(0.186242, 0.781469, 0.538591, 0.921329);
1906 l->SetFillColor(kWhite);
1907 l->AddEntry(hPPiRatio, "ALICE, #sqrt{s} = 900 GeV","lpf");
1908 l->AddEntry(hPPiRatioPhenix, "PHENIX, #sqrt{s} = 200 GeV","lpf");
1909 // TLegend * l = new TLegend(0.206376, 0.77972, 0.600671, 0.909091);
1910 l->Draw();
1911
4d4a268c 1912 PrintCanvas(c2,printFormats);
1913 PrintCanvas(c3,printFormats);
4c0d7bc7 1914
1915}
1916
3725266c 1917void DrawWithSyst() {
1918
1919 // Draws detector and combined with syst errors.
1920
1921 for(Int_t idet = 0; idet < kNHist; idet++){
1922 if(idet > kITS && idet != iCombInStudy) continue;
1923 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
1924 TCanvas * c = new TCanvas(TString("cWithSyst")+detFlag[idet]+chargeFlag[icharge],TString("cWithSyst")+detFlag[idet]+chargeFlag[icharge]);
1925 TH2F * hempty = new TH2F(TString("hempty")+long(icharge),"hempty",100,0.,2.9, 100, 0.0005,5);
1926 hempty->SetXTitle("p_{t} (GeV/c)");
1927 hempty->SetYTitle("1/N_{ev} d^{2}N / dydp_{t} (GeV/c)^{-1}");
1928 hempty->GetYaxis()->SetTitleOffset(1.35);
1929 hempty->GetXaxis()->SetTitleOffset(1.1);
1930 hempty->Draw();
1931 c->SetLogy();
1932 for(Int_t ipart = 0; ipart < kNPart; ipart++){
1933 // cout << detFlag[idet] << " " << chargeFlag[icharge] << " " << partFlag[ipart] << endl;
1934
1935 TString opt = ipart ? "" : "same";
1936 TH1F * hsyst = new TH1F(*htemplate);
1937 AliBWTools::GetValueAndError(hsyst,hSpectra[idet][ipart][icharge],hSystError[idet][ipart][icharge],kTRUE);
55056a39 1938 hsyst->SetFillColor(kGray);
3725266c 1939 hsyst->Draw("e5,same");
1940 hSpectra[idet][ipart][icharge]->Draw("same");
22abbb27 1941 // Do not draw syst error outside of spectra range
1942 Float_t lowEdge = AliBWTools::GetLowestNotEmptyBinEdge(hSpectra[idet][ipart][icharge]);
1943 Float_t hiEdge = AliBWTools::GetHighestNotEmptyBinEdge(hSpectra[idet][ipart][icharge]);
1944 Int_t lowBin = hSystError[idet][ipart][icharge]->FindBin(lowEdge);
1945 Int_t hiBin = hSystError[idet][ipart][icharge]->FindBin(hiEdge);
1946 Int_t nbin = hSystError[idet][ipart][icharge]->GetNbinsX();
2210b002 1947 for(Int_t ibin = 1; ibin < lowBin; ibin++){
22abbb27 1948 hSystError[idet][ipart][icharge]->SetBinContent(ibin,0);
1949 hSystError[idet][ipart][icharge]->SetBinError(ibin,0);
1950 }
1951 for(Int_t ibin = hiBin; ibin <= nbin; ibin++){
1952 hSystError[idet][ipart][icharge]->SetBinContent(ibin,0);
1953 hSystError[idet][ipart][icharge]->SetBinError(ibin,0);
1954 }
1955 // Draw relative syst error, convert to graph to avoid vertical bars at the edges (empty bins in histo)
1956 AliBWTools::GetGraphFromHisto(hSystError[idet][ipart][icharge])->Draw("LX");
1957
3725266c 1958
1959
1960 }
22abbb27 1961 PrintCanvas(c,"png,eps");
3725266c 1962 }
1963 }
1964}
c4fe358b 1965
1966void Help() {
1967
1968 cout << "Macro: void CombineSpectra(Int_t analysisType=kDoFits, Int_t fitFuncID = kFitLevi) " << endl;
1969 cout << "" << endl;
4d4a268c 1970 cout << "WARNING: some function modify the histos upon execution. You are advised to quit root" << endl;
1971 cout << " before running a different function" << endl;
1972 cout << "" << endl;
c4fe358b 1973 cout << "Possible Arguments" << endl;
1974 cout << "- analysisType:" << endl;
eea641de 1975 cout << " kDoFits: Fit Combined Spectra " << endl;
1976 cout << " kDoRatios: Particle ratios K/pi and p/pi" << endl;
1977 cout << " kDoSuperposition: Compare different detectors (superimpose and ratios)" << endl;
1978 cout << " kDoCompareStar: Compare combined spectra to star results" << endl;
1979 cout << " kDoDrawWithModels: Compare combined spectra and models" << endl;
3725266c 1980 cout << " kDoDrawSyst: Draws spectra from individual detectors with their systematic error" << endl;
77233d47 1981 cout << " kDoCompareToAllCharged: convert to dn/deta/dpt, sum up and compare to all charged" << endl;
eea641de 1982 cout << " kDoHelp: This help" << endl;
1983 cout << "- fitFuncID, function used to extrapolate and compute yields" << endl;
1984 cout << " An analitic fit function [kFitLevi, kFitUA1, kFitPowerLaw]" << endl;
1985 cout << " Or a shape from a MC moder [kFitPhojet, kFitAtlasCSC, kFitCMS6D6T, kFitPerugia0]" << endl;
2f7f947e 1986 cout << " Which is fitted to the data at low pt and used to extrapolate at low pt" << endl;
c4fe358b 1987
1988
1989}
3725266c 1990
1991void PrintCanvas(TCanvas* c,const TString formats) {
1992 // print a canvas in every of the given comma-separated formats
1993 // ensure the canvas is updated
22abbb27 1994 if(!doPrint) return;
3725266c 1995 c->Update();
1996 gSystem->ProcessEvents();
1997 TObjArray * arr = formats.Tokenize(",");
1998 TIterator * iter = arr->MakeIterator();
1999 TObjString * element = 0;
2000 TString name =c ->GetName();
2001 name.ReplaceAll(" ","_");
2002 name.ReplaceAll("+","Plus");
2003 name.ReplaceAll("-","");
2004 while ((element = (TObjString*) iter->Next())) {
2005 c->Print(name+ "."+element->GetString());
2006 }
2007}
2008
22abbb27 2009
3725266c 2010void LoadLibs(){
2011
2012 gSystem->Load("libTree.so");
2013 gSystem->Load("libVMC.so");
2014 gSystem->Load("libMinuit.so");
2015 gSystem->Load("libSTEERBase.so");
2016 gSystem->Load("libESD.so");
2017 gSystem->Load("libAOD.so");
2018 gSystem->Load("libANALYSIS.so");
2019 gSystem->Load("libANALYSISalice.so");
2020 gSystem->Load("libCORRFW.so");
2021 gSystem->Load("libPWG2spectra.so");
2022
2023}
22abbb27 2024
4d4a268c 2025void RebinHistosForRatios() {
2026 // rebins all spectra histograms
2027
2028 cout << "WARNING: REBINNING HISTOS BEFORE RATIOS" << endl;
2029
2030
2031 const Float_t rebinBins[] = {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.6,1.8,2.4};
2032 Int_t nrebinBins=29;
2033
2034
2035
2036 Int_t idet = iCombInStudy;
2037 for(Int_t ipart = 0; ipart < kNPart; ipart++){
2038 for(Int_t icharge = 0; icharge < kNCharge; icharge++){
2039
2040 TH1F * h = hSpectra[idet][ipart][icharge];
2041 TString hname = h->GetName();
2042 hname += "_rebin";
2043
2044 TH1F *hrebin = new TH1F(hname, hname,nrebinBins,rebinBins);
2045 hrebin->Sumw2();
2046
2047 for(Int_t i=1;i <= h->GetNbinsX();i++){
2048 Float_t x = h->GetBinCenter(i);
2049 Int_t j=0;
2050 while(x > rebinBins[j+1]) j++;
2051 j++;
2052 hrebin->AddBinContent(j,h->GetBinContent(i));
2053
2054 Float_t err = hrebin->GetBinError(j) + h->GetBinError(i)*h->GetBinError(i);
2055 hrebin->SetBinError(j,err);
2056 }
2057
2058 for(Int_t i=1;i <= hrebin->GetNbinsX();i++){
2059 hrebin->SetBinError(i,TMath::Sqrt(hrebin->GetBinError(i)));
2060 }
2061 hSpectra[idet][ipart][icharge] = hrebin;
2062 }
2063 }
2064
2065}