]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
Correct deletion of pointers which when the class was not the owner.
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(TString data, TString calorimeter, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE)
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 inputDataType = "AOD";
20    if(!data.Contains("delta"))
21            inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
22    //cout<<"DATA TYPE :: "<<inputDataType<<endl;
23    // inputDataType: data managed by the input handler
24    // data: can be same as one managed by input handler, or the output AOD created by the filter. By default use AOD
25    
26    Bool_t kUseKinematics = kFALSE; 
27    if(kSimulation) { 
28            kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE; 
29            if (!kUseKinematics && data=="AOD" && inputDataType != "ESD") kUseKinematics = kTRUE; //AOD primary should be available ... 
30    } 
31         
32    cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;
33
34    // Configure analysis
35    //===========================================================================
36    
37    //Reader
38    AliCaloTrackReader * reader = 0x0;
39    if(data.Contains("AOD")) reader = new AliCaloTrackAODReader();
40    else if(data=="ESD") reader = new AliCaloTrackESDReader();
41    else if(data=="MC" && inputDataType == "ESD") reader = new AliCaloTrackMCReader();
42    reader->SetDebug(-1);//10 for lots of messages
43    reader->SwitchOnCTS();
44    //reader->SetDeltaAODFileName("");
45    //if(!kSimulation) reader->SetFiredTriggerClassName("CINT1B-ABCE-NOPF-ALL");
46   if(calorimeter == "EMCAL") {
47     reader->SwitchOnEMCALCells();  
48     reader->SwitchOnEMCAL();
49   }
50   if(calorimeter == "PHOS") { 
51     reader->SwitchOnPHOSCells();  
52     reader->SwitchOnPHOS();
53   }
54
55   // for case data="deltaAOD", no need to fill the EMCAL/PHOS cluster lists
56   if(data.Contains("delta")){
57         reader->SwitchOffEMCAL();
58         reader->SwitchOffPHOS();
59         reader->SwitchOffEMCALCells(); 
60         reader->SwitchOffPHOSCells(); 
61   }
62         
63   if(kUseKinematics){
64     if(inputDataType == "ESD"){
65       reader->SwitchOnStack();          
66       reader->SwitchOffAODMCParticles(); 
67     }
68     else if(inputDataType == "AOD"){
69       reader->SwitchOffStack();          
70       reader->SwitchOnAODMCParticles(); 
71     }
72   }
73   
74   //Min particle pT
75   reader->SetEMCALPtMin(0.1); 
76   reader->SetPHOSPtMin(0.);
77   reader->SetCTSPtMin(0.);
78   if(kPrintSettings) reader->Print("");
79   
80   // ##### Analysis algorithm settings ####
81   
82         
83   AliFiducialCut * fidCut1stYear = new AliFiducialCut();
84   fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
85   if(kSimulation){
86     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
87     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
88     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
89     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
90   } 
91   else{
92     fidCut1stYear->DoEMCALFiducialCut(kFALSE) ;
93     fidCut1stYear->DoPHOSFiducialCut(kFALSE) ;
94   }     
95   
96   
97         
98   // -----------------------------------
99   // --- Pi0 Invariant Mass Analysis ---
100   // -----------------------------------
101
102   AliAnaPhoton *anaphoton1 = new AliAnaPhoton();
103   anaphoton1->SetDebug(-1); //10 for lots of messages
104   if(calorimeter == "PHOS"){
105           anaphoton1->SetNCellCut(1);// At least 2 cells
106           anaphoton1->SetMinPt(0.2);
107           anaphoton1->SetMinDistanceToBadChannel(2, 4, 5);
108   }
109   else {//EMCAL
110           //anaphoton1->SetNCellCut(0);// At least 2 cells
111           anaphoton1->SetMinPt(0.1); // no effect minium EMCAL cut.
112           anaphoton1->SetTimeCut(550,750);// Time window of [550-750] ns 
113           anaphoton1->SetMinDistanceToBadChannel(6, 12, 18);
114   }
115
116   anaphoton1->SetCalorimeter(calorimeter);
117   if(kUseKinematics) anaphoton1->SwitchOnDataMC() ;//Access MC stack and fill more histograms
118   else  anaphoton1->SwitchOffDataMC() ;
119   anaphoton1->SwitchOffCaloPID();
120   anaphoton1->SwitchOffCaloPIDRecalculation(); //recommended for EMCAL
121   if(kSimulation){
122     anaphoton1->SwitchOnFiducialCut();
123     anaphoton1->SetFiducialCut(fidCut1stYear);
124   }
125   //anaphoton1->SwitchOnTrackMatchRejection();
126   if(!data.Contains("delta")) anaphoton1->SetOutputAODName(Form("PhotonsForIM%s",calorimeter.Data()));
127   else                        anaphoton1->SetInputAODName (Form("PhotonsForIM%s",calorimeter.Data()));
128   //Set Histograms bins and ranges
129   anaphoton1->SetHistoPtRangeAndNBins(0, 50, 500) ;
130   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
131   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
132   
133   if(kPrintSettings) anaphoton1->Print("");
134
135   AliAnaPi0 *anapi0 = new AliAnaPi0();
136   anapi0->SetDebug(-1);//10 for lots of messages
137   anapi0->SetInputAODName(Form("PhotonsForIM%s",calorimeter.Data()));
138   anapi0->SetCalorimeter(calorimeter);
139   if(kSimulation){
140                 anapi0->SwitchOnFiducialCut();
141                 anapi0->SetFiducialCut(fidCut1stYear);
142   }  
143   anapi0->SetNPID(1); //Available from tag AliRoot::v4-18-15-AN
144   //settings for pp collision
145   anapi0->SetNCentrBin(1);
146   anapi0->SetNZvertBin(1);
147   anapi0->SetNRPBin(1);
148   anapi0->SetNMaxEvMix(10);
149   anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
150   if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
151   else  anapi0->SetNumberOfModules(4); //EMCAL first year
152   anapi0->SetHistoPtRangeAndNBins(0, 50, 500) ;
153   //anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
154   //anapi0->SetHistoEtaRangeAndNBins(-0.8, 0.8, 200) ;
155   anapi0->SetHistoMassRangeAndNBins(0., 0.6, 300) ;
156   anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
157   if(kPrintSettings) anapi0->Print("");
158   
159   
160   // -------------------------------------------------
161   // --- Photon Isolation and Correlation Analysis ---
162   // -------------------------------------------------
163   
164   AliAnaPhoton *anaphoton2 = new AliAnaPhoton();
165   anaphoton2->SetDebug(-1); //10 for lots of messages
166   if(calorimeter == "PHOS"){
167                 anaphoton2->SetNCellCut(1);// At least 2 cells
168                 anaphoton2->SetMinPt(0.2);
169             anaphoton2->SetMinDistanceToBadChannel(2, 4, 5);
170   }
171   else {//EMCAL
172                 //anaphoton2->SetNCellCut(0);// At least 2 cells
173                 anaphoton2->SetMinPt(0.1); // no effect minium EMCAL cut.
174                 anaphoton2->SetTimeCut(550,750);// Time window of [550-750] ns
175             anaphoton2->SetMinDistanceToBadChannel(6, 12, 18);
176   }
177   anaphoton2->SetCalorimeter(calorimeter);
178   if(kUseKinematics) anaphoton2->SwitchOnDataMC() ;//Access MC stack and fill more histograms
179   else  anaphoton2->SwitchOffDataMC() ;
180   anaphoton2->SwitchOffCaloPID();
181   anaphoton2->SwitchOffFiducialCut();
182   if(kSimulation){
183                 anaphoton2->SwitchOnFiducialCut();
184                 anaphoton2->SetFiducialCut(fidCut1stYear);
185   }
186         
187   if(!data.Contains("delta")) {
188                 anaphoton2->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
189                 anaphoton2->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
190   }
191   else anaphoton2->SetInputAODName(Form("Photons%s",calorimeter.Data()));
192   anaphoton2->AddToHistogramsName("AnaPhotonCorr_");
193   //Set Histograms bins and ranges
194   anaphoton2->SetHistoPtRangeAndNBins(0, 50, 500) ;
195   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
196   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
197   if(kPrintSettings) anaphoton2->Print("");
198         
199   // ### Isolation analysis ### 
200   
201   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
202   anaisol->SetDebug(-1);
203   anaisol->SetMinPt(0);
204   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
205   anaisol->SetCalorimeter(calorimeter);
206   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
207   else  anaisol->SwitchOffDataMC() ;
208   //Select clusters with no pair, if both clusters with pi0 mass
209   anaisol->SwitchOffInvariantMass();
210   //anaisol->SetNeutralMesonSelection(nms);
211   //Do isolation cut
212   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
213   ic->SetConeSize(0.4);
214   ic->SetPtThreshold(0.2);
215   ic->SetICMethod(AliIsolationCut::kPtThresIC);
216   if(kPrintSettings) ic->Print("");
217         
218   //Do or not do isolation with previously produced AODs.
219   //No effect if use of SwitchOnSeveralIsolation()
220   anaisol->SwitchOffReIsolation();
221   //Multiple IC
222   anaisol->SwitchOffSeveralIsolation() ;
223   //Set Histograms bins and ranges
224   anaisol->SetHistoPtRangeAndNBins(0, 50, 500) ;
225   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
226   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
227   anaisol->AddToHistogramsName("AnaIsolPhoton_");
228   if(kPrintSettings) anaisol->Print("");
229   
230   // ### Correlation with Jet Finder AOD output
231   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
232   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
233   anacorrjet->SwitchOffFiducialCut();
234   anacorrjet->SetDebug(-1);
235   anacorrjet->SetConeSize(1);  
236   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
237   anacorrjet->SetPtThresholdInCone(0.2);
238   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
239   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
240   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
241   //Set Histograms bins and ranges
242   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 500) ;
243   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
244   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
245   if(kPrintSettings) anacorrjet->Print("");
246   
247   // ### Correlation with hadrons
248   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
249   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
250   if(!data.Contains("delta")) {
251           anacorrhadron->SetOutputAODName(Form("CorrGammaHadrons%s",calorimeter.Data()));
252           anacorrhadron->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
253   }
254   else anacorrhadron->SetInputAODName(Form("CorrGammaHadrons%s",calorimeter.Data()));
255         
256   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
257   anacorrhadron->SetDebug(-1);
258   anacorrhadron->SwitchOffCaloPID();
259   anacorrhadron->SwitchOffFiducialCut();
260   anacorrhadron->SetPtCutRange(0.1,100);
261   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
262   anacorrhadron->SwitchOnSeveralUECalculation();
263   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
264   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
265   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
266   else  anacorrhadron->SwitchOffDataMC() ;
267   //if(calorimeter=="PHOS"){
268   //Correlate with particles in EMCAL
269   //anacorrhadron->SwitchOnCaloPID();
270   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
271   //}
272   //Set Histograms bins and ranges
273   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 500) ;
274   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
275   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
276   if(kPrintSettings) anacorrhadron->Print("");
277   
278   // ### Correlation with hadrons
279   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
280   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
281   if(!data.Contains("delta")) {
282           anacorrisohadron->SetOutputAODName(Form("CorrIsoGammaHadrons%s",calorimeter.Data()));
283           anacorrisohadron->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
284   }
285   else  anacorrisohadron->SetInputAODName(Form("CorrIsoGammaHadrons%s",calorimeter.Data()));
286         
287   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
288   anacorrisohadron->SetDebug(-1);
289   anacorrisohadron->SwitchOffCaloPID();
290   anacorrisohadron->SwitchOffFiducialCut();
291   anacorrisohadron->SetPtCutRange(0.1,100);
292   anacorrisohadron->SetDeltaPhiCutRange(1.5,4.5);
293   anacorrisohadron->SwitchOnSeveralUECalculation();
294   anacorrisohadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
295   anacorrisohadron->SelectIsolated(kTRUE); // do correlation with isolated photons
296   if(kUseKinematics) anacorrisohadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
297   else  anacorrisohadron->SwitchOffDataMC() ;
298   //if(calorimeter=="PHOS"){
299   //Correlate with particles in EMCAL
300   //anacorrhadron->SwitchOnCaloPID();
301   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
302   //}
303   //Set Histograms bins and ranges
304   anacorrisohadron->SetHistoPtRangeAndNBins(0, 50, 500) ;
305   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
306   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
307   if(kPrintSettings) anacorrisohadron->Print("");
308   
309   // -------------------------------------------------
310   // --- Pi0    Isolation and Correlation Analysis ---
311   // -------------------------------------------------
312         
313   AliNeutralMesonSelection *nms = new AliNeutralMesonSelection();
314   nms->SetInvMassCutRange(0.05, 0.2)     ;
315   nms->KeepNeutralMesonSelectionHistos(kTRUE);
316   //Set Histrograms bins and ranges
317   nms->SetHistoERangeAndNBins(0, 50, 500) ;
318   //      nms->SetHistoPtRangeAndNBins(0, 50, 100) ;
319   //      nms->SetHistoAngleRangeAndNBins(0, 0.3, 100) ;
320   //      nsm->SetHistoIMRangeAndNBins(0, 0.4, 100) ;  
321   
322   AliAnaPi0EbE *anapi0ebe = new AliAnaPi0EbE();
323   anapi0ebe->SetDebug(-1);//10 for lots of messages
324   anapi0ebe->SetAnalysisType(AliAnaPi0EbE::kIMCalo);
325   anapi0ebe->SetMinPt(0);
326   anapi0ebe->SetCalorimeter(calorimeter);
327   anapi0ebe->SetInputAODName(Form("Photons%s",calorimeter.Data()));
328   if(!data.Contains("delta")) {
329           anapi0ebe->SetOutputAODName(Form("Pi0s%s",calorimeter.Data()));
330           anapi0ebe->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
331   }
332   else  anapi0ebe->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
333         
334   if(kUseKinematics) anapi0ebe->SwitchOnDataMC() ;//Access MC stack and fill more histograms
335   else  anapi0ebe->SwitchOffDataMC() ;  
336   anapi0ebe->SetNeutralMesonSelection(nms);
337   //Set Histrograms bins and ranges
338   anapi0ebe->SetHistoPtRangeAndNBins(0, 50, 500) ;
339   //      anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
340   //      anapi0->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
341   if(kPrintSettings) anapi0ebe->Print("");
342   
343   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
344   anaisolpi0->SetDebug(-1);
345   anaisolpi0->SetMinPt(0);
346   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
347   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
348   anaisolpi0->SetCalorimeter(calorimeter);
349   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
350   else  anaisolpi0->SwitchOffDataMC() ;
351   //Select clusters with no pair, if both clusters with pi0 mass
352   anaisolpi0->SwitchOffInvariantMass();
353   //anaisol->SetNeutralMesonSelection(nms);
354   //Do isolation cut
355   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
356   ic2->SetConeSize(0.4);
357   ic2->SetPtThreshold(0.2);
358   ic2->SetICMethod(AliIsolationCut::kPtThresIC);
359   if(kPrintSettings) ic->Print("");
360   //Do or not do isolation with previously produced AODs.
361   //No effect if use of SwitchOnSeveralIsolation()
362   anaisolpi0->SwitchOffReIsolation();
363   //Multiple IC
364   anaisolpi0->SwitchOffSeveralIsolation() ;
365   //Set Histograms bins and ranges
366   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 500) ;
367   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
368   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
369   if(kPrintSettings) anaisol->Print("");
370   
371   
372   // ### Pi0 Correlation with hadrons, not isolated
373   AliAnaParticleHadronCorrelation *anacorrhadronpi0 = new AliAnaParticleHadronCorrelation();
374   anacorrhadronpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
375   if(!data.Contains("delta")){ 
376           anacorrhadronpi0->SetOutputAODName(Form("CorrPi0Hadrons%s",calorimeter.Data()));
377           anacorrhadronpi0->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
378   }
379   else anacorrhadronpi0->SetInputAODName(Form("CorrPi0Hadrons%s",calorimeter.Data()));
380         
381   anacorrhadronpi0->AddToHistogramsName("AnaHadronCorrPi0_");
382   anacorrhadronpi0->SetDebug(-1);
383   anacorrhadronpi0->SwitchOffCaloPID();
384   anacorrhadronpi0->SwitchOffFiducialCut();
385   anacorrhadronpi0->SetPtCutRange(0.1,100);
386   anacorrhadronpi0->SetDeltaPhiCutRange(1.5,4.5);
387   anacorrhadronpi0->SelectIsolated(kFALSE); // do correlation with non isolated pi0
388   anacorrhadronpi0->SwitchOnSeveralUECalculation();
389   anacorrhadronpi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
390   if(kUseKinematics) anacorrhadronpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
391   else  anacorrhadronpi0->SwitchOffDataMC() ;
392   //if(calorimeter=="PHOS"){
393   //    //Correlate with particles in EMCAL
394   //    anacorrhadronpi0->SwitchOnCaloPID();
395   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
396   //}
397   //Set Histograms bins and ranges
398   anacorrhadronpi0->SetHistoPtRangeAndNBins(0, 50, 500) ;
399   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
400   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
401   if(kPrintSettings) anacorrhadronpi0->Print("");
402   
403   // ### Pi0 Correlation with hadrons, isolated
404   AliAnaParticleHadronCorrelation *anacorrhadronisopi0 = new AliAnaParticleHadronCorrelation();
405   anacorrhadronisopi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
406   if(!data.Contains("delta")) {
407                 anacorrhadronisopi0->SetOutputAODName(Form("CorrIsoPi0Hadrons%s",calorimeter.Data()));
408                 anacorrhadronisopi0->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
409   }
410   else  anacorrhadronisopi0->SetInputAODName(Form("CorrIsoPi0Hadrons%s",calorimeter.Data()));
411         
412   anacorrhadronisopi0->AddToHistogramsName("AnaHadronCorrIsoPi0_");
413   anacorrhadronisopi0->SetDebug(-1);
414   anacorrhadronisopi0->SwitchOffCaloPID();
415   anacorrhadronisopi0->SwitchOffFiducialCut();
416   anacorrhadronisopi0->SetPtCutRange(0.1,100);
417   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
418   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
419   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
420   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
421   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
422   else  anacorrhadronisopi0->SwitchOffDataMC() ;
423   //if(calorimeter=="PHOS"){
424   //    //Correlate with particles in EMCAL
425   //    anacorrhadronpi0->SwitchOnCaloPID();
426   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
427   //}
428   //Set Histograms bins and ranges
429   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 500) ;
430   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
431   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
432   if(kPrintSettings) anacorrhadronisopi0->Print("");
433  
434   //analysis the omega->pi0+gamma
435   AliAnaOmegaToPi0Gamma *anaomegaToPi0Gamma = new AliAnaOmegaToPi0Gamma();
436   anaomegaToPi0Gamma->SetDebug(-1);//10 for lots of messages
437   anaomegaToPi0Gamma->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
438   anaomegaToPi0Gamma->SetInputAODPhotonName(Form("Photons%s",calorimeter.Data()));
439   anaomegaToPi0Gamma->SetNPID(1);
440   anaomegaToPi0Gamma->SetNVtxZ(1);
441   anaomegaToPi0Gamma->SetNEventsMixed(4);
442   if(calorimeter=="PHOS")
443     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.008); // PHOS
444   else if(calorimeter=="EMCAL")
445     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.012); // EMCAL 
446   anaomegaToPi0Gamma->SetHistoPtRangeAndNBins(0, 20, 200) ;
447   anaomegaToPi0Gamma->SetHistoMassRangeAndNBins(0, 1, 200) ;
448   anaomegaToPi0Gamma->SetPi0OverOmegaPtCut(0.8);
449   anaomegaToPi0Gamma->SetGammaOverOmegaPtCut(0.2);
450   if(kUseKinematics) anaomegaToPi0Gamma->SwitchOnDataMC() ;//Access MC stack and fill more histograms
451   else anaomegaToPi0Gamma->SwitchOffDataMC() ;//Access MC stack and fill more histograms
452   anaomegaToPi0Gamma->AddToHistogramsName(Form("AnaOmegaToPi0Gamma%s_",calorimeter.Data()));
453  if(kPrintSettings)   anaomegaToPi0Gamma->Print("");
454  
455   // #### Configure Maker ####
456   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
457   maker->SetReader(reader);//pointer to reader
458   //if(!data.Contains("delta")) maker->AddAnalysis(qa,0);
459   maker->AddAnalysis(anaphoton1,0);
460   maker->AddAnalysis(anapi0,1);
461   maker->AddAnalysis(anaphoton2,2);
462   maker->AddAnalysis(anaisol,3);
463   maker->AddAnalysis(anacorrjet,4);
464   maker->AddAnalysis(anacorrhadron,5);
465   maker->AddAnalysis(anacorrisohadron,6);
466   maker->AddAnalysis(anapi0ebe,7);
467   maker->AddAnalysis(anaisolpi0,8);
468   maker->AddAnalysis(anacorrhadronpi0,9);
469   maker->AddAnalysis(anacorrhadronisopi0,10);
470   maker->AddAnalysis(anaomegaToPi0Gamma,11);   
471   maker->SetAnaDebug(-1)  ;
472   maker->SwitchOnHistogramsMaker()  ;
473   if(data.Contains("delta")) maker->SwitchOffAODsMaker()  ;
474   else                       maker->SwitchOnAODsMaker()  ;
475         
476   if(kPrintSettings) maker->Print("");
477   
478   printf("======================== \n");
479   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
480   printf("======================== \n");
481   
482   // Create task
483   //===========================================================================
484   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
485   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
486   //task->SetDebugLevel(-1);
487   task->SelectCollisionCandidates();
488   task->SetAnalysisMaker(maker);
489   //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
490   mgr->AddTask(task);
491   
492   char name[128];
493   sprintf(name,"PartCorr_%s",calorimeter.Data());
494   cout<<"Name of task "<<name<<endl;
495   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
496   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
497   
498   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
499   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
500   AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(calorimeter.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr",outputfile.Data()));
501   
502   // Create ONLY the output containers for the data produced by the task.
503   // Get and connect other common input/output containers via the manager as below
504   //==============================================================================
505   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
506   // AOD output slot will be used in a different way in future
507   if(!data.Contains("delta")) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
508   mgr->ConnectOutput (task, 1, cout_pc);
509   
510   return task;
511 }
512
513