Split: fix refs to AddTaskPhysicsSelection.C
[u/mrichter/AliRoot.git] / PWGJE / FlavourJetTasks / macros / AddTasksEmcalJetV0CF.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 = kTRUE;
6
7 const Bool_t bAnaInfoMC = kTRUE;
8 const Bool_t bAnaJetsMC = kFALSE;
9
10 const UInt_t wTriggerMask   = AliVEvent::kINT7;
11 const UInt_t wCollisionType = AliPicoHeaderCJ::kPA;
12 //=============================================================================
13
14 const TString sPeriodIn = "LHC13b4";
15 const TString sCentEsti = "V0A";  // "V0M"; "V0A"; "V0C"
16 const Double_t dCentMin =   0.;
17 const Double_t dCentMax = 100.;
18
19 const TString sInputTrkRD = (bIsInfoAOD ? "tracks"       : "Tracks");
20 const TString sInputClsRD = (bIsInfoAOD ? "caloClusters" : "CaloClusters");
21
22 const TString sUsedTrksRD = "PicoTracks";
23 const TString sUsedClusRD = "CaloClustersCorr";
24
25 const TString sUsedTrksMC = "MCParticles";
26 const TString sUsedClusMC = "";
27
28 const TString sUsedRhoRD  = "RhoRD";  // "RhoRD"
29 const TString sUsedRhoMC  = "";       // "RhoMC"
30
31 const TString sAnaType = "TPC";  // "TPC"; "EMCAL"; "USER"
32 const Int_t   nLeading = 0;      // 0: charged; 1: neutral; 2: both
33 //=============================================================================
34
35 const Double_t dV0Cuts[] = {
36   0.5,    // min V0 radius
37   200.,   // max V0 radius
38   1.,     // max V0 daus DCA
39   0.06,   // min tr DCA to PV
40   70.,    // min tr X rows TPC
41   0.8,    // min tr X/F rows TPC
42   5.,     // max Ka PID sigma TPC
43   0.97,   // min Ka cosPA
44   20.,    // max Ka ctau
45   0.005,  // min Ka deltaM
46   5.,     // max La PID sigma TPC
47   0.995,  // min La cosPA
48   30.,    // max La ctau
49   0.01    // min La deltaM
50 };
51
52 const Double_t dV0EtaMin = -0.75;
53 const Double_t dV0EtaMax =  0.75;
54
55 const TString sFileV0InvM = "/global/scratch2/sd/xmzhang/local/AnaCorrJets20140301/outputs/JE_V0A_000_010/AnalysisOutputs_FitInvMrd.root";
56 //=============================================================================
57
58 const Int_t nJetAlgo = 1;  // 0: KT; 1: AKT
59 const Int_t nJetType = 1;  // 0: FullJet; 1: ChargedJet; 2: NeutralJet
60
61 const Double_t dTrkPtCut  = 0.15;
62 const Double_t dCluEnCut  = 0.30;
63
64 const Double_t dJetRadius  = 0.4;
65 const Double_t dJetPtCut   = 10.;
66 const Double_t dJetAreaCut = 0.6;
67
68 const Double_t dJetEtaMin = dV0EtaMin + dJetRadius;
69 const Double_t dJetEtaMax = dV0EtaMax - dJetRadius;
70 //=============================================================================
71
72 Bool_t AddTasksEmcalJetV0CF()
73 {
74   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
75
76   if (bIsInfoAOD) {
77     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODHandler.C");
78     AliAODInputHandler *aodIH = AddAODHandler();
79   } else {
80     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddESDHandler.C");
81     AliESDInputHandler *esdIH = AddESDHandler();
82 //  esdIH->SetReadFriends(kFALSE);
83   }
84
85   if (bAnaInfoMC && (!bIsInfoAOD)) {
86     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddMCHandler.C");
87     AliMCEventHandler *mctEH = AddMCHandler(kTRUE);
88   }
89 //=============================================================================
90
91   if (bIsPhysSel) {
92 /*  gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPhysicsSelection.C");
93     AliEmcalPhysicsSelectionTask *taksPhysSel = AddTaskEmcalPhysicsSelection(kTRUE, kTRUE, wTriggerMask, 5., 5., 10., kTRUE, -1, -1, -1, -1);
94     if (bAnaInfoMC) {
95       AliEmcalPhysicsSelection *pPhysSel = static_cast<AliEmcalPhysicsSelection*>(taksPhysSel->GetPhysicsSelection());
96       if (!pPhysSel) return kTRUE; pPhysSel->SetAnalyzeMC();
97     }*/
98
99     gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
100     AliPhysicsSelectionTask *taskPhysSel = AddTaskPhysicsSelection(bAnaInfoMC);
101   }
102
103   if (bIsCentSel) {
104     gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
105     AliCentralitySelectionTask *taskCentSel = AddTaskCentrality(kTRUE, bIsInfoAOD);
106     if (wTriggerMask) taskCentSel->SelectCollisionCandidates(wTriggerMask);
107     if (bAnaInfoMC)   taskCentSel->SetMCInput();
108   }
109
110   if (bIsEvPnSel) {
111     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
112     AliEPSelectionTask *taskEventPlane = AddTaskEventplane();
113     if (wTriggerMask) taskEventPlane->SelectCollisionCandidates(wTriggerMask);
114     if (bAnaInfoMC)   taskEventPlane->SetUseMCRP();
115   }
116
117   if (bIsRespPID) {
118     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
119     AliAnalysisTaskSE *taskRespPID = AddTaskPIDResponse(bAnaInfoMC);
120     if (wTriggerMask)  taskRespPID->SelectCollisionCandidates(wTriggerMask);
121   }
122 //=============================================================================
123
124   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalSetup.C");
125   AliEmcalSetupTask *taskSetupEMCal = AddTaskEmcalSetup();
126   if (wTriggerMask)  taskSetupEMCal->SelectCollisionCandidates(wTriggerMask);
127   taskSetupEMCal->SetGeoPath("$ALICE_ROOT/OADB/EMCAL");
128
129   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C");
130   AliEmcalPicoTrackMaker *taskPicoTrackRD = AddTaskEmcalPicoTrackMaker(sUsedTrksRD.Data(),
131                                                                        sInputTrkRD.Data(),
132                                                                        sPeriodIn.Data());
133   if (wTriggerMask) taskPicoTrackRD->SelectCollisionCandidates(wTriggerMask);
134   if (bAnaInfoMC)   taskPicoTrackRD->SetMC(kTRUE);
135
136   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
137   AliEmcalJetTask *taskAktRD = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
138                                                ((nJetType!=1) ? sUsedClusRD.Data() : ""),
139                                                nJetAlgo,
140                                                dJetRadius,
141                                                nJetType,
142                                                dTrkPtCut,
143                                                dCluEnCut);
144   if (wTriggerMask) taskAktRD->SelectCollisionCandidates(wTriggerMask);
145
146   if (!sUsedRhoRD.IsNull()) {
147     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
148     AliEmcalJetTask *taskKtRD = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksRD.Data() : ""),
149                                                 ((nJetType!=1) ? sUsedClusRD.Data() : ""),
150                                                 0,  // KT
151                                                 dJetRadius,
152                                                 nJetType);
153     if (wTriggerMask) taskKtRD->SelectCollisionCandidates(wTriggerMask);
154     taskKtRD->SetMinJetPt(0.);
155
156     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskRhoSparse.C");
157     AliAnalysisTaskRhoSparse *taskRhoRD = AddTaskRhoSparse(taskKtRD->GetName(),
158                                                            taskAktRD->GetName(),
159                                                            ((nJetType!=2) ? sUsedTrksRD.Data() : ""),
160                                                            ((nJetType!=1) ? sUsedClusRD.Data() : ""),
161                                                            sUsedRhoRD.Data(),
162                                                            dJetRadius,
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                                                            sUsedRhoRD.Data(),  // task name
171                                                            kTRUE);             // use CMS rho
172     if (wTriggerMask) taskRhoRD->SelectCollisionCandidates(wTriggerMask);
173     taskRhoRD->SetCentRange(dCentMin, dCentMax);
174     taskRhoRD->SetCentralityEstimator(sCentEsti.Data());
175   }
176 //=============================================================================
177
178   if (bAnaJetsMC) {
179     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskMCTrackSelector.C");
180     AliEmcalMCTrackSelector *taskPicoTrackMC = AddTaskMCTrackSelector(sUsedTrksMC.Data(),
181                                                                       kFALSE,  // NK
182                                                                       kTRUE);  // CH
183     if (wTriggerMask) taskPicoTrackMC->SelectCollisionCandidates(wTriggerMask);
184
185     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
186     AliEmcalJetTask *taskAktMC = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksMC.Data() : ""),
187                                                  ((nJetType!=1) ? sUsedClusMC.Data() : ""),
188                                                  nJetAlgo,
189                                                  dJetRadius,
190                                                  nJetType,
191                                                  dTrkPtCut,
192                                                  dCluEnCut);
193     if (wTriggerMask) taskAktMC->SelectCollisionCandidates(wTriggerMask);
194
195     if (!sUsedRhoMC.IsNull()) {
196       gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
197       AliEmcalJetTask *taskKtMC = AddTaskEmcalJet(((nJetType!=2) ? sUsedTrksMC.Data() : ""),
198                                                   ((nJetType!=1) ? sUsedClusMC.Data() : ""),
199                                                   0,  // KT
200                                                   dJetRadius,
201                                                   nJetType);
202       if (wTriggerMask) taskKtMC->SelectCollisionCandidates(wTriggerMask);
203       taskKtMC->SetMinJetPt(0.);
204
205       gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskRhoSparse.C");
206       AliAnalysisTaskRhoSparse *taskRhoMC = AddTaskRhoSparse(taskKtMC->GetName(),
207                                                              taskAktMC->GetName(),
208                                                              ((nJetType!=2) ? sUsedTrksMC.Data() : ""),
209                                                              ((nJetType!=1) ? sUsedClusMC.Data() : ""),
210                                                              sUsedRhoMC.Data(),
211                                                              dJetRadius,
212                                                              sAnaType.Data(),
213                                                              0.01,               // jet area cut
214                                                              0.15,               // jet pT cut
215                                                              0.,                 // EMC area
216                                                              0x0,                // scale fxn
217                                                              0,                  // excluded leadings
218                                                              kTRUE,              // output histogram
219                                                              sUsedRhoMC.Data(),  // task name
220                                                              kTRUE);             // use CMS rho
221       if (wTriggerMask) taskRhoMC->SelectCollisionCandidates(wTriggerMask);
222       taskRhoMC->SetCentRange(dCentMin, dCentMax);
223       taskRhoMC->SetCentralityEstimator(sCentEsti.Data());
224     }
225   }
226 //=============================================================================
227
228   AliAnalysisTaskSEPicoV0MakerMC *taskPicoV0Maker = new AliAnalysisTaskSEPicoV0MakerMC("AliAnalysisTaskSEPicoV0MakerMC");
229   if (wTriggerMask) {
230     taskPicoV0Maker->SetTriggerMask(wTriggerMask);
231     taskPicoV0Maker->SelectCollisionCandidates(wTriggerMask);
232   }
233
234   taskPicoV0Maker->SetCollitionType(wCollisionType);
235   taskPicoV0Maker->SetCentralityEstimator(sCentEsti.Data());
236
237 //taskPicoV0Maker->SetRefitV0ESD();
238 //taskPicoV0Maker->SetSkipFastOnly();
239 //taskPicoV0Maker->SetDMPjetMC();
240
241   taskPicoV0Maker->SetV0Cuts(dV0Cuts);
242   taskPicoV0Maker->SetDauEtaRange(-0.8, 0.8);
243
244   mgr->AddTask(taskPicoV0Maker);
245   mgr->ConnectInput(taskPicoV0Maker,  0, mgr->GetCommonInputContainer());
246   mgr->ConnectOutput(taskPicoV0Maker, 1, mgr->CreateContainer("listPicoV0MakerMC",
247                                                               TList::Class(),
248                                                               AliAnalysisManager::kOutputContainer,
249                                                               AliAnalysisManager::GetCommonFileName()));
250 //=============================================================================
251
252   TFile *file = TFile::Open(sFileV0InvM.Data(), "READ");
253   TH1D *hKshortInvM = (TH1D*)((TList*)file->Get("listFitInvMrd_Kshort_Default"))->FindObject("hFitPtInvM"); hKshortInvM->SetName("hKshortInvM");
254   TH1D *hLambdaInvM = (TH1D*)((TList*)file->Get("listFitInvMrd_Lambda_Default"))->FindObject("hFitPtInvM"); hLambdaInvM->SetName("hLambdaInvM");
255   TH1D *hAntiLaInvM = (TH1D*)((TList*)file->Get("listFitInvMrd_AntiLa_Default"))->FindObject("hFitPtInvM"); hAntiLaInvM->SetName("hAntiLaInvM");
256   file->Close();
257
258   AliAnalysisTaskEmcalJetV0CF *taskEmcalJetV0Filter = new AliAnalysisTaskEmcalJetV0CF("AliAnalysisTaskEmcalJetV0CF");
259   if (wTriggerMask) taskEmcalJetV0Filter->SelectCollisionCandidates(wTriggerMask);
260
261   taskEmcalJetV0Filter->SetCentRange(dCentMin, dCentMax);
262   taskEmcalJetV0Filter->SetCentralityEstimator(sCentEsti.Data());
263
264   taskEmcalJetV0Filter->SetHistoKshortInvM(hKshortInvM);
265   taskEmcalJetV0Filter->SetHistoLambdaInvM(hLambdaInvM);
266   taskEmcalJetV0Filter->SetHistoAntiLaInvM(hAntiLaInvM);
267   taskEmcalJetV0Filter->SetV0EtaRange(dV0EtaMin, dV0EtaMax);
268
269 //taskEmcalJetV0Filter->SetForceBeamType(0);
270 //taskEmcalJetV0Filter->SetIsPythia(kTRUE);
271
272   AliJetContainer *pContJetsRD = taskEmcalJetV0Filter->AddJetContainer(taskAktRD->GetName(), "USER", dJetRadius);
273   pContJetsRD->SetPercAreaCut(dJetAreaCut);
274   pContJetsRD->SetJetPtCut(dJetPtCut);
275   pContJetsRD->SetJetEtaLimits(dJetEtaMin, dJetEtaMax);
276   pContJetsRD->SetRhoName(sUsedRhoRD.Data());
277 //pContJetsRD->SetLocalRhoName();
278   pContJetsRD->SetLeadingHadronType(nLeading);
279   pContJetsRD->ConnectParticleContainer(taskEmcalJetV0Filter->AddParticleContainer((nJetType!=2) ? sUsedTrksRD.Data() : ""));
280   pContJetsRD->ConnectClusterContainer( taskEmcalJetV0Filter->AddClusterContainer( (nJetType!=1) ? sUsedClusRD.Data() : ""));
281
282   if (bAnaJetsMC) {
283     AliJetContainer *pContJetsMC = taskEmcalJetV0Filter->AddJetContainer(taskAktMC->GetName(), sAnaType.Data(), dJetRadius);
284     pContJetsMC->SetPercAreaCut(dJetAreaCut);
285     pContJetsMC->SetJetPtCut(dJetPtCut);
286     pContJetsMC->SetJetEtaLimits(dJetEtaMin, dJetEtaMax);
287     pContJetsMC->SetRhoName(sUsedRhoMC.Data());
288 //  pContJetsMC->SetLocalRhoName();
289     pContJetsMC->SetLeadingHadronType(nLeading);
290     pContJetsMC->ConnectParticleContainer(taskEmcalJetV0Filter->AddParticleContainer((nJetType!=2) ? sUsedTrksMC.Data() : ""));
291     pContJetsMC->ConnectClusterContainer( taskEmcalJetV0Filter->AddClusterContainer( (nJetType!=1) ? sUsedClusMC.Data() : ""));
292   }
293
294   mgr->AddTask(taskEmcalJetV0Filter);
295   mgr->ConnectInput(taskEmcalJetV0Filter,  0, mgr->GetCommonInputContainer());
296   mgr->ConnectOutput(taskEmcalJetV0Filter, 1, mgr->CreateContainer("listEmcalJetTask",
297                                                                    TList::Class(),
298                                                                    AliAnalysisManager::kOutputContainer,
299                                                                    AliAnalysisManager::GetCommonFileName()));
300
301   mgr->ConnectOutput(taskEmcalJetV0Filter, 2, mgr->CreateContainer("listEmcalJetV0CF",
302                                                                    TList::Class(),
303                                                                    AliAnalysisManager::kOutputContainer,
304                                                                    AliAnalysisManager::GetCommonFileName()));
305
306   return kFALSE;
307 }