New task for prompt charm fraction analysis (Andrea R)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AddTaskCharmFraction.C
1 AliAnalysisTaskCharmFraction* AddTaskCharmFraction(
2          const char* fileout="d0D0.root",
3          Bool_t sideband=kFALSE,
4          Bool_t setD0usecuts=kTRUE,
5          Bool_t setcheckMC=kTRUE,
6          Bool_t setcheckMC_prompt=kTRUE,
7          Bool_t setcheckMC_fromB=kFALSE,
8          Bool_t setcheckMC_D0=kTRUE,
9          Bool_t setcheckMC_2prongs=kTRUE,
10          Bool_t setSkipD0star=kTRUE,
11          Bool_t setStudyPureBack=kFALSE)
12 {  
13   //
14   // Configuration macro for the task to analyze the fraction of prompt charm
15   // using the D0 impact parameter
16   // andrea.rossi@ts.infn.it
17   //
18   //==========================================================================
19   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
20   if (!mgr) {
21     ::Error("AddTaskCharmFraction", "No analysis manager to connect to.");
22     return NULL;
23   }   
24
25   TString str=fileout,containername;
26   str.ReplaceAll(".root","");
27   str.Prepend("_");
28
29   AliAnalysisTaskCharmFraction *hfTask;
30   if(!sideband) {
31     hfTask = new AliAnalysisTaskCharmFraction("CharmFraction",10);
32   } else {
33     hfTask= new AliAnalysisTaskCharmFraction("CharmFractionSideB",10);
34     hfTask->SetSideBands(-2.);
35   }
36
37   hfTask->SetUseCuts(setD0usecuts);
38   hfTask->SetCheckMC(setcheckMC);
39   hfTask->SetCheckMC_D0(setcheckMC_D0);
40   hfTask->SetCheckMC_2prongs(setcheckMC_2prongs);
41   hfTask->SetCheckMC_prompt(setcheckMC_prompt);
42   hfTask->SetCheckMC_fromB(setcheckMC_fromB);
43   hfTask->SetCheckMC_fromDstar(setSkipD0star);
44   hfTask->SetStudyPureBackground(setStudyPureBack);
45   //  hfTask->SetSideBands(0);
46   //  hfTask->SetDebugLevel(2);
47   mgr->AddTask(hfTask);
48  
49   //Now the same for sidebands
50   /*AliAnalysisTaskCharmFraction *hfTaskSideB 
51
52   
53   hfTaskSideB->SetUseCuts(fD0usecuts);
54   hfTaskSideB->SetCheckMC(fcheckMC);
55   hfTaskSideB->SetCheckMC_D0(fcheckMC_D0);
56   hfTaskSideB->SetCheckMC_2prongs(fcheckMC_2prongs);
57   hfTaskSideB->SetCheckMC_prompt(fcheckMC_prompt);
58   hfTaskSideB->SetCheckMC_fromB(fcheckMC_fromB);
59   hfTaskSideB->SetCheckMC_fromDstar(fSkipD0star);
60   hfTaskSideB->SetStudyPureBackground(fStudyPureBack);
61
62   //  hfTaskSideB->SetDebugLevel(2);
63   mgr->AddTask(hfTaskSideB);
64   */
65  
66
67   // Create containers for input/output
68   AliAnalysisDataContainer *cinput =   mgr->GetCommonInputContainer();//mgr->CreateContainer("cinput",TChain::Class(),AliAnalysisManager::kInputContainer);
69   mgr->ConnectInput(hfTask,0,cinput);
70   //  mgr->ConnectInput(hfTaskSideB,0,cinput);
71
72   //Now container for general properties histograms
73   containername="coutputCptd0d0";
74   containername.Append(str.Data());
75   AliAnalysisDataContainer *coutputCptd0d0 = mgr->CreateContainer(containername.Data(),TH2::Class(),
76                                                            AliAnalysisManager::kOutputContainer, 
77                                                            fileout);
78   mgr->ConnectOutput(hfTask,0,coutputCptd0d0);
79
80   containername="coutputSecVtxXY";
81   containername.Append(str.Data());
82   AliAnalysisDataContainer *coutputSecVtxXY = mgr->CreateContainer(containername.Data(),TH2::Class(),
83                                                            AliAnalysisManager::kOutputContainer, 
84                                                            fileout);
85   mgr->ConnectOutput(hfTask,1,coutputSecVtxXY);
86
87
88   containername="coutputd0d0";
89   containername.Append(str.Data());
90   AliAnalysisDataContainer *coutputd0d0 = mgr->CreateContainer(containername.Data(),TH1::Class(),
91                                                            AliAnalysisManager::kOutputContainer, 
92                                                            fileout);
93   mgr->ConnectOutput(hfTask,2,coutputd0d0);
94
95   containername="coutputCpt";
96   containername.Append(str.Data());
97   AliAnalysisDataContainer *coutputCpt = mgr->CreateContainer(containername.Data(),TH1::Class(),
98                                                            AliAnalysisManager::kOutputContainer, 
99                                                            fileout);
100   mgr->ConnectOutput(hfTask,3,coutputCpt);
101
102   containername="coutputSecVtxZ";
103   containername.Append(str.Data());
104   AliAnalysisDataContainer *coutputSecVtxZ = mgr->CreateContainer(containername.Data(),TH1::Class(),
105                                                            AliAnalysisManager::kOutputContainer, 
106                                                            fileout);
107   mgr->ConnectOutput(hfTask,4,coutputSecVtxZ);
108
109   containername="coutputSecVtxX";
110   containername.Append(str.Data());
111   AliAnalysisDataContainer *coutputSecVtxX = mgr->CreateContainer(containername.Data(),TH1::Class(),
112                                                            AliAnalysisManager::kOutputContainer, 
113                                                            fileout);
114   mgr->ConnectOutput(hfTask,5,coutputSecVtxX);
115
116   containername="coutputSecVtxY";
117   containername.Append(str.Data());
118   AliAnalysisDataContainer *coutputSecVtxY = mgr->CreateContainer(containername.Data(),TH1::Class(),
119                                                            AliAnalysisManager::kOutputContainer, 
120                                                            fileout);
121   mgr->ConnectOutput(hfTask,6,coutputSecVtxY);
122
123   containername="coutputSecVtxPhi";
124   containername.Append(str.Data());
125  AliAnalysisDataContainer *coutputSecVtxPhi = mgr->CreateContainer(containername.Data(),TH1::Class(),
126                                                            AliAnalysisManager::kOutputContainer, 
127                                                            fileout);
128   mgr->ConnectOutput(hfTask,7,coutputSecVtxPhi);
129
130
131   //Now container for d0D0  
132   AliAnalysisDataContainer **coutput=new AliAnalysisDataContainer*[10];
133   containername="coutputAll";
134   containername.Append(str.Data());
135   AliAnalysisDataContainer *coutputAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
136                                                            AliAnalysisManager::kOutputContainer, 
137                                                            fileout);
138
139
140   TString name="coutput";
141   for(Int_t j=0;j<10;j++){
142     containername=name;
143     containername+=j;
144     containername.Append(str.Data());
145     coutput[j] = mgr->CreateContainer(containername.Data(),TH1::Class(),
146                                       AliAnalysisManager::kOutputContainer, 
147                                       fileout);
148     
149     mgr->ConnectOutput(hfTask,j+8,coutput[j]);
150   }
151   mgr->ConnectOutput(hfTask,18,coutputAll);
152   //Now container for MC d0D0  
153   AliAnalysisDataContainer **coutputMC=new AliAnalysisDataContainer*[10];
154   containername="coutputAllMC";
155   containername.Append(str.Data());
156   AliAnalysisDataContainer *coutputAllMC = mgr->CreateContainer(containername.Data(),TH1::Class(),
157                                                            AliAnalysisManager::kOutputContainer, 
158                                                            fileout);
159
160
161   name="coutputMC";
162   for(Int_t j=0;j<10;j++){
163     containername=name;
164     containername+=j;
165     containername.Append(str.Data());
166     coutputMC[j] = mgr->CreateContainer(containername.Data(),TH1::Class(),
167                                       AliAnalysisManager::kOutputContainer, 
168                                       fileout);
169     
170     mgr->ConnectOutput(hfTask,j+19,coutputMC[j]);
171   }
172   mgr->ConnectOutput(hfTask,29,coutputAllMC);
173
174   //Now container for histo with d0 with respect to True Vtx
175   AliAnalysisDataContainer **coutputd0VtxTrue=new AliAnalysisDataContainer*[10];
176   containername="coutputd0VtxTrueAll";
177   containername.Append(str.Data());
178   AliAnalysisDataContainer *coutputd0VtxTrueAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
179                                                            AliAnalysisManager::kOutputContainer, 
180                                                            fileout);
181
182
183   name="coutputd0VtxTrue";
184   for(Int_t j=0;j<10;j++){
185     containername=name;
186     containername+=j;
187     containername.Append(str.Data());
188     coutputd0VtxTrue[j] = mgr->CreateContainer(containername.Data(),TH1::Class(),
189                                       AliAnalysisManager::kOutputContainer, 
190                                       fileout);
191     
192     mgr->ConnectOutput(hfTask,j+30,coutputd0VtxTrue[j]);
193   }
194   mgr->ConnectOutput(hfTask,40,coutputd0VtxTrueAll);
195   //INV MASS
196   containername="coutputD0InvMassAll";
197   containername.Append(str.Data());
198   AliAnalysisDataContainer *coutputD0InvMassAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
199                                                                        AliAnalysisManager::kOutputContainer, 
200                                                                        fileout);
201   mgr->ConnectOutput(hfTask,41,coutputD0InvMassAll);
202   containername="coutputD0MCInvMassAll";
203   containername.Append(str.Data());
204   AliAnalysisDataContainer *coutputD0MCInvMassAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
205                                                                          AliAnalysisManager::kOutputContainer, 
206                                                                          fileout);
207   mgr->ConnectOutput(hfTask,42,coutputD0MCInvMassAll);
208   
209  ////////
210  //NOW THE SAME FOR SIDE BANDS
211  /*
212  //Now container for general properties histograms
213
214  AliAnalysisDataContainer *coutputSBCptd0d0 = mgr->CreateContainer("coutputSBCptd0d0",TH2::Class(),
215                                                                    AliAnalysisManager::kOutputContainer, 
216                                                            "d0D0SideB.root");
217  mgr->ConnectOutput(hfTaskSideB,0,coutputSBCptd0d0);
218
219   AliAnalysisDataContainer *coutputSBSecVtxXY = mgr->CreateContainer("coutputSBSecVtxXY",TH2::Class(),
220                                                            AliAnalysisManager::kOutputContainer, 
221                                                            "d0D0SideB.root");
222   mgr->ConnectOutput(hfTaskSideB,1,coutputSBSecVtxXY);
223
224
225   AliAnalysisDataContainer *coutputSBd0d0 = mgr->CreateContainer("coutputSBd0d0",TH1::Class(),
226                                                            AliAnalysisManager::kOutputContainer, 
227                                                            "d0D0SideB.root");
228   mgr->ConnectOutput(hfTaskSideB,2,coutputSBd0d0);
229
230   AliAnalysisDataContainer *coutputSBCpt = mgr->CreateContainer("coutputSBCpt",TH1::Class(),
231                                                            AliAnalysisManager::kOutputContainer, 
232                                                            "d0D0SideB.root");
233   mgr->ConnectOutput(hfTaskSideB,3,coutputSBCpt);
234
235   AliAnalysisDataContainer *coutputSBSecVtxZ = mgr->CreateContainer("coutputSBSecVtxZ",TH1::Class(),
236                                                            AliAnalysisManager::kOutputContainer, 
237                                                            "d0D0SideB.root");
238   mgr->ConnectOutput(hfTaskSideB,4,coutputSBSecVtxZ);
239
240   AliAnalysisDataContainer *coutputSBSecVtxX = mgr->CreateContainer("coutputSBSecVtxX",TH1::Class(),
241                                                            AliAnalysisManager::kOutputContainer, 
242                                                            "d0D0SideB.root");
243   mgr->ConnectOutput(hfTaskSideB,5,coutputSBSecVtxX);
244
245   AliAnalysisDataContainer *coutputSBSecVtxY = mgr->CreateContainer("coutputSBSecVtxY",TH1::Class(),
246                                                            AliAnalysisManager::kOutputContainer, 
247                                                            "d0D0SideB.root");
248   mgr->ConnectOutput(hfTaskSideB,6,coutputSBSecVtxY);
249
250  AliAnalysisDataContainer *coutputSBSecVtxPhi = mgr->CreateContainer("coutputSBSecVtxPhi",TH1::Class(),
251                                                            AliAnalysisManager::kOutputContainer, 
252                                                            "d0D0SideB.root");
253   mgr->ConnectOutput(hfTaskSideB,7,coutputSBSecVtxPhi);
254
255
256   //Now container for d0D0SideB  
257   AliAnalysisDataContainer **coutputSB=new AliAnalysisDataContainer*[10];
258   AliAnalysisDataContainer *coutputSBAll = mgr->CreateContainer("coutputSBAll",TH1::Class(),
259                                                            AliAnalysisManager::kOutputContainer, 
260                                                            "d0D0SideB.root");
261
262
263   TString name="coutputSB",strname;
264   for(Int_t j=0;j<10;j++){
265     strname=name;
266     strname+=j;
267     coutputSB[j] = mgr->CreateContainer(strname.Data(),TH1::Class(),
268                                       AliAnalysisManager::kOutputContainer, 
269                                       "d0D0SideB.root");
270     
271     mgr->ConnectOutput(hfTaskSideB,j+8,coutputSB[j]);
272   }
273   mgr->ConnectOutput(hfTaskSideB,18,coutputSBAll);
274   //Now container for MC d0D0SideB  
275   AliAnalysisDataContainer **coutputSBMC=new AliAnalysisDataContainer*[10];
276   AliAnalysisDataContainer *coutputSBAllMC = mgr->CreateContainer("coutputSBAllMC",TH1::Class(),
277                                                            AliAnalysisManager::kOutputContainer, 
278                                                            "d0D0SideB.root");
279
280
281   name="coutputSBMC";
282   for(Int_t j=0;j<10;j++){
283     strname=name;
284     strname+=j;
285     coutputSBMC[j] = mgr->CreateContainer(strname.Data(),TH1::Class(),
286                                       AliAnalysisManager::kOutputContainer, 
287                                       "d0D0SideB.root");
288     
289     mgr->ConnectOutput(hfTaskSideB,j+19,coutputSBMC[j]);
290   }
291   mgr->ConnectOutput(hfTaskSideB,29,coutputSBAllMC);
292
293   //Now container for histo with d0 with respect to True Vtx
294   AliAnalysisDataContainer **coutputSBd0VtxTrue=new AliAnalysisDataContainer*[10];
295   AliAnalysisDataContainer *coutputSBd0VtxTrueAll = mgr->CreateContainer("coutputSBd0VtxTrueAll",TH1::Class(),
296                                                            AliAnalysisManager::kOutputContainer, 
297                                                            "d0D0SideB.root");
298
299
300   name="coutputSBd0VtxTrue";
301   for(Int_t j=0;j<10;j++){
302     strname=name;
303     strname+=j;
304     coutputSBd0VtxTrue[j] = mgr->CreateContainer(strname.Data(),TH1::Class(),
305                                       AliAnalysisManager::kOutputContainer, 
306                                       "d0D0SideB.root");
307     
308     mgr->ConnectOutput(hfTaskSideB,j+30,coutputSBd0VtxTrue[j]);
309   }
310   mgr->ConnectOutput(hfTaskSideB,40,coutputSBd0VtxTrueAll);
311
312 //INV MASS
313  AliAnalysisDataContainer *coutputSBD0InvMassAll = mgr->CreateContainer("coutputSBD0InvMassAll",TH1::Class(),
314                                                            AliAnalysisManager::kOutputContainer, 
315                                                            "d0D0SideB.root");
316  mgr->ConnectOutput(hfTaskSideB,41,coutputSBD0InvMassAll);
317
318  AliAnalysisDataContainer *coutputSBD0MCInvMassAll = mgr->CreateContainer("coutputSBD0MCInvMassAll",TH1::Class(),
319                                                                       AliAnalysisManager::kOutputContainer, 
320                                                            "d0D0SideB.root");
321  mgr->ConnectOutput(hfTaskSideB,42,coutputSBD0MCInvMassAll);
322
323  */
324
325   return hfTask;
326 }