]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/macros/AddTaskPi0.C
adding more flexible hanlding of different JFs
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPi0.C
CommitLineData
bdd28eb5 1AliAnalysisTaskParticleCorrelation *AddTaskPi0(TString data, TString calorimeter, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE, Bool_t outputAOD=kFALSE, TString outputfile = "", Int_t year = 2010,TString col = "pp",Bool_t oldAOD=kFALSE)
d7c10d78 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 }
5c8fd15c 54
bdd28eb5 55 reader->SwitchOffSuspiciousClustersRemoval(); //EMCAL
d7c10d78 56
57 // for case data="deltaAOD", no need to fill the EMCAL/PHOS cluster lists
58 if(data.Contains("delta")){
59 reader->SwitchOffEMCAL();
60 reader->SwitchOffPHOS();
61 reader->SwitchOffEMCALCells();
62 reader->SwitchOffPHOSCells();
63 }
64
65 if(kUseKinematics){
66 if(inputDataType == "ESD"){
67 reader->SwitchOnStack();
68 reader->SwitchOffAODMCParticles();
69 }
70 else if(inputDataType == "AOD"){
71 reader->SwitchOffStack();
72 reader->SwitchOnAODMCParticles();
73 }
74 }
af7b3903 75
76 //In case of AODs created only for calorimeters, and track information filtered
77 //CTS is off when calling this method
78 //reader->SwitchOnCaloFilterPatch();
20218aea 79 //Event selection
80 if (col=="pp" ) {
81 reader->SwitchOnEventSelection(); //remove pileup by default
82 reader->SwitchOffV0ANDSelection() ; // and besides v0 AND
83 reader->SwitchOffPrimaryVertexSelection(); // and besides primary vertex
84 }
85 else if(col=="PbPb") {
86 reader->SwitchOffEventSelection(); //remove pileup by default
87 reader->SwitchOffV0ANDSelection() ; // and besides v0 AND
88 reader->SwitchOffPrimaryVertexSelection(); // and besides primary vertex
89 }
d7c10d78 90
4ec7be95 91 if (col=="pp" ) reader->SetZvertexCut(50.); //Open cut
92 else if(col=="PbPb") reader->SetZvertexCut(10.); //Centrality defined in this range.
0b13c1f9 93
d7c10d78 94 //Min particle pT
bdd28eb5 95 reader->SetEMCALPtMin(0.5);
98ec971d 96 reader->SetEMCALPtMax(30);
d7c10d78 97 reader->SetPHOSPtMin(0.);
98 reader->SetCTSPtMin(0.);
99 if(outputAOD) reader->SwitchOnWriteDeltaAOD() ;
100 if(oldAOD) reader->SwitchOnOldAODs();
101 if(kPrintSettings) reader->Print("");
102
103 // *** Calorimeters Utils ***
104 AliCalorimeterUtils *cu = new AliCalorimeterUtils;
bdd28eb5 105 if(year==2010) cu->SetEMCALGeometryName("EMCAL_FIRSTYEARV1");
106 else cu->SetEMCALGeometryName("EMCAL_COMPLETEV1");
d7c10d78 107 // Remove clusters close to borders, at least max energy cell is 1 cell away
108 cu->SetNumberOfCellsFromEMCALBorder(1);
109 cu->SetNumberOfCellsFromPHOSBorder(2);
110
98ec971d 111 if (col=="pp" ) {
112 cu->SwitchOnCorrectClusterLinearity();
113 AliEMCALRecoUtils * reco = cu->GetEMCALRecoUtils();
114 reco->SetNonLinearityFunction(AliEMCALRecoUtils::kBeamTestCorrected);
115 }
116
d7c10d78 117 // Remove EMCAL hottest channels for first LHC10 periods
af7b3903 118 // cu->SwitchOnBadChannelsRemoval();
119 // cu->SwitchOnDistToBadChannelRecalculation();
120
121// TFile * fbad = new TFile("BadChannels.root","read");
122// TH2I * hbad0 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod0");
123// TH2I * hbad1 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod1");
124// TH2I * hbad2 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod2");
125// TH2I * hbad3 = (TH2I*)fbad->Get("EMCALBadChannelMap_Mod3");
126// cu->SetEMCALChannelStatusMap(0,hbad0);
127// cu->SetEMCALChannelStatusMap(1,hbad1);
128// cu->SetEMCALChannelStatusMap(2,hbad2);
129// cu->SetEMCALChannelStatusMap(3,hbad3);
d7c10d78 130
131
132 //Recalibration
133 //cu->SwitchOnRecalibration();
134 //TFile * f = new TFile("RecalibrationFactors.root","read");
135 //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
136 //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
137 //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
138 //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));
139 //f->Close();
140
141 cu->SetDebug(-1);
142 if(kPrintSettings) cu->Print("");
143
144
145 // ##### Analysis algorithm settings ####
146
147 // -------------------------------------------------
148 // --- Photon/Pi0/Omega/Electron Analysis ---
149 // -------------------------------------------------
150
151 AliAnaPhoton *anaphoton = new AliAnaPhoton();
152 anaphoton->SetDebug(-1); //10 for lots of messages
153 if(calorimeter == "PHOS"){
5c8fd15c 154 anaphoton->SetNCellCut(2);// At least 2 cells
155 anaphoton->SetMinPt(3.);
d7c10d78 156 anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
157 }
158 else {//EMCAL
5c8fd15c 159 anaphoton->SetNCellCut(1);// At least 2 cells
bdd28eb5 160 anaphoton->SetMinPt(0.5); // no effect minium EMCAL cut.
98ec971d 161 anaphoton->SetMaxPt(30);
5c8fd15c 162 //if(!kUseKinematics) anaphoton->SetTimeCut(400,900);// Time window of [400-900] ns
163 //anaphoton->SetMinDistanceToBadChannel(6, 12, 18);//For officially produced ESDs/AODs
164 anaphoton->SetMinDistanceToBadChannel(1, 2, 3);//For filtered AODs, new releases.
d7c10d78 165 }
166 anaphoton->SetCalorimeter(calorimeter);
167 if(kUseKinematics) anaphoton->SwitchOnDataMC() ;//Access MC stack and fill more histograms
168 else anaphoton->SwitchOffDataMC() ;
169 anaphoton->SwitchOffCaloPID();
170 anaphoton->SwitchOffFiducialCut();
171 if(kSimulation){
172 anaphoton->SwitchOnFiducialCut();
173 AliFiducialCut * fidCut1stYear = anaphoton->GetFiducialCut();
174 fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
175 fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
176 fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
177 fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
178 fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
179 }
180
181 if(!data.Contains("delta")) {
182 anaphoton->SetOutputAODName(Form("Photons%s",calorimeter.Data()));
183 anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
184 }
185 else anaphoton->SetInputAODName(Form("Photons%s",calorimeter.Data()));
186 anaphoton->AddToHistogramsName("AnaPhotonCorr_");
187 //Set Histograms bins and ranges
bdd28eb5 188 anaphoton->SetHistoPtRangeAndNBins(0, 30, 150) ;
20218aea 189 if(year==2010)anaphoton->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 122*TMath::DegToRad(), 78) ;
190 else anaphoton->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
bdd28eb5 191 anaphoton->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
d7c10d78 192 if(kPrintSettings) anaphoton->Print("");
193
194 // -----------------------------------
195 // --- Pi0 Invariant Mass Analysis ---
196 // -----------------------------------
197
198 AliAnaPi0 *anapi0 = new AliAnaPi0();
199 anapi0->SetDebug(-1);//10 for lots of messages
200 anapi0->SetInputAODName(Form("Photons%s",calorimeter.Data()));
201 anapi0->SetCalorimeter(calorimeter);
bdd28eb5 202 anapi0->SwitchOffMultipleCutAnalysis();
af7b3903 203 //anapi0->SetNPtCuts(2);
20218aea 204 //anapi0->SetNAsymCuts(2);
af7b3903 205 //anapi0->SetNNCellCuts(2);
20218aea 206 //anapi0->SetNPIDBits(1);
d7c10d78 207
af7b3903 208 //anapi0->SetPtCutsAt(0,0.3); anapi0->SetPtCutsAt(1,0.5);
209 //anapi0->SetAsymCutsAt(0,0.1);anapi0->SetAsymCutsAt(1,0.5);
210 //anapi0->SetNCellCutsAt(0,1); anapi0->SetNCellCutsAt(1,2);
20218aea 211 //anapi0->SetPIDBitsAt(0,0); //No Cut
bdd28eb5 212 //anapi0->SetPIDBitsAt(1,2); //Dispersion Cut
d7c10d78 213
214
215 if(kSimulation){
216 anapi0->SwitchOnFiducialCut();
217 AliFiducialCut * fidCut1stYear = anapi0->GetFiducialCut();
218 fidCut1stYear->DoCTSFiducialCut(kFALSE) ;
219 fidCut1stYear->DoEMCALFiducialCut(kTRUE) ;
220 fidCut1stYear->DoPHOSFiducialCut(kTRUE) ;
221 fidCut1stYear->SetSimpleEMCALFiducialCut(0.7,80.,120.);
222 fidCut1stYear->SetSimplePHOSFiducialCut(0.12,260.,320.);
223 }
224
d7c10d78 225 //settings for pp collision mixing
226 anapi0->SwitchOnOwnMix(); //Off when mixing done with general mixing frame
20218aea 227 if (col=="pp" ) {
228 anapi0->SetNCentrBin(1);
4ec7be95 229 anapi0->SetNZvertBin(50);
20218aea 230 anapi0->SwitchOnSMCombinations();
231 }
232 else if(col=="PbPb") {
233 anapi0->SetNCentrBin(10);
4ec7be95 234 anapi0->SetNZvertBin(10);
20218aea 235 anapi0->SwitchOffSMCombinations();
236 }
d7c10d78 237 anapi0->SetNRPBin(1);
bdd28eb5 238 anapi0->SetNMaxEvMix(50);
d7c10d78 239
240 if(kUseKinematics)anapi0->SwitchOnDataMC() ;//Access MC stack and fill more histograms
241 else anapi0->SwitchOffDataMC() ;
242 if(calorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
bdd28eb5 243 else {
244 if(year==2010) anapi0->SetNumberOfModules(4); //EMCAL first year
245 else anapi0->SetNumberOfModules(10);
246 }
247 anapi0->SetHistoPtRangeAndNBins(0, 30, 150) ;
248 anapi0->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
20218aea 249 if(year==2010)anaphoton->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 122*TMath::DegToRad(), 78) ;
250 else anaphoton->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
bdd28eb5 251
252 anapi0->SetHistoMassRangeAndNBins(0., 1., 200) ;
af7b3903 253 anapi0->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
254 anapi0->SetHistoTrackMultiplicityRangeAndNBins(0, 200, 20);
255
d7c10d78 256 if(kPrintSettings) anapi0->Print("");
257
258
d7c10d78 259 // #### Configure Maker ####
260 AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
261 maker->SetReader(reader);//pointer to reader
262 maker->SetCaloUtils(cu); //pointer to calorimeter utils
263 Int_t n = 0;//Analysis number, order is important
264 // Particle selection analysis
265 maker->AddAnalysis(anaphoton,n++);
266 maker->AddAnalysis(anapi0,n++);
267 maker->SetAnaDebug(-1) ;
268 maker->SwitchOnHistogramsMaker() ;
269 if(data.Contains("delta")) maker->SwitchOffAODsMaker() ;
270 else maker->SwitchOnAODsMaker() ;
271
272 if(kPrintSettings) maker->Print("");
273
274 printf("======================== \n");
275 printf(" End Configuration of Pi0 analysis with detector %s \n",calorimeter.Data());
276 printf("======================== \n");
277
278 // Create task
279 //===========================================================================
280 AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s",calorimeter.Data()));
281 task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
282 //task->SetDebugLevel(-1);
af7b3903 283 if(data=="ESD")task->SelectCollisionCandidates();
d7c10d78 284 task->SetAnalysisMaker(maker);
285 //if(!kSimulation)task->SelectCollisionCandidates(); //AliPhysicsSelection has to be attached before.
286 mgr->AddTask(task);
287
288 //Create containers
289 char name[128];
290 sprintf(name,"PartCorr_%s",calorimeter.Data());
291 cout<<"Name of task "<<name<<endl;
d7c10d78 292
bdd28eb5 293 if(outputfile.Length()==0)outputfile = AliAnalysisManager::GetCommonFileName();
294
d7c10d78 295 AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(calorimeter.Data(), TList::Class(),
bdd28eb5 296 AliAnalysisManager::kOutputContainer,
297 Form("%s:Pi0",outputfile.Data()));
d7c10d78 298
299 AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts",calorimeter.Data()), TList::Class(),
bdd28eb5 300 AliAnalysisManager::kParamContainer,
301 Form("%s:Pi0Cuts",outputfile.Data()));
d7c10d78 302 // Create ONLY the output containers for the data produced by the task.
303 // Get and connect other common input/output containers via the manager as below
304 //==============================================================================
305 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
306 // AOD output slot will be used in a different way in future
307 if(!data.Contains("delta") && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
308 mgr->ConnectOutput (task, 1, cout_pc);
309 mgr->ConnectOutput (task, 2, cout_cuts);
310
311 return task;
312}
313
314