]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
Update wagon macros, method used removed from AliCalorimeterUtils
[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   
88   // Remove EMCAL hottest channels for first LHC10 periods      
89   cu->SwitchOnBadChannelsRemoval();
90   // SM0
91   cu->SetEMCALChannelStatus(0,3,13);  cu->SetEMCALChannelStatus(0,44,1); cu->SetEMCALChannelStatus(0,3,13); 
92   cu->SetEMCALChannelStatus(0,20,7);  cu->SetEMCALChannelStatus(0,38,2);   
93   // SM1
94   cu->SetEMCALChannelStatus(1,4,7);   cu->SetEMCALChannelStatus(1,4,13);  cu->SetEMCALChannelStatus(1,9,20); 
95   cu->SetEMCALChannelStatus(1,14,15); cu->SetEMCALChannelStatus(1,23,16); cu->SetEMCALChannelStatus(1,32,23); 
96   cu->SetEMCALChannelStatus(1,37,5);  cu->SetEMCALChannelStatus(1,40,1);  cu->SetEMCALChannelStatus(1,40,2);
97   cu->SetEMCALChannelStatus(1,40,5);  cu->SetEMCALChannelStatus(1,41,0);  cu->SetEMCALChannelStatus(1,41,1);
98   cu->SetEMCALChannelStatus(1,41,2);  cu->SetEMCALChannelStatus(1,41,4);
99   // SM2        
100   cu->SetEMCALChannelStatus(2,14,15); cu->SetEMCALChannelStatus(2,18,16); cu->SetEMCALChannelStatus(2,18,17); 
101   cu->SetEMCALChannelStatus(2,18,18); cu->SetEMCALChannelStatus(2,18,20); cu->SetEMCALChannelStatus(2,18,21); 
102   cu->SetEMCALChannelStatus(2,18,23); cu->SetEMCALChannelStatus(2,19,16); cu->SetEMCALChannelStatus(2,19,17); 
103   cu->SetEMCALChannelStatus(2,19,19); cu->SetEMCALChannelStatus(2,19,20); cu->SetEMCALChannelStatus(2,19,21); 
104   cu->SetEMCALChannelStatus(2,19,22);
105   //SM3
106   cu->SetEMCALChannelStatus(3,4,7);
107   
108   
109   //Recalibration
110   //cu->SwitchOnRecalibration();
111   //TFile * f = new TFile("RecalibrationFactors.root","read");
112   //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
113   //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
114   //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
115   //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));
116   //f->Close(); 
117   
118   cu->SetDebug(-1);
119   if(kPrintSettings) cu->Print("");
120   
121   
122   // ##### Analysis algorithm settings ####
123   
124   // -------------------------------------------------
125   // --- Photon/Pi0/Omega/Electron Analysis ---
126   // -------------------------------------------------
127   
128   AliAnaPhoton *anaphoton = new AliAnaPhoton();
129   anaphoton->SetDebug(-1); //10 for lots of messages
130   if(calorimeter == "PHOS"){
131     anaphoton->SetNCellCut(0);// At least 2 cells
132     anaphoton->SetMinPt(0.);
133     anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
134   }
135   else {//EMCAL
136     //anaphoton->SetNCellCut(0);// At least 2 cells
137     anaphoton->SetMinPt(0.1); // no effect minium EMCAL cut.
138     if(!kUseKinematics) anaphoton->SetTimeCut(400,900);// Time window of [400-900] ns
139     anaphoton->SetMinDistanceToBadChannel(6, 12, 18);
140   }
141   anaphoton->SetCalorimeter(calorimeter);
142   if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
143   else  anaphoton->SwitchOffDataMC() ;
144   anaphoton->SwitchOffCaloPID();
145   anaphoton->SwitchOffFiducialCut();
146   if(kSimulation){
147     anaphoton->SwitchOnFiducialCut();
148     AliFiducialCut * fidCut1stYear = anaphoton->GetFiducialCut();
149     fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
150     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
151     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
152     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
153     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
154   }
155   
156   if(!data.Contains("delta")) {
157     anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
158     anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
159   }
160   else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
161   anaphoton->AddToHistogramsName("AnaPhotonCorr_");
162   //Set Histograms bins and ranges
163   anaphoton->SetHistoPtRangeAndNBins(0, 50, 200) ;
164   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
165   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
166   if(kPrintSettings) anaphoton->Print("");
167   
168   // -----------------------------------
169   // --- Pi0 Invariant Mass Analysis ---
170   // -----------------------------------
171   
172   AliAnaPi0 *anapi0 = new AliAnaPi0();
173   anapi0->SetDebug(-1);//10 for lots of messages
174   anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
175   anapi0->SetCalorimeter(calorimeter);
176   anapi0->SwitchOnMultipleCutAnalysis(); 
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   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.08, 0.18)     ;
226   nms->KeepNeutralMesonSelectionHistos(kTRUE);
227   //Set Histrograms bins and ranges
228   if(calorimeter=="EMCAL" ){
229     nms->SetHistoERangeAndNBins(0, 15, 150) ;  
230     anapi0ebe->SetHistoPtRangeAndNBins(0, 15, 75) ;
231   }
232   else{
233     nms->SetHistoERangeAndNBins(0, 30, 200) ;  
234     anapi0ebe->SetHistoPtRangeAndNBins(0, 30, 100) ;
235   }
236   //      nms->SetHistoPtRangeAndNBins(0, 50, 100) ;
237   //      nms->SetHistoAngleRangeAndNBins(0, 0.3, 100) ;
238   //      nsm->SetHistoIMRangeAndNBins(0, 0.4, 100) ;  
239   //Set Histrograms bins and ranges
240   //      anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
241   //      anapi0->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
242   if(kPrintSettings) anapi0ebe->Print("");
243         
244   //-------------------------------------
245   //*** analysis the omega->pi0+gamma ***
246   //------------------------------------
247   AliAnaOmegaToPi0Gamma *anaomegaToPi0Gamma = new AliAnaOmegaToPi0Gamma();
248   anaomegaToPi0Gamma->SetDebug(-1);//10 for lots of messages
249   anaomegaToPi0Gamma->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
250   anaomegaToPi0Gamma->SetInputAODPhotonName(Form("Photons%s",calorimeter.Data()));
251   anaomegaToPi0Gamma->SetNPID(1);
252   anaomegaToPi0Gamma->SetNVtxZ(1);
253   anaomegaToPi0Gamma->SetNEventsMixed(4);
254   if(calorimeter=="PHOS")
255     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.008); // PHOS
256   else if(calorimeter=="EMCAL")
257     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.012); // EMCAL 
258   anaomegaToPi0Gamma->SetHistoPtRangeAndNBins(0, 20, 100) ;
259   anaomegaToPi0Gamma->SetHistoMassRangeAndNBins(0, 1, 100) ;
260   anaomegaToPi0Gamma->SetPi0OverOmegaPtCut(0.8);
261   anaomegaToPi0Gamma->SetGammaOverOmegaPtCut(0.2);
262   if(kUseKinematics) anaomegaToPi0Gamma->SwitchOnDataMC() ;//Access MC stack and fill more histograms
263   else anaomegaToPi0Gamma->SwitchOffDataMC() ;//Access MC stack and fill more histograms
264   anaomegaToPi0Gamma->AddToHistogramsName(Form("AnaOmegaToPi0Gamma%s_",calorimeter.Data()));
265   if(kPrintSettings)   anaomegaToPi0Gamma->Print("");
266         
267         
268   //---------------------------------------------------------------------
269   // Electron/btag
270   //---------------------------------------------------------------------
271   if(calorimeter=="EMCAL"){
272     
273     AliAnaBtag *anabtag = new AliAnaBtag();
274     anabtag->SetDebug(-1); //10 for lots of messages
275     if(kUseKinematics){
276       anabtag->SwitchOnDataMC();
277       anabtag->SetMinPt(1.);
278     }
279     anabtag->SetOutputAODName("ElectronsEMCAL");
280     anabtag->SetOutputAODClassName("AliAODPWG4Particle");
281     //anabtag->SetHistoPtRangeAndNBins(0, 100, 100) ;
282     //anabtag->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
283     //anabtag->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
284     if(kPrintSettings)anabtag->Print("");
285   }
286   
287   //==================================
288   // ### Isolation analysis ### 
289   //=================================
290   //Photon
291   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
292   anaisol->SetDebug(-1);
293   anaisol->SetMinPt(0);
294   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
295   anaisol->SetAODObjArrayName("ICPhoton"); 
296   anaisol->SetCalorimeter(calorimeter);
297   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
298   else  anaisol->SwitchOffDataMC() ;
299   //Select clusters with no pair, if both clusters with pi0 mass
300   anaisol->SwitchOffInvariantMass();
301   //Do isolation cut
302   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
303   ic->SetConeSize(0.4);
304   ic->SetPtThreshold(0.2);
305   ic->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
306   ic->SetICMethod(AliIsolationCut::kPtThresIC);
307   if(kPrintSettings) ic->Print("");
308   
309   //Do or not do isolation with previously produced AODs.
310   //No effect if use of SwitchOnSeveralIsolation()
311   anaisol->SwitchOffReIsolation();
312   //Multiple IC
313   anaisol->SwitchOffSeveralIsolation() ;
314   //Set Histograms bins and ranges
315   anaisol->SetHistoPtRangeAndNBins(0, 50, 200) ;
316   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
317   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
318   anaisol->AddToHistogramsName("AnaIsolPhoton_");
319   if(kPrintSettings) anaisol->Print("");
320   
321   //Pi0
322   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
323   anaisolpi0->SetDebug(-1);
324   anaisolpi0->SetMinPt(0);
325   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
326   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
327   anaisolpi0->SetAODObjArrayName("ICPi0"); 
328   anaisolpi0->SetCalorimeter(calorimeter);
329   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
330   else  anaisolpi0->SwitchOffDataMC() ;
331   //Select clusters with no pair, if both clusters with pi0 mass
332   anaisolpi0->SwitchOffInvariantMass();
333   //Do isolation cut
334   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
335   ic2->SetConeSize(0.4);
336   ic2->SetPtThreshold(0.2);
337   ic2->SetICMethod(AliIsolationCut::kPtThresIC);
338   if(kPrintSettings) ic2->Print("");
339   //Do or not do isolation with previously produced AODs.
340   //No effect if use of SwitchOnSeveralIsolation()
341   anaisolpi0->SwitchOffReIsolation();
342   //Multiple IC
343   anaisolpi0->SwitchOffSeveralIsolation() ;
344   //Set Histograms bins and ranges
345   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
346   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
347   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
348   if(kPrintSettings) anaisolpi0->Print("");
349         
350   //===========================
351   //Correlation analysis
352   //===========================
353         
354   // ### Correlation with Jet Finder AOD output
355   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
356   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
357   anacorrjet->SwitchOffFiducialCut();
358   anacorrjet->SetDebug(-1);
359   anacorrjet->SetConeSize(1);  
360   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
361   anacorrjet->SetPtThresholdInCone(0.2);
362   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
363   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
364   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
365   //Set Histograms bins and ranges
366   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 200) ;
367   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
368   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
369   if(kPrintSettings) anacorrjet->Print("");
370   
371   // ### Correlation with hadrons
372   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
373   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
374   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
375   anacorrhadron->SetAODObjArrayName("PhotonHadronCorr"); 
376   anacorrhadron->SetDebug(-1);
377   anacorrhadron->SwitchOffCaloPID();
378   anacorrhadron->SwitchOffFiducialCut();
379   anacorrhadron->SetPtCutRange(0.1,100);
380   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
381   anacorrhadron->SwitchOnSeveralUECalculation();
382   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
383   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
384   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
385   else  anacorrhadron->SwitchOffDataMC() ;
386   //if(calorimeter=="PHOS"){
387   //Correlate with particles in EMCAL
388   //anacorrhadron->SwitchOnCaloPID();
389   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
390   //}
391   //Set Histograms bins and ranges
392   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
393   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
394   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
395   if(kPrintSettings) anacorrhadron->Print("");
396   
397   // ### Correlation with hadrons
398   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
399   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
400   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
401   anacorrisohadron->SetAODObjArrayName("IsoPhotonHadronCorr"); 
402   anacorrisohadron->SetDebug(-1);
403   anacorrisohadron->SwitchOffCaloPID();
404   anacorrisohadron->SwitchOffFiducialCut();
405   anacorrisohadron->SetPtCutRange(0.1,100);
406   anacorrisohadron->SetDeltaPhiCutRange(1.5,4.5);
407   anacorrisohadron->SwitchOnSeveralUECalculation();
408   anacorrisohadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
409   anacorrisohadron->SelectIsolated(kTRUE); // do correlation with isolated photons
410   if(kUseKinematics) anacorrisohadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
411   else  anacorrisohadron->SwitchOffDataMC() ;
412   //if(calorimeter=="PHOS"){
413   //Correlate with particles in EMCAL
414   //anacorrhadron->SwitchOnCaloPID();
415   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
416   //}
417   //Set Histograms bins and ranges
418   anacorrisohadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
419   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
420   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
421   if(kPrintSettings) anacorrisohadron->Print("");
422   
423   
424   // ### Pi0 Correlation with hadrons, not isolated
425   AliAnaParticleHadronCorrelation *anacorrhadronpi0 = new AliAnaParticleHadronCorrelation();
426   anacorrhadronpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
427   anacorrhadronpi0->AddToHistogramsName("AnaHadronCorrPi0_");
428   anacorrhadronpi0->SetAODObjArrayName("Pi0HadronCorr"); 
429   anacorrhadronpi0->SetDebug(-1);
430   anacorrhadronpi0->SwitchOffCaloPID();
431   anacorrhadronpi0->SwitchOffFiducialCut();
432   anacorrhadronpi0->SetPtCutRange(0.1,100);
433   anacorrhadronpi0->SetDeltaPhiCutRange(1.5,4.5);
434   anacorrhadronpi0->SelectIsolated(kFALSE); // do correlation with non isolated pi0
435   anacorrhadronpi0->SwitchOnSeveralUECalculation();
436   anacorrhadronpi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
437   if(kUseKinematics) anacorrhadronpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
438   else  anacorrhadronpi0->SwitchOffDataMC() ;
439   //if(calorimeter=="PHOS"){
440   //    //Correlate with particles in EMCAL
441   //    anacorrhadronpi0->SwitchOnCaloPID();
442   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
443   //}
444   //Set Histograms bins and ranges
445   anacorrhadronpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
446   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
447   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
448   if(kPrintSettings) anacorrhadronpi0->Print("");
449   
450   // ### Pi0 Correlation with hadrons, isolated
451   AliAnaParticleHadronCorrelation *anacorrhadronisopi0 = new AliAnaParticleHadronCorrelation();
452   anacorrhadronisopi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
453   anacorrhadronisopi0->AddToHistogramsName("AnaHadronCorrIsoPi0_");
454   anacorrhadronisopi0->SetAODObjArrayName("IsoPi0HadronCorr"); 
455   anacorrhadronisopi0->SetDebug(-1);
456   anacorrhadronisopi0->SwitchOffCaloPID();
457   anacorrhadronisopi0->SwitchOffFiducialCut();
458   anacorrhadronisopi0->SetPtCutRange(0.1,100);
459   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
460   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
461   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
462   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
463   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
464   else  anacorrhadronisopi0->SwitchOffDataMC() ;
465   //if(calorimeter=="PHOS"){
466   //    //Correlate with particles in EMCAL
467   //    anacorrhadronpi0->SwitchOnCaloPID();
468   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
469   //}
470   //Set Histograms bins and ranges
471   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
472   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
473   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
474   if(kPrintSettings) anacorrhadronisopi0->Print("");
475   
476   
477   // #### Configure Maker ####
478   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
479   maker->SetReader(reader);//pointer to reader
480   maker->SetCaloUtils(cu); //pointer to calorimeter utils
481   Int_t n = 0;//Analysis number, order is important
482   // Particle selection analysis
483   maker->AddAnalysis(anaphoton,n++);
484   maker->AddAnalysis(anapi0,n++);
485   maker->AddAnalysis(anapi0ebe,n++);
486   maker->AddAnalysis(anaomegaToPi0Gamma,n++);  
487   if(calorimeter=="EMCAL")maker->AddAnalysis(anabtag,n++);   
488   // Isolation analysis
489   maker->AddAnalysis(anaisol,n++);
490   maker->AddAnalysis(anaisolpi0,n++);
491   // Correlation analysis
492   maker->AddAnalysis(anacorrjet,n++);
493   maker->AddAnalysis(anacorrhadron,n++);
494   maker->AddAnalysis(anacorrhadronpi0,n++);
495   maker->AddAnalysis(anacorrisohadron,n++);
496   maker->AddAnalysis(anacorrhadronisopi0,n);
497   maker->SetAnaDebug(-1)  ;
498   maker->SwitchOnHistogramsMaker()  ;
499   if(data.Contains("delta")) maker->SwitchOffAODsMaker()  ;
500   else                       maker->SwitchOnAODsMaker()  ;
501         
502   if(kPrintSettings) maker->Print("");
503   
504   printf("======================== \n");
505   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
506   printf("======================== \n");
507   
508   // Create task
509   //===========================================================================
510   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
511   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
512   //task->SetDebugLevel(-1);
513   task->SelectCollisionCandidates();
514   task->SetAnalysisMaker(maker);
515   //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
516   mgr->AddTask(task);
517   
518   //Create containers
519   char name[128];
520   sprintf(name,"PartCorr_%s",calorimeter.Data());
521   cout<<"Name of task "<<name<<endl;
522   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
523   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
524   
525   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
526   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
527   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
528                                                              AliAnalysisManager::kOutputContainer, 
529                                                              Form("%s:PartCorr",outputfile.Data()));
530         
531   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
532                                                              AliAnalysisManager::kParamContainer, 
533                                                              Form("%s:PartCorrCuts",outputfile.Data()));
534         
535   // Create ONLY the output containers for the data produced by the task.
536   // Get and connect other common input/output containers via the manager as below
537   //==============================================================================
538   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
539   // AOD output slot will be used in a different way in future
540   if(!data.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
541   mgr->ConnectOutput (task, 1, cout_pc);
542   mgr->ConnectOutput (task, 2, cout_cuts);
543   
544   return task;
545 }
546
547