]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/macros/AddTaskPi0.C
Adding the possibility to read additional tracks or MC information to the AOD momentu...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPi0.C
CommitLineData
d7c10d78 1AliAnalysisTaskParticleCorrelation *AddTaskPi0(TString data, TString calorimeter, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE, Bool_t outputAOD=kFALSE, Bool_t oldAOD=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("AddTaskPi0", "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("AddTaskPi0", "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 }
af7b3903 73
74 //In case of AODs created only for calorimeters, and track information filtered
75 //CTS is off when calling this method
76 //reader->SwitchOnCaloFilterPatch();
d7c10d78 77
78 //Min particle pT
79 reader->SetEMCALPtMin(0.1);
80 reader->SetPHOSPtMin(0.);
81 reader->SetCTSPtMin(0.);
82 if(outputAOD) reader->SwitchOnWriteDeltaAOD() ;
83 if(oldAOD) reader->SwitchOnOldAODs();
84 if(kPrintSettings) reader->Print("");
85
86 // *** Calorimeters Utils ***
87 AliCalorimeterUtils *cu = new AliCalorimeterUtils;
88 // Remove clusters close to borders, at least max energy cell is 1 cell away
89 cu->SetNumberOfCellsFromEMCALBorder(1);
90 cu->SetNumberOfCellsFromPHOSBorder(2);
91
92 // Remove EMCAL hottest channels for first LHC10 periods
af7b3903 93 // cu->SwitchOnBadChannelsRemoval();
94 // cu->SwitchOnDistToBadChannelRecalculation();
95
96// TFile * fbad = new TFile("BadChannels.root","read");
97// TH2I * hbad0 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod0");
98// TH2I * hbad1 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod1");
99// TH2I * hbad2 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod2");
100// TH2I * hbad3 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod3");
101// cu->SetEMCALChannelStatusMap(0,hbad0);
102// cu->SetEMCALChannelStatusMap(1,hbad1);
103// cu->SetEMCALChannelStatusMap(2,hbad2);
104// cu->SetEMCALChannelStatusMap(3,hbad3);
d7c10d78 105
106
107 //Recalibration
108 //cu->SwitchOnRecalibration();
109 //TFile * f = new TFile("RecalibrationFactors.root","read");
110 //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
111 //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
112 //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
113 //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));
114 //f->Close();
115
116 cu->SetDebug(-1);
117 if(kPrintSettings) cu->Print("");
118
119
120 // ##### Analysis algorithm settings ####
121
122 // -------------------------------------------------
123 // --- Photon/Pi0/Omega/Electron Analysis ---
124 // -------------------------------------------------
125
126 AliAnaPhoton *anaphoton = new AliAnaPhoton();
127 anaphoton->SetDebug(-1); //10 for lots of messages
af7b3903 128 anaphoton->SetZvertexCut(10);
d7c10d78 129 if(calorimeter == "PHOS"){
130 anaphoton->SetNCellCut(0);// At least 2 cells
131 anaphoton->SetMinPt(0.);
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 if(!kUseKinematics) anaphoton->SetTimeCut(400,900);// Time window of [400-900] ns
af7b3903 138 anaphoton->SetMinDistanceToBadChannel(6, 12, 18);//For officially produced ESDs/AODs
139 //anaphoton->SetMinDistanceToBadChannel(1, 2, 3);//For filtered AODs, new releases.
d7c10d78 140 }
141 anaphoton->SetCalorimeter(calorimeter);
142 if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
143 else anaphoton->SwitchOffDataMC() ;
144 anaphoton->SwitchOffCaloPID();
145 anaphoton->SwitchOffFiducialCut();
146 if(kSimulation){
147 anaphoton->SwitchOnFiducialCut();
148 AliFiducialCut * fidCut1stYear = anaphoton->GetFiducialCut();
149 fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
150 fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
151 fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
152 fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
153 fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
154 }
155
156 if(!data.Contains("delta")) {
157 anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
158 anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
159 }
160 else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
161 anaphoton->AddToHistogramsName("AnaPhotonCorr_");
162 //Set Histograms bins and ranges
af7b3903 163 anaphoton->SetHistoPtRangeAndNBins(0, 100, 200) ;
d7c10d78 164 // ana->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
165 // ana->SetHistoEtaRangeAndNBins(-0.7, 0.7, 100) ;
166 if(kPrintSettings) anaphoton->Print("");
167
168 // -----------------------------------
169 // --- Pi0 Invariant Mass Analysis ---
170 // -----------------------------------
171
172 AliAnaPi0 *anapi0 = new AliAnaPi0();
173 anapi0->SetDebug(-1);//10 for lots of messages
174 anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
175 anapi0->SetCalorimeter(calorimeter);
176
177 anapi0->SwitchOnMultipleCutAnalysis();
af7b3903 178 //anapi0->SetNPtCuts(2);
179 //anapi0->SetNAsymCuts(2);
180 //anapi0->SetNNCellCuts(2);
d7c10d78 181 anapi0->SetNPIDBits(2);
182
af7b3903 183 //anapi0->SetPtCutsAt(0,0.3); anapi0->SetPtCutsAt(1,0.5);
184 //anapi0->SetAsymCutsAt(0,0.1);anapi0->SetAsymCutsAt(1,0.5);
185 //anapi0->SetNCellCutsAt(0,1); anapi0->SetNCellCutsAt(1,2);
186 anapi0->SetPIDBitsAt(0,0); //No Cut
187 anapi0->SetPIDBitsAt(1,2); //Dispersion Cut
d7c10d78 188
189
190 if(kSimulation){
191 anapi0->SwitchOnFiducialCut();
192 AliFiducialCut * fidCut1stYear = anapi0->GetFiducialCut();
193 fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
194 fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
195 fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
196 fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
197 fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
198 }
199
d7c10d78 200 //settings for pp collision mixing
201 anapi0->SwitchOnOwnMix(); //Off when mixing done with general mixing frame
202 anapi0->SetNCentrBin(1);
203 anapi0->SetNZvertBin(1);
204 anapi0->SetNRPBin(1);
205 anapi0->SetNMaxEvMix(10);
206
207 if(kUseKinematics)anapi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
208 else anapi0->SwitchOffDataMC() ;
209 if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
210 else anapi0->SetNumberOfModules(4); //EMCAL first year
af7b3903 211 anapi0->SetHistoPtRangeAndNBins(0, 20, 200) ;
d7c10d78 212 //anapi0->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 100) ;
213 //anapi0->SetHistoEtaRangeAndNBins(-0.8, 0.8, 200) ;
af7b3903 214 anapi0->SetHistoMassRangeAndNBins(0., 0.9, 300) ;
215 anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
216 anapi0->SetHistoTrackMultiplicityRangeAndNBins(0, 200, 20);
217
d7c10d78 218 if(kPrintSettings) anapi0->Print("");
219
220
221
222 // #### Configure Maker ####
223 AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
224 maker->SetReader(reader);//pointer to reader
225 maker->SetCaloUtils(cu); //pointer to calorimeter utils
226 Int_t n = 0;//Analysis number, order is important
227 // Particle selection analysis
228 maker->AddAnalysis(anaphoton,n++);
229 maker->AddAnalysis(anapi0,n++);
230 maker->SetAnaDebug(-1) ;
231 maker->SwitchOnHistogramsMaker() ;
232 if(data.Contains("delta")) maker->SwitchOffAODsMaker() ;
233 else maker->SwitchOnAODsMaker() ;
234
235 if(kPrintSettings) maker->Print("");
236
237 printf("======================== \n");
238 printf(" End Configuration of Pi0 analysis with detector %s \n",calorimeter.Data());
239 printf("======================== \n");
240
241 // Create task
242 //===========================================================================
243 AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
244 task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
245 //task->SetDebugLevel(-1);
af7b3903 246 if(data=="ESD")task->SelectCollisionCandidates();
d7c10d78 247 task->SetAnalysisMaker(maker);
248 //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
249 mgr->AddTask(task);
250
251 //Create containers
252 char name[128];
253 sprintf(name,"PartCorr_%s",calorimeter.Data());
254 cout<<"Name of task "<<name<<endl;
255 //AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
256 // AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
257
258 TString outputfile = AliAnalysisManager::GetCommonFileName();
259 // AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form("PartCorr_%s",calorimeter.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:PartCorr_%s",outputfile.Data(),calorimeter.Data()));
260 AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(calorimeter.Data(), TList::Class(),
261 AliAnalysisManager::kOutputContainer,
262 Form("%s:PartCorr",outputfile.Data()));
263
264 AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(),
265 AliAnalysisManager::kParamContainer,
266 Form("%s:PartCorrCuts",outputfile.Data()));
267
268 // Create ONLY the output containers for the data produced by the task.
269 // Get and connect other common input/output containers via the manager as below
270 //==============================================================================
271 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
272 // AOD output slot will be used in a different way in future
273 if(!data.Contains("delta") && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
274 mgr->ConnectOutput (task, 1, cout_pc);
275 mgr->ConnectOutput (task, 2, cout_cuts);
276
277 return task;
278}
279
280