]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliCalorimeter.cxx
New file, import VZERO digits.
[u/mrichter/AliRoot.git] / RALICE / AliCalorimeter.cxx
index c91876b3bc77bcaa4a3a15fd25239b0a87ac09e9..56ef43191223a9e7d5d386f83020396b07664d58 100644 (file)
@@ -62,7 +62,7 @@
 
 ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
  
-AliCalorimeter::AliCalorimeter() : TObject()
+AliCalorimeter::AliCalorimeter() : AliDevice()
 {
 // Default constructor, all parameters set to 0.
 // Create a calorimeter module matrix with fixed row and column size.
@@ -80,7 +80,6 @@ AliCalorimeter::AliCalorimeter() : TObject()
  fVetos=0;
  fAttributes=0;
  fPositions=0;
- fName="Unspecified AliCalorimeter";
 }
 ///////////////////////////////////////////////////////////////////////////
 AliCalorimeter::~AliCalorimeter()
@@ -123,7 +122,7 @@ AliCalorimeter::~AliCalorimeter()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : TObject()
+AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : AliDevice()
 {
 // Create a calorimeter module matrix with fixed row and column size.
 // The modules at the edges are automatically marked as "edge modules".
@@ -161,11 +160,9 @@ AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : TObject()
  fHclusters=0;
 
  fVetos=0;
-
- fName="Unspecified AliCalorimeter";
 }
 ///////////////////////////////////////////////////////////////////////////
-AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TObject(c)
+AliCalorimeter::AliCalorimeter(const AliCalorimeter& c) : AliDevice(c)
 {
 // Copy constructor
  fClusters=0;
@@ -181,7 +178,6 @@ AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TObject(c)
 
  fNrows=c.fNrows;
  fNcolumns=c.fNcolumns;
- fName=c.fName;
 
  fSwap=c.fSwap;
 
@@ -193,7 +189,7 @@ AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TObject(c)
   {
    for (Int_t icol=1; icol<=ncols; icol++)
    {
-    AliPosition* p=c.GetPosition(irow,icol);
+    AliPosition* p=(AliPosition*)(c.fPositions->GetObject(irow,icol));
     if (p) SetPosition(irow,icol,*p);
    } 
   }  
@@ -225,19 +221,6 @@ AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TObject(c)
   }
  }
 
- n=c.GetNsignals();
- if (n)
- {
-  fMatrix=new AliObjMatrix();
-  fMatrix->SetOwner();
-  fMatrix->SetSwapMode(fSwap);
-  for (Int_t im=1; im<=n; im++)
-  {
-   AliCalmodule* m=c.GetModule(im);
-   if (m) fMatrix->EnterObject(m->GetRow(),m->GetColumn(),new AliCalmodule(*m));
-  }
- }
-
  n=c.GetNvetos();
  for (Int_t iv=1; iv<=n; iv++)
  {
@@ -250,6 +233,7 @@ Int_t AliCalorimeter::GetNrows()
 {
 // Provide the number of rows for the calorimeter module matrix
  Int_t nrows=fNrows;
+ if (!fMatrix) LoadMatrix();
  if (fMatrix && !nrows) nrows=fMatrix->GetMaxRow();
  return nrows;
 }
@@ -258,6 +242,7 @@ Int_t AliCalorimeter::GetNcolumns()
 {
 // Provide the number of columns for the calorimeter module matrix
  Int_t ncols=fNcolumns;
+ if (!fMatrix) LoadMatrix();
  if (fMatrix && !ncols) ncols=fMatrix->GetMaxColumn();
  return ncols;
 }
@@ -274,37 +259,44 @@ void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t sig)
   if (fNrows && fNcolumns) cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
   return;
  }
+
+ if (!fMatrix) LoadMatrix();
+
  if (!fMatrix)
  {
   fMatrix=new AliObjMatrix();
-  fMatrix->SetOwner();
   fMatrix->SetSwapMode(fSwap);
  }
 
