]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFMDFloatMap.cxx
Addition of gaussian truncated at different left and right distances (useful for...
[u/mrichter/AliRoot.git] / STEER / AliFMDFloatMap.cxx
index dbe33866f9020e1ab2f9ff6c594d519d9d57da4c..86967661e0a629b446fb8f9a7cc6d177bacf08a3 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,23 +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
-  fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
-  fData  = new Float_t[fTotal];
-  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:
@@ -57,9 +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
-  fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
-  fData  = new Float_t[fTotal];
-  Reset();
+  Reset(0);
 }
 
 //__________________________________________________________
@@ -67,14 +70,22 @@ AliFMDFloatMap&
 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
 {
   // Assignment operator 
-  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 (size_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
+  if(&other != this){
+    if(fMaxDetectors!= other.fMaxDetectors||
+       fMaxRings    != other.fMaxRings||
+       fMaxSectors  != other.fMaxSectors||
+       fMaxStrips   != other.fMaxStrips){
+      // allocate new memory only if the array size is different....
+      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;
 }
 
@@ -83,7 +94,7 @@ void
 AliFMDFloatMap::Reset(const Float_t& val)
 {
   // Reset map to val
-  for (size_t i = 0; i < fTotal; i++) fData[i] = val;
+  for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
 }
 
 //__________________________________________________________