AliPhysics  29d4213 (29d4213)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AddTaskESDFilterEMCALEventSelect.C
Go to the documentation of this file.
1 
13 Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter* esdFilter);
14 Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter* esdFilter);
16 
17 AliAnalysisTaskESDfilter *AddTaskESDFilterEMCALEventSelect(Float_t energyCut = 10, // EMCAL
18  Int_t ncellsCut = 2, // EMCAL
19  Int_t runNumber = 170000, // EMCAL
20  Bool_t useKineFilter=kTRUE,
21  Int_t tofTimeZeroType=AliESDpid::kTOF_T0,
22  Bool_t enableTPCOnlyAODTracks=kFALSE,
23  Bool_t disableCascades=kFALSE,
24  Bool_t disableKinks=kFALSE,
25  Int_t runFlag = 1100)
26 {
27  // Creates a filter task and adds it to the analysis manager.
28  // Get the pointer to the existing analysis manager via the static access method.
29  //==============================================================================
30  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
31  if (!mgr) {
32  ::Error("AddTaskESDFilter", "No analysis manager to connect to.");
33  return NULL;
34  }
35 
36  // This task requires an ESD input handler and an AOD output handler.
37  // Check this using the analysis manager.
38  //===============================================================================
39  TString type = mgr->GetInputEventHandler()->GetDataType();
40  if (!type.Contains("ESD")) {
41  ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler.");
42  return NULL;
43  }
44  // Check if AOD output handler exist.
45  AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler();
46  if (!aod_h) {
47  ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler.");
48  return NULL;
49  }
50  // Check if MC handler is connected in case kine filter requested
51  AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
52  if (!mcH && useKineFilter) {
53  ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
54  return NULL;
55  }
56 
57  // Create the task, add it to the manager and configure it.
58  //===========================================================================
59  AliAnalysisTaskESDfilterEMCALEventSelect *esdfilter = new AliAnalysisTaskESDfilterEMCALEventSelect("ESD Filter : EMCAL event select");
60 
61  esdfilter->DisableZDC();
62  esdfilter->DisablePmdClusters();
63 
64  // EMCAL settings
65  esdfilter->SetEnergyCut(energyCut);
66  esdfilter->SetNcellsCut(ncellsCut);
67 
68  AliEMCALRecoUtils * reco = esdfilter->GetRecoUtils();
69  reco->SwitchOnRejectExoticCluster();
70 
71  // Pass the bad channels, need to access run number
72  TString fileName="$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root";
73  AliOADBContainer *contBC=new AliOADBContainer("");
74  contBC->InitFromFile((char*)fileName.Data(),"AliEMCALBadChannels");
75  TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runNumber);
76  if(arrayBC){
77  TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject("pass1");
78  if(arrayBCpass){
79 
80  reco->SwitchOnBadChannelsRemoval();
81  printf("*** EMCAL RecoUtils : REMOVE bad cells \n");
82 
83  for (Int_t i=0; i<10; ++i) {
84  TH2I *hbm = reco->GetEMCALChannelStatusMap(i);
85  if (hbm)
86  delete hbm;
87  hbm=(TH2I*)arrayBCpass->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
88 
89  if (!hbm) {
90  AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
91  continue;
92  }
93 
94  hbm->SetDirectory(0);
95  reco->SetEMCALChannelStatusMap(i,hbm);
96  }
97  } else printf("AliEMCALRecoUtils ---Do NOT remove bad channels 1\n");
98  } else printf("AliEMCALRecoUtils ---Do NOT remove bad channels 2\n");
99 
100  // From here keep sync with $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C
101 
102  esdfilter->SetTimeZeroType(tofTimeZeroType);
103  if (disableCascades) esdfilter->DisableCascades();
104  if (disableKinks) esdfilter->DisableKinks();
105 
106  mgr->AddTask(esdfilter);
107 
108  // Filtering of MC particles (decays conversions etc)
109  // this task has to go AFTER all other filter tasks
110  // since it fills the AODMC array with all
111  // selected MC Particles, only this way we have the
112  // AODMCparticle information available for following tasks
113  AliAnalysisTaskMCParticleFilter *kinefilter = 0;
114  if (useKineFilter) {
115  kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
116  mgr->AddTask(kinefilter);
117  }
118 
119  enableTPCOnlyAODTracksLocalFlag = enableTPCOnlyAODTracks;
120  if((runFlag/100)==10){
121  AddTrackCutsLHC10h(esdfilter);
122  }
123  else {
124  // default 11h
125  AddTrackCutsLHC11h(esdfilter);
126  }
127 
128  // Filter with cuts on V0s
129  AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
130  esdV0Cuts->SetMinRadius(0.2);
131  esdV0Cuts->SetMaxRadius(200);
132  esdV0Cuts->SetMinDcaPosToVertex(0.05);
133  esdV0Cuts->SetMinDcaNegToVertex(0.05);
134  esdV0Cuts->SetMaxDcaV0Daughters(1.5);
135  esdV0Cuts->SetMinCosinePointingAngle(0.99);
136  AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
137  v0Filter->AddCuts(esdV0Cuts);
138 
139  esdfilter->SetV0Filter(v0Filter);
140 
141  // Create ONLY the output containers for the data produced by the task.
142  // Get and connect other common input/output containers via the manager as below
143  //==============================================================================
144  mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
145  mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
146  if (useKineFilter) {
147  mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
148  mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
149  AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
150  AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
151  mgr->ConnectOutput (kinefilter, 1,coutputEx);
152  }
153  return esdfilter;
154 }
155 
156 Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter* esdfilter)
157 {
158  Printf("%s%d: Creating Track Cuts for LH10h",(char*)__FILE__,__LINE__);
159 
160  // Cuts on primary tracks
161  AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
162 
163  // ITS stand-alone tracks
164  AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
165  esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
166 
167  // Pixel OR necessary for the electrons
168  AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
169  itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
170 
171 
172  // PID for the electrons
173  AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
174  electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
175 
176  // tighter cuts on primary particles for high pT tracks
177  // take the standard cuts, which include already
178  // ITSrefit and use only primaries...
179 
180  // ITS cuts for new jet analysis
181  // gROOT->LoadMacro("$ALICE_PHYSICS/PWGJE/macros/CreateTrackCutsPWGJE.C");
182  // AliESDtrackCuts* esdTrackCutsHG0 = CreateTrackCutsPWGJE(10001006);
183 
184  AliESDtrackCuts *jetCuts1006 = new AliESDtrackCuts("AliESDtrackCuts");
185 
186  TFormula *f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x");
187  jetCuts1006->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.);
188  jetCuts1006->SetMinNClustersTPC(70);
189  jetCuts1006->SetMaxChi2PerClusterTPC(4);
190  jetCuts1006->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1
191  jetCuts1006->SetAcceptKinkDaughters(kFALSE);
192  jetCuts1006->SetRequireTPCRefit(kTRUE);
193  jetCuts1006->SetMaxFractionSharedTPCClusters(0.4);
194  // ITS
195  jetCuts1006->SetRequireITSRefit(kTRUE);
196  //accept secondaries
197  jetCuts1006->SetMaxDCAToVertexXY(2.4);
198  jetCuts1006->SetMaxDCAToVertexZ(3.2);
199  jetCuts1006->SetDCAToVertex2D(kTRUE);
200  //reject fakes
201  jetCuts1006->SetMaxChi2PerClusterITS(36);
202  jetCuts1006->SetMaxChi2TPCConstrainedGlobal(36);
203 
204  jetCuts1006->SetRequireSigmaToVertex(kFALSE);
205 
206  jetCuts1006->SetEtaRange(-0.9,0.9);
207  jetCuts1006->SetPtRange(0.15, 1E+15.);
208 
209  AliESDtrackCuts* esdTrackCutsHG0 = jetCuts1006->Clone("JetCuts10001006");
210  esdTrackCutsHG0->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
211 
212  // throw out tracks with too low number of clusters in
213  // the first pass (be consistent with TPC only tracks)
214  // N.B. the number off crossed rows still acts on the tracks after
215  // all iterations if we require tpc standalone, number of clusters
216  // and chi2 TPC cuts act on track after the first iteration
217  // esdTrackCutsH0->SetRequireTPCStandAlone(kTRUE);
218  // esdTrackCutsH0->SetMinNClustersTPC(80); // <--- first pass
219 
220  // the complement to the one with SPD requirement
221  // AliESDtrackCuts* esdTrackCutsHG1 = CreateTrackCutsPWGJE(10011006);
222  AliESDtrackCuts* esdTrackCutsHG1 = jetCuts1006->Clone("JetCuts10011006");
223  esdTrackCutsHG1->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
224 
225  // the tracks that must not be taken pass this cut and
226  // non HGC1 and HG
227  // AliESDtrackCuts* esdTrackCutsHG2 = CreateTrackCutsPWGJE(10021006);
228  AliESDtrackCuts* esdTrackCutsHG2 = jetCuts1006->Clone("JetCuts10021006");
229  esdTrackCutsHG2->SetMaxChi2PerClusterITS(1E10);
230 
231  // standard cuts also used in R_AA analysis
232  // "Global track RAA analysis QM2011 + Chi2ITS<36";
233  // AliESDtrackCuts* esdTrackCutsH2 = CreateTrackCutsPWGJE(1000);
234  AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE,1);
235  esdTrackCutsH2->SetMinNCrossedRowsTPC(120);
236  esdTrackCutsH2->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
237  esdTrackCutsH2->SetMaxChi2PerClusterITS(36);
238  esdTrackCutsH2->SetMaxFractionSharedTPCClusters(0.4);
239  esdTrackCutsH2->SetMaxChi2TPCConstrainedGlobal(36);
240 
241  esdTrackCutsH2->SetEtaRange(-0.9,0.9);
242  esdTrackCutsH2->SetPtRange(0.15, 1e10);
243 
244  // AliESDtrackCuts* esdTrackCutsGCOnly = CreateTrackCutsPWGJE(10041006);
245  AliESDtrackCuts* esdTrackCutsGCOnly = jetCuts1006->Clone("JetCuts10041006");
246  esdTrackCutsGCOnly->SetRequireITSRefit(kFALSE);
247 
248  // TPC only tracks
249  AliESDtrackCuts* esdTrackCutsTPCCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
250  esdTrackCutsTPCCOnly->SetMinNClustersTPC(70);
251 
252  // Compose the filter
253  AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
254  // 1, 1<<0
255  trackFilter->AddCuts(esdTrackCutsL);
256  // 2 1<<1
257  trackFilter->AddCuts(esdTrackCutsITSsa);
258  // 4 1<<2
259  trackFilter->AddCuts(itsStrong);
260  itsStrong->SetFilterMask(1); // AND with Standard track cuts
261  // 8 1<<3
262  trackFilter->AddCuts(electronID);
263  electronID->SetFilterMask(4); // AND with Pixel Cuts
264  // 16 1<<4
265  trackFilter->AddCuts(esdTrackCutsHG0);
266  // 32 1<<5
267  trackFilter->AddCuts(esdTrackCutsHG1);
268  // 64 1<<6
269  trackFilter->AddCuts(esdTrackCutsHG2);
270  // 128 1<<7
271  trackFilter->AddCuts(esdTrackCutsTPCCOnly); // add QM TPC only track cuts
272  if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128);
273  // 256 1<<8
274  trackFilter->AddCuts(esdTrackCutsGCOnly);
275  // 512 1<<9
276  AliESDtrackCuts* esdTrackCutsHG1_tmp = new AliESDtrackCuts(*esdTrackCutsHG1); // avoid double delete
277  trackFilter->AddCuts(esdTrackCutsHG1_tmp); // add once more for tpc only tracks
278  // 1024 1<<10
279  trackFilter->AddCuts(esdTrackCutsH2); // add r_aa cuts
280 
281 
282 
283  esdfilter->SetGlobalConstrainedFilterMask(1<<8|1<<9); // these tracks are written out as global constrained tracks
284  esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<4)); // these normal global tracks will be marked as hybrid
285  esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement
286  // esdfilter->SetTPCConstrainedFilterMask(1<<11); // these tracks are written out as tpc constrained tracks
287 
288  esdfilter->SetTrackFilter(trackFilter);
289  return kTRUE;
290 }
291 
292 Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter* esdfilter)
293 {
294  Printf("%s%d: Creating Track Cuts LHC11h",(char*)__FILE__,__LINE__);
295 
296  // Cuts on primary tracks
297  AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
298 
299  // ITS stand-alone tracks
300  AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
301  esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
302 
303  // Pixel OR necessary for the electrons
304  AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
305  itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
306 
307 
308  // PID for the electrons
309  AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
310  electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
311 
312  // standard cuts with very loose DCA
313  AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
314  esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
315  esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
316  esdTrackCutsH->SetDCAToVertex2D(kTRUE);
317 
318  // standard cuts with tight DCA cut
319  AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
320 
321  // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster
322  // tracks selected by this cut are exclusive to those selected by the previous cut
323  AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
324  esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
325  esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst);
326 
327  // TPC only tracks: Optionally enable the writing of TPConly information
328  // constrained to SPD vertex in the filter below
329  AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
330  // The following line is needed for 2010 PbPb reprocessing and pp, but not for 2011 PbPb
331  //esdTrackCutsTPCOnly->SetMinNClustersTPC(70);
332 
333  // Extra cuts for hybrids
334  // first the global tracks we want to take
335  AliESDtrackCuts* esdTrackCutsHTG = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
336  esdTrackCutsHTG->SetName("Global Hybrid tracks, loose DCA");
337  esdTrackCutsHTG->SetMaxDCAToVertexXY(2.4);
338  esdTrackCutsHTG->SetMaxDCAToVertexZ(3.2);
339  esdTrackCutsHTG->SetDCAToVertex2D(kTRUE);
340  esdTrackCutsHTG->SetMaxChi2TPCConstrainedGlobal(36);
341 
342  // Than the complementary tracks which will be stored as global
343  // constraint, complement is done in the ESDFilter task
344  AliESDtrackCuts* esdTrackCutsHTGC = new AliESDtrackCuts(*esdTrackCutsHTG);
345  esdTrackCutsHTGC->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement");
346  esdTrackCutsHTGC->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff);
347  esdTrackCutsHTGC->SetRequireITSRefit(kFALSE);
348 
349  // standard cuts with tight DCA cut, using cluster cut instead of crossed rows (a la 2010 default)
350  AliESDtrackCuts* esdTrackCutsH2Cluster = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE, 0);
351 
352  // Compose the filter
353  AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
354  // 1, 1<<0
355  trackFilter->AddCuts(esdTrackCutsL);
356  // 2, 1<<1
357  trackFilter->AddCuts(esdTrackCutsITSsa);
358  // 4, 1<<2
359  trackFilter->AddCuts(itsStrong);
360  itsStrong->SetFilterMask(1); // AND with Standard track cuts
361  // 8, 1<<3
362  trackFilter->AddCuts(electronID);
363  electronID->SetFilterMask(4); // AND with Pixel Cuts
364  // 16, 1<<4
365  trackFilter->AddCuts(esdTrackCutsH);
366  // 32, 1<<5
367  trackFilter->AddCuts(esdTrackCutsH2);
368  // 64, 1<<6
369  trackFilter->AddCuts(esdTrackCutsH3);
370  // 128 , 1 << 7
371  trackFilter->AddCuts(esdTrackCutsTPCOnly);
372  if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128);
373  // 256, 1 << 8 Global Hybrids
374  trackFilter->AddCuts(esdTrackCutsHTG);
375  esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid
376  // 512, 1<< 9 GlobalConstraint Hybrids
377  trackFilter->AddCuts(esdTrackCutsHTGC);
378  esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks
379  esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement
380  // 1024, 1<< 10
381  trackFilter->AddCuts(esdTrackCutsH2Cluster);
382  esdfilter->SetTrackFilter(trackFilter);
383 
384  return kTRUE;
385 }
TString fileName
Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter *esdFilter)
AliAnalysisTaskESDfilter * AddTaskESDFilterEMCALEventSelect(Float_t energyCut=10, Int_t ncellsCut=2, Int_t runNumber=170000, Bool_t useKineFilter=kTRUE, Int_t tofTimeZeroType=AliESDpid::kTOF_T0, Bool_t enableTPCOnlyAODTracks=kFALSE, Bool_t disableCascades=kFALSE, Bool_t disableKinks=kFALSE, Int_t runFlag=1100)
Bool_t enableTPCOnlyAODTracksLocalFlag
Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter *esdFilter)
Filter ESDs events into AODs with some significant calorimeter signal.