]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliEvent.cxx
Communication between generators provising and requesting collision
[u/mrichter/AliRoot.git] / RALICE / AliEvent.cxx
index ba0dc900f255d5f14f073287159933f4aca9da10..2190570c24348d9ce14053666a10720717c74449 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-// $Id: AliEvent.cxx,v 1.3 2001/07/04 15:59:20 nick Exp $
+// $Id: AliEvent.cxx,v 1.7 2002/06/25 09:38:28 nick Exp $
 
 ///////////////////////////////////////////////////////////////////////////
 // Class AliEvent
@@ -52,6 +52,8 @@
 //    creating only one AliCalorimeter instance in the main programme and using the
 //    AliCalorimeter::Reset() and AliCalorimeter parameter setting memberfunctions.
 //
+// See also the documentation provided for the memberfunction SetOwner(). 
+//
 // Coding example to make an event consisting of a primary vertex,
 // 2 secondary vertices and a calorimeter.
 // --------------------------------------------------------------
 // Note : All quantities are in GeV, GeV/c or GeV/c**2
 //
 //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
-//- Modified: NvE $Date: 2001/07/04 15:59:20 $ UU-SAP Utrecht
+//- Modified: NvE $Date: 2002/06/25 09:38:28 $ UU-SAP Utrecht
 ///////////////////////////////////////////////////////////////////////////
 
 #include "AliEvent.h"
@@ -201,6 +203,14 @@ AliEvent::AliEvent()
  fDaytime.Set();
  fRun=0;
  fEvent=0;
+ fAproj=0;
+ fZproj=0;
+ fPnucProj=0;
+ fIdProj=0;
+ fAtarg=0;
+ fZtarg=0;
+ fPnucTarg=0;
+ fIdTarg=0;
  fNcals=0;
  fCalorimeters=0;
  fCalCopy=0;
@@ -210,9 +220,18 @@ AliEvent::AliEvent(Int_t n): AliVertex(n)
 {
 // Create an event to hold initially a maximum of n tracks
 // All variables initialised to default values
+ cout << "AliEvent init with n = " << n << endl;
  fDaytime.Set();
  fRun=0;
  fEvent=0;
+ fAproj=0;
+ fZproj=0;
+ fPnucProj=0;
+ fIdProj=0;
+ fAtarg=0;
+ fZtarg=0;
+ fPnucTarg=0;
+ fIdTarg=0;
  fNcals=0;
  fCalorimeters=0;
  fCalCopy=0;
@@ -223,7 +242,6 @@ AliEvent::~AliEvent()
 // Default destructor
  if (fCalorimeters)
  {
-  if (fCalCopy) fCalorimeters->Delete();
   delete fCalorimeters;
   fCalorimeters=0;
  }
@@ -234,14 +252,22 @@ void AliEvent::Reset()
 // Reset all variables to default values
 // The max. number of tracks is set to the initial value again
 // The max. number of vertices is set to the default value again
+// Note : The CalCopy mode is maintained as it was set by the user before.
  fDaytime.Set();
  fRun=0;
  fEvent=0;
+ fAproj=0;
+ fZproj=0;
+ fPnucProj=0;
+ fIdProj=0;
+ fAtarg=0;
+ fZtarg=0;
+ fPnucTarg=0;
+ fIdTarg=0;
 
  fNcals=0;
  if (fCalorimeters)
  {
-  if (fCalCopy) fCalorimeters->Delete();
   delete fCalorimeters;
   fCalorimeters=0;
  }
@@ -249,6 +275,35 @@ void AliEvent::Reset()
  AliVertex::Reset();
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliEvent::SetOwner(Bool_t own)
+{
+// Set ownership of all added objects. 
+// The default parameter is own=kTRUE.
+//
+// Invokation of this memberfunction also sets all the copy modes
+// (e.g. TrackCopy & co.) according to the value of own.
+//
+// This function (with own=kTRUE) is particularly useful when reading data
+// from a tree/file, since Reset() will then actually remove all the
+// added objects from memory irrespective of the copy mode settings
+// during the tree/file creation process. In this way it provides a nice way
+// of preventing possible memory leaks in the reading/analysis process.
+//
+// In addition this memberfunction can also be used as a shortcut to set all
+// copy modes in one go during a tree/file creation process.
+// However, in this case the user has to take care to only set/change the
+// ownership (and copy mode) for empty objects (e.g. newly created objects
+// or after invokation of the Reset() memberfunction) otherwise it will
+// very likely result in inconsistent destructor behaviour.
+
+ Int_t mode=1;
+ if (!own) mode=0;
+ if (fCalorimeters) fCalorimeters->SetOwner(own);
+ fCalCopy=mode;
+
+ AliVertex::SetOwner(own);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliEvent::SetDayTime(TDatime& stamp)
 {
 // Set the date and time stamp for this event
@@ -285,6 +340,74 @@ Int_t AliEvent::GetEventNumber()
  return fEvent;
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
+{
+// Set the projectile A, Z, momentum per nucleon and user defined particle ID.
+// By default the particle ID is set to zero.
+ fAproj=a;
+ fZproj=z;
+ fPnucProj=pnuc;
+ fIdProj=id;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetProjectileA()
+{
+// Provide the projectile A value.
+ return fAproj;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetProjectileZ()
+{
+// Provide the projectile Z value.
+ return fZproj;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliEvent::GetProjectilePnuc()
+{
+// Provide the projectile momentum value per nucleon.
+ return fPnucProj;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetProjectileId()
+{
+// Provide the user defined particle ID of the projectile.
+ return fIdProj;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
+{
+// Set the target A, Z, momentum per nucleon and user defined particle ID.
+// By default the particle ID is set to zero.
+ fAtarg=a;
+ fZtarg=z;
+ fPnucTarg=pnuc;
+ fIdTarg=id;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetTargetA()
+{
+// Provide the target A value.
+ return fAtarg;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetTargetZ()
+{
+// Provide the target Z value.
+ return fZtarg;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliEvent::GetTargetPnuc()
+{
+// Provide the target momentum value per nucleon.
+ return fPnucTarg;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetTargetId()
+{
+// Provide the user defined particle ID of the target.
+ return fIdTarg;
+}
+///////////////////////////////////////////////////////////////////////////
 void AliEvent::HeaderInfo()
 {
 // Provide event header information
@@ -325,13 +448,17 @@ Int_t AliEvent::GetNcalorimeters()
 void AliEvent::AddCalorimeter(AliCalorimeter& c)
 {
 // Add a calorimeter system to the event
- if (!fCalorimeters) fCalorimeters=new TObjArray();
+ if (!fCalorimeters)
+ {
+  fCalorimeters=new TObjArray();
+  if (fCalCopy) fCalorimeters->SetOwner();
+ }
  
  // Add the calorimeter system to this event
  fNcals++;
  if (fCalCopy)
  {
-  fCalorimeters->AddLast(c.Clone());
+  fCalorimeters->AddLast((AliCalorimeter*)c.Clone());
  }
  else
  {