AliPhysics  c7b8e89 (c7b8e89)
EstimateSingleTrackPIDsyst.C
Go to the documentation of this file.
1 #if !defined (__CINT__) || defined (__CLING__)
2 
3 #include <Riostream.h>
4 #include <TFile.h>
5 #include <TDirectoryFile.h>
6 #include <TCanvas.h>
7 #include <TH1F.h>
8 #include <TH2F.h>
9 #include <TF1.h>
10 #include <TStyle.h>
11 #include <TString.h>
12 #include <TList.h>
13 #include <TTree.h>
14 #include <TMath.h>
15 #include <TFractionFitter.h>
16 #include <TObjArray.h>
17 #include <TDatabasePDG.h>
18 #include <TGaxis.h>
19 #include <TLegend.h>
20 #include <TLatex.h>
21 #include <vector>
22 #include <string>
23 #include <sstream>
24 #include <fstream>
25 
27 
28 #endif
29 
31 // \brief macro for estimation of PID Systematic uncertainty of the single track (pions/kaons/protons) //
32 // \main function: EstimateSingleTrackPIDsyst //
33 // \author: F. Grosa, fabrizio.grosa@cern.ch //
35 
36 using namespace std;
37 
38 //_____________________________________________________
39 //GLOBAL VARIABLES
40 //NOT TO EDIT
42 const int nPDGcodes = 6;
43 const int pdgcodes[nPDGcodes]={11,13,211,321,2212,-100};
44 const int pdgcolors[nPDGcodes]={kOrange+7,kGray,kRed,kBlue,kGreen+2,kBlack};
45 const int pdgfillcolors[nPDGcodes]={kOrange+7,kGray,kRed,kBlue,kGreen+2,kWhite};
46 const TString pdgnames[nPDGcodes]={"Electron","Muon","Pion","Kaon","Proton","All"};
47 //TO EDIT
48 const double ptlims[] = {0.3,0.5,0.75,1.,1.5,2.,3.,5.,10.};
49 const TString infileNameData = "LHC17pq.root";
50 const TString indirNameData = "PWGHF_D2H_SystNsigmaPID";
51 const TString inlistNameData = "coutputPIDhistos_ppMB_kINT7";
52 const TString infileNameMC = "LHC17l3b.root";
53 const TString indirNameMC = "PWGHF_D2H_SystNsigmaPID";
54 const TString inlistNameMC = "coutputPIDhistos_ppMB_kINT7";
55 
56 //_____________________________________________________
57 //METHOD PROTOTYPES
58 int EstimateSingleTrackPIDsyst(int maxEntries=1.e8);
59 int GetHistoParticleIndex(short pdgcode);
60 int FindPtbin(float pt, const double ptlims[], int nPtbins);
61 void ComputeEfficiency(double num, double den, double &eff, double &effunc);
62 void GetTOFFractionsFromData(int whichpart, int iPt, TH1F* hFractionMC[nPDGcodes-1], TH1F* hFractionData[nPDGcodes-1], TH1F* hNsigmaMC[nPDGcodes], TH1F* hNsigmaData, TFractionFitter *&fNsigmaFitter, vector<int> &templUsed);
63 double PDFnsigmaTPCtot(double* nsigma, double* pars);
64 void PlotQAhistos(TList* listMC, TList* listData);
65 void DivideCanvas(TCanvas* c, int nPtbins);
66 void SetStyle();
67 void SetTH1Style(TH1F* histo, int markerstyle, int markercolor, float markersize, int linewidth, int linecolor, int fillcolor, float labelsize=-1, float titlesize=-1);
68 
69 //_____________________________________________________
70 //METHOD IMPLEMENTATIONS
71 int EstimateSingleTrackPIDsyst(int maxEntries) {
72 
73  SetStyle();
74 
75  //********************************************************************************************************************************************//
76  //get pt bins
77  const int nPtbins = sizeof(ptlims)/sizeof(ptlims[0])-1;
78 
79  cout << "\n\n********************\n" << endl;
80  cout << nPtbins << " p_T bins (GeV/c):" << endl;
81  for(int iPt=0; iPt<nPtbins; iPt++) {
82  cout << ptlims[iPt]<<"-"<< ptlims[iPt+1] <<endl;
83  }
84 
85  //********************************************************************************************************************************************//
86  //define histos
87 
88  //MC truth
89  TH2F *hNsigmaTPCPionVsPtMCTrue, *hNsigmaTPCKaonVsPtMCTrue, *hNsigmaTPCProtonVsPtMCTrue;
90  TH2F *hNsigmaTOFPionVsPtMCTrue, *hNsigmaTOFKaonVsPtMCTrue, *hNsigmaTOFProtonVsPtMCTrue;
91 
92  TH1F *hNsigmaTPCPionMCTrue[nPtbins], *hNsigmaTPCKaonMCTrue[nPtbins], *hNsigmaTPCProtonMCTrue[nPtbins];
93  TH1F *hNsigmaTOFPionMCTrue[nPtbins], *hNsigmaTOFKaonMCTrue[nPtbins], *hNsigmaTOFProtonMCTrue[nPtbins];
94 
95  //MC tagged
96  TH1F *hNsigmaTPCPionMCV0tag[nPtbins][nPDGcodes], *hNsigmaTPCKaonMCKinktag[nPtbins][nPDGcodes], *hNsigmaTPCKaonMCTOFtag[nPtbins][nPDGcodes], *hNsigmaTPCProtonMCV0tag[nPtbins][nPDGcodes];
97  TH1F *hNsigmaTOFPionMCV0tag[nPtbins][nPDGcodes], *hNsigmaTOFKaonMCKinktag[nPtbins][nPDGcodes], *hNsigmaTOFKaonMCTPCtag[nPtbins][nPDGcodes], *hNsigmaTOFProtonMCV0tag[nPtbins][nPDGcodes];
98 
99  //data tagged
100  TH1F *hNsigmaTPCPionDataV0tag[nPtbins], *hNsigmaTPCKaonDataKinktag[nPtbins], *hNsigmaTPCKaonDataTOFtag[nPtbins], *hNsigmaTPCProtonDataV0tag[nPtbins];
101  TH1F *hNsigmaTOFPionDataV0tag[nPtbins], *hNsigmaTOFKaonDataKinktag[nPtbins], *hNsigmaTOFKaonDataTPCtag[nPtbins], *hNsigmaTOFProtonDataV0tag[nPtbins];
102 
103  for(int iPt=0; iPt<nPtbins; iPt++) {
104  for(int iPart=0; iPart<nPDGcodes; iPart++) {
105  hNsigmaTPCPionMCV0tag[iPt][iPart] = new TH1F(Form("hNsigmaTPCPionMCV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(#pi);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
106  hNsigmaTPCKaonMCKinktag[iPt][iPart] = new TH1F(Form("hNsigmaTPCKaonMCKinktag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
107  hNsigmaTPCKaonMCTOFtag[iPt][iPart] = new TH1F(Form("hNsigmaTPCKaonMCTOFtag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
108  hNsigmaTPCProtonMCV0tag[iPt][iPart] = new TH1F(Form("hNsigmaTPCProtonMCV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(p);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
109 
110  hNsigmaTOFPionMCV0tag[iPt][iPart] = new TH1F(Form("hNsigmaTOFPionMCV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(#pi);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
111  hNsigmaTOFKaonMCKinktag[iPt][iPart] = new TH1F(Form("hNsigmaTOFKaonMCKinktag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
112  hNsigmaTOFKaonMCTPCtag[iPt][iPart] = new TH1F(Form("hNsigmaTOFKaonMCTPCtag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
113  hNsigmaTOFProtonMCV0tag[iPt][iPart] = new TH1F(Form("hNsigmaTOFProtonMCV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(p);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
114 
115  SetTH1Style(hNsigmaTPCPionMCV0tag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
116  SetTH1Style(hNsigmaTPCKaonMCKinktag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
117  SetTH1Style(hNsigmaTPCKaonMCTOFtag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
118  SetTH1Style(hNsigmaTPCProtonMCV0tag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
119  SetTH1Style(hNsigmaTOFPionMCV0tag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
120  SetTH1Style(hNsigmaTOFKaonMCKinktag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
121  SetTH1Style(hNsigmaTOFKaonMCTPCtag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
122  SetTH1Style(hNsigmaTOFProtonMCV0tag[iPt][iPart],kFullCircle,pdgcolors[iPart],0.6,2,pdgcolors[iPart],pdgfillcolors[iPart],0.055,0.06);
123  }
124 
125  hNsigmaTPCPionDataV0tag[iPt] = new TH1F(Form("hNsigmaTPCPionDataV0tag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(#pi);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
126  hNsigmaTPCKaonDataKinktag[iPt] = new TH1F(Form("hNsigmaTPCKaonDataKinktag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
127  hNsigmaTPCKaonDataTOFtag[iPt] = new TH1F(Form("hNsigmaTPCKaonDataTOFtag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
128  hNsigmaTPCProtonDataV0tag[iPt] = new TH1F(Form("hNsigmaTPCProtonDataV0tag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TPC}(p);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
129 
130  hNsigmaTOFPionDataV0tag[iPt] = new TH1F(Form("hNsigmaTOFPionDataV0tag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(#pi);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
131  hNsigmaTOFKaonDataKinktag[iPt] = new TH1F(Form("hNsigmaTOFKaonDataKinktag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
132  hNsigmaTOFKaonDataTPCtag[iPt] = new TH1F(Form("hNsigmaTOFKaonDataTPCtag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(K);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
133  hNsigmaTOFProtonDataV0tag[iPt] = new TH1F(Form("hNsigmaTOFProtonDataV0tag_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),Form("%0.2f < #it{p}_{T} < %0.2f GeV/#it{c};N_{#sigma}^{TOF}(p);Normalised entries",ptlims[iPt],ptlims[iPt+1]),1000,-50,50);
134 
135  SetTH1Style(hNsigmaTPCPionDataV0tag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
136  SetTH1Style(hNsigmaTPCKaonDataKinktag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
137  SetTH1Style(hNsigmaTPCKaonDataTOFtag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
138  SetTH1Style(hNsigmaTPCProtonDataV0tag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
139  SetTH1Style(hNsigmaTOFPionDataV0tag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
140  SetTH1Style(hNsigmaTOFKaonDataKinktag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
141  SetTH1Style(hNsigmaTOFKaonDataTPCtag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
142  SetTH1Style(hNsigmaTOFProtonDataV0tag[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
143  }
144 
145  //********************************************************************************************************************************************//
146  //load MC inputs
147 
148  TFile* infileMC = TFile::Open(infileNameMC.Data());
149  if(!infileMC || !infileMC->IsOpen()) return 2;
150  TDirectoryFile* indirMC = (TDirectoryFile*)infileMC->Get(indirNameMC.Data());
151  if(!indirMC) return 3;
152  TList* listMC = (TList*)indirMC->Get(inlistNameMC.Data());
153  hNsigmaTPCPionVsPtMCTrue = (TH2F*)listMC->FindObject("fHistNsigmaTPCvsPt_Pion");
154  hNsigmaTPCKaonVsPtMCTrue = (TH2F*)listMC->FindObject("fHistNsigmaTPCvsPt_Kaon");
155  hNsigmaTPCProtonVsPtMCTrue = (TH2F*)listMC->FindObject("fHistNsigmaTPCvsPt_Proton");
156  hNsigmaTOFPionVsPtMCTrue = (TH2F*)listMC->FindObject("fHistNsigmaTOFvsPt_Pion");
157  hNsigmaTOFKaonVsPtMCTrue = (TH2F*)listMC->FindObject("fHistNsigmaTOFvsPt_Kaon");
158  hNsigmaTOFProtonVsPtMCTrue = (TH2F*)listMC->FindObject("fHistNsigmaTOFvsPt_Proton");
159  TTree* treePIDMC = (TTree*)indirMC->Get("fPIDtree");
160  if(!treePIDMC) return 4;
161  treePIDMC->SetName("treePIDMC");
162 
163  for(int iPt=0; iPt<nPtbins; iPt++) {
164  int ptbinmin = hNsigmaTPCPionVsPtMCTrue->GetXaxis()->FindBin(ptlims[iPt]*1.0001);
165  int ptbinmax = hNsigmaTPCPionVsPtMCTrue->GetXaxis()->FindBin(ptlims[iPt+1]*0.9999);
166 
167  hNsigmaTPCPionMCTrue[iPt] = (TH1F*)hNsigmaTPCPionVsPtMCTrue->ProjectionY(Form("hNsigmaTPCPionMCTrue_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),ptbinmin,ptbinmax);
168  hNsigmaTPCKaonMCTrue[iPt] = (TH1F*)hNsigmaTPCKaonVsPtMCTrue->ProjectionY(Form("hNsigmaTPCKaonMCTrue_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),ptbinmin,ptbinmax);
169  hNsigmaTPCProtonMCTrue[iPt] = (TH1F*)hNsigmaTPCProtonVsPtMCTrue->ProjectionY(Form("hNsigmaTPCProtonMCTrue_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),ptbinmin,ptbinmax);
170 
171  hNsigmaTOFPionMCTrue[iPt] = (TH1F*)hNsigmaTOFPionVsPtMCTrue->ProjectionY(Form("hNsigmaTOFPionMCTrue_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),ptbinmin,ptbinmax);
172  hNsigmaTOFKaonMCTrue[iPt] = (TH1F*)hNsigmaTOFKaonVsPtMCTrue->ProjectionY(Form("hNsigmaTOFKaonMCTrue_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),ptbinmin,ptbinmax);
173  hNsigmaTOFProtonMCTrue[iPt] = (TH1F*)hNsigmaTOFProtonVsPtMCTrue->ProjectionY(Form("hNsigmaTOFProtonMCTrue_p%0.f_%0.f",ptlims[iPt]*10,ptlims[iPt+1]*10),ptbinmin,ptbinmax);
174 
175  SetTH1Style(hNsigmaTPCPionMCTrue[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
176  SetTH1Style(hNsigmaTPCKaonMCTrue[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
177  SetTH1Style(hNsigmaTPCProtonMCTrue[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
178  SetTH1Style(hNsigmaTOFPionMCTrue[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
179  SetTH1Style(hNsigmaTOFKaonMCTrue[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
180  SetTH1Style(hNsigmaTOFProtonMCTrue[iPt],kFullCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],kWhite,0.055,0.06);
181  }
182 
183  short pdgMC = -1;
184  unsigned char tagMC = 0;
185  short n_sigma_TPC_pi_MC = -999;
186  short n_sigma_TPC_K_MC = -999;
187  short n_sigma_TPC_p_MC = -999;
188  short n_sigma_TOF_pi_MC = -999;
189  short n_sigma_TOF_K_MC = -999;
190  short n_sigma_TOF_p_MC = -999;
191  unsigned short pT_MC = 0;
192 
193  treePIDMC->SetBranchAddress("PDGcode",&pdgMC);
194  treePIDMC->SetBranchAddress("tag",&tagMC);
195  treePIDMC->SetBranchAddress("n_sigma_TPC_pi",&n_sigma_TPC_pi_MC);
196  treePIDMC->SetBranchAddress("n_sigma_TPC_K",&n_sigma_TPC_K_MC);
197  treePIDMC->SetBranchAddress("n_sigma_TPC_p",&n_sigma_TPC_p_MC);
198  treePIDMC->SetBranchAddress("n_sigma_TOF_pi",&n_sigma_TOF_pi_MC);
199  treePIDMC->SetBranchAddress("n_sigma_TOF_K",&n_sigma_TOF_K_MC);
200  treePIDMC->SetBranchAddress("n_sigma_TOF_p",&n_sigma_TOF_p_MC);
201  treePIDMC->SetBranchAddress("pT",&pT_MC);
202 
203  cout << "\n********** Loop on MC tracks **********\n" << endl;
204 
205  for(int iEntry=0; iEntry<treePIDMC->GetEntriesFast(); iEntry++) {
206 
207  if(iEntry>maxEntries) break;
208 
209  if(iEntry%1000000==0 || iEntry==treePIDMC->GetEntriesFast()-1) cout << Form("MC Track %010d",iEntry) << endl;
210 
211  treePIDMC->GetEntry(iEntry);
212  int iPt = FindPtbin(static_cast<float>(pT_MC)/1000,ptlims,nPtbins);
213  if(iPt<0 || iPt>=static_cast<int>(nPtbins)) continue;
214 
216  hNsigmaTPCPionMCV0tag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TPC_pi_MC)/100);
217  hNsigmaTOFPionMCV0tag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TOF_pi_MC)/100);
218  }
220  hNsigmaTPCKaonMCKinktag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TPC_K_MC)/100);
221  hNsigmaTOFKaonMCKinktag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TOF_K_MC)/100);
222  }
224  hNsigmaTPCKaonMCTOFtag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TPC_K_MC)/100);
225  }
227  hNsigmaTOFKaonMCTPCtag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TOF_K_MC)/100);
228  }
230  hNsigmaTPCProtonMCV0tag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TPC_p_MC)/100);
231  hNsigmaTOFProtonMCV0tag[iPt][kAll]->Fill(static_cast<float>(n_sigma_TOF_p_MC)/100);
232  }
233 
234  int iHisto = GetHistoParticleIndex(pdgMC);
235  if(iHisto>=kElectron && iHisto<kAll) {
236  if((tagMC&AliAnalysisTaskSEHFSystPID::kIsPionFromK0s || tagMC&AliAnalysisTaskSEHFSystPID::kIsPionFromL)) {
237  hNsigmaTPCPionMCV0tag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TPC_pi_MC)/100);
238  hNsigmaTOFPionMCV0tag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TOF_pi_MC)/100);
239  }
240  if(tagMC&AliAnalysisTaskSEHFSystPID::kIsKaonFromKinks) {
241  hNsigmaTPCKaonMCKinktag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TPC_K_MC)/100);
242  hNsigmaTOFKaonMCKinktag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TOF_K_MC)/100);
243  }
244  if(tagMC&AliAnalysisTaskSEHFSystPID::kIsKaonFromTOF) {
245  hNsigmaTPCKaonMCTOFtag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TPC_K_MC)/100);
246  }
247  if(tagMC&AliAnalysisTaskSEHFSystPID::kIsKaonFromTPC) {
248  hNsigmaTOFKaonMCTPCtag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TOF_K_MC)/100);
249  }
250  if(tagMC&AliAnalysisTaskSEHFSystPID::kIsProtonFromL) {
251  hNsigmaTPCProtonMCV0tag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TPC_p_MC)/100);
252  hNsigmaTOFProtonMCV0tag[iPt][iHisto]->Fill(static_cast<float>(n_sigma_TOF_p_MC)/100);
253  }
254  }
255  }
256 
257  //********************************************************************************************************************************************//
258  //load data inputs
259 
260  TFile* infileData = TFile::Open(infileNameData.Data());
261  if(!infileData || !infileData->IsOpen()) return 5;
262  TDirectoryFile* indirData = (TDirectoryFile*)infileData->Get(indirNameData.Data());
263  if(!indirData) return 6;
264  TList* listData = (TList*)indirData->Get(inlistNameData.Data());
265  TTree* treePIDData = (TTree*)indirData->Get("fPIDtree");
266  if(!treePIDData) return 7;
267  treePIDData->SetName("treePIDData");
268 
269  unsigned char tagData = 0;
270  short n_sigma_TPC_pi_Data = -999;
271  short n_sigma_TPC_K_Data = -999;
272  short n_sigma_TPC_p_Data = -999;
273  short n_sigma_TOF_pi_Data = -999;
274  short n_sigma_TOF_K_Data = -999;
275  short n_sigma_TOF_p_Data = -999;
276  unsigned short pT_Data = 0;
277 
278  treePIDData->SetBranchAddress("tag",&tagData);
279  treePIDData->SetBranchAddress("n_sigma_TPC_pi",&n_sigma_TPC_pi_Data);
280  treePIDData->SetBranchAddress("n_sigma_TPC_K",&n_sigma_TPC_K_Data);
281  treePIDData->SetBranchAddress("n_sigma_TPC_p",&n_sigma_TPC_p_Data);
282  treePIDData->SetBranchAddress("n_sigma_TOF_pi",&n_sigma_TOF_pi_Data);
283  treePIDData->SetBranchAddress("n_sigma_TOF_K",&n_sigma_TOF_K_Data);
284  treePIDData->SetBranchAddress("n_sigma_TOF_p",&n_sigma_TOF_p_Data);
285  treePIDData->SetBranchAddress("pT",&pT_Data);
286 
287  cout << "\n********** Loop on data tracks **********\n" << endl;
288 
289  TH2F* hNsigmaTPCKaonTPCtagged = new TH2F("hNsigmaTPCKaonTPCtagged",";#it{p}_{T} (GeV/#it{c});N_{#sigma}(K)",100,0.,10.,1000,-50,50.);
290  hNsigmaTPCKaonTPCtagged->SetMarkerColor(kBlue);
291  TH2F* hNsigmaTPCKaon = new TH2F("hNsigmaTPCKaon",";#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TPC}(K)",100,0.,10.,1000,-50,50.);
292  hNsigmaTPCKaon->SetMarkerColor(kBlack);
293  TH2F* hNsigmaTOFKaonTOFtagged = new TH2F("hNsigmaTOFKaonTOFtagged",";#it{p}_{T} (GeV/#it{c});N_{#sigma}(K)",100,0.,10.,1000,-50,50.);
294  hNsigmaTOFKaonTOFtagged->SetMarkerColor(kBlue);
295  TH2F* hNsigmaTOFKaon = new TH2F("hNsigmaTOFKaon",";#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(K)",100,0.,10.,1000,-50,50.);
296  hNsigmaTOFKaon->SetMarkerColor(kBlack);
297 
298  for(int iEntry=0; iEntry<treePIDData->GetEntriesFast(); iEntry++) {
299 
300  if(iEntry>maxEntries) break;
301 
302  if(iEntry%1000000==0 || iEntry==treePIDData->GetEntriesFast()-1) cout << Form("Data Track %010d",iEntry) << endl;
303 
304  treePIDData->GetEntry(iEntry);
305  int iPt = FindPtbin(static_cast<float>(pT_Data)/1000,ptlims,nPtbins);
306  if(iPt<0 || iPt>=static_cast<int>(nPtbins)) continue;
307  hNsigmaTPCKaon->Fill(static_cast<float>(pT_Data)/1000,static_cast<float>(n_sigma_TPC_K_Data)/100);
308  hNsigmaTOFKaon->Fill(static_cast<float>(pT_Data)/1000,static_cast<float>(n_sigma_TOF_K_Data)/100);
310  hNsigmaTPCPionDataV0tag[iPt]->Fill(static_cast<float>(n_sigma_TPC_pi_Data)/100);
311  hNsigmaTOFPionDataV0tag[iPt]->Fill(static_cast<float>(n_sigma_TOF_pi_Data)/100);
312  }
314  hNsigmaTPCKaonDataKinktag[iPt]->Fill(static_cast<float>(n_sigma_TPC_K_Data)/100);
315  hNsigmaTOFKaonDataKinktag[iPt]->Fill(static_cast<float>(n_sigma_TOF_K_Data)/100);
316  }
318  hNsigmaTPCKaonDataTOFtag[iPt]->Fill(static_cast<float>(n_sigma_TPC_K_Data)/100);
319  hNsigmaTOFKaonTOFtagged->Fill(static_cast<float>(pT_Data)/1000,static_cast<float>(n_sigma_TOF_K_Data)/100);
320  }
322  hNsigmaTOFKaonDataTPCtag[iPt]->Fill(static_cast<float>(n_sigma_TOF_K_Data)/100);
323  hNsigmaTPCKaonTPCtagged->Fill(static_cast<float>(pT_Data)/1000,static_cast<float>(n_sigma_TPC_K_Data)/100);
324  }
326  hNsigmaTPCProtonDataV0tag[iPt]->Fill(static_cast<float>(n_sigma_TPC_p_Data)/100);
327  hNsigmaTOFProtonDataV0tag[iPt]->Fill(static_cast<float>(n_sigma_TOF_p_Data)/100);
328  }
329  }
330  cout << "\n********************\n" << endl;
331 
332  //********************************************************************************************************************************************//
333  //check QA plots
334  PlotQAhistos(listMC,listData);
335 
336  TLatex* latAll = new TLatex();
337  latAll->SetNDC();
338  latAll->SetTextFont(42);
339  latAll->SetTextColor(kBlack);
340  latAll->SetTextSize(0.045);
341  TLatex* latTag = new TLatex();
342  latTag->SetNDC();
343  latTag->SetTextFont(42);
344  latTag->SetTextColor(kBlue);
345  latTag->SetTextSize(0.045);
346 
347  TCanvas* cProva = new TCanvas("cProva","",1920,1080);
348  cProva->Divide(2,1);
349  cProva->cd(1);
350  hNsigmaTPCKaon->DrawCopy("");
351  hNsigmaTPCKaonTPCtagged->DrawCopy("same");
352  latAll->DrawLatex(0.65,0.25,"All tags");
353  latTag->DrawLatex(0.65,0.2,"TPC tag");
354  cProva->cd(2);
355  hNsigmaTOFKaon->DrawCopy("");
356  hNsigmaTOFKaonTOFtagged->DrawCopy("same");
357  latAll->DrawLatex(0.65,0.25,"All tags");
358  latTag->DrawLatex(0.65,0.2,"TOF tag");
359 
360  cProva->SaveAs("TPC_TOF_tag.pdf");
361  cProva->SaveAs("TPC_TOF_tag.png");
362 
363  //********************************************************************************************************************************************//
364  //compute Fraction and contamination in MC
365  double intNsigmaTPCPionMCV0tag[nPtbins][nPDGcodes];
366  double intNsigmaTPCKaonMCKinktag[nPtbins][nPDGcodes];
367  double intNsigmaTPCKaonMCTOFtag[nPtbins][nPDGcodes];
368  double intNsigmaTPCProtonMCV0tag[nPtbins][nPDGcodes];
369  double intNsigmaTOFPionMCV0tag[nPtbins][nPDGcodes];
370  double intNsigmaTOFKaonMCKinktag[nPtbins][nPDGcodes];
371  double intNsigmaTOFKaonMCTPCtag[nPtbins][nPDGcodes];
372  double intNsigmaTOFProtonMCV0tag[nPtbins][nPDGcodes];
373 
374  double intNsigmaTPCPionDataV0tag[nPtbins];
375  double intNsigmaTPCKaonDataKinktag[nPtbins];
376  double intNsigmaTPCKaonDataTOFtag[nPtbins];
377  double intNsigmaTPCProtonDataV0tag[nPtbins];
378  double intNsigmaTOFPionDataV0tag[nPtbins];
379  double intNsigmaTOFKaonDataKinktag[nPtbins];
380  double intNsigmaTOFKaonDataTPCtag[nPtbins];
381  double intNsigmaTOFProtonDataV0tag[nPtbins];
382 
383  for(int iPt=0; iPt<nPtbins; iPt++) {
384  for(int iPart=kElectron; iPart<=kAll; iPart++) {
385  intNsigmaTPCPionMCV0tag[iPt][iPart] = hNsigmaTPCPionMCV0tag[iPt][iPart]->Integral() / hNsigmaTPCPionMCV0tag[iPt][iPart]->GetBinWidth(1);
386  intNsigmaTPCKaonMCKinktag[iPt][iPart] = hNsigmaTPCKaonMCKinktag[iPt][iPart]->Integral() / hNsigmaTPCKaonMCKinktag[iPt][iPart]->GetBinWidth(1);
387  intNsigmaTPCKaonMCTOFtag[iPt][iPart] = hNsigmaTPCKaonMCTOFtag[iPt][iPart]->Integral() / hNsigmaTPCKaonMCTOFtag[iPt][iPart]->GetBinWidth(1);
388  intNsigmaTPCProtonMCV0tag[iPt][iPart] = hNsigmaTPCProtonMCV0tag[iPt][iPart]->Integral() / hNsigmaTPCProtonMCV0tag[iPt][iPart]->GetBinWidth(1);
389  intNsigmaTOFPionMCV0tag[iPt][iPart] = hNsigmaTOFPionMCV0tag[iPt][iPart]->Integral() / hNsigmaTOFPionMCV0tag[iPt][iPart]->GetBinWidth(1);
390  intNsigmaTOFKaonMCKinktag[iPt][iPart] = hNsigmaTOFKaonMCKinktag[iPt][iPart]->Integral() / hNsigmaTOFKaonMCKinktag[iPt][iPart]->GetBinWidth(1);
391  intNsigmaTOFKaonMCTPCtag[iPt][iPart] = hNsigmaTOFKaonMCTPCtag[iPt][iPart]->Integral() / hNsigmaTOFKaonMCTPCtag[iPt][iPart]->GetBinWidth(1);
392  intNsigmaTOFProtonMCV0tag[iPt][iPart] = hNsigmaTOFProtonMCV0tag[iPt][iPart]->Integral() / hNsigmaTOFProtonMCV0tag[iPt][iPart]->GetBinWidth(1);
393  }
394 
395  intNsigmaTPCPionDataV0tag[iPt] = hNsigmaTPCPionDataV0tag[iPt]->Integral() / hNsigmaTPCPionDataV0tag[iPt]->GetBinWidth(1);
396  intNsigmaTPCKaonDataKinktag[iPt] = hNsigmaTPCKaonDataKinktag[iPt]->Integral() / hNsigmaTPCKaonDataKinktag[iPt]->GetBinWidth(1);
397  intNsigmaTPCKaonDataTOFtag[iPt] = hNsigmaTPCKaonDataTOFtag[iPt]->Integral() / hNsigmaTPCKaonDataTOFtag[iPt]->GetBinWidth(1);
398  intNsigmaTPCProtonDataV0tag[iPt] = hNsigmaTPCProtonDataV0tag[iPt]->Integral() / hNsigmaTPCProtonDataV0tag[iPt]->GetBinWidth(1);
399  intNsigmaTOFPionDataV0tag[iPt] = hNsigmaTOFPionDataV0tag[iPt]->Integral() / hNsigmaTOFPionDataV0tag[iPt]->GetBinWidth(1);
400  intNsigmaTOFKaonDataKinktag[iPt] = hNsigmaTOFKaonDataKinktag[iPt]->Integral() / hNsigmaTOFKaonDataKinktag[iPt]->GetBinWidth(1);
401  intNsigmaTOFKaonDataTPCtag[iPt] = hNsigmaTOFKaonDataTPCtag[iPt]->Integral() / hNsigmaTOFKaonDataTPCtag[iPt]->GetBinWidth(1);
402  intNsigmaTOFProtonDataV0tag[iPt] = hNsigmaTOFProtonDataV0tag[iPt]->Integral() / hNsigmaTOFProtonDataV0tag[iPt]->GetBinWidth(1);
403  }
404 
405  TH1F *hFractionTPCPionMCV0tag[nPDGcodes-1], *hFractionTPCKaonMCKinktag[nPDGcodes-1], *hFractionTPCKaonMCTOFtag[nPDGcodes-1], *hFractionTPCProtonMCV0tag[nPDGcodes-1];
406  TH1F *hFractionTOFPionMCV0tag[nPDGcodes-1], *hFractionTOFKaonMCKinktag[nPDGcodes-1], *hFractionTOFKaonMCTPCtag[nPDGcodes-1], *hFractionTOFProtonMCV0tag[nPDGcodes-1];
407 
408  for(int iPart=kElectron; iPart<=kProton; iPart++) {
409  hFractionTPCPionMCV0tag[iPart] = new TH1F(Form("hFractionTPCPionMCV0tag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
410  hFractionTOFPionMCV0tag[iPart] = new TH1F(Form("hFractionTOFPionMCV0tag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
411  hFractionTPCKaonMCKinktag[iPart] = new TH1F(Form("hFractionTPCKaonMCKinktag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
412  hFractionTPCKaonMCTOFtag[iPart] = new TH1F(Form("hFractionTPCKaonMCTOFtag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
413  hFractionTOFKaonMCKinktag[iPart] = new TH1F(Form("hFractionTOFKaonMCKinktag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
414  hFractionTOFKaonMCTPCtag[iPart] = new TH1F(Form("hFractionTOFKaonMCTPCtag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
415  hFractionTPCProtonMCV0tag[iPart] = new TH1F(Form("hFractionTPCProtonMCV0tag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
416  hFractionTOFProtonMCV0tag[iPart] = new TH1F(Form("hFractionTOFProtonMCV0tag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Contamination",nPtbins,ptlims);
417 
418  SetTH1Style(hFractionTPCPionMCV0tag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
419  SetTH1Style(hFractionTOFPionMCV0tag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
420  SetTH1Style(hFractionTPCKaonMCKinktag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
421  SetTH1Style(hFractionTPCKaonMCTOFtag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
422  SetTH1Style(hFractionTOFKaonMCKinktag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
423  SetTH1Style(hFractionTOFKaonMCTPCtag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
424  SetTH1Style(hFractionTPCProtonMCV0tag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
425  SetTH1Style(hFractionTOFProtonMCV0tag[iPart],kFullCircle,pdgcolors[iPart],1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
426  }
427 
428  for(int iPt=0; iPt<nPtbins; iPt++) {
429  double eff=-1, unc=-1;
430  for(int iPart=kElectron; iPart<=kProton; iPart++) {
431  ComputeEfficiency(intNsigmaTPCPionMCV0tag[iPt][iPart],intNsigmaTPCPionMCV0tag[iPt][kAll],eff,unc);
432  hFractionTPCPionMCV0tag[iPart]->SetBinContent(iPt+1,eff);
433  hFractionTPCPionMCV0tag[iPart]->SetBinError(iPt+1,unc);
434 
435  ComputeEfficiency(intNsigmaTOFPionMCV0tag[iPt][iPart],intNsigmaTOFPionMCV0tag[iPt][kAll],eff,unc);
436  hFractionTOFPionMCV0tag[iPart]->SetBinContent(iPt+1,eff);
437  hFractionTOFPionMCV0tag[iPart]->SetBinError(iPt+1,unc);
438 
439  ComputeEfficiency(intNsigmaTPCKaonMCKinktag[iPt][iPart],intNsigmaTPCKaonMCKinktag[iPt][kAll],eff,unc);
440  hFractionTPCKaonMCKinktag[iPart]->SetBinContent(iPt+1,eff);
441  hFractionTPCKaonMCKinktag[iPart]->SetBinError(iPt+1,unc);
442 
443  ComputeEfficiency(intNsigmaTPCKaonMCTOFtag[iPt][iPart],intNsigmaTPCKaonMCTOFtag[iPt][kAll],eff,unc);
444  hFractionTPCKaonMCTOFtag[iPart]->SetBinContent(iPt+1,eff);
445  hFractionTPCKaonMCTOFtag[iPart]->SetBinError(iPt+1,unc);
446 
447  ComputeEfficiency(intNsigmaTOFKaonMCKinktag[iPt][iPart],intNsigmaTOFKaonMCKinktag[iPt][kAll],eff,unc);
448  hFractionTOFKaonMCKinktag[iPart]->SetBinContent(iPt+1,eff);
449  hFractionTOFKaonMCKinktag[iPart]->SetBinError(iPt+1,unc);
450 
451  ComputeEfficiency(intNsigmaTOFKaonMCTPCtag[iPt][iPart],intNsigmaTOFKaonMCTPCtag[iPt][kAll],eff,unc);
452  hFractionTOFKaonMCTPCtag[iPart]->SetBinContent(iPt+1,eff);
453  hFractionTOFKaonMCTPCtag[iPart]->SetBinError(iPt+1,unc);
454 
455  ComputeEfficiency(intNsigmaTPCProtonMCV0tag[iPt][iPart],intNsigmaTPCProtonMCV0tag[iPt][kAll],eff,unc);
456  hFractionTPCProtonMCV0tag[iPart]->SetBinContent(iPt+1,eff);
457  hFractionTPCProtonMCV0tag[iPart]->SetBinError(iPt+1,unc);
458 
459  ComputeEfficiency(intNsigmaTOFProtonMCV0tag[iPt][iPart],intNsigmaTOFProtonMCV0tag[iPt][kAll],eff,unc);
460  hFractionTOFProtonMCV0tag[iPart]->SetBinContent(iPt+1,eff);
461  hFractionTOFProtonMCV0tag[iPart]->SetBinError(iPt+1,unc);
462  }
463  }
464 
465  TLegend* legFracMC = new TLegend(0.2,0.4,0.45,0.7);
466  legFracMC->SetTextSize(0.05);
467  for(int iPart=kElectron; iPart<=kProton; iPart++) {
468  legFracMC->AddEntry(hFractionTOFProtonMCV0tag[iPart],pdgnames[iPart].Data(),"lpe");
469  }
470 
471  TCanvas* cFractionTPCMC = new TCanvas("cFractionTPCMC","cFractionTPCMC",1920,1080);
472  cFractionTPCMC->Divide(2,2);
473  cFractionTPCMC->cd(1)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TPC #pi from K_{s}^{0};#it{p}_{T} (GeV/#it{c});Purity / Contamination");
474  cFractionTPCMC->cd(1)->SetLogy();
475  cFractionTPCMC->cd(1)->SetLogx();
476  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTPCPionMCV0tag[iPart]->Draw("same");
477  legFracMC->Draw("same");
478 
479  cFractionTPCMC->cd(2)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TPC K from kinks;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
480  cFractionTPCMC->cd(2)->SetLogy();
481  cFractionTPCMC->cd(2)->SetLogx();
482  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTPCKaonMCKinktag[iPart]->Draw("same");
483 
484  cFractionTPCMC->cd(3)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TPC K TOF tagged;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
485  cFractionTPCMC->cd(3)->SetLogy();
486  cFractionTPCMC->cd(3)->SetLogx();
487  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTPCKaonMCTOFtag[iPart]->Draw("same");
488 
489  cFractionTPCMC->cd(4)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TPC p from #Lambda;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
490  cFractionTPCMC->cd(4)->SetLogy();
491  cFractionTPCMC->cd(4)->SetLogx();
492  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTPCProtonMCV0tag[iPart]->Draw("same");
493 
494  TCanvas* cFractionTOFMC = new TCanvas("cFractionTOFMC","cFractionTOFMC",1920,1080);
495  cFractionTOFMC->Divide(2,2);
496  cFractionTOFMC->cd(1)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TOF #pi from K_{s}^{0};#it{p}_{T} (GeV/#it{c});Purity / Contamination");
497  cFractionTOFMC->cd(1)->SetLogy();
498  cFractionTOFMC->cd(1)->SetLogx();
499  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTOFPionMCV0tag[iPart]->Draw("same");
500  legFracMC->Draw("same");
501 
502  cFractionTOFMC->cd(2)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TOF K from kinks;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
503  cFractionTOFMC->cd(2)->SetLogy();
504  cFractionTOFMC->cd(2)->SetLogx();
505  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTOFKaonMCKinktag[iPart]->Draw("same");
506 
507  cFractionTOFMC->cd(3)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TOF K TPC tag;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
508  cFractionTOFMC->cd(3)->SetLogy();
509  cFractionTOFMC->cd(3)->SetLogx();
510  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTOFKaonMCTPCtag[iPart]->Draw("same");
511 
512  cFractionTOFMC->cd(4)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TOF p from #Lambda;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
513  cFractionTOFMC->cd(4)->SetLogy();
514  cFractionTOFMC->cd(45)->SetLogx();
515  for(int iPart=kElectron; iPart<=kProton; iPart++) hFractionTOFProtonMCV0tag[iPart]->Draw("same");
516 
517  //********************************************************************************************************************************************//
518  //compute fractions in data (only TOF)
519 
520  TFractionFitter *fNsigmaTOFKaonTPCtagFitter[nPtbins];
521  TFractionFitter *fNsigmaTOFProtonV0tagFitter[nPtbins];
522  TH1F *hFractionTOFKaonDataTPCtag[nPDGcodes-1];
523  TH1F *hFractionTOFProtonDataV0tag[nPDGcodes-1];
524  TH1F *hNsigmaTOFKaonDataTPCtag_Fit[nPtbins][nPDGcodes];
525  TH1F *hNsigmaTOFProtonDataV0tag_Fit[nPtbins][nPDGcodes];
526  for(int iPart=kElectron; iPart<=kProton; iPart++) {
527  hFractionTOFKaonDataTPCtag[iPart] = new TH1F(Form("hFractionTOFKaonDataTPCtag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Fraction",nPtbins,ptlims);
528  hFractionTOFProtonDataV0tag[iPart] = new TH1F(Form("hFractionTOFProtonDataV0tag_%s",pdgnames[iPart].Data()),";#it{p}_{T} (GeV/#it{c});Fraction",nPtbins,ptlims);
529  SetTH1Style(hFractionTOFKaonDataTPCtag[iPart],kOpenSquare,pdgcolors[iPart]+1,1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
530  SetTH1Style(hFractionTOFProtonDataV0tag[iPart],kOpenSquare,pdgcolors[iPart]+1,1.,2,pdgcolors[iPart],kWhite,0.045,0.05);
531  }
532 
533  TCanvas* cFitResultTOFKaonFromTPCtag = new TCanvas("cFitResultTOFKaonFromTPCtag","cFitResultTOFKaonFromTPCtag",1920,1080);
534  DivideCanvas(cFitResultTOFKaonFromTPCtag,nPtbins);
535  TCanvas* cFitResultTOFProtonFromV0tag = new TCanvas("cFitResultTOFProtonFromV0tag","cFitResultTOFProtonFromV0tag",1920,1080);
536  DivideCanvas(cFitResultTOFProtonFromV0tag,nPtbins);
537  TCanvas* cTOFFractionData = new TCanvas("cTOFFractionData","cTOFFractionData",1920,1080);
538  cTOFFractionData->Divide(3,1);
539 
540  TLegend* legTOFFitter = new TLegend(0.14,0.62,0.52,0.86);
541  legTOFFitter->SetTextSize(0.04);
542  legTOFFitter->AddEntry(hNsigmaTOFKaonDataTPCtag[0],"Data","p");
543  for(int iPart=kElectron; iPart<=kProton; iPart++) {
544  legTOFFitter->AddEntry(hNsigmaTOFKaonMCTPCtag[0][iPart],Form("Templ %s",pdgnames[iPart].Data()),"l");
545  }
546 
547  for(int iPt=0; iPt<nPtbins; iPt++) {
548 
549  vector<int> templUsedTOFKaonMCTPCtag;
550  GetTOFFractionsFromData(kKaon,iPt,hFractionTOFKaonMCTPCtag,hFractionTOFKaonDataTPCtag,hNsigmaTOFKaonMCTPCtag[iPt],hNsigmaTOFKaonDataTPCtag[iPt],fNsigmaTOFKaonTPCtagFitter[iPt],templUsedTOFKaonMCTPCtag);
551 
552  if(templUsedTOFKaonMCTPCtag.size()>1) {
553  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll] = (TH1F*)fNsigmaTOFKaonTPCtagFitter[iPt]->GetPlot();
554  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->SetLineColor(kRed);
555  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->SetFillStyle(0);
556  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->SetFillColor(kWhite);
557 
558  for(unsigned int iTempl=0; iTempl<templUsedTOFKaonMCTPCtag.size(); iTempl++) {
559  double frac, err;
560  fNsigmaTOFKaonTPCtagFitter[iPt]->GetResult(iTempl, frac, err);
561  hNsigmaTOFKaonDataTPCtag_Fit[iPt][templUsedTOFKaonMCTPCtag[iTempl]] = (TH1F*)fNsigmaTOFKaonTPCtagFitter[iPt]->GetMCPrediction(iTempl);
562  hNsigmaTOFKaonDataTPCtag_Fit[iPt][templUsedTOFKaonMCTPCtag[iTempl]]->Scale(frac/hNsigmaTOFKaonDataTPCtag_Fit[iPt][templUsedTOFKaonMCTPCtag[iTempl]]->Integral()*hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->Integral());
563  hNsigmaTOFKaonDataTPCtag_Fit[iPt][templUsedTOFKaonMCTPCtag[iTempl]]->SetFillColor(kWhite);
564  hNsigmaTOFKaonDataTPCtag_Fit[iPt][templUsedTOFKaonMCTPCtag[iTempl]]->SetFillStyle(0);
565  }
566  }
567  else {
568  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll] = (TH1F*)hNsigmaTOFKaonDataTPCtag[iPt]->Clone();
569  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->SetLineColor(kRed);
570  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->SetFillStyle(0);
571  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kAll]->SetFillColor(kWhite);
572  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kKaon] = (TH1F*)hNsigmaTOFKaonDataTPCtag[iPt]->Clone();
573  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kKaon]->SetFillColor(kWhite);
574  hNsigmaTOFKaonDataTPCtag_Fit[iPt][kKaon]->SetFillStyle(0);
575  }
576  cFitResultTOFKaonFromTPCtag->cd(iPt+1)->SetLogy();
577  hNsigmaTOFKaonDataTPCtag[iPt]->DrawCopy("E");
578  for(int iPart=kElectron; iPart<=kProton; iPart++) {
579  vector<int>::iterator it = find(templUsedTOFKaonMCTPCtag.begin(),templUsedTOFKaonMCTPCtag.end(),iPart);
580  if(it!=templUsedTOFKaonMCTPCtag.end()) {
581  hNsigmaTOFKaonDataTPCtag_Fit[iPt][iPart]->DrawCopy("hist same");
582  }
583  else {
584  hNsigmaTOFKaonDataTPCtag_Fit[iPt][iPart]=nullptr;
585  }
586  }
587  legTOFFitter->Draw("same");
588 
589  vector<int> templUsedTOFProtonMCV0tag;
590  GetTOFFractionsFromData(kProton,iPt,hFractionTOFProtonMCV0tag,hFractionTOFProtonDataV0tag,hNsigmaTOFProtonMCV0tag[iPt],hNsigmaTOFProtonDataV0tag[iPt],fNsigmaTOFProtonV0tagFitter[iPt],templUsedTOFProtonMCV0tag);
591 
592  if(templUsedTOFProtonMCV0tag.size()>1) {
593  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll] = (TH1F*)fNsigmaTOFProtonV0tagFitter[iPt]->GetPlot();
594  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->SetLineColor(kRed);
595  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->SetFillStyle(0);
596  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->SetFillColor(kWhite);
597 
598  for(unsigned int iTempl=0; iTempl<templUsedTOFProtonMCV0tag.size(); iTempl++) {
599  double frac, err;
600  fNsigmaTOFProtonV0tagFitter[iPt]->GetResult(iTempl, frac, err);
601  hNsigmaTOFProtonDataV0tag_Fit[iPt][templUsedTOFProtonMCV0tag[iTempl]] = (TH1F*)fNsigmaTOFProtonV0tagFitter[iPt]->GetMCPrediction(iTempl);
602  hNsigmaTOFProtonDataV0tag_Fit[iPt][templUsedTOFProtonMCV0tag[iTempl]]->Scale(frac/hNsigmaTOFProtonDataV0tag_Fit[iPt][templUsedTOFProtonMCV0tag[iTempl]]->Integral()*hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->Integral());
603  hNsigmaTOFProtonDataV0tag_Fit[iPt][templUsedTOFProtonMCV0tag[iTempl]]->SetFillColor(kWhite);
604  hNsigmaTOFProtonDataV0tag_Fit[iPt][templUsedTOFProtonMCV0tag[iTempl]]->SetFillStyle(0);
605  }
606  }
607  else {
608  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll] = (TH1F*)hNsigmaTOFProtonDataV0tag[iPt]->Clone();
609  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->SetLineColor(kRed);
610  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->SetFillStyle(0);
611  hNsigmaTOFProtonDataV0tag_Fit[iPt][kAll]->SetFillColor(kWhite);
612  hNsigmaTOFProtonDataV0tag_Fit[iPt][kProton] = (TH1F*)hNsigmaTOFProtonDataV0tag[iPt]->Clone();
613  hNsigmaTOFProtonDataV0tag_Fit[iPt][kProton]->SetFillColor(kWhite);
614  hNsigmaTOFProtonDataV0tag_Fit[iPt][kProton]->SetFillStyle(0);
615  }
616  cFitResultTOFProtonFromV0tag->cd(iPt+1)->SetLogy();
617  hNsigmaTOFProtonDataV0tag[iPt]->DrawCopy("E");
618  for(int iPart=kElectron; iPart<=kProton; iPart++) {
619  vector<int>::iterator it = find(templUsedTOFProtonMCV0tag.begin(),templUsedTOFProtonMCV0tag.end(),iPart);
620  if(it!=templUsedTOFProtonMCV0tag.end()) {
621  hNsigmaTOFProtonDataV0tag_Fit[iPt][iPart]->DrawCopy("hist same");
622  }
623  else {
624  hNsigmaTOFProtonDataV0tag_Fit[iPt][iPart]=nullptr;
625  }
626  }
627  legTOFFitter->Draw("same");
628  }
629 
630  cTOFFractionData->cd(1)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TOF K TPC tag;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
631  cTOFFractionData->cd(1)->SetLogy();
632  cTOFFractionData->cd(1)->SetLogx();
633  for(int iPart=0; iPart<=kProton; iPart++) {
634  hFractionTOFKaonDataTPCtag[iPart]->DrawCopy("same");
635  }
636  cTOFFractionData->cd(2)->DrawFrame(ptlims[0],1.e-5,ptlims[nPtbins],10.,"TOF p from #Lambda;#it{p}_{T} (GeV/#it{c});Purity / Contamination");
637  cTOFFractionData->cd(2)->SetLogy();
638  cTOFFractionData->cd(2)->SetLogx();
639  for(int iPart=0; iPart<=kProton; iPart++) {
640  hFractionTOFProtonDataV0tag[iPart]->DrawCopy("same");
641  }
642  TLegend* legFracData = new TLegend(0.3,0.3,0.8,0.8);
643  legFracData->SetTextSize(0.05);
644  for(int iPart=kElectron; iPart<=kProton; iPart++) {
645  legFracData->AddEntry(hFractionTOFProtonDataV0tag[iPart],pdgnames[iPart].Data(),"lpe");
646  }
647  cTOFFractionData->cd(3);
648  legFracData->Draw("same");
649 
650  //********************************************************************************************************************************************//
651  //normalise histograms
652 
653  for(int iPt=0; iPt<nPtbins; iPt++) {
654  for(int iPart=kElectron; iPart<=kAll; iPart++) {
655  hNsigmaTPCPionMCV0tag[iPt][iPart]->Scale(1./hNsigmaTPCPionMCV0tag[iPt][kAll]->Integral());
656  hNsigmaTPCKaonMCKinktag[iPt][iPart]->Scale(1./hNsigmaTPCKaonMCKinktag[iPt][kAll]->Integral());
657  hNsigmaTPCKaonMCTOFtag[iPt][iPart]->Scale(1./hNsigmaTPCKaonMCTOFtag[iPt][kAll]->Integral());
658  hNsigmaTPCProtonMCV0tag[iPt][iPart]->Scale(1./hNsigmaTPCProtonMCV0tag[iPt][kAll]->Integral());
659  hNsigmaTOFPionMCV0tag[iPt][iPart]->Scale(1./hNsigmaTOFPionMCV0tag[iPt][kAll]->Integral());
660  hNsigmaTOFKaonMCKinktag[iPt][iPart]->Scale(1./hNsigmaTOFKaonMCKinktag[iPt][kAll]->Integral());
661  hNsigmaTOFKaonMCTPCtag[iPt][iPart]->Scale(1./hNsigmaTOFKaonMCTPCtag[iPt][kAll]->Integral());
662  hNsigmaTOFProtonMCV0tag[iPt][iPart]->Scale(1./hNsigmaTOFProtonMCV0tag[iPt][kAll]->Integral());
663 
664  if(iPart==kAll || hFractionTOFKaonDataTPCtag[iPart]->GetBinContent(iPt+1)>0) hNsigmaTOFKaonDataTPCtag_Fit[iPt][iPart]->Scale(1./hNsigmaTOFKaonDataTPCtag[iPt]->Integral());
665  if(iPart==kAll || hFractionTOFProtonDataV0tag[iPart]->GetBinContent(iPt+1)>0) hNsigmaTOFProtonDataV0tag_Fit[iPt][iPart]->Scale(1./hNsigmaTOFProtonDataV0tag[iPt]->Integral());
666  }
667 
668  hNsigmaTPCPionDataV0tag[iPt]->Scale(1./hNsigmaTPCPionDataV0tag[iPt]->Integral());
669  hNsigmaTPCKaonDataKinktag[iPt]->Scale(1./hNsigmaTPCKaonDataKinktag[iPt]->Integral());
670  hNsigmaTPCKaonDataTOFtag[iPt]->Scale(1./hNsigmaTPCKaonDataTOFtag[iPt]->Integral());
671  hNsigmaTPCProtonDataV0tag[iPt]->Scale(1./hNsigmaTPCProtonDataV0tag[iPt]->Integral());
672  hNsigmaTOFPionDataV0tag[iPt]->Scale(1./hNsigmaTOFPionDataV0tag[iPt]->Integral());
673  hNsigmaTOFKaonDataKinktag[iPt]->Scale(1./hNsigmaTOFKaonDataKinktag[iPt]->Integral());
674  hNsigmaTOFKaonDataTPCtag[iPt]->Scale(1./hNsigmaTOFKaonDataTPCtag[iPt]->Integral());
675  hNsigmaTOFProtonDataV0tag[iPt]->Scale(1./hNsigmaTOFProtonDataV0tag[iPt]->Integral());
676  }
677 
678  //********************************************************************************************************************************************//
679  //draw and fit distributions
680 
681  TCanvas* cPionMCV0tagTPC = new TCanvas("cPionMCV0tagTPC","cPionMCV0tagTPC",1920,1080);
682  DivideCanvas(cPionMCV0tagTPC,nPtbins);
683  TCanvas* cKaonMCKinkstagTPC = new TCanvas("cKaonMCKinkstagTPC","cKaonMCKinkstagTPC",1920,1080);
684  DivideCanvas(cKaonMCKinkstagTPC,nPtbins);
685  TCanvas* cKaonMCTOFtagTPC = new TCanvas("cKaonMCTOFtagTPC","cKaonMCTOFtagTPC",1920,1080);
686  DivideCanvas(cKaonMCTOFtagTPC,nPtbins);
687  TCanvas* cProtonMCV0tagTPC = new TCanvas("cProtonMCV0tagTPC","cProtonMCV0tagTPC",1920,1080);
688  DivideCanvas(cProtonMCV0tagTPC,nPtbins);
689  TCanvas* cPionMCV0tagTOF = new TCanvas("cPionMCV0tagTOF","cPionMCV0tagTOF",1920,1080);
690  DivideCanvas(cPionMCV0tagTOF,nPtbins);
691  TCanvas* cKaonMCKinkstagTOF = new TCanvas("cKaonMCKinkstagTOF","cKaonMCKinkstagTOF",1920,1080);
692  DivideCanvas(cKaonMCKinkstagTOF,nPtbins);
693  TCanvas* cKaonMCTPCtagTOF = new TCanvas("cKaonMCTPCtagTOF","cKaonMCTPCtagTOF",1920,1080);
694  DivideCanvas(cKaonMCTPCtagTOF,nPtbins);
695  TCanvas* cProtonMCV0tagTOF = new TCanvas("cProtonMCV0tagTOF","cProtonMCV0tagTOF",1920,1080);
696  DivideCanvas(cProtonMCV0tagTOF,nPtbins);
697 
698  TCanvas* cPionDataV0tagTPC = new TCanvas("cPionDataV0tagTPC","cPionDataV0tagTPC",1920,1080);
699  DivideCanvas(cPionDataV0tagTPC,nPtbins);
700  TCanvas* cKaonDataKinkstagTPC = new TCanvas("cKaonDataKinkstagTPC","cKaonDataKinkstagTPC",1920,1080);
701  DivideCanvas(cKaonDataKinkstagTPC,nPtbins);
702  TCanvas* cKaonDataTOFtagTPC = new TCanvas("cKaonDataTOFtagTPC","cKaonDataTOFtagTPC",1920,1080);
703  DivideCanvas(cKaonDataTOFtagTPC,nPtbins);
704  TCanvas* cProtonDataV0tagTPC = new TCanvas("cProtonDataV0tagTPC","cProtonDataV0tagTPC",1920,1080);
705  DivideCanvas(cProtonDataV0tagTPC,nPtbins);
706  TCanvas* cPionDataV0tagTOF = new TCanvas("cPionDataV0tagTOF","cPionDataV0tagTOF",1920,1080);
707  DivideCanvas(cPionDataV0tagTOF,nPtbins);
708  TCanvas* cKaonDataKinkstagTOF = new TCanvas("cKaonDataKinkstagTOF","cKaonDataKinkstagTOF",1920,1080);
709  DivideCanvas(cKaonDataKinkstagTOF,nPtbins);
710  TCanvas* cKaonDataTPCtagTOF = new TCanvas("cKaonDataTPCtagTOF","cKaonDataTPCtagTOF",1920,1080);
711  DivideCanvas(cKaonDataTPCtagTOF,nPtbins);
712  TCanvas* cProtonDataV0tagTOF = new TCanvas("cProtonDataV0tagTOF","cProtonDataV0tagTOF",1920,1080);
713  DivideCanvas(cProtonDataV0tagTOF,nPtbins);
714 
715  //fit TPC nsigma
716  TF1 *fNsigmaTPCPionMCV0tag[nPtbins][nPDGcodes-1], *fNsigmaTPCKaonMCKinktag[nPtbins][nPDGcodes-1], *fNsigmaTPCKaonMCTOFtag[nPtbins][nPDGcodes-1], *fNsigmaTPCProtonMCV0tag[nPtbins][nPDGcodes-1];
717 
718  TF1* fNsigmaTPCPionDataV0tag[nPtbins][nPDGcodes], *fNsigmaTPCKaonDataKinktag[nPtbins][nPDGcodes], *fNsigmaTPCKaonDataTOFtag[nPtbins][nPDGcodes], *fNsigmaTPCProtonDataV0tag[nPtbins][nPDGcodes];
719 
720  //subtract bkg template for TOF nsigma
721  TH1F *hNsigmaTOFPionDataV0tag_sub[nPtbins], *hNsigmaTOFKaonDataKinktag_sub[nPtbins], *hNsigmaTOFKaonDataTPCtag_sub[nPtbins], *hNsigmaTOFProtonDataV0tag_sub[nPtbins];
722 
723  TLegend* legMCdist = new TLegend(0.14,0.62,0.44,0.86);
724  legMCdist->SetTextSize(0.04);
725  legMCdist->AddEntry(hNsigmaTPCPionMCV0tag[0][kAll],"MC All","p");
726  for(int iPart=kElectron; iPart<=kProton; iPart++) {
727  legMCdist->AddEntry(hNsigmaTPCPionMCV0tag[0][iPart],Form("MC %s",pdgnames[iPart].Data()),"f");
728  }
729 
730  TLegend* legTPCFitter = new TLegend(0.14,0.62,0.48,0.86);
731  legTPCFitter->SetTextSize(0.04);
732  legTPCFitter->AddEntry(hNsigmaTPCPionDataV0tag[0],"Data","p");
733 
734  TLegend* legTOFPionDataV0tag = new TLegend(0.14,0.7,0.48,0.8);
735  legTOFPionDataV0tag->SetTextSize(0.05);
736 
737  TLegend* legTOFKaonDataKinkstag = new TLegend(0.14,0.7,0.48,0.8);
738  legTOFKaonDataKinkstag->SetTextSize(0.05);
739 
740  TLegend* legTOFKaonDataTPCtag = new TLegend(0.14,0.7,0.48,0.8);
741  legTOFKaonDataTPCtag->SetTextSize(0.05);
742 
743  TLegend* legTOFProtonDataV0tag = new TLegend(0.14,0.7,0.48,0.8);
744  legTOFProtonDataV0tag->SetTextSize(0.05);
745 
746  for(int iPt=0; iPt<nPtbins; iPt++) {
747 
748  for(int iPart=kElectron; iPart<=kProton; iPart++) {
749  fNsigmaTPCPionMCV0tag[iPt][iPart] = new TF1(Form("fNsigmaTPCPionMCV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
750  fNsigmaTPCKaonMCKinktag[iPt][iPart] = new TF1(Form("fNsigmaTPCKaonMCKinktag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
751  fNsigmaTPCKaonMCTOFtag[iPt][iPart] = new TF1(Form("fNsigmaTPCKaonMCTOFtag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
752  fNsigmaTPCProtonMCV0tag[iPt][iPart] = new TF1(Form("fNsigmaTPCProtonMCV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
753  }
754 
755  cPionMCV0tagTPC->cd(iPt+1)->SetLogy();
756  hNsigmaTPCPionMCV0tag[iPt][nPDGcodes-1]->DrawCopy("E");
757  for(int iPart=kElectron; iPart<=kProton; iPart++) {
758  hNsigmaTPCPionMCV0tag[iPt][iPart]->DrawCopy("hist same");
759  if(iPart==kPion || hFractionTPCPionMCV0tag[iPart]->GetBinContent(iPt+1)>1.e-5) hNsigmaTPCPionMCV0tag[iPt][iPart]->Fit(fNsigmaTPCPionMCV0tag[iPt][iPart],"L0R");
760  else fNsigmaTPCPionMCV0tag[iPt][iPart]->SetParameter(0,0);
761  }
762  hNsigmaTPCPionMCV0tag[iPt][nPDGcodes-1]->DrawCopy("Esame");
763  legMCdist->Draw("same");
764  cKaonMCKinkstagTPC->cd(iPt+1)->SetLogy();
765  hNsigmaTPCKaonMCKinktag[iPt][nPDGcodes-1]->DrawCopy("E");
766  for(int iPart=kElectron; iPart<=kProton; iPart++) {
767  hNsigmaTPCKaonMCKinktag[iPt][iPart]->DrawCopy("hist same");
768  if(iPart==kKaon || hFractionTPCKaonMCKinktag[iPart]->GetBinContent(iPt+1)>1.e-5) hNsigmaTPCKaonMCKinktag[iPt][iPart]->Fit(fNsigmaTPCKaonMCKinktag[iPt][iPart],"L0R");
769  else fNsigmaTPCKaonMCKinktag[iPt][iPart]->SetParameter(0,0);
770  }
771  hNsigmaTPCKaonMCKinktag[iPt][nPDGcodes-1]->DrawCopy("Esame");
772  legMCdist->Draw("same");
773  cKaonMCTOFtagTPC->cd(iPt+1)->SetLogy();
774  hNsigmaTPCKaonMCTOFtag[iPt][nPDGcodes-1]->DrawCopy("E");
775  for(int iPart=kElectron; iPart<=kProton; iPart++) {
776  hNsigmaTPCKaonMCTOFtag[iPt][iPart]->DrawCopy("hist same");
777  if(iPart==kKaon || hFractionTPCKaonMCTOFtag[iPart]->GetBinContent(iPt+1)>1.e-5) hNsigmaTPCKaonMCTOFtag[iPt][iPart]->Fit(fNsigmaTPCKaonMCTOFtag[iPt][iPart],"L0R");
778  else fNsigmaTPCKaonMCTOFtag[iPt][iPart]->SetParameter(0,0);
779  }
780  hNsigmaTPCKaonMCTOFtag[iPt][nPDGcodes-1]->DrawCopy("Esame");
781  legMCdist->Draw("same");
782  cProtonMCV0tagTPC->cd(iPt+1)->SetLogy();
783  hNsigmaTPCProtonMCV0tag[iPt][nPDGcodes-1]->DrawCopy("E");
784  for(int iPart=kElectron; iPart<=kProton; iPart++) {
785  hNsigmaTPCProtonMCV0tag[iPt][iPart]->DrawCopy("hist same");
786  if(iPart==kProton || hFractionTPCProtonMCV0tag[iPart]->GetBinContent(iPt+1)>1.e-5) hNsigmaTPCProtonMCV0tag[iPt][iPart]->Fit(fNsigmaTPCProtonMCV0tag[iPt][iPart],"L0R");
787  else fNsigmaTPCProtonMCV0tag[iPt][iPart]->SetParameter(0,0);
788  }
789  hNsigmaTPCProtonMCV0tag[iPt][nPDGcodes-1]->DrawCopy("Esame");
790  legMCdist->Draw("same");
791 
792  cPionMCV0tagTOF->cd(iPt+1)->SetLogy();
793  hNsigmaTOFPionMCV0tag[iPt][nPDGcodes-1]->DrawCopy("E");
794  for(int iPart=kElectron; iPart<=kProton; iPart++) hNsigmaTOFPionMCV0tag[iPt][iPart]->DrawCopy("hist same");
795  hNsigmaTOFPionMCV0tag[iPt][nPDGcodes-1]->DrawCopy("Esame");
796  legMCdist->Draw("same");
797  cKaonMCKinkstagTOF->cd(iPt+1)->SetLogy();
798  hNsigmaTOFKaonMCKinktag[iPt][nPDGcodes-1]->DrawCopy("E");
799  for(int iPart=kElectron; iPart<=kProton; iPart++) hNsigmaTOFKaonMCKinktag[iPt][iPart]->DrawCopy("hist same");
800  hNsigmaTOFKaonMCKinktag[iPt][nPDGcodes-1]->DrawCopy("Esame");
801  legMCdist->Draw("same");
802  cKaonMCTPCtagTOF->cd(iPt+1)->SetLogy();
803  hNsigmaTOFKaonMCTPCtag[iPt][nPDGcodes-1]->DrawCopy("E");
804  for(int iPart=kElectron; iPart<=kProton; iPart++) hNsigmaTOFKaonMCTPCtag[iPt][iPart]->DrawCopy("hist same");
805  hNsigmaTOFKaonMCTPCtag[iPt][nPDGcodes-1]->DrawCopy("Esame");
806  legMCdist->Draw("same");
807  cProtonMCV0tagTOF->cd(iPt+1)->SetLogy();
808  hNsigmaTOFProtonMCV0tag[iPt][nPDGcodes-1]->DrawCopy("E");
809  for(int iPart=kElectron; iPart<=kProton; iPart++) hNsigmaTOFProtonMCV0tag[iPt][iPart]->DrawCopy("hist same");
810  hNsigmaTOFProtonMCV0tag[iPt][nPDGcodes-1]->DrawCopy("Esame");
811  legMCdist->Draw("same");
812 
813  fNsigmaTPCPionDataV0tag[iPt][kAll] = new TF1(Form("fNsigmaTPCPionDataV0tag_%s_p%0.f_%0.f",pdgnames[kAll].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),PDFnsigmaTPCtot,-50,50,(nPDGcodes-1)*3);
814  fNsigmaTPCKaonDataKinktag[iPt][kAll] = new TF1(Form("fNsigmaTPCKaonDataKinktag_%s_p%0.f_%0.f",pdgnames[kAll].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),PDFnsigmaTPCtot,-50,50,(nPDGcodes-1)*3);
815  fNsigmaTPCKaonDataTOFtag[iPt][kAll] = new TF1(Form("fNsigmaTPCKaonDataTOFtag_%s_p%0.f_%0.f",pdgnames[kAll].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),PDFnsigmaTPCtot,-50,50,(nPDGcodes-1)*3);
816  fNsigmaTPCProtonDataV0tag[iPt][kAll] = new TF1(Form("fNsigmaTPCProtonDataV0tag_%s_p%0.f_%0.f",pdgnames[kAll].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),PDFnsigmaTPCtot,-50,50,(nPDGcodes-1)*3);
817 
818  for(int iPart=kElectron; iPart<=kProton; iPart++) {
819 
820  double toll = 0.5;
821  for(int iPar=0; iPar<3; iPar++) {
822  fNsigmaTPCPionDataV0tag[iPt][kAll]->SetParameter(iPart*3+iPar,fNsigmaTPCPionMCV0tag[iPt][iPart]->GetParameter(iPar));
823  fNsigmaTPCKaonDataKinktag[iPt][kAll]->SetParameter(iPart*3+iPar,fNsigmaTPCKaonMCKinktag[iPt][iPart]->GetParameter(iPar));
824  fNsigmaTPCKaonDataTOFtag[iPt][kAll]->SetParameter(iPart*3+iPar,fNsigmaTPCKaonMCTOFtag[iPt][iPart]->GetParameter(iPar));
825  fNsigmaTPCProtonDataV0tag[iPt][kAll]->SetParameter(iPart*3+iPar,fNsigmaTPCProtonMCV0tag[iPt][iPart]->GetParameter(iPar));
826 
827  if(iPart*3+iPar!=kPion*3+1) {
828  fNsigmaTPCPionDataV0tag[iPt][kAll]->SetParLimits(iPart*3+iPar,fNsigmaTPCPionMCV0tag[iPt][iPart]->GetParameter(iPar)-TMath::Abs(fNsigmaTPCPionMCV0tag[iPt][iPart]->GetParameter(iPar))*toll,fNsigmaTPCPionMCV0tag[iPt][iPart]->GetParameter(iPar)+TMath::Abs(fNsigmaTPCPionMCV0tag[iPt][iPart]->GetParameter(iPar))*toll);
829  }
830  if(iPart*3+iPar!=kKaon*3+1) {
831  fNsigmaTPCKaonDataKinktag[iPt][kAll]->SetParLimits(iPart*3+iPar,fNsigmaTPCKaonMCKinktag[iPt][iPart]->GetParameter(iPar)-TMath::Abs(fNsigmaTPCKaonMCKinktag[iPt][iPart]->GetParameter(iPar))*toll,fNsigmaTPCKaonMCKinktag[iPt][iPart]->GetParameter(iPar)+TMath::Abs(fNsigmaTPCKaonMCKinktag[iPt][iPart]->GetParameter(iPar))*toll);
832 
833  fNsigmaTPCKaonDataTOFtag[iPt][kAll]->SetParLimits(iPart*3+iPar,fNsigmaTPCKaonMCTOFtag[iPt][iPart]->GetParameter(iPar)-TMath::Abs(fNsigmaTPCKaonMCTOFtag[iPt][iPart]->GetParameter(iPar))*toll,fNsigmaTPCKaonMCTOFtag[iPt][iPart]->GetParameter(iPar)+TMath::Abs(fNsigmaTPCKaonMCTOFtag[iPt][iPart]->GetParameter(iPar))*toll);
834  }
835  if(iPart*3+iPar!=kProton*3+1) {
836  fNsigmaTPCProtonDataV0tag[iPt][kAll]->SetParLimits(iPart*3+iPar,fNsigmaTPCProtonMCV0tag[iPt][iPart]->GetParameter(iPar)-TMath::Abs(fNsigmaTPCProtonMCV0tag[iPt][iPart]->GetParameter(iPar))*toll,fNsigmaTPCProtonMCV0tag[iPt][iPart]->GetParameter(iPar)+TMath::Abs(fNsigmaTPCProtonMCV0tag[iPt][iPart]->GetParameter(iPar))*toll);
837  }
838  }
839  }
840 
841  hNsigmaTPCPionDataV0tag[iPt]->Fit(fNsigmaTPCPionDataV0tag[iPt][kAll],"L0R");
842  hNsigmaTPCKaonDataKinktag[iPt]->Fit(fNsigmaTPCKaonDataKinktag[iPt][kAll],"L0R");
843  hNsigmaTPCKaonDataTOFtag[iPt]->Fit(fNsigmaTPCKaonDataTOFtag[iPt][kAll],"L0R");
844  hNsigmaTPCProtonDataV0tag[iPt]->Fit(fNsigmaTPCProtonDataV0tag[iPt][kAll],"L0R");
845 
846  for(int iPart=kElectron; iPart<=kProton; iPart++) {
847  fNsigmaTPCPionDataV0tag[iPt][iPart] = new TF1(Form("fNsigmaTPCPionDataV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
848  fNsigmaTPCKaonDataKinktag[iPt][iPart] = new TF1(Form("fNsigmaTPCKaonDataKinktag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
849  fNsigmaTPCKaonDataTOFtag[iPt][iPart] = new TF1(Form("fNsigmaTPCKaonDataTOFtag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
850  fNsigmaTPCProtonDataV0tag[iPt][iPart] = new TF1(Form("fNsigmaTPCProtonDataV0tag_%s_p%0.f_%0.f",pdgnames[iPart].Data(),ptlims[iPt]*10,ptlims[iPt+1]*10),"gaus",-50,50);
851 
852  for(int iPar=0; iPar<3; iPar++) {
853  fNsigmaTPCPionDataV0tag[iPt][iPart]->SetParameter(iPar,fNsigmaTPCPionDataV0tag[iPt][kAll]->GetParameter(iPart*3+iPar));
854  fNsigmaTPCKaonDataKinktag[iPt][iPart]->SetParameter(iPar,fNsigmaTPCKaonDataKinktag[iPt][kAll]->GetParameter(iPart*3+iPar));
855  fNsigmaTPCKaonDataTOFtag[iPt][iPart]->SetParameter(iPar,fNsigmaTPCKaonDataTOFtag[iPt][kAll]->GetParameter(iPart*3+iPar));
856  fNsigmaTPCProtonDataV0tag[iPt][iPart]->SetParameter(iPar,fNsigmaTPCProtonDataV0tag[iPt][kAll]->GetParameter(iPart*3+iPar));
857  }
858  fNsigmaTPCPionDataV0tag[iPt][iPart]->SetLineColor(pdgcolors[iPart]);
859  fNsigmaTPCKaonDataKinktag[iPt][iPart]->SetLineColor(pdgcolors[iPart]);
860  fNsigmaTPCKaonDataTOFtag[iPt][iPart]->SetLineColor(pdgcolors[iPart]);
861  fNsigmaTPCProtonDataV0tag[iPt][iPart]->SetLineColor(pdgcolors[iPart]);
862  if(iPt==0) legTPCFitter->AddEntry(fNsigmaTPCProtonDataV0tag[iPt][iPart],Form("Func %s",pdgnames[iPart].Data()),"l");
863  }
864 
865  cPionDataV0tagTPC->cd(iPt+1)->SetLogy();
866  hNsigmaTPCPionDataV0tag[iPt]->DrawCopy("E");
867  for(int iPart=kElectron; iPart<=kProton; iPart++) fNsigmaTPCPionDataV0tag[iPt][iPart]->Draw("same");
868  legTPCFitter->Draw("same");
869  cKaonDataKinkstagTPC->cd(iPt+1)->SetLogy();
870  hNsigmaTPCKaonDataKinktag[iPt]->DrawCopy("E");
871  for(int iPart=kElectron; iPart<=kProton; iPart++) fNsigmaTPCKaonDataKinktag[iPt][iPart]->Draw("same");
872  legTPCFitter->Draw("same");
873  cKaonDataTOFtagTPC->cd(iPt+1)->SetLogy();
874  hNsigmaTPCKaonDataTOFtag[iPt]->DrawCopy("E");
875  for(int iPart=kElectron; iPart<=kProton; iPart++) fNsigmaTPCKaonDataTOFtag[iPt][iPart]->Draw("same");
876  legTPCFitter->Draw("same");
877  cProtonDataV0tagTPC->cd(iPt+1)->SetLogy();
878  hNsigmaTPCProtonDataV0tag[iPt]->DrawCopy("E");
879  for(int iPart=kElectron; iPart<=kProton; iPart++) fNsigmaTPCProtonDataV0tag[iPt][iPart]->Draw("same");
880  legTPCFitter->Draw("same");
881 
882  //subtract bkg template for TOF nsigma
883  TString name = hNsigmaTOFPionDataV0tag[iPt]->GetName();
884  name.ReplaceAll("hNsigmaTOFPionDataV0tag","hNsigmaTOFPionDataV0tag_sub");
885  hNsigmaTOFPionDataV0tag_sub[iPt] = (TH1F*)hNsigmaTOFPionDataV0tag[iPt]->Clone(name.Data());
886 
887  name = hNsigmaTOFKaonDataKinktag[iPt]->GetName();
888  name.ReplaceAll("hNsigmaTOFKaonDataKinktag","hNsigmaTOFKaonDataKinktag_sub");
889  hNsigmaTOFKaonDataKinktag_sub[iPt] = (TH1F*)hNsigmaTOFKaonDataKinktag[iPt]->Clone(name.Data());
890 
891  name = hNsigmaTOFKaonDataTPCtag[iPt]->GetName();
892  name.ReplaceAll("hNsigmaTOFKaonDataTPCtag","hNsigmaTOFKaonDataTPCtag_sub");
893  hNsigmaTOFKaonDataTPCtag_sub[iPt] = (TH1F*)hNsigmaTOFKaonDataTPCtag[iPt]->Clone(name.Data());
894 
895  name = hNsigmaTOFProtonDataV0tag[iPt]->GetName();
896  name.ReplaceAll("hNsigmaTOFProtonDataV0tag","hNsigmaTOFProtonDataV0tag_sub");
897  hNsigmaTOFProtonDataV0tag_sub[iPt] = (TH1F*)hNsigmaTOFProtonDataV0tag[iPt]->Clone(name.Data());
898 
899  for(int iPart=kElectron; iPart<=kProton; iPart++) {
900  if(iPart!=kPion) hNsigmaTOFPionDataV0tag_sub[iPt]->Add(hNsigmaTOFPionMCV0tag[iPt][iPart],-1.);
901  if(iPart!=kKaon) {
902  hNsigmaTOFKaonDataKinktag_sub[iPt]->Add(hNsigmaTOFKaonMCKinktag[iPt][iPart],-1.);
903  if(hFractionTOFKaonDataTPCtag[iPart]->GetBinContent(iPt+1)>0) {
904  hNsigmaTOFKaonDataTPCtag_sub[iPt]->Add(hNsigmaTOFKaonDataTPCtag_Fit[iPt][iPart],-1.);
905  }
906  else {
907  hNsigmaTOFKaonDataTPCtag_sub[iPt]->Add(hNsigmaTOFKaonMCTPCtag[iPt][iPart],-1.);
908  }
909  }
910  if(iPart!=kProton) {
911  if(hFractionTOFProtonDataV0tag[iPart]->GetBinContent(iPt+1)>0) {
912  hNsigmaTOFProtonDataV0tag_sub[iPt]->Add(hNsigmaTOFProtonDataV0tag_Fit[iPt][iPart],-1.);
913  }
914  else {
915  hNsigmaTOFProtonDataV0tag_sub[iPt]->Add(hNsigmaTOFProtonMCV0tag[iPt][iPart],-1.);
916  }
917  }
918  }
919 
920  SetTH1Style(hNsigmaTOFPionDataV0tag_sub[iPt],kOpenCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],pdgfillcolors[kAll],0.055,0.06);
921  SetTH1Style(hNsigmaTOFKaonDataKinktag_sub[iPt],kOpenCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],pdgfillcolors[kAll],0.055,0.06);
922  SetTH1Style(hNsigmaTOFKaonDataTPCtag_sub[iPt],kOpenCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],pdgfillcolors[kAll],0.055,0.06);
923  SetTH1Style(hNsigmaTOFProtonDataV0tag_sub[iPt],kOpenCircle,pdgcolors[kAll],0.6,2,pdgcolors[kAll],pdgfillcolors[kAll],0.055,0.06);
924  if(iPt==0) {
925  legTOFPionDataV0tag->AddEntry(hNsigmaTOFPionDataV0tag_sub[iPt],"Data","p");
926  legTOFPionDataV0tag->AddEntry(hNsigmaTOFPionMCV0tag[iPt][kPion],"MC Pion","p");
927  legTOFKaonDataKinkstag->AddEntry(hNsigmaTOFKaonDataKinktag_sub[iPt],"Data","p");
928  legTOFKaonDataKinkstag->AddEntry(hNsigmaTOFKaonMCKinktag[iPt][kKaon],"MC Kaon","p");
929  legTOFKaonDataTPCtag->AddEntry(hNsigmaTOFKaonDataTPCtag_sub[iPt],"Data","p");
930  legTOFKaonDataTPCtag->AddEntry(hNsigmaTOFKaonMCTPCtag[iPt][kKaon],"MC Kaon","p");
931  legTOFProtonDataV0tag->AddEntry(hNsigmaTOFProtonDataV0tag_sub[iPt],"Data","p");
932  legTOFProtonDataV0tag->AddEntry(hNsigmaTOFKaonMCTPCtag[iPt][kProton],"MC Proton","p");
933  }
934 
935  cPionDataV0tagTOF->cd(iPt+1)->SetLogy();
936  hNsigmaTOFPionDataV0tag_sub[iPt]->DrawCopy("E");
937  hNsigmaTOFPionMCV0tag[iPt][kPion]->DrawCopy("hist same");
938  legTOFPionDataV0tag->Draw("same");
939  cKaonDataKinkstagTOF->cd(iPt+1)->SetLogy();
940  hNsigmaTOFKaonDataKinktag_sub[iPt]->DrawCopy("E");
941  hNsigmaTOFKaonMCKinktag[iPt][kKaon]->DrawCopy("hist same");
942  legTOFKaonDataKinkstag->Draw("same");
943  cKaonDataTPCtagTOF->cd(iPt+1)->SetLogy();
944  hNsigmaTOFKaonDataTPCtag_sub[iPt]->DrawCopy("E");
945  hNsigmaTOFKaonMCTPCtag[iPt][kKaon]->DrawCopy("hist same");
946  legTOFKaonDataTPCtag->Draw("same");
947  cProtonDataV0tagTOF->cd(iPt+1)->SetLogy();
948  hNsigmaTOFProtonDataV0tag_sub[iPt]->DrawCopy("E");
949  hNsigmaTOFProtonMCV0tag[iPt][kProton]->DrawCopy("hist same");
950  legTOFProtonDataV0tag->Draw("same");
951  }
952 
953  //********************************************************************************************************************************************//
954  //compute efficiencies
955 
956  const int nEff = 3;
957  int nSigma[nEff] = {3,2,1};
958  int markersMC[nEff] = {kFullCircle,kFullSquare,kFullDiamond};
959  int markersData[nEff] = {kOpenCircle,kOpenSquare,kOpenDiamond};
960  TH1F *hEffPionTPCMCtrue[nEff], *hEffPionTOFMCtrue[nEff], *hEffKaonTPCMCtrue[nEff], *hEffKaonTOFMCtrue[nEff],*hEffProtonTPCMCtrue[nEff], *hEffProtonTOFMCtrue[nEff];
961  TH1F *hEffPionTPCDataV0tag[nEff], *hEffPionTOFDataV0tag[nEff], *hEffKaonTPCDataKinktag[nEff], *hEffKaonTOFDataKinktag[nEff], *hEffKaonTPCDataTOFtag[nEff], *hEffKaonTOFDataTPCtag[nEff],*hEffProtonTPCDataV0tag[nEff], *hEffProtonTOFDataV0tag[nEff];
962  TH1F *hRatioEffPionTPCDataV0tag[nEff], *hRatioEffPionTOFDataV0tag[nEff], *hRatioEffKaonTPCDataKinktag[nEff], *hRatioEffKaonTOFDataKinktag[nEff], *hRatioEffKaonTPCDataTOFtag[nEff], *hRatioEffKaonTOFDataTPCtag[nEff],*hRatioEffProtonTPCDataV0tag[nEff], *hRatioEffProtonTOFDataV0tag[nEff];
963  TLegend* legEffPion = new TLegend(0.18,0.15,0.925,0.38);
964  legEffPion->SetTextSize(0.045);
965  legEffPion->SetNColumns(2);
966  legEffPion->AddEntry("","MC","");
967  legEffPion->AddEntry("","V0 tag","");
968  TLegend* legEffKaonTPC = new TLegend(0.18,0.15,0.925,0.38);
969  legEffKaonTPC->SetTextSize(0.045);
970  legEffKaonTPC->SetNColumns(3);
971  legEffKaonTPC->AddEntry("","MC","");
972  legEffKaonTPC->AddEntry("","TOF tag","");
973  legEffKaonTPC->AddEntry("","kink tag","");
974  TLegend* legEffKaonTOF = new TLegend(0.18,0.15,0.925,0.38);
975  legEffKaonTOF->SetTextSize(0.045);
976  legEffKaonTOF->SetNColumns(2);
977  legEffKaonTOF->AddEntry("","MC","");
978  legEffKaonTOF->AddEntry("","TPC tag","");
979  TLegend* legEffProton = new TLegend(0.18,0.15,0.925,0.38);
980  legEffProton->SetTextSize(0.045);
981  legEffProton->SetNColumns(2);
982  legEffProton->AddEntry("","MC","");
983  legEffProton->AddEntry("","V0 tag","");
984 
985  for(int iEff=0; iEff<nEff; iEff++) {
986  hEffPionTPCMCtrue[iEff] = new TH1F(Form("hEffPionTPCMCtrue_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC #pi efficiency",nPtbins,ptlims);
987  hEffPionTOFMCtrue[iEff] = new TH1F(Form("hEffPionTOFMCtrue_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF #pi efficiency",nPtbins,ptlims);
988 
989  hEffKaonTPCMCtrue[iEff] = new TH1F(Form("hEffKaonTPCMCtrue_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC K efficiency",nPtbins,ptlims);
990  hEffKaonTOFMCtrue[iEff] = new TH1F(Form("hEffKaonTOFMCtrue_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF K efficiency",nPtbins,ptlims);
991 
992  hEffProtonTPCMCtrue[iEff] = new TH1F(Form("hEffProtonTPCMCtrue_%dsigma;",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC p efficiency",nPtbins,ptlims);
993  hEffProtonTOFMCtrue[iEff] = new TH1F(Form("hEffProtonTOFMCtrue_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF p efficiency",nPtbins,ptlims);
994 
995  hEffPionTPCDataV0tag[iEff] = new TH1F(Form("hEffPionTPCDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC #pi efficiency",nPtbins,ptlims);
996  hEffPionTOFDataV0tag[iEff] = new TH1F(Form("hEffPionTOFDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF #pi efficiency",nPtbins,ptlims);
997 
998  hEffKaonTPCDataKinktag[iEff] = new TH1F(Form("hEffKaonTPCDataKinktag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC K efficiency",nPtbins,ptlims);
999  hEffKaonTOFDataKinktag[iEff] = new TH1F(Form("hEffKaonTOFDataKinktag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF K efficiency",nPtbins,ptlims);
1000 
1001  hEffKaonTPCDataTOFtag[iEff] = new TH1F(Form("hEffKaonTPCDataTOFtag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC K efficiency",nPtbins,ptlims);
1002  hEffKaonTOFDataTPCtag[iEff] = new TH1F(Form("hEffKaonTOFDataTPCtag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF K efficiency",nPtbins,ptlims);
1003 
1004  hEffProtonTPCDataV0tag[iEff] = new TH1F(Form("hEffProtonTPCDataV0tag_%dsigma;",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC p efficiency",nPtbins,ptlims);
1005  hEffProtonTOFDataV0tag[iEff] = new TH1F(Form("hEffProtonTOFDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF p efficiency",nPtbins,ptlims);
1006 
1007  hRatioEffPionTPCDataV0tag[iEff] = new TH1F(Form("hRatioEffPionTPCDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC #pi efficiency",nPtbins,ptlims);
1008  hRatioEffPionTOFDataV0tag[iEff] = new TH1F(Form("hRatioEffPionTOFDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF #pi efficiency",nPtbins,ptlims);
1009 
1010  hRatioEffKaonTPCDataKinktag[iEff] = new TH1F(Form("hRatioEffKaonTPCDataKinktag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC K efficiency",nPtbins,ptlims);
1011  hRatioEffKaonTOFDataKinktag[iEff] = new TH1F(Form("hRatioEffKaonTOFDataKinktag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF K efficiency",nPtbins,ptlims);
1012 
1013  hRatioEffKaonTPCDataTOFtag[iEff] = new TH1F(Form("hRatioEffKaonTPCDataTOFtag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC K efficiency",nPtbins,ptlims);
1014  hRatioEffKaonTOFDataTPCtag[iEff] = new TH1F(Form("hRatioEffKaonTOFDataTPCtag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF K efficiency",nPtbins,ptlims);
1015 
1016  hRatioEffProtonTPCDataV0tag[iEff] = new TH1F(Form("hRatioEffProtonTPCDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TPC #pi efficiency",nPtbins,ptlims);
1017  hRatioEffProtonTOFDataV0tag[iEff] = new TH1F(Form("hRatioEffProtonTOFDataV0tag_%dsigma",nSigma[iEff]),";#it{p}_{T} (GeV/#it{c});TOF #pi efficiency",nPtbins,ptlims);
1018 
1019  int nsigmabinlow = hNsigmaTOFPionMCTrue[0]->GetXaxis()->FindBin(-nSigma[iEff]+1.e-5);
1020  int nsigmabinhigh = hNsigmaTOFPionMCTrue[0]->GetXaxis()->FindBin(nSigma[iEff]-1.e-5);
1021 
1022  legEffPion->AddEntry(hEffPionTPCMCtrue[iEff],Form("|N_{#sigma}(#pi)| < %d",nSigma[iEff]),"p");
1023  legEffPion->AddEntry(hEffPionTPCDataV0tag[iEff],Form("|N_{#sigma}(#pi)| < %d",nSigma[iEff]),"p");
1024  legEffKaonTPC->AddEntry(hEffKaonTPCMCtrue[iEff],Form("|N_{#sigma}(K)| < %d",nSigma[iEff]),"p");
1025  legEffKaonTPC->AddEntry(hEffKaonTPCDataTOFtag[iEff],Form("|N_{#sigma}(K)| < %d",nSigma[iEff]),"p");
1026  legEffKaonTPC->AddEntry(hEffKaonTPCDataKinktag[iEff],Form("|N_{#sigma}(K)| < %d",nSigma[iEff]),"p");
1027  legEffKaonTOF->AddEntry(hEffKaonTPCMCtrue[iEff],Form("|N_{#sigma}(K)| < %d",nSigma[iEff]),"p");
1028  legEffKaonTOF->AddEntry(hEffKaonTPCDataTOFtag[iEff],Form("|N_{#sigma}(K)| < %d",nSigma[iEff]),"p");
1029  legEffProton->AddEntry(hEffProtonTPCMCtrue[iEff],Form("|N_{#sigma}(p)| < %d",nSigma[iEff]),"p");
1030  legEffProton->AddEntry(hEffProtonTOFDataV0tag[iEff],Form("|N_{#sigma}(p)| < %d",nSigma[iEff]),"p");
1031 
1032  for(int iPt=0; iPt<nPtbins; iPt++) {
1033  double eff=-1, unc=-1;
1034  ComputeEfficiency(hNsigmaTPCPionMCTrue[iPt]->Integral(nsigmabinlow,nsigmabinhigh),hNsigmaTPCPionMCTrue[iPt]->Integral(),eff,unc);
1035  hEffPionTPCMCtrue[iEff]->SetBinContent(iPt+1,eff);
1036  hEffPionTPCMCtrue[iEff]->SetBinError(iPt+1,unc);
1037 
1038  ComputeEfficiency(hNsigmaTOFPionMCTrue[iPt]->Integral(nsigmabinlow,nsigmabinhigh),hNsigmaTOFPionMCTrue[iPt]->Integral(),eff,unc);
1039  hEffPionTOFMCtrue[iEff]->SetBinContent(iPt+1,eff);
1040  hEffPionTOFMCtrue[iEff]->SetBinError(iPt+1,unc);
1041 
1042  ComputeEfficiency(hNsigmaTPCKaonMCTrue[iPt]->Integral(nsigmabinlow,nsigmabinhigh),hNsigmaTPCKaonMCTrue[iPt]->Integral(),eff,unc);
1043  hEffKaonTPCMCtrue[iEff]->SetBinContent(iPt+1,eff);
1044  hEffKaonTPCMCtrue[iEff]->SetBinError(iPt+1,unc);
1045 
1046  ComputeEfficiency(hNsigmaTOFKaonMCTrue[iPt]->Integral(nsigmabinlow,nsigmabinhigh),hNsigmaTOFKaonMCTrue[iPt]->Integral(),eff,unc);
1047  hEffKaonTOFMCtrue[iEff]->SetBinContent(iPt+1,eff);
1048  hEffKaonTOFMCtrue[iEff]->SetBinError(iPt+1,unc);
1049 
1050  ComputeEfficiency(hNsigmaTPCProtonMCTrue[iPt]->Integral(nsigmabinlow,nsigmabinhigh),hNsigmaTPCProtonMCTrue[iPt]->Integral(),eff,unc);
1051  hEffProtonTPCMCtrue[iEff]->SetBinContent(iPt+1,eff);
1052  hEffProtonTPCMCtrue[iEff]->SetBinError(iPt+1,unc);
1053 
1054  ComputeEfficiency(hNsigmaTOFProtonMCTrue[iPt]->Integral(nsigmabinlow,nsigmabinhigh),hNsigmaTOFProtonMCTrue[iPt]->Integral(),eff,unc);
1055  hEffProtonTOFMCtrue[iEff]->SetBinContent(iPt+1,eff);
1056  hEffProtonTOFMCtrue[iEff]->SetBinError(iPt+1,unc);
1057 
1058  ComputeEfficiency(fNsigmaTPCPionDataV0tag[iPt][kPion]->Integral(-nSigma[iEff],nSigma[iEff])*intNsigmaTPCPionDataV0tag[iPt],fNsigmaTPCPionDataV0tag[iPt][kPion]->Integral(-50,50)*intNsigmaTPCPionDataV0tag[iPt],eff,unc);
1059  hEffPionTPCDataV0tag[iEff]->SetBinContent(iPt+1,eff);
1060  hEffPionTPCDataV0tag[iEff]->SetBinError(iPt+1,unc);
1061 
1062  ComputeEfficiency(fNsigmaTPCKaonDataKinktag[iPt][kKaon]->Integral(-nSigma[iEff],nSigma[iEff])*intNsigmaTPCKaonDataKinktag[iPt],fNsigmaTPCKaonDataKinktag[iPt][kKaon]->Integral(-50,50)*intNsigmaTPCKaonDataKinktag[iPt],eff,unc);
1063  hEffKaonTPCDataKinktag[iEff]->SetBinContent(iPt+1,eff);
1064  hEffKaonTPCDataKinktag[iEff]->SetBinError(iPt+1,unc);
1065 
1066  ComputeEfficiency(fNsigmaTPCKaonDataTOFtag[iPt][kKaon]->Integral(-nSigma[iEff],nSigma[iEff])*intNsigmaTPCKaonDataTOFtag[iPt],fNsigmaTPCKaonDataTOFtag[iPt][kKaon]->Integral(-50,50)*intNsigmaTPCKaonDataTOFtag[iPt],eff,unc);
1067  hEffKaonTPCDataTOFtag[iEff]->SetBinContent(iPt+1,eff);
1068  hEffKaonTPCDataTOFtag[iEff]->SetBinError(iPt+1,unc);
1069 
1070  ComputeEfficiency(fNsigmaTPCProtonDataV0tag[iPt][kProton]->Integral(-nSigma[iEff],nSigma[iEff])*intNsigmaTPCProtonDataV0tag[iPt],fNsigmaTPCProtonDataV0tag[iPt][kProton]->Integral(-50,50)*intNsigmaTPCProtonDataV0tag[iPt],eff,unc);
1071  hEffProtonTPCDataV0tag[iEff]->SetBinContent(iPt+1,eff);
1072  hEffProtonTPCDataV0tag[iEff]->SetBinError(iPt+1,unc);
1073 
1074  ComputeEfficiency(hNsigmaTOFPionDataV0tag_sub[iPt]->Integral(nsigmabinlow,nsigmabinhigh)*intNsigmaTOFPionDataV0tag[iPt],hNsigmaTOFPionDataV0tag_sub[iPt]->Integral()*intNsigmaTOFPionDataV0tag[iPt],eff,unc);
1075  hEffPionTOFDataV0tag[iEff]->SetBinContent(iPt+1,eff);
1076  hEffPionTOFDataV0tag[iEff]->SetBinError(iPt+1,unc);
1077 
1078  ComputeEfficiency(hNsigmaTOFKaonDataTPCtag_sub[iPt]->Integral(nsigmabinlow,nsigmabinhigh)*intNsigmaTOFKaonDataTPCtag[iPt],hNsigmaTOFKaonDataTPCtag_sub[iPt]->Integral()*intNsigmaTOFKaonDataTPCtag[iPt],eff,unc);
1079  hEffKaonTOFDataTPCtag[iEff]->SetBinContent(iPt+1,eff);
1080  hEffKaonTOFDataTPCtag[iEff]->SetBinError(iPt+1,unc);
1081 
1082  ComputeEfficiency(hNsigmaTOFProtonDataV0tag_sub[iPt]->Integral(nsigmabinlow,nsigmabinhigh)*intNsigmaTOFProtonDataV0tag[iPt],hNsigmaTOFProtonDataV0tag_sub[iPt]->Integral()*intNsigmaTOFProtonDataV0tag[iPt],eff,unc);
1083  hEffProtonTOFDataV0tag[iEff]->SetBinContent(iPt+1,eff);
1084  hEffProtonTOFDataV0tag[iEff]->SetBinError(iPt+1,unc);
1085  }
1086 
1087  hRatioEffPionTPCDataV0tag[iEff]->Divide(hEffPionTPCDataV0tag[iEff],hEffPionTPCMCtrue[iEff],1.,1.,"");
1088  hRatioEffPionTOFDataV0tag[iEff]->Divide(hEffPionTOFDataV0tag[iEff],hEffPionTOFMCtrue[iEff],1.,1.,"");
1089  hRatioEffKaonTPCDataKinktag[iEff]->Divide(hEffKaonTPCDataKinktag[iEff],hEffKaonTPCMCtrue[iEff],1.,1.,"");
1090  hRatioEffKaonTPCDataTOFtag[iEff]->Divide(hEffKaonTPCDataTOFtag[iEff],hEffKaonTPCMCtrue[iEff],1.,1.,"");
1091  hRatioEffKaonTOFDataTPCtag[iEff]->Divide(hEffKaonTOFDataTPCtag[iEff],hEffKaonTOFMCtrue[iEff],1.,1.,"");
1092  hRatioEffProtonTPCDataV0tag[iEff]->Divide(hEffProtonTPCDataV0tag[iEff],hEffProtonTPCMCtrue[iEff],1.,1.,"");
1093  hRatioEffProtonTOFDataV0tag[iEff]->Divide(hEffProtonTOFDataV0tag[iEff],hEffProtonTOFMCtrue[iEff],1.,1.,"");
1094 
1095  SetTH1Style(hEffPionTPCMCtrue[iEff],markersMC[iEff],pdgcolors[kPion],1.,2,pdgcolors[kPion],kWhite,0.045,0.055);
1096  SetTH1Style(hEffPionTOFMCtrue[iEff],markersMC[iEff],pdgcolors[kPion],1.,2,pdgcolors[kPion],kWhite,0.045,0.055);
1097  SetTH1Style(hEffKaonTPCMCtrue[iEff],markersMC[iEff],pdgcolors[kKaon],1.,2,pdgcolors[kKaon],kWhite,0.045,0.055);
1098  SetTH1Style(hEffKaonTOFMCtrue[iEff],markersMC[iEff],pdgcolors[kKaon],1.,2,pdgcolors[kKaon],kWhite,0.045,0.055);
1099  SetTH1Style(hEffProtonTPCMCtrue[iEff],markersMC[iEff],pdgcolors[kProton],1.,2,pdgcolors[kProton],kWhite,0.045,0.055);
1100  SetTH1Style(hEffProtonTOFMCtrue[iEff],markersMC[iEff],pdgcolors[kProton],1.,2,pdgcolors[kProton],kWhite,0.045,0.055);
1101 
1102  SetTH1Style(hEffPionTPCDataV0tag[iEff],markersData[iEff],pdgcolors[kPion]+1,1.,2,pdgcolors[kPion]+1,kWhite,0.045,0.055);
1103  SetTH1Style(hEffPionTOFDataV0tag[iEff],markersData[iEff],pdgcolors[kPion]+1,1.,2,pdgcolors[kPion]+1,kWhite,0.045,0.055);
1104  SetTH1Style(hEffKaonTPCDataKinktag[iEff],markersData[iEff],pdgcolors[kKaon]+1,1.,2,pdgcolors[kKaon]+1,kWhite,0.045,0.055);
1105  SetTH1Style(hEffKaonTPCDataTOFtag[iEff],markersData[iEff],pdgcolors[kKaon]+3,1.,2,pdgcolors[kKaon]+3,kWhite,0.045,0.055);
1106  SetTH1Style(hEffKaonTOFDataTPCtag[iEff],markersData[iEff],pdgcolors[kKaon]+3,1.,2,pdgcolors[kKaon]+3,kWhite,0.045,0.055);
1107  SetTH1Style(hEffProtonTPCDataV0tag[iEff],markersData[iEff],pdgcolors[kProton]+1,1.,2,pdgcolors[kProton]+1,kWhite,0.045,0.055);
1108  SetTH1Style(hEffProtonTOFDataV0tag[iEff],markersData[iEff],pdgcolors[kProton]+1,1.,2,pdgcolors[kProton]+1,kWhite,0.045,0.055);
1109 
1110  SetTH1Style(hRatioEffPionTPCDataV0tag[iEff],markersData[iEff],pdgcolors[kPion]+1,1.,2,pdgcolors[kPion]+1,kWhite,0.045,0.055);
1111  SetTH1Style(hRatioEffPionTOFDataV0tag[iEff],markersData[iEff],pdgcolors[kPion]+1,1.,2,pdgcolors[kPion]+1,kWhite,0.045,0.055);
1112  SetTH1Style(hRatioEffKaonTPCDataKinktag[iEff],markersData[iEff],pdgcolors[kKaon]+1,1.,2,pdgcolors[kKaon]+1,kWhite,0.045,0.055);
1113  SetTH1Style(hRatioEffKaonTPCDataTOFtag[iEff],markersData[iEff],pdgcolors[kKaon]+3,1.,2,pdgcolors[kKaon]+3,kWhite,0.045,0.055);
1114  SetTH1Style(hRatioEffKaonTOFDataTPCtag[iEff],markersData[iEff],pdgcolors[kKaon]+3,1.,2,pdgcolors[kKaon]+3,kWhite,0.045,0.055);
1115  SetTH1Style(hRatioEffProtonTPCDataV0tag[iEff],markersData[iEff],pdgcolors[kProton]+1,1.,2,pdgcolors[kProton]+1,kWhite,0.045,0.055);
1116  SetTH1Style(hRatioEffProtonTOFDataV0tag[iEff],markersData[iEff],pdgcolors[kProton]+1,1.,2,pdgcolors[kProton]+1,kWhite,0.045,0.055);
1117  }
1118 
1119  TCanvas* cEffPion = new TCanvas("cEffPion","cEffPion",800,800);
1120  TCanvas* cEffKaon = new TCanvas("cEffKaon","cEffKaon",800,800);
1121  TCanvas* cEffProton = new TCanvas("cEffProton","cEffProton",800,800);
1122  cEffPion->Divide(2,2);
1123  cEffPion->cd(1)->DrawFrame(ptlims[0],0.,ptlims[nPtbins],1.,";#it{p}_{T} (GeV/#it{c});pion TPC PID efficiency");
1124  cEffPion->cd(2)->DrawFrame(ptlims[0],0.,ptlims[nPtbins],1.,";#it{p}_{T} (GeV/#it{c});pion TOF PID efficiency");
1125  cEffPion->cd(3)->DrawFrame(ptlims[0],0.85,ptlims[nPtbins],1.15,";#it{p}_{T} (GeV/#it{c}); pion data / MC TPC PID efficiency");
1126  cEffPion->cd(4)->DrawFrame(ptlims[0],0.85,ptlims[nPtbins],1.15,";#it{p}_{T} (GeV/#it{c});pion data / MC TOF PID efficiency");
1127  cEffKaon->Divide(2,2);
1128  cEffKaon->cd(1)->DrawFrame(ptlims[0],0.,ptlims[nPtbins],1.,";#it{p}_{T} (GeV/#it{c});kaon TPC PID efficiency");
1129  cEffKaon->cd(2)->DrawFrame(ptlims[0],0.,ptlims[nPtbins],1.,";#it{p}_{T} (GeV/#it{c});kaon TOF PID efficiency");
1130  cEffKaon->cd(3)->DrawFrame(ptlims[0],0.85,ptlims[nPtbins],1.15,";#it{p}_{T} (GeV/#it{c});kaon data / MC TPC PID efficiency");
1131  cEffKaon->cd(4)->DrawFrame(ptlims[0],0.85,ptlims[nPtbins],1.15,";#it{p}_{T} (GeV/#it{c});kaon data / MC TOF PID efficiency");
1132  cEffProton->Divide(2,2);
1133  cEffProton->cd(1)->DrawFrame(ptlims[0],0.,ptlims[nPtbins],1.,";#it{p}_{T} (GeV/#it{c});proton TPC PID efficiency");
1134  cEffProton->cd(2)->DrawFrame(ptlims[0],0.,ptlims[nPtbins],1.,";#it{p}_{T} (GeV/#it{c});proton TOF PID efficiency");
1135  cEffProton->cd(3)->DrawFrame(ptlims[0],0.85,ptlims[nPtbins],1.15,";#it{p}_{T} (GeV/#it{c});proton data / MC TPC PID efficiency");
1136  cEffProton->cd(4)->DrawFrame(ptlims[0],0.85,ptlims[nPtbins],1.15,";#it{p}_{T} (GeV/#it{c});proton data / MC TOF PID efficiency");
1137 
1138  for(int iEff=0; iEff<nEff; iEff++) {
1139  cEffPion->cd(1)->SetLogx();
1140  cEffPion->cd(1)->SetTopMargin(0.035);
1141  cEffPion->cd(1)->SetBottomMargin(0.12);
1142  cEffPion->cd(1)->SetRightMargin(0.035);
1143  hEffPionTPCMCtrue[iEff]->Draw("same");
1144  hEffPionTPCDataV0tag[iEff]->Draw("same");
1145  legEffPion->Draw("same");
1146 
1147  cEffPion->cd(2)->SetLogx();
1148  cEffPion->cd(2)->SetTopMargin(0.035);
1149  cEffPion->cd(2)->SetBottomMargin(0.12);
1150  cEffPion->cd(2)->SetRightMargin(0.035);
1151  hEffPionTOFMCtrue[iEff]->Draw("same");
1152  hEffPionTOFDataV0tag[iEff]->Draw("same");
1153  legEffPion->Draw("same");
1154 
1155  cEffPion->cd(3)->SetLogx();
1156  cEffPion->cd(3)->SetTopMargin(0.035);
1157  cEffPion->cd(3)->SetBottomMargin(0.12);
1158  cEffPion->cd(3)->SetRightMargin(0.035);
1159  hRatioEffPionTPCDataV0tag[iEff]->Draw("same");
1160 
1161  cEffPion->cd(4)->SetLogx();
1162  cEffPion->cd(4)->SetTopMargin(0.035);
1163  cEffPion->cd(4)->SetBottomMargin(0.12);
1164  cEffPion->cd(4)->SetRightMargin(0.035);
1165  hRatioEffPionTOFDataV0tag[iEff]->Draw("same");
1166 
1167  cEffKaon->cd(1)->SetLogx();
1168  cEffKaon->cd(1)->SetTopMargin(0.035);
1169  cEffKaon->cd(1)->SetBottomMargin(0.12);
1170  cEffKaon->cd(1)->SetRightMargin(0.035);
1171  hEffKaonTPCMCtrue[iEff]->Draw("same");
1172  hEffKaonTPCDataKinktag[iEff]->Draw("same");
1173  hEffKaonTPCDataTOFtag[iEff]->Draw("same");
1174  legEffKaonTPC->Draw("same");
1175 
1176  cEffKaon->cd(2)->SetLogx();
1177  cEffKaon->cd(2)->SetTopMargin(0.035);
1178  cEffKaon->cd(2)->SetBottomMargin(0.12);
1179  cEffKaon->cd(2)->SetRightMargin(0.035);
1180  hEffKaonTOFMCtrue[iEff]->Draw("same");
1181  hEffKaonTOFDataTPCtag[iEff]->Draw("same");
1182  legEffKaonTOF->Draw("same");
1183 
1184  cEffKaon->cd(3)->SetLogx();
1185  cEffKaon->cd(3)->SetTopMargin(0.035);
1186  cEffKaon->cd(3)->SetBottomMargin(0.12);
1187  cEffKaon->cd(3)->SetRightMargin(0.035);
1188  hRatioEffKaonTPCDataKinktag[iEff]->Draw("same");
1189  hRatioEffKaonTPCDataTOFtag[iEff]->Draw("same");
1190 
1191  cEffKaon->cd(4)->SetLogx();
1192  cEffKaon->cd(4)->SetTopMargin(0.035);
1193  cEffKaon->cd(4)->SetBottomMargin(0.12);
1194  cEffKaon->cd(4)->SetRightMargin(0.035);
1195  hRatioEffKaonTOFDataTPCtag[iEff]->Draw("same");
1196 
1197  cEffProton->cd(1)->SetLogx();
1198  cEffProton->cd(1)->SetTopMargin(0.035);
1199  cEffProton->cd(1)->SetBottomMargin(0.12);
1200  cEffProton->cd(1)->SetRightMargin(0.035);
1201  hEffProtonTPCMCtrue[iEff]->Draw("same");
1202  hEffProtonTPCDataV0tag[iEff]->Draw("same");
1203  legEffProton->Draw("same");
1204 
1205  cEffProton->cd(2)->SetLogx();
1206  cEffProton->cd(2)->SetTopMargin(0.035);
1207  cEffProton->cd(2)->SetBottomMargin(0.12);
1208  cEffProton->cd(2)->SetRightMargin(0.035);
1209  hEffProtonTOFMCtrue[iEff]->Draw("same");
1210  hEffProtonTOFDataV0tag[iEff]->Draw("same");
1211  legEffProton->Draw("same");
1212 
1213  cEffProton->cd(3)->SetLogx();
1214  cEffProton->cd(3)->SetTopMargin(0.035);
1215  cEffProton->cd(3)->SetBottomMargin(0.12);
1216  cEffProton->cd(3)->SetRightMargin(0.035);
1217  hRatioEffProtonTPCDataV0tag[iEff]->Draw("same");
1218 
1219  cEffProton->cd(4)->SetLogx();
1220  cEffProton->cd(4)->SetTopMargin(0.035);
1221  cEffProton->cd(4)->SetBottomMargin(0.12);
1222  cEffProton->cd(4)->SetRightMargin(0.035);
1223  hRatioEffProtonTOFDataV0tag[iEff]->Draw("same");
1224  }
1225 
1226  //********************************************************************************************************************************************//
1227  //output files
1228  TFile outfile("PIDSystSingleTrack.root","RECREATE");
1229  for(int iEff=0; iEff<nEff; iEff++) {
1230  hEffPionTPCMCtrue[iEff]->Write();
1231  hEffPionTOFMCtrue[iEff]->Write();
1232  hEffKaonTPCMCtrue[iEff]->Write();
1233  hEffKaonTOFMCtrue[iEff]->Write();
1234  hEffProtonTPCMCtrue[iEff]->Write();
1235  hEffProtonTOFMCtrue[iEff]->Write();
1236  hEffPionTPCDataV0tag[iEff]->Write();
1237  hEffPionTOFDataV0tag[iEff]->Write();
1238  hEffKaonTPCDataKinktag[iEff]->Write();
1239  hEffKaonTPCDataTOFtag[iEff]->Write();
1240  hEffKaonTOFDataTPCtag[iEff]->Write();
1241  hEffProtonTPCDataV0tag[iEff]->Write();
1242  hEffProtonTOFDataV0tag[iEff]->Write();
1243  hRatioEffPionTPCDataV0tag[iEff]->Write();
1244  hRatioEffPionTOFDataV0tag[iEff]->Write();
1245  hRatioEffKaonTPCDataKinktag[iEff]->Write();
1246  hRatioEffKaonTPCDataTOFtag[iEff]->Write();
1247  hRatioEffKaonTOFDataTPCtag[iEff]->Write();
1248  hRatioEffProtonTPCDataV0tag[iEff]->Write();
1249  hRatioEffProtonTOFDataV0tag[iEff]->Write();
1250  }
1251  outfile.Close();
1252 
1253  TFile outfiledist("NsigmaPIDdist.root","RECREATE");
1254  for(int iPt=0; iPt<nPtbins; iPt++) {
1255  hNsigmaTPCPionMCTrue[iPt]->Write();
1256  hNsigmaTPCKaonMCTrue[iPt]->Write();
1257  hNsigmaTPCProtonMCTrue[iPt]->Write();
1258  hNsigmaTOFPionMCTrue[iPt]->Write();
1259  hNsigmaTOFKaonMCTrue[iPt]->Write();
1260  hNsigmaTOFProtonMCTrue[iPt]->Write();
1261  }
1262  for(int iPt=0; iPt<nPtbins; iPt++) {
1263  for(int iPart=kElectron; iPart<=kAll; iPart++) {
1264  hNsigmaTPCPionMCV0tag[iPt][iPart]->Write();
1265  hNsigmaTPCKaonMCKinktag[iPt][iPart]->Write();
1266  hNsigmaTPCKaonMCTOFtag[iPt][iPart]->Write();
1267  hNsigmaTPCProtonMCV0tag[iPt][iPart]->Write();
1268  hNsigmaTOFPionMCV0tag[iPt][iPart]->Write();
1269  hNsigmaTOFKaonMCKinktag[iPt][iPart]->Write();
1270  hNsigmaTOFKaonMCTPCtag[iPt][iPart]->Write();
1271  hNsigmaTOFProtonMCV0tag[iPt][iPart]->Write();
1272 
1273  }
1274  }
1275  for(int iPt=0; iPt<nPtbins; iPt++) {
1276  hNsigmaTPCPionDataV0tag[iPt]->Write();
1277  hNsigmaTPCKaonDataKinktag[iPt]->Write();
1278  hNsigmaTPCKaonDataTOFtag[iPt]->Write();
1279  hNsigmaTPCProtonDataV0tag[iPt]->Write();
1280  hNsigmaTOFPionDataV0tag[iPt]->Write();
1281  hNsigmaTOFKaonDataKinktag[iPt]->Write();
1282  hNsigmaTOFKaonDataTPCtag[iPt]->Write();
1283  hNsigmaTOFProtonDataV0tag[iPt]->Write();
1284  }
1285  for(int iPt=0; iPt<nPtbins; iPt++) {
1286  hNsigmaTOFPionDataV0tag_sub[iPt]->Write();
1287  hNsigmaTOFKaonDataKinktag_sub[iPt]->Write();
1288  hNsigmaTOFKaonDataTPCtag_sub[iPt]->Write();
1289  hNsigmaTOFProtonDataV0tag_sub[iPt]->Write();
1290  }
1291  for(int iPt=0; iPt<nPtbins; iPt++) {
1292  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1293  fNsigmaTPCPionMCV0tag[iPt][iPart]->Write();
1294  fNsigmaTPCKaonMCKinktag[iPt][iPart]->Write();
1295  fNsigmaTPCKaonMCTOFtag[iPt][iPart]->Write();
1296  fNsigmaTPCProtonMCV0tag[iPt][iPart]->Write();
1297  }
1298  }
1299  for(int iPt=0; iPt<nPtbins; iPt++) {
1300  for(int iPart=kElectron; iPart<=kAll; iPart++) {
1301  fNsigmaTPCPionDataV0tag[iPt][iPart]->Write();
1302  fNsigmaTPCKaonDataKinktag[iPt][iPart]->Write();
1303  fNsigmaTPCKaonDataTOFtag[iPt][iPart]->Write();
1304  fNsigmaTPCProtonDataV0tag[iPt][iPart]->Write();
1305  }
1306  }
1307  for(int iPt=0; iPt<nPtbins; iPt++) {
1308  for(int iPart=kElectron; iPart<=kAll; iPart++) {
1309  if(hNsigmaTOFKaonDataTPCtag_Fit[iPt][iPart]) hNsigmaTOFKaonDataTPCtag_Fit[iPt][iPart]->Write();
1310  if(hNsigmaTOFProtonDataV0tag_Fit[iPt][iPart]) hNsigmaTOFProtonDataV0tag_Fit[iPt][iPart]->Write();
1311  }
1312  }
1313  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1314  hFractionTPCPionMCV0tag[iPart]->Write();
1315  hFractionTPCKaonMCKinktag[iPart]->Write();
1316  hFractionTPCKaonMCTOFtag[iPart]->Write();
1317  hFractionTPCProtonMCV0tag[iPart]->Write();
1318  hFractionTOFPionMCV0tag[iPart]->Write();
1319  hFractionTOFKaonMCKinktag[iPart]->Write();
1320  hFractionTOFKaonMCTPCtag[iPart]->Write();
1321  hFractionTOFProtonMCV0tag[iPart]->Write();
1322  }
1323  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1324  hFractionTOFKaonDataTPCtag[iPart]->Write();
1325  hFractionTOFProtonDataV0tag[iPart]->Write();
1326  }
1327  outfiledist.Close();
1328 
1329 
1330  cFractionTPCMC->SaveAs("ParticleFractionsTPCMC.pdf");
1331  cFractionTOFMC->SaveAs("ParticleFractionsTOFMC.pdf");
1332  cTOFFractionData->SaveAs("ParticleFractionsTOFdata.pdf");
1333 
1334  cFitResultTOFKaonFromTPCtag->SaveAs("TFractionFitterResultTOFKaonFromTPCtag.pdf");
1335  cFitResultTOFProtonFromV0tag->SaveAs("TFractionFitterResultTOFProtonFromV0tag.pdf");
1336 
1337  cPionMCV0tagTPC->SaveAs("PionMCV0tagTPC.pdf");
1338  cKaonMCKinkstagTPC->SaveAs("KaonMCKinkstagTPC.pdf");
1339  cKaonMCTOFtagTPC->SaveAs("KaonMCTOFtagTPC.pdf");
1340  cProtonMCV0tagTPC->SaveAs("ProtonMCV0tagTPC.pdf");
1341  cPionMCV0tagTOF->SaveAs("PionMCV0tagTOF.pdf");
1342  cKaonMCKinkstagTOF->SaveAs("KaonMCKinkstagTOF.pdf");
1343  cKaonMCTPCtagTOF->SaveAs("KaonMCTPCtagTOF.pdf");
1344  cProtonMCV0tagTOF->SaveAs("ProtonMCV0tagTOF.pdf");
1345 
1346  cPionDataV0tagTPC->SaveAs("PionDataV0tagTPC.pdf");
1347  cKaonDataKinkstagTPC->SaveAs("KaonDataKinkstagTPC.pdf");
1348  cKaonDataTOFtagTPC->SaveAs("KaonDataTOFtagTPC.pdf");
1349  cProtonDataV0tagTPC->SaveAs("ProtonDataV0tagTPC.pdf");
1350  cPionDataV0tagTOF->SaveAs("PionDataV0tagTOF.pdf");
1351  cKaonDataKinkstagTOF->SaveAs("KaonDataKinkstagTOF.pdf");
1352  cKaonDataTPCtagTOF->SaveAs("KaonDataTPCtagTOF.pdf");
1353  cProtonDataV0tagTOF->SaveAs("ProtonDataV0tagTOF.pdf");
1354 
1355  cEffPion->SaveAs("PionPIDefficiency_data_MC.pdf");
1356  cEffKaon->SaveAs("KaonPIDefficiency_data_MC.pdf");
1357  cEffProton->SaveAs("ProtonPIDefficiency_data_MC.pdf");
1358 
1359  return 0;
1360 }
1361 
1362 //_____________________________________________________
1363 int GetHistoParticleIndex(short pdgcode) {
1364  switch(pdgcode) {
1365  case 11:
1366  return kElectron;
1367  break;
1368  case 13:
1369  return kMuon;
1370  break;
1371  case 211:
1372  return kPion;
1373  break;
1374  case 321:
1375  return kKaon;
1376  break;
1377  case 2212:
1378  return kProton;
1379  break;
1380  }
1381  return -1;
1382 }
1383 
1384 //_____________________________________________________
1385 int FindPtbin(float pt, const double ptlims[], int nPtbins) {
1386 
1387  int ptbin=-1;
1388  for(int iPt=0; iPt<nPtbins; iPt++) {
1389  if(pt>ptlims[iPt] && pt<ptlims[iPt+1]) {
1390  ptbin=iPt;
1391  break;
1392  }
1393  }
1394 
1395  return ptbin;
1396 }
1397 
1398 //______________________________________________________
1399 void ComputeEfficiency(double num, double den, double &eff, double &effunc) {
1400 
1401  TH1F htmpnum("htmpnum","",1,0,1);
1402  TH1F htmpden("htmpden","",1,0,1);
1403  TH1F htmpratio("htmpratio","",1,0,1);
1404 
1405  htmpnum.SetBinContent(1,num);
1406  htmpden.SetBinContent(1,den);
1407  htmpnum.SetBinError(1,TMath::Sqrt(num));
1408  htmpden.SetBinError(1,TMath::Sqrt(den));
1409  htmpratio.Divide(&htmpnum,&htmpden,1.,1.,"B");
1410  eff=htmpratio.GetBinContent(1);
1411  effunc=htmpratio.GetBinError(1);
1412 }
1413 
1414 //______________________________________________________
1415 void GetTOFFractionsFromData(int whichpart, int iPt, TH1F* hFractionMC[nPDGcodes-1], TH1F* hFractionData[nPDGcodes-1], TH1F* hNsigmaMC[nPDGcodes], TH1F* hNsigmaData, TFractionFitter *&fNsigmaFitter, vector<int> &templUsed) {
1416 
1417  TObjArray* oNsigmaMC = new TObjArray(0);
1418 
1419  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1420  if(iPart==whichpart || hFractionMC[iPart]->GetBinContent(iPt+1)>1.e-5) {
1421  TH1F* hMC = (TH1F*)hNsigmaMC[iPart]->Clone(Form("hMC_%d_%s",iPt,pdgnames[iPart].Data()));
1422  oNsigmaMC->AddLast(hMC);
1423  templUsed.push_back(iPart);
1424  }
1425  }
1426 
1427  if(templUsed.size()==1) {
1428  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1429  if(iPart==whichpart) {
1430  hFractionData[iPart]->SetBinContent(iPt+1,1.);
1431  }
1432  else {
1433  hFractionData[iPart]->SetBinContent(iPt+1,0.);
1434  }
1435  }
1436  return;
1437  }
1438 
1439  if(oNsigmaMC->GetEntries()>1) {
1440 
1441  fNsigmaFitter = new TFractionFitter(hNsigmaData,oNsigmaMC);
1442  for(int iEntry=0; iEntry<oNsigmaMC->GetEntries(); iEntry++) {
1443  fNsigmaFitter->Constrain(iEntry,hFractionMC[templUsed[iEntry]]->GetBinContent(iPt+1)*0.5,hFractionMC[templUsed[iEntry]]->GetBinContent(iPt+1)*2);
1444  }
1445  fNsigmaFitter->Fit();
1446 
1447  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1448 
1449  vector<int>::iterator it = find(templUsed.begin(), templUsed.end(), iPart);
1450  if(it!=templUsed.end()) {
1451  double frac, err;
1452  int iEntry = static_cast<int>(distance(templUsed.begin(),it));
1453 
1454  fNsigmaFitter->GetResult(iEntry, frac, err);
1455  hFractionData[iPart]->SetBinContent(iPt+1,frac);
1456  hFractionData[iPart]->SetBinError(iPt+1,err);
1457  }
1458  else {
1459  hFractionData[iPart]->SetBinContent(iPt+1,0);
1460  hFractionData[iPart]->SetBinError(iPt+1,0);
1461  }
1462  }
1463  }
1464  else {
1465  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1466  if(iPart!=whichpart) {
1467  hFractionData[iPart]->SetBinContent(iPt+1,1);
1468  hFractionData[iPart]->SetBinError(iPt+1,1);
1469  }
1470  else {
1471  hFractionData[iPart]->SetBinContent(iPt+1,0);
1472  hFractionData[iPart]->SetBinError(iPt+1,0);
1473  }
1474  }
1475  }
1476 
1477 }
1478 
1479 //______________________________________________________
1480 double PDFnsigmaTPCtot(double* nsigma, double* pars) {
1481 
1482  double partpdf[nPDGcodes-1];
1483  double totalpdf = 0;
1484  for(int iPart=kElectron; iPart<=kProton; iPart++) {
1485  partpdf[iPart] = pars[3*iPart]*TMath::Gaus(nsigma[0],pars[3*iPart+1],pars[3*iPart+2]);
1486  totalpdf += partpdf[iPart];
1487  }
1488 
1489  return totalpdf;
1490 }
1491 
1492 //_____________________________________________________
1493 void PlotQAhistos(TList* listMC, TList* listData) {
1494 
1495  //V0 QA histos
1496  TString ArmenterosName[5] = {"All","K0s","Lambda","AntiLambda","Gamma"};
1497  TString legV0name[4] = {"K_{s}^{0} #rightarrow #pi^{+}#pi^{-}","#Lambda #rightarrow p#pi^{-}","#bar{#Lambda} #rightarrow #bar{p}#pi^{+}","#gamma #rightarrow e^{+}e^{-}"};
1498  int ArmenterosColor[5] = {kBlack,kOrange+7,kRed,kBlue,kGreen+3};
1499  TH2F* hArmenterosMC[5];
1500  TH2F* hArmenterosData[5];
1501 
1502  //kinks QA histos
1503  TString KinksName[5] = {"QtVsMassKinks","PDaughterVsMotherKink","OpeningAngleVsPMotherKink","dEdxVsPMotherKink","NTPCclsVsRadius"};
1504  TH2F* hKinksMC[5];
1505  TH2F* hKinksData[5];
1506 
1507  TCanvas* cArmentero = new TCanvas("cArmenteros","cArmenteros",1920,1080);
1508  TCanvas* cKinks = new TCanvas("cKinks","cKinks",1920,1080);
1509  cArmentero->Divide(2,1);
1510  cKinks->Divide(5,2);
1511  TLatex* latV0[5];
1512 
1513  for(int iHisto=0; iHisto<5; iHisto++) {
1514  hArmenterosMC[iHisto] = (TH2F*)listMC->FindObject(Form("fHistArmenteroPlot%s",ArmenterosName[iHisto].Data()));
1515  hArmenterosData[iHisto] = (TH2F*)listData->FindObject(Form("fHistArmenteroPlot%s",ArmenterosName[iHisto].Data()));
1516  hArmenterosMC[iHisto]->SetDirectory(0);
1517  hArmenterosData[iHisto]->SetDirectory(0);
1518  hArmenterosData[iHisto]->SetMarkerColor(ArmenterosColor[iHisto]);
1519  hArmenterosMC[iHisto]->SetMarkerColor(ArmenterosColor[iHisto]);
1520  hArmenterosData[iHisto]->GetYaxis()->SetTitleOffset(1.4);
1521  hArmenterosMC[iHisto]->GetYaxis()->SetTitleOffset(1.4);
1522  latV0[iHisto] = new TLatex();
1523  latV0[iHisto]->SetNDC();
1524  latV0[iHisto]->SetTextFont(42);
1525  latV0[iHisto]->SetTextColor(ArmenterosColor[iHisto]);
1526  latV0[iHisto]->SetTextSize(0.045);
1527  cArmentero->cd(1);
1528  hArmenterosMC[iHisto]->Draw("same");
1529  cArmentero->cd(2);
1530  hArmenterosData[iHisto]->Draw("same");
1531  if(iHisto!=0) {
1532  cArmentero->cd(1);
1533  latV0[iHisto]->DrawLatex(0.6,0.8-0.05*iHisto,legV0name[iHisto-1].Data());
1534  cArmentero->cd(2);
1535  latV0[iHisto]->DrawLatex(0.6,0.8-0.05*iHisto,legV0name[iHisto-1].Data());
1536  }
1537 
1538  hKinksMC[iHisto] = (TH2F*)listMC->FindObject(Form("fHist%s",KinksName[iHisto].Data()));
1539  hKinksData[iHisto] = (TH2F*)listData->FindObject(Form("fHist%s",KinksName[iHisto].Data()));
1540  hKinksMC[iHisto]->SetTitle("MC");
1541  hKinksData[iHisto]->SetTitle("Data");
1542 
1543  cKinks->cd(1+iHisto)->SetLogz();
1544  hKinksMC[iHisto]->Draw("colz");
1545  cKinks->cd(6+iHisto)->SetLogz();
1546  hKinksData[iHisto]->Draw("colz");
1547  }
1548 
1549  TH1F* hKinksMassMC = (TH1F*)hKinksMC[0]->ProjectionX("hKinksMassMC");
1550  hKinksMassMC->Scale(1./hKinksMassMC->Integral());
1551  hKinksMassMC->SetLineColor(kBlue);
1552  hKinksMassMC->SetLineWidth(2);
1553  hKinksMassMC->SetMarkerColor(kBlue);
1554  hKinksMassMC->SetMarkerStyle(kFullSquare);
1555  hKinksMassMC->SetTitle("");
1556  hKinksMassMC->GetYaxis()->SetTitle("Normalised entries");
1557  hKinksMassMC->GetYaxis()->SetTitleSize(0.045);
1558  hKinksMassMC->GetYaxis()->SetLabelSize(0.04);
1559  hKinksMassMC->GetXaxis()->SetTitleSize(0.045);
1560  hKinksMassMC->GetXaxis()->SetLabelSize(0.04);
1561 
1562  TH1F* hKinksMassData = (TH1F*)hKinksData[0]->ProjectionX("hKinksMassData");
1563  hKinksMassData->Scale(1./hKinksMassData->Integral());
1564  hKinksMassData->SetLineColor(kRed);
1565  hKinksMassData->SetLineWidth(2);
1566  hKinksMassData->SetMarkerColor(kRed);
1567  hKinksMassData->SetMarkerStyle(kFullDiamond);
1568  hKinksMassData->SetTitle("");
1569  hKinksMassData->GetYaxis()->SetTitle("Normalised entries");
1570  hKinksMassData->GetYaxis()->SetTitleSize(0.045);
1571  hKinksMassData->GetYaxis()->SetLabelSize(0.04);
1572  hKinksMassData->GetXaxis()->SetTitleSize(0.045);
1573  hKinksMassData->GetXaxis()->SetLabelSize(0.04);
1574 
1575  TLegend* leg = new TLegend(0.2,0.7,0.4,0.8);
1576  leg->SetTextSize(0.045);
1577  leg->AddEntry(hKinksMassMC,"MC","lpe");
1578  leg->AddEntry(hKinksMassData,"Data","lpe");
1579  TCanvas* cKinksMass = new TCanvas("cKinksMass","",800,800);
1580  cKinksMass->SetTopMargin(0.1);
1581  hKinksMassMC->Draw();
1582  hKinksMassData->Draw("same");
1583  leg->Draw("same");
1584 
1585  cArmentero->SaveAs("V0QAplots.pdf");
1586  cKinks->SaveAs("KinksQAplots.pdf");
1587  cKinksMass->SaveAs("KinksMass.pdf");
1588  cArmentero->SaveAs("V0QAplots.png");
1589  cKinks->SaveAs("KinksQAplots.png");
1590 }
1591 
1592 //_____________________________________________________
1593 void DivideCanvas(TCanvas* c, int nPtbins) {
1594  if(nPtbins<2)
1595  c->cd();
1596  else if(nPtbins==2 || nPtbins==3)
1597  c->Divide(nPtbins,1);
1598  else if(nPtbins==4 || nPtbins==6 || nPtbins==8)
1599  c->Divide(nPtbins/2,2);
1600  else if(nPtbins==5 || nPtbins==7)
1601  c->Divide((nPtbins+1)/2,2);
1602  else if(nPtbins==9 || nPtbins==12 || nPtbins==15)
1603  c->Divide(nPtbins/3,3);
1604  else if(nPtbins==10 || nPtbins==11)
1605  c->Divide(4,3);
1606  else if(nPtbins==13 || nPtbins==14)
1607  c->Divide(5,3);
1608  else if(nPtbins>15 && nPtbins<=20 && nPtbins%4==0)
1609  c->Divide(nPtbins/4,4);
1610  else if(nPtbins>15 && nPtbins<=20 && nPtbins%4!=0)
1611  c->Divide(5,4);
1612  else if(nPtbins==21)
1613  c->Divide(7,3);
1614  else if(nPtbins>21 && nPtbins<=25)
1615  c->Divide(5,5);
1616  else if(nPtbins>25 && nPtbins%2==0)
1617  c->Divide(nPtbins/2,2);
1618  else
1619  c->Divide((nPtbins+1)/2,2);
1620 }
1621 
1622 //_____________________________________________________
1623 void SetStyle() {
1624  gStyle->SetLegendBorderSize(1);
1625  gStyle->SetTitleOffset(1.4,"y");
1626  gStyle->SetTitleOffset(1.2,"x");
1627  gStyle->SetPadTopMargin(0.14);
1628  gStyle->SetPadRightMargin(0.035);
1629  gStyle->SetPadLeftMargin(0.14);
1630  gStyle->SetPadBottomMargin(0.14);
1631  gStyle->SetTitleSize(0.05,"xyzt");
1632  gStyle->SetLabelSize(0.045,"xyz");
1633 
1634  gStyle->SetPadTickX(1);
1635  gStyle->SetPadTickY(1);
1636  gStyle->SetOptStat(0);
1637 
1638  TGaxis::SetMaxDigits(3);
1639 }
1640 
1641 //_____________________________________________________
1642 void SetTH1Style(TH1F* histo, int markerstyle, int markercolor, float markersize, int linewidth, int linecolor, int fillcolor, float labelsize, float titlesize) {
1643 
1644  histo->SetMarkerStyle(markerstyle);
1645  histo->SetMarkerSize(markersize);
1646  histo->SetMarkerColor(markercolor);
1647  histo->SetLineWidth(linewidth);
1648  histo->SetLineColor(linecolor);
1649  histo->SetFillColorAlpha(fillcolor,0.25);
1650 
1651  if(labelsize>0) {
1652  histo->GetXaxis()->SetLabelSize(labelsize);
1653  histo->GetYaxis()->SetLabelSize(labelsize);
1654  }
1655  if(titlesize>0) {
1656  histo->GetXaxis()->SetTitleSize(labelsize);
1657  histo->GetYaxis()->SetTitleSize(labelsize);
1658  histo->SetTitleSize(labelsize);
1659  }
1660 }
const TString indirNameData
void Draw(const char *filename, const char *title="", const char *others="ALL", const char *options="DEFAULT", const char *outFlg="ALL", UShort_t rebin=5, Float_t eff=0, const char *base="")
Definition: DrawdNdeta.C:3603
Definition: External.C:236
const TString pdgnames[nPDGcodes]
const TString infileNameData
void DivideCanvas(TCanvas *c, int nPtbins)
double PDFnsigmaTPCtot(double *nsigma, double *pars)
TCanvas * c
Definition: TestFitELoss.C:172
const TString inlistNameMC
void SetTH1Style(TH1F *histo, int markerstyle, int markercolor, float markersize, int linewidth, int linecolor, int fillcolor, float labelsize=-1, float titlesize=-1)
const int pdgcodes[nPDGcodes]
void ComputeEfficiency(double num, double den, double &eff, double &effunc)
const TString indirNameMC
const int pdgcolors[nPDGcodes]
const TString inlistNameData
int EstimateSingleTrackPIDsyst(int maxEntries=1.e8)
const double ptlims[]
Double_t nsigma
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void PlotQAhistos(TList *listMC, TList *listData)
const int nPDGcodes
const TString infileNameMC
TList * listMC
int FindPtbin(float pt, const double ptlims[], int nPtbins)
int GetHistoParticleIndex(short pdgcode)
const int pdgfillcolors[nPDGcodes]
void GetTOFFractionsFromData(int whichpart, int iPt, TH1F *hFractionMC[nPDGcodes-1], TH1F *hFractionData[nPDGcodes-1], TH1F *hNsigmaMC[nPDGcodes], TH1F *hNsigmaData, TFractionFitter *&fNsigmaFitter, vector< int > &templUsed)