]>
Commit | Line | Data |
---|---|---|
d16062ac | 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 | ||
6516b62d | 16 | // $Id: AliEvent.cxx,v 1.4 2001/07/06 09:30:59 nick Exp $ |
d16062ac | 17 | |
18 | /////////////////////////////////////////////////////////////////////////// | |
19 | // Class AliEvent | |
20 | // Creation and investigation of an Alice physics event. | |
7849a8ab | 21 | // An AliEvent can be constructed by adding AliTracks, Alivertices, AliJets |
22 | // and/or AliCalorimeters. | |
d16062ac | 23 | // |
24 | // The basic functionality of AliEvent is identical to the one of AliVertex. | |
35044448 | 25 | // So, an AliEvent may be used as the primary vertex with some additional |
26 | // functionality compared to AliVertex. | |
d16062ac | 27 | // |
7849a8ab | 28 | // To provide maximal flexibility to the user, the two modes of track/jet/vertex |
29 | // storage as described in AliJet and AliVertex can be used. | |
30 | // In addition an identical structure is provided for the storage of AliCalorimeter | |
31 | // objects, which can be selected by means of the memberfunction SetCalCopy(). | |
32 | // | |
33 | // a) SetCalCopy(0) (which is the default). | |
34 | // Only the pointers of the 'added' calorimeters are stored. | |
35 | // This mode is typically used by making cal. studies based on a fixed set | |
36 | // of calorimeters which stays under user control or is kept on an external | |
37 | // file/tree. | |
38 | // In this way the AliEvent just represents a 'logical structure' for the | |
39 | // physics analysis. | |
35044448 | 40 | // |
41 | // Note : | |
7849a8ab | 42 | // Modifications made to the original calorimeters also affect the AliCalorimeter |
43 | // objects which are stored in the AliEvent. | |
35044448 | 44 | // |
7849a8ab | 45 | // b) SetCalCopy(1). |
46 | // Of every 'added' calorimeter a private copy will be made of which the pointer | |
47 | // will be stored. | |
48 | // In this way the AliEvent represents an entity on its own and modifications | |
49 | // made to the original calorimeters do not affect the AliCalorimeter objects | |
50 | // which are stored in the AliEvent. | |
51 | // This mode will allow 'adding' many different AliCalorimeters into an AliEvent by | |
52 | // creating only one AliCalorimeter instance in the main programme and using the | |
53 | // AliCalorimeter::Reset() and AliCalorimeter parameter setting memberfunctions. | |
54 | // | |
55 | // Coding example to make an event consisting of a primary vertex, | |
56 | // 2 secondary vertices and a calorimeter. | |
d16062ac | 57 | // -------------------------------------------------------------- |
7849a8ab | 58 | // vp contains the tracks 1,2,3 and 4 (primary vertex) |
59 | // v1 contains the tracks 5,6 and 7 (sec. vertex) | |
60 | // v2 contains the jets 1 and 2 (sec. vertex) | |
61 | // | |
7849a8ab | 62 | // AliEvent evt; |
63 | // | |
64 | // Specify the event object as the repository of all objects | |
65 | // for the event building and physics analysis. | |
66 | // | |
67 | // evt.SetCalCopy(1); | |
68 | // evt.SetTrackCopy(1); | |
69 | // | |
70 | // Fill the event structure with the basic objects | |
71 | // | |
35044448 | 72 | // AliCalorimeter emcal; |
73 | // ... | |
74 | // ... // code to fill the calorimeter data | |
75 | // ... | |
76 | // | |
7849a8ab | 77 | // evt.AddCalorimeter(emcal); |
78 | // | |
35044448 | 79 | // AliTrack* tx=new AliTrack(); |
7849a8ab | 80 | // for (Int_t i=0; i<10; i++) |
81 | // { | |
d16062ac | 82 | // ... |
83 | // ... // code to fill the track data | |
84 | // ... | |
7849a8ab | 85 | // evt.AddTrack(tx); |
86 | // tx->Reset(); | |
87 | // } | |
88 | // | |
35044448 | 89 | // if (tx) |
90 | // { | |
91 | // delete tx; | |
92 | // tx=0; | |
93 | // } | |
94 | // | |
7849a8ab | 95 | // Build the event structure (vertices, jets, ...) for physics analysis |
96 | // based on the basic objects from the event repository. | |
d16062ac | 97 | // |
98 | // AliJet j1,j2; | |
7849a8ab | 99 | // for (Int_t i=0; i<evt.GetNtracks(); i++) |
100 | // { | |
101 | // tx=evt.GetTrack(i); | |
d16062ac | 102 | // ... |
103 | // ... // code to fill the jet data | |
104 | // ... | |
7849a8ab | 105 | // } |
d16062ac | 106 | // |
7849a8ab | 107 | // AliVertex vp; |
35044448 | 108 | // tx=evt.GetTrack(1); |
7849a8ab | 109 | // vp.AddTrack(tx); |
35044448 | 110 | // tx=evt.GetTrack(2); |
7849a8ab | 111 | // vp.AddTrack(tx); |
35044448 | 112 | // tx=evt.GetTrack(3); |
7849a8ab | 113 | // vp.AddTrack(tx); |
35044448 | 114 | // tx=evt.GetTrack(4); |
7849a8ab | 115 | // vp.AddTrack(tx); |
d16062ac | 116 | // |
7849a8ab | 117 | // Float_t rp[3]={2.4,0.1,-8.5}; |
118 | // vp.SetPosition(rp,"car"); | |
d16062ac | 119 | // |
7849a8ab | 120 | // AliVertex v1; |
35044448 | 121 | // tx=evt.GetTrack(5); |
7849a8ab | 122 | // v1.AddTrack(tx); |
35044448 | 123 | // tx=evt.GetTrack(6); |
7849a8ab | 124 | // v1.AddTrack(tx); |
35044448 | 125 | // tx=evt.GetTrack(7); |
7849a8ab | 126 | // v1.AddTrack(tx); |
d16062ac | 127 | // |
128 | // Float_t r1[3]={1.6,-3.2,5.7}; | |
129 | // v1.SetPosition(r1,"car"); | |
130 | // | |
d16062ac | 131 | // |
7849a8ab | 132 | // AliVertex v2; |
133 | // v2.SetJetCopy(1); | |
d16062ac | 134 | // v2.AddJet(j1); |
135 | // v2.AddJet(j2); | |
136 | // | |
137 | // Float_t r2[3]={6.2,4.8,1.3}; | |
138 | // v2.SetPosition(r2,"car"); | |
139 | // | |
7849a8ab | 140 | // Specify the vertices v1 and v2 as secondary vertices of the primary |
141 | // | |
142 | // vp.SetVertexCopy(1); | |
143 | // vp.AddVertex(v1); | |
144 | // vp.AddVertex(v2); | |
145 | // | |
146 | // Enter the physics structures into the event | |
147 | // evt.SetVertexCopy(1); | |
148 | // evt.AddVertex(vp,0); | |
149 | // | |
150 | // The jets j1 and j2 are already available via sec. vertex v2, | |
151 | // but can be made available also from the event itself if desired. | |
152 | // AliJet* jx; | |
153 | // jx=v2.GetJet(1); | |
154 | // evt.AddJet(jx,0); | |
155 | // jx=v2.GetJet(2); | |
156 | // evt.AddJet(jx,0); | |
157 | // | |
d16062ac | 158 | // evt.Info("sph"); |
159 | // v1.ListAll(); | |
160 | // v2.List("cyl"); | |
161 | // | |
162 | // Float_t etot=evt.GetEnergy(); | |
163 | // Ali3Vector ptot=evt.Get3Momentum(); | |
164 | // Float_t loc[3]; | |
165 | // evt.GetPosition(loc,"sph"); | |
166 | // AliPosition r=v1.GetPosition(); | |
167 | // r.Info(); | |
168 | // Int_t nt=v2.GetNtracks(); | |
169 | // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2 | |
170 | // | |
d16062ac | 171 | // evt.List(); |
172 | // | |
173 | // Int_t nv=evt.GetNvtx(); | |
7849a8ab | 174 | // AliVertex* vx=evt.GetVertex(1); // Access primary vertex |
d16062ac | 175 | // Float_t e=vx->GetEnergy(); |
176 | // | |
177 | // Float_t M=evt.GetInvmass(); | |
178 | // | |
179 | // Reconstruct the event from scratch | |
180 | // | |
181 | // evt.Reset(); | |
182 | // evt.SetNvmax(25); // Increase initial no. of sec. vertices | |
7849a8ab | 183 | // ... |
184 | // ... // code to create tracks etc... | |
185 | // ... | |
d16062ac | 186 | // |
187 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 | |
188 | // | |
189 | //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht | |
6516b62d | 190 | //- Modified: NvE $Date: 2001/07/06 09:30:59 $ UU-SAP Utrecht |
d16062ac | 191 | /////////////////////////////////////////////////////////////////////////// |
192 | ||
193 | #include "AliEvent.h" | |
194 | ||
195 | ClassImp(AliEvent) // Class implementation to enable ROOT I/O | |
196 | ||
197 | AliEvent::AliEvent() | |
198 | { | |
199 | // Default constructor. | |
200 | // All variables initialised to default values. | |
201 | fDaytime.Set(); | |
202 | fRun=0; | |
203 | fEvent=0; | |
7849a8ab | 204 | fNcals=0; |
205 | fCalorimeters=0; | |
206 | fCalCopy=0; | |
d16062ac | 207 | } |
208 | /////////////////////////////////////////////////////////////////////////// | |
81508922 | 209 | AliEvent::AliEvent(Int_t n): AliVertex(n) |
d16062ac | 210 | { |
211 | // Create an event to hold initially a maximum of n tracks | |
212 | // All variables initialised to default values | |
213 | fDaytime.Set(); | |
214 | fRun=0; | |
215 | fEvent=0; | |
7849a8ab | 216 | fNcals=0; |
217 | fCalorimeters=0; | |
218 | fCalCopy=0; | |
d16062ac | 219 | } |
220 | /////////////////////////////////////////////////////////////////////////// | |
221 | AliEvent::~AliEvent() | |
222 | { | |
223 | // Default destructor | |
7849a8ab | 224 | if (fCalorimeters) |
225 | { | |
7849a8ab | 226 | delete fCalorimeters; |
227 | fCalorimeters=0; | |
228 | } | |
d16062ac | 229 | } |
230 | /////////////////////////////////////////////////////////////////////////// | |
231 | void AliEvent::Reset() | |
232 | { | |
233 | // Reset all variables to default values | |
234 | // The max. number of tracks is set to the initial value again | |
235 | // The max. number of vertices is set to the default value again | |
236 | fDaytime.Set(); | |
237 | fRun=0; | |
238 | fEvent=0; | |
239 | ||
7849a8ab | 240 | fNcals=0; |
241 | if (fCalorimeters) | |
242 | { | |
7849a8ab | 243 | delete fCalorimeters; |
244 | fCalorimeters=0; | |
245 | } | |
246 | ||
d16062ac | 247 | AliVertex::Reset(); |
248 | } | |
249 | /////////////////////////////////////////////////////////////////////////// | |
250 | void AliEvent::SetDayTime(TDatime& stamp) | |
251 | { | |
252 | // Set the date and time stamp for this event | |
253 | fDaytime=stamp; | |
254 | } | |
255 | /////////////////////////////////////////////////////////////////////////// | |
256 | void AliEvent::SetRunNumber(Int_t run) | |
257 | { | |
258 | // Set the run number for this event | |
259 | fRun=run; | |
260 | } | |
261 | /////////////////////////////////////////////////////////////////////////// | |
262 | void AliEvent::SetEventNumber(Int_t evt) | |
263 | { | |
264 | // Set the event number for this event | |
265 | fEvent=evt; | |
266 | } | |
267 | /////////////////////////////////////////////////////////////////////////// | |
268 | TDatime AliEvent::GetDayTime() | |
269 | { | |
270 | // Provide the date and time stamp for this event | |
271 | return fDaytime; | |
272 | } | |
273 | /////////////////////////////////////////////////////////////////////////// | |
274 | Int_t AliEvent::GetRunNumber() | |
275 | { | |
276 | // Provide the run number for this event | |
277 | return fRun; | |
278 | } | |
279 | /////////////////////////////////////////////////////////////////////////// | |
280 | Int_t AliEvent::GetEventNumber() | |
281 | { | |
282 | // Provide the event number for this event | |
283 | return fEvent; | |
284 | } | |
285 | /////////////////////////////////////////////////////////////////////////// | |
286 | void AliEvent::HeaderInfo() | |
287 | { | |
288 | // Provide event header information | |
289 | Int_t date=fDaytime.GetDate(); | |
290 | Int_t time=fDaytime.GetTime(); | |
291 | ||
292 | Int_t year=date/10000; | |
293 | Int_t month=(date%10000)/100; | |
294 | Int_t day=date%100; | |
295 | Int_t hh=time/10000; | |
296 | Int_t mm=(time%10000)/100; | |
297 | Int_t ss=time%100; | |
298 | ||
299 | char* c[12]={"jan","feb","mar","apr","may","jun", | |
300 | "jul","aug","sep","oct","nov","dec"}; | |
301 | ||
302 | cout << " *AliEvent::Info* Run : " << fRun << " Event : " << fEvent; | |
303 | cout.fill('0'); | |
304 | cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year | |
35044448 | 305 | << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss; |
d16062ac | 306 | cout.fill(' '); |
7849a8ab | 307 | cout << " Ncalorimeters : " << fNcals << endl; |
d16062ac | 308 | } |
309 | /////////////////////////////////////////////////////////////////////////// | |
310 | void AliEvent::Info(TString f) | |
311 | { | |
312 | // Provide event information within the coordinate frame f | |
313 | HeaderInfo(); | |
314 | AliVertex::Info(f); | |
315 | } | |
316 | /////////////////////////////////////////////////////////////////////////// | |
7849a8ab | 317 | Int_t AliEvent::GetNcalorimeters() |
318 | { | |
319 | // Provide the number of stored calorimeter systems | |
320 | return fNcals; | |
321 | } | |
322 | /////////////////////////////////////////////////////////////////////////// | |
323 | void AliEvent::AddCalorimeter(AliCalorimeter& c) | |
324 | { | |
325 | // Add a calorimeter system to the event | |
6516b62d | 326 | if (!fCalorimeters) |
327 | { | |
328 | fCalorimeters=new TObjArray(); | |
329 | if (fCalCopy) fCalorimeters->SetOwner(); | |
330 | } | |
7849a8ab | 331 | |
332 | // Add the calorimeter system to this event | |
333 | fNcals++; | |
334 | if (fCalCopy) | |
335 | { | |
6516b62d | 336 | fCalorimeters->AddLast((AliCalorimeter*)c.Clone()); |
7849a8ab | 337 | } |
338 | else | |
339 | { | |
340 | fCalorimeters->AddLast(&c); | |
341 | } | |
342 | } | |
343 | /////////////////////////////////////////////////////////////////////////// | |
344 | void AliEvent::SetCalCopy(Int_t j) | |
345 | { | |
346 | // (De)activate the creation of private copies of the added calorimeters. | |
347 | // j=0 ==> No private copies are made; pointers of original cals. are stored. | |
348 | // j=1 ==> Private copies of the cals. are made and these pointers are stored. | |
349 | // | |
350 | // Note : Once the storage contains pointer(s) to AliCalorimeter(s) one cannot | |
351 | // change the CalCopy mode anymore. | |
352 | // To change the CalCopy mode for an existing AliEvent containing | |
353 | // calorimeters one first has to invoke Reset(). | |
354 | if (!fCalorimeters) | |
355 | { | |
356 | if (j==0 || j==1) | |
357 | { | |
358 | fCalCopy=j; | |
359 | } | |
360 | else | |
361 | { | |
362 | cout << "*AliEvent::SetCalCopy* Invalid argument : " << j << endl; | |
363 | } | |
364 | } | |
365 | else | |
366 | { | |
367 | cout << "*AliEvent::SetCalCopy* Storage already contained calorimeters." | |
368 | << " ==> CalCopy mode not changed." << endl; | |
369 | } | |
370 | } | |
371 | /////////////////////////////////////////////////////////////////////////// | |
372 | Int_t AliEvent::GetCalCopy() | |
373 | { | |
374 | // Provide value of the CalCopy mode. | |
375 | // 0 ==> No private copies are made; pointers of original cals. are stored. | |
376 | // 1 ==> Private copies of the cals. are made and these pointers are stored. | |
377 | return fCalCopy; | |
378 | } | |
379 | /////////////////////////////////////////////////////////////////////////// | |
380 | AliCalorimeter* AliEvent::GetCalorimeter(Int_t i) | |
381 | { | |
382 | // Return the i-th calorimeter of this event | |
383 | if (!fCalorimeters) | |
384 | { | |
385 | cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl; | |
386 | return 0; | |
387 | } | |
388 | else | |
389 | { | |
390 | if (i<=0 || i>fNcals) | |
391 | { | |
392 | cout << " *AliEvent::GetCalorimeter* Invalid argument i : " << i | |
393 | << " Ncals = " << fNcals << endl; | |
394 | return 0; | |
395 | } | |
396 | else | |
397 | { | |
398 | return (AliCalorimeter*)fCalorimeters->At(i-1); | |
399 | } | |
400 | } | |
401 | } | |
402 | /////////////////////////////////////////////////////////////////////////// | |
403 | AliCalorimeter* AliEvent::GetCalorimeter(TString name) | |
404 | { | |
405 | // Return the calorimeter with name tag "name" | |
406 | if (!fCalorimeters) | |
407 | { | |
408 | cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl; | |
409 | return 0; | |
410 | } | |
411 | else | |
412 | { | |
413 | AliCalorimeter* cx; | |
414 | TString s; | |
415 | for (Int_t i=0; i<fNcals; i++) | |
416 | { | |
417 | cx=(AliCalorimeter*)fCalorimeters->At(i); | |
35044448 | 418 | if (cx) |
419 | { | |
420 | s=cx->GetName(); | |
421 | if (s == name) return cx; | |
422 | } | |
7849a8ab | 423 | } |
424 | ||
425 | return 0; // No matching name found | |
426 | } | |
427 | } | |
428 | /////////////////////////////////////////////////////////////////////////// | |
d16062ac | 429 |