Macro to be attached to the analysis train
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
CommitLineData
90eb3a19 1AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(Char_t * analysis, TString data, TString calorimeter)
2{
3 // Creates a PartCorr task, configures it and adds it to the analysis manager.
4
5 // Get the pointer to the existing analysis manager via the static access method.
6 //==============================================================================
7 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
8 if (!mgr) {
9 ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
10 return NULL;
11 }
12
13 // Check the analysis type using the event handlers connected to the analysis manager.
14 //==============================================================================
15 if (!mgr->GetInputEventHandler()) {
16 ::Error("AddTaskPartCorr", "This task requires an input event handler");
17 return NULL;
18 }
19 //TString dataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20
21 // Configure analysis
22 //===========================================================================
23
24 //Reader
25 AliCaloTrackReader * reader = 0x0;
26 if(data=="AOD") reader = new AliCaloTrackAODReader();
27 else if(data=="ESD") reader = new AliCaloTrackESDReader();
28 else if(data=="MC") reader = new AliCaloTrackMCReader();
29 reader->SetDebug(-1);//10 for lots of messages
30
31 AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
32 switch (analysis) {
33 case "Pi0":
34 AnalysisPi0(maker,reader,calorimeter);
35 break;
36 case "GammaJetFinder":
37 //JETAN must run before
38 AnalysisGammaJetFinderCorrelation(maker,reader,calorimeter);
39 break;
40 case "GammaHadron":
41 AnalysisGammaHadronCorrelation(maker,reader,calorimeter);
42 break;
43 }
44
45
46 // Create task
47 //===========================================================================
48 AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (analysis);
49 task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
50 task->SetAnalysisMaker(maker);
51 mgr->AddTask(task);
52
53 AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("%s", analysis),TList::Class(),
54 AliAnalysisManager::kOutputContainer, Form("%s_%s.root",analysis,calorimeter.Data()));
55
56 // Create ONLY the output containers for the data produced by the task.
57 // Get and connect other common input/output containers via the manager as below
58 //==============================================================================
59 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
60 // AOD output slot will be used in a different way in future
61 mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
62 mgr->ConnectOutput (task, 1, cout_pc);
63
64 return task;
65}
66
67//_________________________________________________________________________________________________
68void AnalysisPi0(AliAnaPartCorrMaker * maker, AliCaloTrackReader * reader, TString calorimeter){
69 //Configuration for pi0 invariant mass analysis
70
71 // #### Reader ####
72 //Switch on or off the detectors
73 if(calorimeter=="EMCAL"){
74 reader->SwitchOnEMCAL();
75 reader->SwitchOffPHOS();
76 }
77 else if(calorimeter=="PHOS"){
78 reader->SwitchOffEMCAL();
79 reader->SwitchOnPHOS();
80 }
81 else if {
82 printf("ABORT analysis: Wrong calorimeter in configuration: %s\n",calorimeter.Data());
83 abort();
84 }
85 reader->SwitchOffCTS();
86
87 //Min particle pT
88 reader->SetEMCALPtMin(0.5);
89 reader->SetPHOSPtMin(0.5);
90 reader->Print("");
91
92 // ##### Analysis algorithm ####
93
94 AliCaloPID * pid = new AliCaloPID();
95 pid->SetDispersionCut(1.5);
96 pid->SetTOFCut(5.e-9);
97 pid->SetDebug(-1);
98 pid->Print("");
99
100 AliAnaPhoton *anaphoton = new AliAnaPhoton();
101 anaphoton->SetDebug(-1); //10 for lots of messages
102 //anaphoton->SetMinPt(0.5);
103 anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
104 anaphoton->SetCaloPID(pid);
105 anaphoton->SetCalorimeter(calorimeter);
106 anaphoton->SwitchOffDataMC() ;//Access MC stack and fill more histograms
107 anaphoton->SwitchOffCaloPID();
108 anaphoton->SwitchOffCaloPIDRecalculation(); //recommended for EMCAL
109 anaphoton->SwitchOffFidutialCut();
110 anaphoton->SetOutputAODName("Photons"+calorimeter);
111 anaphoton->SetOutputAODClassName("AliAODPWG4Particle");
112
113 AliAnaPi0 *anapi0 = new AliAnaPi0();
114 anapi0->SetDebug(-1);//10 for lots of messages
115 anapi0->SetInputAODName("Photons"+calorimeter);
116 anapi0->SetCaloPID(pid);
117 anapi0->SetCalorimeter(calorimeter);
118 anapi0->SwitchOnFidutialCut();
119 anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
120 anapi0->Print("");
121
122 // #### Configure Maker ####
123 maker->SetReader(reader);//pointer to reader
124 maker->AddAnalysis(anaphoton,0);
125 maker->AddAnalysis(anapi0,1);
126 maker->SetAnaDebug(-1) ;
127 maker->SwitchOnHistogramsMaker() ;
128 maker->SwitchOnAODsMaker() ;
129 maker->Print("");
130 //
131 printf("======================== \n");
132 printf("End Configuration of AnalysisPi0() \n");
133 printf("======================== \n");
134
135
136}
137//_________________________________________________________________________________________________
138void AnalysisGammaJetFinderCorrelation(AliAnaPartCorrMaker * maker, AliCaloTrackReader * reader, TString calorimeter){
139 //Configuration for pi0 invariant mass analysis
140
141 // #### Reader ####
142 //Switch on or off the detectors
143 if(calorimeter=="PHOS")
144 reader->SwitchOnPHOS();
145 else if(calorimeter=="EMCAL")
146 reader->SwitchOffPHOS();
147 else if {
148 printf("ABORT analysis: Wrong calorimeter in configuration: %s\n",calorimeter.Data());
149 abort();
150 }
151 reader->SwitchOnEMCAL();
152 reader->SwitchOnCTS();
153
154 //Min particle pT
155 reader->SetEMCALPtMin(0.5);
156 reader->SetPHOSPtMin(0.5);
157 reader->SetCTSPtMin(0.1);
158 reader->Print("");
159
160 // ##### Analysis algorithm ####
161 // ### Photon analysis ###
162 //AliCaloPID * pid = new AliCaloPID();
163 //pid->Print("");
164
165 AliAnaPhoton *anaphoton = new AliAnaPhoton();
166 anaphoton->SetDebug(-1); //10 for lots of messages
167 anaphoton->SetMinPt(5);
168 //anaphoton->SetCaloPID(pid);
169 anaphoton->SetCalorimeter(calorimeter);
170 anaphoton->SwitchOffDataMC() ;//Access MC stack and fill more histograms
171 anaphoton->SwitchOnCaloPID();
172 if(calorimeter == "EMCAL") anaphoton->SwitchOnCaloPIDRecalculation();
173 anaphoton->SwitchOffFidutialCut();
174 anaphoton->SetOutputAODName("DirectPhotonsJet"+calorimeter);
175 anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
176
177 // ### Isolation analysis ###
178
179 AliIsolationCut * ic = new AliIsolationCut();
180 ic->SetConeSize(0.5);
181 ic->SetPtThreshold(1.);
182 ic->SetICMethod(AliIsolationCut::kPtThresIC);
183 ic->Print("");
184
185 AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
186 anaisol->SetDebug(-1);
187 //anaisol->SetMinPt(5);
188 anaisol->SetInputAODName("DirectPhotonsJet"+calorimeter);
189 anaisol->SetCalorimeter(calorimeter);
190 anaisol->SwitchOffDataMC() ;//Access MC stack and fill more histograms
191 //Select clusters with no pair, if both clusters with pi0 mass
192 anaisol->SwitchOffInvariantMass();
193 //anaisol->SetNeutralMesonSelection(nms);
194 //Do isolation cut
195 anaisol->SetIsolationCut(ic);
196 //Do or not do isolation with previously produced AODs.
197 //No effect if use of SwitchOnSeveralIsolation()
198 anaisol->SwitchOffReIsolation();
199 //Multiple IC
200 anaisol->SwitchOffSeveralIsolation() ;
201 anaisol->Print("");
202
203 // ### Correlatio with Jet Finder AOD output
204 AliAnaParticleJetFinderCorrelation *anacorr = new AliAnaParticleJetFinderCorrelation();
205 anacorr->SetInputAODName("DirectPhotonsJet"+calorimeter);
206 anacorr->SwitchOffFidutialCut();
207 anacorr->SetDebug(-1);
208 anacorr->SetConeSize(1);
209 anacorr->SelectIsolated(kTRUE); // do correlation with isolated photons
210 anacorr->SetPtThresholdInCone(0.2);
211 anacorr->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts
212 anacorr->SetRatioCutRange(0.01,3); //Mostly Open Cuts
213 anacorr->UseJetRefTracks(kFALSE); //Not working now
214 anacorr->Print("");
215
216 // #### Configure Maker ####
217 maker->SetReader(reader);//pointer to reader
218 maker->AddAnalysis(anaphoton,0);
219 maker->AddAnalysis(anaisol,1);
220 maker->AddAnalysis(anacorr,2);
221 maker->SetAnaDebug(-1) ;
222 maker->SwitchOnHistogramsMaker() ;
223 maker->SwitchOnAODsMaker() ;
224 maker->Print("");
225 //
226 printf("======================== \n");
227 printf("End Configuration of AnalysisGammaJetFinderCorrelation() \n");
228 printf("======================== \n");
229
230
231}
232
233
234//_________________________________________________________________________________________________
235void AnalysisGammaHadronCorrelation(AliAnaPartCorrMaker * maker, AliCaloTrackReader * reader, TString calorimeter){
236 //Configuration for pi0 invariant mass analysis
237
238 // #### Reader ####
239 //Switch on or off the detectors
240 if(calorimeter=="PHOS")
241 reader->SwitchOnPHOS();
242 else if(calorimeter=="EMCAL")
243 reader->SwitchOffPHOS();
244 else if {
245 printf("ABORT analysis: Wrong calorimeter in configuration: %s\n",calorimeter.Data());
246 abort();
247 }
248 reader->SwitchOnEMCAL();
249 reader->SwitchOnCTS();
250
251 //Min particle pT
252 reader->SetEMCALPtMin(0.5);
253 reader->SetPHOSPtMin(0.5);
254 reader->SetCTSPtMin(0.1);
255 reader->Print("");
256
257 // ##### Analysis algorithm ####
258 // ### Photon analysis ###
259 //AliCaloPID * pid = new AliCaloPID();
260 //pid->Print("");
261
262 AliAnaPhoton *anaphoton = new AliAnaPhoton();
263 anaphoton->SetDebug(-1); //10 for lots of messages
264 anaphoton->SetMinPt(5);
265 //anaphoton->SetCaloPID(pid);
266 anaphoton->SetCalorimeter(calorimeter);
267 anaphoton->SwitchOffDataMC() ;//Access MC stack and fill more histograms
268 anaphoton->SwitchOnCaloPID();
269 if(calorimeter == "EMCAL") anaphoton->SwitchOnCaloPIDRecalculation();
270 anaphoton->SwitchOffFidutialCut();
271 anaphoton->SetOutputAODName("DirectPhotonsHadron"+calorimeter);
272 anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
273
274 // ### Isolation analysis ###
275
276 AliIsolationCut * ic = new AliIsolationCut();
277 ic->SetConeSize(0.5);
278 ic->SetPtThreshold(1.);
279 ic->SetICMethod(AliIsolationCut::kPtThresIC);
280 ic->Print("");
281
282 AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
283 anaisol->SetDebug(-1);
284 //anaisol->SetMinPt(5);
285 anaisol->SetInputAODName("DirectPhotonsHadron"+calorimeter);
286 anaisol->SetCalorimeter(calorimeter);
287 anaisol->SwitchOffDataMC() ;//Access MC stack and fill more histograms
288 //Select clusters with no pair, if both clusters with pi0 mass
289 anaisol->SwitchOffInvariantMass();
290 //anaisol->SetNeutralMesonSelection(nms);
291 //Do isolation cut
292 anaisol->SetIsolationCut(ic);
293 //Do or not do isolation with previously produced AODs.
294 //No effect if use of SwitchOnSeveralIsolation()
295 anaisol->SwitchOffReIsolation();
296 //Multiple IC
297 anaisol->SwitchOffSeveralIsolation() ;
298 anaisol->Print("");
299
300 // ### Correlation with hadrons
301 AliAnaParticleHadronCorrelation *anacorr = new AliAnaParticleHadronCorrelation();
302 anacorr->SetInputAODName("DirectPhotonsHadron"+calorimeter);
303 anacorr->SetDebug(-1);
304 anacorr->SwitchOffFidutialCut();
305 anacorr->SetPtCutRange(1,100);
306 anacorr->SetDeltaPhiCutRange(1.5,4.5);
307 if(calorimeter=="PHOS"){
308 //Correlate with particles in EMCAL
309 anacorr->SwitchOnCaloPID();
310 anacorr->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
311 }
312 anacorr->Print("");
313
314 // #### Configure Maker ####
315 maker->SetReader(reader);//pointer to reader
316 maker->AddAnalysis(anaphoton,0);
317 maker->AddAnalysis(anaisol,1);
318 maker->AddAnalysis(anacorr,2);
319 maker->SetAnaDebug(-1) ;
320 maker->SwitchOnHistogramsMaker() ;
321 maker->SwitchOnAODsMaker() ;
322 maker->Print("");
323 //
324 printf("======================== \n");
325 printf("End Configuration of AnalysisGammaJetFinderCorrelation() \n");
326 printf("======================== \n");
327
328}