///////////////////////////////////////////////////////////////////////////
AliCalorimeter::~AliCalorimeter()
{
-// Destructor to delete memory allocated to the various arrays and matrix
+// Destructor to delete memory allocated to the various arrays and matrices
if (fModules)
{
delete fModules;
delete fHclusters;
fHclusters=0;
}
+
+ // Free memory allocated for (internal) module and position matrices.
+ // The modules have already been deleted via the fModules I/O array,
+ // so they shouldn't be deleted here anymore.
if (fMatrix || fPositions)
{
for (Int_t i=0; i<fNrows; i++)
{
for (Int_t j=0; j<fNcolumns; j++)
{
- fMatrix[i][j]=0;
if (fPositions[i][j]) delete fPositions[i][j];
}
+ if (fPositions[i]) delete [] fPositions[i];
+ if (fMatrix[i]) delete [] fMatrix[i];
}
if (fMatrix)
{
}
}
///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::Reset()
+void AliCalorimeter::Reset(Int_t mode)
{
-// Reset the signals for the complete calorimeter
-// Normally this is done to prepare for the data of the next event
-// Note : Module gains, edge and dead flags remain unchanged
-
- if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
+// Reset the signals for the complete calorimeter.
+// Normally this is done to prepare for the data of the next event.
+//
+// mode = 0 : Module positions, gains, edge and dead flags remain unchanged.
+// 1 : Module positions, gains, edge and dead flags are cleared.
+//
+// The default is mode=0.
+//
+// Note : In the case of reading AliCalorimeter objects from a data file,
+// one has to reset the AliCalorimeter object with mode=1
+// (or explicitly delete it) before reading-in the next object
+// in order to prevent memory leaks.
+
+ if (mode<0 || mode>1)
+ {
+ cout << " *AliCalorimeter::Reset* Wrong argument. mode = " << mode << endl;
+ return;
+ }
fNsignals=0;
if (fModules)
delete fModules;
fModules=0;
}
- for (Int_t i=0; i<fNrows; i++)
- {
- for (Int_t j=0; j<fNcolumns; j++)
- {
- fMatrix[i][j]=0;
- }
- }
fNclusters=0;
if (fClusters)
delete fVetos;
fVetos=0;
}
+
+ if (fMatrix || fPositions)
+ {
+ for (Int_t i=0; i<fNrows; i++)
+ {
+ for (Int_t j=0; j<fNcolumns; j++)
+ {
+ if (mode==0)
+ {
+ fMatrix[i][j]=0;
+ }
+ else
+ {
+ if (fPositions[i][j]) delete fPositions[i][j];
+ }
+ }
+ if (mode==1)
+ {
+ if (fPositions[i]) delete [] fPositions[i];
+ if (fMatrix[i]) delete [] fMatrix[i];
+ }
+ }
+ }
+
+ // Free memory allocated for various arrays and matrices.
+ if (mode==1)
+ {
+ if (fMatrix)
+ {
+ delete [] fMatrix;
+ fMatrix=0;
+ }
+ if (fPositions)
+ {
+ delete [] fPositions;
+ fPositions=0;
+ }
+ if (fGains)
+ {
+ delete fGains;
+ fGains=0;
+ }
+ if (fAttributes)
+ {
+ delete fAttributes;
+ fAttributes=0;
+ }
+ if (fHmodules)
+ {
+ delete fHmodules;
+ fHmodules=0;
+ }
+ if (fHclusters)
+ {
+ delete fHclusters;
+ fHclusters=0;
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////
Float_t AliCalorimeter::GetSignal(Int_t row,Int_t col)
void AddSignal(Int_t row,Int_t col,Float_t s); // Add signal to a certain module
void AddSignal(AliCalmodule* m); // Add module signal to current calorimeter
void Reset(Int_t row,Int_t col); // Reset signal for a certain module
- void Reset(); // Reset the complete calorimeter
+ void Reset(Int_t mode=0); // Reset the complete calorimeter
Float_t GetSignal(Int_t row,Int_t col); // Provide signal of a certain module
Int_t GetNsignals(); // Return number of modules with a signal
void Group(Int_t n); // Group modules into clusters (n rings)
AliPosition ***fPositions; //! Matrix of module position pointers for internal use
TString fName; // Name of the calorimeter system
- ClassDef(AliCalorimeter,2) // Description of a modular calorimeter system.
+ ClassDef(AliCalorimeter,3) // Description of a modular calorimeter system.
};
#endif
* provided "as is" without express or implied warranty. *
**************************************************************************/
-// $Id: AliEvent.cxx,v 1.7 2002/06/25 09:38:28 nick Exp $
+// $Id: AliEvent.cxx,v 1.8 2002/12/02 15:10:37 nick Exp $
///////////////////////////////////////////////////////////////////////////
// Class AliEvent
// 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/06/25 09:38:28 $ UU-SAP Utrecht
+//- Modified: NvE $Date: 2002/12/02 15:10:37 $ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
#include "AliEvent.h"
{
// 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;
11-dec-2002 NvE Copyright notice added into AliCollider.h and AliCollider.cxx.
Also small (integer division) modification made in AliCollider.cxx
to prevent an innocent warning of the g++ compiler under Linux.
+08-jan-2003 NvE Delete statements for fMatrix[i] and fPositions[i] added in the dtor of
+ AliCalorimeter to fix a memory leak.
+09-jan-2003 NvE Different modes introduced for AliCalorimeter::Reset() to prevent memory
+ leaks in reading back AliCalorimeter objects from a data file.
+ Also unnecessary "LoadMatrix()" statement removed in AliCalorimeter::Reset().
+ Irrelevant cout statement removed from AliEvent constructor.