1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // $Id: AliEvent.cxx,v 1.7 2002/06/25 09:38:28 nick Exp $
18 ///////////////////////////////////////////////////////////////////////////
20 // Creation and investigation of an Alice physics event.
21 // An AliEvent can be constructed by adding AliTracks, Alivertices, AliJets
22 // and/or AliCalorimeters.
24 // The basic functionality of AliEvent is identical to the one of AliVertex.
25 // So, an AliEvent may be used as the primary vertex with some additional
26 // functionality compared to AliVertex.
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().
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
38 // In this way the AliEvent just represents a 'logical structure' for the
42 // Modifications made to the original calorimeters also affect the AliCalorimeter
43 // objects which are stored in the AliEvent.
46 // Of every 'added' calorimeter a private copy will be made of which the pointer
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.
55 // See also the documentation provided for the memberfunction SetOwner().
57 // Coding example to make an event consisting of a primary vertex,
58 // 2 secondary vertices and a calorimeter.
59 // --------------------------------------------------------------
60 // vp contains the tracks 1,2,3 and 4 (primary vertex)
61 // v1 contains the tracks 5,6 and 7 (sec. vertex)
62 // v2 contains the jets 1 and 2 (sec. vertex)
66 // Specify the event object as the repository of all objects
67 // for the event building and physics analysis.
70 // evt.SetTrackCopy(1);
72 // Fill the event structure with the basic objects
74 // AliCalorimeter emcal;
76 // ... // code to fill the calorimeter data
79 // evt.AddCalorimeter(emcal);
81 // AliTrack* tx=new AliTrack();
82 // for (Int_t i=0; i<10; i++)
85 // ... // code to fill the track data
97 // Build the event structure (vertices, jets, ...) for physics analysis
98 // based on the basic objects from the event repository.
101 // for (Int_t i=0; i<evt.GetNtracks(); i++)
103 // tx=evt.GetTrack(i);
105 // ... // code to fill the jet data
110 // tx=evt.GetTrack(1);
112 // tx=evt.GetTrack(2);
114 // tx=evt.GetTrack(3);
116 // tx=evt.GetTrack(4);
119 // Float_t rp[3]={2.4,0.1,-8.5};
120 // vp.SetPosition(rp,"car");
123 // tx=evt.GetTrack(5);
125 // tx=evt.GetTrack(6);
127 // tx=evt.GetTrack(7);
130 // Float_t r1[3]={1.6,-3.2,5.7};
131 // v1.SetPosition(r1,"car");
139 // Float_t r2[3]={6.2,4.8,1.3};
140 // v2.SetPosition(r2,"car");
142 // Specify the vertices v1 and v2 as secondary vertices of the primary
144 // vp.SetVertexCopy(1);
148 // Enter the physics structures into the event
149 // evt.SetVertexCopy(1);
150 // evt.AddVertex(vp,0);
152 // The jets j1 and j2 are already available via sec. vertex v2,
153 // but can be made available also from the event itself if desired.
164 // Float_t etot=evt.GetEnergy();
165 // Ali3Vector ptot=evt.Get3Momentum();
167 // evt.GetPosition(loc,"sph");
168 // AliPosition r=v1.GetPosition();
170 // Int_t nt=v2.GetNtracks();
171 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
175 // Int_t nv=evt.GetNvtx();
176 // AliVertex* vx=evt.GetVertex(1); // Access primary vertex
177 // Float_t e=vx->GetEnergy();
179 // Float_t M=evt.GetInvmass();
181 // Reconstruct the event from scratch
184 // evt.SetNvmax(25); // Increase initial no. of sec. vertices
186 // ... // code to create tracks etc...
189 // Note : All quantities are in GeV, GeV/c or GeV/c**2
191 //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
192 //- Modified: NvE $Date: 2002/06/25 09:38:28 $ UU-SAP Utrecht
193 ///////////////////////////////////////////////////////////////////////////
195 #include "AliEvent.h"
197 ClassImp(AliEvent) // Class implementation to enable ROOT I/O
201 // Default constructor.
202 // All variables initialised to default values.
218 ///////////////////////////////////////////////////////////////////////////
219 AliEvent::AliEvent(Int_t n): AliVertex(n)
221 // Create an event to hold initially a maximum of n tracks
222 // All variables initialised to default values
223 cout << "AliEvent init with n = " << n << endl;
239 ///////////////////////////////////////////////////////////////////////////
240 AliEvent::~AliEvent()
242 // Default destructor
245 delete fCalorimeters;
249 ///////////////////////////////////////////////////////////////////////////
250 void AliEvent::Reset()
252 // Reset all variables to default values
253 // The max. number of tracks is set to the initial value again
254 // The max. number of vertices is set to the default value again
255 // Note : The CalCopy mode is maintained as it was set by the user before.
271 delete fCalorimeters;
277 ///////////////////////////////////////////////////////////////////////////
278 void AliEvent::SetOwner(Bool_t own)
280 // Set ownership of all added objects.
281 // The default parameter is own=kTRUE.
283 // Invokation of this memberfunction also sets all the copy modes
284 // (e.g. TrackCopy & co.) according to the value of own.
286 // This function (with own=kTRUE) is particularly useful when reading data
287 // from a tree/file, since Reset() will then actually remove all the
288 // added objects from memory irrespective of the copy mode settings
289 // during the tree/file creation process. In this way it provides a nice way
290 // of preventing possible memory leaks in the reading/analysis process.
292 // In addition this memberfunction can also be used as a shortcut to set all
293 // copy modes in one go during a tree/file creation process.
294 // However, in this case the user has to take care to only set/change the
295 // ownership (and copy mode) for empty objects (e.g. newly created objects
296 // or after invokation of the Reset() memberfunction) otherwise it will
297 // very likely result in inconsistent destructor behaviour.
301 if (fCalorimeters) fCalorimeters->SetOwner(own);
304 AliVertex::SetOwner(own);
306 ///////////////////////////////////////////////////////////////////////////
307 void AliEvent::SetDayTime(TDatime& stamp)
309 // Set the date and time stamp for this event
312 ///////////////////////////////////////////////////////////////////////////
313 void AliEvent::SetRunNumber(Int_t run)
315 // Set the run number for this event
318 ///////////////////////////////////////////////////////////////////////////
319 void AliEvent::SetEventNumber(Int_t evt)
321 // Set the event number for this event
324 ///////////////////////////////////////////////////////////////////////////
325 TDatime AliEvent::GetDayTime()
327 // Provide the date and time stamp for this event
330 ///////////////////////////////////////////////////////////////////////////
331 Int_t AliEvent::GetRunNumber()
333 // Provide the run number for this event
336 ///////////////////////////////////////////////////////////////////////////
337 Int_t AliEvent::GetEventNumber()
339 // Provide the event number for this event
342 ///////////////////////////////////////////////////////////////////////////
343 void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
345 // Set the projectile A, Z, momentum per nucleon and user defined particle ID.
346 // By default the particle ID is set to zero.
352 ///////////////////////////////////////////////////////////////////////////
353 Int_t AliEvent::GetProjectileA()
355 // Provide the projectile A value.
358 ///////////////////////////////////////////////////////////////////////////
359 Int_t AliEvent::GetProjectileZ()
361 // Provide the projectile Z value.
364 ///////////////////////////////////////////////////////////////////////////
365 Double_t AliEvent::GetProjectilePnuc()
367 // Provide the projectile momentum value per nucleon.
370 ///////////////////////////////////////////////////////////////////////////
371 Int_t AliEvent::GetProjectileId()
373 // Provide the user defined particle ID of the projectile.
376 ///////////////////////////////////////////////////////////////////////////
377 void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
379 // Set the target A, Z, momentum per nucleon and user defined particle ID.
380 // By default the particle ID is set to zero.
386 ///////////////////////////////////////////////////////////////////////////
387 Int_t AliEvent::GetTargetA()
389 // Provide the target A value.
392 ///////////////////////////////////////////////////////////////////////////
393 Int_t AliEvent::GetTargetZ()
395 // Provide the target Z value.
398 ///////////////////////////////////////////////////////////////////////////
399 Double_t AliEvent::GetTargetPnuc()
401 // Provide the target momentum value per nucleon.
404 ///////////////////////////////////////////////////////////////////////////
405 Int_t AliEvent::GetTargetId()
407 // Provide the user defined particle ID of the target.
410 ///////////////////////////////////////////////////////////////////////////
411 void AliEvent::HeaderInfo()
413 // Provide event header information
414 Int_t date=fDaytime.GetDate();
415 Int_t time=fDaytime.GetTime();
417 Int_t year=date/10000;
418 Int_t month=(date%10000)/100;
421 Int_t mm=(time%10000)/100;
424 char* c[12]={"jan","feb","mar","apr","may","jun",
425 "jul","aug","sep","oct","nov","dec"};
427 cout << " *AliEvent::Info* Run : " << fRun << " Event : " << fEvent;
429 cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year
430 << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss;
432 cout << " Ncalorimeters : " << fNcals << endl;
434 ///////////////////////////////////////////////////////////////////////////
435 void AliEvent::Info(TString f)
437 // Provide event information within the coordinate frame f
441 ///////////////////////////////////////////////////////////////////////////
442 Int_t AliEvent::GetNcalorimeters()
444 // Provide the number of stored calorimeter systems
447 ///////////////////////////////////////////////////////////////////////////
448 void AliEvent::AddCalorimeter(AliCalorimeter& c)
450 // Add a calorimeter system to the event
453 fCalorimeters=new TObjArray();
454 if (fCalCopy) fCalorimeters->SetOwner();
457 // Add the calorimeter system to this event
461 fCalorimeters->AddLast((AliCalorimeter*)c.Clone());
465 fCalorimeters->AddLast(&c);
468 ///////////////////////////////////////////////////////////////////////////
469 void AliEvent::SetCalCopy(Int_t j)
471 // (De)activate the creation of private copies of the added calorimeters.
472 // j=0 ==> No private copies are made; pointers of original cals. are stored.
473 // j=1 ==> Private copies of the cals. are made and these pointers are stored.
475 // Note : Once the storage contains pointer(s) to AliCalorimeter(s) one cannot
476 // change the CalCopy mode anymore.
477 // To change the CalCopy mode for an existing AliEvent containing
478 // calorimeters one first has to invoke Reset().
487 cout << "*AliEvent::SetCalCopy* Invalid argument : " << j << endl;
492 cout << "*AliEvent::SetCalCopy* Storage already contained calorimeters."
493 << " ==> CalCopy mode not changed." << endl;
496 ///////////////////////////////////////////////////////////////////////////
497 Int_t AliEvent::GetCalCopy()
499 // Provide value of the CalCopy mode.
500 // 0 ==> No private copies are made; pointers of original cals. are stored.
501 // 1 ==> Private copies of the cals. are made and these pointers are stored.
504 ///////////////////////////////////////////////////////////////////////////
505 AliCalorimeter* AliEvent::GetCalorimeter(Int_t i)
507 // Return the i-th calorimeter of this event
510 cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl;
515 if (i<=0 || i>fNcals)
517 cout << " *AliEvent::GetCalorimeter* Invalid argument i : " << i
518 << " Ncals = " << fNcals << endl;
523 return (AliCalorimeter*)fCalorimeters->At(i-1);
527 ///////////////////////////////////////////////////////////////////////////
528 AliCalorimeter* AliEvent::GetCalorimeter(TString name)
530 // Return the calorimeter with name tag "name"
533 cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl;
540 for (Int_t i=0; i<fNcals; i++)
542 cx=(AliCalorimeter*)fCalorimeters->At(i);
546 if (s == name) return cx;
550 return 0; // No matching name found
553 ///////////////////////////////////////////////////////////////////////////