]>
Commit | Line | Data |
---|---|---|
df9db588 | 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$ */ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // AOD base class | |
20 | // Author: Markus Oldenburg, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
ec4af4c1 | 23 | #include <TTree.h> |
24 | ||
df9db588 | 25 | #include "AliAODEvent.h" |
26 | #include "AliAODHeader.h" | |
27 | #include "AliAODTrack.h" | |
28 | ||
29 | ClassImp(AliAODEvent) | |
30 | ||
31 | //______________________________________________________________________________ | |
32 | AliAODEvent::AliAODEvent() : | |
33 | fAODObjects(new TList()), | |
ec4af4c1 | 34 | fHeader(0), |
35 | fTracks(0), | |
36 | fVertices(0), | |
37 | fClusters(0), | |
38 | fJets(0) | |
df9db588 | 39 | { |
40 | // default constructor | |
41 | } | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliAODEvent::~AliAODEvent() | |
45 | { | |
ec4af4c1 | 46 | // destructor |
47 | delete fAODObjects; | |
df9db588 | 48 | } |
49 | ||
50 | //______________________________________________________________________________ | |
51 | void AliAODEvent::AddObject(TObject* obj) | |
52 | { | |
53 | // Add an object to the list of object. | |
54 | // Please be aware that in order to increase performance you should | |
55 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
56 | ||
57 | fAODObjects->AddLast(obj); | |
58 | } | |
59 | ||
60 | //______________________________________________________________________________ | |
61 | TObject *AliAODEvent::GetObject(const char *objName) const | |
62 | { | |
63 | // Return the pointer to the object with the given name. | |
64 | ||
65 | return fAODObjects->FindObject(objName); | |
66 | } | |
67 | ||
68 | //______________________________________________________________________________ | |
69 | void AliAODEvent::CreateStdContent() | |
70 | { | |
71 | // create the standard AOD content and set pointers | |
72 | ||
73 | // create standard objects and add them to the TList of objects | |
74 | AddObject(new AliAODHeader()); | |
75 | AddObject(new TClonesArray("AliAODTrack", 0)); | |
76 | AddObject(new TClonesArray("AliAODVertex", 0)); | |
a9255000 | 77 | AddObject(new TClonesArray("AliAODCluster", 0)); |
df9db588 | 78 | AddObject(new TClonesArray("AliAODJet", 0)); |
79 | ||
80 | // read back pointers | |
81 | GetStdContent(); | |
82 | ||
83 | // set names | |
84 | fTracks->SetName("tracks"); | |
85 | fVertices->SetName("vertices"); | |
31fd97b2 | 86 | fClusters->SetName("clusters"); |
df9db588 | 87 | fJets->SetName("jets"); |
88 | ||
89 | } | |
90 | ||
91 | //______________________________________________________________________________ | |
ec4af4c1 | 92 | void AliAODEvent::GetStdContent() |
df9db588 | 93 | { |
94 | // set pointers for standard content | |
95 | ||
96 | fHeader = (AliAODHeader*)fAODObjects->At(0); | |
97 | fTracks = (TClonesArray*)fAODObjects->At(1); | |
98 | fVertices = (TClonesArray*)fAODObjects->At(2); | |
a9255000 | 99 | fClusters = (TClonesArray*)fAODObjects->At(3); |
df9db588 | 100 | fJets = (TClonesArray*)fAODObjects->At(4); |
101 | } | |
102 | ||
103 | //______________________________________________________________________________ | |
104 | void AliAODEvent::ResetStd(Int_t trkArrSize, Int_t vtxArrSize) | |
105 | { | |
106 | // deletes content of standard arrays and resets size | |
107 | fTracks->Delete(); | |
108 | if (trkArrSize > fTracks->GetSize()) | |
109 | fTracks->Expand(trkArrSize); | |
110 | ||
111 | fVertices->Delete(); | |
112 | if (vtxArrSize > fVertices->GetSize()) | |
113 | fVertices->Expand(vtxArrSize); | |
114 | } | |
115 | ||
ec4af4c1 | 116 | void AliAODEvent::ClearStd() |
117 | { | |
118 | // clears the standard arrays | |
119 | fTracks ->Clear(); | |
120 | fVertices ->Clear(); | |
121 | fClusters ->Clear(); | |
122 | fJets ->Clear(); | |
123 | } | |
124 | ||
fb41236c | 125 | //______________________________________________________________________________ |
126 | Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const | |
127 | { | |
128 | // fills the provided TRefArray with all found muon tracks | |
df9db588 | 129 | |
fb41236c | 130 | muonTracks->Clear(); |
df9db588 | 131 | |
fb41236c | 132 | AliAODTrack *track = 0; |
133 | for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) { | |
134 | if ((track = GetTrack(iTrack))->GetMostProbablePID() == AliAODTrack::kMuon) { | |
135 | muonTracks->Add(track); | |
136 | } | |
137 | } | |
138 | ||
139 | return muonTracks->GetSize(); | |
140 | } | |
ec4af4c1 | 141 | |
142 |