]>
Commit | Line | Data |
---|---|---|
6e8d91c9 | 1 | // $Id$ |
b87234fd | 2 | // |
42642780 | 3 | // Emcal base analysis task. |
b87234fd | 4 | // |
42642780 | 5 | // Author: S.Aiola |
6 | ||
7 | #include "AliAnalysisTaskEmcal.h" | |
b87234fd | 8 | |
9 | #include <TObject.h> | |
10 | #include <TChain.h> | |
11 | #include <TClonesArray.h> | |
12 | #include <TList.h> | |
13 | ||
77a4b369 | 14 | #include "AliESDEvent.h" |
b87234fd | 15 | #include "AliAnalysisManager.h" |
16 | #include "AliCentrality.h" | |
17 | #include "AliVCluster.h" | |
18 | #include "AliVParticle.h" | |
19 | #include "AliEmcalJet.h" | |
20 | #include "AliVEventHandler.h" | |
21 | #include "AliLog.h" | |
22 | #include "AliEMCALGeometry.h" | |
23 | ||
b87234fd | 24 | ClassImp(AliAnalysisTaskEmcal) |
25 | ||
26 | //________________________________________________________________________ | |
27 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() : | |
28 | AliAnalysisTaskSE("AliAnalysisTaskEmcal"), | |
29 | fAnaType(kTPC), | |
30 | fInitialized(kFALSE), | |
31 | fMinEta(-0.9), | |
32 | fMaxEta(0.9), | |
33 | fMinPhi(-10), | |
34 | fMaxPhi(10), | |
35 | fJetRadius(0.4), | |
36 | fTracksName("Tracks"), | |
37 | fCaloName("CaloClusters"), | |
38 | fJetsName("Jets"), | |
39 | fNbins(500), | |
40 | fMinPt(0), | |
41 | fMaxPt(250), | |
42 | fPtCut(0.15), | |
43 | fPtBiasJetTrack(10), | |
44 | fPtBiasJetClus(10), | |
45 | fJetPtCut(1), | |
46 | fJetAreaCut(0.2), | |
47 | fTracks(0), | |
48 | fCaloClusters(0), | |
49 | fJets(0), | |
50 | fCent(0), | |
51 | fCentBin(-1), | |
52 | fOutput(0) | |
53 | { | |
54 | // Default constructor. | |
55 | ||
56 | fVertex[0] = 0; | |
57 | fVertex[1] = 0; | |
58 | fVertex[2] = 0; | |
6e8d91c9 | 59 | |
60 | // Output slot #1 writes into a TH1 container | |
61 | DefineOutput(1, TList::Class()); | |
b87234fd | 62 | } |
63 | ||
64 | //________________________________________________________________________ | |
65 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name) : | |
66 | AliAnalysisTaskSE(name), | |
67 | fAnaType(kTPC), | |
68 | fInitialized(kFALSE), | |
69 | fMinEta(-0.9), | |
70 | fMaxEta(0.9), | |
71 | fMinPhi(-10), | |
72 | fMaxPhi(10), | |
73 | fJetRadius(0.4), | |
74 | fTracksName("Tracks"), | |
75 | fCaloName("CaloClusters"), | |
76 | fJetsName("Jets"), | |
77 | fNbins(500), | |
78 | fMinPt(0), | |
79 | fMaxPt(250), | |
80 | fPtCut(0.15), | |
81 | fPtBiasJetTrack(10), | |
82 | fPtBiasJetClus(10), | |
83 | fJetPtCut(1), | |
84 | fJetAreaCut(0.2), | |
85 | fTracks(0), | |
86 | fCaloClusters(0), | |
87 | fJets(0), | |
88 | fCent(0), | |
89 | fCentBin(-1), | |
90 | fOutput(0) | |
91 | { | |
92 | // Standard constructor. | |
93 | ||
94 | fVertex[0] = 0; | |
95 | fVertex[1] = 0; | |
96 | fVertex[2] = 0; | |
97 | ||
98 | // Output slot #1 writes into a TH1 container | |
99 | DefineOutput(1, TList::Class()); | |
100 | } | |
101 | ||
102 | //________________________________________________________________________ | |
103 | AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal() | |
104 | { | |
105 | // Destructor | |
106 | } | |
107 | ||
108 | //________________________________________________________________________ | |
109 | void AliAnalysisTaskEmcal::UserCreateOutputObjects() | |
110 | { | |
42642780 | 111 | // User create outputs. |
b87234fd | 112 | } |
113 | ||
77a4b369 | 114 | //_____________________________________________________ |
115 | Int_t AliAnalysisTaskEmcal::GetBeamType() | |
116 | { | |
117 | // Get beam type : pp-AA-pA | |
118 | // ESDs have it directly, AODs get it from hardcoded run number ranges | |
119 | ||
120 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent()); | |
121 | if (esd) { | |
122 | const AliESDRun *run = esd->GetESDRun(); | |
123 | TString beamType = run->GetBeamType(); | |
124 | if (beamType == "p-p") | |
125 | return kpp; | |
126 | else if (beamType == "A-A") | |
127 | return kAA; | |
128 | else if (beamType == "p-A") | |
129 | return kpA; | |
130 | else | |
131 | return kNA; | |
132 | } | |
133 | else | |
134 | { | |
135 | Int_t runNumber = InputEvent()->GetRunNumber(); | |
136 | if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h | |
137 | (runNumber >= 166529 && runNumber <= 170593)) // LHC11h | |
138 | { | |
139 | return kAA; | |
140 | } | |
141 | else | |
142 | { | |
143 | return kpp; | |
144 | } | |
145 | } | |
146 | } | |
147 | ||
b87234fd | 148 | //________________________________________________________________________ |
149 | void AliAnalysisTaskEmcal::RetrieveEventObjects() | |
150 | { | |
42642780 | 151 | // Retrieve objects from event. |
152 | ||
77a4b369 | 153 | if (!InputEvent()) { |
154 | AliError("Could not retrieve event! Returning..."); | |
155 | return; | |
156 | } | |
157 | ||
b87234fd | 158 | fVertex[0] = 0; |
159 | fVertex[1] = 0; | |
160 | fVertex[2] = 0; | |
161 | InputEvent()->GetPrimaryVertex()->GetXYZ(fVertex); | |
162 | ||
77a4b369 | 163 | if (GetBeamType() == kAA) { |
164 | AliCentrality *aliCent = InputEvent()->GetCentrality(); | |
165 | if (aliCent) { | |
166 | fCent = aliCent->GetCentralityPercentile("V0M"); | |
167 | if (fCent >= 0 && fCent < 10) fCentBin = 0; | |
168 | else if (fCent >= 10 && fCent < 30) fCentBin = 1; | |
169 | else if (fCent >= 30 && fCent < 50) fCentBin = 2; | |
170 | else if (fCent >= 50 && fCent <= 100) fCentBin = 3; | |
171 | else { | |
172 | AliWarning(Form("Negative centrality: %f. Assuming 99", fCent)); | |
173 | fCentBin = 3; | |
174 | } | |
175 | } | |
b87234fd | 176 | else { |
77a4b369 | 177 | AliWarning(Form("Could not retrieve centrality information! Assuming 99")); |
b87234fd | 178 | fCentBin = 3; |
179 | } | |
180 | } | |
181 | else { | |
77a4b369 | 182 | fCent = 99; |
183 | fCentBin = 0; | |
b87234fd | 184 | } |
185 | ||
42642780 | 186 | if ((!fCaloName.IsNull()) && (fAnaType == kEMCAL)) { |
b87234fd | 187 | fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName)); |
188 | if (!fCaloClusters) { | |
189 | AliWarning(Form("Could not retrieve clusters %s!", fCaloName.Data())); | |
190 | } | |
191 | } | |
192 | ||
42642780 | 193 | if (!fTracksName.IsNull()) { |
b87234fd | 194 | fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName)); |
195 | if (!fTracks) { | |
196 | AliWarning(Form("Could not retrieve tracks %s!", fTracksName.Data())); | |
197 | } | |
198 | } | |
199 | ||
42642780 | 200 | if (!fJetsName.IsNull()) { |
b87234fd | 201 | fJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsName)); |
202 | if (!fJets) { | |
203 | AliWarning(Form("Could not retrieve jets %s!", fJetsName.Data())); | |
204 | } | |
205 | } | |
206 | } | |
207 | ||
208 | //________________________________________________________________________ | |
209 | void AliAnalysisTaskEmcal::Init() | |
210 | { | |
42642780 | 211 | // Init the analysis. |
212 | ||
b87234fd | 213 | if (fAnaType == kTPC) { |
214 | SetEtaLimits(-0.9, 0.9); | |
215 | SetPhiLimits(-10, 10); | |
216 | } | |
217 | else if (fAnaType == kEMCAL) { | |
218 | AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); | |
219 | if (!geom) { | |
220 | AliFatal("Can not create geometry"); | |
221 | return; | |
222 | } | |
223 | SetEtaLimits(geom->GetArm1EtaMin(), geom->GetArm1EtaMax()); | |
224 | SetPhiLimits(geom->GetArm1PhiMin() * TMath::DegToRad(), geom->GetArm1PhiMax() * TMath::DegToRad()); | |
225 | } | |
226 | else { | |
227 | AliWarning("Analysis type not recognized! Assuming kTPC..."); | |
228 | SetAnaType(kTPC); | |
229 | Init(); | |
230 | } | |
231 | ||
232 | SetInitialized(); | |
233 | } | |
234 | ||
235 | //________________________________________________________________________ | |
236 | Bool_t AliAnalysisTaskEmcal::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const | |
237 | { | |
42642780 | 238 | // Return true if track is in jet. |
239 | ||
b87234fd | 240 | for (Int_t i = 0; i < jet->GetNumberOfTracks(); i++) { |
241 | Int_t ijettrack = jet->TrackAt(i); | |
242 | if (sorted && ijettrack > itrack) | |
243 | return kFALSE; | |
244 | if (ijettrack == itrack) | |
245 | return kTRUE; | |
246 | } | |
247 | return kFALSE; | |
248 | } | |
249 | ||
250 | //________________________________________________________________________ | |
251 | Bool_t AliAnalysisTaskEmcal::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const | |
252 | { | |
42642780 | 253 | // Return true if cluster is in jet. |
254 | ||
b87234fd | 255 | for (Int_t i = 0; i < jet->GetNumberOfClusters(); i++) { |
256 | Int_t ijetclus = jet->ClusterAt(i); | |
257 | if (sorted && ijetclus > iclus) | |
258 | return kFALSE; | |
259 | if (ijetclus == iclus) | |
260 | return kTRUE; | |
261 | } | |
262 | return kFALSE; | |
263 | } | |
264 | ||
265 | //________________________________________________________________________ | |
266 | Bool_t AliAnalysisTaskEmcal::AcceptJet(AliEmcalJet *jet) const | |
267 | { | |
42642780 | 268 | // Return true if jet is accepted. |
269 | ||
b87234fd | 270 | if (jet->Pt() <= fJetPtCut) |
271 | return kFALSE; | |
272 | if (jet->Area() <= fJetAreaCut) | |
273 | return kFALSE; | |
b87234fd | 274 | |
77a4b369 | 275 | return (Bool_t)(jet->Eta() > fMinEta + fJetRadius && jet->Eta() < fMaxEta - fJetRadius && jet->Phi() > fMinPhi + fJetRadius && jet->Phi() < fMaxPhi - fJetRadius); |
b87234fd | 276 | } |
277 | ||
278 | //________________________________________________________________________ | |
279 | Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster* clus, Bool_t acceptMC) const | |
280 | { | |
42642780 | 281 | // Return true if cluster is accepted. |
282 | ||
b87234fd | 283 | if (!acceptMC && clus->Chi2() == 100) |
284 | return kFALSE; | |
285 | ||
286 | TLorentzVector nPart; | |
287 | clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex)); | |
288 | ||
289 | if (nPart.Et() < fPtCut) | |
290 | return kFALSE; | |
291 | ||
292 | return kTRUE; | |
293 | } | |
294 | ||
295 | //________________________________________________________________________ | |
296 | Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVParticle* track, Bool_t acceptMC) const | |
297 | { | |
42642780 | 298 | // Return true if track is accepted. |
299 | ||
b87234fd | 300 | if (!acceptMC && track->GetLabel() == 100) |
301 | return kFALSE; | |
302 | ||
303 | if (track->Pt() < fPtCut) | |
304 | return kFALSE; | |
305 | ||
306 | return (Bool_t)(track->Eta() > fMinEta && track->Eta() < fMaxEta && track->Phi() > fMinPhi && track->Phi() < fMaxPhi); | |
307 | } | |
308 | ||
309 | //________________________________________________________________________ | |
310 | void AliAnalysisTaskEmcal::UserExec(Option_t *) | |
311 | { | |
312 | // Main loop, called for each event. | |
313 | ||
314 | if (!fInitialized) | |
315 | Init(); | |
316 | ||
317 | RetrieveEventObjects(); | |
318 | ||
319 | FillHistograms(); | |
320 | ||
321 | // information for this iteration of the UserExec in the container | |
322 | PostData(1, fOutput); | |
323 | } | |
324 | ||
325 | //________________________________________________________________________ | |
326 | void AliAnalysisTaskEmcal::Terminate(Option_t *) | |
327 | { | |
328 | // Called once at the end of the analysis. | |
329 | } |