After last changes in the reader default setting for filling input of detectors is...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
CommitLineData
4a55403a 1AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(TString data, TString calorimeter, Bool_t kUseKinematics = kFALSE, Bool_t kPrintSettings = kFALSE)
90eb3a19 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 }
4a55403a 19 TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20 //cout<<"DATA TYPE :: "<<inputDataType<<endl;
21 // inputDataType: data managed by the input handler
22 // data: can be same as one managed by input handler, or the output AOD created by the filter. By default use AOD
23
90eb3a19 24 // Configure analysis
25 //===========================================================================
26
27 //Reader
28 AliCaloTrackReader * reader = 0x0;
29 if(data=="AOD") reader = new AliCaloTrackAODReader();
30 else if(data=="ESD") reader = new AliCaloTrackESDReader();
4a55403a 31 else if(data=="MC" && dataType == "ESD") reader = new AliCaloTrackMCReader();
90eb3a19 32 reader->SetDebug(-1);//10 for lots of messages
911e17cd 33 reader->SwitchOnCTS();
34 if(calorimeter == "EMCAL") {
35 reader->SwitchOnEMCALCells();
36 reader->SwitchOnEMCAL();
37 }
38 if(calorimeter == "PHOS") {
39 reader->SwitchOnPHOSCells();
40 reader->SwitchOnPHOS();
41 }
4a55403a 42 if(kUseKinematics){
43 if(inputDataType == "ESD"){
44 reader->SwitchOnStack();
45 reader->SwitchOffAODMCParticles();
46 }
47 else if(inputDataType == "AOD"){
48 reader->SwitchOffStack();
49 reader->SwitchOnAODMCParticles();
50 }
51 }
52
90eb3a19 53 //Min particle pT
4865e325 54 reader->SetEMCALPtMin(0.2);
55 reader->SetPHOSPtMin(0.2);
a3aebfff 56 reader->SetCTSPtMin(0.2);
4a55403a 57 if(kPrintSettings) reader->Print("");
d0b67781 58
a3aebfff 59 // ##### Analysis algorithm settings ####
60
61 // --------------------
62 // --- Pi0 Analysis ---
63 // --------------------
90eb3a19 64
65 AliCaloPID * pid = new AliCaloPID();
66 pid->SetDispersionCut(1.5);
67 pid->SetTOFCut(5.e-9);
68 pid->SetDebug(-1);
4a55403a 69 if(kPrintSettings) pid->Print("");
4865e325 70
71 AliFidutialCut * fidCut = new AliFidutialCut();
72 fidCut->DoCTSFidutialCut(kFALSE) ;
73 fidCut->DoEMCALFidutialCut(kTRUE) ;
74 fidCut->DoPHOSFidutialCut(kTRUE) ;
75
76 AliAnaCalorimeterQA *qa = new AliAnaCalorimeterQA();
77 qa->SetDebug(-1); //10 for lots of messages
78 qa->SetCalorimeter(calorimeter);
8d4bd2e1 79 if(kUseKinematics && inputDataType!="AOD") qa->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
4a55403a 80 else qa->SwitchOffDataMC() ;
d0b67781 81 //qa->AddToHistogramsName(Form("AnaCaloQA_%s",calorimeter.Data()));
82 qa->AddToHistogramsName("AnaCaloQA_");
4865e325 83 qa->SetFidutialCut(fidCut);
84 qa->SwitchOnFidutialCut();
4a55403a 85 if(kPrintSettings) qa->Print("");
86
87 AliFidutialCut * fidCut1stYear = new AliFidutialCut();
88 fidCut1stYear->DoCTSFidutialCut(kFALSE) ;
89 fidCut1stYear->DoEMCALFidutialCut(kTRUE) ;
90 fidCut1stYear->DoPHOSFidutialCut(kTRUE) ;
91 fidCut1stYear->SetSimpleEMCALFidutialCut(0.7,80.,120.);
92 fidCut1stYear->SetSimplePHOSFidutialCut(0.12,260.,320.);
4865e325 93
a3aebfff 94 AliAnaPhoton *anaphoton1 = new AliAnaPhoton();
95 anaphoton1->SetDebug(-1); //10 for lots of messages
90eb3a19 96 //anaphoton->SetMinPt(0.5);
a3aebfff 97 anaphoton1->SetMinDistanceToBadChannel(2, 4, 5);
98 anaphoton1->SetCaloPID(pid);
99 anaphoton1->SetCalorimeter(calorimeter);
4a55403a 100 if(kUseKinematics) anaphoton1->SwitchOnDataMC() ;//Access MC stack and fill more histograms
101 else anaphoton1->SwitchOffDataMC() ;
a3aebfff 102 anaphoton1->SwitchOffCaloPID();
103 anaphoton1->SwitchOffCaloPIDRecalculation(); //recommended for EMCAL
4a55403a 104 anaphoton1->SwitchOnFidutialCut();
105 anaphoton1->SetFidutialCut(fidCut1stYear);
ad1ac1b7 106 anaphoton1->SetOutputAODName(Form("PhotonsForIM%s",calorimeter.Data()));
4a55403a 107 if(kPrintSettings) anaphoton1->Print("");
a3aebfff 108
90eb3a19 109 AliAnaPi0 *anapi0 = new AliAnaPi0();
74b57e64 110 anapi0->SetDebug(-1);//10 for lots of messages
ad1ac1b7 111 anapi0->SetInputAODName(Form("PhotonsForIM%s",calorimeter.Data()));
90eb3a19 112 anapi0->SetCaloPID(pid);
113 anapi0->SetCalorimeter(calorimeter);
114 anapi0->SwitchOnFidutialCut();
115 anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
4a55403a 116 if(kPrintSettings) anapi0->Print("");
90eb3a19 117
4865e325 118
a3aebfff 119 // -------------------------------------------------
120 // --- Photon Isolation and Correlation Analysis ---
121 // -------------------------------------------------
122
123 AliAnaPhoton *anaphoton2 = new AliAnaPhoton();
124 anaphoton2->SetDebug(-1); //10 for lots of messages
125 anaphoton2->SetMinPt(5);
126 anaphoton2->SetCaloPID(pid);
127 anaphoton2->SetCalorimeter(calorimeter);
4a55403a 128 if(kUseKinematics) anaphoton2->SwitchOnDataMC() ;//Access MC stack and fill more histograms
129 else anaphoton2->SwitchOffDataMC() ;
a3aebfff 130 anaphoton2->SwitchOnCaloPID();
131 if(calorimeter == "EMCAL") anaphoton2->SwitchOnCaloPIDRecalculation();
132 anaphoton2->SwitchOffFidutialCut();
ad1ac1b7 133 anaphoton2->SetOutputAODName(Form("DirectPhotons%s",calorimeter.Data()));
a3aebfff 134 anaphoton2->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
135 anaphoton2->AddToHistogramsName("AnaPhotonCorr_");
4a55403a 136 if(kPrintSettings) anaphoton2->Print("");
90eb3a19 137 // ### Isolation analysis ###
138
139 AliIsolationCut * ic = new AliIsolationCut();
140 ic->SetConeSize(0.5);
141 ic->SetPtThreshold(1.);
142 ic->SetICMethod(AliIsolationCut::kPtThresIC);
4a55403a 143 if(kPrintSettings) ic->Print("");
90eb3a19 144
145 AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
146 anaisol->SetDebug(-1);
147 //anaisol->SetMinPt(5);
ad1ac1b7 148 anaisol->SetInputAODName(Form("DirectPhotons%s",calorimeter.Data()));
90eb3a19 149 anaisol->SetCalorimeter(calorimeter);
4a55403a 150 if(kUseKinematics) anaisol->SwitchOnDataMC() ;//Access MC stack and fill more histograms
151 else anaisol->SwitchOffDataMC() ;
90eb3a19 152 //Select clusters with no pair, if both clusters with pi0 mass
153 anaisol->SwitchOffInvariantMass();
154 //anaisol->SetNeutralMesonSelection(nms);
155 //Do isolation cut
156 anaisol->SetIsolationCut(ic);
157 //Do or not do isolation with previously produced AODs.
158 //No effect if use of SwitchOnSeveralIsolation()
159 anaisol->SwitchOffReIsolation();
160 //Multiple IC
161 anaisol->SwitchOffSeveralIsolation() ;
4a55403a 162 if(kPrintSettings) anaisol->Print("");
90eb3a19 163
a3aebfff 164 // ### Correlation with Jet Finder AOD output
165 AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
ad1ac1b7 166 anacorrjet->SetInputAODName(Form("DirectPhotons%s",calorimeter.Data()));
a3aebfff 167 anacorrjet->SwitchOffFidutialCut();
168 anacorrjet->SetDebug(-1);
169 anacorrjet->SetConeSize(1);
170 anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
171 anacorrjet->SetPtThresholdInCone(0.2);
172 anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts
173 anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
174 anacorrjet->UseJetRefTracks(kFALSE); //Not working now
4a55403a 175 if(kPrintSettings) anacorrjet->Print("");
90eb3a19 176
177 // ### Correlation with hadrons
a3aebfff 178 AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
ad1ac1b7 179 anacorrhadron->SetInputAODName(Form("DirectPhotons%s",calorimeter.Data()));
180 anacorrhadron->SetOutputAODName(Form("CorrelatedPi0s%s",calorimeter.Data()));
9415d854 181 anacorrhadron->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
a3aebfff 182 anacorrhadron->SetDebug(-1);
12524a23 183 anacorrhadron->SwitchOffCaloPID();
a3aebfff 184 anacorrhadron->SwitchOffFidutialCut();
185 anacorrhadron->SetPtCutRange(1,100);
186 anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
187 anacorrhadron->SelectIsolated(kTRUE); // do correlation with isolated photons
4865e325 188 if(calorimeter=="PHOS"){
90eb3a19 189 //Correlate with particles in EMCAL
a3aebfff 190 anacorrhadron->SwitchOnCaloPID();
191 anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
90eb3a19 192 }
4a55403a 193 if(kPrintSettings) anacorrhadron->Print("");
90eb3a19 194
195 // #### Configure Maker ####
a3aebfff 196 AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
90eb3a19 197 maker->SetReader(reader);//pointer to reader
4865e325 198 maker->AddAnalysis(qa,0);
199 maker->AddAnalysis(anaphoton1,1);
200 maker->AddAnalysis(anapi0,2);
201 maker->AddAnalysis(anaphoton2,3);
202 maker->AddAnalysis(anaisol,4);
203 maker->AddAnalysis(anacorrjet,5);
204 maker->AddAnalysis(anacorrhadron,6);
850b8c8c 205 maker->SetAnaDebug(-1) ;
90eb3a19 206 maker->SwitchOnHistogramsMaker() ;
207 maker->SwitchOnAODsMaker() ;
4a55403a 208 if(kPrintSettings) maker->Print("");
a3aebfff 209
90eb3a19 210 printf("======================== \n");
a3aebfff 211 printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
90eb3a19 212 printf("======================== \n");
213
a3aebfff 214 // Create task
215 //===========================================================================
ad1ac1b7 216 AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
a3aebfff 217 task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
218 //task->SetDebugLevel(-1);
219 task->SetAnalysisMaker(maker);
220 mgr->AddTask(task);
221
fbc534a2 222 char name[128];
223 sprintf(name,"PartCorr_%s",calorimeter.Data());
d0b67781 224 cout<<"Name of task "<<name<<endl;
225 //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
226 // AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
a3aebfff 227
d0b67781 228 TString outputfile = AliAnalysisManager::GetCommonFileName();
229 // AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
230 AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(calorimeter.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr",outputfile.Data()));
231
a3aebfff 232 // Create ONLY the output containers for the data produced by the task.
233 // Get and connect other common input/output containers via the manager as below
234 //==============================================================================
235 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
236 // AOD output slot will be used in a different way in future
237 mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
238 mgr->ConnectOutput (task, 1, cout_pc);
239
240 return task;
90eb3a19 241}
a3aebfff 242
243