Patch for the tracker
[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
51 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
52 mgr->AddTask(esdmuonfilter);
daf100e1 53 if(usePhysicsSelection){
0c6c629b 54 esdfilter->SelectCollisionCandidates(AliVEvent::kAny);
55 esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny);
daf100e1 56 }
3827f93a 57
58 // Filtering of MC particles (decays conversions etc)
59 // this task has to go AFTER all other filter tasks
60 // since it fills the AODMC array with all
61 // selected MC Particles, only this way we have the
62 // AODMCparticle information available for following tasks
63 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
64 if (useKineFilter) {
65 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
66 mgr->AddTask(kinefilter);
67 }
68
216c8759 69 AliAnalysisTaskAODCentralityMaker* ctask = 0;
70
71 if (useCentralityTask) {
72 ctask = new AliAnalysisTaskAODCentralityMaker("AODCentralityMaker");
73 ctask->SetDeltaAODFileName("AliAODCentrality.root");
74 mgr->AddTask(ctask);
75 }
76
099d8f33 77 // Cuts on primary tracks
31a3bbb0 78 AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
a550fcbd 79
099d8f33 80 // ITS stand-alone tracks
04f2cd11 81 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
31a3bbb0 82 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
099d8f33 83
a550fcbd 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
103431ad 93 // standard cuts with very loose DCA
94 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE);
cfd26fc5 95 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
96 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
97 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
cfd26fc5 98
103431ad 99 // standard cuts with tight DCA cut
100 AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
101
102 // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster
103 // tracks selected by this cut are exclusive to those selected by the previous cut
104 AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
105 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
106 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst);
cfd26fc5 107
4dae02e3 108 // TPC only tracks: Optionally enable the writing of TPConly information
109 // constrained to SPD vertex in the filter below
110 AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
111 esdTrackCutsTPCOnly->SetMinNClustersTPC(70);
a550fcbd 112
113 // Compose the filter
3ef9ce84 114 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
a550fcbd 115 // 1
3ef9ce84 116 trackFilter->AddCuts(esdTrackCutsL);
a550fcbd 117 // 2
099d8f33 118 trackFilter->AddCuts(esdTrackCutsITSsa);
a550fcbd 119 // 4
120 trackFilter->AddCuts(itsStrong);
121 itsStrong->SetFilterMask(1); // AND with Standard track cuts
122 // 8
123 trackFilter->AddCuts(electronID);
124 electronID->SetFilterMask(4); // AND with Pixel Cuts
cfd26fc5 125 // 16
126 trackFilter->AddCuts(esdTrackCutsH);
103431ad 127 // 32
128 trackFilter->AddCuts(esdTrackCutsH2);
129 // 64
130 trackFilter->AddCuts(esdTrackCutsH3);
4dae02e3 131 // 128 , 1 << 7
132 trackFilter->AddCuts(esdTrackCutsTPCOnly);
133 if(enableTPCOnlyAODTracks)esdfilter->SetTPCOnlyFilterMask(128);
134
a550fcbd 135 // Filter with cuts on V0s
04f2cd11 136 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 137 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 138 esdV0Cuts->SetMaxRadius(200);
099d8f33 139 esdV0Cuts->SetMinDcaPosToVertex(0.05);
140 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 141 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 142 esdV0Cuts->SetMinCosinePointingAngle(0.99);
143 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
144 v0Filter->AddCuts(esdV0Cuts);
145
3ef9ce84 146 esdfilter->SetTrackFilter(trackFilter);
099d8f33 147 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 148
f785fc59 149 // Enable writing of Muon AODs
48f1c230 150 esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
79bd4a7a 151
152 // Enable writing of Dimuon AODs
153 esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
cfd26fc5 154
3ef9ce84 155 // Create ONLY the output containers for the data produced by the task.
156 // Get and connect other common input/output containers via the manager as below
157 //==============================================================================
158 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
159 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 160 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
161 if (useKineFilter) {
162 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
163 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 164 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
165 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 166 mgr->ConnectOutput (kinefilter, 1,coutputEx);
3827f93a 167 }
3038fa73 168 if (useCentralityTask) {
169 mgr->ConnectInput (ctask, 0, mgr->GetCommonInputContainer());
170 mgr->ConnectOutput(ctask, 0, mgr->GetCommonOutputContainer());
171 }
3ef9ce84 172 return esdfilter;
cfd26fc5 173 }
174