3 /* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights
6 * See cxx source for full Copyright notice
11 //____________________________________________________________________
13 // Base class for caches of per-strip information.
14 // This is used to index a strip.
15 // Data stored depends on derived class.
17 class AliFMDMap : public TObject
26 AliFMDMap(size_t maxDet = kMaxDetectors,
27 size_t maxRing= kMaxRings,
28 size_t maxSec = kMaxSectors,
29 size_t maxStr = kMaxStrips);
30 virtual ~AliFMDMap() {}
31 size_t MaxDetectors() const { return fMaxDetectors; }
32 size_t MaxRings() const { return fMaxRings; }
33 size_t MaxSectors() const { return fMaxSectors; }
34 size_t MaxStrips() const { return fMaxStrips; }
35 Int_t CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
37 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
38 size_t fMaxDetectors; // Maximum # of detectors
39 size_t fMaxRings; // Maximum # of rings
40 size_t fMaxSectors; // Maximum # of sectors
41 size_t fMaxStrips; // Maximum # of strips
42 ClassDef(AliFMDMap, 1) // Cache of per strip information
45 #ifdef MAY_USE_TEMPLATES
49 //____________________________________________________________________
51 // Class template for classes that cache per strip information.
52 // Access to the data goes via
54 // Type& AliFMDMap<Type>::operator()(size_t detector,
59 // (as well as a const version of this member function).
60 // The elements can be reset to the default value by calling
61 // AliFMDMap<Type>::Clear(). This resets the values to `Type()'.
63 template <typename Type>
64 class AliFMDMap : public TObject
67 AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40,
69 virtual ~AliFMDMap() {}
70 void Clear(const Type& val=Type());
71 Type& operator()(size_t det, Char_t ring, size_t sec, size_t str);
72 const Type& operator()(size_t det, Char_t ring, size_t sec, size_t str)const;
74 typedef std::vector<Type> ValueVector; // Type of container
75 ValueVector fValues; // Contained values
76 size_t fMaxDetectors; // Maximum # of detectors
77 size_t fMaxRings; // Maximum # of rings
78 size_t fMaxSectors; // Maximum # of sectors
79 size_t fMaxStrips; // Maximum # of strips
81 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
82 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
86 //____________________________________________________________________
87 template <typename Type>
89 AliFMDMap<Type>::AliFMDMap(size_t maxDet,
93 : fValues(maxDet * maxRing * maxSec * maxStr),
94 fMaxDetectors(maxDet),
102 // maxDet Maximum # of detectors
103 // maxRinf Maximum # of rings
104 // maxSec Maximum # of sectors
105 // maxStr Maximum # of strips
109 //____________________________________________________________________
110 template <typename Type>
112 AliFMDMap<Type>::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
114 // Calculate index into storage from arguments.
122 // Returns appropriate index into storage
124 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
126 (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
127 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) {
128 Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
129 "in particular the %s index",
131 (det >= fMaxDetectors ? "Detector" :
132 (ringi >= fMaxRings ? "Ring" :
133 (sec >= fMaxSectors ? "Sector" : "Strip"))));
139 //____________________________________________________________________
140 template <typename Type>
142 AliFMDMap<Type>::Clear(const Type& val)
144 // Resets stored values to the default value for that type
145 for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
148 //____________________________________________________________________
149 template <typename Type>
151 AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)
159 // Returns data[det][ring][sec][str]
160 return fValues[CalcIndex(det, ring, sec, str)];
163 //____________________________________________________________________
164 template <typename Type>
166 AliFMDMap<Type>::operator()(size_t det,
177 // Returns data[det][ring][sec][str]
178 return fValues[CalcIndex(det, ring, sec, str)];
182 //____________________________________________________________________
184 // Some specialisations
186 typedef AliFMDMap<UShort_t> AliFMDAdcMap;
187 typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
191 //____________________________________________________________________