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.
16 class AliFMDMap : public TObject
25 AliFMDMap(size_t maxDet = kMaxDetectors,
26 size_t maxRing= kMaxRings,
27 size_t maxSec = kMaxSectors,
28 size_t maxStr = kMaxStrips);
29 virtual ~AliFMDMap() {}
30 Int_t CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
32 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
33 size_t fMaxDetectors; // Maximum # of detectors
34 size_t fMaxRings; // Maximum # of rings
35 size_t fMaxSectors; // Maximum # of sectors
36 size_t fMaxStrips; // Maximum # of strips
37 ClassDef(AliFMDMap, 1) // Cache of per strip information
40 #ifdef MAY_USE_TEMPLATES
44 //____________________________________________________________________
46 // Class template for classes that cache per strip information.
47 // Access to the data goes via
49 // Type& AliFMDMap<Type>::operator()(size_t detector,
54 // (as well as a const version of this member function).
55 // The elements can be reset to the default value by calling
56 // AliFMDMap<Type>::Clear(). This resets the values to `Type()'.
58 template <typename Type>
59 class AliFMDMap : public TObject
62 AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40,
64 virtual ~AliFMDMap() {}
65 void Clear(const Type& val=Type());
66 Type& operator()(size_t det, Char_t ring, size_t sec, size_t str);
67 const Type& operator()(size_t det, Char_t ring, size_t sec, size_t str)const;
69 typedef std::vector<Type> ValueVector; // Type of container
70 ValueVector fValues; // Contained values
71 size_t fMaxDetectors; // Maximum # of detectors
72 size_t fMaxRings; // Maximum # of rings
73 size_t fMaxSectors; // Maximum # of sectors
74 size_t fMaxStrips; // Maximum # of strips
76 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
77 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
81 //____________________________________________________________________
82 template <typename Type>
84 AliFMDMap<Type>::AliFMDMap(size_t maxDet,
88 : fValues(maxDet * maxRing * maxSec * maxStr),
89 fMaxDetectors(maxDet),
97 // maxDet Maximum # of detectors
98 // maxRinf Maximum # of rings
99 // maxSec Maximum # of sectors
100 // maxStr Maximum # of strips
104 //____________________________________________________________________
105 template <typename Type>
107 AliFMDMap<Type>::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
109 // Calculate index into storage from arguments.
117 // Returns appropriate index into storage
119 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
121 (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
122 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) {
123 Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
124 "in particular the %s index",
126 (det >= fMaxDetectors ? "Detector" :
127 (ringi >= fMaxRings ? "Ring" :
128 (sec >= fMaxSectors ? "Sector" : "Strip"))));
134 //____________________________________________________________________
135 template <typename Type>
137 AliFMDMap<Type>::Clear(const Type& val)
139 // Resets stored values to the default value for that type
140 for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
143 //____________________________________________________________________
144 template <typename Type>
146 AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)
154 // Returns data[det][ring][sec][str]
155 return fValues[CalcIndex(det, ring, sec, str)];
158 //____________________________________________________________________
159 template <typename Type>
161 AliFMDMap<Type>::operator()(size_t det,
172 // Returns data[det][ring][sec][str]
173 return fValues[CalcIndex(det, ring, sec, str)];
177 //____________________________________________________________________
179 // Some specialisations
181 typedef AliFMDMap<UShort_t> AliFMDAdcMap;
182 typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
186 //____________________________________________________________________