* provided "as is" without express or implied warranty. *
**************************************************************************/
-// $Id: AliEvent.cxx,v 1.5 2002/01/18 08:46:59 nick Exp $
+// $Id: AliEvent.cxx,v 1.11 2003/02/25 12:36:28 nick Exp $
///////////////////////////////////////////////////////////////////////////
// Class AliEvent
// 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.
// --------------------------------------------------------------
// jx=v2.GetJet(2);
// evt.AddJet(jx,0);
//
-// evt.Info("sph");
+// evt.Data("sph");
// v1.ListAll();
// v2.List("cyl");
//
// Float_t loc[3];
// evt.GetPosition(loc,"sph");
// AliPosition r=v1.GetPosition();
-// r.Info();
+// r.Data();
// Int_t nt=v2.GetNtracks();
// AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
//
// 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: 2002/01/18 08:46:59 $ UU-SAP Utrecht
+//- Modified: NvE $Date: 2003/02/25 12:36:28 $ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
#include "AliEvent.h"
+#include "Riostream.h"
ClassImp(AliEvent) // Class implementation to enable ROOT I/O
-AliEvent::AliEvent()
+AliEvent::AliEvent() : AliVertex()
{
// Default constructor.
// All variables initialised to default values.
fAproj=0;
fZproj=0;
fPnucProj=0;
+ fIdProj=0;
fAtarg=0;
fZtarg=0;
fPnucTarg=0;
+ fIdTarg=0;
fNcals=0;
fCalorimeters=0;
fCalCopy=0;
}
///////////////////////////////////////////////////////////////////////////
-AliEvent::AliEvent(Int_t n): AliVertex(n)
+AliEvent::AliEvent(Int_t n) : AliVertex(n)
{
// Create an event to hold initially a maximum of n tracks
// All variables initialised to default values
+ if (n<=0)
+ {
+ cout << " *** This AliVertex initialisation was invoked via the AliEvent ctor." << 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;
}
}
///////////////////////////////////////////////////////////////////////////
+AliEvent::AliEvent(AliEvent& evt) : AliVertex(evt)
+{
+// Copy constructor.
+ fDaytime=evt.fDaytime;
+ fRun=evt.fRun;
+ fEvent=evt.fEvent;
+ fAproj=evt.fAproj;
+ fZproj=evt.fZproj;
+ fPnucProj=evt.fPnucProj;
+ fIdProj=evt.fIdProj;
+ fAtarg=evt.fAtarg;
+ fZtarg=evt.fZtarg;
+ fPnucTarg=evt.fPnucTarg;
+ fIdTarg=evt.fIdTarg;
+ fNcals=evt.fNcals;
+ fCalCopy=evt.fCalCopy;
+
+ fCalorimeters=0;
+ if (fNcals)
+ {
+ fCalorimeters=new TObjArray(fNcals);
+ if (fCalCopy) fCalorimeters->SetOwner();
+ for (Int_t i=1; i<=fNcals; i++)
+ {
+ AliCalorimeter* cal=evt.GetCalorimeter(i);
+ if (cal)
+ {
+ if (fCalCopy)
+ {
+ fCalorimeters->Add(new AliCalorimeter(*cal));
+ }
+ else
+ {
+ fCalorimeters->Add(cal);
+ }
+ }
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
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.
+
+ AliVertex::Reset();
+
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)
delete fCalorimeters;
fCalorimeters=0;
}
+}
+///////////////////////////////////////////////////////////////////////////
+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.
- AliVertex::Reset();
+ Int_t mode=1;
+ if (!own) mode=0;
+ if (fCalorimeters) fCalorimeters->SetOwner(own);
+ fCalCopy=mode;
+
+ AliVertex::SetOwner(own);
}
///////////////////////////////////////////////////////////////////////////
void AliEvent::SetDayTime(TDatime& stamp)
return fEvent;
}
///////////////////////////////////////////////////////////////////////////
-void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc)
+void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
{
-// Set the projectile A, Z and momentum value per nucleon.
+// 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()
return fPnucProj;
}
///////////////////////////////////////////////////////////////////////////
-void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc)
+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 and momentum value per nucleon.
+// 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()
return fPnucTarg;
}
///////////////////////////////////////////////////////////////////////////
-void AliEvent::HeaderInfo()
+Int_t AliEvent::GetTargetId()
+{
+// Provide the user defined particle ID of the target.
+ return fIdTarg;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliEvent::HeaderData()
{
// Provide event header information
- Int_t date=fDaytime.GetDate();
- Int_t time=fDaytime.GetTime();
-
- Int_t year=date/10000;
- Int_t month=(date%10000)/100;
- Int_t day=date%100;
- Int_t hh=time/10000;
- Int_t mm=(time%10000)/100;
- Int_t ss=time%100;
-
- char* c[12]={"jan","feb","mar","apr","may","jun",
- "jul","aug","sep","oct","nov","dec"};
+ cout << " *AliEvent::Data* Run : " << fRun << " Event : " << fEvent
+ << " Date : " << fDaytime.AsString() << endl;
- cout << " *AliEvent::Info* Run : " << fRun << " Event : " << fEvent;
- cout.fill('0');
- cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year
- << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss;
- cout.fill(' ');
- cout << " Ncalorimeters : " << fNcals << endl;
+ ShowCalorimeters();
}
///////////////////////////////////////////////////////////////////////////
-void AliEvent::Info(TString f)
+void AliEvent::Data(TString f)
{
// Provide event information within the coordinate frame f
- HeaderInfo();
- AliVertex::Info(f);
+ HeaderData();
+ AliVertex::Data(f);
}
///////////////////////////////////////////////////////////////////////////
Int_t AliEvent::GetNcalorimeters()
fNcals++;
if (fCalCopy)
{
- fCalorimeters->AddLast((AliCalorimeter*)c.Clone());
+ fCalorimeters->Add(new AliCalorimeter(c));
}
else
{
- fCalorimeters->AddLast(&c);
+ fCalorimeters->Add(&c);
}
}
///////////////////////////////////////////////////////////////////////////
}
}
///////////////////////////////////////////////////////////////////////////
+void AliEvent::ShowCalorimeters()
+{
+// Provide an overview of the available calorimeter systems.
+ if (fNcals>0)
+ {
+ cout << " The following " << fNcals << " calorimeter systems are available :" << endl;
+ for (Int_t i=1; i<=fNcals; i++)
+ {
+ AliCalorimeter* cal=GetCalorimeter(i);
+ if (cal) cout << " Calorimeter number : " << i << " Name : " << (cal->GetName()).Data() << endl;
+ }
+ }
+ else
+ {
+ cout << " No calorimeters present for this event." << endl;
+ }
+}
+///////////////////////////////////////////////////////////////////////////