Added an output file for average cross section and number of trials from pyxsec.root...
[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
38 if (useKineFilter) {
39 AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
40 mgr->AddTask(kinefilter);
41 }
42
3ef9ce84 43 // Create the task, add it to the manager and configure it.
099d8f33 44 //===========================================================================
45 // Barrel tracks filter
3ef9ce84 46 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
47 mgr->AddTask(esdfilter);
099d8f33 48 // Muons
49 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
50 mgr->AddTask(esdmuonfilter);
51
52 // Cuts on primary tracks
53 AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
54 esdTrackCutsL->SetMinNClustersTPC(50);
3ef9ce84 55 esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
3ef9ce84 56 esdTrackCutsL->SetRequireTPCRefit(kTRUE);
80a77868 57 esdTrackCutsL->SetMaxDCAToVertexXY(2.4);
58 esdTrackCutsL->SetMaxDCAToVertexZ(3.2);
099d8f33 59 esdTrackCutsL->SetDCAToVertex2D(kTRUE);
60 esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
61 esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
62 // ITS stand-alone tracks
63 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
64 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
65
3ef9ce84 66 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
67 trackFilter->AddCuts(esdTrackCutsL);
099d8f33 68 trackFilter->AddCuts(esdTrackCutsITSsa);
69
70 // Cuts on V0s
71 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
72 esdV0Cuts->SetMinRadius(0.2);
73 esdV0Cuts->SetMaxRadius(100);
74 esdV0Cuts->SetMinDcaPosToVertex(0.05);
75 esdV0Cuts->SetMinDcaNegToVertex(0.05);
76 esdV0Cuts->SetMaxDcaV0Daughters(0.5);
77 esdV0Cuts->SetMinCosinePointingAngle(0.99);
78 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
79 v0Filter->AddCuts(esdV0Cuts);
80
3ef9ce84 81 esdfilter->SetTrackFilter(trackFilter);
099d8f33 82 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 83
84
85 // Create ONLY the output containers for the data produced by the task.
86 // Get and connect other common input/output containers via the manager as below
87 //==============================================================================
88 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
89 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 90 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
91 if (useKineFilter) {
92 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
93 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 94 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
95 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
099d8f33 96 }
3ef9ce84 97 return esdfilter;
98}