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