Protection reinforced
[u/mrichter/AliRoot.git] / ANALYSIS / macros / AddTaskESDFilter.C
CommitLineData
099d8f33 1AliAnalysisTaskESDfilter *AddTaskESDFilter(Bool_t useKineFilter=kTRUE)
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
099d8f33 34 // Filtering of MC particles (decays conversions etc)
35 // this task is also needed to set the MCEventHandler
36 // to the AODHandler, this will not be needed when
37 // AODHandler goes to ANALYSISalice
ee75cfc3 38 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
099d8f33 39 if (useKineFilter) {
ee75cfc3 40 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
099d8f33 41 mgr->AddTask(kinefilter);
42 }
43
3ef9ce84 44 // Create the task, add it to the manager and configure it.
099d8f33 45 //===========================================================================
46 // Barrel tracks filter
3ef9ce84 47 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
48 mgr->AddTask(esdfilter);
099d8f33 49 // Muons
50 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
51 mgr->AddTask(esdmuonfilter);
52
53 // Cuts on primary tracks
04f2cd11 54 AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("Standard Track Cuts", "ESD Track Cuts");
099d8f33 55 esdTrackCutsL->SetMinNClustersTPC(50);
3ef9ce84 56 esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
3ef9ce84 57 esdTrackCutsL->SetRequireTPCRefit(kTRUE);
80a77868 58 esdTrackCutsL->SetMaxDCAToVertexXY(2.4);
59 esdTrackCutsL->SetMaxDCAToVertexZ(3.2);
099d8f33 60 esdTrackCutsL->SetDCAToVertex2D(kTRUE);
61 esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
62 esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
a550fcbd 63
099d8f33 64 // ITS stand-alone tracks
04f2cd11 65 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
099d8f33 66 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
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
77
78 // Compose the filter
3ef9ce84 79 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
a550fcbd 80 // 1
3ef9ce84 81 trackFilter->AddCuts(esdTrackCutsL);
a550fcbd 82 // 2
099d8f33 83 trackFilter->AddCuts(esdTrackCutsITSsa);
a550fcbd 84 // 4
85 trackFilter->AddCuts(itsStrong);
86 itsStrong->SetFilterMask(1); // AND with Standard track cuts
87 // 8
88 trackFilter->AddCuts(electronID);
89 electronID->SetFilterMask(4); // AND with Pixel Cuts
099d8f33 90
a550fcbd 91 // Filter with cuts on V0s
04f2cd11 92 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 93 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 94 esdV0Cuts->SetMaxRadius(200);
099d8f33 95 esdV0Cuts->SetMinDcaPosToVertex(0.05);
96 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 97 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 98 esdV0Cuts->SetMinCosinePointingAngle(0.99);
99 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
100 v0Filter->AddCuts(esdV0Cuts);
101
3ef9ce84 102 esdfilter->SetTrackFilter(trackFilter);
099d8f33 103 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 104
105
106 // Create ONLY the output containers for the data produced by the task.
107 // Get and connect other common input/output containers via the manager as below
108 //==============================================================================
109 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
110 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 111 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
112 if (useKineFilter) {
113 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
114 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 115 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
116 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 117 mgr->ConnectOutput (kinefilter, 1,coutputEx);
099d8f33 118 }
3ef9ce84 119 return esdfilter;
120}