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.3 2001/07/04 15:59:20 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 // Coding example to make an event consisting of a primary vertex,
56 // 2 secondary vertices and a calorimeter.
57 // --------------------------------------------------------------
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)
64 // Specify the event object as the repository of all objects
65 // for the event building and physics analysis.
68 // evt.SetTrackCopy(1);
70 // Fill the event structure with the basic objects
72 // AliCalorimeter emcal;
74 // ... // code to fill the calorimeter data
77 // evt.AddCalorimeter(emcal);
79 // AliTrack* tx=new AliTrack();
80 // for (Int_t i=0; i<10; i++)
83 // ... // code to fill the track data
95 // Build the event structure (vertices, jets, ...) for physics analysis
96 // based on the basic objects from the event repository.
99 // for (Int_t i=0; i<evt.GetNtracks(); i++)
101 // tx=evt.GetTrack(i);
103 // ... // code to fill the jet data
108 // tx=evt.GetTrack(1);
110 // tx=evt.GetTrack(2);
112 // tx=evt.GetTrack(3);
114 // tx=evt.GetTrack(4);
117 // Float_t rp[3]={2.4,0.1,-8.5};
118 // vp.SetPosition(rp,"car");
121 // tx=evt.GetTrack(5);
123 // tx=evt.GetTrack(6);
125 // tx=evt.GetTrack(7);
128 // Float_t r1[3]={1.6,-3.2,5.7};
129 // v1.SetPosition(r1,"car");
137 // Float_t r2[3]={6.2,4.8,1.3};
138 // v2.SetPosition(r2,"car");
140 // Specify the vertices v1 and v2 as secondary vertices of the primary
142 // vp.SetVertexCopy(1);
146 // Enter the physics structures into the event
147 // evt.SetVertexCopy(1);
148 // evt.AddVertex(vp,0);
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.
162 // Float_t etot=evt.GetEnergy();
163 // Ali3Vector ptot=evt.Get3Momentum();
165 // evt.GetPosition(loc,"sph");
166 // AliPosition r=v1.GetPosition();
168 // Int_t nt=v2.GetNtracks();
169 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
173 // Int_t nv=evt.GetNvtx();
174 // AliVertex* vx=evt.GetVertex(1); // Access primary vertex
175 // Float_t e=vx->GetEnergy();
177 // Float_t M=evt.GetInvmass();
179 // Reconstruct the event from scratch
182 // evt.SetNvmax(25); // Increase initial no. of sec. vertices
184 // ... // code to create tracks etc...
187 // Note : All quantities are in GeV, GeV/c or GeV/c**2
189 //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
190 //- Modified: NvE $Date: 2001/07/04 15:59:20 $ UU-SAP Utrecht
191 ///////////////////////////////////////////////////////////////////////////
193 #include "AliEvent.h"
195 ClassImp(AliEvent) // Class implementation to enable ROOT I/O
199 // Default constructor.
200 // All variables initialised to default values.
208 ///////////////////////////////////////////////////////////////////////////
209 AliEvent::AliEvent(Int_t n): AliVertex(n)
211 // Create an event to hold initially a maximum of n tracks
212 // All variables initialised to default values
220 ///////////////////////////////////////////////////////////////////////////
221 AliEvent::~AliEvent()
223 // Default destructor
226 if (fCalCopy) fCalorimeters->Delete();
227 delete fCalorimeters;
231 ///////////////////////////////////////////////////////////////////////////
232 void AliEvent::Reset()
234 // Reset all variables to default values
235 // The max. number of tracks is set to the initial value again
236 // The max. number of vertices is set to the default value again
244 if (fCalCopy) fCalorimeters->Delete();
245 delete fCalorimeters;
251 ///////////////////////////////////////////////////////////////////////////
252 void AliEvent::SetDayTime(TDatime& stamp)
254 // Set the date and time stamp for this event
257 ///////////////////////////////////////////////////////////////////////////
258 void AliEvent::SetRunNumber(Int_t run)
260 // Set the run number for this event
263 ///////////////////////////////////////////////////////////////////////////
264 void AliEvent::SetEventNumber(Int_t evt)
266 // Set the event number for this event
269 ///////////////////////////////////////////////////////////////////////////
270 TDatime AliEvent::GetDayTime()
272 // Provide the date and time stamp for this event
275 ///////////////////////////////////////////////////////////////////////////
276 Int_t AliEvent::GetRunNumber()
278 // Provide the run number for this event
281 ///////////////////////////////////////////////////////////////////////////
282 Int_t AliEvent::GetEventNumber()
284 // Provide the event number for this event
287 ///////////////////////////////////////////////////////////////////////////
288 void AliEvent::HeaderInfo()
290 // Provide event header information
291 Int_t date=fDaytime.GetDate();
292 Int_t time=fDaytime.GetTime();
294 Int_t year=date/10000;
295 Int_t month=(date%10000)/100;
298 Int_t mm=(time%10000)/100;
301 char* c[12]={"jan","feb","mar","apr","may","jun",
302 "jul","aug","sep","oct","nov","dec"};
304 cout << " *AliEvent::Info* Run : " << fRun << " Event : " << fEvent;
306 cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year
307 << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss;
309 cout << " Ncalorimeters : " << fNcals << endl;
311 ///////////////////////////////////////////////////////////////////////////
312 void AliEvent::Info(TString f)
314 // Provide event information within the coordinate frame f
318 ///////////////////////////////////////////////////////////////////////////
319 Int_t AliEvent::GetNcalorimeters()
321 // Provide the number of stored calorimeter systems
324 ///////////////////////////////////////////////////////////////////////////
325 void AliEvent::AddCalorimeter(AliCalorimeter& c)
327 // Add a calorimeter system to the event
328 if (!fCalorimeters) fCalorimeters=new TObjArray();
330 // Add the calorimeter system to this event
334 fCalorimeters->AddLast(c.Clone());
338 fCalorimeters->AddLast(&c);
341 ///////////////////////////////////////////////////////////////////////////
342 void AliEvent::SetCalCopy(Int_t j)
344 // (De)activate the creation of private copies of the added calorimeters.
345 // j=0 ==> No private copies are made; pointers of original cals. are stored.
346 // j=1 ==> Private copies of the cals. are made and these pointers are stored.
348 // Note : Once the storage contains pointer(s) to AliCalorimeter(s) one cannot
349 // change the CalCopy mode anymore.
350 // To change the CalCopy mode for an existing AliEvent containing
351 // calorimeters one first has to invoke Reset().
360 cout << "*AliEvent::SetCalCopy* Invalid argument : " << j << endl;
365 cout << "*AliEvent::SetCalCopy* Storage already contained calorimeters."
366 << " ==> CalCopy mode not changed." << endl;
369 ///////////////////////////////////////////////////////////////////////////
370 Int_t AliEvent::GetCalCopy()
372 // Provide value of the CalCopy mode.
373 // 0 ==> No private copies are made; pointers of original cals. are stored.
374 // 1 ==> Private copies of the cals. are made and these pointers are stored.
377 ///////////////////////////////////////////////////////////////////////////
378 AliCalorimeter* AliEvent::GetCalorimeter(Int_t i)
380 // Return the i-th calorimeter of this event
383 cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl;
388 if (i<=0 || i>fNcals)
390 cout << " *AliEvent::GetCalorimeter* Invalid argument i : " << i
391 << " Ncals = " << fNcals << endl;
396 return (AliCalorimeter*)fCalorimeters->At(i-1);
400 ///////////////////////////////////////////////////////////////////////////
401 AliCalorimeter* AliEvent::GetCalorimeter(TString name)
403 // Return the calorimeter with name tag "name"
406 cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl;
413 for (Int_t i=0; i<fNcals; i++)
415 cx=(AliCalorimeter*)fCalorimeters->At(i);
419 if (s == name) return cx;
423 return 0; // No matching name found
426 ///////////////////////////////////////////////////////////////////////////