]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
839f9a1fb6ae9d87e8fd5a890e973fb0e6c2d260
[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     
274     AliAnaBtag *anabtag = new AliAnaBtag();
275     anabtag->SetDebug(-1); //10 for lots of messages
276     if(kUseKinematics){
277       anabtag->SwitchOnDataMC();
278       anabtag->SetMinPt(1.);
279     }
280     anabtag->SetOutputAODName("ElectronsEMCAL");
281     anabtag->SetOutputAODClassName("AliAODPWG4Particle");
282     //anabtag->SetHistoPtRangeAndNBins(0, 100, 100) ;
283     //anabtag->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
284     //anabtag->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
285     if(kPrintSettings)anabtag->Print("");
286   }
287   
288   //==================================
289   // ### Isolation analysis ### 
290   //=================================
291   //Photon
292   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
293   anaisol->SetDebug(-1);
294   anaisol->SetMinPt(0);
295   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
296   anaisol->SetAODObjArrayName("ICPhoton"); 
297   anaisol->SetCalorimeter(calorimeter);
298   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
299   else  anaisol->SwitchOffDataMC() ;
300   //Select clusters with no pair, if both clusters with pi0 mass
301   anaisol->SwitchOffInvariantMass();
302   //Do isolation cut
303   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
304   ic->SetConeSize(0.4);
305   ic->SetPtThreshold(0.2);
306   ic->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
307   ic->SetICMethod(AliIsolationCut::kPtThresIC);
308   if(kPrintSettings) ic->Print("");
309   
310   //Do or not do isolation with previously produced AODs.
311   //No effect if use of SwitchOnSeveralIsolation()
312   anaisol->SwitchOffReIsolation();
313   //Multiple IC
314   anaisol->SwitchOffSeveralIsolation() ;
315   //Set Histograms bins and ranges
316   anaisol->SetHistoPtRangeAndNBins(0, 50, 200) ;
317   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
318   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
319   anaisol->AddToHistogramsName("AnaIsolPhoton_");
320   if(kPrintSettings) anaisol->Print("");
321   
322   //Pi0
323   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
324   anaisolpi0->SetDebug(-1);
325   anaisolpi0->SetMinPt(0);
326   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
327   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
328   anaisolpi0->SetAODObjArrayName("ICPi0"); 
329   anaisolpi0->SetCalorimeter(calorimeter);
330   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
331   else  anaisolpi0->SwitchOffDataMC() ;
332   //Select clusters with no pair, if both clusters with pi0 mass
333   anaisolpi0->SwitchOffInvariantMass();
334   //Do isolation cut
335   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
336   ic2->SetConeSize(0.4);
337   ic2->SetPtThreshold(0.2);
338   ic2->SetICMethod(AliIsolationCut::kPtThresIC);
339   if(kPrintSettings) ic2->Print("");
340   //Do or not do isolation with previously produced AODs.
341   //No effect if use of SwitchOnSeveralIsolation()
342   anaisolpi0->SwitchOffReIsolation();
343   //Multiple IC
344   anaisolpi0->SwitchOffSeveralIsolation() ;
345   //Set Histograms bins and ranges
346   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
347   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
348   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
349   if(kPrintSettings) anaisolpi0->Print("");
350         
351   //===========================
352   //Correlation analysis
353   //===========================
354         
355   // ### Correlation with Jet Finder AOD output
356   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
357   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
358   anacorrjet->SwitchOffFiducialCut();
359   anacorrjet->SetDebug(-1);
360   anacorrjet->SetConeSize(1);  
361   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
362   anacorrjet->SetPtThresholdInCone(0.2);
363   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
364   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
365   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
366   //Set Histograms bins and ranges
367   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 200) ;
368   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
369   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
370   if(kPrintSettings) anacorrjet->Print("");
371   
372   // ### Correlation with hadrons
373   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
374   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
375   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
376   anacorrhadron->SetAODObjArrayName("PhotonHadronCorr"); 
377   anacorrhadron->SetDebug(-1);
378   anacorrhadron->SwitchOffCaloPID();
379   anacorrhadron->SwitchOffFiducialCut();
380   anacorrhadron->SetPtCutRange(0.1,100);
381   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
382   anacorrhadron->SwitchOnSeveralUECalculation();
383   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
384   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
385   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
386   else  anacorrhadron->SwitchOffDataMC() ;
387   //if(calorimeter=="PHOS"){
388   //Correlate with particles in EMCAL
389   //anacorrhadron->SwitchOnCaloPID();
390   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
391   //}
392   //Set Histograms bins and ranges
393   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
394   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
395   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
396   if(kPrintSettings) anacorrhadron->Print("");
397   
398   // ### Correlation with hadrons
399   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
400   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
401   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
402   anacorrisohadron->SetAODObjArrayName("IsoPhotonHadronCorr"); 
403   anacorrisohadron->SetDebug(-1);
404   anacorrisohadron->SwitchOffCaloPID();
405   anacorrisohadron->SwitchOffFiducialCut();
406   anacorrisohadron->SetPtCutRange(0.1,100);
407   anacorrisohadron->SetDeltaPhiCutRange(1.5,4.5);
408   anacorrisohadron->SwitchOnSeveralUECalculation();
409   anacorrisohadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
410   anacorrisohadron->SelectIsolated(kTRUE); // do correlation with isolated photons
411   if(kUseKinematics) anacorrisohadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
412   else  anacorrisohadron->SwitchOffDataMC() ;
413   //if(calorimeter=="PHOS"){
414   //Correlate with particles in EMCAL
415   //anacorrhadron->SwitchOnCaloPID();
416   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
417   //}
418   //Set Histograms bins and ranges
419   anacorrisohadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
420   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
421   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
422   if(kPrintSettings) anacorrisohadron->Print("");
423   
424   
425   // ### Pi0 Correlation with hadrons, not isolated
426   AliAnaParticleHadronCorrelation *anacorrhadronpi0 = new AliAnaParticleHadronCorrelation();
427   anacorrhadronpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
428   anacorrhadronpi0->AddToHistogramsName("AnaHadronCorrPi0_");
429   anacorrhadronpi0->SetAODObjArrayName("Pi0HadronCorr"); 
430   anacorrhadronpi0->SetDebug(-1);
431   anacorrhadronpi0->SwitchOffCaloPID();
432   anacorrhadronpi0->SwitchOffFiducialCut();
433   anacorrhadronpi0->SetPtCutRange(0.1,100);
434   anacorrhadronpi0->SetDeltaPhiCutRange(1.5,4.5);
435   anacorrhadronpi0->SelectIsolated(kFALSE); // do correlation with non isolated pi0
436   anacorrhadronpi0->SwitchOnSeveralUECalculation();
437   anacorrhadronpi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
438   if(kUseKinematics) anacorrhadronpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
439   else  anacorrhadronpi0->SwitchOffDataMC() ;
440   //if(calorimeter=="PHOS"){
441   //    //Correlate with particles in EMCAL
442   //    anacorrhadronpi0->SwitchOnCaloPID();
443   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
444   //}
445   //Set Histograms bins and ranges
446   anacorrhadronpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
447   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
448   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
449   if(kPrintSettings) anacorrhadronpi0->Print("");
450   
451   // ### Pi0 Correlation with hadrons, isolated
452   AliAnaParticleHadronCorrelation *anacorrhadronisopi0 = new AliAnaParticleHadronCorrelation();
453   anacorrhadronisopi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
454   anacorrhadronisopi0->AddToHistogramsName("AnaHadronCorrIsoPi0_");
455   anacorrhadronisopi0->SetAODObjArrayName("IsoPi0HadronCorr"); 
456   anacorrhadronisopi0->SetDebug(-1);
457   anacorrhadronisopi0->SwitchOffCaloPID();
458   anacorrhadronisopi0->SwitchOffFiducialCut();
459   anacorrhadronisopi0->SetPtCutRange(0.1,100);
460   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
461   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
462   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
463   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
464   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
465   else  anacorrhadronisopi0->SwitchOffDataMC() ;
466   //if(calorimeter=="PHOS"){
467   //    //Correlate with particles in EMCAL
468   //    anacorrhadronpi0->SwitchOnCaloPID();
469   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
470   //}
471   //Set Histograms bins and ranges
472   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
473   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
474   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
475   if(kPrintSettings) anacorrhadronisopi0->Print("");
476   
477   
478   // #### Configure Maker ####
479   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
480   maker->SetReader(reader);//pointer to reader
481   maker->SetCaloUtils(cu); //pointer to calorimeter utils
482   Int_t n = 0;//Analysis number, order is important
483   // Particle selection analysis
484   maker->AddAnalysis(anaphoton,n++);
485   maker->AddAnalysis(anapi0,n++);
486   maker->AddAnalysis(anapi0ebe,n++);
487   maker->AddAnalysis(anaomegaToPi0Gamma,n++);  
488   if(calorimeter=="EMCAL")maker->AddAnalysis(anabtag,n++);   
489   // Isolation analysis
490   maker->AddAnalysis(anaisol,n++);
491   maker->AddAnalysis(anaisolpi0,n++);
492   // Correlation analysis
493   maker->AddAnalysis(anacorrjet,n++);
494   maker->AddAnalysis(anacorrhadron,n++);
495   maker->AddAnalysis(anacorrhadronpi0,n++);
496   maker->AddAnalysis(anacorrisohadron,n++);
497   maker->AddAnalysis(anacorrhadronisopi0,n);
498   maker->SetAnaDebug(-1)  ;
499   maker->SwitchOnHistogramsMaker()  ;
500   if(data.Contains("delta")) maker->SwitchOffAODsMaker()  ;
501   else                       maker->SwitchOnAODsMaker()  ;
502         
503   if(kPrintSettings) maker->Print("");
504   
505   printf("======================== \n");
506   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
507   printf("======================== \n");
508   
509   // Create task
510   //===========================================================================
511   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
512   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
513   //task->SetDebugLevel(-1);
514   task->SelectCollisionCandidates();
515   task->SetAnalysisMaker(maker);
516   //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
517   mgr->AddTask(task);
518   
519   //Create containers
520   char name[128];
521   sprintf(name,"PartCorr_%s",calorimeter.Data());
522   cout<<"Name of task "<<name<<endl;
523   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
524   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
525   
526   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
527   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
528   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
529                                                              AliAnalysisManager::kOutputContainer, 
530                                                              Form("%s:PartCorr",outputfile.Data()));
531         
532   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
533                                                              AliAnalysisManager::kParamContainer, 
534                                                              Form("%s:PartCorrCuts",outputfile.Data()));
535         
536   // Create ONLY the output containers for the data produced by the task.
537   // Get and connect other common input/output containers via the manager as below
538   //==============================================================================
539   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
540   // AOD output slot will be used in a different way in future
541   if(!data.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
542   mgr->ConnectOutput (task, 1, cout_pc);
543   mgr->ConnectOutput (task, 2, cout_cuts);
544   
545   return task;
546 }
547
548