]>
Commit | Line | Data |
---|---|---|
f8b94231 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliAnalysisMuonUtility.cxx 47782 2011-02-24 18:37:31Z martinez $ */ | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | /// \class AliAnalysisMuonUtility | |
20 | /// Static tilities for muon analysis | |
21 | /// The class allows to treat AODs and ESDs | |
22 | /// as well as MC AODs and MC in a transparent way | |
23 | /// | |
24 | /// \author Diego Stocco | |
25 | //----------------------------------------------------------------------------- | |
26 | ||
27 | #include "AliAnalysisMuonUtility.h" | |
28 | ||
29 | // ROOT includes | |
30 | #include "TAxis.h" | |
31 | #include "TMath.h" | |
32 | #include "TLorentzVector.h" | |
68e9b988 | 33 | #include "TFile.h" |
f8b94231 | 34 | |
35 | // STEER includes | |
36 | #include "AliAODEvent.h" | |
5376e016 | 37 | #include "AliAODHeader.h" |
68e9b988 | 38 | #include "AliAODMCHeader.h" |
f8b94231 | 39 | #include "AliAODMCParticle.h" |
5376e016 CP |
40 | #include "AliAODTrack.h" |
41 | #include "AliAODTZERO.h" | |
f8b94231 | 42 | #include "AliESDEvent.h" |
43 | #include "AliESDMuonTrack.h" | |
5376e016 CP |
44 | #include "AliESDTZERO.h" |
45 | #include "AliInputEventHandler.h" | |
f8b94231 | 46 | #include "AliLog.h" |
5376e016 CP |
47 | #include "AliMCEvent.h" |
48 | #include "AliMCParticle.h" | |
49 | #include "AliVVertex.h" | |
33898693 | 50 | #include "AliStack.h" |
f8b94231 | 51 | |
52 | // CORRFW includes | |
53 | #include "AliCFGridSparse.h" | |
0a918d8d | 54 | #include "assert.h" |
f8b94231 | 55 | |
56 | /// \cond CLASSIMP | |
57 | ClassImp(AliAnalysisMuonUtility) // Class implementation in ROOT context | |
58 | /// \endcond | |
59 | ||
60 | ||
61 | //________________________________________________________________________ | |
62 | Bool_t AliAnalysisMuonUtility::IsAODEvent ( const AliVEvent* event ) | |
63 | { | |
64 | /// Check if event is from ESD or AOD | |
65 | return ( event->IsA() == AliAODEvent::Class() ); | |
66 | } | |
67 | ||
68 | //________________________________________________________________________ | |
69 | Bool_t AliAnalysisMuonUtility::IsAODTrack ( const AliVParticle* track ) | |
70 | { | |
71 | /// Check if track is from ESD or AOD | |
72 | return ( track->IsA() == AliAODTrack::Class() ); | |
73 | } | |
74 | ||
75 | //________________________________________________________________________ | |
76 | Bool_t AliAnalysisMuonUtility::IsMuonTrack ( const AliVParticle* track ) | |
77 | { | |
78 | /// Check if track has muon tracker info | |
79 | return ( IsAODTrack(track) ) ? static_cast<const AliAODTrack*>(track)->IsMuonTrack() : static_cast<const AliESDMuonTrack*>(track)->ContainTrackerData(); | |
80 | } | |
81 | ||
82 | //________________________________________________________________________ | |
83 | Bool_t AliAnalysisMuonUtility::IsMuonGhost ( const AliVParticle* track ) | |
84 | { | |
85 | /// Check if track has trigger info | |
86 | return ( IsAODTrack(track) ) ? kFALSE : ( ! static_cast<const AliESDMuonTrack*>(track)->ContainTrackerData() ); | |
87 | } | |
88 | ||
89 | //________________________________________________________________________ | |
90 | Double_t AliAnalysisMuonUtility::GetRabs ( const AliVParticle* track ) | |
91 | { | |
92 | /// Get Rabs | |
93 | return ( IsAODTrack(track) ) ? static_cast<const AliAODTrack*>(track)->GetRAtAbsorberEnd() : static_cast<const AliESDMuonTrack*>(track)->GetRAtAbsorberEnd(); | |
94 | } | |
95 | ||
96 | //________________________________________________________________________ | |
97 | Double_t AliAnalysisMuonUtility::GetThetaAbsDeg ( const AliVParticle* track ) | |
98 | { | |
99 | /// Get Theta at absorber end (in deg) | |
100 | return TMath::ATan( GetRabs(track) / 505. ) * TMath::RadToDeg(); | |
101 | } | |
102 | ||
103 | //________________________________________________________________________ | |
104 | Int_t AliAnalysisMuonUtility::GetMatchTrigger ( const AliVParticle* track ) | |
105 | { | |
106 | /// Get match trigger | |
107 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->GetMatchTrigger() : static_cast<const AliESDMuonTrack*>(track)->GetMatchTrigger(); | |
108 | } | |
109 | ||
110 | //________________________________________________________________________ | |
111 | Double_t AliAnalysisMuonUtility::GetChi2perNDFtracker ( const AliVParticle* track ) | |
112 | { | |
e6bc9bbf | 113 | /// Get the normalized chi2 of the tracker track |
f8b94231 | 114 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->Chi2perNDF() : static_cast<const AliESDMuonTrack*>(track)->GetNormalizedChi2(); |
115 | } | |
116 | ||
e6bc9bbf | 117 | //________________________________________________________________________ |
118 | Double_t AliAnalysisMuonUtility::GetChi2MatchTrigger ( const AliVParticle* track ) | |
119 | { | |
120 | /// Get the normalized chi2 of the tracker-trigger track matching | |
121 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->GetChi2MatchTrigger() : static_cast<const AliESDMuonTrack*>(track)->GetChi2MatchTrigger(); | |
122 | } | |
123 | ||
f8b94231 | 124 | //________________________________________________________________________ |
125 | Double_t AliAnalysisMuonUtility::GetXatVertex ( const AliVParticle* track ) | |
126 | { | |
127 | /// Get X at vertex | |
128 | Double_t coor = 0.; | |
129 | if ( IsAODTrack(track) ) { | |
130 | Double_t vtxPos[3]; | |
131 | static_cast<const AliAODTrack*>(track)->GetXYZ(vtxPos); | |
132 | coor = vtxPos[0]; | |
133 | } | |
134 | else coor = static_cast<const AliESDMuonTrack*>(track)->GetNonBendingCoor(); | |
135 | ||
136 | return coor; | |
137 | } | |
138 | ||
139 | //________________________________________________________________________ | |
140 | Double_t AliAnalysisMuonUtility::GetYatVertex ( const AliVParticle* track ) | |
141 | { | |
142 | /// Get Y at vertex | |
143 | Double_t coor = 0.; | |
144 | if ( IsAODTrack(track) ) { | |
145 | Double_t vtxPos[3]; | |
146 | static_cast<const AliAODTrack*>(track)->GetXYZ(vtxPos); | |
147 | coor = vtxPos[1]; | |
148 | } | |
149 | else coor = static_cast<const AliESDMuonTrack*>(track)->GetBendingCoor(); | |
150 | ||
151 | return coor; | |
152 | } | |
153 | ||
154 | //________________________________________________________________________ | |
155 | Double_t AliAnalysisMuonUtility::GetZatVertex ( const AliVParticle* track ) | |
156 | { | |
157 | /// Get Z at vertex | |
158 | Double_t coor = 0.; | |
159 | if ( IsAODTrack(track) ) { | |
160 | Double_t vtxPos[3]; | |
161 | static_cast<const AliAODTrack*>(track)->GetXYZ(vtxPos); | |
162 | coor = vtxPos[2]; | |
163 | } | |
164 | else coor = static_cast<const AliESDMuonTrack*>(track)->GetZ(); | |
165 | ||
166 | return coor; | |
167 | } | |
168 | ||
169 | //________________________________________________________________________ | |
170 | Double_t AliAnalysisMuonUtility::GetXatDCA ( const AliVParticle* track ) | |
171 | { | |
172 | /// Get X at DCA | |
173 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->XAtDCA() : static_cast<const AliESDMuonTrack*>(track)->GetNonBendingCoorAtDCA(); | |
174 | } | |
175 | ||
176 | //________________________________________________________________________ | |
177 | Double_t AliAnalysisMuonUtility::GetYatDCA ( const AliVParticle* track ) | |
178 | { | |
179 | /// Get Y at DCA | |
180 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->YAtDCA() : static_cast<const AliESDMuonTrack*>(track)->GetBendingCoorAtDCA(); | |
181 | } | |
182 | ||
e6bc9bbf | 183 | //________________________________________________________________________ |
184 | Bool_t AliAnalysisMuonUtility::IsTrkChamberHit( Int_t chamber, const AliVParticle* track ) | |
185 | { | |
186 | /// Check if the given tracking chamber has been fired | |
187 | if (chamber < 0 || chamber > 9) return kFALSE; | |
188 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->HitsMuonChamber(chamber) : static_cast<const AliESDMuonTrack*>(track)->IsInMuonClusterMap(chamber); | |
189 | } | |
190 | ||
f8b94231 | 191 | //________________________________________________________________________ |
192 | UInt_t AliAnalysisMuonUtility::GetMUONTrigHitsMapTrk ( const AliVParticle* track ) | |
193 | { | |
194 | /// Get hit pattern in trigger chambers from tracker track extrapolation | |
195 | return ( IsAODTrack(track) ) ? const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMUONTrigHitsMapTrk() : static_cast<const AliESDMuonTrack*>(track)->GetHitsPatternInTrigChTrk(); | |
196 | } | |
197 | ||
198 | //________________________________________________________________________ | |
199 | UInt_t AliAnalysisMuonUtility::GetMUONTrigHitsMapTrg ( const AliVParticle* track ) | |
200 | { | |
201 | /// Get hit pattern in trigger chambers from tracker track extrapolation | |
202 | return ( IsAODTrack(track) ) ? const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMUONTrigHitsMapTrg() : static_cast<const AliESDMuonTrack*>(track)->GetHitsPatternInTrigCh(); | |
203 | } | |
204 | ||
ef1fa0e4 | 205 | //________________________________________________________________________ |
206 | Int_t AliAnalysisMuonUtility::GetMuonTrigDevSign ( const AliVParticle* track ) | |
207 | { | |
208 | /// Get trigger deviation sign | |
209 | return ( IsAODTrack(track) ) ? const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMuonTrigDevSign() : static_cast<const AliESDMuonTrack*>(track)->GetMuonTrigDevSign(); | |
210 | } | |
211 | ||
2feea167 | 212 | //________________________________________________________________________ |
213 | Int_t AliAnalysisMuonUtility::GetLoCircuit ( const AliVParticle* track ) | |
214 | { | |
215 | /// Get local board | |
216 | Int_t loCircuit = 0; | |
217 | if ( IsAODTrack (track) ) { | |
218 | UInt_t pattern = const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMUONTrigHitsMapTrg(); | |
219 | loCircuit = AliESDMuonTrack::GetCrossedBoard(pattern); | |
220 | } | |
221 | else loCircuit = static_cast<const AliESDMuonTrack*>(track)->LoCircuit(); | |
222 | ||
223 | return loCircuit; | |
224 | } | |
225 | ||
f8b94231 | 226 | //________________________________________________________________________ |
227 | TString AliAnalysisMuonUtility::GetFiredTriggerClasses ( const AliVEvent* event ) | |
228 | { | |
229 | /// Check if track is from ESD or AOD | |
230 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetFiredTriggerClasses() : static_cast<const AliESDEvent*>(event)->GetFiredTriggerClasses(); | |
231 | } | |
232 | ||
233 | //________________________________________________________________________ | |
234 | Int_t AliAnalysisMuonUtility::GetNTracks ( const AliVEvent* event ) | |
235 | { | |
236 | // | |
237 | /// Return the number of tracks in event | |
238 | // | |
4640c275 | 239 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetNumberOfTracks() : static_cast<const AliESDEvent*>(event)->GetNumberOfMuonTracks(); |
f8b94231 | 240 | } |
241 | ||
af8a23d3 | 242 | //________________________________________________________________________ |
243 | UInt_t AliAnalysisMuonUtility::GetL0TriggerInputs ( const AliVEvent* event ) | |
244 | { | |
245 | // | |
246 | /// Return the L0 trigger inputs | |
247 | // | |
248 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetHeader()->GetL0TriggerInputs() : static_cast<const AliESDEvent*>(event)->GetHeader()->GetL0TriggerInputs(); | |
249 | } | |
250 | ||
251 | //________________________________________________________________________ | |
252 | UInt_t AliAnalysisMuonUtility::GetL1TriggerInputs ( const AliVEvent* event ) | |
253 | { | |
254 | // | |
255 | /// Return the L1 trigger inputs | |
256 | // | |
257 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetHeader()->GetL1TriggerInputs() : static_cast<const AliESDEvent*>(event)->GetHeader()->GetL1TriggerInputs(); | |
258 | } | |
259 | ||
260 | //________________________________________________________________________ | |
261 | UInt_t AliAnalysisMuonUtility::GetL2TriggerInputs ( const AliVEvent* event ) | |
262 | { | |
263 | // | |
264 | /// Return the L2 trigger inputs | |
265 | // | |
266 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetHeader()->GetL2TriggerInputs() : static_cast<const AliESDEvent*>(event)->GetHeader()->GetL2TriggerInputs(); | |
267 | } | |
f8b94231 | 268 | |
269 | //________________________________________________________________________ | |
270 | AliVParticle* AliAnalysisMuonUtility::GetTrack ( Int_t itrack, const AliVEvent* event ) | |
271 | { | |
272 | // | |
273 | /// Get the current track | |
274 | // | |
275 | AliVParticle* track = 0x0; | |
276 | if ( IsAODEvent(event) ) track = static_cast<const AliAODEvent*>(event)->GetTrack(itrack); | |
277 | else { | |
278 | AliESDEvent* esdEvent = const_cast<AliESDEvent*>(static_cast<const AliESDEvent*> (event)); | |
279 | track = esdEvent->GetMuonTrack(itrack); | |
280 | } | |
281 | return track; | |
282 | } | |
283 | ||
284 | //________________________________________________________________________ | |
285 | Double_t AliAnalysisMuonUtility::MuonMass2() | |
286 | { | |
287 | /// A usefull constant | |
288 | return 1.11636129640000012e-02; | |
289 | } | |
290 | ||
291 | //________________________________________________________________________ | |
292 | TLorentzVector AliAnalysisMuonUtility::GetTrackPair ( const AliVParticle* track1, const AliVParticle* track2 ) | |
293 | { | |
294 | // | |
295 | /// Get track pair | |
296 | // | |
297 | const AliVParticle* tracks[2] = {track1, track2}; | |
298 | ||
299 | TLorentzVector vec[2]; | |
300 | for ( Int_t itrack=0; itrack<2; ++itrack ) { | |
301 | Double_t trackP = tracks[itrack]->P(); | |
302 | Double_t energy = TMath::Sqrt(trackP*trackP + MuonMass2()); | |
303 | vec[itrack].SetPxPyPzE(tracks[itrack]->Px(), tracks[itrack]->Py(), tracks[itrack]->Pz(), energy); | |
304 | } | |
305 | ||
306 | TLorentzVector vecPair = vec[0] + vec[1]; | |
307 | return vecPair; | |
308 | } | |
309 | ||
f8b94231 | 310 | |
311 | //________________________________________________________________________ | |
312 | Bool_t AliAnalysisMuonUtility::IsAODMCTrack( const AliVParticle* mcParticle ) | |
313 | { | |
314 | /// Check if track is from AOD MC | |
315 | return ( mcParticle->IsA() == AliAODMCParticle::Class() ); | |
316 | } | |
317 | ||
33898693 | 318 | //________________________________________________________________________ |
319 | Bool_t AliAnalysisMuonUtility::IsMCTrack( const AliVParticle* mcParticle ) | |
320 | { | |
321 | /// Check if track is MC track | |
322 | return ( mcParticle->IsA() == AliAODMCParticle::Class() || mcParticle->IsA() == AliMCParticle::Class() ); | |
323 | } | |
324 | ||
f8b94231 | 325 | |
f8b94231 | 326 | //________________________________________________________________________ |
327 | Double_t AliAnalysisMuonUtility::GetMCVertexZ ( const AliVEvent* event, const AliMCEvent* mcEvent ) | |
328 | { | |
329 | /// Get MC vertex Z | |
330 | Double_t vz = 0.; | |
ac2e110b | 331 | if ( IsAODEvent(event) ) { |
f8b94231 | 332 | AliAODMCHeader* aodMCHeader = static_cast<AliAODMCHeader*> (static_cast<const AliAODEvent*>(event)->FindListObject(AliAODMCHeader::StdBranchName())); |
333 | vz = aodMCHeader->GetVtxZ(); | |
334 | } | |
ac2e110b | 335 | else if ( mcEvent ) vz = mcEvent->GetPrimaryVertex()->GetZ(); |
f8b94231 | 336 | else AliErrorClass("No MC event found"); |
337 | return vz; | |
338 | } | |
339 | ||
340 | //________________________________________________________________________ | |
341 | Int_t AliAnalysisMuonUtility::GetMotherIndex ( const AliVParticle* mcParticle ) | |
342 | { | |
343 | // | |
344 | /// Return the mother index | |
345 | // | |
346 | return ( IsAODMCTrack(mcParticle) ) ? static_cast<const AliAODMCParticle*>(mcParticle)->GetMother() : static_cast<const AliMCParticle*>(mcParticle)->GetMother(); | |
347 | } | |
348 | ||
349 | //________________________________________________________________________ | |
350 | Int_t AliAnalysisMuonUtility::GetDaughterIndex ( const AliVParticle* mcParticle, Int_t idaughter ) | |
351 | { | |
352 | // | |
353 | /// Return the daughter index | |
354 | /// idaughter can be: | |
355 | /// 0 -> first daughter | |
356 | /// 1 -> last daughter | |
357 | // | |
358 | if ( idaughter < 0 || idaughter > 1 ) { | |
359 | AliErrorClass(Form("Requested daughter %i Daughter index can be either 0 (first) or 1 (last)", idaughter)); | |
360 | return -1; | |
361 | } | |
362 | ||
363 | if ( IsAODMCTrack(mcParticle) ) return static_cast<const AliAODMCParticle*>(mcParticle)->GetDaughter(idaughter); | |
364 | ||
365 | if ( idaughter == 0 ) return static_cast<const AliMCParticle*>(mcParticle)->GetFirstDaughter(); | |
366 | else return static_cast<const AliMCParticle*>(mcParticle)->GetLastDaughter(); | |
367 | } | |
368 | ||
369 | //________________________________________________________________________ | |
370 | Bool_t AliAnalysisMuonUtility::IsPrimary ( const AliVParticle* mcParticle, const AliMCEvent* mcEvent ) | |
371 | { | |
372 | /// Check if the particle is primary | |
373 | ||
f66fa7d4 | 374 | if ( IsAODMCTrack(mcParticle) ) return static_cast<const AliAODMCParticle*>(mcParticle)->IsPrimary(); |
ac2e110b | 375 | else if ( mcEvent ) { |
f66fa7d4 | 376 | return ( mcParticle->GetLabel() < const_cast<AliMCEvent*>(mcEvent)->GetNumberOfPrimaries() ); |
f8b94231 | 377 | } |
ac2e110b | 378 | else AliWarningClass("There is no MC info"); |
f66fa7d4 | 379 | return kFALSE; |
f8b94231 | 380 | } |
381 | ||
33898693 | 382 | //________________________________________________________________________ |
383 | UInt_t AliAnalysisMuonUtility::GetMCProcess ( const AliVParticle* mcParticle ) | |
384 | { | |
385 | /// Get MC process | |
386 | /// WARNING: the method may fail when running on AODs for old MC production, | |
387 | /// the information was propagated to the AOD level only recently | |
388 | UInt_t mcProcess = 0; | |
389 | if ( IsAODMCTrack(mcParticle) ) { | |
390 | mcProcess = const_cast<AliAODMCParticle*>(static_cast<const AliAODMCParticle*>(mcParticle))->GetMCProcessCode(); | |
391 | } | |
392 | else if ( mcParticle->IsA() == AliMCParticle::Class() ) { | |
393 | mcProcess = static_cast<const AliMCParticle*>(mcParticle)->Particle()->GetUniqueID(); | |
394 | } | |
395 | else AliWarningClass("There is no MC info"); | |
396 | return mcProcess; | |
397 | } | |
398 | ||
399 | //________________________________________________________________________ | |
400 | UInt_t AliAnalysisMuonUtility::GetStatusCode ( const AliVParticle* mcParticle ) | |
401 | { | |
402 | /// Get particle status code | |
403 | UInt_t statusCode = 0; | |
404 | if ( IsAODMCTrack(mcParticle) ) { | |
405 | statusCode = static_cast<const AliAODMCParticle*>(mcParticle)->GetStatus(); | |
406 | } | |
407 | else if ( mcParticle->IsA() == AliMCParticle::Class() ) { | |
408 | statusCode = static_cast<const AliMCParticle*>(mcParticle)->Particle()->GetStatusCode(); | |
409 | } | |
410 | else AliWarningClass("There is no MC info"); | |
411 | return statusCode; | |
412 | } | |
f8b94231 | 413 | |
414 | //________________________________________________________________________ | |
415 | AliVVertex* AliAnalysisMuonUtility::GetVertexSPD ( const AliVEvent* event ) | |
416 | { | |
417 | // | |
418 | /// Get vertex SPD | |
419 | // | |
420 | ||
421 | AliVVertex* primaryVertex = ( IsAODEvent(event) ) ? (AliVVertex*)static_cast<const AliAODEvent*>(event)->GetPrimaryVertexSPD() : (AliVVertex*)static_cast<const AliESDEvent*>(event)->GetPrimaryVertexSPD(); | |
422 | return primaryVertex; | |
423 | } | |
424 | ||
425 | ||
68e9b988 | 426 | //________________________________________________________________________ |
b7e84a9b | 427 | TString AliAnalysisMuonUtility::GetPassName ( const AliInputEventHandler* eventHandler ) |
68e9b988 | 428 | { |
b7e84a9b | 429 | /// Get pass name from event |
430 | ||
431 | // At present there is no straightforward way to get the pass name. | |
432 | // The pass name is usually written in the path to the ESDs/AODs | |
68e9b988 | 433 | // but this won't work for: |
434 | // - MC data (no pass info available) | |
435 | // - local ESDs/AODs | |
436 | ||
437 | TString filePath = ""; | |
b7e84a9b | 438 | const AliVEvent* event = eventHandler->GetEvent(); |
68e9b988 | 439 | if ( IsAODEvent(event) ) { |
440 | // In AODs, the header contains the path to the input ESD event | |
441 | // However, sometimes there is not the FULL path of the ESDs. | |
442 | // In that case we cannot extract the pass number. | |
443 | // To increase the possibility of getting the pass number, | |
444 | // try first to find the info in the AOD header | |
445 | // (which is a priori safer because it works even on local copies of AODs) | |
446 | // and if it does not work, directly check the path to the AOD | |
0a918d8d | 447 | AliAODHeader * header = dynamic_cast<AliAODHeader*>(static_cast<const AliAODEvent*> (event)->GetHeader()); |
448 | assert(header && "Not a standard AOD"); | |
449 | filePath = header->GetESDFileName(); | |
b7e84a9b | 450 | TString passName = GetPassName(filePath.Data()); |
451 | if ( passName.IsNull() ) AliWarningClass("Check again with the AOD path"); | |
452 | else return passName; | |
68e9b988 | 453 | } |
454 | ||
455 | filePath = eventHandler->GetTree()->GetCurrentFile()->GetName(); | |
b7e84a9b | 456 | return GetPassName(filePath.Data()); |
457 | } | |
458 | ||
459 | ||
460 | //________________________________________________________________________ | |
461 | Int_t AliAnalysisMuonUtility::GetPassNumber ( const AliInputEventHandler* eventHandler ) | |
462 | { | |
463 | /// Get pass number from event | |
464 | ||
465 | // At present there is no straightforward way to get the pass number. | |
466 | // The pass number is usually written in the path to the ESDs/AODs | |
467 | // but this won't work for: | |
468 | // - MC data (no pass info available) | |
469 | // - local ESDs/AODs | |
470 | ||
471 | TString passName = GetPassName(eventHandler); | |
472 | return GetPassNumber(passName); | |
68e9b988 | 473 | } |
474 | ||
475 | ||
b7e84a9b | 476 | //________________________________________________________________________ |
477 | TString AliAnalysisMuonUtility::GetPassName ( const char* str ) | |
478 | { | |
479 | // | |
480 | /// Get pass name from string | |
481 | // | |
482 | ||
483 | TString currName(str); | |
484 | TObjArray* array = currName.Tokenize("/"); | |
485 | ||
486 | TString passName = ""; | |
487 | for ( Int_t ientry=0; ientry<array->GetEntries(); ientry++ ) { | |
488 | TString currToken = static_cast<TObjString*>(array->At(ientry))->GetString(); | |
489 | TString checkToken(currToken); | |
490 | checkToken.ToUpper(); | |
491 | if ( checkToken.Contains("PASS") || checkToken.Contains("MUON_CALO") ) { | |
492 | passName = currToken; | |
493 | break; | |
494 | } | |
495 | } | |
496 | ||
497 | delete array; | |
498 | ||
499 | if ( passName.IsNull() ) AliWarningClass(Form("Cannot find pass name in: %s", str)); | |
500 | ||
501 | return passName; | |
502 | } | |
503 | ||
68e9b988 | 504 | //________________________________________________________________________ |
505 | Int_t AliAnalysisMuonUtility::GetPassNumber ( const char* str ) | |
506 | { | |
507 | // | |
508 | /// Get pass number from string | |
509 | // | |
510 | ||
511 | TString currName(str); | |
512 | currName.ToUpper(); | |
513 | Int_t idx = currName.Index("PASS"); | |
514 | if ( idx >= 0 ) { | |
515 | // Remove all of the words before PASS (and remove the word PASS itself) | |
516 | currName.Remove(0,idx+4); | |
517 | // Cut the word from the end untill only the digits are left | |
518 | // (In this way we can extract the pass number even if it has more than one digit) | |
519 | while ( ! currName.IsDigit() && currName.Length() > 0 ) { | |
520 | currName.Remove(currName.Length()-1); | |
521 | } | |
522 | ||
523 | if ( currName.Length() > 0 ) return currName.Atoi(); | |
524 | } | |
525 | ||
526 | AliWarningClass(Form("Cannot find pass number in: %s", str)); | |
527 | return -1; | |
528 | } | |
529 | ||
b5a808f9 | 530 | //________________________________________________________________________ |
33898693 | 531 | TString AliAnalysisMuonUtility::GetTrackHistory ( const AliVParticle* track, const AliMCEvent* mcEvent, Bool_t verbose ) |
b5a808f9 | 532 | { |
533 | // | |
534 | /// Get string containing particle history | |
535 | /// Useful when debugging MC | |
536 | // | |
537 | TString trackHistory = ""; | |
538 | if ( ! mcEvent ) return trackHistory; | |
33898693 | 539 | Int_t fakeMother = 999999999; |
540 | Int_t imother = IsMCTrack(track) ? fakeMother : track->GetLabel(); | |
541 | ||
b5a808f9 | 542 | while ( imother >= 0 ) { |
33898693 | 543 | const AliVParticle* part = ( imother == fakeMother ) ? track : mcEvent->GetTrack(imother); |
b5a808f9 | 544 | if ( ! part ) break; // In principle not needed...but for some old MC it breaks sometimes |
545 | TParticlePDG* partPdg = TDatabasePDG::Instance()->GetParticle(part->PdgCode()); | |
546 | TString pname = ( partPdg ) ? partPdg->GetName() : Form("%i",part->PdgCode()); | |
547 | if ( ! trackHistory.IsNull() ) trackHistory.Append(" <- "); | |
33898693 | 548 | if ( imother != fakeMother ) trackHistory.Append(Form("%i ", imother)); |
549 | trackHistory.Append(Form("(%s)", pname.Data())); | |
550 | if ( verbose ) trackHistory.Append(Form(" [vz %g mc %i]", part->Zv(), GetMCProcess(part))); | |
b5a808f9 | 551 | imother = AliAnalysisMuonUtility::GetMotherIndex(part); |
552 | } | |
553 | return trackHistory; | |
554 | } | |
555 | ||
5376e016 CP |
556 | //________________________________________________________________________ |
557 | Bool_t AliAnalysisMuonUtility::EAGetTZEROFlags(const AliVEvent* event, Bool_t& backgroundFlag, Bool_t& pileupFlag, Bool_t& satelliteFlag) | |
558 | { | |
559 | // get the TZERO decisions | |
560 | // return false if there's no tzero information in this event | |
561 | ||
562 | Bool_t rv(kFALSE); | |
563 | ||
564 | if ( event->IsA() == AliESDEvent::Class() ) | |
565 | { | |
566 | const AliESDTZERO* tzero = static_cast<AliESDEvent*>(const_cast<AliVEvent*>(event))->GetESDTZERO(); | |
567 | if ( tzero ) | |
568 | { | |
569 | backgroundFlag = tzero->GetBackgroundFlag(); | |
570 | pileupFlag = tzero->GetPileupFlag(); | |
571 | satelliteFlag = tzero->GetSatellite(); | |
572 | rv = kTRUE; | |
573 | } | |
574 | } | |
575 | else if ( event->IsA() == AliAODEvent::Class() ) | |
576 | { | |
577 | AliAODTZERO* tzero = static_cast<const AliAODEvent*>(event)->GetTZEROData(); | |
578 | if ( tzero ) | |
579 | { | |
580 | backgroundFlag = tzero->GetBackgroundFlag(); | |
581 | pileupFlag = tzero->GetPileupFlag(); | |
582 | satelliteFlag = tzero->GetSatellite(); | |
583 | rv = kTRUE; | |
584 | } | |
585 | } | |
586 | else | |
587 | { | |
588 | AliErrorClass(Form("Unknown class for the event = %s",event->ClassName())); | |
589 | } | |
590 | ||
591 | return rv; | |
592 | } | |
68e9b988 | 593 | |
f8b94231 | 594 | //_______________________________________________________________________ |
595 | Bool_t AliAnalysisMuonUtility::SetSparseRange(AliCFGridSparse* gridSparse, | |
596 | Int_t ivar, TString labelName, | |
597 | Double_t varMin, Double_t varMax, | |
598 | TString option) | |
599 | { | |
600 | // | |
601 | /// Set range in a smart way. | |
602 | /// Allows to select a bin from the label. | |
603 | /// Check the bin limits. | |
604 | // | |
605 | ||
606 | option.ToUpper(); | |
607 | Int_t minVarBin = -1, maxVarBin = -1; | |
608 | TAxis* axis = gridSparse->GetAxis(ivar); | |
609 | ||
610 | if ( ! axis ) { | |
611 | printf("Warning: Axis %i not found in %s", ivar, gridSparse->GetName()); | |
612 | return kFALSE; | |
613 | } | |
614 | ||
615 | if ( ! labelName.IsNull() ) { | |
616 | minVarBin = axis->FindBin(labelName.Data()); | |
617 | maxVarBin = minVarBin; | |
618 | if ( minVarBin < 1 ) { | |
619 | printf("Warning: %s: label %s not found. Nothing done", gridSparse->GetName(), labelName.Data()); | |
620 | return kFALSE; | |
621 | } | |
622 | } | |
623 | else if ( option.Contains( "USEBIN" ) ) { | |
624 | minVarBin = (Int_t)varMin; | |
625 | maxVarBin = (Int_t)varMax; | |
626 | } | |
627 | else { | |
628 | minVarBin = axis->FindBin(varMin); | |
629 | maxVarBin = axis->FindBin(varMax); | |
630 | } | |
631 | ||
54ddf78c | 632 | if ( axis->GetFirst() == minVarBin && axis->GetLast() == maxVarBin && axis->TestBit(TAxis::kAxisRange) ) return kFALSE; |
f8b94231 | 633 | |
634 | gridSparse->SetRangeUser(ivar, axis->GetBinCenter(minVarBin), axis->GetBinCenter(maxVarBin)); | |
635 | ||
636 | return kTRUE; | |
637 | } |