]>
Commit | Line | Data |
---|---|---|
0dffcc8a | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | //------------------------------------------------------------------------- | |
17 | // Class AliRsnEvent | |
2f769150 | 18 | // ------------------- |
19 | // Simple collection of reconstructed tracks | |
20 | // selected from an ESD event | |
21 | // to be used for analysis. | |
22 | // ......................................... | |
0dffcc8a | 23 | // |
24 | // author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
25 | //------------------------------------------------------------------------- | |
26 | ||
27 | #include <Riostream.h> | |
28 | ||
0dffcc8a | 29 | #include <TString.h> |
0dffcc8a | 30 | #include <TObjArray.h> |
0dffcc8a | 31 | #include <TClonesArray.h> |
32 | ||
0dffcc8a | 33 | #include "AliRsnDaughter.h" |
34 | #include "AliRsnEvent.h" | |
35 | ||
36 | ClassImp(AliRsnEvent) | |
37 | ||
38 | //-------------------------------------------------------------------------------------------------------- | |
39 | AliRsnEvent::AliRsnEvent() : | |
0dffcc8a | 40 | fPVx(0.0), |
41 | fPVy(0.0), | |
42 | fPVz(0.0), | |
43 | fMultiplicity(-1) | |
2f769150 | 44 | { |
0dffcc8a | 45 | // |
46 | // Default constructor | |
47 | // | |
0dffcc8a | 48 | Int_t i; |
49 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
50 | fPos[i] = NULL; | |
51 | fNeg[i] = NULL; | |
52 | } | |
2a9c8c76 | 53 | fPosNoPID = NULL; |
54 | fNegNoPID = NULL; | |
0dffcc8a | 55 | } |
56 | //-------------------------------------------------------------------------------------------------------- | |
57 | AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) : | |
58 | TObject((TObject)event), | |
0dffcc8a | 59 | fPVx(event.fPVx), |
60 | fPVy(event.fPVy), | |
61 | fPVz(event.fPVz), | |
62 | fMultiplicity(event.fMultiplicity) | |
2f769150 | 63 | { |
0dffcc8a | 64 | // |
65 | // Copy constructor. | |
66 | // Creates new instances of all collections to store a copy of all objects. | |
67 | // | |
2f769150 | 68 | // clone tracks collections |
69 | Int_t i; | |
70 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
71 | fPos[i] = 0; | |
72 | fNeg[i] = 0; | |
73 | if (event.fPos[i]) fPos[i] = (TClonesArray*)event.fPos[i]->Clone(); | |
74 | if (event.fNeg[i]) fNeg[i] = (TClonesArray*)event.fNeg[i]->Clone(); | |
75 | } | |
2a9c8c76 | 76 | fPosNoPID = (TClonesArray*)event.fPosNoPID->Clone(); |
77 | fNegNoPID = (TClonesArray*)event.fNegNoPID->Clone(); | |
2f769150 | 78 | } |
2a9c8c76 | 79 | //-------------------------------------------------------------------------------------------------------- |
2f769150 | 80 | AliRsnEvent& AliRsnEvent::operator=(const AliRsnEvent &event) |
0dffcc8a | 81 | { |
2f769150 | 82 | // |
83 | // Assignment operator. | |
84 | // Creates new instances of all collections to store a copy of all objects. | |
85 | // | |
2f769150 | 86 | fPVx = event.fPVx; |
87 | fPVy = event.fPVy; | |
88 | fPVz = event.fPVz; | |
89 | fMultiplicity = event.fMultiplicity; | |
90 | ||
0dffcc8a | 91 | // clone tracks collections |
92 | Int_t i; | |
93 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
94 | fPos[i] = 0; | |
95 | fNeg[i] = 0; | |
96 | if (event.fPos[i]) fPos[i] = (TClonesArray*)event.fPos[i]->Clone(); | |
97 | if (event.fNeg[i]) fNeg[i] = (TClonesArray*)event.fNeg[i]->Clone(); | |
98 | } | |
2a9c8c76 | 99 | fPosNoPID = (TClonesArray*)event.fPosNoPID->Clone(); |
100 | fNegNoPID = (TClonesArray*)event.fNegNoPID->Clone(); | |
2f769150 | 101 | |
102 | return (*this); | |
0dffcc8a | 103 | } |
2f769150 | 104 | //--------------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------------- |
0dffcc8a | 105 | void AliRsnEvent::AddTrack(AliRsnDaughter track) |
2f769150 | 106 | { |
0dffcc8a | 107 | // |
108 | // Stores a track into the correct array | |
109 | // | |
0dffcc8a | 110 | // if sign is zero, track is not stored |
2a9c8c76 | 111 | Int_t sign = (Int_t)track.GetSign(); |
0dffcc8a | 112 | if (!sign) return; |
113 | ||
114 | // if PDG code is assigned, track is stored in the corresponding collection | |
2a9c8c76 | 115 | // otherwise, it is stored in the array of unidentified particles with that sign |
116 | Int_t index, iarray, pdg = track.GetPDG(); | |
0dffcc8a | 117 | if (pdg != 0) { |
2a9c8c76 | 118 | iarray = PDG2Enum(pdg); |
119 | if (iarray < AliPID::kElectron || iarray > AliPID::kProton) return; | |
120 | TClonesArray &array = (sign > 0) ? *fPos[iarray] : *fNeg[iarray]; | |
121 | index = array.GetEntries(); | |
122 | new(array[index]) AliRsnDaughter(track); | |
0dffcc8a | 123 | } |
124 | else { | |
2a9c8c76 | 125 | TClonesArray &array = (sign > 0) ? *fPosNoPID : *fNegNoPID; |
126 | index = array.GetEntries(); | |
127 | new(array[index]) AliRsnDaughter(track); | |
0dffcc8a | 128 | } |
129 | } | |
130 | //-------------------------------------------------------------------------------------------------------- | |
131 | void AliRsnEvent::Clear(Option_t *option) | |
2f769150 | 132 | { |
0dffcc8a | 133 | // |
134 | // Clears list of tracks and references. | |
135 | // If the string "DELETE" is specified, the collection classes | |
136 | // are also cleared from heap. | |
137 | // | |
0dffcc8a | 138 | // evaluate option |
139 | TString opt(option); | |
140 | Bool_t deleteCollections = opt.Contains("DELETE", TString::kIgnoreCase); | |
141 | ||
142 | Int_t i; | |
143 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
144 | if (fPos[i]) fPos[i]->Delete(); | |
145 | if (fNeg[i]) fNeg[i]->Delete(); | |
146 | if (deleteCollections) { | |
147 | delete fPos[i]; | |
148 | delete fNeg[i]; | |
149 | fPos[i] = 0; | |
150 | fNeg[i] = 0; | |
151 | } | |
152 | } | |
2a9c8c76 | 153 | if (fPosNoPID) fPosNoPID->Delete(); |
154 | if (fNegNoPID) fNegNoPID->Delete(); | |
155 | if (deleteCollections) { | |
156 | delete fPosNoPID; | |
157 | delete fNegNoPID; | |
158 | fPosNoPID = 0; | |
159 | fNegNoPID = 0; | |
0dffcc8a | 160 | } |
0dffcc8a | 161 | } |
162 | //-------------------------------------------------------------------------------------------------------- | |
2a9c8c76 | 163 | void AliRsnEvent::ComputeMultiplicity() |
2f769150 | 164 | { |
0dffcc8a | 165 | // |
2a9c8c76 | 166 | // Computes multiplicity. |
0dffcc8a | 167 | // |
2a9c8c76 | 168 | fMultiplicity = 0; |
169 | Int_t i; | |
170 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
171 | fMultiplicity += (Int_t)fPos[i]->GetEntries(); | |
172 | fMultiplicity += (Int_t)fNeg[i]->GetEntries(); | |
0dffcc8a | 173 | } |
2a9c8c76 | 174 | if (fPosNoPID) fMultiplicity += fPosNoPID->GetEntries(); |
175 | if (fNegNoPID) fMultiplicity += fNegNoPID->GetEntries(); | |
0dffcc8a | 176 | } |
177 | //-------------------------------------------------------------------------------------------------------- | |
178 | TClonesArray* AliRsnEvent::GetTracks(Char_t sign, AliPID::EParticleType type) | |
2f769150 | 179 | { |
0dffcc8a | 180 | // |
181 | // Returns the particle collection specified in argument | |
182 | // | |
0dffcc8a | 183 | Int_t itype = (Int_t)type; |
184 | if (itype >= 0 && itype < AliPID::kSPECIES) { | |
185 | if (sign == '+') return fPos[type]; else return fNeg[type]; | |
186 | } | |
187 | else { | |
188 | return NULL; | |
189 | } | |
190 | } | |
191 | //-------------------------------------------------------------------------------------------------------- | |
192 | void AliRsnEvent::Init() | |
2f769150 | 193 | { |
0dffcc8a | 194 | // |
195 | // Action 1: define default values for some data members (including pointers). | |
196 | // Action 2: if 'ntracks' > 0 allocates memory to store tracks. | |
197 | // | |
0dffcc8a | 198 | Int_t i; |
199 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
200 | fPos[i] = new TClonesArray("AliRsnDaughter", 0); | |
201 | fNeg[i] = new TClonesArray("AliRsnDaughter", 0); | |
202 | fPos[i]->BypassStreamer(kFALSE); | |
203 | fNeg[i]->BypassStreamer(kFALSE); | |
204 | } | |
2a9c8c76 | 205 | fPosNoPID = new TClonesArray("AliRsnDaughter", 0); |
206 | fNegNoPID = new TClonesArray("AliRsnDaughter", 0); | |
207 | fPosNoPID->BypassStreamer(kFALSE); | |
208 | fNegNoPID->BypassStreamer(kFALSE); | |
0dffcc8a | 209 | } |
210 | //-------------------------------------------------------------------------------------------------------- | |
211 | Int_t AliRsnEvent::PDG2Enum(Int_t pdgcode) | |
2f769150 | 212 | { |
0dffcc8a | 213 | // |
214 | // Converts a PDG code into the correct slot in the EParticleType enumeration in AliPID | |
215 | // | |
0dffcc8a | 216 | Int_t i; |
217 | for (i = 0; i < AliPID::kSPECIES; i++) { | |
218 | if (AliPID::ParticleCode((AliPID::EParticleType)i) == TMath::Abs(pdgcode)) { | |
219 | return i; | |
220 | } | |
221 | } | |
222 | ||
223 | return -1; | |
224 | } | |
225 | //-------------------------------------------------------------------------------------------------------- | |
226 | void AliRsnEvent::PrintTracks() | |
2f769150 | 227 | { |
0dffcc8a | 228 | // |
229 | // Print data for particles stored in this event | |
230 | // | |
0dffcc8a | 231 | cout << endl; |
232 | ||
233 | AliRsnDaughter *track = 0; | |
234 | ||
235 | Int_t type; | |
236 | for (type = 0; type < AliPID::kSPECIES; type++) { | |
237 | TObjArrayIter iterPos(fPos[type]); | |
238 | cout << "Positive " << AliPID::ParticleName(type) << "s" << endl; | |
239 | if (!fPos[type]) cout << "NOT INITIALIZED" << endl; | |
240 | while ( (track = (AliRsnDaughter*)iterPos.Next()) ) { | |
241 | cout << "Index, Sign, PDG = "; | |
242 | cout << track->GetIndex() << " "; | |
243 | cout << (Int_t)track->GetSign() << " "; | |
244 | cout << track->GetPDG() << endl; | |
245 | } | |
246 | TObjArrayIter iterNeg(fNeg[type]); | |
247 | cout << "Negative " << AliPID::ParticleName(type) << "s" << endl; | |
248 | if (!fNeg[type]) cout << "NOT INITIALIZED" << endl; | |
249 | while ( (track = (AliRsnDaughter*)iterNeg.Next()) ) { | |
250 | cout << "Index, Sign, PDG = "; | |
251 | cout << track->GetIndex() << " "; | |
252 | cout << (Int_t)track->GetSign() << " "; | |
253 | cout << track->GetPDG() << endl; | |
254 | } | |
255 | } | |
256 | } | |
257 | //-------------------------------------------------------------------------------------------------------- |