- AliCalmodule* m=GetModule(row,col);
- if (!m) // initialise for a new module
+ AliCalmodule* mx=GetModule(row,col);
+ if (mx) // Existing module
  {
-  m=new AliCalmodule();
+  mx->SetSignal(sig);
+ }
+ else // Initialise for a new module
+ {
+  AliCalmodule m;
+  m.SetRow(row);
+  m.SetColumn(col);
+  m.SetSignal(sig);
   AliPosition* r=0;
   if (fPositions) r=(AliPositionObj*)fPositions->GetObject(row,col);
-  if (r) m->SetPosition(*r);
+  if (r) m.SetPosition(*r);
   if (fAttributes)
   {
    AliAttribObj* a=0;
    if (row <= fAttributes->GetSize()) a=(AliAttribObj*)fAttributes->At(row-1);
    if (a)
    {
-    if (a->GetGainFlag(col)) m->SetGain(a->GetGain(col));
-    if (a->GetOffsetFlag(col)) m->SetOffset(a->GetOffset(col));
-    if (a->GetDeadValue(col)) m->SetDead();
-    if (a->GetEdgeValue(col)) m->SetEdgeValue(a->GetEdgeValue(col));
+    if (a->GetGainFlag(col)) m.SetGain(a->GetGain(col));
+    if (a->GetOffsetFlag(col)) m.SetOffset(a->GetOffset(col));
+    if (a->GetDeadValue(col)) m.SetDead();
+    if (a->GetEdgeValue(col)) m.SetEdgeValue(a->GetEdgeValue(col));
    }
   }
-  fMatrix->EnterObject(row,col,m);
+  AddHit(m);
+  fMatrix->EnterObject(row,col,fHits->Last());
  }
-
- m->SetSignal(row,col,sig);
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
@@ -327,7 +319,7 @@ void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
   }
   else
   {
-   m->AddSignal(row,col,sig);
+   m->AddSignal(sig);
   }
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -357,42 +349,44 @@ void AliCalorimeter::AddSignal(AliCalmodule* mod)
   if (fNrows && fNcolumns) cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
   return;
  }
+
+ if (!fMatrix) LoadMatrix();
  
  if (!fMatrix)
  {
   fMatrix=new AliObjMatrix();
-  fMatrix->SetOwner();
   fMatrix->SetSwapMode(fSwap);
  }
 
- AliCalmodule* m=GetModule(row,col);
- if (!m) // No module existed yet at this position
+ AliCalmodule* mx=GetModule(row,col);
+ if (!mx) // No module existed yet at this position
  {
-  m=new AliCalmodule(*mod);
+  AliCalmodule m(*mod);
   AliPosition* r=0;
   if (fPositions) r=(AliPositionObj*)fPositions->GetObject(row,col);
-  if (r) m->SetPosition(*r);
+  if (r) m.SetPosition(*r);
   // Don't take the dead and edge attributes from this module,
   // but from the calorimeter dbase, if present.
-  m->SetEdgeOff();
-  m->SetAlive();
+  m.SetEdgeOff();
+  m.SetAlive();
   if (fAttributes)
   {
    AliAttribObj* a=0;
    if (row <= fAttributes->GetSize()) a=(AliAttribObj*)fAttributes->At(row-1);
    if (a)
    {
-    if (a->GetGainFlag(col)) m->SetGain(a->GetGain(col));
-    if (a->GetOffsetFlag(col)) m->SetOffset(a->GetOffset(col));
-    if (a->GetDeadValue(col)) m->SetDead();
-    if (a->GetEdgeValue(col)) m->SetEdgeValue(a->GetEdgeValue(col));
+    if (a->GetGainFlag(col)) m.SetGain(a->GetGain(col));
+    if (a->GetOffsetFlag(col)) m.SetOffset(a->GetOffset(col));
+    if (a->GetDeadValue(col)) m.SetDead();
+    if (a->GetEdgeValue(col)) m.SetEdgeValue(a->GetEdgeValue(col));
    }
   }
-  fMatrix->EnterObject(row,col,m);
+  AddHit(m);
+  fMatrix->EnterObject(row,col,fHits->Last());
  }
  else
  {
-  m->AddSignal(row,col,sig);
+  mx->AddSignal(sig);
  }
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -411,7 +405,11 @@ void AliCalorimeter::Reset(Int_t row,Int_t col)
  }
  
  AliCalmodule* m=GetModule(row,col);
