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