new track cut, for loser ITS requirement (128+16)
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskESDFilterPWG4Train.C
CommitLineData
ebad39a9 1
2AliAnalysisTaskESDfilter *AddTaskESDFilter(Bool_t useKineFilter=kTRUE,
3 Bool_t writeMuonAOD=kFALSE,
4 Bool_t writeDimuonAOD=kFALSE,
5 Bool_t usePhysicsSelection=kFALSE)
6{
7// Creates a filter task and adds it to the analysis manager.
8
9 // Get the pointer to the existing analysis manager via the static access method.
10 //==============================================================================
11 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
12 if (!mgr) {
13 ::Error("AddTaskESDFilter", "No analysis manager to connect to.");
14 return NULL;
15 }
16
17 // This task requires an ESD input handler and an AOD output handler.
18 // Check this using the analysis manager.
19 //===============================================================================
20 TString type = mgr->GetInputEventHandler()->GetDataType();
21 if (!type.Contains("ESD")) {
22 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler.");
23 return NULL;
24 }
25 // Check if AOD output handler exist.
26 AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler();
27 if (!aod_h) {
28 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler.");
29 return NULL;
30 }
31 // Check if MC handler is connected in case kine filter requested
32 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
33 if (!mcH && useKineFilter) {
34 ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
35 return NULL;
36 }
37
38 // Create the task, add it to the manager and configure it.
39 //===========================================================================
40 // Barrel tracks filter
41 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
42 mgr->AddTask(esdfilter);
43 // Muons
48602d36 44 // AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
45 // mgr->AddTask(esdmuonfilter);
ebad39a9 46 if(usePhysicsSelection){
47 esdfilter->SelectCollisionCandidates(AliVEvent::kAny);
48602d36 48 // esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny);
ebad39a9 49 }
50
51 // Filtering of MC particles (decays conversions etc)
52 // this task has to go AFTER all other filter tasks
53 // since it fills the AODMC array with all
54 // selected MC Particles, only this way we have the
55 // AODMCparticle information available for following tasks
56 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
57 if (useKineFilter) {
58 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
48602d36 59 if(usePhysicsSelection)kinefilter->SelectCollisionCandidates(AliVEvent::kAny);
ebad39a9 60 mgr->AddTask(kinefilter);
61 }
62
63 // Cuts on primary tracks
64 AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
65
66 // ITS stand-alone tracks
67 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
68 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
69
70 // Pixel OR necessary for the electrons
71 AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
72 itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
73
74
75 // PID for the electrons
76 AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
77 electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
78
79 // tighter cuts on primary particles for high pT tracks
80 // take the standard cuts, which include already
81 // ITSrefit and use only primaries...
3456f527 82
39e7e8ab 83 // loose DCA cuts
3456f527 84 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE);
85 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
86 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
87 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
f4132e7d 88 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
89 esdTrackCutsH->SetPtRange(0.15,1E10);
3456f527 90
91 // standard cuts with tight DCA cut
92 AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
f4132e7d 93 esdTrackCutsH2->SetPtRange(0.15,1E10);
3456f527 94
95 // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster
96 // tracks selected by this cut are exclusive to those selected by the previous cut
97 AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
98 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
99 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst);
100
ebad39a9 101
1c79997e 102 AliESDtrackCuts* esdTrackCutsH4 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE);
103 esdTrackCutsH4->SetMaxDCAToVertexXY(2.4);
104 esdTrackCutsH4->SetMaxDCAToVertexZ(3.2);
105 esdTrackCutsH4->SetDCAToVertex2D(kTRUE);
106 esdTrackCutsH4->SetDCAToVertex2D(kTRUE);
107 esdTrackCutsH4->SetPtRange(0.15,1E10);
108 esdTrackCutsH4->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
109 esdTrackCutsH4->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst);
58a3693a 110
ebad39a9 111 // Compose the filter
112 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
39e7e8ab 113 // 1, 1<<0
ebad39a9 114 trackFilter->AddCuts(esdTrackCutsL);
39e7e8ab 115 // 2 1<<1
ebad39a9 116 trackFilter->AddCuts(esdTrackCutsITSsa);
39e7e8ab 117 // 4 1<<2
ebad39a9 118 trackFilter->AddCuts(itsStrong);
119 itsStrong->SetFilterMask(1); // AND with Standard track cuts
39e7e8ab 120 // 8 1<<3
ebad39a9 121 trackFilter->AddCuts(electronID);
122 electronID->SetFilterMask(4); // AND with Pixel Cuts
39e7e8ab 123 // 16 1<<4
ebad39a9 124 trackFilter->AddCuts(esdTrackCutsH);
39e7e8ab 125 // 32 1<<5
ebad39a9 126 trackFilter->AddCuts(esdTrackCutsH2);
39e7e8ab 127 // 64 1<<6
3456f527 128 trackFilter->AddCuts(esdTrackCutsH3);
39e7e8ab 129 // 128 1<<7
1c79997e 130 trackFilter->AddCuts(esdTrackCutsH4);
ebad39a9 131
132 // Filter with cuts on V0s
133 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
134 esdV0Cuts->SetMinRadius(0.2);
135 esdV0Cuts->SetMaxRadius(200);
136 esdV0Cuts->SetMinDcaPosToVertex(0.05);
137 esdV0Cuts->SetMinDcaNegToVertex(0.05);
138 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
139 esdV0Cuts->SetMinCosinePointingAngle(0.99);
140 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
141 // v0Filter->AddCuts(esdV0Cuts);
142
143 esdfilter->SetTrackFilter(trackFilter);
144 // esdfilter->SetV0Filter(v0Filter);
145
146 // Enable writing of Muon AODs
48602d36 147 // esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
ebad39a9 148
149 // Enable writing of Dimuon AODs
48602d36 150 // esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
ebad39a9 151
152 // Create ONLY the output containers for the data produced by the task.
153 // Get and connect other common input/output containers via the manager as below
154 //==============================================================================
155
156 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
157 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
158
159
160 // mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
161 if (useKineFilter) {
162 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
163 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
164 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
165 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
166 mgr->ConnectOutput (kinefilter, 1,coutputEx);
167 }
168 return esdfilter;
169 }
170