preserve bit 8 for TPC only tracks
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskESDFilterPWG4Train.C
CommitLineData
ebad39a9 1
2a7c86bc 2
ebad39a9 3AliAnalysisTaskESDfilter *AddTaskESDFilter(Bool_t useKineFilter=kTRUE,
4 Bool_t writeMuonAOD=kFALSE,
5 Bool_t writeDimuonAOD=kFALSE,
6 Bool_t usePhysicsSelection=kFALSE)
7{
8// Creates a filter task and adds it to the analysis manager.
9
10 // Get the pointer to the existing analysis manager via the static access method.
11 //==============================================================================
12 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
13 if (!mgr) {
14 ::Error("AddTaskESDFilter", "No analysis manager to connect to.");
15 return NULL;
16 }
17
18 // This task requires an ESD input handler and an AOD output handler.
19 // Check this using the analysis manager.
20 //===============================================================================
21 TString type = mgr->GetInputEventHandler()->GetDataType();
22 if (!type.Contains("ESD")) {
23 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler.");
24 return NULL;
25 }
26 // Check if AOD output handler exist.
27 AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler();
28 if (!aod_h) {
29 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler.");
30 return NULL;
31 }
32 // Check if MC handler is connected in case kine filter requested
33 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
34 if (!mcH && useKineFilter) {
35 ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
36 return NULL;
37 }
38
39 // Create the task, add it to the manager and configure it.
40 //===========================================================================
41 // Barrel tracks filter
42 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
3095177c 43
44 // Make the AOD a little bit lighter and filtering faster
45
46 esdfilter->DisableCascades();
47 // esdfilter->DisableV0s();
48 esdfilter->DisableKinks();
49 // esdfilter->DisableTracks();
50 esdfilter->DisablePmdClusters();
51 // esdfilter->DisableCaloClusters();
52 // esdfilter->DisableCells();
53 esdfilter->DisableTracklets();
54
55
ebad39a9 56 mgr->AddTask(esdfilter);
57 // Muons
48602d36 58 // AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
59 // mgr->AddTask(esdmuonfilter);
ebad39a9 60 if(usePhysicsSelection){
61 esdfilter->SelectCollisionCandidates(AliVEvent::kAny);
48602d36 62 // esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny);
ebad39a9 63 }
64
65 // Filtering of MC particles (decays conversions etc)
66 // this task has to go AFTER all other filter tasks
67 // since it fills the AODMC array with all
68 // selected MC Particles, only this way we have the
69 // AODMCparticle information available for following tasks
70 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
71 if (useKineFilter) {
72 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
48602d36 73 if(usePhysicsSelection)kinefilter->SelectCollisionCandidates(AliVEvent::kAny);
ebad39a9 74 mgr->AddTask(kinefilter);
75 }
76
77 // Cuts on primary tracks
78 AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
79
80 // ITS stand-alone tracks
81 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
82 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
83
84 // Pixel OR necessary for the electrons
85 AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
86 itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
87
88
89 // PID for the electrons
90 AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
91 electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
92
93 // tighter cuts on primary particles for high pT tracks
94 // take the standard cuts, which include already
95 // ITSrefit and use only primaries...
3456f527 96
5a0bd31f 97 // ITS cuts for new jet analysis
98 AliESDtrackCuts* esdTrackCutsH0 = new AliESDtrackCuts("ITS+TPC cuts tight");
99
100 // ITS
101 esdTrackCutsH0->SetRequireITSRefit(kTRUE);
102
103 // TPC
104 esdTrackCutsH0->SetMinNClustersTPC(80);
105 esdTrackCutsH0->SetMaxChi2PerClusterTPC(4);
106 esdTrackCutsH0->SetAcceptKinkDaughters(kFALSE);
107 esdTrackCutsH0->SetRequireTPCRefit(kTRUE);
108 esdTrackCutsH0->SetMaxFractionSharedTPCClusters(0.4);
109
110 //
2a7c86bc 111 esdTrackCutsH0->SetMaxDCAToVertexXY(2.4);
112 esdTrackCutsH0->SetMaxDCAToVertexZ(3.2);
113 esdTrackCutsH0->SetDCAToVertex2D(kTRUE);
5a0bd31f 114 esdTrackCutsH0->SetMaxChi2PerClusterITS(36);
2a7c86bc 115 esdTrackCutsH0->SetPtRange(0.15,1E10);
5a0bd31f 116
117
c3ff0a6e 118 // throw out tracks with too low number of clusters in
119 // the first pass (be consistent with TPC only tracks)
120 // N.B. the number off crossed rows still acts on the tracks after
121 // all iterations if we require tpc standalone, number of clusters
122 // and chi2 TPC cuts act on track after the first iteration
5a0bd31f 123 // esdTrackCutsH0->SetRequireTPCStandAlone(kTRUE);
124 // esdTrackCutsH0->SetMinNClustersTPC(80); // <--- first pass
c3ff0a6e 125
2a7c86bc 126
127 //
128 AliESDtrackCuts* esdTrackCutsH1 = new AliESDtrackCuts(*esdTrackCutsH0);
129 esdTrackCutsH1->SetName("loose ITS fake cuts");
130 esdTrackCutsH1->SetMaxChi2PerClusterITS(1E10);
131
3456f527 132
5a0bd31f 133 // standard cuts also used in R_AA analysis
134 gROOT->LoadMacro("$ALICE_ROOT/PWG0/dNdPt/macros/CreatedNdPtTrackCuts.C");
135 AliESDtrackCuts* esdTrackCutsH2 = CreatedNdPtTrackCuts(200);
136 esdTrackCutsH2->SetMaxChi2PerClusterITS(36.);
f4132e7d 137 esdTrackCutsH2->SetPtRange(0.15,1E10);
3456f527 138
070f06d2 139 // TPC only tracks
140 AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
5a0bd31f 141 esdTrackCutsTPCOnly->SetPtRange(0.15,1E10);
c3ff0a6e 142 esdTrackCutsTPCOnly->SetMaxFractionSharedTPCClusters(0.4);
143 // throw out tracks with too low number of clusters in
144 // the first pass
145 // N.B. the number off crossed rows still acts on the tracks after
146 // all iterations if we require tpc standalone, number of clusters
147 // and chi2 TPC cuts act on track after the first iteration
148 esdTrackCutsTPCOnly->SetRequireTPCStandAlone(kTRUE);
149 esdTrackCutsTPCOnly->SetMinNClustersTPC(80); // <--- first pass
150
ebad39a9 151 // Compose the filter
152 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
39e7e8ab 153 // 1, 1<<0
ebad39a9 154 trackFilter->AddCuts(esdTrackCutsL);
39e7e8ab 155 // 2 1<<1
ebad39a9 156 trackFilter->AddCuts(esdTrackCutsITSsa);
39e7e8ab 157 // 4 1<<2
ebad39a9 158 trackFilter->AddCuts(itsStrong);
159 itsStrong->SetFilterMask(1); // AND with Standard track cuts
39e7e8ab 160 // 8 1<<3
ebad39a9 161 trackFilter->AddCuts(electronID);
162 electronID->SetFilterMask(4); // AND with Pixel Cuts
39e7e8ab 163 // 16 1<<4
2a7c86bc 164 trackFilter->AddCuts(esdTrackCutsH0);
39e7e8ab 165 // 32 1<<5
2a7c86bc 166 trackFilter->AddCuts(esdTrackCutsH1);
39e7e8ab 167 // 64 1<<6
2a7c86bc 168 trackFilter->AddCuts(esdTrackCutsH2);
39e7e8ab 169 // 128 1<<7
2a7c86bc 170 trackFilter->AddCuts(esdTrackCutsH0); // add once more for tpc only tracks
ea4857bd 171 // 256 1<<8
172 trackFilter->AddCuts(esdTrackCutsTPCOnly);
5a0bd31f 173 // 512 1<<9
2a7c86bc 174 trackFilter->AddCuts(esdTrackCutsH1); // add once more for tpc only tracks
175
5a0bd31f 176 esdfilter->SetTPCOnlyFilterMask((1<<7)|(1<<8)); // these tracks are written out as TPC only
2a7c86bc 177 esdfilter->SetHybridFilterMaskITSTPC((1<<4)|(1<<5)); // these global tracks will be marked has hybrid
ea4857bd 178 esdfilter->SetHybridFilterMasksTPC(1<<7,1<<9); // arg0, these tpc tracks will be marked as TPC hybrid, in addtion to thos that fail arg1
2a7c86bc 179
180
ebad39a9 181 // Filter with cuts on V0s
182 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
183 esdV0Cuts->SetMinRadius(0.2);
184 esdV0Cuts->SetMaxRadius(200);
185 esdV0Cuts->SetMinDcaPosToVertex(0.05);
186 esdV0Cuts->SetMinDcaNegToVertex(0.05);
187 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
188 esdV0Cuts->SetMinCosinePointingAngle(0.99);
189 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
070f06d2 190 v0Filter->AddCuts(esdV0Cuts);
ebad39a9 191
192 esdfilter->SetTrackFilter(trackFilter);
070f06d2 193 esdfilter->SetV0Filter(v0Filter);
ebad39a9 194
195 // Enable writing of Muon AODs
48602d36 196 // esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
ebad39a9 197
198 // Enable writing of Dimuon AODs
48602d36 199 // esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
ebad39a9 200
201 // Create ONLY the output containers for the data produced by the task.
202 // Get and connect other common input/output containers via the manager as below
203 //==============================================================================
204
205 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
206 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
207
208
209 // mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
210 if (useKineFilter) {
211 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
212 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
213 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
214 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
215 mgr->ConnectOutput (kinefilter, 1,coutputEx);
216 }
217 return esdfilter;
218 }
219