]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/macros/makeTFile4CutsLctoV0bachelor.C
Updates in Lc->V0bachelor analysis (Annalisa)
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / macros / makeTFile4CutsLctoV0bachelor.C
1 #include <Riostream.h>
2 #include <TFile.h>
3 #include <AliRDHFCutsLctoV0.h>
4 #include <AliAODPidHF.h>
5 #include <TClonesArray.h>
6 #include <TParameter.h>
7 #include <TF1.h>
8
9
10 //Use:
11 //Set hard coded commentet with //set this!!
12 // root[] .L makeInput...C++
13 // root[] makeInputAliAnalysisTaskSE...()
14 //similar macros for D mesons as well as for Lc->3prongs
15
16 //Author: Annalisa De Caro - decaro@sa.infn.it
17
18
19 //macro to make a .root file which contains an AliRDHFCutsLctoV0 for AliAnalysisTaskSELc2pK0S task
20
21 void makeInputAliAnalysisTaskSELctoV0bachelor(){
22
23   AliRDHFCutsLctoV0* RDHFLctoV0Prod=new AliRDHFCutsLctoV0();
24   RDHFLctoV0Prod->SetName("LctoV0ProductionCuts");
25   RDHFLctoV0Prod->SetTitle("Production cuts for Lc analysis");
26   AliESDtrackCuts* esdTrackCutsProd=new AliESDtrackCuts();
27   RDHFLctoV0Prod->AddTrackCuts(esdTrackCutsProd);
28   RDHFLctoV0Prod->AddTrackCutsV0daughters(esdTrackCutsProd);
29   RDHFLctoV0Prod->SetUseTrackSelectionWithFilterBits(kFALSE);
30   RDHFLctoV0Prod->SetPidSelectionFlag(2); // 0 -> TOF AND TPC
31                                           // 1 -> if (TOF) TOF else TPC w veto
32                                           // 2 -> if (p<1) TPC@3s else if (1<=p<2.5) {if (TOF) TOF@3s AND TPC@3s} else (p>=2.5) {if (TOF) -2s<TOF<3s AND TPC@3s}
33                                           // 3 -> if (p<1) TPC@3s else if (1<=p<2.5) {if (TOF) TOF@3s AND TPC@3s} else if (2.5<=p<3) {if (TOF) -2s<TOF<3s AND TPC@3s} else (p>=3) {if (TOF) -2s<TOF<3s AND -3s<TPC<2s}
34
35   AliESDtrackCuts* esdTrackCuts=new AliESDtrackCuts();
36   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
37   //default
38   esdTrackCuts->SetRequireTPCRefit(kTRUE);
39   esdTrackCuts->SetRequireITSRefit(kTRUE);
40   esdTrackCuts->SetMinNClustersITS(0);//(4); // default is 5
41   esdTrackCuts->SetMinNClustersTPC(70);
42   //esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
43   //                                       AliESDtrackCuts::kAny); 
44   // default is kBoth, otherwise kAny
45   esdTrackCuts->SetMinDCAToVertexXY(0.);
46   //esdTrackCuts->SetPtRange(0.3,1.e10);
47   esdTrackCuts->SetPtRange(0.,1.e10);
48   esdTrackCuts->SetEtaRange(-0.8,0.8);
49   esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
50
51
52
53   AliESDtrackCuts* esdTrackCutsV0daughters=new AliESDtrackCuts();
54   esdTrackCutsV0daughters->SetRequireSigmaToVertex(kFALSE);
55   //default
56   esdTrackCutsV0daughters->SetRequireTPCRefit(kTRUE);
57   esdTrackCutsV0daughters->SetRequireITSRefit(kFALSE);//kTRUE);
58   esdTrackCutsV0daughters->SetMinNClustersITS(0);//(4); // default is 5
59   esdTrackCutsV0daughters->SetMinNClustersTPC(70);
60   //esdTrackCutsV0daughters->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
61   //                                                  AliESDtrackCuts::kAny); 
62   // default is kBoth, otherwise kAny
63   esdTrackCutsV0daughters->SetMinDCAToVertexXY(0.);
64   esdTrackCutsV0daughters->SetPtRange(0.,1.e10);
65   esdTrackCutsV0daughters->SetEtaRange(-0.8,0.8);
66   esdTrackCutsV0daughters->SetAcceptKinkDaughters(kFALSE);
67
68
69
70   AliRDHFCutsLctoV0* RDHFLctoV0An=new AliRDHFCutsLctoV0();
71   RDHFLctoV0An->SetName("LctoV0AnalysisCuts");
72   RDHFLctoV0An->SetTitle("Analysis cuts for Lc analysis");
73   RDHFLctoV0An->AddTrackCuts(esdTrackCuts);
74   RDHFLctoV0An->AddTrackCutsV0daughters(esdTrackCutsV0daughters);
75   RDHFLctoV0An->SetUseTrackSelectionWithFilterBits(kFALSE);
76   RDHFLctoV0An->SetPidSelectionFlag(2); // 0 -> TOF AND TPC
77                                         // 1 -> if (TOF) TOF else TPC w veto
78                                         // 2 -> if (p>1) TPC@3s else if (1<=p<2.5) {if (TOF) TOF@3s AND TPC@3s} else (p>=2.5) {if (TOF) -2s<TOF<3s AND TPC@3s}
79                                         // 3 -> if (p>1) TPC@3s else if (1<=p<2.5) {if (TOF) TOF@3s AND TPC@3s} else if (2.5<=p<3) {if (TOF) -2s<TOF<3s AND TPC@3s} else (p>=3) {if (TOF) -2s<TOF<3s AND -3s<TPC<2s}
80
81   const Int_t nptbins=9;
82   RDHFLctoV0Prod->SetNPtBins(nptbins);
83   RDHFLctoV0An->SetNPtBins(nptbins);
84
85   Float_t* ptbins;
86   ptbins=new Float_t[nptbins+1];
87   ptbins[0]= 0.;
88   ptbins[1]= 1.;
89   ptbins[2]= 2.;
90   ptbins[3]= 3.;
91   ptbins[4]= 4.;
92   ptbins[5]= 5.;
93   ptbins[6]= 6.;
94   ptbins[7]= 8.;
95   ptbins[8]=12.;
96   ptbins[9]=99999999.;
97   RDHFLctoV0Prod->SetPtBins(nptbins+1,ptbins);
98   RDHFLctoV0An->SetPtBins(nptbins+1,ptbins);
99
100   const Int_t nvars=17;
101
102   Float_t** prodcutsval;
103   prodcutsval=new Float_t*[nvars];
104   for(Int_t ic=0;ic<nvars;ic++){prodcutsval[ic]=new Float_t[nptbins];}
105   for(Int_t ipt2=0;ipt2<nptbins;ipt2++){
106    prodcutsval[0][ipt2]=1.;    // inv. mass if K0S [GeV/c2]
107    prodcutsval[1][ipt2]=1.;    // inv. mass if Lambda [GeV/c2]
108    prodcutsval[2][ipt2]=0.05;  // inv. mass V0 if K0S [GeV/c2]
109    prodcutsval[3][ipt2]=0.05;  // inv. mass V0 if Lambda [GeV/c2]
110    prodcutsval[4][ipt2]=0.3;   // pT min bachelor track [GeV/c] // AOD by construction
111    prodcutsval[5][ipt2]=0.;    // pT min V0-positive track [GeV/c]
112    prodcutsval[6][ipt2]=0.;    // pT min V0-negative track [GeV/c]
113    prodcutsval[7][ipt2]=1000.; // dca cascade cut [cm]
114    prodcutsval[8][ipt2]=1000.; // dca V0 cut [nSigma] // it's 1.5 x offline V0s
115    prodcutsval[9][ipt2]=-1.;   // cosPA V0 cut // it's 0.90 x offline V0s at reconstruction level, 0.99 at filtering level
116    prodcutsval[10][ipt2]=3.;   // d0 max bachelor wrt PV [cm]
117    prodcutsval[11][ipt2]=1000.;// d0 max V0 wrt PV [cm]
118    prodcutsval[12][ipt2]=0.;   // mass K0S veto [GeV/c2]
119    prodcutsval[13][ipt2]=0.;   // mass Lambda/LambdaBar veto [GeV/c2]
120    prodcutsval[14][ipt2]=0.;   // mass Gamma veto [GeV/c2]
121    prodcutsval[15][ipt2]=0.;   // pT min V0 track [GeV/c]
122    prodcutsval[16][ipt2]=0.;   // V0 type cut
123   }
124
125
126   RDHFLctoV0Prod->SetCuts(nvars,nptbins,prodcutsval);
127
128   Float_t** anacutsval;
129   anacutsval=new Float_t*[nvars];
130   for(Int_t ic=0;ic<nvars;ic++){anacutsval[ic]=new Float_t[nptbins];}
131   for(Int_t ipt2=0;ipt2<nptbins;ipt2++){
132    anacutsval[0][ipt2]=0.25;   // inv. mass if K0S [GeV/c2]
133    anacutsval[1][ipt2]=0.25;   // inv. mass if Lambda [GeV/c2]
134    anacutsval[2][ipt2]=0.0075; // inv. mass V0 if K0S [GeV/c2]
135    anacutsval[3][ipt2]=0.0030; // inv. mass V0 if Lambda [GeV/c2]
136    anacutsval[4][ipt2]=0.4;    // pT min bachelor track [GeV/c] // AOD by construction
137    anacutsval[5][ipt2]=0.2;    // pT min V0-positive track [GeV/c]
138    anacutsval[6][ipt2]=0.2;    // pT min V0-negative track [GeV/c]
139    anacutsval[7][ipt2]=1000.;  // dca cascade cut [cm]
140    anacutsval[8][ipt2]=1.5;    // dca V0 cut [nSigma] // it's 1.5 x offline V0s
141    anacutsval[9][ipt2]=0.99;   // cosPA V0 cut // it's 0.90 x offline V0s at reconstruction level, 0.99 at filtering level
142    anacutsval[10][ipt2]=0.05;  // d0 max bachelor wrt PV [cm]
143    anacutsval[11][ipt2]=0.1;   // d0 max V0 wrt PV [cm]
144    anacutsval[12][ipt2]=0.;    // mass K0S veto [GeV/c2]
145    anacutsval[13][ipt2]=0.005; // mass Lambda/LambdaBar veto [GeV/c2]
146    anacutsval[14][ipt2]=0.100; // mass Gamma veto [GeV/c2]
147    anacutsval[16][ipt2]=0.;    // V0 type cut
148   }
149
150   anacutsval[15][0]=0.0; // pT min V0 track [GeV/c]
151   anacutsval[15][1]=0.6; // pT min V0 track [GeV/c]
152   anacutsval[15][2]=0.8; // pT min V0 track [GeV/c]
153   anacutsval[15][3]=0.8; // pT min V0 track [GeV/c]
154   anacutsval[15][4]=0.8; // pT min V0 track [GeV/c]
155   anacutsval[15][5]=1.0; // pT min V0 track [GeV/c]
156   anacutsval[15][6]=1.0; // pT min V0 track [GeV/c]
157   anacutsval[15][7]=1.0; // pT min V0 track [GeV/c]
158   anacutsval[15][8]=0.0; // pT min V0 track [GeV/c]
159   anacutsval[15][9]=0.0; // pT min V0 track [GeV/c]
160
161
162   RDHFLctoV0An->SetCuts(nvars,nptbins,anacutsval);
163
164
165   //RDHFLc->SetRecoKF(); //set this if you want to recompute the secondary vertex with the KF package
166
167   //pid settings
168   //1. bachelor: default one
169   AliAODPidHF* pidObjBachelor = new AliAODPidHF();
170   Double_t sigmasBac[5]={3.,1.,1.,3.,3.}; // 0, 1(A), 2(A) -> TPC; 3 -> TOF; 4 -> ITS
171   pidObjBachelor->SetSigma(sigmasBac);
172   pidObjBachelor->SetAsym(kFALSE);
173   pidObjBachelor->SetMatch(1);
174   pidObjBachelor->SetTPC(kTRUE);
175   pidObjBachelor->SetTOF(kTRUE);
176   pidObjBachelor->SetTOFdecide(kFALSE);
177
178   RDHFLctoV0An->SetPidHF(pidObjBachelor);
179   RDHFLctoV0Prod->SetPidHF(pidObjBachelor);
180
181   //2. V0pos
182   AliAODPidHF* pidObjV0pos = new AliAODPidHF();
183   Double_t sigmasV0pos[5]={3.,1.,1.,3.,3.}; // 0, 1(A), 2(A) -> TPC; 3 -> TOF; 4 -> ITS
184   pidObjV0pos->SetSigma(sigmasV0pos);
185   pidObjV0pos->SetAsym(kFALSE);
186   pidObjV0pos->SetMatch(1);
187   pidObjV0pos->SetTPC(kTRUE);
188   pidObjV0pos->SetTOF(kTRUE);
189   pidObjV0pos->SetTOFdecide(kFALSE);
190
191   RDHFLctoV0An->SetPidV0pos(pidObjV0pos);
192   RDHFLctoV0Prod->SetPidV0pos(pidObjV0pos);
193
194   //2. V0neg
195   AliAODPidHF* pidObjV0neg = new AliAODPidHF();
196   Double_t sigmasV0neg[5]={3.,1.,1.,3.,3.}; // 0, 1(A), 2(A) -> TPC; 3 -> TOF; 4 -> ITS
197   pidObjV0neg->SetSigma(sigmasV0neg);
198   pidObjV0neg->SetAsym(kFALSE);
199   pidObjV0neg->SetMatch(1);
200   pidObjV0neg->SetTPC(kTRUE);
201   pidObjV0neg->SetTOF(kTRUE);
202   pidObjV0neg->SetTOFdecide(kFALSE);
203
204   RDHFLctoV0An->SetPidV0neg(pidObjV0neg);
205   RDHFLctoV0Prod->SetPidV0neg(pidObjV0neg);
206
207
208   // uncomment these lines for Baysian PID:
209   // Double_t threshold=0.3;
210   // SetupCombinedPID(RDHFLctoV0An  ,threshold);
211   // RDHFLctoV0An  ->SetPIDStrategy(AliRDHFCutsLctoV0::kCombined);
212   //
213
214
215   //uncomment these lines to apply cuts with the KF package
216   //RDHFLctoV0An->SetCutsStrategy(AliRDHFCutsLctoV0::kKF);
217   //for(Int_t ipt2=0;ipt2<nptbins;ipt2++){
218   //   anacutsval[0]=1.;  //if <0., no topological constraint
219   //   anacutsval[1]=2.;  //cut on the Chi2/Ndf
220   // }
221
222   Bool_t pidflag=kTRUE;
223   RDHFLctoV0An->SetUsePID(pidflag);
224   RDHFLctoV0Prod->SetUsePID(kFALSE);
225   if(pidflag) cout<<"PID is used"<<endl;
226   else cout<<"PID is not used"<<endl;
227
228   cout<<"This is the object I'm going to save:"<<endl;
229   RDHFLctoV0Prod->PrintAll();
230   cout<<"This is the object I'm going to save:"<<endl;
231   RDHFLctoV0An->PrintAll();
232   TFile* fout=new TFile("Lc2pK0SCuts.root","RECREATE"); 
233   fout->cd();
234   RDHFLctoV0Prod->Write();
235   RDHFLctoV0An->Write();
236   fout->Close();
237   delete fout;
238
239   delete pidObjBachelor;
240   delete pidObjV0neg;
241   delete pidObjV0pos;
242   delete RDHFLctoV0Prod;
243   delete RDHFLctoV0An;
244
245 }
246
247
248 //macro to make a .root file (for significance maximization) which contains an AliRDHFCutsLctoV0 with loose set of cuts  and TParameter with the tighest value of these cuts
249
250 void makeInputAliAnalysisTaskSESignificanceMaximization(){
251
252   AliRDHFCutsLctoV0* RDHFLctoV0=new AliRDHFCutsLctoV0();
253   RDHFLctoV0->SetName("loosercuts");
254   RDHFLctoV0->SetTitle("Cuts for significance maximization");
255
256   AliESDtrackCuts* esdTrackCuts=new AliESDtrackCuts();
257   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
258   //default
259   esdTrackCuts->SetRequireTPCRefit(kTRUE);
260   esdTrackCuts->SetMinNClustersTPC(70);
261   esdTrackCuts->SetRequireITSRefit(kFALSE);
262   esdTrackCuts->SetMinNClustersITS(0);
263   //esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
264   esdTrackCuts->SetMinDCAToVertexXY(0.);
265   //esdTrackCuts->SetEtaRange(-0.8,0.8);
266   esdTrackCuts->SetPtRange(0.3,1.e10);
267   
268   AliESDtrackCuts* esdTrackCutsV0daughters=new AliESDtrackCuts();
269   esdTrackCutsV0daughters->SetRequireSigmaToVertex(kFALSE);
270   //default
271   esdTrackCutsV0daughters->SetRequireTPCRefit(kTRUE);
272   esdTrackCutsV0daughters->SetMinNClustersTPC(70);
273   esdTrackCutsV0daughters->SetRequireITSRefit(kFALSE);
274   esdTrackCutsV0daughters->SetMinNClustersITS(0);
275   //esdTrackCutsV0daughters->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny); // default is kBoth, otherwise kAny
276   esdTrackCutsV0daughters->SetMinDCAToVertexXY(0.);
277   esdTrackCutsV0daughters->SetPtRange(0.,1.e10);
278
279   RDHFLctoV0->AddTrackCuts(esdTrackCuts);
280
281   RDHFLctoV0->AddTrackCutsV0daughters(esdTrackCutsV0daughters);
282
283   RDHFLctoV0->SetPidSelectionFlag(2); // 0 -> TOF AND TPC
284                                       // 1 -> if (TOF) TOF else TPC w veto
285                                       // 2 -> if (p>1) TPC@3s else if (1<=p<2.5) {if (TOF) TOF@3s AND TPC@3s} else (p>=2.5) {if (TOF) -2s<TOF<3s AND TPC@3s}
286                                       // 3 -> if (p>1) TPC@3s else if (1<=p<2.5) {if (TOF) TOF@3s AND TPC@3s} else if (2.5<=p<3) {if (TOF) -2s<TOF<3s AND TPC@3s} else (p>=3) {if (TOF) -2s<TOF<3s AND -3s<TPC<2s}
287
288   const Int_t nvars=14;
289
290   const Int_t nptbins=9;
291   Float_t* ptbins;
292   ptbins=new Float_t[nptbins+1];
293   ptbins[0]= 0.;
294   ptbins[1]= 1.;
295   ptbins[2]= 2.;
296   ptbins[3]= 3.;
297   ptbins[4]= 4.;
298   ptbins[5]= 5.;
299   ptbins[6]= 6.;
300   ptbins[7]= 8.;
301   ptbins[8]=12.;
302   ptbins[9]=99999999.;
303   RDHFLctoV0->SetPtBins(nptbins+1,ptbins);
304
305   Float_t** rdcutsvalmine;
306   rdcutsvalmine=new Float_t*[nvars];
307   for(Int_t iv=0;iv<nvars;iv++){
308     rdcutsvalmine[iv]=new Float_t[nptbins];
309   }
310
311   //setting my cut values
312   // inv. mass if K0s [GeV]
313   // inv. mass if Lambda [GeV]
314   // inv. mass V0 if K0S [GeV]
315   // inv. mass V0 if Lambda [GeV]
316   // pT min bachelor track [GeV/c]
317   // pT min V0-positive track [GeV/c]
318   // pT min V0-negative track [GeV/c]
319   // dca cascade cut (cm)
320   // dca V0 cut (nSigmas)
321   // cosPA V0 cut
322   // d0 max bachelor wrt PV [cm]
323   // d0 max V0 wrt PV [cm]
324   // mass K0S veto [GeV/c2]
325   // mass Lambda/LambdaBar veto [GeV/c2]
326   // mass Gamma veto [GeV/c2]
327   // pT min V0 track [GeV/c]
328   Float_t **cutsMatrixLctoV0Stand = new Float_t*[nvars];
329   for(Int_t ic=0;ic<nvars;ic++)
330     cutsMatrixLctoV0Stand[ic]=new Float_t[nptbins];
331   for(Int_t ipt2=0;ipt2<nptbins;ipt2++){
332     cutsMatrixLctoV0Stand[0][ipt2] =0.0075;
333     cutsMatrixLctoV0Stand[1][ipt2] =0.0030;
334     cutsMatrixLctoV0Stand[2][ipt2] =0.4;
335     cutsMatrixLctoV0Stand[3][ipt2] =0.2;
336     cutsMatrixLctoV0Stand[4][ipt2] =0.2;
337     cutsMatrixLctoV0Stand[5][ipt2] =1000.;
338     cutsMatrixLctoV0Stand[6][ipt2] =1.5;
339     cutsMatrixLctoV0Stand[7][ipt2] =0.99;
340     cutsMatrixLctoV0Stand[8][ipt2] =0.05;
341     cutsMatrixLctoV0Stand[9][ipt2] =0.1;
342     cutsMatrixLctoV0Stand[10][ipt2] =0.0;
343     cutsMatrixLctoV0Stand[11][ipt2] =0.005;
344     cutsMatrixLctoV0Stand[12][ipt2] =0.100;
345   }
346   cutsMatrixLctoV0Stand[0][13]=0.0; // pT min V0 track [GeV/c]
347   cutsMatrixLctoV0Stand[1][13]=0.6; // pT min V0 track [GeV/c]
348   cutsMatrixLctoV0Stand[2][13]=0.8; // pT min V0 track [GeV/c]
349   cutsMatrixLctoV0Stand[3][13]=0.8; // pT min V0 track [GeV/c]
350   cutsMatrixLctoV0Stand[4][13]=0.8; // pT min V0 track [GeV/c]
351   cutsMatrixLctoV0Stand[5][13]=1.0; // pT min V0 track [GeV/c]
352   cutsMatrixLctoV0Stand[6][13]=1.0; // pT min V0 track [GeV/c]
353   cutsMatrixLctoV0Stand[7][13]=1.0; // pT min V0 track [GeV/c]
354   cutsMatrixLctoV0Stand[8][13]=0.0; // pT min V0 track [GeV/c]
355   cutsMatrixLctoV0Stand[9][13]=0.0; // pT min V0 track [GeV/c]
356
357
358   //CREATE TRANSPOSE MATRIX...REVERSE INDICES as required by AliRDHFCuts
359   Float_t **cutsMatrixTransposeStand=new Float_t*[nvars];
360   for(Int_t iv=0;iv<nvars;iv++)cutsMatrixTransposeStand[iv]=new Float_t[nptbins];
361   for (Int_t ibin=0;ibin<nptbins;ibin++){
362     for (Int_t ivar=0; ivar<nvars; ivar++){
363       cutsMatrixTransposeStand[ivar][ibin]=cutsMatrixLctoV0Stand[ibin][ivar];
364     }
365   }
366   RDHFLctoV0->SetCuts(nvars,nptbins,cutsMatrixTransposeStand);
367
368
369   Int_t nvarsforopt=RDHFLctoV0->GetNVarsForOpt();
370   Int_t dim=14; //set this!!
371   Bool_t *boolforopt;
372   boolforopt=new Bool_t[nvars];
373   if(dim>nvarsforopt){
374     cout<<"Number of variables for optimization has probably changed, check and edit accordingly"<<endl;
375     return;
376   } else {
377     if(dim==nvarsforopt){
378       boolforopt=RDHFLctoV0->GetVarsForOpt();
379     }else{
380       TString *names;
381       names=new TString[nvars];
382       TString answer="";
383       Int_t checktrue=0;
384       names=RDHFLctoV0->GetVarNames();
385       for(Int_t i=0;i<nvars;i++){
386         cout<<names[i]<<" for opt? (y/n)"<<endl;
387         cin>>answer;
388         if(answer=="y") {
389           boolforopt[i]=kTRUE;
390           checktrue++;
391         }
392         else boolforopt[i]=kFALSE;
393       }
394       if (checktrue!=dim) {
395         cout<<"Error! You set "<<checktrue<<" kTRUE instead of "<<dim<<endl;
396         return;
397       }
398       RDHFLctoV0->SetVarsForOpt(dim,boolforopt);
399     }
400   }
401
402
403   Float_t tighterval[dim][nptbins];
404   // 0(2): inv. mass V0 if K0S [GeV]
405   // 1(3): inv. mass V0 if Lambda [GeV]
406   // 2(4): pT min bachelor track [GeV/c]
407   // 3(5): pT min V0-positive track [GeV/c]
408   // 4(6): pT min V0-negative track [GeV/c]
409   // 5(7): dca cascade cut (cm)
410   // 6(8): dca V0 cut (nSigmas)
411   // 7(9): cosPA V0 cut
412   // 8(10): d0 max bachelor wrt PV [cm]
413   // 9(11): d0 max V0 wrt PV [cm]
414   // 10(12): mass K0S veto [GeV/c2]
415   // 11(13): mass Lambda/LambdaBar veto [GeV/c2]
416   // 12(14): mass Gamma veto [GeV/c2]
417   // 13(15): pT min V0 track [GeV/c]
418
419   // number of steps for each variable is set in the AddTask arguments (default=8)
420   // set this!!
421   for(Int_t ipt=0;ipt<nptbins;ipt++){
422     tighterval[0][ipt] =0.075;  // inv. mass V0 if K0S [GeV]
423     tighterval[1][ipt] =0.040;  // inv. mass V0 if Lambda [GeV]
424     tighterval[2][ipt] =0.4;    // pT min bachelor track [GeV/c]
425     tighterval[3][ipt] =0.2;    // pT min V0-positive track [GeV/c]
426     tighterval[4][ipt] =0.2;    // pT min V0-negative track [GeV/c]
427     tighterval[5][ipt] =100.;   // dca cascade cut (cm)
428     tighterval[6][ipt] =1.5;    // dca v0 cut
429     tighterval[7][ipt] =0.99;   // cosPA v0 cut
430     tighterval[8][ipt] =0.05;   // d0 max bachelor wrt PV [cm]
431     tighterval[9][ipt] =0.1;    // d0 max V0 wrt PV [cm]
432     tighterval[10][ipt] =0.0;   // mass K0S veto [GeV/c2]
433     tighterval[11][ipt] =0.005; // mass Lambda/LambdaBar veto [GeV/c2]
434     tighterval[12][ipt] =0.100; // mass Gamma veto [GeV/c2]
435   }
436   tighterval[0][13]=0.0; // pT min V0 track [GeV/c]
437   tighterval[1][13]=0.6; // pT min V0 track [GeV/c]
438   tighterval[2][13]=0.8; // pT min V0 track [GeV/c]
439   tighterval[3][13]=0.8; // pT min V0 track [GeV/c]
440   tighterval[4][13]=0.8; // pT min V0 track [GeV/c]
441   tighterval[5][13]=1.0; // pT min V0 track [GeV/c]
442   tighterval[6][13]=1.0; // pT min V0 track [GeV/c]
443   tighterval[7][13]=1.0; // pT min V0 track [GeV/c]
444   tighterval[8][13]=0.0; // pT min V0 track [GeV/c]
445   tighterval[9][13]=0.0; // pT min V0 track [GeV/c]
446
447   TString name=""; 
448   Int_t arrdim=dim*nptbins;
449   cout<<"Will save "<<arrdim<<" TParameter<float>"<<endl;
450   TClonesArray max("TParameter<float>",arrdim);
451   for(Int_t ival=0;ival<dim;ival++){
452     for(Int_t jpt=0;jpt<nptbins;jpt++){
453       name=Form("par%dptbin%d",ival,jpt);
454       cout<<"Setting "<<name.Data()<<" to "<<tighterval[ival][jpt]<<endl;
455       new(max[jpt*dim+ival])TParameter<float>(name.Data(),tighterval[ival][jpt]);
456     }
457   }
458
459   Bool_t flagPID=kFALSE;
460   RDHFLctoV0->SetUsePID(flagPID);
461
462   RDHFLctoV0->PrintAll();
463   printf("Use PID? %s\n",flagPID ? "yes" : "no");
464
465   //pid settings
466   //1. bachelor: default one
467   AliAODPidHF* pidObjBachelor = new AliAODPidHF();
468   Double_t sigmasBac[5]={3.,1.,1.,3.,3.}; // 0, 1(A), 2(A) -> TPC; 3 -> TOF; 4 -> ITS
469   pidObjBachelor->SetSigma(sigmasBac);
470   pidObjBachelor->SetAsym(kFALSE);
471   pidObjBachelor->SetMatch(1);
472   pidObjBachelor->SetTPC(kTRUE);
473   pidObjBachelor->SetTOF(kTRUE);
474   pidObjBachelor->SetTOFdecide(kFALSE);
475   RDHFLctoV0->SetPidHF(pidObjBachelor);
476
477   //2. V0pos
478   AliAODPidHF* pidObjV0pos = new AliAODPidHF();
479   Double_t sigmasV0pos[5]={3.,1.,1.,3.,3.}; // 0, 1(A), 2(A) -> TPC; 3 -> TOF; 4 -> ITS
480   pidObjV0pos->SetSigma(sigmasV0pos);
481   pidObjV0pos->SetAsym(kFALSE);
482   pidObjV0pos->SetMatch(1);
483   pidObjV0pos->SetTPC(kTRUE);
484   pidObjV0pos->SetTOF(kTRUE);
485   pidObjV0pos->SetTOFdecide(kFALSE);
486   RDHFLctoV0->SetPidV0pos(pidObjV0pos);
487
488   //2. V0neg
489   AliAODPidHF* pidObjV0neg = new AliAODPidHF();
490   Double_t sigmasV0neg[5]={3.,1.,1.,3.,3.}; // 0, 1(A), 2(A) -> TPC; 3 -> TOF; 4 -> ITS
491   pidObjV0neg->SetSigma(sigmasV0neg);
492   pidObjV0neg->SetAsym(kFALSE);
493   pidObjV0neg->SetMatch(1);
494   pidObjV0neg->SetTPC(kTRUE);
495   pidObjV0neg->SetTOF(kTRUE);
496   pidObjV0neg->SetTOFdecide(kFALSE);
497   RDHFLctoV0->SetPidV0neg(pidObjV0neg);
498
499   //activate pileup rejection (for pp)
500   //RDHFLctoV0->SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
501
502   //Do not recalculate the vertex
503   RDHFLctoV0->SetRemoveDaughtersFromPrim(kFALSE); //activate for pp
504
505   TString cent="";
506   //centrality selection (Pb-Pb)
507   Float_t minc=20,maxc=80;
508   RDHFLctoV0->SetMinCentrality(minc);
509   RDHFLctoV0->SetMaxCentrality(maxc);
510   cent=Form("%.0f%.0f",minc,maxc);
511   //RDHFLctoV0->SetUseCentrality(AliRDHFCuts::kCentV0M); //kCentOff,kCentV0M,kCentTRK,kCentTKL,kCentCL1,kCentInvalid
512   RDHFLctoV0->SetUseCentrality(AliRDHFCuts::kCentOff); //kCentOff,kCentV0M,kCentTRK,kCentTKL,kCentCL1,kCentInvalid
513
514   //temporary
515   //RDHFLctoV0->SetFixRefs();
516
517   TFile* fout=new TFile(Form("cuts4SignifMaxim%s%s%sRecVtx%sPileupRej.root",
518                              RDHFLctoV0->GetUseCentrality()==0 ? "pp" : "PbPb",
519                              cent.Data(),
520                              RDHFLctoV0->GetIsPrimaryWithoutDaughters() ? "" : "No",
521                              RDHFLctoV0->GetOptPileUp() ? "" : "No"),"recreate"); //set this!! 
522
523   fout->cd();
524   RDHFLctoV0->Write();
525   max.Write();
526   fout->Close();
527  
528 }