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