]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TPC/macros/PIDCalib/THnSparseDefinitions.h
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / TPC / macros / PIDCalib / THnSparseDefinitions.h
1 #ifndef THNSPARSEDEFINITIONS_H
2 #define THNSPARSEDEFINITIONS_H
3
4 #ifndef __CINT__
5 #include "TCanvas.h"
6 #include "THnSparse.h"
7 #include "TPaveText.h"
8 #include "TString.h"
9 #include "TGraphAsymmErrors.h"
10 #include "AliPID.h"
11 #endif
12
13 #define NEW_AXES
14
15 #ifdef NEW_AXES
16   enum axesTHnSparseEta {
17     kMCpid = 0,
18     kSelectSpecies,
19     kPtpcInner,
20     kMultiplicity,
21     kDeltaPrime,
22     kEta
23   };
24 #else
25   enum axesTHnSparseEta {
26     kMCpid = 0,
27     kSelectSpecies,
28     kPtpcInner,
29     kPt,
30     kDeDx,
31     kMultiplicity,//kDelta,
32     kDeltaPrime,
33     kEta
34   };
35 #endif
36
37 enum axesTHnSparsePID {
38   kPidMCpid = 0,
39   kPidSelectSpecies,
40   kPidPt,
41   //OLD kPidDelta,
42   kPidDeltaPrime,
43   kPidCentrality,
44   kPidJetPt,
45   kPidZ,
46   kPidXi
47 };
48
49 /*OLD with TOF, p_TPC_Inner and p_vertex
50 enum axesTHnSparsePID {
51   kPidMCpid = 0,
52   kPidSelectSpecies,
53   kPidPtpcInner,
54   kPidPt,
55   kPidPvertex,
56   kPidDelta,
57   kPidDeltaPrime,
58   kPidDeltaTOF
59 };//*/
60
61 enum axesTHnSparsePIDgen {
62   kPidGenMCpid = 0,
63   kPidGenSelectSpecies,
64   kPidGenPt,
65   //OLD kPidGenDelta,
66   kPidGenDeltaPrime,
67   kPidGenCentrality,
68   kPidGenJetPt,
69   kPidGenZ,
70   kPidGenXi
71 };
72
73 enum axesTHnSparsePIDgenYield {
74   kPidGenYieldMCpid = 0,
75   kPidGenYieldPt = 1,
76   kPidGenYieldCentrality = 2,
77   kPidGenYieldJetPt = 3,
78   kPidGenYieldZ = 4,
79   kPidGenYieldXi = 5,
80   kPidGenYieldNumAxes = 6 
81 };
82
83 enum MCpid  {
84   kEl = 1,
85   kKa = 2,
86   kMu = 3,
87   kPi = 4,
88   kPr = 5,
89   kMuPlusPi = 10
90 };
91
92 enum PIDtype { 
93   kMCid = 0, 
94   kTPCid = 1, 
95   kV0idNoTOF = 2, 
96   kTPCandTOFid = 3,
97   kV0idPlusTOFaccepted = 4,
98   kV0idPlusTOFrejected = 5  
99 };
100
101 enum efficiencyAxes {
102   kEffMCID = 0, 
103   kEffTrackPt = 1, 
104   kEffTrackEta = 2, 
105   kEffTrackCharge = 3, 
106   kEffCentrality = 4, 
107   kEffJetPt = 5,
108   kEffNumAxes = 6 
109 };
110
111 enum ptResolutionAxes { 
112   kPtResJetPt = 0,
113   kPtResGenPt = 1,
114   kPtResRecPt = 2,
115   kPtResCharge = 3,
116   kPtResCentrality = 4, 
117   kPtResNumAxes = 5
118 };
119
120 enum dEdxCheckAxes {
121   kDeDxCheckPID = 0,
122   kDeDxCheckP = 1,
123   kDeDxCheckJetPt = 2,
124   kDeDxCheckEtaAbs = 3,
125   kDeDxCheckDeDx = 4,
126   kDeDxCheckNumAxes = 5 
127 };
128   
129 enum EffSteps {
130   kStepGenWithGenCuts = 0, 
131   kStepRecWithGenCuts = 1, 
132   kStepRecWithGenCutsMeasuredObs = 2,
133   kStepRecWithRecCutsMeasuredObs = 3, 
134   kStepRecWithRecCutsMeasuredObsPrimaries = 4,
135   kStepRecWithRecCutsMeasuredObsStrangenessScaled = 5,
136   kStepRecWithRecCutsPrimaries = 6,
137   kNumSteps = 7
138 };
139
140 enum chargeMode {
141   kNegCharge = -1,
142   kAllCharged = 0,
143   kPosCharge = 1
144 };
145
146 enum TOFpidInfo {
147   kNoTOFinfo = -2,
148   kNoTOFpid = -1,
149   kTOFpion = 0,
150   kTOFkaon = 1,
151   kTOFproton = 2,
152   kNumTOFspecies = 3,
153   kNumTOFpidInfoBins = 5
154 };
155
156 const TString partShortName[9] = { "El", "Ka", "Mu", "Pi", "Pr", "V0plusTOFel", "V0el", "V0pi", "V0pr" };
157
158 ///*
159 //coarser binning at high pT and in general coarser binning to get reasonable weighting for regularisation
160 const Int_t nPtBins = 53;
161 const Double_t binsPt[nPtBins+1] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45,
162              0.5, 0.55, 0.6, 0.65, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4,
163              1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4,
164              3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0,
165              9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0,
166              24.0, 30.0, 40.0, 50.0 };
167 //*/
168              
169 /*
170 //coarser binning at high pT and, in addition, coarser binning around crossings for PbPb 2.76 ATeV FINAL version
171 const Int_t nPtBins = 50;
172 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
173              0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.95, 1.1,
174              1.3, 1.4, 1.8, 2.2, 2.6, 3.0, 3.2, 3.4, 3.6, 3.8, 
175              4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 
176              11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0, 
177              50.0 };
178 */
179
180
181
182 /*
183 //coarser binning at high pT and, in addition, coarser binning around crossings for pPb 5.023 ATeV FINAL version
184 const Int_t nPtBins = 52;
185 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
186              0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95,
187              1.0, 1.1, 1.2, 1.3, 1.4, 1.8, 2.2, 2.6, 3.0, 3.2, 
188              3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 
189              8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0,
190              22.0, 30.0, 50.0 };
191 */
192
193 /*
194 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 7 TeV FINAL version
195 const Int_t nPtBins = 47;
196 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
197              0.5, 0.55, 0.6,  0.65, 0.7, 0.75, 0.8, 1.2, 1.4, 1.6,
198              1.8, 2.0, 2.6, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5,
199              5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 
200              13.0, 14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 50.0 };
201 */
202 /*
203 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 7 TeV VERY NEW version
204 const Int_t nPtBins = 46;
205 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
206              0.5, 0.55, 0.6,  0.65, 0.7, 0.75, 0.8, 1.2, 1.6,
207              2.0, 2.5, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0,
208              5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
209              14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0, 50.0 };
210 */
211 /*
212 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 7 TeV NEW version
213 const Int_t nPtBins = 47;
214 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
215              0.5, 0.55, 0.6,  0.65, 0.7, 0.75, 0.9, 1.2, 1.4, 1.6,
216              2.0, 2.5, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0,
217              5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
218              14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0, 50.0 };
219 */
220 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 7 TeV
221 /*
222 const Int_t nPtBins = 50;
223 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
224              0.5, 0.55, 0.6,  0.65, 0.7, 0.75, 0.9, 1.1, 1.2, 1.3,
225              1.4, 1.6, 1.8, 2.0, 2.9, 3.0, 3.2, 3.4, 3.6, 3.8,
226              4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0,
227              11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0,
228              50.0 };
229 */
230 /*
231 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 2.76 TeV FINAL version
232 const Int_t nPtBins = 45;
233 const Double_t binsPt[nPtBins+1] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45,
234              0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 1.05,  
235              1.2, 1.3, 1.4, 1.8, 2.9, 3.4, 3.6, 3.8, 4.0, 4.5, 
236              5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 
237              13.0, 14.0, 15.0, 16.0, 20.0, 50.0 };
238 */
239 /*
240 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 2.76 TeV NEW version
241 const Int_t nPtBins = 49;
242 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
243              0.5,  0.55, 0.6,  0.65, 0.7,  0.75, 0.8,  0.85, 0.9,
244              1.05,  1.2,  1.3 , 1.4,  1.7,  2.4, 3.2 , 3.4 , 3.6,  3.8 ,
245              4.0,  4.5 , 5.0,  5.5 , 6.0,  6.5 , 7.0,  8.0 , 9.0,  10.0,
246              11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0,
247              50.0 };
248 */
249 /*
250 // Coarser binning at high pT and, in addition, coarser binning around crossings for pp 2.76 TeV
251 const Int_t nPtBins = 50;
252 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
253              0.5,  0.55, 0.6,  0.65, 0.7,  0.75, 0.8,  0.85, 0.9,  0.95,
254              1.0,  1.1 , 1.2,  1.3 , 1.4, 1.8,  2.4, 3.2,  3.6,  3.8 ,
255              4.0,  4.5 , 5.0,  5.5 , 6.0,  6.5 , 7.0,  8.0 , 9.0,  10.0,
256              11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0,
257              50.0 };
258 */
259
260 /*
261 //coarser binning at high pT
262 const Int_t nPtBins = 60;
263 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
264              0.5,  0.55, 0.6,  0.65, 0.7,  0.75, 0.8,  0.85, 0.9,  0.95,
265              1.0,  1.1 , 1.2,  1.3 , 1.4,  1.5 , 1.6,  1.7 , 1.8,  1.9 ,
266              2.0,  2.2 , 2.4,  2.6 , 2.8,  3.0 , 3.2,  3.4 , 3.6,  3.8 ,
267              4.0,  4.5 , 5.0,  5.5 , 6.0,  6.5 , 7.0,  8.0 , 9.0,  10.0,
268              11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 22.0, 26.0, 35.0,
269              50.0 };
270 */
271              
272 /* OLD default as used in PID-Task to create THnSparses
273 const Int_t nPtBins = 68;
274 const Double_t binsPt[nPtBins+1] = {0. ,  0.05, 0.1,  0.15, 0.2,  0.25, 0.3,  0.35, 0.4,  0.45,
275                                0.5,  0.55, 0.6,  0.65, 0.7,  0.75, 0.8,  0.85, 0.9,  0.95,
276                                1.0,  1.1 , 1.2,  1.3 , 1.4,  1.5 , 1.6,  1.7 , 1.8,  1.9 ,
277                                2.0,  2.2 , 2.4,  2.6 , 2.8,  3.0 , 3.2,  3.4 , 3.6,  3.8 ,
278                                4.0,  4.5 , 5.0,  5.5 , 6.0,  6.5 , 7.0,  8.0 , 9.0,  10.0,
279                                11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0, 22.0, 24.0,
280                                26.0, 28.0, 30.0, 32.0, 34.0, 36.0, 40.0, 45.0, 50.0 };
281 */
282              
283 const Int_t nDeDxBins = 19;
284 const Double_t binsDeDx[nDeDxBins+1] = {50., 52., 54., 56., 58., 60., 65., 70., 75., 80., 
285                                         85., 90., 100., 120., 160., 200., 250., 300., 400., 600. };            
286 /*                             
287 const Int_t nDeDxBins = 35;
288 const Double_t binsDeDx[nDeDxBins+1] = {50., 51., 52., 53., 54., 55., 56., 57., 58., 59.,
289              60., 62., 64., 66., 68., 70., 72., 74., 76., 78.,
290              80., 85., 90., 95., 100., 120., 140., 160., 180., 200.,
291              250., 300., 350., 400., 500, 650.};*/
292
293 //____________________________________________________________________________________________________________________
294 Int_t getLineColor(Int_t ID) {
295   switch (ID) {
296     case kEl:
297       // El
298       return kMagenta;
299     case kKa:
300       // Ka
301       return kGreen;
302     case kMu:
303       // Mu
304       return kOrange -3;
305     case kPi:
306       // Pi
307       return kRed;
308     case kPr:
309       // Pr
310       return kBlue;
311     case kMuPlusPi:
312       // Muons plus pions
313       return kCyan;
314     default:
315       return 0;
316   }
317   
318   return 0;
319 }
320
321
322 //____________________________________________________________________________________________________________________
323 Int_t getLineColorAliPID(Int_t ID) {
324   switch (ID) {
325     case AliPID::kElectron:
326       // El
327       return kMagenta;
328     case AliPID::kKaon:
329       // Ka
330       return kGreen;
331     case AliPID::kMuon:
332       // Mu
333       return kOrange - 3;
334     case AliPID::kPion:
335       // Pi
336       return kRed;
337     case AliPID::kProton:
338       // Pr
339       return kBlue;
340     default:
341       return 0;
342   }
343   
344   return 0;
345 }
346
347
348 //____________________________________________________________________________________________________________________
349 void ClearTitleFromHistoInCanvas(TCanvas* c, Int_t padNum = -1)
350 {
351   // Remove the title from a histogram plotted in the canvase without 
352   // removing the title from the histogram itself.
353   // If padNum is >= 0, this method will be applied to the corresponding
354   // pad number
355   
356   c->Update();    // Update in order to have access to the title in the following
357
358   TPaveText* paveTextTitle = (padNum >= 0) ? (TPaveText*)c->GetPad(padNum)->FindObject("title") : (TPaveText*)c->FindObject("title");
359   if (paveTextTitle) 
360     paveTextTitle->Clear();
361 }
362
363
364 //____________________________________________________________________________________________________________________
365 Int_t GetAxisByTitle(const THnSparse* h, TString title)
366 {
367   if (!h)
368     return -1;
369   
370   for (Int_t iDim = 0; iDim < h->GetNdimensions(); iDim++) {
371     if (!title.CompareTo(h->GetAxis(iDim)->GetTitle()))
372       return iDim;
373   }
374
375   return -1;
376 }
377
378
379 //____________________________________________________________________________________________________________________
380 TGraphAsymmErrors* HistToGraph(const TString grname, const TH1 *hh, const Double_t thres=0, const TH1 *herr=0x0, const Double_t xmin=-1e10, const Double_t xmax=1e10)
381 {
382   if (!hh)
383     return 0x0;
384   
385   const Int_t nbin = hh->GetNbinsX();
386   Double_t xxs[nbin], yys[nbin], exs[nbin], eys[nbin];
387   Int_t np=0;
388   for(Int_t ii=1; ii<=nbin; ii++){
389     const Double_t iyy = hh->GetBinContent(ii);
390     if(iyy<=thres)
391       continue;
392
393     const Double_t iey = hh->GetBinError(ii);
394     if(iey<1e-15){
395       if(iyy>1e-15){
396         printf("HistToGraph warning! should be fine if this is ratio %d %e %e\n", ii, iyy, iey); //exit(1);
397       }
398       //continue;
399     }
400
401     const Double_t ixx = hh->GetBinCenter(ii);
402     if(ixx<xmin || ixx>xmax){
403       //printf("test HistToGraph rejecting ixx %e xmin %e xmax %e\n", ixx, xmin, xmax);
404       continue;
405     }
406
407     Double_t iex = 0;
408     if(herr){
409       iex = herr->GetBinContent(herr->GetXaxis()->FindBin(ixx));
410     }
411     else{
412       iex = hh->GetBinWidth(ii)/2.;
413     }
414
415     xxs[np] = ixx;
416     yys[np] = iyy;
417     exs[np] = iex;
418     eys[np] = iey;
419     np++;
420   }
421   TGraphAsymmErrors * gr = new TGraphAsymmErrors(np, xxs, yys, exs, exs, eys, eys);
422   gr->SetName(grname);
423   gr->SetMaximum(hh->GetMaximum());
424   gr->SetMinimum(hh->GetMinimum());
425   gr->GetXaxis()->SetLimits(hh->GetXaxis()->GetXmin(), hh->GetXaxis()->GetXmax());
426   
427   gr->SetLineColor(hh->GetLineColor());
428   gr->SetMarkerColor(hh->GetMarkerColor());
429   gr->SetFillStyle(hh->GetFillStyle());
430   gr->GetXaxis()->SetTitle(hh->GetXaxis()->GetTitle());
431   gr->GetYaxis()->SetTitle(hh->GetYaxis()->GetTitle());
432   return gr;
433 }
434
435 #endif