Split: fix refs to AddTaskCentrality.C
[u/mrichter/AliRoot.git] / PWGJE / FlavourJetTasks / macros / AddTasksEmcalJetFilter.C
1 const Bool_t bIsInfoAOD = kTRUE;
2 const Bool_t bIsPhysSel = kFALSE;
3 const Bool_t bIsCentSel = kFALSE;
4 const Bool_t bIsEvPnSel = kFALSE;
5 const Bool_t bIsRespPID = kFALSE;
6
7 const Bool_t bAnaJetR02 = kTRUE;
8 const Bool_t bAnaJetR03 = kTRUE;
9 const Bool_t bAnaJetR04 = kTRUE;
10 const Bool_t bAnaInfoMC = kFALSE;
11
12 const UInt_t wTriggerMask   = AliVEvent::kINT7;
13 //=============================================================================
14
15 const TString sPeriodIn = "LHC13b";
16 const TString sCentEsti = "V0A";  // "V0M"; "V0A"; "V0C"
17 const Double_t dCentMin =   0.;
18 const Double_t dCentMax = 100.;
19
20 const TString sInputTrkRD = (bIsInfoAOD ? "tracks"          : "Tracks");
21 const TString sInputClsRD = (bIsInfoAOD ? "caloClusters"    : "CaloClusters");
22 const TString sFilterTrks = (bIsInfoAOD ? "AODFilterTracks" : "ESDFilterTracks");
23
24 const TString sUsedTrksRD = "PicoTracks";
25 const TString sUsedClusRD = "CaloClustersCorr";
26
27 const TString sUsedTrksMC = "MCParticles";
28 const TString sUsedClusMC = "";
29
30 const TString sUsedRhoRD02  = "RhoRD02";  // "RhoRD"
31 const TString sUsedRhoRD03  = "RhoRD03";  // "RhoRD"
32 const TString sUsedRhoRD04  = "RhoRD04";  // "RhoRD"
33
34 const TString sUsedRhoMC02  = "";         // "RhoMC"
35 const TString sUsedRhoMC03  = "";         // "RhoMC"
36 const TString sUsedRhoMC04  = "";         // "RhoMC"
37
38 const TString sAnaType = "TPC";  // "TPC"; "EMCAL"; "USER"
39 const Int_t   nLeading = 0;      // 0: charged; 1: neutral; 2: both
40 //=============================================================================
41
42 const Int_t nJetAlgo = 1;  // 0: KT; 1: AKT
43 const Int_t nJetType = 1;  // 0: FullJet; 1: ChargedJet; 2: NeutralJet
44
45 const Double_t dJetPtCut   = 8.0;
46 const Double_t dJetAreaCut = 0.6;
47
48 const Double_t dTrkPtCut  = 0.15;
49 const Double_t dCluEnCut  = 0.30;
50 //=============================================================================
51
52 Bool_t AddTasksEmcalJetFilter()
53 {
54   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
55
56   if (bIsInfoAOD) {
57     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODHandler.C");
58     AliAODInputHandler *aodIH = AddAODHandler();
59   } else {
60     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddESDHandler.C");
61     AliESDInputHandler *esdIH = AddESDHandler();
62 //  esdIH->SetReadFriends(kFALSE);
63   }
64
65   if (bAnaInfoMC && (!bIsInfoAOD)) {
66     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddMCHandler.C");
67     AliMCEventHandler *mctEH = AddMCHandler(kTRUE);
68   }
69
70   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODOutputHandler.C");
71   AliAODHandler *aodH = AddAODOutputHandler();
72   aodH->SetOutputFileName("AliAOD.PicoJets.root");
73   aodH->SetFillAOD(kTRUE);
74   aodH->SetCreateNonStandardAOD();
75   mgr->SetOutputEventHandler(aodH);
76 //=============================================================================
77
78   if (bIsPhysSel) {
79     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPhysicsSelection.C");
80     AliEmcalPhysicsSelectionTask *taksPhysSel = AddTaskEmcalPhysicsSelection(kTRUE, kTRUE, wTriggerMask, 5., 5., 10., kTRUE, -1, -1, -1, -1);
81     if (bAnaInfoMC) {
82       AliEmcalPhysicsSelection *pPhysSel = static_cast<AliEmcalPhysicsSelection*>(taksPhysSel->GetPhysicsSelection());
83       if (!pPhysSel) return kTRUE; pPhysSel->SetAnalyzeMC();
84     }
85   }
86
87   if (bIsCentSel) {
88     gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
89     AliCentralitySelectionTask *taskCentSel = AddTaskCentrality(kTRUE, bIsAOD);
90     if (wTriggerMask) taskCentSel->SelectCollisionCandidates(wTriggerMask);
91     if (bAnaInfoMC)   taskCentSel->SetMCInput();
92   }
93
94   if (bIsEvPnSel) {
95     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
96     AliEPSelectionTask *taskEventPlane = AddTaskEventplane();
97     if (wTriggerMask) taskEventPlane->SelectCollisionCandidates(wTriggerMask);
98     if (bAnaInfoMC)   taskEventPlane->SetUseMCRP();
99   }
100
101   if (bIsRespPID) {
102     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
103     AliAnalysisTaskSE *taskRespPID = AddTaskPIDResponse(bAnaInfoMC);
104     if (wTriggerMask)  taskRespPID->SelectCollisionCandidates(wTriggerMask);
105   }
106 //=============================================================================
107
108   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalSetup.C");
109   AliEmcalSetupTask *taskSetupEMCal = AddTaskEmcalSetup();
110   if (wTriggerMask)  taskSetupEMCal->SelectCollisionCandidates(wTriggerMask);
111   taskSetupEMCal->SetGeoPath("$ALICE_ROOT/OADB/EMCAL");
112
113   if (bIsInfoAOD) {
114     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalAodTrackFilter.C");
115     AliEmcalAodTrackFilterTask *taskTrkFilterAOD = AddTaskEmcalAodTrackFilter(sFilterTrks.Data(),
116                                                                               sInputTrkRD.Data(),
117                                                                               sPeriodIn.Data());
118     if (wTriggerMask) taskTrkFilterAOD->SelectCollisionCandidates(wTriggerMask);
119   } else {
120     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalEsdTrackFilter.C");
121     AliEmcalEsdTrackFilterTask *taskTrkFilterESD = AddTaskEmcalEsdTrackFilter(sFilterTrks.Data(),
122                                                                               Form("Hybrid_%s",sPeriodIn.Data()));
123     if (wTriggerMask) taskTrkFilterESD->SelectCollisionCandidates(wTriggerMask);
124     esdfilter->SetDoPropagation(kTRUE);
125     esdfilter->SetDist(440.);
126   }
127
128   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C");
129   AliEmcalPicoTrackMaker *taskPicoTrackRD = AddTaskEmcalPicoTrackMaker(sUsedTrksRD.Data(),
130                                                                        sFilterTrks.Data());
131   if (wTriggerMask) taskPicoTrackRD->SelectCollisionCandidates(wTriggerMask);
132   if (bAnaInfoMC)   taskPicoTrackRD->SetMC(kTRUE);
133 //=============================================================================
134
135   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
136   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskRhoSparse.C");
137
138   if (bAnaJetR02) {
139     AliEmcalJetTask *taskAktRD02 = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
140                                                    ((nJetType!=1) ? sUsedClusRD.Data() : ""),
141                                                    nJetAlgo,
142                                                    0.2,
143                                                    nJetType,
144                                                    dTrkPtCut,
145                                                    dCluEnCut);
146     if (wTriggerMask) taskAktRD02->SelectCollisionCandidates(wTriggerMask);
147
148     if (!sUsedRhoRD02.IsNull()) {
149       AliEmcalJetTask *taskKtRD02 = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
150                                                     ((nJetType!=1) ? sUsedClusRD.Data() : ""),
151                                                     0,  // KT
152                                                     0.2,
153                                                     nJetType);
154       if (wTriggerMask) taskKtRD02->SelectCollisionCandidates(wTriggerMask);
155       taskKtRD02->SetMinJetPt(0.);
156
157       AliAnalysisTaskRhoSparse *taskRhoRD02 = AddTaskRhoSparse(taskKtRD02->GetName(),
158                                                                taskAktRD02->GetName(),
159                                                                ((nJetType!=2) ? sUsedTrksRD.Data() : ""),
160                                                                ((nJetType!=1) ? sUsedClusRD.Data() : ""),
161                                                                sUsedRhoRD02.Data(),
162                                                                0.2,
163                                                                sAnaType.Data(),
164                                                                0.01,                 // jet area cut
165                                                                0.15,                 // jet pT cut
166                                                                0.,                   // EMC area
167                                                                0x0,                  // scale fxn
168                                                                0,                    // excluded leadings
169                                                                kTRUE,                // output histogram
170                                                                sUsedRhoRD02.Data(),  // task name
171                                                                kTRUE);               // use CMS rho
172       if (wTriggerMask) taskRhoRD02->SelectCollisionCandidates(wTriggerMask);
173       taskRhoRD02->SetCentRange(dCentMin, dCentMax);
174       taskRhoRD02->SetCentralityEstimator(sCentEsti.Data());
175     }
176   }
177
178   if (bAnaJetR03) {
179     AliEmcalJetTask *taskAktRD03 = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
180                                                    ((nJetType!=1) ? sUsedClusRD.Data() : ""),
181                                                    nJetAlgo,
182                                                    0.3,
183                                                    nJetType,
184                                                    dTrkPtCut,
185                                                    dCluEnCut);
186     if (wTriggerMask) taskAktRD03->SelectCollisionCandidates(wTriggerMask);
187
188     if (!sUsedRhoRD03.IsNull()) {
189       AliEmcalJetTask *taskKtRD03 = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
190                                                     ((nJetType!=1) ? sUsedClusRD.Data() : ""),
191                                                     0,  // KT
192                                                     0.3,
193                                                     nJetType);
194       if (wTriggerMask) taskKtRD03->SelectCollisionCandidates(wTriggerMask);
195       taskKtRD03->SetMinJetPt(0.);
196
197       AliAnalysisTaskRhoSparse *taskRhoRD03 = AddTaskRhoSparse(taskKtRD03->GetName(),
198                                                                taskAktRD03->GetName(),
199                                                                ((nJetType!=2) ? sUsedTrksRD.Data() : ""),
200                                                                ((nJetType!=1) ? sUsedClusRD.Data() : ""),
201                                                                sUsedRhoRD03.Data(),
202                                                                0.3,
203                                                                sAnaType.Data(),
204                                                                0.01,                 // jet area cut
205                                                                0.15,                 // jet pT cut
206                                                                0.,                   // EMC area
207                                                                0x0,                  // scale fxn
208                                                                0,                    // excluded leadings
209                                                                kTRUE,                // output histogram
210                                                                sUsedRhoRD03.Data(),  // task name
211                                                                kTRUE);               // use CMS rho
212       if (wTriggerMask) taskRhoRD03->SelectCollisionCandidates(wTriggerMask);
213       taskRhoRD03->SetCentRange(dCentMin, dCentMax);
214       taskRhoRD03->SetCentralityEstimator(sCentEsti.Data());
215     }
216   }
217
218   if (bAnaJetR04) {
219     AliEmcalJetTask *taskAktRD04 = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
220                                                    ((nJetType!=1) ? sUsedClusRD.Data() : ""),
221                                                    nJetAlgo,
222                                                    0.4,
223                                                    nJetType,
224                                                    dTrkPtCut,
225                                                    dCluEnCut);
226     if (wTriggerMask) taskAktRD04->SelectCollisionCandidates(wTriggerMask);
227
228     if (!sUsedRhoRD04.IsNull()) {
229       AliEmcalJetTask *taskKtRD04 = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
230                                                     ((nJetType!=1) ? sUsedClusRD.Data() : ""),
231                                                     0,  // KT
232                                                     0.4,
233                                                     nJetType);
234       if (wTriggerMask) taskKtRD04->SelectCollisionCandidates(wTriggerMask);
235       taskKtRD04->SetMinJetPt(0.);
236
237       AliAnalysisTaskRhoSparse *taskRhoRD04 = AddTaskRhoSparse(taskKtRD04->GetName(),
238                                                                taskAktRD04->GetName(),
239                                                                ((nJetType!=2) ? sUsedTrksRD.Data() : ""),
240                                                                ((nJetType!=1) ? sUsedClusRD.Data() : ""),
241                                                                sUsedRhoRD04.Data(),
242                                                                0.4,
243                                                                sAnaType.Data(),
244                                                                0.01,                 // jet area cut
245                                                                0.15,                 // jet pT cut
246                                                                0.,                   // EMC area
247                                                                0x0,                  // scale fxn
248                                                                0,                    // excluded leadings
249                                                                kTRUE,                // output histogram
250                                                                sUsedRhoRD04.Data(),  // task name
251                                                                kTRUE);               // use CMS rho
252       if (wTriggerMask) taskRhoRD04->SelectCollisionCandidates(wTriggerMask);
253       taskRhoRD04->SetCentRange(dCentMin, dCentMax);
254       taskRhoRD04->SetCentralityEstimator(sCentEsti.Data());
255     }
256   }
257 //=============================================================================
258
259   if (bAnaInfoMC) {
260     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskMCTrackSelector.C");
261     AliEmcalMCTrackSelector *taskPicoTrackMC = AddTaskMCTrackSelector(sUsedTrksMC.Data(),
262                                                                       kFALSE,  // NK
263                                                                       kTRUE);  // CH
264     if (wTriggerMask) taskPicoTrackMC->SelectCollisionCandidates(wTriggerMask);
265   }
266 //=============================================================================
267
268   AliAnalysisTaskEmcalJetFilter *taskEmcalJetFilter = new AliAnalysisTaskEmcalJetFilter("AliAnalysisTaskEmcalJetFilter");
269   if (wTriggerMask) taskEmcalJetFilter->SelectCollisionCandidates(wTriggerMask);
270
271   taskEmcalJetFilter->SetCentRange(dCentMin, dCentMax);
272   taskEmcalJetFilter->SetCentralityEstimator(sCentEsti.Data());
273 //taskEmcalJetFilter->SetForceBeamType(0);
274 //taskEmcalJetFilter->SetIsPythia(kTRUE);
275
276   if (bAnaJetR02) {
277     AliJetContainer *pContJetsRD02 = taskEmcalJetFilter->AddJetContainer(taskAktRD02->GetName(), sAnaType.Data(), 0.2);
278     pContJetsRD02->SetPercAreaCut(dJetAreaCut);
279     pContJetsRD02->SetJetPtCut(dJetPtCut);
280     pContJetsRD02->SetRhoName(sUsedRhoRD02.Data());
281 //  pContJetsRD02->SetLocalRhoName();
282     pContJetsRD02->SetLeadingHadronType(nLeading);
283     pContJetsRD02->ConnectParticleContainer(taskEmcalJetFilter->AddParticleContainer((nJetType!=2) ? sUsedTrksRD.Data() : ""));
284     pContJetsRD02->ConnectClusterContainer( taskEmcalJetFilter->AddClusterContainer( (nJetType!=1) ? sUsedClusRD.Data() : ""));
285     pContJetsRD02->SetNameTitle("AliEMcalJetContainerRD02", "AliEMcalJetContainerRD02");
286     taskEmcalJetFilter->SetNameJetRD02("AliEMcalJetContainerRD02");
287   }
288
289   if (bAnaJetR03) {
290     AliJetContainer *pContJetsRD03 = taskEmcalJetFilter->AddJetContainer(taskAktRD03->GetName(), sAnaType.Data(), 0.3);
291     pContJetsRD03->SetPercAreaCut(dJetAreaCut);
292     pContJetsRD03->SetJetPtCut(dJetPtCut);
293     pContJetsRD03->SetRhoName(sUsedRhoRD03.Data());
294 //  pContJetsRD03->SetLocalRhoName();
295     pContJetsRD03->SetLeadingHadronType(nLeading);
296     pContJetsRD03->ConnectParticleContainer(taskEmcalJetFilter->AddParticleContainer((nJetType!=2) ? sUsedTrksRD.Data() : ""));
297     pContJetsRD03->ConnectClusterContainer( taskEmcalJetFilter->AddClusterContainer( (nJetType!=1) ? sUsedClusRD.Data() : ""));
298     pContJetsRD03->SetNameTitle("AliEMcalJetContainerRD03", "AliEMcalJetContainerRD03");
299     taskEmcalJetFilter->SetNameJetRD03("AliEMcalJetContainerRD03");
300   }
301
302   if (bAnaJetR04) {
303     AliJetContainer *pContJetsRD04 = taskEmcalJetFilter->AddJetContainer(taskAktRD04->GetName(), sAnaType.Data(), 0.4);
304     pContJetsRD04->SetPercAreaCut(dJetAreaCut);
305     pContJetsRD04->SetJetPtCut(dJetPtCut);
306     pContJetsRD04->SetRhoName(sUsedRhoRD04.Data());
307 //  pContJetsRD04->SetLocalRhoName();
308     pContJetsRD04->SetLeadingHadronType(nLeading);
309     pContJetsRD04->ConnectParticleContainer(taskEmcalJetFilter->AddParticleContainer((nJetType!=2) ? sUsedTrksRD.Data() : ""));
310     pContJetsRD04->ConnectClusterContainer( taskEmcalJetFilter->AddClusterContainer( (nJetType!=1) ? sUsedClusRD.Data() : ""));
311     pContJetsRD04->SetNameTitle("AliEMcalJetContainerRD04", "AliEMcalJetContainerRD04");
312     taskEmcalJetFilter->SetNameJetRD04("AliEMcalJetContainerRD04");
313   }
314
315   mgr->AddTask(taskEmcalJetFilter);
316   mgr->ConnectInput(taskEmcalJetFilter,  0, mgr->GetCommonInputContainer());
317   mgr->ConnectOutput(taskEmcalJetFilter, 1, mgr->CreateContainer("listEmcalJet",
318                                                                  TList::Class(),
319                                                                  AliAnalysisManager::kOutputContainer,
320                                                                  AliAnalysisManager::GetCommonFileName()));
321
322   return kFALSE;
323 }