Deepa code electron hadron correlation
[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,
4354b266 4 Bool_t usePhysicsSelection=kFALSE,
bd625b5b 5 Bool_t useCentralityTask=kFALSE, /*obsolete*/
4354b266 6 Int_t tofTimeZeroType=AliESDpid::kTOF_T0,
7 Bool_t enableTPCOnlyAODTracks=kFALSE,
8 Bool_t disableCascades=kFALSE,
9 Bool_t disableKinks=kFALSE)
3ef9ce84 10{
11// Creates a filter task and adds it to the analysis manager.
12
13 // Get the pointer to the existing analysis manager via the static access method.
14 //==============================================================================
15 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
16 if (!mgr) {
c85963a0 17 ::Error("AddTaskESDFilter", "No analysis manager to connect to.");
3ef9ce84 18 return NULL;
19 }
20
21 // This task requires an ESD input handler and an AOD output handler.
22 // Check this using the analysis manager.
23 //===============================================================================
24 TString type = mgr->GetInputEventHandler()->GetDataType();
25 if (!type.Contains("ESD")) {
c85963a0 26 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler.");
3ef9ce84 27 return NULL;
28 }
29 // Check if AOD output handler exist.
30 AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler();
31 if (!aod_h) {
c85963a0 32 ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler.");
3ef9ce84 33 return NULL;
099d8f33 34 }
35 // Check if MC handler is connected in case kine filter requested
36 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
37 if (!mcH && useKineFilter) {
38 ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested");
39 return NULL;
3ef9ce84 40 }
41
42 // Create the task, add it to the manager and configure it.
099d8f33 43 //===========================================================================
44 // Barrel tracks filter
3ef9ce84 45 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
26917b0b 46 esdfilter->SetTimeZeroType(tofTimeZeroType);
4354b266 47 if (disableCascades) esdfilter->DisableCascades();
48 if (disableKinks) esdfilter->DisableKinks();
c7ef1c47 49
50 mgr->AddTask(esdfilter);
51
099d8f33 52 // Muons
14d6fad5 53 Bool_t onlyMuon=kTRUE;
54 Bool_t keepAllEvents=kTRUE;
55 Int_t mcMode=(useKineFilter ? 2 : 0); // use 1 instead of 2 to get all MC information instead of just ancestors of mu tracks
56 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter",onlyMuon,keepAllEvents,mcMode);
099d8f33 57 mgr->AddTask(esdmuonfilter);
daf100e1 58 if(usePhysicsSelection){
0c6c629b 59 esdfilter->SelectCollisionCandidates(AliVEvent::kAny);
60 esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny);
daf100e1 61 }
3827f93a 62
63 // Filtering of MC particles (decays conversions etc)
64 // this task has to go AFTER all other filter tasks
65 // since it fills the AODMC array with all
66 // selected MC Particles, only this way we have the
67 // AODMCparticle information available for following tasks
68 AliAnalysisTaskMCParticleFilter *kinefilter = 0;
69 if (useKineFilter) {
70 kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter");
71 mgr->AddTask(kinefilter);
72 }
73
099d8f33 74 // Cuts on primary tracks
31a3bbb0 75 AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
a550fcbd 76
099d8f33 77 // ITS stand-alone tracks
04f2cd11 78 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts");
31a3bbb0 79 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
099d8f33 80
a550fcbd 81 // Pixel OR necessary for the electrons
82 AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS");
83 itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
84
85
86 // PID for the electrons
87 AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts");
88 electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.);
89
103431ad 90 // standard cuts with very loose DCA
0914b519 91 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
cfd26fc5 92 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
93 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
94 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
cfd26fc5 95
103431ad 96 // standard cuts with tight DCA cut
0914b519 97 AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
103431ad 98
99 // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster
100 // tracks selected by this cut are exclusive to those selected by the previous cut
0914b519 101 AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
103431ad 102 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
103 esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst);
cfd26fc5 104
4dae02e3 105 // TPC only tracks: Optionally enable the writing of TPConly information
106 // constrained to SPD vertex in the filter below
107 AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
108 esdTrackCutsTPCOnly->SetMinNClustersTPC(70);
a550fcbd 109
0914b519 110 // Extra cuts for hybrids
111 // first the global tracks we want to take
112 AliESDtrackCuts* esdTrackCutsHTG = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
113 esdTrackCutsHTG->SetName("Global Hybrid tracks, loose DCA");
114 esdTrackCutsHTG->SetMaxDCAToVertexXY(2.4);
115 esdTrackCutsHTG->SetMaxDCAToVertexZ(3.2);
116 esdTrackCutsHTG->SetDCAToVertex2D(kTRUE);
117 esdTrackCutsHTG->SetMaxChi2TPCConstrainedGlobal(36);
118
119 // Than the complementary tracks which will be stored as global
120 // constraint, complement is done in the ESDFilter task
121 AliESDtrackCuts* esdTrackCutsHTGC = new AliESDtrackCuts(*esdTrackCutsHTG);
122 esdTrackCutsHTGC->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement");
123 esdTrackCutsHTGC->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff);
124 // esdTrackCutsHTGC->SetRequireITSRefit(kFALSE)
125
a550fcbd 126 // Compose the filter
3ef9ce84 127 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
0914b519 128 // 1, 1<<0
3ef9ce84 129 trackFilter->AddCuts(esdTrackCutsL);
0914b519 130 // 2, 1<<1
099d8f33 131 trackFilter->AddCuts(esdTrackCutsITSsa);
0914b519 132 // 4, 1<<2
a550fcbd 133 trackFilter->AddCuts(itsStrong);
134 itsStrong->SetFilterMask(1); // AND with Standard track cuts
0914b519 135 // 8, 1<<3
a550fcbd 136 trackFilter->AddCuts(electronID);
137 electronID->SetFilterMask(4); // AND with Pixel Cuts
0914b519 138 // 16, 1<<4
cfd26fc5 139 trackFilter->AddCuts(esdTrackCutsH);
0914b519 140 // 32, 1<<5
103431ad 141 trackFilter->AddCuts(esdTrackCutsH2);
0914b519 142 // 64, 1<<6
103431ad 143 trackFilter->AddCuts(esdTrackCutsH3);
4dae02e3 144 // 128 , 1 << 7
145 trackFilter->AddCuts(esdTrackCutsTPCOnly);
146 if(enableTPCOnlyAODTracks)esdfilter->SetTPCOnlyFilterMask(128);
0914b519 147 // 256, 1 << 8 Global Hybrids
148 trackFilter->AddCuts(esdTrackCutsHTG);
149 esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid
150 // 512, 1<< 9 GlobalConstraint Hybrids
151 trackFilter->AddCuts(esdTrackCutsHTGC);
152 esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks
153 esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement
4dae02e3 154
a550fcbd 155 // Filter with cuts on V0s
04f2cd11 156 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts");
099d8f33 157 esdV0Cuts->SetMinRadius(0.2);
36cf8bb5 158 esdV0Cuts->SetMaxRadius(200);
099d8f33 159 esdV0Cuts->SetMinDcaPosToVertex(0.05);
160 esdV0Cuts->SetMinDcaNegToVertex(0.05);
36cf8bb5 161 esdV0Cuts->SetMaxDcaV0Daughters(1.5);
099d8f33 162 esdV0Cuts->SetMinCosinePointingAngle(0.99);
163 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
164 v0Filter->AddCuts(esdV0Cuts);
165
3ef9ce84 166 esdfilter->SetTrackFilter(trackFilter);
099d8f33 167 esdfilter->SetV0Filter(v0Filter);
3ef9ce84 168
f785fc59 169 // Enable writing of Muon AODs
48f1c230 170 esdmuonfilter->SetWriteMuonAOD(writeMuonAOD);
79bd4a7a 171
172 // Enable writing of Dimuon AODs
173 esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD);
cfd26fc5 174
3ef9ce84 175 // Create ONLY the output containers for the data produced by the task.
176 // Get and connect other common input/output containers via the manager as below
177 //==============================================================================
178 mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer());
179 mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer());
099d8f33 180 mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer());
181 if (useKineFilter) {
182 mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer());
183 mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer());
a3b51fd2 184 AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
185 AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
84c04254 186 mgr->ConnectOutput (kinefilter, 1,coutputEx);
3827f93a 187 }
3ef9ce84 188 return esdfilter;
cfd26fc5 189 }
190