]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDEdepMap.cxx
Fixes for coverity checks.
[u/mrichter/AliRoot.git] / FMD / AliFMDEdepMap.cxx
index e6872b06ef7a7a0f04bf56c912192c6cfb6bb58f..7a34c10ea989d6bff865fa2f94124895fb97831e 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
-
+/** @file    AliFMDEdepMap.cxx
+    @author  Christian Holm Christensen <cholm@nbi.dk>
+    @date    Mon Mar 27 12:39:50 2006
+    @brief   Per strip map of energy deposited and number of hits 
+    @ingroup FMD_sim
+*/
 //____________________________________________________________________
 //                                                                          
+// Contains a pair of energy deposited fEdep and number of hits  
+// fN, fEdep is the summed energy deposition, and fN is the
+// number of hits.  The map contains one such object or each strip.
+// It is used to cache the data in the digitization classes
+// AliFMDBaseDigitizer and so on. 
 //
 //
 #include "AliFMDEdepMap.h"             // ALIFMDEDEPMAP_H
@@ -31,22 +40,35 @@ ClassImp(AliFMDEdepMap)
 AliFMDEdepMap::AliFMDEdepMap(const AliFMDEdepMap& other)
   : AliFMDMap(other.fMaxDetectors, other.fMaxRings, other.fMaxSectors, 
              other.fMaxStrips), 
+    fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
     fData(0)
 {
   // Copy constructor 
-  fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
+  if (fTotal == 0) fTotal = 51200;
   fData  = new AliFMDEdepHitPair[fTotal];
-  for (size_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
+  for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
 }
 
   
+//____________________________________________________________________
+AliFMDEdepMap::AliFMDEdepMap()
+  : AliFMDMap(), 
+    fTotal(0),
+    fData(0)
+{
+  // Construct a map
+  //
+  // Parameters:
+  //   None
+}
 
 //____________________________________________________________________
-AliFMDEdepMap::AliFMDEdepMap(size_t maxDet, 
-                            size_t maxRing, 
-                            size_t maxSec, 
-                            size_t maxStr)
+AliFMDEdepMap::AliFMDEdepMap(UShort_t maxDet, 
+                            UShort_t maxRing, 
+                            UShort_t maxSec, 
+                            UShort_t maxStr)
   : AliFMDMap(maxDet, maxRing, maxSec, maxStr), 
+    fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
     fData(0)
 {
   // Construct a map
@@ -56,7 +78,7 @@ AliFMDEdepMap::AliFMDEdepMap(size_t maxDet,
   //     maxRinf      Maximum # of rings
   //     maxSec       Maximum # of sectors
   //     maxStr       Maximum # of strips
-  fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
+  if (fTotal == 0) fTotal = 51200;
   fData  = new AliFMDEdepHitPair[fTotal];
 }
 
@@ -65,14 +87,16 @@ AliFMDEdepMap&
 AliFMDEdepMap::operator=(const AliFMDEdepMap& other) 
 {
   // Assignment operator
+  if (&other == this) return *this; 
   fMaxDetectors = other.fMaxDetectors;
   fMaxRings     = other.fMaxRings;
   fMaxSectors   = other.fMaxSectors;
   fMaxStrips    = other.fMaxStrips;
   if (fData) delete [] fData;
   fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
+  if (fTotal == 0) fTotal = 51200;
   fData  = new AliFMDEdepHitPair[fTotal];
-  for (size_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
+  for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
   return *this;
 }
 
@@ -81,9 +105,11 @@ void
 AliFMDEdepMap::Reset() 
 {
   // Reset to zero
-  for (size_t i = 0; i < fTotal; i++) { 
-    fData[i].fEdep = 0; 
-    fData[i].fN = 0; 
+  for (Int_t i = 0; i < fTotal; i++) { 
+    fData[i].fEdep  = 0; 
+    fData[i].fN     = 0; 
+    fData[i].fNPrim = 0;
+    fData[i].fLabels.Reset();
   };
 }
 
@@ -92,15 +118,18 @@ void
 AliFMDEdepMap::Reset(const AliFMDEdepHitPair& val) 
 {
   // Reset to val
-  for (size_t i = 0; i < fTotal; i++) { 
-    fData[i].fEdep = val.fEdep; 
-    fData[i].fN = val.fN; 
+  for (Int_t i = 0; i < fTotal; i++) { 
+    fData[i].fEdep   = val.fEdep; 
+    fData[i].fN      = val.fN; 
+    fData[i].fNPrim  = val.fNPrim;
+    fData[i].fLabels = val.fLabels;
   };
 }
 
 //____________________________________________________________________
 AliFMDEdepHitPair& 
-AliFMDEdepMap::operator()(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) 
+AliFMDEdepMap::operator()(UShort_t det, Char_t ring, 
+                         UShort_t sec, UShort_t str) 
 {
   // Get data 
   // 
@@ -117,7 +146,8 @@ AliFMDEdepMap::operator()(UShort_t det, Char_t ring, UShort_t sec, UShort_t str)
 
 //____________________________________________________________________
 const AliFMDEdepHitPair& 
-AliFMDEdepMap::operator()(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
+AliFMDEdepMap::operator()(UShort_t det, Char_t ring, 
+                         UShort_t sec, UShort_t str) const
 {
   // Get data 
   //