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