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.2 2001/06/25 09:37:23 hristov 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 regarded as the primary vertex with some
26 // additional 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
40 // Modifications made to the original calorimeters also affect the AliCalorimeter
41 // objects which are stored in the AliEvent.
43 // Of every 'added' calorimeter a private copy will be made of which the pointer
45 // In this way the AliEvent represents an entity on its own and modifications
46 // made to the original calorimeters do not affect the AliCalorimeter objects
47 // which are stored in the AliEvent.
48 // This mode will allow 'adding' many different AliCalorimeters into an AliEvent by
49 // creating only one AliCalorimeter instance in the main programme and using the
50 // AliCalorimeter::Reset() and AliCalorimeter parameter setting memberfunctions.
52 // Coding example to make an event consisting of a primary vertex,
53 // 2 secondary vertices and a calorimeter.
54 // --------------------------------------------------------------
55 // vp contains the tracks 1,2,3 and 4 (primary vertex)
56 // v1 contains the tracks 5,6 and 7 (sec. vertex)
57 // v2 contains the jets 1 and 2 (sec. vertex)
59 // AliCalorimeter emcal;
61 // ... // code to fill the calorimeter data
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 // evt.AddCalorimeter(emcal);
77 // for (Int_t i=0; i<10; i++)
80 // ... // code to fill the track data
86 // Build the event structure (vertices, jets, ...) for physics analysis
87 // based on the basic objects from the event repository.
90 // for (Int_t i=0; i<evt.GetNtracks(); i++)
92 // tx=evt.GetTrack(i);
94 // ... // code to fill the jet data
101 // tx=evt.GetTrack(2)
103 // tx=evt.GetTrack(3)
105 // tx=evt.GetTrack(4)
108 // Float_t rp[3]={2.4,0.1,-8.5};
109 // vp.SetPosition(rp,"car");
112 // tx=evt.GetTrack(5)
114 // tx=evt.GetTrack(6)
116 // tx=evt.GetTrack(7)
119 // Float_t r1[3]={1.6,-3.2,5.7};
120 // v1.SetPosition(r1,"car");
128 // Float_t r2[3]={6.2,4.8,1.3};
129 // v2.SetPosition(r2,"car");
131 // Specify the vertices v1 and v2 as secondary vertices of the primary
133 // vp.SetVertexCopy(1);
137 // Enter the physics structures into the event
138 // evt.SetVertexCopy(1);
139 // evt.AddVertex(vp,0);
141 // The jets j1 and j2 are already available via sec. vertex v2,
142 // but can be made available also from the event itself if desired.
153 // Float_t etot=evt.GetEnergy();
154 // Ali3Vector ptot=evt.Get3Momentum();
156 // evt.GetPosition(loc,"sph");
157 // AliPosition r=v1.GetPosition();
159 // Int_t nt=v2.GetNtracks();
160 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
164 // Int_t nv=evt.GetNvtx();
165 // AliVertex* vx=evt.GetVertex(1); // Access primary vertex
166 // Float_t e=vx->GetEnergy();
168 // Float_t M=evt.GetInvmass();
170 // Reconstruct the event from scratch
173 // evt.SetNvmax(25); // Increase initial no. of sec. vertices
175 // ... // code to create tracks etc...
178 // Note : All quantities are in GeV, GeV/c or GeV/c**2
180 //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
181 //- Modified: NvE $Date: 2001/06/25 09:37:23 $ UU-SAP Utrecht
182 ///////////////////////////////////////////////////////////////////////////
184 #include "AliEvent.h"
186 ClassImp(AliEvent) // Class implementation to enable ROOT I/O
190 // Default constructor.
191 // All variables initialised to default values.
199 ///////////////////////////////////////////////////////////////////////////
200 AliEvent::AliEvent(Int_t n): AliVertex(n)
202 // Create an event to hold initially a maximum of n tracks
203 // All variables initialised to default values
211 ///////////////////////////////////////////////////////////////////////////
212 AliEvent::~AliEvent()
214 // Default destructor
217 if (fCalCopy) fCalorimeters->Delete();
218 delete fCalorimeters;
222 ///////////////////////////////////////////////////////////////////////////
223 void AliEvent::Reset()
225 // Reset all variables to default values
226 // The max. number of tracks is set to the initial value again
227 // The max. number of vertices is set to the default value again
235 if (fCalCopy) fCalorimeters->Delete();
236 delete fCalorimeters;
242 ///////////////////////////////////////////////////////////////////////////
243 void AliEvent::SetDayTime(TDatime& stamp)
245 // Set the date and time stamp for this event
248 ///////////////////////////////////////////////////////////////////////////
249 void AliEvent::SetRunNumber(Int_t run)
251 // Set the run number for this event
254 ///////////////////////////////////////////////////////////////////////////
255 void AliEvent::SetEventNumber(Int_t evt)
257 // Set the event number for this event
260 ///////////////////////////////////////////////////////////////////////////
261 TDatime AliEvent::GetDayTime()
263 // Provide the date and time stamp for this event
266 ///////////////////////////////////////////////////////////////////////////
267 Int_t AliEvent::GetRunNumber()
269 // Provide the run number for this event
272 ///////////////////////////////////////////////////////////////////////////
273 Int_t AliEvent::GetEventNumber()
275 // Provide the event number for this event
278 ///////////////////////////////////////////////////////////////////////////
279 void AliEvent::HeaderInfo()
281 // Provide event header information
282 Int_t date=fDaytime.GetDate();
283 Int_t time=fDaytime.GetTime();
285 Int_t year=date/10000;
286 Int_t month=(date%10000)/100;
289 Int_t mm=(time%10000)/100;
292 char* c[12]={"jan","feb","mar","apr","may","jun",
293 "jul","aug","sep","oct","nov","dec"};
295 cout << " *AliEvent::Info* Run : " << fRun << " Event : " << fEvent;
297 cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year
298 << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss << endl;
300 cout << " Ncalorimeters : " << fNcals << endl;
302 ///////////////////////////////////////////////////////////////////////////
303 void AliEvent::Info(TString f)
305 // Provide event information within the coordinate frame f
309 ///////////////////////////////////////////////////////////////////////////
310 Int_t AliEvent::GetNcalorimeters()
312 // Provide the number of stored calorimeter systems
315 ///////////////////////////////////////////////////////////////////////////
316 void AliEvent::AddCalorimeter(AliCalorimeter& c)
318 // Add a calorimeter system to the event
319 if (!fCalorimeters) fCalorimeters=new TObjArray();
321 // Add the calorimeter system to this event
325 AliCalorimeter* cx=new AliCalorimeter(c);
326 fCalorimeters->AddLast(cx);
330 fCalorimeters->AddLast(&c);
333 ///////////////////////////////////////////////////////////////////////////
334 void AliEvent::SetCalCopy(Int_t j)
336 // (De)activate the creation of private copies of the added calorimeters.
337 // j=0 ==> No private copies are made; pointers of original cals. are stored.
338 // j=1 ==> Private copies of the cals. are made and these pointers are stored.
340 // Note : Once the storage contains pointer(s) to AliCalorimeter(s) one cannot
341 // change the CalCopy mode anymore.
342 // To change the CalCopy mode for an existing AliEvent containing
343 // calorimeters one first has to invoke Reset().
352 cout << "*AliEvent::SetCalCopy* Invalid argument : " << j << endl;
357 cout << "*AliEvent::SetCalCopy* Storage already contained calorimeters."
358 << " ==> CalCopy mode not changed." << endl;
361 ///////////////////////////////////////////////////////////////////////////
362 Int_t AliEvent::GetCalCopy()
364 // Provide value of the CalCopy mode.
365 // 0 ==> No private copies are made; pointers of original cals. are stored.
366 // 1 ==> Private copies of the cals. are made and these pointers are stored.
369 ///////////////////////////////////////////////////////////////////////////
370 AliCalorimeter* AliEvent::GetCalorimeter(Int_t i)
372 // Return the i-th calorimeter of this event
375 cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl;
380 if (i<=0 || i>fNcals)
382 cout << " *AliEvent::GetCalorimeter* Invalid argument i : " << i
383 << " Ncals = " << fNcals << endl;
388 return (AliCalorimeter*)fCalorimeters->At(i-1);
392 ///////////////////////////////////////////////////////////////////////////
393 AliCalorimeter* AliEvent::GetCalorimeter(TString name)
395 // Return the calorimeter with name tag "name"
398 cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl;
405 for (Int_t i=0; i<fNcals; i++)
407 cx=(AliCalorimeter*)fCalorimeters->At(i);
409 if (s == name) return cx;
412 return 0; // No matching name found
415 ///////////////////////////////////////////////////////////////////////////