Updates from Chiara
[u/mrichter/AliRoot.git] / PWGJE / FlavourJetTasks / macros / AddTasksFlavourJet.C
1 void AddTasksFlavourJet(const Int_t iCandType = 1 /*0 = D0, 1=Dstar...*/,
2                         const TString sCutFile = "cutsHF/D0toKpiCutsppRecVtxNoPileupRejNoEMCAL.root",
3                         const Double_t dJetPtCut   = 1.,
4                         const Double_t dJetAreaCut = 0.,
5                         const Int_t iAccCut = 1,
6                         const TString sRunPeriod = "LHC10b",
7                         const Int_t    uBeamType = 0,
8                         const UInt_t uTriggerMask = AliVEvent::kMB, /*for jets; the D mesons trigger is defined in the cut object*/
9                         const Bool_t bIsMC = kFALSE,
10                         TString sText=""/*completes the name of the candidate task lists*/
11 )
12 {
13   const TString sInputTrk  = "tracks";
14   const TString sUsedTrks  = "PicoTracks";
15   const TString sUsedClus  = "";
16
17   const Int_t iJetAlgo = 1;
18   const Int_t iJetType = 1;
19   /*
20   const Int_t    nRadius = 3;
21   const Double_t aRadius[] = {  0.2,   0.4,   0.6  };
22   const TString  sRadius[] = { "R02", "R04", "R06" };
23   */
24   const Int_t    nRadius = 1;
25   const Double_t aRadius[] = {  0.4  };
26   const TString  sRadius[] = { "R04" };
27
28 //=============================================================================
29
30   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
31
32   if (!mgr) {
33     ::Error("AddTasksFlavourJet.C::AddTasksFlavourJet", "No analysis manager to connect to.");
34     return;
35   }
36
37   TString type = mgr->GetInputEventHandler()->GetDataType();
38   if (!type.Contains("ESD") && !type.Contains("AOD")) {
39     ::Error("AddTasksFlavourJet.C::AddTasksFlavourJet", "Task manager to have an ESD or AOD input handler.");
40     return;
41   }
42
43   if (!mgr->GetInputEventHandler()) {
44     ::Error("AddTasksFlavourJet.C::AddTasksFlavourJet", "This task requires an input event handler");
45     return;
46   }
47 //=============================================================================
48
49   UInt_t uAnaType = (((iJetType==0) ||     (iJetType==2)) ? 1 : 0);
50   Int_t  iLeading =  ((iJetType==0) ? 3 : ((iJetType==1)  ? 0 : 1));
51
52   //D mesons -- PID
53   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
54   AliAnalysisTaskSE *taskRespPID = AddTaskPIDResponse(bIsMC);
55
56   // -- D meson selection
57   gROOT->LoadMacro("AliAnalysisTaskSEDmesonsFilterCJ.cxx++g");
58   gROOT->LoadMacro("AddTaskSEDmesonsFilterCJ.C");
59   AliAnalysisTaskSEDmesonsFilterCJ *taskDmesonsFilter = AddTaskSEDmesonsFilterCJ(iCandType,sCutFile,bIsMC,sText);
60
61   // EMCal framework
62   // -- Physics selection task
63   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPhysicsSelection.C");
64   AliPhysicsSelectionTask *physSelTask = AddTaskEmcalPhysicsSelection(kTRUE, kTRUE, uTriggerMask, 5, 5, 10, kTRUE, -1, -1, -1, -1);
65
66   if (!physSelTask) {
67     cout << "no physSelTask"; 
68     return; 
69   }
70
71   // -- 
72   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalSetup.C");
73   AliEmcalSetupTask *taskSetupEMCal = AddTaskEmcalSetup();
74   taskSetupEMCal->SetGeoPath("$ALICE_ROOT/OADB/EMCAL");
75   taskSetupEMCal->SelectCollisionCandidates(uTriggerMask);
76
77   // Jet preparation
78   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskJetPreparation.C");
79   AddTaskJetPreparation(type,bIsMC,sRunPeriod);
80
81   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C");
82   AliEmcalPicoTrackMaker *taskPicoTrack = AddTaskEmcalPicoTrackMaker(sUsedTrks.Data(),sInputTrk.Data(),sRunPeriod.Data());
83   taskPicoTrack->SelectCollisionCandidates(uTriggerMask);
84
85   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
86   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetSample.C");
87   gROOT->LoadMacro("AliAnalysisTaskFlavourJetCorrelations.cxx++g");
88   gROOT->LoadMacro("AddTaskFlavourJetCorrelations.C");
89
90   for (Int_t i=0; i<nRadius; i++) {
91     AliEmcalJetTask *taskFJ = AddTaskEmcalJet(sUsedTrks.Data(),sUsedClus.Data(),iJetAlgo,aRadius[i],iJetType);
92     taskFJ->SelectCollisionCandidates(uTriggerMask);
93
94     AliAnalysisTaskFlavourJetCorrelations *taskDmesonCJ = AddTaskFlavourJetCorrelations(iCandType,
95                                                                                         sCutFile,
96                                                                                         bIsMC,
97                                                                                         taskFJ->GetName(),
98                                                                                         Form("JetR%s",sRadius[i].Data()),
99                                                                                         iLeading,
100                                                                                         aRadius[i],
101                                                                                         dJetPtCut,
102                                                                                         iAccCut,
103                                                                                         dJetAreaCut);
104
105     taskDmesonCJ->SetName(Form("AliAnalysisTaskSEEmcalJetDmesonsCJ_%s",sRadius[i].Data()));
106    taskDmesonCJ->SetForceBeamType(uBeamType);
107     taskDmesonCJ->SetAnaType(uAnaType);
108     taskDmesonCJ->SetLeadingHadronType(iLeading);
109
110 //  taskDmesonCJ->SelectCollisionCandidates(uTriggerMask);
111   }
112
113   return;
114 }