]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFMDFloatMap.cxx
Additional protection for locked geometry. Don't MakeAlignablePN in Set/GetLocalMatrix
[u/mrichter/AliRoot.git] / STEER / AliFMDFloatMap.cxx
index 5251a30ce2f897bd24feb4c635af61d2f6fc6b68..5be6487bb53a4c4194687136c7dca303004a226d 100755 (executable)
 //__________________________________________________________
 // 
 // Map of per strip Float_t information
+// the floats are indexed by the coordinates 
+//     DETECTOR # (1-3)
+//     RING ID    ('I' or 'O', any case)
+//     SECTOR #   (0-39)
+//     STRIP #    (0-511)
+//
 // 
 // Created Mon Nov  8 12:51:51 2004 by Christian Holm Christensen
 // 
@@ -33,22 +39,22 @@ AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
               other.fMaxRings,
               other.fMaxSectors,
               other.fMaxStrips),
-    fData(0)
+    fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
+    fData(new Float_t[fTotal])
 {
   // Copy constructor
-  fData = new Float_t[fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips];
-  for (size_t i = 0; i < fMaxDetectors * fMaxRings 
-        * fMaxSectors * fMaxStrips; i++)
+  for (Int_t i = 0; i < fTotal; i++)
     fData[i] = other.fData[i];
 }
 
 //__________________________________________________________
-AliFMDFloatMap::AliFMDFloatMap(size_t maxDet,
-                              size_t maxRing,
-                              size_t maxSec,
-                              size_t maxStr)
+AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
+                              Int_t maxRing,
+                              Int_t maxSec,
+                              Int_t maxStr)
   : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
-    fData(0)
+    fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
+    fData(new Float_t[fTotal])
 {
   // Constructor.
   // Parameters:
@@ -56,8 +62,7 @@ AliFMDFloatMap::AliFMDFloatMap(size_t maxDet,
   //   maxRing Maximum number of rings per detector
   //   maxSec  Maximum number of sectors per ring
   //   maxStr  Maximum number of strips per sector
-  fData = new Float_t[fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips];
-  Reset();
+  Reset(0);
 }
 
 //__________________________________________________________
@@ -65,15 +70,16 @@ AliFMDFloatMap&
 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
 {
   // Assignment operator 
-  fMaxDetectors = other.fMaxDetectors;
-  fMaxRings     = other.fMaxRings;
-  fMaxSectors   = other.fMaxSectors;
-  fMaxStrips    = other.fMaxStrips;
-  if (fData) delete [] fData;
-  fData = new Float_t[fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips];
-  for (size_t i = 0; i < fMaxDetectors * fMaxRings 
-        * fMaxSectors * fMaxStrips; i++)
-    fData[i] = other.fData[i];
+  if(&other != this){
+    fMaxDetectors = other.fMaxDetectors;
+    fMaxRings     = other.fMaxRings;
+    fMaxSectors   = other.fMaxSectors;
+    fMaxStrips    = other.fMaxStrips;
+    fTotal        = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
+    if (fData) delete [] fData;
+    fData = new Float_t[fTotal];
+    for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
+  }
   return *this;
 }
 
@@ -82,9 +88,7 @@ void
 AliFMDFloatMap::Reset(const Float_t& val)
 {
   // Reset map to val
-  for (size_t i = 0; i < fMaxDetectors * fMaxRings 
-        * fMaxSectors * fMaxStrips; i++)
-    fData[i] = val;
+  for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
 }
 
 //__________________________________________________________