updates for differnt jet configs (including background), reduced number of UA1 Jets
[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
070f06d2 111 // TPC only tracks
112 AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
113 esdTrackCutsTPCOnly->SetMinNClustersTPC(70);
114
ebad39a9 115 // Compose the filter
116 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
39e7e8ab 117 // 1, 1<<0
ebad39a9 118 trackFilter->AddCuts(esdTrackCutsL);
39e7e8ab 119 // 2 1<<1
ebad39a9 120 trackFilter->AddCuts(esdTrackCutsITSsa);
39e7e8ab 121 // 4 1<<2
ebad39a9 122 trackFilter->AddCuts(itsStrong);
123 itsStrong->SetFilterMask(1); // AND with Standard track cuts
39e7e8ab 124 // 8 1<<3
ebad39a9 125 trackFilter->AddCuts(electronID);
126 electronID->SetFilterMask(4); // AND with Pixel Cuts
39e7e8ab 127 // 16 1<<4
ebad39a9 128 trackFilter->AddCuts(esdTrackCutsH);
39e7e8ab 129 // 32 1<<5
ebad39a9 130 trackFilter->AddCuts(esdTrackCutsH2);
39e7e8ab 131 // 64 1<<6
3456f527 132 trackFilter->AddCuts(esdTrackCutsH3);
39e7e8ab 133 // 128 1<<7
1c79997e 134 trackFilter->AddCuts(esdTrackCutsH4);
070f06d2 135 // 256 1<<8
136 trackFilter->AddCuts(esdTrackCutsTPCOnly);
137 esdfilter->SetTPCOnlyFilterMask(1<<8);
ebad39a9 138 // Filter with cuts on V0s
139 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
140 esdV0Cuts->SetMinRadius(0.2);
141 esdV0Cuts->SetMaxRadius(200);
142 esdV0Cuts->SetMinDcaPosToVertex(0.05);
143 esdV0Cuts->SetMinDcaNegToVertex(0.05);
144 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
145 esdV0Cuts->SetMinCosinePointingAngle(0.99);
146 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
070f06d2 147 v0Filter->AddCuts(esdV0Cuts);
ebad39a9 148
149 esdfilter->SetTrackFilter(trackFilter);
070f06d2 150 esdfilter->SetV0Filter(v0Filter);
ebad39a9 151
152 // Enable writing of Muon AODs
48602d36 153 // esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
ebad39a9 154
155 // Enable writing of Dimuon AODs
48602d36 156 // esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
ebad39a9 157
158 // Create ONLY the output containers for the data produced by the task.
159 // Get and connect other common input/output containers via the manager as below
160 //==============================================================================
161
162 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
163 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
164
165
166 // mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
167 if (useKineFilter) {
168 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
169 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
170 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
171 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
172 mgr->ConnectOutput (kinefilter, 1,coutputEx);
173 }
174 return esdfilter;
175 }
176