From 7849a8abda93d9549c8088c20bf394ac4cecf6c3 Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 4 Jul 2001 15:59:20 +0000 Subject: [PATCH] 04-jul-2001 NvE Storage of calorimeters introduced in AliEvent and ResetVertices() added to AliVertex. --- RALICE/AliEvent.cxx | 266 +++++++++++++++++++++++++++++++++++++------ RALICE/AliEvent.h | 19 +++- RALICE/AliVertex.cxx | 42 ++++++- RALICE/AliVertex.h | 3 +- RALICE/history.txt | 2 + 5 files changed, 292 insertions(+), 40 deletions(-) diff --git a/RALICE/AliEvent.cxx b/RALICE/AliEvent.cxx index f6c04e42b1d..139bdaf0313 100644 --- a/RALICE/AliEvent.cxx +++ b/RALICE/AliEvent.cxx @@ -13,61 +13,139 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -// $Id$ +// $Id: AliEvent.cxx,v 1.2 2001/06/25 09:37:23 hristov Exp $ /////////////////////////////////////////////////////////////////////////// // Class AliEvent // Creation and investigation of an Alice physics event. -// An AliEvent can be constructed by adding AliTracks, Alivertices -// and/or AliJets. +// An AliEvent can be constructed by adding AliTracks, Alivertices, AliJets +// and/or AliCalorimeters. // // The basic functionality of AliEvent is identical to the one of AliVertex. // So, an AliEvent may be regarded as the primary vertex with some // additional functionality compared to AliVertex. // -// Coding example to make an event consisting of a primary vertex -// and 2 secondary vertices. +// To provide maximal flexibility to the user, the two modes of track/jet/vertex +// storage as described in AliJet and AliVertex can be used. +// In addition an identical structure is provided for the storage of AliCalorimeter +// objects, which can be selected by means of the memberfunction SetCalCopy(). +// +// a) SetCalCopy(0) (which is the default). +// Only the pointers of the 'added' calorimeters are stored. +// This mode is typically used by making cal. studies based on a fixed set +// of calorimeters which stays under user control or is kept on an external +// file/tree. +// In this way the AliEvent just represents a 'logical structure' for the +// physics analysis. +// Modifications made to the original calorimeters also affect the AliCalorimeter +// objects which are stored in the AliEvent. +// b) SetCalCopy(1). +// Of every 'added' calorimeter a private copy will be made of which the pointer +// will be stored. +// In this way the AliEvent represents an entity on its own and modifications +// made to the original calorimeters do not affect the AliCalorimeter objects +// which are stored in the AliEvent. +// This mode will allow 'adding' many different AliCalorimeters into an AliEvent by +// creating only one AliCalorimeter instance in the main programme and using the +// AliCalorimeter::Reset() and AliCalorimeter parameter setting memberfunctions. +// +// Coding example to make an event consisting of a primary vertex, +// 2 secondary vertices and a calorimeter. // -------------------------------------------------------------- -// v1 contains the tracks 1,2,3 and 4 -// v2 contains the tracks 5,6 and 7 -// v3 contains the jets 1 and 2 +// vp contains the tracks 1,2,3 and 4 (primary vertex) +// v1 contains the tracks 5,6 and 7 (sec. vertex) +// v2 contains the jets 1 and 2 (sec. vertex) +// +// AliCalorimeter emcal; +// ... +// ... // code to fill the calorimeter data +// ... // -// AliTrack t1,t2,t3,t4,t5,t6,t7; +// AliEvent evt; +// +// Specify the event object as the repository of all objects +// for the event building and physics analysis. +// +// evt.SetCalCopy(1); +// evt.SetTrackCopy(1); +// +// Fill the event structure with the basic objects +// +// evt.AddCalorimeter(emcal); +// +// AliTrack* tx; +// for (Int_t i=0; i<10; i++) +// { // ... // ... // code to fill the track data // ... +// evt.AddTrack(tx); +// tx->Reset(); +// } +// +// Build the event structure (vertices, jets, ...) for physics analysis +// based on the basic objects from the event repository. // // AliJet j1,j2; +// for (Int_t i=0; iGetEnergy(); // // Float_t M=evt.GetInvmass(); @@ -98,16 +171,14 @@ // // evt.Reset(); // evt.SetNvmax(25); // Increase initial no. of sec. vertices -// evt.AddTrack(t3); -// evt.AddTrack(t7); -// evt.AddJet(j2); -// Float_t pos[3]={7,9,4}; -// evt.SetPosition(pos,"car"); +// ... +// ... // code to create tracks etc... +// ... // // 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$ UU-SAP Utrecht +//- Modified: NvE $Date: 2001/06/25 09:37:23 $ UU-SAP Utrecht /////////////////////////////////////////////////////////////////////////// #include "AliEvent.h" @@ -121,6 +192,9 @@ AliEvent::AliEvent() fDaytime.Set(); fRun=0; fEvent=0; + fNcals=0; + fCalorimeters=0; + fCalCopy=0; } /////////////////////////////////////////////////////////////////////////// AliEvent::AliEvent(Int_t n): AliVertex(n) @@ -130,11 +204,20 @@ AliEvent::AliEvent(Int_t n): AliVertex(n) fDaytime.Set(); fRun=0; fEvent=0; + fNcals=0; + fCalorimeters=0; + fCalCopy=0; } /////////////////////////////////////////////////////////////////////////// AliEvent::~AliEvent() { // Default destructor + if (fCalorimeters) + { + if (fCalCopy) fCalorimeters->Delete(); + delete fCalorimeters; + fCalorimeters=0; + } } /////////////////////////////////////////////////////////////////////////// void AliEvent::Reset() @@ -146,6 +229,14 @@ void AliEvent::Reset() fRun=0; fEvent=0; + fNcals=0; + if (fCalorimeters) + { + if (fCalCopy) fCalorimeters->Delete(); + delete fCalorimeters; + fCalorimeters=0; + } + AliVertex::Reset(); } /////////////////////////////////////////////////////////////////////////// @@ -206,6 +297,7 @@ void AliEvent::HeaderInfo() cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss << endl; cout.fill(' '); + cout << " Ncalorimeters : " << fNcals << endl; } /////////////////////////////////////////////////////////////////////////// void AliEvent::Info(TString f) @@ -215,4 +307,110 @@ void AliEvent::Info(TString f) AliVertex::Info(f); } /////////////////////////////////////////////////////////////////////////// +Int_t AliEvent::GetNcalorimeters() +{ +// Provide the number of stored calorimeter systems + return fNcals; +} +/////////////////////////////////////////////////////////////////////////// +void AliEvent::AddCalorimeter(AliCalorimeter& c) +{ +// Add a calorimeter system to the event + if (!fCalorimeters) fCalorimeters=new TObjArray(); + + // Add the calorimeter system to this event + fNcals++; + if (fCalCopy) + { + AliCalorimeter* cx=new AliCalorimeter(c); + fCalorimeters->AddLast(cx); + } + else + { + fCalorimeters->AddLast(&c); + } +} +/////////////////////////////////////////////////////////////////////////// +void AliEvent::SetCalCopy(Int_t j) +{ +// (De)activate the creation of private copies of the added calorimeters. +// j=0 ==> No private copies are made; pointers of original cals. are stored. +// j=1 ==> Private copies of the cals. are made and these pointers are stored. +// +// Note : Once the storage contains pointer(s) to AliCalorimeter(s) one cannot +// change the CalCopy mode anymore. +// To change the CalCopy mode for an existing AliEvent containing +// calorimeters one first has to invoke Reset(). + if (!fCalorimeters) + { + if (j==0 || j==1) + { + fCalCopy=j; + } + else + { + cout << "*AliEvent::SetCalCopy* Invalid argument : " << j << endl; + } + } + else + { + cout << "*AliEvent::SetCalCopy* Storage already contained calorimeters." + << " ==> CalCopy mode not changed." << endl; + } +} +/////////////////////////////////////////////////////////////////////////// +Int_t AliEvent::GetCalCopy() +{ +// Provide value of the CalCopy mode. +// 0 ==> No private copies are made; pointers of original cals. are stored. +// 1 ==> Private copies of the cals. are made and these pointers are stored. + return fCalCopy; +} +/////////////////////////////////////////////////////////////////////////// +AliCalorimeter* AliEvent::GetCalorimeter(Int_t i) +{ +// Return the i-th calorimeter of this event + if (!fCalorimeters) + { + cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl; + return 0; + } + else + { + if (i<=0 || i>fNcals) + { + cout << " *AliEvent::GetCalorimeter* Invalid argument i : " << i + << " Ncals = " << fNcals << endl; + return 0; + } + else + { + return (AliCalorimeter*)fCalorimeters->At(i-1); + } + } +} +/////////////////////////////////////////////////////////////////////////// +AliCalorimeter* AliEvent::GetCalorimeter(TString name) +{ +// Return the calorimeter with name tag "name" + if (!fCalorimeters) + { + cout << " *AliEvent::GetCalorimeter* No calorimeters present." << endl; + return 0; + } + else + { + AliCalorimeter* cx; + TString s; + for (Int_t i=0; iAt(i); + s=cx->GetName(); + if (s == name) return cx; + } + + return 0; // No matching name found + } +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliEvent.h b/RALICE/AliEvent.h index 408fdb46a5a..477379535ec 100644 --- a/RALICE/AliEvent.h +++ b/RALICE/AliEvent.h @@ -3,7 +3,7 @@ /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ -// $Id$ +// $Id: AliEvent.h,v 1.1 2001/06/06 13:22:48 nick Exp $ #include #include @@ -13,6 +13,7 @@ #include "TDatime.h" #include "AliVertex.h" +#include "AliCalorimeter.h" class AliEvent : public AliVertex { @@ -29,11 +30,21 @@ class AliEvent : public AliVertex Int_t GetEventNumber(); // Provide the event number void HeaderInfo(); // Print the event header information void Info(TString f="car"); // Print the event info within coordinate frame f + void SetCalCopy(Int_t j); // (De)activate creation of private copies in fCalorimeters + Int_t GetCalCopy(); // Provide CalCopy flag value + void AddCalorimeter(AliCalorimeter& c); // Add a calorimeter system to the event + void AddCalorimeter(AliCalorimeter* c) { AddCalorimeter(*c); } + Int_t GetNcalorimeters(); // Provide the number of calorimeter systems + AliCalorimeter* GetCalorimeter(Int_t i);// Provide i-th calorimeter system of the event + AliCalorimeter* GetCalorimeter(TString name); // Provide calorimeter with name "name" protected: - TDatime fDaytime; // The date and time stamp - Int_t fRun; // The run number - Int_t fEvent; // The event number + TDatime fDaytime; // The date and time stamp + Int_t fRun; // The run number + Int_t fEvent; // The event number + Int_t fNcals; // The number of calorimeter systems + TObjArray* fCalorimeters; // Array to hold the pointers to the calorimeter systems + Int_t fCalCopy; // Flag to denote creation of private copies in fCalorimeters ClassDef(AliEvent,1) // Creation and investigation of an Alice physics event. }; diff --git a/RALICE/AliVertex.cxx b/RALICE/AliVertex.cxx index 38fd633c9b9..d11db625850 100644 --- a/RALICE/AliVertex.cxx +++ b/RALICE/AliVertex.cxx @@ -252,9 +252,10 @@ void AliVertex::SetNjmax(Int_t n) /////////////////////////////////////////////////////////////////////////// void AliVertex::Reset() { -// Reset all variables to 0 +// Reset all variables to 0 and reset all stored vertex and jet lists. // The max. number of tracks is set to the initial value again // The max. number of vertices is set to the default value again +// The max. number of jets is set to the default value again AliJet::Reset(); @@ -275,6 +276,45 @@ void AliVertex::Reset() if (fNjmax>0) SetNjmax(fNjmax); } /////////////////////////////////////////////////////////////////////////// +void AliVertex::ResetVertices() +{ +// Reset the stored vertex list and delete all connecting tracks which +// were generated automatically via connect=1 in AddVertex(). +// The max. number of vertices is set to the default value again. +// All physics quantities are updated according to the remaining structure +// of connected tracks. + AliTrack* t; + if (fConnects) + { + for (Int_t i=0; i<=fConnects->GetLast(); i++) + { + t=(AliTrack*)fConnects->At(i); + AliTrack* test=(AliTrack*)fTracks->Remove(t); + if (test) fNtrk--; + } + fTracks->Compress(); + } + + fQ=0; + Double_t a[4]={0,0,0,0}; + Ali4Vector::SetVector(a,"sph"); + for (Int_t i=0; iGetCharge(); + } + + fNvtx=0; + if (fNvmax>0) SetNvmax(fNvmax); + if (fConnects) + { + fConnects->Delete(); + delete fConnects; + fConnects=0; + } +} +/////////////////////////////////////////////////////////////////////////// void AliVertex::AddJet(AliJet& j,Int_t tracks) { // Add a jet (and its tracks) to the vertex diff --git a/RALICE/AliVertex.h b/RALICE/AliVertex.h index 22bc7572844..aba1b45f735 100644 --- a/RALICE/AliVertex.h +++ b/RALICE/AliVertex.h @@ -20,7 +20,8 @@ class AliVertex : public AliJet,public AliPosition AliVertex(); // Default constructor AliVertex(Int_t n); // Create a vertex to hold initially n tracks ~AliVertex(); // Default destructor - void Reset(); // Reset all values + void Reset(); // Reset all values and stored vertex and jet lists + void ResetVertices(); // Reset stored vertex list void AddJet(AliJet& j,Int_t tracks=1); // Add a jet (and its tracks) to the vertex void AddVertex(AliVertex& v,Int_t connect=1);// Add (and connect) a (sec.) vertex to the current vertex void AddJet(AliJet* j,Int_t tracks=1) { AddJet(*j,tracks); } diff --git a/RALICE/history.txt b/RALICE/history.txt index 60645d37666..61e08b2c540 100644 --- a/RALICE/history.txt +++ b/RALICE/history.txt @@ -278,3 +278,5 @@ different calorimeter systems in an event structure. Storage of jets introduced in AliVertex on the same footing as the storage of (secondary) vertices. +04-jul-2001 NvE Storage of calorimeters introduced in AliEvent and ResetVertices() + added to AliVertex. -- 2.31.1