]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
Reader: Add option to remove or not event with primary vertex not reconstructed
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr
2 (
3  TString inputDataType, 
4  TString calorimeter, 
5  Bool_t kPrintSettings = kTRUE,
6  Bool_t kSimulation = kFALSE, 
7  Bool_t outputAOD=kFALSE, 
8  Bool_t oldAOD=kFALSE,
9  TString period
10  ) {
11
12   // Creates a PartCorr task, configures it and adds it to the analysis manager.
13   
14   // Get the pointer to the existing analysis manager via the static access method.
15   //==============================================================================
16   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
17   if (!mgr) {
18     ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
19     return NULL;
20   }  
21  
22   Bool_t kUseKinematics = kFALSE; 
23   if(kSimulation) { 
24     kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE; 
25     if (!kUseKinematics && inputDataType == "AOD") kUseKinematics = kTRUE; //AOD primary should be available ... 
26   } 
27   
28   cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;
29   
30   // Configure analysis
31   //===========================================================================
32   
33   // *** Reader ***
34   AliCaloTrackReader * reader =0x0 ;
35   if(inputDataType.Contains("AOD")) reader = new AliCaloTrackAODReader();
36   else if(inputDataType=="ESD") reader = new AliCaloTrackESDReader();
37   else if(inputDataType=="MC" && inputDataType == "ESD") reader = new AliCaloTrackMCReader();
38   reader->SetDebug(-1);//10 for lots of messages
39   reader->SwitchOnCTS();
40   //reader->SetDeltaAODFileName("");
41   //if(!kSimulation) reader->SetFiredTriggerClassName("CINT1B-ABCE-NOPF-ALL");
42   if(calorimeter == "EMCAL") {
43     reader->SwitchOnEMCALCells();  
44     reader->SwitchOnEMCAL();
45   }
46   if(calorimeter == "PHOS") { 
47     reader->SwitchOnPHOSCells();  
48     reader->SwitchOnPHOS();
49   }
50   
51   // for case inputDataType="deltaAOD", no need to fill the EMCAL/PHOS cluster lists
52   if(inputDataType.Contains("delta")){
53     reader->SwitchOffEMCAL();
54     reader->SwitchOffPHOS();
55     reader->SwitchOffEMCALCells(); 
56     reader->SwitchOffPHOSCells(); 
57   }
58   
59   if(kUseKinematics){
60     if(inputDataType == "ESD"){
61       reader->SwitchOnStack();          
62       reader->SwitchOffAODMCParticles(); 
63     }
64     else if(inputDataType == "AOD"){
65       reader->SwitchOffStack();          
66       reader->SwitchOnAODMCParticles(); 
67     }
68   }
69
70   //-----------------------------------------------------------------
71   // Switch on cluster energy smearing 
72   //  -> SIMULATION
73   //  -> EMCAL
74   //-----------------------------------------------------------------
75
76   if (kSimulation && calorimeter == "EMCAL") {
77     //switch on cluster energy smearing
78     reader->SwitchOnClusterEnergySmearing();
79     reader->SetSmearingParameters(0,0.07);
80     reader->SetSmearingParameters(0,0.00);
81     reader->SetSmearingParameters(0,0.00);
82   }
83
84   
85   //-----------------------------------------------------------------
86   // Z vertex cut
87   reader->SetZvertexCut(10.);
88   //-----------------------------------------------------------------
89
90   //-----------------------------------------------------------------
91   // Min particle pT
92   //-----------------------------------------------------------------
93   reader->SetEMCALPtMin(0.3); 
94   reader->SetPHOSPtMin(0.3);
95   reader->SetCTSPtMin(0.1);
96
97   if(outputAOD)      reader->SwitchOnWriteDeltaAOD()  ;
98   if(oldAOD)         reader->SwitchOnOldAODs();
99   if(kPrintSettings) reader->Print("");
100   
101
102   //-----------------------------------------------------------------
103   // Bad cluster removal
104   //  -> REAL DATA ONLY
105   //-----------------------------------------------------------------
106   reader->SwitchOnSuspiciousClustersRemoval();
107
108
109   // *** Calorimeters Utils     ***
110   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
111
112   //-----------------------------------------------------------------
113   // Non-linearity corrections 
114   //  -> REAL DATA AND SIMULATION
115   //  -> EMCAL
116   //-----------------------------------------------------------------
117   if (calorimeter == "EMCAL") {
118     cu->SwitchOnCorrectClusterLinearity();
119     if (!kSimulation) {
120       cu->GetEMCALRecoUtils()->SetNonLinearityFunction(AliEMCALRecoUtils::kBeamTestCorrected);
121       cu->GetEMCALRecoUtils()->SetNonLinearityParam(0,0.976       ) ;
122       cu->GetEMCALRecoUtils()->SetNonLinearityParam(1,9.83529e-01 ) ;
123       cu->GetEMCALRecoUtils()->SetNonLinearityParam(2,-1.84235e+02) ; 
124       cu->GetEMCALRecoUtils()->SetNonLinearityParam(3,-2.05019e+00) ;
125       cu->GetEMCALRecoUtils()->SetNonLinearityParam(4,-5.89423e+00) ;
126     }
127     else              {
128       cu->GetEMCALRecoUtils()->SetNonLinearityFunction(AliEMCALRecoUtils::kPi0MC);
129       cu->GetEMCALRecoUtils()->SetNonLinearityParam(0,1.001   ) ;
130       cu->GetEMCALRecoUtils()->SetNonLinearityParam(1,-0.01264) ;
131       cu->GetEMCALRecoUtils()->SetNonLinearityParam(2,-0.03632) ;
132       cu->GetEMCALRecoUtils()->SetNonLinearityParam(3,0.1798  ) ;
133       cu->GetEMCALRecoUtils()->SetNonLinearityParam(4,-0.522  ) ;
134     }
135   }
136   
137   //-----------------------------------------------------------------
138   //  Remove clusters close to borders, 
139   //  at least max energy cell is 1 cell away 
140   //-----------------------------------------------------------------
141   cu->SetNumberOfCellsFromEMCALBorder(1);
142   cu->SetNumberOfCellsFromPHOSBorder(2);
143   
144   
145   //-----------------------------------------------------------------
146   // Remove EMCAL hottest channels 
147   //  -> REAL DATA AND SIMULATION
148   //  -> EMCAL
149   // Recover the file from alien  
150   //   /alice/cern.ch/user/g/gconesab/BadChannelsDB
151   //-----------------------------------------------------------------
152   if (calorimeter == "EMCAL") {
153     cu->SwitchOnBadChannelsRemoval();
154     cu->SwitchOnDistToBadChannelRecalculation();
155     TFile * fbad = new TFile("BadChannels.root","read");
156     TH2I * hbad0 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod0");
157     TH2I * hbad1 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod1");
158     TH2I * hbad2 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod2");
159     TH2I * hbad3 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod3");
160     cu->SetEMCALChannelStatusMap(0,hbad0);
161     cu->SetEMCALChannelStatusMap(1,hbad1);
162     cu->SetEMCALChannelStatusMap(2,hbad2);
163     cu->SetEMCALChannelStatusMap(3,hbad3);
164   }
165   
166   
167   //-----------------------------------------------------------------
168   // Misalignment + recalculate position 
169   //  -> REAL DATA and SIMULATION
170   //  -> EMCAL
171   //-----------------------------------------------------------------
172   if (calorimeter == "EMCAL") {
173     cu->SetEMCALGeometryName("EMCAL_FIRSTYEARV1");
174     cu->GetEMCALRecoUtils()->SetParticleType(AliEMCALRecoUtils::kPhoton);
175     cu->GetEMCALRecoUtils()->SetW0(4.5);      
176     cu->GetEMCALRecoUtils()->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
177     cu->SwitchOnLoadOwnEMCALGeometryMatrices();
178     TGeoHMatrix *matrix[4];
179     
180     double rotationMatrix[4][9] = {-0.014587, -0.999892, -0.002031, 0.999892, -0.014591,  0.001979, -0.002009, -0.002002,  0.999996,
181                                    -0.014587,  0.999892,  0.002031, 0.999892,  0.014591, -0.001979, -0.002009,  0.002002, -0.999996,
182                                    -0.345864, -0.938278, -0.003412, 0.938276, -0.345874,  0.003010, -0.004004, -0.002161,  0.999990,
183                                    -0.345861,  0.938280,  0.003412, 0.938276,  0.345874, -0.003010, -0.004004,  0.002161, -0.999990};
184     
185     double translationMatrix[4][3] = {0.351659,    447.576446,  176.269742,
186                                       1.062577,    446.893974, -173.728870,
187                                       -154.213287, 419.306156,  176.753692,
188                                       -153.018950, 418.623681, -173.243605};
189     for(int j=0; j<4; j++)
190       {
191         matrix[j] = new TGeoHMatrix();
192         matrix[j]->SetRotation(rotationMatrix[j]);
193         matrix[j]->SetTranslation(translationMatrix[j]);
194         matrix[j]->Print();
195         cu->SetEMCALGeometryMatrixInSM(matrix[j],j);
196       }
197     cu->SwitchOnRecalculateClusterTrackMatching();
198   }
199   
200   //-----------------------------------------------------------------
201   // Time dependent corrections 
202   //  -> REAL_DATA ONLY
203   //  -> EMCAL
204   //  Recover file from alien  
205   //  /alice/cern.ch/user/g/gconesab/TimeDepCorrectionDB
206   //-----------------------------------------------------------------
207   if (!kSimulation && calorimeter == "EMCAL") {
208     cu->GetEMCALRecoUtils()->SwitchOnTimeDepCorrection();
209     char cmd[200] ;
210     sprintf(cmd, ".!tar xvfz CorrectionFiles.tgz >& /dev/null") ;
211     gROOT->ProcessLine(cmd) ;
212   }
213   
214   
215   //------------------------------------------------------------------------
216   //     Recalibration factors 
217   //       -> REAL DATA ONLY
218   //       -> EMCAL
219   //     Recover the file from alien for LHC10d pass2
220   //     /alice/cern.ch/user/g/gconesab/RecalDB/december2010        -> LHC10d pass2
221   //     /alice/cern.ch/user/g/gconesab/RecalDB/summer_december2010 -> LHC10e pass1
222   //  ******
223   //     For other periods/passes, see
224   //     https://twiki.cern.ch/twiki/bin/view/ALICE/EMCalOffline#Summary_of_Calibration_and_Align
225   //------------------------------------------------------------------------
226   
227   if (calorimeter == "EMCAL") {
228     cu->SwitchOnRecalibration();
229     TFile* f = 0x0 ;
230     if (!kSimulation) {
231       if      (period == "LHC10d") f = new TFile("RecalibrationFactors_LHC10d.root","read");
232       else if (period == "LHC10e") f = new TFile("RecalibrationFactors_LHC10e.root","read");
233       else                         Fatal("AddTaskPartCorr","run period not supported");
234     }
235     else {
236       f = new TFile("DecalibrationFactors.root","read");
237     }
238     if (!f || !f->IsOpen()) Fatal("AddTaskPartCorr","Re(De)-calibration file not found");
239
240     Info("AddTaskPartCorr",Form("Using calibration files for period %s",period.Data()));
241
242     TH2F * h0 = (TH2F*)f->Get("EMCALRecalFactors_SM0");
243     TH2F * h1 = (TH2F*)f->Get("EMCALRecalFactors_SM1");
244     TH2F * h2 = (TH2F*)f->Get("EMCALRecalFactors_SM2");
245     TH2F * h3 = (TH2F*)f->Get("EMCALRecalFactors_SM3");
246     cu->SetEMCALChannelRecalibrationFactors(0,h0);
247     cu->SetEMCALChannelRecalibrationFactors(1,h1);
248     cu->SetEMCALChannelRecalibrationFactors(2,h2);
249     cu->SetEMCALChannelRecalibrationFactors(3,h3);
250   }
251
252   cu->SetDebug(-1);
253
254
255   // ##### Analysis algorithm settings ####
256   
257   // -------------------------------------------------
258   // --- Photon/Pi0/Omega/Electron Analysis ---
259   // -------------------------------------------------
260   
261   AliAnaPhoton *anaphoton = new AliAnaPhoton();
262   anaphoton->SetDebug(-1); //10 for lots of messages
263   //settings for different multiplicity analysis
264   anaphoton->SwitchOffEventSelection() ;
265   //anaphoton->SetMultiplicity(80, 120);
266
267   if(calorimeter == "PHOS"){
268     anaphoton->SetNCellCut(2);
269     anaphoton->SetMinPt(0.);
270     anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
271   }
272   else {//EMCAL
273     anaphoton->SetNCellCut(1);
274     anaphoton->SetMinPt(0.); 
275     if(!kUseKinematics) anaphoton->SetTimeCut(400,900);// Time window of [400-900] ns
276     anaphoton->SetMinDistanceToBadChannel(4, 5, 10);
277   }
278   anaphoton->SetCalorimeter(calorimeter);
279   if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
280   else  anaphoton->SwitchOffDataMC() ;
281   anaphoton->SwitchOffCaloPID();
282   anaphoton->SwitchOffFiducialCut();
283   if(kSimulation){
284     anaphoton->SwitchOnFiducialCut();
285     AliFiducialCut * fidCut1stYear = anaphoton->GetFiducialCut();
286     fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
287     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
288     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
289     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
290     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
291   }
292   
293   if(!inputDataType.Contains("delta")) {
294     anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
295     anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
296   }
297   else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
298   anaphoton->AddToHistogramsName("AnaPhotonCorr_");
299   //Set Histograms bins and ranges
300   anaphoton->SetHistoPtRangeAndNBins(0, 20, 200) ;
301   if(kPrintSettings) anaphoton->Print("");
302   
303   // -----------------------------------
304   // --- Pi0 Invariant Mass Analysis ---
305   // -----------------------------------
306   
307   AliAnaPi0 *anapi0 = new AliAnaPi0();
308   anapi0->SetDebug(-1);//10 for lots of messages
309   anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
310   anapi0->SetCalorimeter(calorimeter);
311   anapi0->SwitchOnMultipleCutAnalysis(); 
312   if(kSimulation){
313     anapi0->SwitchOnFiducialCut();
314     AliFiducialCut * fidCut1stYear = anapi0->GetFiducialCut();
315     fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
316     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
317     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
318     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
319     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
320   }     
321
322   //settings for pp collision
323   anapi0->SwitchOnOwnMix();
324   anapi0->SwitchOnEventSelection() ;
325   anapi0->SetNCentrBin(1);
326   //anapi0->SetMultiplicity(80, 120);
327   anapi0->SetMultiBin(1);  
328   if(kUseKinematics)anapi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
329   else anapi0->SwitchOffDataMC() ;
330   if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
331   else  anapi0->SetNumberOfModules(4); //EMCAL first year
332   anapi0->SetHistoPtRangeAndNBins(0, 20, 40) ;
333   //anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
334   //anapi0->SetHistoEtaRangeAndNBins(-0.8, 0.8, 200) ;
335   anapi0->SetHistoMassRangeAndNBins(0., 0.9, 300) ;
336   anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
337   anapi0->SetHistoTrackMultiplicityRangeAndNBins(0, 200, 20); 
338
339   if(kPrintSettings) anapi0->Print("");
340         
341   //---------------------------  
342   //Pi0, event by event
343   //---------------------------  
344   
345   AliAnaPi0EbE *anapi0ebe = new AliAnaPi0EbE();
346   anapi0ebe->SwitchOffEventSelection() ;
347   //anapi0ebe->SetMultiplicity(80, 120);
348   anapi0ebe->SetMultiBin(1);  
349   anapi0ebe->SetDebug(-1);//10 for lots of messages
350   anapi0ebe->SetAnalysisType(AliAnaPi0EbE::kIMCalo);
351   anapi0ebe->SetMinPt(0);
352   anapi0ebe->SetCalorimeter(calorimeter);
353   anapi0ebe->SetInputAODName(Form("Photons%s",calorimeter.Data()));
354   if(!inputDataType.Contains("delta")) {
355     anapi0ebe->SetOutputAODName(Form("Pi0s%s",calorimeter.Data()));
356     anapi0ebe->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
357   }
358   else  anapi0ebe->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
359   
360   if(kUseKinematics) anapi0ebe->SwitchOnDataMC() ;//Access MC stack and fill more histograms
361   else  anapi0ebe->SwitchOffDataMC() ;  
362   
363   AliNeutralMesonSelection *nms = anapi0ebe->GetNeutralMesonSelection();
364   nms->SetInvMassCutRange(0.08, 0.18)     ;
365   nms->KeepNeutralMesonSelectionHistos(kTRUE);
366   //Set Histrograms bins and ranges
367   if(calorimeter=="EMCAL" ){
368     nms->SetHistoERangeAndNBins(0, 15, 150) ;  
369     anapi0ebe->SetHistoPtRangeAndNBins(0, 30, 60) ;
370   }
371   else{
372     nms->SetHistoERangeAndNBins(0, 30, 200) ;  
373     anapi0ebe->SetHistoPtRangeAndNBins(0, 30, 100) ;
374   }
375   //      nms->SetHistoPtRangeAndNBins(0, 50, 100) ;
376   //      nms->SetHistoAngleRangeAndNBins(0, 0.3, 100) ;
377   //      nsm->SetHistoIMRangeAndNBins(0, 0.4, 100) ;  
378   //Set Histrograms bins and ranges
379   //      anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
380   //      anapi0->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
381   if(kPrintSettings) anapi0ebe->Print("");
382         
383   //-------------------------------------
384   //*** analysis the omega->pi0+gamma ***
385   //------------------------------------
386   AliAnaOmegaToPi0Gamma *anaomegaToPi0Gamma = new AliAnaOmegaToPi0Gamma();
387   anaomegaToPi0Gamma->SetDebug(-1);//10 for lots of messages
388   anaomegaToPi0Gamma->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
389   anaomegaToPi0Gamma->SetInputAODPhotonName(Form("Photons%s",calorimeter.Data()));
390   anaomegaToPi0Gamma->SetNPID(1);
391   anaomegaToPi0Gamma->SetNVtxZ(1);
392   anaomegaToPi0Gamma->SetNEventsMixed(4);
393   if(calorimeter=="PHOS")
394     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.008); // PHOS
395   else if(calorimeter=="EMCAL")
396     anaomegaToPi0Gamma->SetPi0MassPeakWidthCut(0.012); // EMCAL 
397   anaomegaToPi0Gamma->SetHistoPtRangeAndNBins(0, 20, 100) ;
398   anaomegaToPi0Gamma->SetHistoMassRangeAndNBins(0, 1, 100) ;
399   anaomegaToPi0Gamma->SetPi0OverOmegaPtCut(0.8);
400   anaomegaToPi0Gamma->SetGammaOverOmegaPtCut(0.2);
401   if(kUseKinematics) anaomegaToPi0Gamma->SwitchOnDataMC() ;//Access MC stack and fill more histograms
402   else anaomegaToPi0Gamma->SwitchOffDataMC() ;//Access MC stack and fill more histograms
403   anaomegaToPi0Gamma->AddToHistogramsName(Form("AnaOmegaToPi0Gamma%s_",calorimeter.Data()));
404   if(kPrintSettings)   anaomegaToPi0Gamma->Print("");
405         
406         
407 //  //---------------------------------------------------------------------
408 //  // Electron/btag
409 //  //---------------------------------------------------------------------
410 //  if(calorimeter=="EMCAL"){
411 //    
412 //    AliAnaBtag *anabtag = new AliAnaBtag();
413 //    anabtag->SetDebug(-1); //10 for lots of messages
414 //    if(kUseKinematics){
415 //      anabtag->SwitchOnDataMC();
416 //      anabtag->SetMinPt(1.);
417 //    }
418 //    anabtag->SetOutputAODName("ElectronsEMCAL");
419 //    anabtag->SetOutputAODClassName("AliAODPWG4Particle");
420 //    //anabtag->SetHistoPtRangeAndNBins(0, 100, 100) ;
421 //    //anabtag->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
422 //    //anabtag->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
423 //    if(kPrintSettings)anabtag->Print("");
424 //  }
425   
426   //==================================
427   // ### Isolation analysis ### 
428   //=================================
429   //Photon
430   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
431   anaisol->SetDebug(-1);
432   anaisol->SetMinPt(0);
433   anaisol->SetInputAODName(Form("Photons%s",calorimeter.Data()));
434   anaisol->SetAODObjArrayName("ICPhoton"); 
435   anaisol->SetCalorimeter(calorimeter);
436   if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
437   else  anaisol->SwitchOffDataMC() ;
438   //Select clusters with no pair, if both clusters with pi0 mass
439   anaisol->SwitchOffInvariantMass();
440   //Do isolation cut
441   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
442   ic->SetConeSize(0.4);
443   ic->SetPtThreshold(0.7);
444   ic->SetPtFraction(0.1);
445   ic->SetSumPtThreshold(1.0) ;
446   ic->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
447   ic->SetICMethod(AliIsolationCut::kSumPtFracIC);
448   if(kPrintSettings) ic->Print("");
449   
450   //Do or not do isolation with previously produced AODs.
451   //No effect if use of SwitchOnSeveralIsolation()
452   anaisol->SwitchOffReIsolation();
453   //Multiple IC
454   anaisol->SwitchOffSeveralIsolation() ;
455   //Set Histograms bins and ranges
456   anaisol->SetHistoPtRangeAndNBins(0, 50, 200) ;
457   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
458   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
459   anaisol->AddToHistogramsName("AnaIsolPhoton_");
460   if(kPrintSettings) anaisol->Print("");
461   
462   //Pi0
463   AliAnaParticleIsolation *anaisolpi0 = new AliAnaParticleIsolation();
464   anaisolpi0->SetDebug(-1);
465   anaisolpi0->SetMinPt(0);
466   anaisolpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
467   anaisolpi0->AddToHistogramsName("AnaIsolPi0_");
468   anaisolpi0->SetAODObjArrayName("ICPi0"); 
469   anaisolpi0->SetCalorimeter(calorimeter);
470   if(kUseKinematics) anaisolpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
471   else  anaisolpi0->SwitchOffDataMC() ;
472   //Select clusters with no pair, if both clusters with pi0 mass
473   anaisolpi0->SwitchOffInvariantMass();
474   //Do isolation cut
475   AliIsolationCut * ic2 =  anaisolpi0->GetIsolationCut();       
476   ic2->SetConeSize(0.4);
477   ic2->SetPtThreshold(0.7);
478   ic2->SetPtFraction(0.1);
479   ic2->SetSumPtThreshold(1.0) ;
480   ic2->SetICMethod(AliIsolationCut::kSumPtFracIC);
481   ic2->SetParticleTypeInCone(AliIsolationCut::kOnlyCharged);
482   if(kPrintSettings) ic2->Print("");
483   //Do or not do isolation with previously produced AODs.
484   //No effect if use of SwitchOnSeveralIsolation()
485   anaisolpi0->SwitchOffReIsolation();
486   //Multiple IC
487   anaisolpi0->SwitchOffSeveralIsolation() ;
488   //Set Histograms bins and ranges
489   anaisolpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
490   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
491   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
492   if(kPrintSettings) anaisolpi0->Print("");
493         
494   //===========================
495   //Correlation analysis
496   //===========================
497         
498   // ### Correlation with Jet Finder AOD output
499   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
500   anacorrjet->SetInputAODName(Form("Photons%s",calorimeter.Data()));
501   anacorrjet->SwitchOffFiducialCut();
502   anacorrjet->SetDebug(-1);
503   anacorrjet->SetConeSize(1);  
504   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
505   anacorrjet->SetPtThresholdInCone(0.2);
506   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
507   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
508   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
509   //Set Histograms bins and ranges
510   anacorrjet->SetHistoPtRangeAndNBins(0, 50, 200) ;
511   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
512   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
513   if(kPrintSettings) anacorrjet->Print("");
514   
515   // ### Correlation with hadrons
516   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
517   anacorrhadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
518   anacorrhadron->AddToHistogramsName("AnaHadronCorrPhoton_");
519   anacorrhadron->SetAODObjArrayName("PhotonHadronCorr"); 
520   anacorrhadron->SetDebug(-1);
521   anacorrhadron->SwitchOffCaloPID();
522   if(kSimulation){
523     anacorrhadron->SwitchOnFiducialCut();
524     AliFiducialCut * fidCut1stYear = anacorrhadron->GetFiducialCut();
525     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
526     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
527     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
528     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
529     fidCut1stYear->DoCTSFiducialCut(kTRUE) ;
530     fidCut1stYear->SetSimpleCTSFiducialCut(0.8,0.,360.);    
531   }
532   anacorrhadron->SwitchOnDecayCorr();
533   anacorrhadron->SetMultiBin(1);
534   anacorrhadron->SwitchOffNeutralCorr();
535   anacorrhadron->SwitchOffEventSelection();
536   anacorrhadron->SetPtCutRange(0.1,100);
537   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
538   anacorrhadron->SwitchOnSeveralUECalculation();
539   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
540   anacorrhadron->SelectIsolated(kFALSE); // do correlation with isolated photons
541   if(kUseKinematics) anacorrhadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
542   else  anacorrhadron->SwitchOffDataMC() ;
543   //if(calorimeter=="PHOS"){
544   //Correlate with particles in EMCAL
545   //anacorrhadron->SwitchOnCaloPID();
546   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
547   //}
548   //Set Histograms bins and ranges
549   anacorrhadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
550   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
551   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
552   if(kPrintSettings) anacorrhadron->Print("");
553   
554   // ### Correlation with hadrons
555   AliAnaParticleHadronCorrelation *anacorrisohadron = new AliAnaParticleHadronCorrelation();
556   anacorrisohadron->SetInputAODName(Form("Photons%s",calorimeter.Data()));
557   anacorrisohadron->AddToHistogramsName("AnaHadronCorrIsoPhoton_");
558   anacorrisohadron->SetAODObjArrayName("IsoPhotonHadronCorr"); 
559   anacorrisohadron->SetDebug(-1);
560   anacorrisohadron->SwitchOffCaloPID();
561   if(kSimulation){
562     anacorrisohadron->SwitchOnFiducialCut();
563     AliFiducialCut * fidCut1stYear = anacorrisohadron->GetFiducialCut();
564     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
565     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
566     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
567     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
568     fidCut1stYear->DoCTSFiducialCut(kTRUE) ;
569     fidCut1stYear->SetSimpleCTSFiducialCut(0.8,0.,360.);    
570   }
571   anacorrisohadron->SwitchOnDecayCorr();
572   anacorrisohadron->SetMultiBin(1);
573   anacorrisohadron->SwitchOffNeutralCorr();
574   anacorrisohadron->SwitchOffEventSelection();
575   anacorrisohadron->SetPtCutRange(0.1,100);
576   anacorrisohadron->SetDeltaPhiCutRange(1.5,4.5);
577   anacorrisohadron->SwitchOnSeveralUECalculation();
578   anacorrisohadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
579   anacorrisohadron->SelectIsolated(kTRUE); // do correlation with isolated photons
580   if(kUseKinematics) anacorrisohadron->SwitchOnDataMC() ;//Access MC stack and fill more histograms
581   else  anacorrisohadron->SwitchOffDataMC() ;
582   //if(calorimeter=="PHOS"){
583   //Correlate with particles in EMCAL
584   //anacorrhadron->SwitchOnCaloPID();
585   //anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
586   //}
587   //Set Histograms bins and ranges
588   anacorrisohadron->SetHistoPtRangeAndNBins(0, 50, 200) ;
589   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
590   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
591   if(kPrintSettings) anacorrisohadron->Print("");
592   
593   
594   // ### Pi0 Correlation with hadrons, not isolated
595   AliAnaParticleHadronCorrelation *anacorrhadronpi0 = new AliAnaParticleHadronCorrelation();
596   anacorrhadronpi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
597   anacorrhadronpi0->AddToHistogramsName("AnaHadronCorrPi0_");
598   anacorrhadronpi0->SetAODObjArrayName("Pi0HadronCorr"); 
599   anacorrhadronpi0->SetDebug(-1);
600   anacorrhadronpi0->SwitchOffCaloPID();
601   if(kSimulation){
602     anacorrhadronpi0->SwitchOnFiducialCut();
603     AliFiducialCut * fidCut1stYear = anacorrhadronpi0->GetFiducialCut();
604     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
605     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
606     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
607     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
608     fidCut1stYear->DoCTSFiducialCut(kTRUE) ;
609     fidCut1stYear->SetSimpleCTSFiducialCut(0.8,0.,360.);    
610   }
611   anacorrhadronpi0->SwitchOnDecayCorr();
612   anacorrhadronpi0->SetMultiBin(1);
613   anacorrhadronpi0->SwitchOffNeutralCorr();
614   anacorrhadronpi0->SwitchOffEventSelection();
615   anacorrhadronpi0->SetPtCutRange(0.1,100);
616   anacorrhadronpi0->SetDeltaPhiCutRange(1.5,4.5);
617   anacorrhadronpi0->SelectIsolated(kFALSE); // do correlation with non isolated pi0
618   anacorrhadronpi0->SwitchOnSeveralUECalculation();
619   anacorrhadronpi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
620   if(kUseKinematics) anacorrhadronpi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
621   else  anacorrhadronpi0->SwitchOffDataMC() ;
622   //if(calorimeter=="PHOS"){
623   //    //Correlate with particles in EMCAL
624   //    anacorrhadronpi0->SwitchOnCaloPID();
625   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
626   //}
627   //Set Histograms bins and ranges
628   anacorrhadronpi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
629   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
630   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
631   if(kPrintSettings) anacorrhadronpi0->Print("");
632   
633   // ### Pi0 Correlation with hadrons, isolated
634   AliAnaParticleHadronCorrelation *anacorrhadronisopi0 = new AliAnaParticleHadronCorrelation();
635   anacorrhadronisopi0->SetInputAODName(Form("Pi0s%s",calorimeter.Data()));
636   anacorrhadronisopi0->AddToHistogramsName("AnaHadronCorrIsoPi0_");
637   anacorrhadronisopi0->SetAODObjArrayName("IsoPi0HadronCorr"); 
638   anacorrhadronisopi0->SetDebug(-1);
639   anacorrhadronisopi0->SwitchOffCaloPID();
640   if(kSimulation){
641     anacorrhadronisopi0->SwitchOnFiducialCut();
642     AliFiducialCut * fidCut1stYear = anacorrhadronisopi0->GetFiducialCut();
643     fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
644     fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
645     fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
646     fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
647     fidCut1stYear->DoCTSFiducialCut(kTRUE) ;
648     fidCut1stYear->SetSimpleCTSFiducialCut(0.8,0.,360.);    
649   }
650   anacorrhadronisopi0->SwitchOnDecayCorr();
651   anacorrhadronisopi0->SetMultiBin(1);
652   anacorrhadronisopi0->SwitchOffNeutralCorr();
653   anacorrhadronisopi0->SwitchOffEventSelection();
654   anacorrhadronisopi0->SetPtCutRange(0.1,100);
655   anacorrhadronisopi0->SetDeltaPhiCutRange(1.5,4.5);
656   anacorrhadronisopi0->SelectIsolated(kTRUE); // do correlation with isolated pi0
657   anacorrhadronisopi0->SwitchOnSeveralUECalculation();
658   anacorrhadronisopi0->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
659   if(kUseKinematics) anacorrhadronisopi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
660   else  anacorrhadronisopi0->SwitchOffDataMC() ;
661   //if(calorimeter=="PHOS"){
662   //    //Correlate with particles in EMCAL
663   //    anacorrhadronpi0->SwitchOnCaloPID();
664   //    anacorrhadronpi0->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
665   //}
666   //Set Histograms bins and ranges
667   anacorrhadronisopi0->SetHistoPtRangeAndNBins(0, 50, 200) ;
668   //      ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
669   //      ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
670   if(kPrintSettings) anacorrhadronisopi0->Print("");
671   
672   
673   // #### Configure Maker ####
674   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
675   maker->SetReader(reader);//pointer to reader
676   maker->SetCaloUtils(cu); //pointer to calorimeter utils
677
678
679   Int_t n = 0;//Analysis number, order is important
680   // Particle selection analysis
681   maker->AddAnalysis(anaphoton,n++);
682   //maker->AddAnalysis(anapi0,n++);
683   maker->AddAnalysis(anapi0ebe,n++);
684 //   maker->AddAnalysis(anaomegaToPi0Gamma,n++);  
685   //if(calorimeter=="EMCAL")maker->AddAnalysis(anabtag,n++);   
686   // Isolation analysis
687   maker->AddAnalysis(anaisol,n++);
688 //   maker->AddAnalysis(anaisolpi0,n++);
689   // Correlation analysis
690 //   maker->AddAnalysis(anacorrjet,n++);
691   maker->AddAnalysis(anacorrhadron,n++);
692 //   maker->AddAnalysis(anacorrhadronpi0,n++);
693 //   maker->AddAnalysis(anacorrisohadron,n++);
694 //   maker->AddAnalysis(anacorrhadronisopi0,n);
695   maker->SetAnaDebug(0)  ;
696   maker->SwitchOnHistogramsMaker()  ;
697   if(inputDataType.Contains("delta")) maker->SwitchOffAODsMaker()  ;
698   else                                maker->SwitchOnAODsMaker()  ;
699         
700   if(kPrintSettings) maker->Print("");
701
702   printf("======================== \n");
703   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
704   printf("======================== \n");
705   
706   // Create task
707   //===========================================================================
708   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
709   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
710   //task->SetDebugLevel(-1);
711   task->SetAnalysisMaker(maker);
712   if(inputDataType=="ESD" && !kSimulation) task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
713   mgr->AddTask(task);
714   
715   //Create containers
716   char name[128];
717   sprintf(name,"PartCorr_%s",calorimeter.Data());
718   cout<<"Name of task "<<name<<endl;
719   //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
720   //                                       AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
721   
722   TString outputfile = AliAnalysisManager::GetCommonFileName();
723
724   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()),  TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
725   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(calorimeter.Data(), TList::Class(), 
726                                                              AliAnalysisManager::kOutputContainer, 
727                                                              Form("%s:PartCorr",outputfile.Data()));
728         
729   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(), 
730                                                              AliAnalysisManager::kParamContainer, 
731                                                              Form("%s:PartCorrCuts",outputfile.Data()));
732   
733   // Create ONLY the output containers for the data produced by the task.
734   // Get and connect other common input/output containers via the manager as below
735   //==============================================================================
736   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
737   // AOD output slot will be used in a different way in future
738   if(!inputDataType.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
739   mgr->ConnectOutput (task, 1, cout_pc);
740   mgr->ConnectOutput (task, 2, cout_cuts);
741
742   return task;
743 }