Added macro for analysing output of AliAnalysisTaskHardSoft
[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){
46 esdfilter->SelectCollisionCandidates();
47 esdmuonfilter->SelectCollisionCandidates();
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
04f2cd11 62 AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("Standard Track Cuts", "ESD Track Cuts");
099d8f33 63 esdTrackCutsL->SetMinNClustersTPC(50);
3ef9ce84 64 esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
3ef9ce84 65 esdTrackCutsL->SetRequireTPCRefit(kTRUE);
80a77868 66 esdTrackCutsL->SetMaxDCAToVertexXY(2.4);
67 esdTrackCutsL->SetMaxDCAToVertexZ(3.2);
099d8f33 68 esdTrackCutsL->SetDCAToVertex2D(kTRUE);
69 esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
70 esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
a550fcbd 71
099d8f33 72 // ITS stand-alone tracks
04f2cd11 73 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
c4d54b2e 74 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE, kTRUE);
099d8f33 75
a550fcbd 76 // Pixel OR necessary for the electrons
77 AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
78 itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
79
80
81 // PID for the electrons
82 AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
83 electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
84
cfd26fc5 85 // tighter cuts on primary particles for high pT tracks
86 // needed as input for jetfinder
87 AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("Standard Track Cuts + ITSRefit", "High pT ESD Track Cuts");
88 esdTrackCutsH->SetMinNClustersTPC(50);
89 esdTrackCutsH->SetMaxChi2PerClusterTPC(3.5);
90 esdTrackCutsH->SetRequireTPCRefit(kTRUE);
91 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
92 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
93 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
94 esdTrackCutsH->SetRequireSigmaToVertex(kFALSE);
95 esdTrackCutsH->SetAcceptKinkDaughters(kFALSE);
96 esdTrackCutsH->SetRequireITSRefit(kTRUE); // additional cut
97
98
a550fcbd 99
100 // Compose the filter
3ef9ce84 101 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
a550fcbd 102 // 1
3ef9ce84 103 trackFilter->AddCuts(esdTrackCutsL);
a550fcbd 104 // 2
099d8f33 105 trackFilter->AddCuts(esdTrackCutsITSsa);
a550fcbd 106 // 4
107 trackFilter->AddCuts(itsStrong);
108 itsStrong->SetFilterMask(1); // AND with Standard track cuts
109 // 8
110 trackFilter->AddCuts(electronID);
111 electronID->SetFilterMask(4); // AND with Pixel Cuts
cfd26fc5 112 // 16
113 trackFilter->AddCuts(esdTrackCutsH);
114
a550fcbd 115 // Filter with cuts on V0s
04f2cd11 116 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 117 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 118 esdV0Cuts->SetMaxRadius(200);
099d8f33 119 esdV0Cuts->SetMinDcaPosToVertex(0.05);
120 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 121 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 122 esdV0Cuts->SetMinCosinePointingAngle(0.99);
123 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
124 v0Filter->AddCuts(esdV0Cuts);
125
3ef9ce84 126 esdfilter->SetTrackFilter(trackFilter);
099d8f33 127 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 128
f785fc59 129 // Enable writing of Muon AODs
48f1c230 130 esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
79bd4a7a 131
132 // Enable writing of Dimuon AODs
133 esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
cfd26fc5 134
3ef9ce84 135 // Create ONLY the output containers for the data produced by the task.
136 // Get and connect other common input/output containers via the manager as below
137 //==============================================================================
138 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
139 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 140 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
141 if (useKineFilter) {
142 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
143 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 144 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
145 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 146 mgr->ConnectOutput (kinefilter, 1,coutputEx);
3827f93a 147 }
3ef9ce84 148 return esdfilter;
cfd26fc5 149 }
150