]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
remove from EMCAL analysis warm channels
[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   AliFiducialCut * fidCut1stYear = new AliFiducialCut();
125   fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
126   if(kSimulation){
127     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
128     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
129     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
130     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
131   } 
132   else{
133     fidCut1stYear->DoEMCALFiducialCut(kFALSE) ;
134     fidCut1stYear->DoPHOSFiducialCut(kFALSE) ;
135   }     
136   
137   
138   // -------------------------------------------------
139   // --- Photon/Pi0/Omega/Electron Analysis ---
140   // -------------------------------------------------
141   
142   AliAnaPhoton *anaphoton = new AliAnaPhoton();
143   anaphoton->SetDebug(-1); //10 for lots of messages
144   if(calorimeter == "PHOS"){
145     anaphoton->SetNCellCut(1);// At least 2 cells
146     anaphoton->SetMinPt(0.2);
147     anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
148   }
149   else {//EMCAL
150     //anaphoton->SetNCellCut(0);// At least 2 cells
151     anaphoton->SetMinPt(0.1); // no effect minium EMCAL cut.
152     anaphoton->SetTimeCut(525,725);// Time window of [550-750] ns
153     anaphoton->SetMinDistanceToBadChannel(6, 12, 18);
154   }
155   anaphoton->SetCalorimeter(calorimeter);
156   if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
157   else  anaphoton->SwitchOffDataMC() ;
158   anaphoton->SwitchOffCaloPID();
159   anaphoton->SwitchOffFiducialCut();
160   if(kSimulation){
161     anaphoton->SwitchOnFiducialCut();
162     anaphoton->SetFiducialCut(fidCut1stYear);
163   }
164   
165   if(!data.Contains("delta")) {
166     anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
167     anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
168   }
169   else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
170   anaphoton->AddToHistogramsName("AnaPhotonCorr_");
171   //Set Histograms bins and ranges
172   anaphoton->SetHistoPtRangeAndNBins(0, 50, 200) ;
173   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
174   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
175   if(kPrintSettings) anaphoton->Print("");
176  
177   // -----------------------------------
178   // --- Pi0 Invariant Mass Analysis ---
179   // -----------------------------------
180   
181   AliAnaPi0 *anapi0 = new AliAnaPi0();
182   anapi0->SetDebug(-1);//10 for lots of messages
183   anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
184   anapi0->SetCalorimeter(calorimeter);
185   if(kSimulation){
186     anapi0->SwitchOnFiducialCut();
187     anapi0->SetFiducialCut(fidCut1stYear);
188   }  
189   anapi0->SetNPID(1); //Available from tag AliRoot::v4-18-15-AN
190   //settings for pp collision
191   anapi0->SetNCentrBin(1);
192   anapi0->SetNZvertBin(1);
193   anapi0->SetNRPBin(1);
194   anapi0->SetNMaxEvMix(10);
195   anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
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   AliNeutralMesonSelection *nms = new AliNeutralMesonSelection();
210   nms->SetInvMassCutRange(0.05, 0.2)     ;
211   nms->KeepNeutralMesonSelectionHistos(kTRUE);
212   //Set Histrograms bins and ranges
213   nms->SetHistoERangeAndNBins(0, 50, 200) ;
214   //      nms->SetHistoPtRangeAndNBins(0, 50, 100) ;
215   //      nms->SetHistoAngleRangeAndNBins(0, 0.3, 100) ;
216   //      nsm->SetHistoIMRangeAndNBins(0, 0.4, 100) ;  
217                 
218   AliAnaPi0EbE *anapi0ebe = new AliAnaPi0EbE();
219   anapi0ebe->SetDebug(-1);//10 for lots of messages
220   anapi0ebe->SetAnalysisType(AliAnaPi0EbE::kIMCalo);
221   anapi0ebe->SetMinPt(0);
222   anapi0ebe->SetCalorimeter(calorimeter);
223   anapi0ebe->SetInputAODName(Form("Photons%s",calorimeter.Data()));
224   if(!data.Contains("delta")) {
225         anapi0ebe->SetOutputAODName(Form("Pi0s%s",calorimeter.Data()));
226         anapi0ebe->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
227   }
228   else  anapi0ebe->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
229         
230   if(kUseKinematics) anapi0ebe->SwitchOnDataMC() ;//Access MC stack and fill more histograms
231   else  anapi0ebe->SwitchOffDataMC() ;  
232   anapi0ebe->SetNeutralMesonSelection(nms);
233   //Set Histrograms bins and ranges
234   anapi0ebe->SetHistoPtRangeAndNBins(0, 50, 200) ;
235   //      anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
236   //      anapi0->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
237   if(kPrintSettings) anapi0ebe->Print("");
238         
239   //-------------------------------------
240   //*** analysis the omega->pi0+gamma ***
241   //------------------------------------
242   AliAnaOmegaToPi0Gamma *anaomegaToPi0Gamma = new AliAnaOmegaToPi0Gamma();
243   anaomegaToPi0Gamma->SetDebug(-1);//10 for lots of messages
244   anaomegaToPi0Gamma->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
245   anaomegaToPi0Gamma->SetInputAODPhotonName(Form("Photons%s",calorimeter.Data()));
246   anaomegaToPi0Gamma->SetNPID(1);
247   anaomegaToPi0Gamma->SetNVtxZ(1);
248   anaomegaToPi0Gamma->SetNEventsMixed(4);
249   if(calorimeter=="PHOS")
250         anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.008); // PHOS
251   else if(calorimeter=="EMCAL")
252         anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.012); // EMCAL 
253   anaomegaToPi0Gamma->SetHistoPtRangeAndNBins(0, 20, 100) ;
254   anaomegaToPi0Gamma->SetHistoMassRangeAndNBins(0, 1, 100) ;
255   anaomegaToPi0Gamma->SetPi0OverOmegaPtCut(0.8);
256   anaomegaToPi0Gamma->SetGammaOverOmegaPtCut(0.2);
257   if(kUseKinematics) anaomegaToPi0Gamma->SwitchOnDataMC() ;//Access MC stack and fill more histograms
258   else anaomegaToPi0Gamma->SwitchOffDataMC() ;//Access MC stack and fill more histograms
259   anaomegaToPi0Gamma->AddToHistogramsName(Form("AnaOmegaToPi0Gamma%s_",calorimeter.Data()));
260   if(kPrintSettings)   anaomegaToPi0Gamma->Print("");
261         
262         
263   //---------------------------------------------------------------------
264   // Electron/btag
265   //---------------------------------------------------------------------
266   if(calorimeter=="EMCAL"){
267         Double_t pOverEmin = 0.8;  //tight
268         Double_t pOverEmax = 1.2;  //tight
269         Double_t dRmax     = 0.02; //tight
270         
271         AliAnaBtag *anaelectron = new AliAnaBtag();
272         anaelectron->SetDebug(-1); //10 for lots of messages
273         anaelectron->SetCalorimeter("EMCAL");
274         if(kUseKinematics){
275                 anaelectron->SwitchOffDataMC();
276                 anaelectron->SetMinPt(1.);
277         }
278         anaelectron->SetOutputAODName("ElectronsEMCAL");
279         anaelectron->SetOutputAODClassName("AliAODPWG4Particle");
280         //Determine which cuts to use based on enum
281         anaelectron->SetpOverEmin(pOverEmin);
282         anaelectron->SetpOverEmax(pOverEmax);
283         anaelectron->SetResidualCut(dRmax);
284         //Set Histrograms bins and ranges 
285         anaelectron->SetHistoPtRangeAndNBins(0, 100, 100) ;
286         anaelectron->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
287         anaelectron->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
288         if(kPrintSettings)anaelectron->Print("");
289   }
290   //==================================
291   // ### Isolation analysis ### 
292   //=================================
293   //Photon
294   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
295   anaisol->SetDebug(-1);
296   anaisol->SetMinPt(0);
297   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
298   anaisol->SetCalorimeter(calorimeter);
299   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
300   else  anaisol->SwitchOffDataMC() ;
301   //Select clusters with no pair, if both clusters with pi0 mass
302   anaisol->SwitchOffInvariantMass();
303   //anaisol->SetNeutralMesonSelection(nms);
304   //Do isolation cut
305   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
306   ic->SetConeSize(0.4);
307   ic->SetPtThreshold(0.2);
308   ic->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
309   ic->SetICMethod(AliIsolationCut::kPtThresIC);
310   if(kPrintSettings) ic->Print("");
311   
312   //Do or not do isolation with previously produced AODs.
313   //No effect if use of SwitchOnSeveralIsolation()
314   anaisol->SwitchOffReIsolation();
315   //Multiple IC
316   anaisol->SwitchOffSeveralIsolation() ;
317   //Set Histograms bins and ranges
318   anaisol->SetHistoPtRangeAndNBins(0, 50, 200) ;
319   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
320   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
321   anaisol->AddToHistogramsName("AnaIsolPhoton_");
322   if(kPrintSettings) anaisol->Print("");
323   
324   //Pi0
325   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
326   anaisolpi0->SetDebug(-1);
327   anaisolpi0->SetMinPt(0);
328   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
329   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
330   anaisolpi0->SetCalorimeter(calorimeter);
331   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
332   else  anaisolpi0->SwitchOffDataMC() ;
333   //Select clusters with no pair, if both clusters with pi0 mass
334   anaisolpi0->SwitchOffInvariantMass();
335   //anaisol->SetNeutralMesonSelection(nms);
336   //Do isolation cut
337   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
338   ic2->SetConeSize(0.4);
339   ic2->SetPtThreshold(0.2);
340   ic2->SetICMethod(AliIsolationCut::kPtThresIC);
341   if(kPrintSettings) ic->Print("");
342   //Do or not do isolation with previously produced AODs.
343   //No effect if use of SwitchOnSeveralIsolation()
344   anaisolpi0->SwitchOffReIsolation();
345   //Multiple IC
346   anaisolpi0->SwitchOffSeveralIsolation() ;
347   //Set Histograms bins and ranges
348   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
349   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
350   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
351   if(kPrintSettings) anaisol->Print("");
352         
353   //===========================
354   //Correlation analysis
355   //===========================
356         
357   // ### Correlation with Jet Finder AOD output
358   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
359   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
360   anacorrjet->SwitchOffFiducialCut();
361   anacorrjet->SetDebug(-1);
362   anacorrjet->SetConeSize(1);  
363   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
364   anacorrjet->SetPtThresholdInCone(0.2);
365   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
366   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
367   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
368   //Set Histograms bins and ranges
369   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 200) ;
370   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
371   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
372   if(kPrintSettings) anacorrjet->Print("");
373   
374   // ### Correlation with hadrons
375   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
376   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
377   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
378   anacorrhadron->SetDebug(-1);
379   anacorrhadron->SwitchOffCaloPID();
380   anacorrhadron->SwitchOffFiducialCut();
381   anacorrhadron->SetPtCutRange(0.1,100);
382   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
383   anacorrhadron->SwitchOnSeveralUECalculation();
384   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
385   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
386   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
387   else  anacorrhadron->SwitchOffDataMC() ;
388   //if(calorimeter=="PHOS"){
389   //Correlate with particles in EMCAL
390   //anacorrhadron->SwitchOnCaloPID();
391   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
392   //}
393   //Set Histograms bins and ranges
394   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
395   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
396   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
397   if(kPrintSettings) anacorrhadron->Print("");
398   
399   // ### Correlation with hadrons
400   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
401   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
402   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
403   anacorrisohadron->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->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->SetDebug(-1);
455   anacorrhadronisopi0->SwitchOffCaloPID();
456   anacorrhadronisopi0->SwitchOffFiducialCut();
457   anacorrhadronisopi0->SetPtCutRange(0.1,100);
458   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
459   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
460   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
461   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
462   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
463   else  anacorrhadronisopi0->SwitchOffDataMC() ;
464   //if(calorimeter=="PHOS"){
465   //    //Correlate with particles in EMCAL
466   //    anacorrhadronpi0->SwitchOnCaloPID();
467   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
468   //}
469   //Set Histograms bins and ranges
470   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
471   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
472   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
473   if(kPrintSettings) anacorrhadronisopi0->Print("");
474   
475   
476   // #### Configure Maker ####
477   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
478   maker->SetReader(reader);//pointer to reader
479   maker->SetCaloUtils(cu); //pointer to calorimeter utils
480   Int_t n = 0;//Analysis number, order is important
481   // Particle selection analysis
482   maker->AddAnalysis(anaphoton,n++);
483   maker->AddAnalysis(anapi0,n++);
484   maker->AddAnalysis(anapi0ebe,n++);
485   maker->AddAnalysis(anaomegaToPi0Gamma,n++);  
486   if(calorimeter=="EMCAL")maker->AddAnalysis(anaelectron,n++);   
487   // Isolation analysis
488   maker->AddAnalysis(anaisol,n++);
489   maker->AddAnalysis(anacorrisohadron,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(anacorrhadronisopi0,n);
496   maker->SetAnaDebug(-1)  ;
497   maker->SwitchOnHistogramsMaker()  ;
498   if(data.Contains("delta")) maker->SwitchOffAODsMaker()  ;
499   else                       maker->SwitchOnAODsMaker()  ;
500         
501   if(kPrintSettings) maker->Print("");
502   
503   printf("======================== \n");
504   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
505   printf("======================== \n");
506   
507   // Create task
508   //===========================================================================
509   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
510   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
511   //task->SetDebugLevel(-1);
512   task->SelectCollisionCandidates();
513   task->SetAnalysisMaker(maker);
514   //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
515   mgr->AddTask(task);
516   
517   //Create containers
518   char name[128];
519   sprintf(name,"PartCorr_%s",calorimeter.Data());
520   cout<<"Name of task "<<name<<endl;
521   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
522   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
523   
524   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
525   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
526   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
527                                                                                                                          AliAnalysisManager::kOutputContainer, 
528                                                                                                                          Form("%s:PartCorr",outputfile.Data()));
529         
530   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
531                                                                                                                          AliAnalysisManager::kParamContainer, 
532                                                                                                                          Form("%s:PartCorrCuts",outputfile.Data()));
533         
534   // Create ONLY the output containers for the data produced by the task.
535   // Get and connect other common input/output containers via the manager as below
536   //==============================================================================
537   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
538   // AOD output slot will be used in a different way in future
539   if(!data.Contains("delta")) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
540   mgr->ConnectOutput (task, 1, cout_pc);
541   mgr->ConnectOutput (task, 2, cout_cuts);
542
543   return task;
544 }
545
546