dda16bbc21e6fc0e19630f2b24c95193c2ceeed7
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / AddTaskHFEpPb.C
1 AliAnalysisTask *AddTaskHFEpPb(Bool_t isAOD = kFALSE){\r
2   // Switches for the TOF-TPC analysis\r
3   Bool_t kTPC_Only                   = kTRUE;\r
4   Bool_t kTPCTOF_Ref                 = kTRUE;\r
5   Bool_t kTPCTOF_Sys                 = kFALSE;\r
6   Bool_t kTRD_Test                   = kFALSE;\r
7   //get the current analysis manager\r
8   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
9   if (!mgr) {\r
10     Error("AddTask_hfe_HFE", "No analysis manager found.");\r
11     return 0;\r
12   }\r
13   \r
14   Bool_t MCthere=kTRUE;\r
15   AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>(mgr->GetMCtruthEventHandler());\r
16   if(!mcH){\r
17     MCthere=kFALSE;\r
18   }\r
19   \r
20   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();\r
21   \r
22   //@@ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
23   \r
24   // Default settings \r
25   const int kDefITScl = 3;\r
26   const int kDefTPCcl = 110;\r
27   const int kDefTPCclPID = 80;\r
28   const double kDefDCAr = 1.;\r
29   const double kDefDCAz = 2.;\r
30   // For pPb, new fits by Martin, 07.02.2013\r
31   const double kDefTPCs = 0.045;\r
32   // it seems the sigma is 1 and not 0.88 (3 sigma = 2.685)\r
33   const double kDefTPCu = 3.045;   \r
34   const double kDefTOFs = 3.;\r
35 \r
36   Double_t dEdxlm[12] = {0.045,0.045,0.045,0.045,0.045,0.045,0.045,0.045,0.045,0.045,0.045,0.045};  //  50%\r
37   Double_t dEdxhm[12] = {2.685,2.685,2.685,2.685,2.685,2.685,2.685,2.685,2.685,2.685,2.685,2.685};\r
38   // For systematics:\r
39   Double_t tpcl0[12]  = {-0.835,-0.835,-0.835,-0.835,-0.835,-0.835,-0.835,-0.835,-0.835,-0.835,-0.835,-0.835};  //  84%\r
40   Double_t tpcl1[12]  = {-0.184,-0.184,-0.184,-0.184,-0.184,-0.184,-0.184,-0.184,-0.184,-0.184,-0.184,-0.184};  //  60%\r
41   Double_t tpcl2[12]  = {0.265,0.265,0.265,0.265,0.265,0.265,0.265,0.265,0.265,0.265,0.265,0.265};  //   40%\r
42 \r
43   \r
44   // For TPC only\r
45   const double kDefTPCs1 = 0.034;\r
46   const double kDefTPCu1 = 2.674;\r
47   \r
48   if(kTPC_Only){\r
49     // for the moment (09.02.2013) use the same as TOF-TPC. Refine later on\r
50     RegisterTaskPID2(MCthere,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth);\r
51   }\r
52   \r
53   //------------------------------//\r
54   //   TPC-TOF analysis\r
55   //------------------------------//\r
56   \r
57   if(kTPCTOF_Ref){\r
58     // Reference task\r
59      // Fits by Martin 07.02.2013\r
60     // mean = 0.045\r
61     // sigma = 0.88\r
62     // 50%\r
63     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
64     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,0.295,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
65 \r
66     // add centrality\r
67     RegisterTask(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&dEdxlm[0],&dEdxhm[0],kDefTOFs,0,AliHFEextraCuts::kBoth); // 50%\r
68     //if (!MCthere){\r
69     //  RegisterTask(MCthere,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl0[0],&dEdxhm[0],kDefTOFs,0,AliHFEextraCuts::kBoth);  // 84%\r
70     //}\r
71   }\r
72   if(kTPCTOF_Sys){\r
73 \r
74     // TPC PID\r
75     if (!MCthere){\r
76       // 84%\r
77       RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,-0.835,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
78       // 60%\r
79       RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,-0.184,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
80       // 40%\r
81       RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,0.265,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
82     }\r
83 \r
84     // TOF PID\r
85     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,2.0,0,AliHFEextraCuts::kBoth);\r
86     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,4.0,0,AliHFEextraCuts::kBoth);\r
87     // TOF latest mismatch - helps nothing\r
88     //RegisterTaskPID2(MCthere,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,1,AliHFEextraCuts::kBoth);\r
89 \r
90     // ITS hits and SPD request\r
91     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,4,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
92     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,5,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
93     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,3,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kFirst);\r
94     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,4,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kFirst);\r
95 \r
96     // TPC clusters\r
97     RegisterTaskPID2(MCthere,isAOD,100,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
98     RegisterTaskPID2(MCthere,isAOD,120,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
99     RegisterTaskPID2(MCthere,isAOD,130,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
100     // TPC clusters PID\r
101     RegisterTaskPID2(MCthere,isAOD,kDefTPCcl,100,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth);\r
102 \r
103   }\r
104   \r
105   return NULL;\r
106 }\r
107 \r
108 \r
109 //===============================================================================\r
110 \r
111 AliAnalysisTask *RegisterTask(Bool_t useMC, Bool_t isAOD, Int_t tpcCls=120, Int_t tpcClsPID = 80, \r
112                               Int_t itsCls=4, Double_t dcaxy=1.0, Double_t dcaz=2.0, \r
113                               Double_t *tpcdEdxcutlow=NULL, \r
114                               Double_t *tpcdEdxcuthigh=NULL, \r
115                               //Double_t tpcs=-0.0113, Double_t tpcu=3.09, \r
116                               Double_t tofs=3., Int_t tofm=0,\r
117                               Int_t itshitpixel = AliHFEextraCuts::kBoth, \r
118                               Bool_t withetacorrection = kFALSE){\r
119 \r
120   Int_t idcaxy = (Int_t)(dcaxy*10.);\r
121   Int_t idcaz = (Int_t)(dcaz*10.);\r
122   Int_t tpclow = 0;\r
123   if(tpcdEdxcutlow) tpclow = (Int_t) (tpcdEdxcutlow[0]*1000.);\r
124   Int_t itofs = (Int_t)(tofs*10.);\r
125   Int_t ipixelany = itshitpixel;\r
126   Int_t ietacorr = 0;\r
127   if(withetacorrection) ietacorr = 1;\r
128   \r
129   TString appendix(TString::Format("centTPCc%dTPCp%dITS%dDCAr%dz%dTPCs%dTOFs%dm%ipa%d",tpcCls,\r
130                                    tpcClsPID,itsCls,idcaxy,idcaz,tpclow,itofs,tofm,ipixelany));\r
131   printf("Add macro appendix %s\n", appendix.Data());\r
132 \r
133 \r
134   gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/pPb/ConfigHFEpPb.C");\r
135   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
136   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();\r
137   AliAnalysisTaskHFE *task = ConfigHFEpPb(useMC, isAOD, appendix, tpcCls, tpcClsPID, itsCls, dcaxy, dcaz, \r
138                                           tpcdEdxcutlow,tpcdEdxcuthigh,\r
139                                           tofs,tofm,itshitpixel);\r
140 \r
141   if(isAOD)\r
142     task->SetAODAnalysis();\r
143   else\r
144     task->SetESDAnalysis();\r
145   if (useMC)\r
146     task->SetHasMCData(kTRUE);\r
147   else{\r
148     task->SetHasMCData(kFALSE);\r
149   }\r
150   task->SelectCollisionCandidates(AliVEvent::kINT7);\r
151 \r
152   TString containerName = mgr->GetCommonFileName();\r
153   containerName += ":HFEpPbcent";\r
154   containerName += appendix.Data();\r
155   printf("container name: %s\n", containerName.Data());\r
156  \r
157   //create data containers\r
158   task->ConnectOutput(1, mgr->CreateContainer(Form("HFE_Results_%s", appendix.Data()), \r
159                                               TList::Class(), AliAnalysisManager::kOutputContainer, \r
160                                               containerName.Data()));\r
161   task->ConnectOutput(2, mgr->CreateContainer(Form("HFE_QA_%s", appendix.Data()), TList::Class(), \r
162                                               AliAnalysisManager::kOutputContainer, \r
163                                               containerName.Data()));\r
164   mgr->ConnectInput(task,  0, cinput );\r
165 \r
166   mgr->AddTask(task);\r
167   return NULL;\r
168 }\r
169 \r
170 //===============================================================================\r
171 \r
172 AliAnalysisTask *RegisterTaskPID2(Bool_t useMC, Bool_t isAOD, Int_t tpcCls=120, Int_t tpcClsPID = 80, \r
173                                   Int_t itsCls=4, Double_t dcaxy=1.0, Double_t dcaz=2.0, \r
174                                   Double_t tpcs=-0.0113, Double_t tpcu=3.09, Double_t tofs=3., \r
175                                   Int_t tofm=0,\r
176                                   Int_t itshitpixel = AliHFEextraCuts::kBoth, \r
177                                   Bool_t withetacorrection = kTRUE){\r
178   gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/pPb/ConfigHFEmbpPb.C");\r
179   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
180   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();\r
181   AliAnalysisTaskHFE *task = ConfigHFEmbpPb(useMC, isAOD, tpcCls, tpcClsPID, itsCls, dcaxy, dcaz, \r
182                                              tpcs,tpcu,tofs,tofm,3.,kFALSE,kTRUE,kFALSE,itshitpixel,withetacorrection);\r
183   if()\r
184     task->SetAODAnalysis();\r
185   else\r
186     task->SetESDAnalysis();\r
187   if (useMC)\r
188     task->SetHasMCData(kTRUE);\r
189   else{\r
190     task->SetHasMCData(kFALSE);\r
191   }\r
192   task->SelectCollisionCandidates(AliVEvent::kINT7);\r
193  \r
194   Int_t idcaxy = (Int_t)(dcaxy*10.);\r
195   Int_t idcaz = (Int_t)(dcaz*10.);\r
196   Int_t itpcs = (Int_t)(tpcs*1000.);\r
197   Int_t itofs = (Int_t)(tofs*10.);\r
198   Int_t ipixelany = itshitpixel;\r
199   Int_t ietacorr = 0;\r
200   if(withetacorrection) ietacorr = 1;\r
201   \r
202   TString appendix(TString::Format("TPCc%dTPCp%dITS%dDCAr%dz%dTPCs%dTOFs%dm%ipa%d",tpcCls,\r
203                                    tpcClsPID,itsCls,idcaxy,idcaz,itpcs,itofs,tofm,ipixelany));\r
204   printf("Add macro appendix %s\n", appendix.Data());\r
205 \r
206   TString containerName = mgr->GetCommonFileName();\r
207   containerName += ":HFEpPbmb";\r
208   containerName += appendix.Data();\r
209   printf("container name: %s\n", containerName.Data());\r
210 \r
211   //create data containers\r
212   task->ConnectOutput(1, mgr->CreateContainer(Form("HFE_Results_%s", appendix.Data()), \r
213                                               TList::Class(), AliAnalysisManager::kOutputContainer, \r
214                                               containerName.Data()));\r
215   task->ConnectOutput(2, mgr->CreateContainer(Form("HFE_QA_%s", appendix.Data()), TList::Class(), \r
216                                               AliAnalysisManager::kOutputContainer, \r
217                                               containerName.Data()));\r
218   mgr->ConnectInput(task,  0, cinput );\r
219 \r
220   mgr->AddTask(task);\r
221   return NULL;\r
222 }\r
223 \r
224 \r
225 //=========================================================================\r