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