Update macro for phi variable (Chiara Z)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AddTaskCFMultiVarMultiStep.C
CommitLineData
f5ec6c30 1//DEFINITION OF A FEW CONSTANTS
2const Double_t ymin = -2.1 ;
3const Double_t ymax = 2.1 ;
4const Double_t ptmin_0_4 = 0.0 ;
5const Double_t ptmax_0_4 = 4.0 ;
6const Double_t ptmin_4_8 = 4.0 ;
7const Double_t ptmax_4_8 = 8.0 ;
8const Double_t ptmin_8_10 = 8.0 ;
9const Double_t ptmax_8_10 = 10.0 ;
10const Double_t cosmin = -1.05;
11const Double_t cosmax = 1.05;
12const Double_t cTmin = 0; // micron
13const Double_t cTmax = 500; // micron
14const Double_t dcamin = 0; // micron
15const Double_t dcamax = 500; // micron
16const Double_t d0min = -1000; // micron
17const Double_t d0max = 1000; // micron
18const Double_t d0xd0min = -100000; // micron
19const Double_t d0xd0max = 100000; // micron
2c9d065f 20const Double_t phimin = 0.0;
21//const Double_t phimax = 2Pi; // defined in the macro!!!!!!!!!!!!!!
f5ec6c30 22const Int_t mintrackrefsTPC = 2 ;
23const Int_t mintrackrefsITS = 3 ;
24const Int_t charge = 1 ;
25const Int_t PDG = 421;
26const Int_t minclustersTPC = 50 ;
27// cuts
28const Double_t ptmin = 0.1;
29const Double_t ptmax = 9999.;
30const Double_t etamin = -0.9;
31const Double_t etamax = 0.9;
32const Int_t minITSClusters = 5;
33
34//----------------------------------------------------
35
36AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep()
37{
38
39 //CONTAINER DEFINITION
40 Info("AliCFHeavyFlavourTaskMultiVarMultiStep","SETUP CONTAINER");
41 //the sensitive variables (6 in this example), their indices
42 UInt_t ipt = 0;
43 UInt_t iy = 1;
44 UInt_t icosThetaStar = 2;
45 UInt_t ipTpi = 3;
46 UInt_t ipTk = 4;
47 UInt_t icT = 5;
48 UInt_t idca = 6;
49 UInt_t id0pi = 7;
50 UInt_t id0K = 8;
51 UInt_t id0xd0 = 9;
52 UInt_t ipointing = 10;
2c9d065f 53 UInt_t iphi = 11;
f5ec6c30 54
55 //Setting up the container grid...
56 UInt_t nstep = 6; //number of selection steps: MC, Acceptance, Reco (no cuts), RecoAcceptance, RecoITSClusters (RecoAcceptance included), RecoPPR (RecoAcceptance+RecoITSCluster included)
2c9d065f 57 const Int_t nvar = 12 ; //number of variables on the grid:pt, y, cosThetaStar, pTpi, pTk, cT, dca, d0pi, d0K, d0xd0, cosPointingAngle, phi
f5ec6c30 58 const Int_t nbin0_0_4 = 8 ; //bins in pt from 0 to 4 GeV
59 const Int_t nbin0_4_8 = 4 ; //bins in pt from 4 to 8 GeV
60 const Int_t nbin0_8_10 = 1 ; //bins in pt from 8 to 10 GeV
61 const Int_t nbin1 = 42 ; //bins in y
62 const Int_t nbin2 = 42 ; //bins in cosThetaStar
63 const Int_t nbin3_0_4 = 8 ; //bins in ptPi from 0 to 4 GeV
64 const Int_t nbin3_4_8 = 4 ; //bins in ptPi from 4 to 8 GeV
65 const Int_t nbin3_8_10 = 1 ; //bins in ptPi from 8 to 10 GeV
66 const Int_t nbin4_0_4 = 8 ; //bins in ptKa from 0 to 4 GeV
67 const Int_t nbin4_4_8 = 4 ; //bins in ptKa from 4 to 8 GeV
68 const Int_t nbin4_8_10 = 1 ; //bins in ptKa from 8 to 10 GeV
69 const Int_t nbin5 = 24 ; //bins in cT
70 const Int_t nbin6 = 24 ; //bins in dca
71 const Int_t nbin7 = 100 ; //bins in d0pi
72 const Int_t nbin8 = 100 ; //bins in d0K
73 const Int_t nbin9 = 80 ; //bins in d0xd0
74 const Int_t nbin10 = 1050 ; //bins in cosPointingAngle
2c9d065f 75 const Int_t nbin11 = 100 ; //bins in Phi
76
f5ec6c30 77 //arrays for the number of bins in each dimension
78 Int_t iBin[nvar];
79 iBin[0]=nbin0_0_4+nbin0_4_8+nbin0_8_10;
80 iBin[1]=nbin1;
81 iBin[2]=nbin2;
82 iBin[3]=nbin3_0_4+nbin3_4_8+nbin3_8_10;
83 iBin[4]=nbin4_0_4+nbin4_4_8+nbin4_8_10;
84 iBin[5]=nbin5;
85 iBin[6]=nbin6;
86 iBin[7]=nbin7;
87 iBin[8]=nbin8;
88 iBin[9]=nbin9;
89 iBin[10]=nbin10;
2c9d065f 90 iBin[11]=nbin11;
f5ec6c30 91
92 //arrays for lower bounds :
93 Double_t *binLim0=new Double_t[iBin[0]+1];
94 Double_t *binLim1=new Double_t[iBin[1]+1];
95 Double_t *binLim2=new Double_t[iBin[2]+1];
96 Double_t *binLim3=new Double_t[iBin[3]+1];
97 Double_t *binLim4=new Double_t[iBin[4]+1];
98 Double_t *binLim5=new Double_t[iBin[5]+1];
99 Double_t *binLim6=new Double_t[iBin[6]+1];
100 Double_t *binLim7=new Double_t[iBin[7]+1];
101 Double_t *binLim8=new Double_t[iBin[8]+1];
102 Double_t *binLim9=new Double_t[iBin[9]+1];
103 Double_t *binLim10=new Double_t[iBin[10]+1];
2c9d065f 104 Double_t *binLim11=new Double_t[iBin[11]+1];
105
f5ec6c30 106 // checking limits
107 if (ptmax_0_4 != ptmin_4_8) {
108 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 1st range != min lim 2nd range, please check!");
109 }
110 if (ptmax_4_8 != ptmin_8_10) {
111 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 2nd range != min lim 3rd range, please check!");
112 }
113
114 // values for bin lower bounds
115 // pt
116 for(Int_t i=0; i<=nbin0_0_4; i++) binLim0[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin0_0_4*(Double_t)i ;
117 if (binLim0[nbin0_0_4] != ptmin_4_8) {
118 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
119 }
120 for(Int_t i=0; i<=nbin0_4_8; i++) binLim0[i+nbin0_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin0_4_8*(Double_t)i ;
121 if (binLim0[nbin0_0_4+nbin0_4_8] != ptmin_8_10) {
122 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
123 }
124 for(Int_t i=0; i<=nbin0_8_10; i++) binLim0[i+nbin0_0_4+nbin0_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin0_8_10*(Double_t)i ;
125
126 // y
127 for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ymin + (ymax-ymin) /nbin1*(Double_t)i ;
128
129 // cosThetaStar
130 for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)cosmin + (cosmax-cosmin) /nbin2*(Double_t)i ;
131
132 // ptPi
133 for(Int_t i=0; i<=nbin3_0_4; i++) binLim3[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin3_0_4*(Double_t)i ;
134 if (binLim3[nbin3_0_4] != ptmin_4_8) {
135 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 1st range - differs from expected!");
136 }
137 for(Int_t i=0; i<=nbin3_4_8; i++) binLim3[i+nbin3_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin3_4_8*(Double_t)i ;
138 if (binLim3[nbin3_0_4+nbin3_4_8] != ptmin_8_10) {
139 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 2nd range - differs from expected!\n");
140 }
141 for(Int_t i=0; i<=nbin3_8_10; i++) binLim3[i+nbin3_0_4+nbin3_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin3_8_10*(Double_t)i ;
142
143 // ptKa
144 for(Int_t i=0; i<=nbin4_0_4; i++) binLim4[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin4_0_4*(Double_t)i ;
145 if (binLim4[nbin4_0_4] != ptmin_4_8) {
146 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 1st range - differs from expected!");
147 }
148 for(Int_t i=0; i<=nbin4_4_8; i++) binLim4[i+nbin4_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin4_4_8*(Double_t)i ;
149 if (binLim4[nbin4_0_4+nbin4_4_8] != ptmin_8_10) {
150 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 2nd range - differs from expected!\n");
151 }
152 for(Int_t i=0; i<=nbin4_8_10; i++) binLim4[i+nbin4_0_4+nbin4_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin4_8_10*(Double_t)i ;
153
154 // cT
155 for(Int_t i=0; i<=nbin5; i++) binLim5[i]=(Double_t)cTmin + (cTmax-cTmin) /nbin5*(Double_t)i ;
156
157 // dca
158 for(Int_t i=0; i<=nbin6; i++) binLim6[i]=(Double_t)dcamin + (dcamax-dcamin) /nbin6*(Double_t)i ;
159
160 // d0pi
161 for(Int_t i=0; i<=nbin7; i++) binLim7[i]=(Double_t)d0min + (d0max-d0min) /nbin7*(Double_t)i ;
162
163 // d0K
164 for(Int_t i=0; i<=nbin8; i++) binLim8[i]=(Double_t)d0min + (d0max-d0min) /nbin8*(Double_t)i ;
165
166 // d0xd0
167 for(Int_t i=0; i<=nbin9; i++) binLim9[i]=(Double_t)d0xd0min + (d0xd0max-d0xd0min) /nbin9*(Double_t)i ;
168
169 // cosPointingAngle
170 for(Int_t i=0; i<=nbin10; i++) binLim10[i]=(Double_t)cosmin + (cosmax-cosmin) /nbin10*(Double_t)i ;
171
2c9d065f 172 // Phi
173 for(Int_t i=0; i<=nbin11; i++) binLim11[i]=(Double_t)phimin + (phimax-phimin) /nbin11*(Double_t)i ;
174
f5ec6c30 175 // debugging printings
176 //Info("AliCFHeavyFlavourTaskMultiVarMultiStep","Printing lower limits for bins in pt");
177 //for (Int_t i =0; i<= iBin[0]; i++){
178 // Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim0[i]));
179 //}
180 //Info("Printing lower limits for bins in ptPi");
181 //for (Int_t i =0; i<= iBin[3]; i++){
182 // Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim3[i]));
183 //}
184 //Info("Printing lower limits for bins in ptKa");
185 //for (Int_t i =0; i<= iBin[4]; i++){
186 // Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim4[i]));
187 // }
188
189 //one "container" for MC
190 AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin);
191 //setting the bin limits
192 container -> SetBinLimits(ipt,binLim0);
193 container -> SetBinLimits(iy,binLim1);
194 container -> SetBinLimits(icosThetaStar,binLim2);
195 container -> SetBinLimits(ipTpi,binLim3);
196 container -> SetBinLimits(ipTk,binLim4);
197 container -> SetBinLimits(icT,binLim5);
198 container -> SetBinLimits(idca,binLim6);
199 container -> SetBinLimits(id0pi,binLim7);
200 container -> SetBinLimits(id0K,binLim8);
201 container -> SetBinLimits(id0xd0,binLim9);
202 container -> SetBinLimits(ipointing,binLim10);
2c9d065f 203 container -> SetBinLimits(iphi,binLim11);
f5ec6c30 204
205 //CREATE THE CUTS -----------------------------------------------
206
207 // Gen-Level kinematic cuts
208 AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
209 // mcKineCuts->SetPtRange(ptmin,ptmax);
210 // mcKineCuts->SetRapidityRange(ymin,ymax);
211 // mcKineCuts->SetChargeMC(charge);
212
213 //Particle-Level cuts:
214 AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
215 //mcGenCuts->SetRequireIsPrimary();
216 mcGenCuts->SetRequirePdgCode(PDG, kTRUE); // kTRUE set in order to include D0_bar
217 mcGenCuts->SetAODMC(1); //special flag for reading MC in AOD tree (important)
218
219 // Acceptance cuts:
220 AliCFAcceptanceCuts* accCuts = new AliCFAcceptanceCuts("accCuts", "Acceptance cuts");
221 //accCuts->SetMinNHitITS(3);
222 //accCuts->SetMinNHitTPC(2);
223 AliCFTrackKineCuts *kineAccCuts = new AliCFTrackKineCuts("kineAccCuts","Kine-Acceptance cuts");
224 kineAccCuts->SetPtRange(ptmin,ptmax);
225 kineAccCuts->SetEtaRange(etamin,etamax);
226
227 // Rec-Level kinematic cuts
228 AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
229 // recKineCuts->SetPtRange(ptmin,ptmax);
230 // recKineCuts->SetRapidityRange(ymin,ymax);
231 // recKineCuts->SetChargeRec(charge);
232
233 AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
234 //recQualityCuts->SetStatus(AliESDtrack::kITSrefit);
235
236 AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
237 //recIsPrimaryCuts->SetAODType(AliAODTrack::kPrimary);
238
239 printf("CREATE MC KINE CUTS\n");
240 TObjArray* mcList = new TObjArray(0) ;
241 mcList->AddLast(mcKineCuts);
242 mcList->AddLast(mcGenCuts);
243
244 printf("CREATE ACCEPTANCE CUTS\n");
245 TObjArray* accList = new TObjArray(0) ;
246 accList->AddLast(kineAccCuts);
247
248 printf("CREATE RECONSTRUCTION CUTS\n");
249 TObjArray* recList = new TObjArray(0) ;
250 recList->AddLast(recKineCuts);
251 recList->AddLast(recQualityCuts);
252 recList->AddLast(recIsPrimaryCuts);
253
254 //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
255 printf("CREATE INTERFACE AND CUTS\n");
256 AliCFManager* man = new AliCFManager() ;
257 man->SetParticleContainer (container);
258 man->SetParticleCutsList(0 , mcList); // MC
259 man->SetParticleCutsList(1 , accList); // Acceptance
260 man->SetParticleCutsList(2 , recList); // AOD
261 man->SetParticleCutsList(3 , recList); // AOD in Acceptance
262 man->SetParticleCutsList(4 , recList); // AOD with required n. of ITS clusters
263 man->SetParticleCutsList(5 , recList); // AOD Reco (PPR cuts implemented in Task)
264
265 // Get the pointer to the existing analysis manager via the static access method.
266 //==============================================================================
267 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
268 if (!mgr) {
269 ::Error("AddTaskCompareHF", "No analysis manager to connect to.");
270 return NULL;
271 }
272 //CREATE THE TASK
273 printf("CREATE TASK\n");
274 // create the task
275 AliCFHeavyFlavourTaskMultiVarMultiStep *task = new AliCFHeavyFlavourTaskMultiVarMultiStep("AliCFHeavyFlavourTaskMultiVarMultiStep");
276 task->SetFillFromGenerated(kFALSE);
277 task->SetMinITSClusters(minITSClusters);
278 task->SetCFManager(man); //here is set the CF manager
279
280 // Create and connect containers for input/output
281
282 // ------ input data ------
283 AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
284
285 // ----- output data -----
286
287 //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
288 AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output.root");
289
290 //now comes user's output objects :
291
292 // output TH1I for event counting
293 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root");
294 // output Correction Framework Container (for acceptance & efficiency calculations)
295 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
296
297 mgr->AddTask(task);
298
299 mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
300 mgr->ConnectOutput(task,0,coutput0);
301 mgr->ConnectOutput(task,1,coutput1);
302 mgr->ConnectOutput(task,2,coutput2);
303
304 return task;
305}
306