]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
Correct MCReader: do not fill created AODCaloClusters to AODEvent
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(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(400,900);// Time window of [400-900] 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->GetFiducialCut();
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->SwitchOnOwnMix();
190   anapi0->SetNCentrBin(1);
191   anapi0->SetNZvertBin(1);
192   anapi0->SetNRPBin(1);
193   anapi0->SetNMaxEvMix(10);
194   if(kUseKinematics)anapi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
195   else anapi0->SwitchOffDataMC() ;
196   if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
197   else  anapi0->SetNumberOfModules(4); //EMCAL first year
198   anapi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
199   //anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
200   //anapi0->SetHistoEtaRangeAndNBins(-0.8, 0.8, 200) ;
201   anapi0->SetHistoMassRangeAndNBins(0., 0.6, 200) ;
202   anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
203   if(kPrintSettings) anapi0->Print("");
204         
205   //---------------------------  
206   //Pi0, event by event
207   //---------------------------  
208   
209   
210   AliAnaPi0EbE *anapi0ebe = new AliAnaPi0EbE();
211   anapi0ebe->SetDebug(-1);//10 for lots of messages
212   anapi0ebe->SetAnalysisType(AliAnaPi0EbE::kIMCalo);
213   anapi0ebe->SetMinPt(0);
214   anapi0ebe->SetCalorimeter(calorimeter);
215   anapi0ebe->SetInputAODName(Form("Photons%s",calorimeter.Data()));
216   if(!data.Contains("delta")) {
217     anapi0ebe->SetOutputAODName(Form("Pi0s%s",calorimeter.Data()));
218     anapi0ebe->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
219   }
220   else  anapi0ebe->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
221   
222   if(kUseKinematics) anapi0ebe->SwitchOnDataMC() ;//Access MC stack and fill more histograms
223   else  anapi0ebe->SwitchOffDataMC() ;  
224   
225   AliNeutralMesonSelection *nms = anapi0ebe->GetNeutralMesonSelection();
226   nms->SetInvMassCutRange(0.05, 0.2)     ;
227   nms->KeepNeutralMesonSelectionHistos(kTRUE);
228   //Set Histrograms bins and ranges
229   nms->SetHistoERangeAndNBins(0, 50, 200) ;
230   //      nms->SetHistoPtRangeAndNBins(0, 50, 100) ;
231   //      nms->SetHistoAngleRangeAndNBins(0, 0.3, 100) ;
232   //      nsm->SetHistoIMRangeAndNBins(0, 0.4, 100) ;  
233   //Set Histrograms bins and ranges
234   anapi0ebe->SetHistoPtRangeAndNBins(0, 50, 200) ;
235   //      anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
236   //      anapi0->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
237   if(kPrintSettings) anapi0ebe->Print("");
238         
239   //-------------------------------------
240   //*** analysis the omega->pi0+gamma ***
241   //------------------------------------
242   AliAnaOmegaToPi0Gamma *anaomegaToPi0Gamma = new AliAnaOmegaToPi0Gamma();
243   anaomegaToPi0Gamma->SetDebug(-1);//10 for lots of messages
244   anaomegaToPi0Gamma->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
245   anaomegaToPi0Gamma->SetInputAODPhotonName(Form("Photons%s",calorimeter.Data()));
246   anaomegaToPi0Gamma->SetNPID(1);
247   anaomegaToPi0Gamma->SetNVtxZ(1);
248   anaomegaToPi0Gamma->SetNEventsMixed(4);
249   if(calorimeter=="PHOS")
250     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.008); // PHOS
251   else if(calorimeter=="EMCAL")
252     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.012); // EMCAL 
253   anaomegaToPi0Gamma->SetHistoPtRangeAndNBins(0, 20, 100) ;
254   anaomegaToPi0Gamma->SetHistoMassRangeAndNBins(0, 1, 100) ;
255   anaomegaToPi0Gamma->SetPi0OverOmegaPtCut(0.8);
256   anaomegaToPi0Gamma->SetGammaOverOmegaPtCut(0.2);
257   if(kUseKinematics) anaomegaToPi0Gamma->SwitchOnDataMC() ;//Access MC stack and fill more histograms
258   else anaomegaToPi0Gamma->SwitchOffDataMC() ;//Access MC stack and fill more histograms
259   anaomegaToPi0Gamma->AddToHistogramsName(Form("AnaOmegaToPi0Gamma%s_",calorimeter.Data()));
260   if(kPrintSettings)   anaomegaToPi0Gamma->Print("");
261         
262         
263   //---------------------------------------------------------------------
264   // Electron/btag
265   //---------------------------------------------------------------------
266   if(calorimeter=="EMCAL"){
267     Double_t pOverEmin = 0.8;  //tight
268     Double_t pOverEmax = 1.2;  //tight
269     Double_t dRmax     = 0.02; //tight
270     
271     AliAnaBtag *anaelectron = new AliAnaBtag();
272     anaelectron->SetDebug(-1); //10 for lots of messages
273     anaelectron->SetCalorimeter("EMCAL");
274     if(kUseKinematics){
275       anaelectron->SwitchOffDataMC();
276       anaelectron->SetMinPt(1.);
277     }
278     anaelectron->SetOutputAODName("ElectronsEMCAL");
279     anaelectron->SetOutputAODClassName("AliAODPWG4Particle");
280     //Determine which cuts to use based on enum
281     anaelectron->SetpOverEmin(pOverEmin);
282     anaelectron->SetpOverEmax(pOverEmax);
283     anaelectron->SetResidualCut(dRmax);
284     //Set Histrograms bins and ranges 
285     anaelectron->SetHistoPtRangeAndNBins(0, 100, 100) ;
286     anaelectron->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
287     anaelectron->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
288     if(kPrintSettings)anaelectron->Print("");
289   }
290   //==================================
291   // ### Isolation analysis ### 
292   //=================================
293   //Photon
294   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
295   anaisol->SetDebug(-1);
296   anaisol->SetMinPt(0);
297   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
298   anaisol->SetAODObjArrayName("ICPhoton"); 
299   anaisol->SetCalorimeter(calorimeter);
300   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
301   else  anaisol->SwitchOffDataMC() ;
302   //Select clusters with no pair, if both clusters with pi0 mass
303   anaisol->SwitchOffInvariantMass();
304   //Do isolation cut
305   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
306   ic->SetConeSize(0.4);
307   ic->SetPtThreshold(0.2);
308   ic->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
309   ic->SetICMethod(AliIsolationCut::kPtThresIC);
310   if(kPrintSettings) ic->Print("");
311   
312   //Do or not do isolation with previously produced AODs.
313   //No effect if use of SwitchOnSeveralIsolation()
314   anaisol->SwitchOffReIsolation();
315   //Multiple IC
316   anaisol->SwitchOffSeveralIsolation() ;
317   //Set Histograms bins and ranges
318   anaisol->SetHistoPtRangeAndNBins(0, 50, 200) ;
319   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
320   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
321   anaisol->AddToHistogramsName("AnaIsolPhoton_");
322   if(kPrintSettings) anaisol->Print("");
323   
324   //Pi0
325   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
326   anaisolpi0->SetDebug(-1);
327   anaisolpi0->SetMinPt(0);
328   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
329   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
330   anaisolpi0->SetAODObjArrayName("ICPi0"); 
331   anaisolpi0->SetCalorimeter(calorimeter);
332   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
333   else  anaisolpi0->SwitchOffDataMC() ;
334   //Select clusters with no pair, if both clusters with pi0 mass
335   anaisolpi0->SwitchOffInvariantMass();
336   //Do isolation cut
337   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
338   ic2->SetConeSize(0.4);
339   ic2->SetPtThreshold(0.2);
340   ic2->SetICMethod(AliIsolationCut::kPtThresIC);
341   if(kPrintSettings) ic2->Print("");
342   //Do or not do isolation with previously produced AODs.
343   //No effect if use of SwitchOnSeveralIsolation()
344   anaisolpi0->SwitchOffReIsolation();
345   //Multiple IC
346   anaisolpi0->SwitchOffSeveralIsolation() ;
347   //Set Histograms bins and ranges
348   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
349   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
350   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
351   if(kPrintSettings) anaisolpi0->Print("");
352         
353   //===========================
354   //Correlation analysis
355   //===========================
356         
357   // ### Correlation with Jet Finder AOD output
358   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
359   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
360   anacorrjet->SwitchOffFiducialCut();
361   anacorrjet->SetDebug(-1);
362   anacorrjet->SetConeSize(1);  
363   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
364   anacorrjet->SetPtThresholdInCone(0.2);
365   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
366   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
367   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
368   //Set Histograms bins and ranges
369   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 200) ;
370   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
371   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
372   if(kPrintSettings) anacorrjet->Print("");
373   
374   // ### Correlation with hadrons
375   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
376   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
377   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
378   anacorrhadron->SetAODObjArrayName("PhotonHadronCorr"); 
379   anacorrhadron->SetDebug(-1);
380   anacorrhadron->SwitchOffCaloPID();
381   anacorrhadron->SwitchOffFiducialCut();
382   anacorrhadron->SetPtCutRange(0.1,100);
383   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
384   anacorrhadron->SwitchOnSeveralUECalculation();
385   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
386   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
387   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
388   else  anacorrhadron->SwitchOffDataMC() ;
389   //if(calorimeter=="PHOS"){
390   //Correlate with particles in EMCAL
391   //anacorrhadron->SwitchOnCaloPID();
392   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
393   //}
394   //Set Histograms bins and ranges
395   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
396   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
397   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
398   if(kPrintSettings) anacorrhadron->Print("");
399   
400   // ### Correlation with hadrons
401   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
402   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
403   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
404   anacorrisohadron->SetAODObjArrayName("IsoPhotonHadronCorr"); 
405   anacorrisohadron->SetDebug(-1);
406   anacorrisohadron->SwitchOffCaloPID();
407   anacorrisohadron->SwitchOffFiducialCut();
408   anacorrisohadron->SetPtCutRange(0.1,100);
409   anacorrisohadron->SetDeltaPhiCutRange(1.5,4.5);
410   anacorrisohadron->SwitchOnSeveralUECalculation();
411   anacorrisohadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
412   anacorrisohadron->SelectIsolated(kTRUE); // do correlation with isolated photons
413   if(kUseKinematics) anacorrisohadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
414   else  anacorrisohadron->SwitchOffDataMC() ;
415   //if(calorimeter=="PHOS"){
416   //Correlate with particles in EMCAL
417   //anacorrhadron->SwitchOnCaloPID();
418   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
419   //}
420   //Set Histograms bins and ranges
421   anacorrisohadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
422   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
423   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
424   if(kPrintSettings) anacorrisohadron->Print("");
425   
426   
427   // ### Pi0 Correlation with hadrons, not isolated
428   AliAnaParticleHadronCorrelation *anacorrhadronpi0 = new AliAnaParticleHadronCorrelation();
429   anacorrhadronpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
430   anacorrhadronpi0->AddToHistogramsName("AnaHadronCorrPi0_");
431   anacorrhadronpi0->SetAODObjArrayName("Pi0HadronCorr"); 
432   anacorrhadronpi0->SetDebug(-1);
433   anacorrhadronpi0->SwitchOffCaloPID();
434   anacorrhadronpi0->SwitchOffFiducialCut();
435   anacorrhadronpi0->SetPtCutRange(0.1,100);
436   anacorrhadronpi0->SetDeltaPhiCutRange(1.5,4.5);
437   anacorrhadronpi0->SelectIsolated(kFALSE); // do correlation with non isolated pi0
438   anacorrhadronpi0->SwitchOnSeveralUECalculation();
439   anacorrhadronpi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
440   if(kUseKinematics) anacorrhadronpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
441   else  anacorrhadronpi0->SwitchOffDataMC() ;
442   //if(calorimeter=="PHOS"){
443   //    //Correlate with particles in EMCAL
444   //    anacorrhadronpi0->SwitchOnCaloPID();
445   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
446   //}
447   //Set Histograms bins and ranges
448   anacorrhadronpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
449   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
450   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
451   if(kPrintSettings) anacorrhadronpi0->Print("");
452   
453   // ### Pi0 Correlation with hadrons, isolated
454   AliAnaParticleHadronCorrelation *anacorrhadronisopi0 = new AliAnaParticleHadronCorrelation();
455   anacorrhadronisopi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
456   anacorrhadronisopi0->AddToHistogramsName("AnaHadronCorrIsoPi0_");
457   anacorrhadronisopi0->SetAODObjArrayName("IsoPi0HadronCorr"); 
458   anacorrhadronisopi0->SetDebug(-1);
459   anacorrhadronisopi0->SwitchOffCaloPID();
460   anacorrhadronisopi0->SwitchOffFiducialCut();
461   anacorrhadronisopi0->SetPtCutRange(0.1,100);
462   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
463   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
464   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
465   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
466   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
467   else  anacorrhadronisopi0->SwitchOffDataMC() ;
468   //if(calorimeter=="PHOS"){
469   //    //Correlate with particles in EMCAL
470   //    anacorrhadronpi0->SwitchOnCaloPID();
471   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
472   //}
473   //Set Histograms bins and ranges
474   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
475   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
476   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
477   if(kPrintSettings) anacorrhadronisopi0->Print("");
478   
479   
480   // #### Configure Maker ####
481   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
482   maker->SetReader(reader);//pointer to reader
483   maker->SetCaloUtils(cu); //pointer to calorimeter utils
484   Int_t n = 0;//Analysis number, order is important
485   // Particle selection analysis
486   maker->AddAnalysis(anaphoton,n++);
487   maker->AddAnalysis(anapi0,n++);
488   maker->AddAnalysis(anapi0ebe,n++);
489   maker->AddAnalysis(anaomegaToPi0Gamma,n++);  
490   if(calorimeter=="EMCAL")maker->AddAnalysis(anaelectron,n++);   
491   // Isolation analysis
492   maker->AddAnalysis(anaisol,n++);
493   maker->AddAnalysis(anaisolpi0,n++);
494   // Correlation analysis
495   maker->AddAnalysis(anacorrjet,n++);
496   maker->AddAnalysis(anacorrhadron,n++);
497   maker->AddAnalysis(anacorrhadronpi0,n++);
498   maker->AddAnalysis(anacorrisohadron,n++);
499   maker->AddAnalysis(anacorrhadronisopi0,n);
500   maker->SetAnaDebug(-1)  ;
501   maker->SwitchOnHistogramsMaker()  ;
502   if(data.Contains("delta")) maker->SwitchOffAODsMaker()  ;
503   else                       maker->SwitchOnAODsMaker()  ;
504         
505   if(kPrintSettings) maker->Print("");
506   
507   printf("======================== \n");
508   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
509   printf("======================== \n");
510   
511   // Create task
512   //===========================================================================
513   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
514   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
515   //task->SetDebugLevel(-1);
516   task->SelectCollisionCandidates();
517   task->SetAnalysisMaker(maker);
518   //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
519   mgr->AddTask(task);
520   
521   //Create containers
522   char name[128];
523   sprintf(name,"PartCorr_%s",calorimeter.Data());
524   cout<<"Name of task "<<name<<endl;
525   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
526   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
527   
528   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
529   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
530   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
531                                                              AliAnalysisManager::kOutputContainer, 
532                                                              Form("%s:PartCorr",outputfile.Data()));
533         
534   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
535                                                              AliAnalysisManager::kParamContainer, 
536                                                              Form("%s:PartCorrCuts",outputfile.Data()));
537         
538   // Create ONLY the output containers for the data produced by the task.
539   // Get and connect other common input/output containers via the manager as below
540   //==============================================================================
541   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
542   // AOD output slot will be used in a different way in future
543   if(!data.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
544   mgr->ConnectOutput (task, 1, cout_pc);
545   mgr->ConnectOutput (task, 2, cout_cuts);
546   
547   return task;
548 }
549
550