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() {}
31 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
32 size_t fMaxDetectors; // Maximum # of detectors
33 size_t fMaxRings; // Maximum # of rings
34 size_t fMaxSectors; // Maximum # of sectors
35 size_t fMaxStrips; // Maximum # of strips
36 ClassDef(AliFMDMap, 1) // Cache of per strip information
39 #ifdef MAY_USE_TEMPLATES
43 //____________________________________________________________________
45 // Class template for classes that cache per strip information.
46 // Access to the data goes via
48 // Type& AliFMDMap<Type>::operator()(size_t detector,
53 // (as well as a const version of this member function).
54 // The elements can be reset to the default value by calling
55 // AliFMDMap<Type>::Clear(). This resets the values to `Type()'.
57 template <typename Type>
58 class AliFMDMap : public TObject
61 AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40,
63 virtual ~AliFMDMap() {}
64 void Clear(const Type& val=Type());
65 Type& operator()(size_t det, Char_t ring, size_t sec, size_t str);
66 const Type& operator()(size_t det, Char_t ring, size_t sec, size_t str)const;
68 typedef std::vector<Type> ValueVector; // Type of container
69 ValueVector fValues; // Contained values
70 size_t fMaxDetectors; // Maximum # of detectors
71 size_t fMaxRings; // Maximum # of rings
72 size_t fMaxSectors; // Maximum # of sectors
73 size_t fMaxStrips; // Maximum # of strips
75 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
76 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
80 //____________________________________________________________________
81 template <typename Type>
83 AliFMDMap<Type>::AliFMDMap(size_t maxDet,
87 : fValues(maxDet * maxRing * maxSec * maxStr),
88 fMaxDetectors(maxDet),
96 // maxDet Maximum # of detectors
97 // maxRinf Maximum # of rings
98 // maxSec Maximum # of sectors
99 // maxStr Maximum # of strips
103 //____________________________________________________________________
104 template <typename Type>
106 AliFMDMap<Type>::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
108 // Calculate index into storage from arguments.
116 // Returns appropriate index into storage
118 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
120 (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
121 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) {
122 Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
123 "in particular the %s index",
125 (det >= fMaxDetectors ? "Detector" :
126 (ringi >= fMaxRings ? "Ring" :
127 (sec >= fMaxSectors ? "Sector" : "Strip"))));
133 //____________________________________________________________________
134 template <typename Type>
136 AliFMDMap<Type>::Clear(const Type& val)
138 // Resets stored values to the default value for that type
139 for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
142 //____________________________________________________________________
143 template <typename Type>
145 AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)
153 // Returns data[det][ring][sec][str]
154 return fValues[CalcIndex(det, ring, sec, str)];
157 //____________________________________________________________________
158 template <typename Type>
160 AliFMDMap<Type>::operator()(size_t det,
171 // Returns data[det][ring][sec][str]
172 return fValues[CalcIndex(det, ring, sec, str)];
176 //____________________________________________________________________
178 // Some specialisations
180 typedef AliFMDMap<UShort_t> AliFMDAdcMap;
181 typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
185 //____________________________________________________________________