- if (m) fMatrix->RemoveObject(row,col);
+ if (m)
+ {
+  RemoveHit(m);
+  fMatrix->RemoveObject(row,col);
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliCalorimeter::Reset(Int_t mode)
@@ -435,6 +433,8 @@ void AliCalorimeter::Reset(Int_t mode)
   return;
  }
 
+ AliDevice::Reset(mode);
+
  if (fClusters)
  {
   delete fClusters;
@@ -1140,8 +1140,6 @@ AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col)
   return 0;
  }
 
- if (!fPositions && !fMatrix) return 0;
-
  AliPositionObj* po=0;
  if (fPositions) po=(AliPositionObj*)fPositions->GetObject(row,col);
  if (po) return po;
@@ -1171,14 +1169,12 @@ Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col)
  return sig;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetNsignals()
+Int_t AliCalorimeter::GetNsignals() const
 {
 // Provide the number of modules that contain a signal
 // Note : The number of modules marked 'dead' but which had a signal
 //        are included.
- Int_t nsig=0;
- if (fMatrix) nsig=fMatrix->GetNobjects();
- return nsig;
+ return GetNhits();
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliCalorimeter::Group(Int_t n,Int_t mode)
@@ -1204,6 +1200,14 @@ void AliCalorimeter::Group(Int_t n,Int_t mode)
   mode=1;
  }
 
+ if (fClusters)
+ {
+  delete fClusters;
+  fClusters=0;
+ }
+
+ if (!fMatrix) LoadMatrix();
+
  if (!fMatrix) return;
  
  Int_t nsignals=GetNsignals();
@@ -1212,31 +1216,26 @@ void AliCalorimeter::Group(Int_t n,Int_t mode)
   if (GetNclusters() > 0) Ungroup(); // Restore unclustered situation if needed
  
   // Order the modules with decreasing signal
-  AliCalmodule** ordered=new AliCalmodule*[nsignals]; // temp. array for ordered modules
+  if (mode==1) SortM(); 
+  if (mode==2) SortA();
+
   Int_t nord=0;
-  if (mode==1) SortM(ordered,nord);
-  if (mode==2) SortA(ordered,nord);
+  if (fOrdered) nord=fOrdered->GetEntries();
  
   // Clustering of modules. Start with the highest signal.
-  if (fClusters)
-  {
-   delete fClusters;
-   fClusters=0;
-  }
   fClusters=new TObjArray();
   fClusters->SetOwner();
   Int_t row=0;
   Int_t col=0;
   AliCalcluster* c=0;
-  AliCalmodule* m=0;
   for (Int_t i=0; i<nord; i++)
   {
-   row=ordered[i]->GetRow();    // row number of cluster center
-   col=ordered[i]->GetColumn(); // column number of cluster center
-
-   m=(AliCalmodule*)fMatrix->GetObject(row,col);
+   AliCalmodule* m=(AliCalmodule*)fOrdered->At(i);
    if (!m) continue;
 
+   row=m->GetRow();    // row number of cluster center
+   col=m->GetColumn(); // column number of cluster center
+
    // only use modules not yet used in a cluster
    if (m->GetClusteredSignal() > 0.)
    {
@@ -1255,20 +1254,10 @@ void AliCalorimeter::Group(Int_t n,Int_t mode)
     }
    }
   }
