Removed as obsolete
[u/mrichter/AliRoot.git] / ANALYSIS / macros / AddTaskESDFilter.C
CommitLineData
79bd4a7a 1AliAnalysisTaskESDfilter *AddTaskESDFilter(Bool_t useKineFilter=kTRUE,
2 Bool_t writeMuonAOD=kFALSE,
daf100e1 3 Bool_t writeDimuonAOD=kFALSE,
4354b266 4 Bool_t usePhysicsSelection=kFALSE,
bd625b5b 5 Bool_t useCentralityTask=kFALSE, /*obsolete*/
4354b266 6 Int_t tofTimeZeroType=AliESDpid::kTOF_T0,
7 Bool_t enableTPCOnlyAODTracks=kFALSE,
8 Bool_t disableCascades=kFALSE,
9 Bool_t disableKinks=kFALSE)
3ef9ce84 10{
11// Creates a filter task and adds it to the analysis manager.
12
13 // Get the pointer to the existing analysis manager via the static access method.
14 //==============================================================================
15 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
16 if (!mgr) {
c85963a0 17 ::Error("AddTaskESDFilter", "No analysis manager to connect to.");
3ef9ce84 18 return NULL;
19 }
20
21 // This task requires an ESD input handler and an AOD output handler.
22 // Check this using the analysis manager.
23 //===============================================================================
24 TString type = mgr->GetInputEventHandler()->GetDataType();
25 if (!type.Contains("ESD")) {
c85963a0 26 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler.");
3ef9ce84 27 return NULL;
28 }
29 // Check if AOD output handler exist.
30 AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler();
31 if (!aod_h) {
c85963a0 32 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler.");
3ef9ce84 33 return NULL;
099d8f33 34 }
35 // Check if MC handler is connected in case kine filter requested
36 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
37 if (!mcH && useKineFilter) {
38 ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
39 return NULL;
3ef9ce84 40 }
41
42 // Create the task, add it to the manager and configure it.
099d8f33 43 //===========================================================================
44 // Barrel tracks filter
3ef9ce84 45 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
26917b0b 46 esdfilter->SetTimeZeroType(tofTimeZeroType);
4354b266 47 if (disableCascades) esdfilter->DisableCascades();
48 if (disableKinks) esdfilter->DisableKinks();
c7ef1c47 49
50 mgr->AddTask(esdfilter);
51
099d8f33 52 // Muons
14d6fad5 53 Bool_t onlyMuon=kTRUE;
54 Bool_t keepAllEvents=kTRUE;
55 Int_t mcMode=(useKineFilter ? 2 : 0); // use 1 instead of 2 to get all MC information instead of just ancestors of mu tracks
56 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter",onlyMuon,keepAllEvents,mcMode);
099d8f33 57 mgr->AddTask(esdmuonfilter);
daf100e1 58 if(usePhysicsSelection){
0c6c629b 59 esdfilter->SelectCollisionCandidates(AliVEvent::kAny);
60 esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny);
daf100e1 61 }
3827f93a 62
63 // Filtering of MC particles (decays conversions etc)
64 // this task has to go AFTER all other filter tasks
65 // since it fills the AODMC array with all
66 // selected MC Particles, only this way we have the
67 // AODMCparticle information available for following tasks
68 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
69 if (useKineFilter) {
70 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
71 mgr->AddTask(kinefilter);
72 }
73
099d8f33 74 // Cuts on primary tracks
31a3bbb0 75 AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
a550fcbd 76
099d8f33 77 // ITS stand-alone tracks
04f2cd11 78 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
31a3bbb0 79 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
099d8f33 80
a550fcbd 81 // Pixel OR necessary for the electrons
82 AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
83 itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
84
85
86 // PID for the electrons
87 AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
88 electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
89
103431ad 90 // standard cuts with very loose DCA
0914b519 91 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
cfd26fc5 92 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
93 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
94 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
cfd26fc5 95
103431ad 96 // standard cuts with tight DCA cut
0914b519 97 AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
103431ad 98
99 // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster
100 // tracks selected by this cut are exclusive to those selected by the previous cut
0914b519 101 AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
103431ad 102 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
103 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst);
cfd26fc5 104
4dae02e3 105 // TPC only tracks: Optionally enable the writing of TPConly information
106 // constrained to SPD vertex in the filter below
107 AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
b7cce158 108 // The following line is needed for 2010 PbPb reprocessing and pp, but not for 2011 PbPb
109 //esdTrackCutsTPCOnly->SetMinNClustersTPC(70);
a550fcbd 110
0914b519 111 // Extra cuts for hybrids
112 // first the global tracks we want to take
113 AliESDtrackCuts* esdTrackCutsHTG = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
114 esdTrackCutsHTG->SetName("Global Hybrid tracks, loose DCA");
115 esdTrackCutsHTG->SetMaxDCAToVertexXY(2.4);
116 esdTrackCutsHTG->SetMaxDCAToVertexZ(3.2);
117 esdTrackCutsHTG->SetDCAToVertex2D(kTRUE);
118 esdTrackCutsHTG->SetMaxChi2TPCConstrainedGlobal(36);
119
120 // Than the complementary tracks which will be stored as global
121 // constraint, complement is done in the ESDFilter task
122 AliESDtrackCuts* esdTrackCutsHTGC = new AliESDtrackCuts(*esdTrackCutsHTG);
123 esdTrackCutsHTGC->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement");
124 esdTrackCutsHTGC->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff);
50a15d74 125 esdTrackCutsHTGC->SetRequireITSRefit(kFALSE);
0914b519 126
ba206921 127 // standard cuts with tight DCA cut, using cluster cut instead of crossed rows (a la 2010 default)
128 AliESDtrackCuts* esdTrackCutsH2Cluster = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE, 0);
129
a550fcbd 130 // Compose the filter
3ef9ce84 131 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
0914b519 132 // 1, 1<<0
3ef9ce84 133 trackFilter->AddCuts(esdTrackCutsL);
0914b519 134 // 2, 1<<1
099d8f33 135 trackFilter->AddCuts(esdTrackCutsITSsa);
0914b519 136 // 4, 1<<2
a550fcbd 137 trackFilter->AddCuts(itsStrong);
138 itsStrong->SetFilterMask(1); // AND with Standard track cuts
0914b519 139 // 8, 1<<3
a550fcbd 140 trackFilter->AddCuts(electronID);
141 electronID->SetFilterMask(4); // AND with Pixel Cuts
0914b519 142 // 16, 1<<4
cfd26fc5 143 trackFilter->AddCuts(esdTrackCutsH);
0914b519 144 // 32, 1<<5
103431ad 145 trackFilter->AddCuts(esdTrackCutsH2);
0914b519 146 // 64, 1<<6
103431ad 147 trackFilter->AddCuts(esdTrackCutsH3);
4dae02e3 148 // 128 , 1 << 7
149 trackFilter->AddCuts(esdTrackCutsTPCOnly);
150 if(enableTPCOnlyAODTracks)esdfilter->SetTPCOnlyFilterMask(128);
0914b519 151 // 256, 1 << 8 Global Hybrids
152 trackFilter->AddCuts(esdTrackCutsHTG);
153 esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid
154 // 512, 1<< 9 GlobalConstraint Hybrids
155 trackFilter->AddCuts(esdTrackCutsHTGC);
156 esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks
157 esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement
ba206921 158 // 1024, 1<< 10
159 trackFilter->AddCuts(esdTrackCutsH2Cluster);
4dae02e3 160
a550fcbd 161 // Filter with cuts on V0s
04f2cd11 162 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 163 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 164 esdV0Cuts->SetMaxRadius(200);
099d8f33 165 esdV0Cuts->SetMinDcaPosToVertex(0.05);
166 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 167 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 168 esdV0Cuts->SetMinCosinePointingAngle(0.99);
169 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
170 v0Filter->AddCuts(esdV0Cuts);
171
3ef9ce84 172 esdfilter->SetTrackFilter(trackFilter);
099d8f33 173 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 174
f785fc59 175 // Enable writing of Muon AODs
48f1c230 176 esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
79bd4a7a 177
178 // Enable writing of Dimuon AODs
179 esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
cfd26fc5 180
3ef9ce84 181 // Create ONLY the output containers for the data produced by the task.
182 // Get and connect other common input/output containers via the manager as below
183 //==============================================================================
184 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
185 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 186 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
187 if (useKineFilter) {
188 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
189 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 190 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
191 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 192 mgr->ConnectOutput (kinefilter, 1,coutputEx);
3827f93a 193 }
3ef9ce84 194 return esdfilter;
cfd26fc5 195 }
196