Removed aliroot as executable command in the generated trains
[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
91 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(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
97 AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
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
101 AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
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();
108 esdTrackCutsTPCOnly->SetMinNClustersTPC(70);
a550fcbd 109
110 // Compose the filter
3ef9ce84 111 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
a550fcbd 112 // 1
3ef9ce84 113 trackFilter->AddCuts(esdTrackCutsL);
a550fcbd 114 // 2
099d8f33 115 trackFilter->AddCuts(esdTrackCutsITSsa);
a550fcbd 116 // 4
117 trackFilter->AddCuts(itsStrong);
118 itsStrong->SetFilterMask(1); // AND with Standard track cuts
119 // 8
120 trackFilter->AddCuts(electronID);
121 electronID->SetFilterMask(4); // AND with Pixel Cuts
cfd26fc5 122 // 16
123 trackFilter->AddCuts(esdTrackCutsH);
103431ad 124 // 32
125 trackFilter->AddCuts(esdTrackCutsH2);
126 // 64
127 trackFilter->AddCuts(esdTrackCutsH3);
4dae02e3 128 // 128 , 1 << 7
129 trackFilter->AddCuts(esdTrackCutsTPCOnly);
130 if(enableTPCOnlyAODTracks)esdfilter->SetTPCOnlyFilterMask(128);
131
a550fcbd 132 // Filter with cuts on V0s
04f2cd11 133 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 134 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 135 esdV0Cuts->SetMaxRadius(200);
099d8f33 136 esdV0Cuts->SetMinDcaPosToVertex(0.05);
137 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 138 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 139 esdV0Cuts->SetMinCosinePointingAngle(0.99);
140 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
141 v0Filter->AddCuts(esdV0Cuts);
142
3ef9ce84 143 esdfilter->SetTrackFilter(trackFilter);
099d8f33 144 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 145
f785fc59 146 // Enable writing of Muon AODs
48f1c230 147 esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
79bd4a7a 148
149 // Enable writing of Dimuon AODs
150 esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
cfd26fc5 151
3ef9ce84 152 // Create ONLY the output containers for the data produced by the task.
153 // Get and connect other common input/output containers via the manager as below
154 //==============================================================================
155 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
156 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 157 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
158 if (useKineFilter) {
159 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
160 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 161 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
162 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 163 mgr->ConnectOutput (kinefilter, 1,coutputEx);
3827f93a 164 }
3ef9ce84 165 return esdfilter;
cfd26fc5 166 }
167