-  // Delete the temp. array
-  if (ordered)
-  { 
-   for (Int_t j=0; j<nord; j++)
-   {
-    ordered[j]=0;
-   }
-   delete [] ordered;
-  }
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SortM(AliCalmodule** ordered,Int_t& nord)
+void AliCalorimeter::SortM()
 {
 // Order the modules with decreasing signal by looping over the (row,col) grid
 // of the matrix.
@@ -1295,23 +1284,37 @@ void AliCalorimeter::SortM(AliCalmodule** ordered,Int_t& nord)
 // ---------------
 // * In case of a very high occupancy, there might be a slight effect on the
 //   cluster signals depending on the geometrical location in the detector matrix.
+
+ if (fOrdered)
+ {
+  delete fOrdered;
+  fOrdered=0;
+ }
+
  Int_t nrows=fMatrix->GetMaxRow();
  Int_t ncols=fMatrix->GetMaxColumn();
 
  Float_t signal=0.;
- nord=0;
Int_t nord=0;
  for (Int_t irow=1; irow<=nrows; irow++) // loop over all modules of the matrix
  {
   for (Int_t icol=1; icol<=ncols; icol++)
   {
-   signal=GetSignal(irow,icol,1); // get the gain etc... corrected signal
-   if (signal <= 0.) continue;    // only take alive modules with a signal
+   AliCalmodule* m=(AliCalmodule*)fMatrix->GetObject(irow,icol);
+   if (!m) continue;
+
+   signal=m->GetSignal(1,1);   // get the gain etc... corrected signal
+   if (signal <= 0.) continue; // only take alive modules with a signal
  
    if (nord == 0) // store the first module with a signal at the first ordered position
    {
+    if (!fOrdered)
+    {
+     Int_t nhits=GetNhits();
+     fOrdered=new TObjArray(nhits);
+    }
     nord++;
-    ordered[nord-1]=(AliCalmodule*)fMatrix->GetObject(irow,icol);
+    fOrdered->AddAt(m,nord-1);
     continue;
    }
  
@@ -1320,25 +1323,25 @@ void AliCalorimeter::SortM(AliCalmodule** ordered,Int_t& nord)
     if (j == nord) // module has smallest signal seen so far
     {
      nord++;
-     ordered[j]=(AliCalmodule*)fMatrix->GetObject(irow,icol); // add module at the end
+     fOrdered->AddAt(m,j); // add module at the end
      break; // go for next matrix module
     }
  
-    if (signal < ordered[j]->GetSignal(1,1)) continue;
+    if (signal < ((AliCalmodule*)fOrdered->At(j))->GetSignal(1,1)) continue;
  
     nord++;
     for (Int_t k=nord-1; k>j; k--) // create empty position
     {
-     ordered[k]=ordered[k-1];
+     fOrdered->AddAt(fOrdered->At(k-1),k);
     }
-    ordered[j]=(AliCalmodule*)fMatrix->GetObject(irow,icol); // put module at empty position
+    fOrdered->AddAt(m,j); // put module at empty position
     break; // go for next matrix module
    }
   }
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SortA(AliCalmodule** ordered,Int_t& nord)
+void AliCalorimeter::SortA()
 {
 // Order the modules with decreasing signal by looping over the linear array
 // of fired modules.
@@ -1365,45 +1368,8 @@ void AliCalorimeter::SortA(AliCalmodule** ordered,Int_t& nord)
 //   of the resulting cluster signal.
 // * This method might produce results depending on the filling
 //   order of the matrix modules.
- Int_t nmods=0;
- if (fMatrix) nmods=fMatrix->GetNobjects();
 
- nord=0;
- for (Int_t i=1; i<=nmods; i++) // loop over all fired modules of the matrix
- {
-  AliCalmodule* m=(AliCalmodule*)fMatrix->GetObject(i);
-
-  if (!m) continue;
-  if (m->GetDeadValue()) continue; // only take alive modules with a signal
-  if (nord == 0) // store the first module with a signal at the first ordered position
-  {
-   nord++;
-   ordered[nord-1]=m;
-   continue;
-  }
-  for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
-  {
-   if (j == nord) // module has smallest signal seen so far
-   {
-    nord++;
-    ordered[j]=m; // add module at the end
-    break; // go for next matrix module
-   }
-   if (m->GetSignal(1,1) < ordered[j]->GetSignal(1,1)) continue;
-   nord++;
-   for (Int_t k=nord-1; k>j; k--) // create empty position
-   {
-    ordered[k]=ordered[k-1];
-   }
-   ordered[j]=m; // put module at empty position
-   break; // go for next matrix module
-  }
- }
+ SortHits();
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
@@ -1443,7 +1409,7 @@ void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetNclusters()
+Int_t AliCalorimeter::GetNclusters() const
 {
 // Provide the number of clusters
  Int_t nclu=0;
@@ -1451,7 +1417,7 @@ Int_t AliCalorimeter::GetNclusters()
  return nclu;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
+AliCalcluster* AliCalorimeter::GetCluster(Int_t j) const
 {
 // Provide cluster number j
 // Note : j=1 denotes the first cluster
@@ -1470,23 +1436,13 @@ AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliCalmodule* AliCalorimeter::GetModule(Int_t j)
+AliCalmodule* AliCalorimeter::GetModule(Int_t j) const
 {
 // Provide 'fired' module number j
 // Note : j=1 denotes the first 'fired' module
 
- if (!fMatrix) return 0;
-
- if ((j >= 1) && (j <= GetNsignals()))
- {
-  return (AliCalmodule*)fMatrix->GetObject(j);
- }
- else
- {
-  cout << " *AliCalorimeter::GetModule* module number : " << j
-       << " out of range ==> 0 returned." << endl;
-  return 0;
- }
+ AliCalmodule* m=(AliCalmodule*)GetHit(j);
+ return m;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
@@ -1495,6 +1451,7 @@ AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
 // Note : first module is at (1,1).
 
  AliCalmodule* m=0;
+ if (!fMatrix) LoadMatrix();
  if (fMatrix) m=(AliCalmodule*)fMatrix->GetObject(row,col);
  return m;
 }
@@ -1510,6 +1467,8 @@ TH2F* AliCalorimeter::DrawModules(Float_t thresh,Int_t mode)
  Int_t nrows=fNrows;
  Int_t ncols=fNcolumns;
 
+ if (!fMatrix) LoadMatrix();
+
  if (fMatrix && !nrows && !ncols)
  {
   nrows=fMatrix->GetMaxRow();
@@ -1530,20 +1489,20 @@ TH2F* AliCalorimeter::DrawModules(Float_t thresh,Int_t mode)
  
  Int_t nmods=GetNsignals();
 
- Float_t row,col,signal;
+ Int_t row,col;
+ Float_t signal;
  Int_t dead;
  for (Int_t i=1; i<=nmods; i++)
  {
   AliCalmodule* m=(AliCalmodule*)fMatrix->GetObject(i);
   if (m)
   {
-   row=float(m->GetRow());
-   col=float(m->GetColumn());
+   row=m->GetRow();
+   col=m->GetColumn();
    dead=m->GetDeadValue();
    signal=0;
-   if (!dead) signal=GetSignal(static_cast<Int_t>(row),
-                              static_cast<Int_t>(col),mode);
-   if (signal>thresh) fHmodules->Fill(col,row,signal);
+   if (!dead) signal=GetSignal(row,col,mode);
+   if (signal>thresh) fHmodules->Fill(float(col),float(row),signal);
   }
  }
  
@@ -1560,6 +1519,8 @@ TH2F* AliCalorimeter::DrawClusters(Float_t thresh)
  Int_t nrows=fNrows;
  Int_t ncols=fNcolumns;
 
+ if (!fMatrix) LoadMatrix();
+
  if (fMatrix && !nrows && !ncols)
  {
   nrows=fMatrix->GetMaxRow();
@@ -1579,16 +1540,17 @@ TH2F* AliCalorimeter::DrawClusters(Float_t thresh)
  }
  
  AliCalcluster* c;
- Float_t row,col,signal;
+ Int_t row,col;
+ Float_t signal;
  for (Int_t i=0; i<GetNclusters(); i++)
  {
   c=(AliCalcluster*)fClusters->At(i);
   if (c)
   {
-   row=float(c->GetRow());
-   col=float(c->GetColumn());
+   row=c->GetRow();
+   col=c->GetColumn();
    signal=c->GetSignal();
-   if (signal>thresh) fHclusters->Fill(col,row,signal);
+   if (signal>thresh) fHclusters->Fill(float(col),float(row),signal);
   }
  }
  
@@ -1600,6 +1562,8 @@ void AliCalorimeter::Ungroup()
 {
 // Set the module signals back to the non-clustered situation
 
+ if (!fMatrix) LoadMatrix();
+
  if (!fMatrix) return;
  
  Int_t nsig=GetNsignals();
@@ -1630,7 +1594,7 @@ void AliCalorimeter::AddVetoSignal(AliSignal& s)
  fVetos->Add(sx);
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetNvetos()
+Int_t AliCalorimeter::GetNvetos() const
 {
 // Provide the number of veto signals associated to the calorimeter.
  Int_t nvetos=0;
@@ -1638,7 +1602,7 @@ Int_t AliCalorimeter::GetNvetos()
  return nvetos;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
+AliSignal* AliCalorimeter::GetVetoSignal(Int_t i) const
 {
 // Provide access to the i-th veto signal of this calorimeter
 // Note : The first hit corresponds to i=1
@@ -1655,19 +1619,7 @@ AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SetName(TString name)
-{
-// Set the name of the calorimeter system.
- fName=name;
-}
-///////////////////////////////////////////////////////////////////////////
-TString AliCalorimeter::GetName()
-{
-// Provide the name of the calorimeter system.
- return fName;
-}
-///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SetSwapMode(Int_t swap)
+void AliCalorimeter::SetMatrixSwapMode(Int_t swap)
 {
 // Set the swap mode for the module and position matrices.
 // At invokation of this memberfunction the default argument is swap=1.
@@ -1678,26 +1630,54 @@ void AliCalorimeter::SetSwapMode(Int_t swap)
  }
  else
  {
-  cout << " *AliCalorimeter::SetSwapMode* Invalid argument : swap = " << swap << endl; 
+  cout << " *AliCalorimeter::SetMatrixSwapMode* Invalid argument : swap = " << swap << endl; 
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetSwapMode()
+Int_t AliCalorimeter::GetMatrixSwapMode() const
 {
 // Provide the swap mode for the module and position matrices.
 // For further details see the documentation of AliObjMatrix.
  return fSwap;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliCalorimeter* AliCalorimeter::MakeCopy(AliCalorimeter& c)
+void AliCalorimeter::LoadMatrix()
+{
+// Load the matrix lookup table of module pointers from the linear hit array.
+ Int_t nhits=GetNhits();
+ if (!nhits) return;
+
+ fMatrix=new AliObjMatrix();
+ fMatrix->SetSwapMode(fSwap);
+
+ Int_t row=0;
+ Int_t col=0;
+ for (Int_t i=1; i<=nhits; i++)
+ {
+  AliCalmodule* m=(AliCalmodule*)GetHit(i);
+  if (m)
+  {
+   row=m->GetRow();
+   col=m->GetColumn();
+   fMatrix->EnterObject(row,col,m);
+  }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliCalorimeter::Clone(const char* name) const
 {
-// Make a deep copy of the input object and provide the pointer to the copy.
+// Make a deep copy of the current object and provide the pointer to the copy.
 // This memberfunction enables automatic creation of new objects of the
-// correct type depending on the argument type, a feature which may be very useful
+// correct type depending on the object type, a feature which may be very useful
 // for containers like AliEvent when adding objects in case the
 // container owns the objects.
 
- AliCalorimeter* cal=new AliCalorimeter(c);
+ AliCalorimeter* cal=new AliCalorimeter(*this);
+ if (name)
+ {
+  if (strlen(name)) cal->SetName(name);
+ } 
  return cal;
 }
 ///////////////////////////////////////////////////////////////////////////