]>
Commit | Line | Data |
---|---|---|
2da09763 | 1 | // $Id: AliAnalysisTaskEmcal.cxx 56756 2012-05-30 05:03:02Z loizides $ |
2 | // | |
3 | // Emcal base analysis task. | |
4 | // | |
5 | // Author: S.Aiola | |
6 | ||
7 | #include "AliAnalysisTaskEmcal.h" | |
8 | ||
2da09763 | 9 | #include <TChain.h> |
10 | #include <TClonesArray.h> | |
11 | #include <TList.h> | |
09ca054b | 12 | #include <TObject.h> |
2da09763 | 13 | |
2da09763 | 14 | #include "AliAnalysisManager.h" |
15 | #include "AliCentrality.h" | |
09ca054b | 16 | #include "AliEMCALGeometry.h" |
17 | #include "AliESDEvent.h" | |
2da09763 | 18 | #include "AliEmcalJet.h" |
09ca054b | 19 | #include "AliEmcalParticle.h" |
2da09763 | 20 | #include "AliLog.h" |
09ca054b | 21 | #include "AliMCParticle.h" |
22 | #include "AliVCluster.h" | |
23 | #include "AliVEventHandler.h" | |
24 | #include "AliVParticle.h" | |
2da09763 | 25 | |
26 | ClassImp(AliAnalysisTaskEmcal) | |
27 | ||
28 | //________________________________________________________________________ | |
29 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() : | |
30 | AliAnalysisTaskSE("AliAnalysisTaskEmcal"), | |
31 | fAnaType(kTPC), | |
32 | fInitialized(kFALSE), | |
33 | fCreateHisto(kTRUE), | |
20f79d37 | 34 | fTracksName(), |
35 | fCaloName(), | |
2da09763 | 36 | fNbins(500), |
37 | fMinBinPt(0), | |
38 | fMaxBinPt(250), | |
e44e8726 | 39 | fClusPtCut(0.15), |
40 | fTrackPtCut(0.15), | |
2da09763 | 41 | fTracks(0), |
42 | fCaloClusters(0), | |
43 | fCent(0), | |
44 | fCentBin(-1), | |
1f6fff78 | 45 | fBeamType(kNA), |
2da09763 | 46 | fOutput(0) |
47 | { | |
48 | // Default constructor. | |
49 | ||
50 | fVertex[0] = 0; | |
51 | fVertex[1] = 0; | |
52 | fVertex[2] = 0; | |
2da09763 | 53 | } |
54 | ||
55 | //________________________________________________________________________ | |
56 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) : | |
57 | AliAnalysisTaskSE(name), | |
58 | fAnaType(kTPC), | |
59 | fInitialized(kFALSE), | |
60 | fCreateHisto(histo), | |
20f79d37 | 61 | fTracksName(), |
62 | fCaloName(), | |
2da09763 | 63 | fNbins(500), |
64 | fMinBinPt(0), | |
65 | fMaxBinPt(250), | |
e44e8726 | 66 | fClusPtCut(0.15), |
67 | fTrackPtCut(0.15), | |
2da09763 | 68 | fTracks(0), |
69 | fCaloClusters(0), | |
70 | fCent(0), | |
71 | fCentBin(-1), | |
1f6fff78 | 72 | fBeamType(kNA), |
2da09763 | 73 | fOutput(0) |
74 | { | |
75 | // Standard constructor. | |
76 | ||
77 | fVertex[0] = 0; | |
78 | fVertex[1] = 0; | |
79 | fVertex[2] = 0; | |
80 | ||
81 | if (fCreateHisto) { | |
2da09763 | 82 | DefineOutput(1, TList::Class()); |
83 | } | |
84 | } | |
85 | ||
86 | //________________________________________________________________________ | |
87 | AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal() | |
88 | { | |
89 | // Destructor | |
90 | } | |
91 | ||
92 | //________________________________________________________________________ | |
629c7ac0 | 93 | void AliAnalysisTaskEmcal::UserExec(Option_t *) |
94 | { | |
95 | // Main loop, called for each event. | |
96 | ||
e44e8726 | 97 | if (!fInitialized) |
629c7ac0 | 98 | Init(); |
99 | ||
e44e8726 | 100 | if (!fInitialized) |
101 | return; | |
102 | ||
629c7ac0 | 103 | if (!RetrieveEventObjects()) |
104 | return; | |
105 | ||
106 | if (!Run()) | |
107 | return; | |
108 | ||
109 | if (!FillHistograms()) | |
110 | return; | |
111 | ||
112 | if (fCreateHisto) { | |
113 | // information for this iteration of the UserExec in the container | |
114 | PostData(1, fOutput); | |
115 | } | |
116 | } | |
117 | ||
118 | //________________________________________________________________________ | |
119 | Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, Bool_t acceptMC) const | |
2da09763 | 120 | { |
629c7ac0 | 121 | // Return true if cluster is accepted. |
122 | ||
123 | if (!clus) | |
124 | return kFALSE; | |
125 | ||
126 | if (!clus->IsEMCAL()) | |
127 | return kFALSE; | |
128 | ||
129 | if (!acceptMC && clus->Chi2() == 100) | |
130 | return kFALSE; | |
131 | ||
132 | TLorentzVector nPart; | |
133 | clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex)); | |
134 | ||
e44e8726 | 135 | if (nPart.Et() < fClusPtCut) |
629c7ac0 | 136 | return kFALSE; |
137 | ||
138 | return kTRUE; | |
139 | } | |
140 | ||
141 | //________________________________________________________________________ | |
142 | Bool_t AliAnalysisTaskEmcal::AcceptEmcalPart(AliEmcalParticle *part, Bool_t acceptMC) const | |
143 | { | |
144 | // Return true if EMCal particle is accepted. | |
145 | ||
146 | if (!part) | |
147 | return kFALSE; | |
148 | ||
149 | if (fAnaType == kEMCAL && !part->IsEMCAL()) | |
150 | return kFALSE; | |
151 | ||
e44e8726 | 152 | if ((part->IsTrack() && part->Pt() < fTrackPtCut) || (part->IsCluster() && part->Pt() < fClusPtCut)) |
629c7ac0 | 153 | return kFALSE; |
154 | ||
155 | if (!acceptMC && part->IsMC()) | |
156 | return kFALSE; | |
157 | ||
158 | return kTRUE; | |
159 | } | |
160 | ||
161 | //________________________________________________________________________ | |
162 | Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVTrack *track, Bool_t acceptMC) const | |
163 | { | |
164 | // Return true if track is accepted. | |
165 | ||
166 | if (!track) | |
167 | return kFALSE; | |
168 | ||
169 | if (!acceptMC && track->GetLabel() == 100) | |
170 | return kFALSE; | |
171 | ||
e44e8726 | 172 | if (track->Pt() < fTrackPtCut) |
629c7ac0 | 173 | return kFALSE; |
174 | ||
175 | return kTRUE; | |
2da09763 | 176 | } |
177 | ||
178 | //_____________________________________________________ | |
1f6fff78 | 179 | AliAnalysisTaskEmcal::BeamType AliAnalysisTaskEmcal::GetBeamType() |
2da09763 | 180 | { |
181 | // Get beam type : pp-AA-pA | |
182 | // ESDs have it directly, AODs get it from hardcoded run number ranges | |
183 | ||
184 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent()); | |
185 | if (esd) { | |
186 | const AliESDRun *run = esd->GetESDRun(); | |
187 | TString beamType = run->GetBeamType(); | |
188 | if (beamType == "p-p") | |
189 | return kpp; | |
190 | else if (beamType == "A-A") | |
191 | return kAA; | |
192 | else if (beamType == "p-A") | |
193 | return kpA; | |
194 | else | |
195 | return kNA; | |
901cc837 | 196 | } else { |
2da09763 | 197 | Int_t runNumber = InputEvent()->GetRunNumber(); |
198 | if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h | |
199 | (runNumber >= 166529 && runNumber <= 170593)) // LHC11h | |
200 | { | |
201 | return kAA; | |
901cc837 | 202 | } else { |
2da09763 | 203 | return kpp; |
204 | } | |
205 | } | |
206 | } | |
207 | ||
629c7ac0 | 208 | //________________________________________________________________________ |
8a28ded1 | 209 | void AliAnalysisTaskEmcal::Init() |
210 | { | |
211 | // Init the analysis. | |
212 | ||
8a28ded1 | 213 | SetInitialized(); |
214 | } | |
215 | ||
c596bd28 | 216 | //________________________________________________________________________ |
217 | TClonesArray *AliAnalysisTaskEmcal::GetArrayFromEvent(const char *name, const char *clname) | |
218 | { | |
219 | // Get array from event. | |
220 | ||
221 | TClonesArray *arr = 0; | |
222 | TString sname(name); | |
223 | if (!sname.IsNull()) { | |
224 | arr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(sname)); | |
225 | if (!arr) { | |
226 | AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name)); | |
227 | return 0; | |
228 | } | |
229 | } | |
230 | if (!clname) | |
231 | return arr; | |
232 | ||
233 | TString objname(arr->GetClass()->GetName()); | |
234 | TClass cls(objname); | |
235 | if (!cls.InheritsFrom(clname)) { | |
236 | AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!", | |
237 | GetName(), cls.GetName(), name, clname)); | |
238 | return 0; | |
239 | } | |
240 | return arr; | |
241 | } | |
242 | ||
2da09763 | 243 | //________________________________________________________________________ |
244 | Bool_t AliAnalysisTaskEmcal::RetrieveEventObjects() | |
245 | { | |
246 | // Retrieve objects from event. | |
247 | ||
248 | if (!InputEvent()) { | |
901cc837 | 249 | AliError(Form("%s: Could not retrieve event! Returning!", GetName())); |
2da09763 | 250 | return kFALSE; |
251 | } | |
252 | ||
e44e8726 | 253 | if (!fCaloName.IsNull() && (fAnaType == kEMCAL) && !fCaloClusters) { |
254 | fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName)); | |
255 | if (!fCaloClusters) { | |
256 | AliError(Form("%s: Could not retrieve clusters %s!", GetName(), fCaloName.Data())); | |
257 | return kFALSE; | |
20f79d37 | 258 | } else { |
e44e8726 | 259 | TClass *cl = fCaloClusters->GetClass(); |
260 | if (!cl->GetBaseClass("AliVCluster") && !cl->GetBaseClass("AliEmcalParticle")) { | |
261 | AliError(Form("%s: Collection %s does not contain AliVCluster nor AliEmcalParticle objects!", GetName(), fCaloName.Data())); | |
262 | fCaloClusters = 0; | |
263 | return kFALSE; | |
264 | } | |
265 | } | |
266 | } | |
267 | ||
268 | if (!fTracksName.IsNull() && !fTracks) { | |
269 | fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName)); | |
270 | if (!fTracks) { | |
271 | AliError(Form("%s: Could not retrieve tracks %s!", GetName(), fTracksName.Data())); | |
272 | return kFALSE; | |
20f79d37 | 273 | } else { |
e44e8726 | 274 | TClass *cl = fTracks->GetClass(); |
275 | if (!cl->GetBaseClass("AliVParticle") && !cl->GetBaseClass("AliEmcalParticle")) { | |
276 | AliError(Form("%s: Collection %s does not contain AliVParticle nor AliEmcalParticle objects!", GetName(), fTracksName.Data())); | |
277 | fTracks = 0; | |
278 | return kFALSE; | |
279 | } | |
280 | } | |
281 | } | |
282 | ||
2da09763 | 283 | fVertex[0] = 0; |
284 | fVertex[1] = 0; | |
285 | fVertex[2] = 0; | |
286 | InputEvent()->GetPrimaryVertex()->GetXYZ(fVertex); | |
287 | ||
1f6fff78 | 288 | fBeamType = GetBeamType(); |
289 | ||
290 | if (fBeamType == kAA) { | |
2da09763 | 291 | AliCentrality *aliCent = InputEvent()->GetCentrality(); |
292 | if (aliCent) { | |
293 | fCent = aliCent->GetCentralityPercentile("V0M"); | |
294 | if (fCent >= 0 && fCent < 10) fCentBin = 0; | |
295 | else if (fCent >= 10 && fCent < 30) fCentBin = 1; | |
296 | else if (fCent >= 30 && fCent < 50) fCentBin = 2; | |
297 | else if (fCent >= 50 && fCent <= 100) fCentBin = 3; | |
298 | else { | |
901cc837 | 299 | AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); |
2da09763 | 300 | fCentBin = 3; |
301 | } | |
901cc837 | 302 | } else { |
303 | AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName())); | |
2da09763 | 304 | fCentBin = 3; |
305 | } | |
901cc837 | 306 | } else { |
2da09763 | 307 | fCent = 99; |
308 | fCentBin = 0; | |
309 | } | |
310 | ||
2da09763 | 311 | return kTRUE; |
312 | } |