Charged jets (pPb): Fixes and improvements
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / macros / AddTaskChargedJetsPA.C
1 AliAnalysisTaskChargedJetsPA* AddTaskChargedJetsPA(
2   const char*         containerSuffix         = "",
3   Double_t            jetRadius               = 0.4,
4   const char*         centralityType          = "V0A",
5   Int_t               trigger                 = AliVEvent::kINT7,
6   Bool_t              isPA                    = kTRUE,
7   Bool_t              isMC                    = kFALSE,
8   Bool_t              doJetProfileAnalysis    = kFALSE,
9   Bool_t              doTrackcutAnalysis      = kFALSE,
10   Bool_t              doJetAnalysis           = kTRUE,
11   const char*         usedTracks              = "PicoTracks",
12   Int_t               numberOfCentralityBins  = 20,
13   Double_t            areaPercentage          = 0.6,
14   Double_t            ktJetRadius             = 0.4,
15   Double_t            trackBgrdConeR          = 0.6,
16   Double_t            minEta                  = -0.9,
17   Double_t            maxEta                  = +0.9,
18   Double_t            minJetEta               = -0.5,
19   Double_t            maxJetEta               = +0.5,
20   Bool_t              isEMCalTrain            = kFALSE,
21 )
22 {
23   // #### Detect the demanded trigger with its readable name
24   TString triggerName(Form("Trigger_%i", trigger));
25   if (trigger == AliVEvent::kAnyINT)
26     triggerName = "kAnyINT";
27   else if (trigger == AliVEvent::kAny)
28     triggerName = "kAny";
29   else if(trigger == AliVEvent::kINT7)
30     triggerName = "kINT7";
31   else if(trigger == AliVEvent::kMB)
32     triggerName = "kMB";
33   else if(trigger == AliVEvent::kEMC7)
34     triggerName = "kEMC7";
35   else if(trigger == AliVEvent::kEMCEJE)
36     triggerName = "kEMCEJE";
37   else if(trigger == AliVEvent::kEMCEGA)
38     triggerName = "kEMCEGA";
39
40   // #### Define manager and data container names
41   AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
42   if (!manager) {
43     ::Error("AddTaskChargedJetsPA", "No analysis manager to connect to.");
44     return NULL;
45   }
46
47   TString containerNameSuffix("");
48
49   if (strcmp(containerSuffix,""))
50     containerNameSuffix = Form("_%s", containerSuffix);
51
52   TString bgrdName("Background");
53   TString myContName("");
54   TString myContJPName("");
55   TString myContTCName("");
56   if(isMC)
57   {
58     bgrdName = Form("BackgroundR0%2.0f_%s_MC%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
59     myContName = Form("AnalysisR0%2.0f_%s_MC%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
60     myContJPName = Form("JetProfileR0%2.0f_%s_MC%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
61     myContTCName = Form("TrackcutsR0%2.0f_%s_MC%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
62   }
63   else
64   {
65     bgrdName = Form("BackgroundR0%2.0f_%s%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
66     myContName = Form("AnalysisR0%2.0f_%s%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
67     myContJPName = Form("JetProfileR0%2.0f_%s%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
68     myContTCName = Form("TrackcutsR0%2.0f_%s%s", jetRadius*100, triggerName.Data(), containerNameSuffix.Data());
69   }
70
71   if(doJetAnalysis)
72   {
73     // #### Add necessary jet finder tasks
74     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
75     AliEmcalJetTask* jetFinderTask = AddTaskEmcalJet(usedTracks,"",1,jetRadius,1,0.150,0.300); // anti-kt
76     AliEmcalJetTask* jetFinderTaskKT = AddTaskEmcalJet(usedTracks,"",0,ktJetRadius,1,0.150,0.300); // kt
77
78     // #### Define external rho task
79     AliEmcalJetTask* jetFinderRho = AddTaskEmcalJet(usedTracks,"",1,0.4,1,0.150,0.300); // anti-kt
80     AliEmcalJetTask* jetFinderRhoKT = AddTaskEmcalJet(usedTracks,"",0,0.4,1,0.150,0.300); // kt
81     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskRhoSparse.C");
82     AliAnalysisTaskRhoSparse* rhotask = AddTaskRhoSparse(jetFinderRhoKT->GetName(), NULL, usedTracks, "", bgrdName.Data(), 0.4,"TPC", 0., 5., 0, 0,2,kFALSE,bgrdName.Data(),kTRUE);
83   }
84
85   // #### Define analysis task
86   AliAnalysisTaskChargedJetsPA *task = NULL;
87   AliAnalysisDataContainer* contHistos = manager->CreateContainer(myContName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:ChargedJets", AliAnalysisManager::GetCommonFileName()));
88   if(doJetProfileAnalysis)
89     AliAnalysisDataContainer* contJetProfile = manager->CreateContainer(myContJPName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:ChargedJets", AliAnalysisManager::GetCommonFileName()));
90   if(doTrackcutAnalysis)
91     AliAnalysisDataContainer* contTrackcuts = manager->CreateContainer(myContTCName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:ChargedJets", AliAnalysisManager::GetCommonFileName()));
92
93   if(doJetAnalysis)
94   {
95     task = new AliAnalysisTaskChargedJetsPA(Form("AnalysisPA_%s_%s", jetFinderTask->GetName(), triggerName.Data()), usedTracks, jetFinderTask->GetName(),jetFinderTaskKT->GetName(), doJetProfileAnalysis, doTrackcutAnalysis);
96     task->SetExternalRhoTaskName(bgrdName.Data());
97   }
98   else
99     task = new AliAnalysisTaskChargedJetsPA(Form("AnalysisPA_%s", "", triggerName.Data()), usedTracks, "","", doJetProfileAnalysis, doTrackcutAnalysis);
100
101
102   // #### Task preferences
103   task->SetIsPA(isPA);
104   task->SetAnalyzeJetProfile(doJetProfileAnalysis);
105   task->SetAnalyzeTrackcuts(doTrackcutAnalysis);
106   task->SetAcceptanceEta(minEta,maxEta);
107   task->SetAcceptanceJetEta(minJetEta,maxJetEta);
108   task->SetSignalJetRadius(jetRadius);
109   task->SetBackgroundJetRadius(jetRadius);
110   task->SetSignalJetMinArea(areaPercentage*jetRadius*jetRadius*TMath::Pi());
111   task->SetRandConeRadius(jetRadius);
112   task->SelectCollisionCandidates(trigger);
113   task->SetCentralityType(centralityType);
114   task->SetNumberOfCentralityBins(numberOfCentralityBins);
115   task->SetDoJetAnalysis(doJetAnalysis);
116
117   // #### Add analysis task
118   manager->AddTask(task);
119   manager->ConnectInput(task, 0, manager->GetCommonInputContainer());
120   manager->ConnectOutput(task, 1, contHistos);
121   if(doJetProfileAnalysis)
122   {
123     manager->ConnectOutput(task, 2, contJetProfile);
124   }
125   if(doTrackcutAnalysis && !doJetProfileAnalysis)
126   {
127     manager->ConnectOutput(task, 2, contTrackcuts);
128   }
129   else if(doTrackcutAnalysis && doJetProfileAnalysis)
130   {
131     manager->ConnectOutput(task, 3, contTrackcuts);
132   }
133
134   if(isEMCalTrain)
135     RequestMemory(task,200*1024);
136
137   return task;
138 }