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