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