//__________________________________________________________
//
// 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
//
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:
// 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);
}
//__________________________________________________________
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){
+ 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;
}
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;
}
//__________________________________________________________