X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=STEER%2FAliFMDMap.h;h=6ffdc68dc5b6685afc955aeb4d46e817a516970b;hb=b31d3cd88c1e4a2116513923734ca727dbfeee08;hp=f50843395dd01d2230c2f3ddee5cfd912144dc0e;hpb=5664d15a373d9000cbf8bfc54e5c618125d3c048;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliFMDMap.h b/STEER/AliFMDMap.h index f50843395dd..6ffdc68dc5b 100755 --- a/STEER/AliFMDMap.h +++ b/STEER/AliFMDMap.h @@ -8,191 +8,80 @@ #ifndef ROOT_TObject # include #endif +class TFile; + //____________________________________________________________________ -// -// Base class for caches of per-strip information. -// This is used to index a strip. -// Data stored depends on derived class. -// +/** @class AliFMDMap + @brief Base class for caches of per-strip information. + @ingroup FMD_data + This is used to index a strip. Data stored depends on derived + class. */ class AliFMDMap : public TObject { public: enum { + /** Default maximum detector number */ kMaxDetectors = 3, + /** Default maximum number of rings */ kMaxRings = 2, + /** Default maximum number of sectors */ kMaxSectors = 40, + /** Default maximum number of strips */ kMaxStrips = 512 }; + /** Constructor + @param maxDet Maximum allowed detector number + @param maxRing Maximum number of rings + @param maxSec Maximum number of sectors + @param maxStr Maximum number of strips + @return */ AliFMDMap(UShort_t maxDet = kMaxDetectors, UShort_t maxRing= kMaxRings, UShort_t maxSec = kMaxSectors, UShort_t maxStr = kMaxStrips); + /** Destructor */ virtual ~AliFMDMap() {} + /** @return Maximum detector number */ UShort_t MaxDetectors() const { return fMaxDetectors; } + /** @return Maximum number of rings */ UShort_t MaxRings() const { return fMaxRings; } + /** @return Maximum number of sectors */ UShort_t MaxSectors() const { return fMaxSectors; } + /** @return Maximum number of strip */ UShort_t MaxStrips() const { return fMaxStrips; } + /** Calculate, check, and return index for strip. If the index is + invalid, -1 is returned + @param det Detector number + @param ring Ring identifier + @param sec Sector number + @param str Strip number + @return Unique index, or -1 in case of errors */ Int_t CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const; + /** Check if we need UShort_t hack + @param file File this object was read from */ + void CheckNeedUShort(TFile* file); + enum { + /** In case of version 2 of this class, this bit should be set. */ + kNeedUShort = 14 + }; protected: + /** Calculate index and return + @param det Detector number + @param ring Ring identifier + @param sec Sector number + @param str Strip number + @return Index (not checked) */ Int_t CalcIndex(UShort_t det, Char_t ring, - UShort_t sec, UShort_t str) const; + UShort_t sec, UShort_t str) const; UShort_t fMaxDetectors; // Maximum # of detectors UShort_t fMaxRings; // Maximum # of rings UShort_t fMaxSectors; // Maximum # of sectors UShort_t fMaxStrips; // Maximum # of strips - ClassDef(AliFMDMap, 2) // Cache of per strip information -}; -#ifdef MAY_USE_TEMPLATES -#ifndef __VECTOR__ -# include -#endif -//____________________________________________________________________ -// -// Class template for classes that cache per strip information. -// Access to the data goes via -// -// Type& AliFMDMap::operator()(UShort_t detector, -// Char_t ring, -// UShort_t sector, -// UShort_t strip); -// -// (as well as a const version of this member function). -// The elements can be reset to the default value by calling -// AliFMDMap::Clear(). This resets the values to `Type()'. -// -template -class AliFMDMap : public TObject -{ -public: - AliFMDMap(UShort_t maxDet=3, UShort_t maxRing=2, UShort_t maxSec=40, - UShort_t maxStr=512); - virtual ~AliFMDMap() {} - void Clear(const Type& val=Type()); - Type& operator()(UShort_t det, Char_t ring, UShort_t sec, UShort_t str); - const Type& operator()(UShort_t det, Char_t ring, - UShort_t sec, UShort_t str)const; -private: - typedef std::vector ValueVector; // Type of container - ValueVector fValues; // Contained values - UShort_t fMaxDetectors; // Maximum # of detectors - UShort_t fMaxRings; // Maximum # of rings - UShort_t fMaxSectors; // Maximum # of sectors - UShort_t fMaxStrips; // Maximum # of strips - - UShort_t CalcIndex(UShort_t det, Char_t ring, - UShort_t sec, UShort_t str) const; - ClassDef(AliFMDMap, 0); // Map of FMD index's to values + ClassDef(AliFMDMap, 3) // Cache of per strip information }; - -//____________________________________________________________________ -template -inline -AliFMDMap::AliFMDMap(UShort_t maxDet, - UShort_t maxRing, - UShort_t maxSec, - UShort_t maxStr) - : fValues(maxDet * maxRing * maxSec * maxStr), - fMaxDetectors(maxDet), - fMaxRings(maxRing), - fMaxSectors(maxSec), - fMaxStrips(maxStr) -{ - // Construct a map - // - // Parameters: - // maxDet Maximum # of detectors - // maxRinf Maximum # of rings - // maxSec Maximum # of sectors - // maxStr Maximum # of strips -} - - -//____________________________________________________________________ -template -inline UShort_t -AliFMDMap::CalcIndex(UShort_t det, Char_t ring, - UShort_t sec, UShort_t str) const -{ - // Calculate index into storage from arguments. - // - // Parameters: - // det Detector # - // ring Ring ID - // sec Sector # - // str Strip # - // - // Returns appropriate index into storage - // - UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1); - UShort_t idx = - (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str))); - if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) { - Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, " - "in particular the %s index", - det, ring, sec, str, - (det >= fMaxDetectors ? "Detector" : - (ringi >= fMaxRings ? "Ring" : - (sec >= fMaxSectors ? "Sector" : "Strip")))); - return 0; - } - return idx; -} - -//____________________________________________________________________ -template -inline void -AliFMDMap::Clear(const Type& val) -{ - // Resets stored values to the default value for that type - for (UShort_t i = 0; i < fValues.size(); ++i) fValues[i] = val; -} - -//____________________________________________________________________ -template -inline Type& -AliFMDMap::operator()(UShort_t det, Char_t ring, - UShort_t sec, UShort_t str) -{ - // Parameters: - // det Detector # - // ring Ring ID - // sec Sector # - // str Strip # - // - // Returns data[det][ring][sec][str] - return fValues[CalcIndex(det, ring, sec, str)]; -} - -//____________________________________________________________________ -template -inline const Type& -AliFMDMap::operator()(UShort_t det, - Char_t ring, - UShort_t sec, - UShort_t str) const -{ - // Parameters: - // det Detector # - // ring Ring ID - // sec Sector # - // str Strip # - // - // Returns data[det][ring][sec][str] - return fValues[CalcIndex(det, ring, sec, str)]; -} - - -//____________________________________________________________________ -// -// Some specialisations -// -typedef AliFMDMap AliFMDAdcMap; -typedef AliFMDMap > AliFMDEdepMap; - -#endif #endif //____________________________________________________________________ //