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