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