Corrected bug in cluster selection with PID
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(TString data, TString calorimeter)
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 dataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20   
21    // Configure analysis
22    //===========================================================================
23   
24   //Reader
25   AliCaloTrackReader * reader = 0x0;
26   if(data=="AOD") reader = new AliCaloTrackAODReader();
27   else if(data=="ESD") reader = new AliCaloTrackESDReader();
28   else if(data=="MC") reader = new AliCaloTrackMCReader();
29   reader->SetDebug(-1);//10 for lots of messages
30   
31   //Min particle pT
32   reader->SetEMCALPtMin(0.5); 
33   reader->SetPHOSPtMin(0.5);
34   reader->SetCTSPtMin(0.2);
35   reader->Print("");
36   
37   // ##### Analysis algorithm settings ####
38
39   // --------------------
40   // --- Pi0 Analysis ---
41   // --------------------
42   
43   AliCaloPID * pid = new AliCaloPID();
44   pid->SetDispersionCut(1.5);
45   pid->SetTOFCut(5.e-9);
46   pid->SetDebug(-1);
47   pid->Print("");
48   
49   AliAnaPhoton *anaphoton1 = new AliAnaPhoton();
50   anaphoton1->SetDebug(-1); //10 for lots of messages
51   //anaphoton->SetMinPt(0.5);
52   anaphoton1->SetMinDistanceToBadChannel(2, 4, 5);
53   anaphoton1->SetCaloPID(pid);
54   anaphoton1->SetCalorimeter(calorimeter);
55   anaphoton1->SwitchOffDataMC() ;//Access MC stack and fill more histograms
56   anaphoton1->SwitchOffCaloPID();
57   anaphoton1->SwitchOffCaloPIDRecalculation(); //recommended for EMCAL
58   anaphoton1->SwitchOffFidutialCut();
59   anaphoton1->SetOutputAODName("PhotonsForPi0IM"+calorimeter);
60   anaphoton1->Print("");
61
62   AliAnaPi0 *anapi0 = new AliAnaPi0();
63   anapi0->SetDebug(-1);//10 for lots of messages
64   anapi0->SetInputAODName("PhotonsForPi0IM"+calorimeter);
65   anapi0->SetCaloPID(pid);
66   anapi0->SetCalorimeter(calorimeter);
67   anapi0->SwitchOnFidutialCut();
68   anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
69   anapi0->Print("");
70   
71   
72   // -------------------------------------------------
73   // --- Photon Isolation and Correlation Analysis ---
74   // -------------------------------------------------
75   
76   AliAnaPhoton *anaphoton2 = new AliAnaPhoton();
77   anaphoton2->SetDebug(-1); //10 for lots of messages
78   anaphoton2->SetMinPt(5);
79   anaphoton2->SetCaloPID(pid);
80   anaphoton2->SetCalorimeter(calorimeter);
81   anaphoton2->SwitchOffDataMC() ;//Access MC stack and fill more histograms
82   anaphoton2->SwitchOnCaloPID();
83   if(calorimeter == "EMCAL") anaphoton2->SwitchOnCaloPIDRecalculation();
84   anaphoton2->SwitchOffFidutialCut();
85   anaphoton2->SetOutputAODName("DirectPhotons"+calorimeter);
86   anaphoton2->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
87   anaphoton2->AddToHistogramsName("AnaPhotonCorr_");
88   anaphoton2->Print("");
89   // ### Isolation analysis ### 
90   
91   AliIsolationCut * ic = new AliIsolationCut();
92   ic->SetConeSize(0.5);
93   ic->SetPtThreshold(1.);
94   ic->SetICMethod(AliIsolationCut::kPtThresIC);
95   ic->Print("");
96   
97   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
98   anaisol->SetDebug(-1);
99   //anaisol->SetMinPt(5);
100   anaisol->SetInputAODName("DirectPhotons"+calorimeter);
101   anaisol->SetCalorimeter(calorimeter);
102   anaisol->SwitchOffDataMC() ;//Access MC stack and fill more histograms
103   //Select clusters with no pair, if both clusters with pi0 mass
104   anaisol->SwitchOffInvariantMass();
105   //anaisol->SetNeutralMesonSelection(nms);
106   //Do isolation cut
107   anaisol->SetIsolationCut(ic); 
108   //Do or not do isolation with previously produced AODs.
109   //No effect if use of SwitchOnSeveralIsolation()
110   anaisol->SwitchOffReIsolation();
111   //Multiple IC
112   anaisol->SwitchOffSeveralIsolation() ;
113   anaisol->Print("");
114   
115   // ### Correlation with Jet Finder AOD output
116   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
117   anacorrjet->SetInputAODName("DirectPhotons"+calorimeter);
118   anacorrjet->SwitchOffFidutialCut();
119   anacorrjet->SetDebug(-1);
120   anacorrjet->SetConeSize(1);  
121   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
122   anacorrjet->SetPtThresholdInCone(0.2);
123   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
124   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
125   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
126   anacorrjet->Print("");
127   
128   // ### Correlation with hadrons
129   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
130   anacorrhadron->SetInputAODName("DirectPhotons"+calorimeter);
131   anacorrhadron->SetOutputAODName("CorrelatedPi0s"+calorimeter);
132   anacorrhadron->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
133   anacorrhadron->SetDebug(-1);
134   anacorrhadron->SwitchOffCaloPID();
135   anacorrhadron->SwitchOffFidutialCut();
136   anacorrhadron->SetPtCutRange(1,100);
137   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
138   anacorrhadron->SelectIsolated(kTRUE); // do correlation with isolated photons
139         if(calorimeter=="PHOS"){
140     //Correlate with particles in EMCAL
141     anacorrhadron->SwitchOnCaloPID();
142     anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
143   }
144   anacorrhadron->Print("");
145   
146   // #### Configure Maker ####
147   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
148   maker->SetReader(reader);//pointer to reader
149   maker->AddAnalysis(anaphoton1,0);
150   maker->AddAnalysis(anapi0,1);
151   maker->AddAnalysis(anaphoton2,2);
152   maker->AddAnalysis(anaisol,3);
153   maker->AddAnalysis(anacorrjet,4);
154   maker->AddAnalysis(anacorrhadron,5);
155   maker->SetAnaDebug(-1)  ;
156   maker->SwitchOnHistogramsMaker()  ;
157   maker->SwitchOnAODsMaker()  ;
158   maker->Print("");
159   
160   printf("======================== \n");
161   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
162   printf("======================== \n");
163   
164    // Create task
165    //===========================================================================
166   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("PartCorr"+calorimeter);
167   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
168   //task->SetDebugLevel(-1);
169   task->SetAnalysisMaker(maker);                                
170   mgr->AddTask(task);
171   
172   char name[128];
173   sprintf(name,"PartCorr_%s",calorimeter.Data());
174 cout<<"Name of task "<<name<<endl;
175   AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
176                                                            AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
177   
178   // Create ONLY the output containers for the data produced by the task.
179   // Get and connect other common input/output containers via the manager as below
180   //==============================================================================
181   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
182   // AOD output slot will be used in a different way in future
183   mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
184   mgr->ConnectOutput (task, 1, cout_pc);
185   
186   return task;
187 }
188
189