]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorrM.C
dcbaf8f2b1502be529053794264e7b44310e0189
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorrM.C
1 AliAnalysisTaskParticleCorrelationM *AddTaskPartCorrM(TString data, TString calorimeter, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE,Bool_t outputAOD=kFALSE, Bool_t oldAOD=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 = ;
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(outputAOD)  reader->SwitchOnWriteDeltaAOD()  ;
79   if(oldAOD) reader->SwitchOnOldAODs();
80   if(kPrintSettings) reader->Print("");
81   
82   // *** Calorimeters Utils     ***
83   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
84   // Remove clusters close to borders, at least max energy cell is 1 cell away 
85   cu->SetNumberOfCellsFromEMCALBorder(1);
86   cu->SetNumberOfCellsFromPHOSBorder(2);
87   cu->SwitchOnNoFiducialBorderInEMCALEta0();
88   
89   // Remove EMCAL hottest channels for first LHC10 periods      
90   cu->SwitchOnBadChannelsRemoval();
91   // SM0
92   cu->SetEMCALChannelStatus(0,3,13);  cu->SetEMCALChannelStatus(0,44,1); cu->SetEMCALChannelStatus(0,3,13); 
93   cu->SetEMCALChannelStatus(0,20,7);  cu->SetEMCALChannelStatus(0,38,2);   
94   // SM1
95   cu->SetEMCALChannelStatus(1,4,7);   cu->SetEMCALChannelStatus(1,4,13);  cu->SetEMCALChannelStatus(1,9,20); 
96   cu->SetEMCALChannelStatus(1,14,15); cu->SetEMCALChannelStatus(1,23,16); cu->SetEMCALChannelStatus(1,32,23); 
97   cu->SetEMCALChannelStatus(1,37,5);  cu->SetEMCALChannelStatus(1,40,1);  cu->SetEMCALChannelStatus(1,40,2);
98   cu->SetEMCALChannelStatus(1,40,5);  cu->SetEMCALChannelStatus(1,41,0);  cu->SetEMCALChannelStatus(1,41,1);
99   cu->SetEMCALChannelStatus(1,41,2);  cu->SetEMCALChannelStatus(1,41,4);
100   // SM2        
101   cu->SetEMCALChannelStatus(2,14,15); cu->SetEMCALChannelStatus(2,18,16); cu->SetEMCALChannelStatus(2,18,17); 
102   cu->SetEMCALChannelStatus(2,18,18); cu->SetEMCALChannelStatus(2,18,20); cu->SetEMCALChannelStatus(2,18,21); 
103   cu->SetEMCALChannelStatus(2,18,23); cu->SetEMCALChannelStatus(2,19,16); cu->SetEMCALChannelStatus(2,19,17); 
104   cu->SetEMCALChannelStatus(2,19,19); cu->SetEMCALChannelStatus(2,19,20); cu->SetEMCALChannelStatus(2,19,21); 
105   cu->SetEMCALChannelStatus(2,19,22);
106   //SM3
107   cu->SetEMCALChannelStatus(3,4,7);
108   
109   
110   //Recalibration
111   //cu->SwitchOnRecalibration();
112   //TFile * f = new TFile("RecalibrationFactors.root","read");
113   //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
114   //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
115   //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
116   //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));
117   //f->Close(); 
118   
119   cu->SetDebug(-1);
120   if(kPrintSettings) cu->Print("");
121   
122   
123   // ##### Analysis algorithm settings ####
124   
125   // -------------------------------------------------
126   // --- Photon/Pi0/Omega/Electron Analysis ---
127   // -------------------------------------------------
128   
129   AliAnaPhoton *anaphoton = new AliAnaPhoton();
130   anaphoton->SetDebug(-1); //10 for lots of messages
131   if(calorimeter == "PHOS"){
132     anaphoton->SetNCellCut(1);// At least 2 cells
133     anaphoton->SetMinPt(0.2);
134     anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
135   }
136   else {//EMCAL
137     //anaphoton->SetNCellCut(0);// At least 2 cells
138     anaphoton->SetMinPt(0.1); // no effect minium EMCAL cut.
139     if(kUseKinematics) anaphoton->SetTimeCut(525,725);// Time window of [550-750] ns
140     anaphoton->SetMinDistanceToBadChannel(6, 12, 18);
141   }
142   anaphoton->SetCalorimeter(calorimeter);
143   if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
144   else  anaphoton->SwitchOffDataMC() ;
145   anaphoton->SwitchOffCaloPID();
146   anaphoton->SwitchOffFiducialCut();
147   if(kSimulation){
148     anaphoton->SwitchOnFiducialCut();
149         AliFiducialCut * fidCut1stYear = anaphoton->GetFidutialCut();
150         fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
151         fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
152         fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
153         fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
154         fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
155   }
156   
157   if(!data.Contains("delta")) {
158     anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
159     anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
160   }
161   else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
162   anaphoton->AddToHistogramsName("AnaPhotonCorr_");
163   //Set Histograms bins and ranges
164   anaphoton->SetHistoPtRangeAndNBins(0, 50, 200) ;
165   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
166   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
167   if(kPrintSettings) anaphoton->Print("");
168  
169   // -----------------------------------
170   // --- Pi0 Invariant Mass Analysis ---
171   // -----------------------------------
172   
173   AliAnaPi0 *anapi0 = new AliAnaPi0();
174   anapi0->SetDebug(-1);//10 for lots of messages
175   anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
176   anapi0->SetCalorimeter(calorimeter);
177   if(kSimulation){
178     anapi0->SwitchOnFiducialCut();
179     AliFiducialCut * fidCut1stYear = anapi0->GetFiducialCut();
180     fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
181     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
182     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
183     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
184     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
185   }  
186         
187   anapi0->SetNPID(1); //Available from tag AliRoot::v4-18-15-AN
188   //settings for pp collision
189   anapi0->SetNCentrBin(1);
190   anapi0->SetNZvertBin(1);
191   anapi0->SetNRPBin(1);
192   anapi0->SetNMaxEvMix(10);
193   anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
194   if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
195   else  anapi0->SetNumberOfModules(4); //EMCAL first year
196   anapi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
197   //anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
198   //anapi0->SetHistoEtaRangeAndNBins(-0.8, 0.8, 200) ;
199   anapi0->SetHistoMassRangeAndNBins(0., 0.6, 200) ;
200   anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
201   if(kPrintSettings) anapi0->Print("");
202         
203   //---------------------------  
204   //Pi0, event by event
205   //---------------------------  
206
207                 
208   AliAnaPi0EbE *anapi0ebe = new AliAnaPi0EbE();
209   anapi0ebe->SetDebug(-1);//10 for lots of messages
210   anapi0ebe->SetAnalysisType(AliAnaPi0EbE::kIMCalo);
211   anapi0ebe->SetMinPt(0);
212   anapi0ebe->SetCalorimeter(calorimeter);
213   anapi0ebe->SetInputAODName(Form("Photons%s",calorimeter.Data()));
214   if(!data.Contains("delta")) {
215     anapi0ebe->SetOutputAODName(Form("Pi0s%s",calorimeter.Data()));
216     anapi0ebe->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
217   }
218   else  anapi0ebe->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
219   
220   if(kUseKinematics) anapi0ebe->SwitchOnDataMC() ;//Access MC stack and fill more histograms
221   else  anapi0ebe->SwitchOffDataMC() ;  
222   
223   AliNeutralMesonSelection *nms = anapi0ebe->GetNeutralMesonSelection();
224   nms->SetInvMassCutRange(0.05, 0.2)     ;
225   nms->KeepNeutralMesonSelectionHistos(kTRUE);
226   //Set Histrograms bins and ranges
227   nms->SetHistoERangeAndNBins(0, 50, 200) ;
228   //      nms->SetHistoPtRangeAndNBins(0, 50, 100) ;
229   //      nms->SetHistoAngleRangeAndNBins(0, 0.3, 100) ;
230   //      nsm->SetHistoIMRangeAndNBins(0, 0.4, 100) ;  
231   //Set Histrograms bins and ranges
232   anapi0ebe->SetHistoPtRangeAndNBins(0, 50, 200) ;
233   //      anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
234   //      anapi0->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
235   if(kPrintSettings) anapi0ebe->Print("");
236         
237   //-------------------------------------
238   //*** analysis the omega->pi0+gamma ***
239   //------------------------------------
240   AliAnaOmegaToPi0Gamma *anaomegaToPi0Gamma = new AliAnaOmegaToPi0Gamma();
241   anaomegaToPi0Gamma->SetDebug(-1);//10 for lots of messages
242   anaomegaToPi0Gamma->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
243   anaomegaToPi0Gamma->SetInputAODPhotonName(Form("Photons%s",calorimeter.Data()));
244   anaomegaToPi0Gamma->SetNPID(1);
245   anaomegaToPi0Gamma->SetNVtxZ(1);
246   anaomegaToPi0Gamma->SetNEventsMixed(4);
247   if(calorimeter=="PHOS")
248         anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.008); // PHOS
249   else if(calorimeter=="EMCAL")
250         anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.012); // EMCAL 
251   anaomegaToPi0Gamma->SetHistoPtRangeAndNBins(0, 20, 100) ;
252   anaomegaToPi0Gamma->SetHistoMassRangeAndNBins(0, 1, 100) ;
253   anaomegaToPi0Gamma->SetPi0OverOmegaPtCut(0.8);
254   anaomegaToPi0Gamma->SetGammaOverOmegaPtCut(0.2);
255   if(kUseKinematics) anaomegaToPi0Gamma->SwitchOnDataMC() ;//Access MC stack and fill more histograms
256   else anaomegaToPi0Gamma->SwitchOffDataMC() ;//Access MC stack and fill more histograms
257   anaomegaToPi0Gamma->AddToHistogramsName(Form("AnaOmegaToPi0Gamma%s_",calorimeter.Data()));
258   if(kPrintSettings)   anaomegaToPi0Gamma->Print("");
259         
260   //==================================
261   // ### Isolation analysis ### 
262   //=================================
263   //Photon
264   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
265   anaisol->SetDebug(-1);
266   anaisol->SetMinPt(0);
267   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
268   anaisol->SetAODObjArrayName("ICPhoton"); 
269   anaisol->SetCalorimeter(calorimeter);
270   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
271   else  anaisol->SwitchOffDataMC() ;
272   //Select clusters with no pair, if both clusters with pi0 mass
273   anaisol->SwitchOffInvariantMass();
274   //Do isolation cut
275   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
276   ic->SetConeSize(0.4);
277   ic->SetPtThreshold(0.2);
278   ic->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
279   ic->SetICMethod(AliIsolationCut::kPtThresIC);
280   if(kPrintSettings) ic->Print("");
281   
282   //Do or not do isolation with previously produced AODs.
283   //No effect if use of SwitchOnSeveralIsolation()
284   anaisol->SwitchOffReIsolation();
285   //Multiple IC
286   anaisol->SwitchOffSeveralIsolation() ;
287   //Set Histograms bins and ranges
288   anaisol->SetHistoPtRangeAndNBins(0, 50, 200) ;
289   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
290   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
291   anaisol->AddToHistogramsName("AnaIsolPhoton_");
292   if(kPrintSettings) anaisol->Print("");
293   
294   //Pi0
295   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
296   anaisolpi0->SetDebug(-1);
297   anaisolpi0->SetMinPt(0);
298   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
299   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
300   anaisolpi0->SetAODObjArrayName("ICPi0"); 
301   anaisolpi0->SetCalorimeter(calorimeter);
302   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
303   else  anaisolpi0->SwitchOffDataMC() ;
304   //Select clusters with no pair, if both clusters with pi0 mass
305   anaisolpi0->SwitchOffInvariantMass();
306   //Do isolation cut
307   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
308   ic2->SetConeSize(0.4);
309   ic2->SetPtThreshold(0.2);
310   ic2->SetICMethod(AliIsolationCut::kPtThresIC);
311   if(kPrintSettings) ic2->Print("");
312   //Do or not do isolation with previously produced AODs.
313   //No effect if use of SwitchOnSeveralIsolation()
314   anaisolpi0->SwitchOffReIsolation();
315   //Multiple IC
316   anaisolpi0->SwitchOffSeveralIsolation() ;
317   //Set Histograms bins and ranges
318   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
319   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
320   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
321   if(kPrintSettings) anaisolpi0->Print("");
322         
323   //===========================
324   //Correlation analysis
325   //===========================
326         
327   // ### Correlation with Jet Finder AOD output
328   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
329   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
330   anacorrjet->SwitchOffFiducialCut();
331   anacorrjet->SetDebug(-1);
332   anacorrjet->SetConeSize(1);  
333   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
334   anacorrjet->SetPtThresholdInCone(0.2);
335   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
336   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
337   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
338   //Set Histograms bins and ranges
339   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 200) ;
340   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
341   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
342   if(kPrintSettings) anacorrjet->Print("");
343   
344   // ### Correlation with hadrons
345   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
346   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
347   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
348   anacorrhadron->SetAODObjArrayName("PhotonHadronCorr"); 
349   anacorrhadron->SetDebug(-1);
350   anacorrhadron->SwitchOffCaloPID();
351   anacorrhadron->SwitchOffFiducialCut();
352   anacorrhadron->SetPtCutRange(0.1,100);
353   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
354   anacorrhadron->SwitchOnSeveralUECalculation();
355   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
356   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
357   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
358   else  anacorrhadron->SwitchOffDataMC() ;
359   //if(calorimeter=="PHOS"){
360   //Correlate with particles in EMCAL
361   //anacorrhadron->SwitchOnCaloPID();
362   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
363   //}
364   //Set Histograms bins and ranges
365   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
366   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
367   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
368   if(kPrintSettings) anacorrhadron->Print("");
369   
370   // ### Correlation with hadrons
371   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
372   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
373   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
374   anacorrisohadron->SetAODObjArrayName("IsoPhotonHadronCorr"); 
375   anacorrisohadron->SetDebug(-1);
376   anacorrisohadron->SwitchOffCaloPID();
377   anacorrisohadron->SwitchOffFiducialCut();
378   anacorrisohadron->SetPtCutRange(0.1,100);
379   anacorrisohadron->SetDeltaPhiCutRange(1.5,4.5);
380   anacorrisohadron->SwitchOnSeveralUECalculation();
381   anacorrisohadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
382   anacorrisohadron->SelectIsolated(kTRUE); // do correlation with isolated photons
383   if(kUseKinematics) anacorrisohadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
384   else  anacorrisohadron->SwitchOffDataMC() ;
385   //if(calorimeter=="PHOS"){
386   //Correlate with particles in EMCAL
387   //anacorrhadron->SwitchOnCaloPID();
388   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
389   //}
390   //Set Histograms bins and ranges
391   anacorrisohadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
392   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
393   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
394   if(kPrintSettings) anacorrisohadron->Print("");
395   
396   
397   // ### Pi0 Correlation with hadrons, not isolated
398   AliAnaParticleHadronCorrelation *anacorrhadronpi0 = new AliAnaParticleHadronCorrelation();
399   anacorrhadronpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
400   anacorrhadronpi0->AddToHistogramsName("AnaHadronCorrPi0_");
401   anacorrhadronpi0->SetAODObjArrayName("Pi0HadronCorr"); 
402   anacorrhadronpi0->SetDebug(-1);
403   anacorrhadronpi0->SwitchOffCaloPID();
404   anacorrhadronpi0->SwitchOffFiducialCut();
405   anacorrhadronpi0->SetPtCutRange(0.1,100);
406   anacorrhadronpi0->SetDeltaPhiCutRange(1.5,4.5);
407   anacorrhadronpi0->SelectIsolated(kFALSE); // do correlation with non isolated pi0
408   anacorrhadronpi0->SwitchOnSeveralUECalculation();
409   anacorrhadronpi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
410   if(kUseKinematics) anacorrhadronpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
411   else  anacorrhadronpi0->SwitchOffDataMC() ;
412   //if(calorimeter=="PHOS"){
413   //    //Correlate with particles in EMCAL
414   //    anacorrhadronpi0->SwitchOnCaloPID();
415   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
416   //}
417   //Set Histograms bins and ranges
418   anacorrhadronpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
419   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
420   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
421   if(kPrintSettings) anacorrhadronpi0->Print("");
422   
423   // ### Pi0 Correlation with hadrons, isolated
424   AliAnaParticleHadronCorrelation *anacorrhadronisopi0 = new AliAnaParticleHadronCorrelation();
425   anacorrhadronisopi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
426   anacorrhadronisopi0->AddToHistogramsName("AnaHadronCorrIsoPi0_");
427   anacorrhadronisopi0->SetAODObjArrayName("IsoPi0HadronCorr"); 
428   anacorrhadronisopi0->SetDebug(-1);
429   anacorrhadronisopi0->SwitchOffCaloPID();
430   anacorrhadronisopi0->SwitchOffFiducialCut();
431   anacorrhadronisopi0->SetPtCutRange(0.1,100);
432   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
433   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
434   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
435   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
436   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
437   else  anacorrhadronisopi0->SwitchOffDataMC() ;
438   //if(calorimeter=="PHOS"){
439   //    //Correlate with particles in EMCAL
440   //    anacorrhadronpi0->SwitchOnCaloPID();
441   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
442   //}
443   //Set Histograms bins and ranges
444   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
445   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
446   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
447   if(kPrintSettings) anacorrhadronisopi0->Print("");
448   
449   
450   // #### Configure Maker ####
451   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
452   maker->SetReader(reader);//pointer to reader
453   maker->SetCaloUtils(cu); //pointer to calorimeter utils
454   Int_t n = 0;//Analysis number, order is important
455
456   // Particle selection analysis
457   maker->AddAnalysis(anaphoton,n++);
458   maker->AddAnalysis(anapi0,n++);
459   maker->AddAnalysis(anapi0ebe,n++);
460   maker->AddAnalysis(anaomegaToPi0Gamma,n++);  
461   // Isolation analysis
462   maker->AddAnalysis(anaisol,n++);
463   maker->AddAnalysis(anaisolpi0,n++);
464   // Correlation analysis
465   maker->AddAnalysis(anacorrjet,n++);
466   maker->AddAnalysis(anacorrhadron,n++);
467   maker->AddAnalysis(anacorrhadronpi0,n++);
468   maker->AddAnalysis(anacorrisohadron,n++);
469   maker->AddAnalysis(anacorrhadronisopi0,n);
470
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   AliAnalysisTaskParticleCorrelationM * task = new AliAnalysisTaskParticleCorrelationM (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   //Create containers
493   char name[128];
494   sprintf(name,"PartCorr_%s",calorimeter.Data());
495   cout<<"Name of task "<<name<<endl;
496   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
497   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
498   
499   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
500   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
501   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
502                                                                                                                          AliAnalysisManager::kOutputContainer, 
503                                                                                                                          Form("%s:PartCorr",outputfile.Data()));
504         
505   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
506                                                                                                                          AliAnalysisManager::kParamContainer, 
507                                                                                                                          Form("%s:PartCorrCuts",outputfile.Data()));
508         
509   // Create ONLY the output containers for the data produced by the task.
510   // Get and connect other common input/output containers via the manager as below
511   //==============================================================================
512   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
513   // AOD output slot will be used in a different way in future
514   if(!data.Contains("delta") && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
515   mgr->ConnectOutput (task, 1, cout_pc);
516   mgr->ConnectOutput (task, 2, cout_cuts);
517
518   return task;
519 }
520
521