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