Extending the functionality of the physics selection. Instead of providing a yes...
[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,
4 Bool_t usePhysicsSelection=kFALSE)
3ef9ce84 5{
6// Creates a filter task and adds it to the analysis manager.
7
8 // Get the pointer to the existing analysis manager via the static access method.
9 //==============================================================================
10 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
11 if (!mgr) {
c85963a0 12 ::Error("AddTaskESDFilter", "No analysis manager to connect to.");
3ef9ce84 13 return NULL;
14 }
15
16 // This task requires an ESD input handler and an AOD output handler.
17 // Check this using the analysis manager.
18 //===============================================================================
19 TString type = mgr->GetInputEventHandler()->GetDataType();
20 if (!type.Contains("ESD")) {
c85963a0 21 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler.");
3ef9ce84 22 return NULL;
23 }
24 // Check if AOD output handler exist.
25 AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler();
26 if (!aod_h) {
c85963a0 27 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler.");
3ef9ce84 28 return NULL;
099d8f33 29 }
30 // Check if MC handler is connected in case kine filter requested
31 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
32 if (!mcH && useKineFilter) {
33 ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
34 return NULL;
3ef9ce84 35 }
36
37 // Create the task, add it to the manager and configure it.
099d8f33 38 //===========================================================================
39 // Barrel tracks filter
3ef9ce84 40 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
41 mgr->AddTask(esdfilter);
099d8f33 42 // Muons
43 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
44 mgr->AddTask(esdmuonfilter);
daf100e1 45 if(usePhysicsSelection){
0c6c629b 46 esdfilter->SelectCollisionCandidates(AliVEvent::kAny);
47 esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny);
daf100e1 48 }
3827f93a 49
50 // Filtering of MC particles (decays conversions etc)
51 // this task has to go AFTER all other filter tasks
52 // since it fills the AODMC array with all
53 // selected MC Particles, only this way we have the
54 // AODMCparticle information available for following tasks
55 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
56 if (useKineFilter) {
57 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
58 mgr->AddTask(kinefilter);
59 }
60
099d8f33 61 // Cuts on primary tracks
31a3bbb0 62 AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
a550fcbd 63
099d8f33 64 // ITS stand-alone tracks
04f2cd11 65 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
31a3bbb0 66 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
099d8f33 67
a550fcbd 68 // Pixel OR necessary for the electrons
69 AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
70 itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
71
72
73 // PID for the electrons
74 AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
75 electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
76
cfd26fc5 77 // tighter cuts on primary particles for high pT tracks
78 // needed as input for jetfinder
79 AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("Standard Track Cuts + ITSRefit", "High pT ESD Track Cuts");
80 esdTrackCutsH->SetMinNClustersTPC(50);
81 esdTrackCutsH->SetMaxChi2PerClusterTPC(3.5);
82 esdTrackCutsH->SetRequireTPCRefit(kTRUE);
83 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
84 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
85 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
86 esdTrackCutsH->SetRequireSigmaToVertex(kFALSE);
87 esdTrackCutsH->SetAcceptKinkDaughters(kFALSE);
88 esdTrackCutsH->SetRequireITSRefit(kTRUE); // additional cut
89
90
a550fcbd 91
92 // Compose the filter
3ef9ce84 93 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
a550fcbd 94 // 1
3ef9ce84 95 trackFilter->AddCuts(esdTrackCutsL);
a550fcbd 96 // 2
099d8f33 97 trackFilter->AddCuts(esdTrackCutsITSsa);
a550fcbd 98 // 4
99 trackFilter->AddCuts(itsStrong);
100 itsStrong->SetFilterMask(1); // AND with Standard track cuts
101 // 8
102 trackFilter->AddCuts(electronID);
103 electronID->SetFilterMask(4); // AND with Pixel Cuts
cfd26fc5 104 // 16
105 trackFilter->AddCuts(esdTrackCutsH);
106
a550fcbd 107 // Filter with cuts on V0s
04f2cd11 108 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 109 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 110 esdV0Cuts->SetMaxRadius(200);
099d8f33 111 esdV0Cuts->SetMinDcaPosToVertex(0.05);
112 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 113 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 114 esdV0Cuts->SetMinCosinePointingAngle(0.99);
115 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
116 v0Filter->AddCuts(esdV0Cuts);
117
3ef9ce84 118 esdfilter->SetTrackFilter(trackFilter);
099d8f33 119 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 120
f785fc59 121 // Enable writing of Muon AODs
48f1c230 122 esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
79bd4a7a 123
124 // Enable writing of Dimuon AODs
125 esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
cfd26fc5 126
3ef9ce84 127 // Create ONLY the output containers for the data produced by the task.
128 // Get and connect other common input/output containers via the manager as below
129 //==============================================================================
130 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
131 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 132 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
133 if (useKineFilter) {
134 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
135 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 136 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
137 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 138 mgr->ConnectOutput (kinefilter, 1,coutputEx);
3827f93a 139 }
3ef9ce84 140 return esdfilter;
cfd26fc5 141 }
142