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(UShort_t maxDet = kMaxDetectors,
27 UShort_t maxRing= kMaxRings,
28 UShort_t maxSec = kMaxSectors,
29 UShort_t maxStr = kMaxStrips);
30 virtual ~AliFMDMap() {}
31 UShort_t MaxDetectors() const { return fMaxDetectors; }
32 UShort_t MaxRings() const { return fMaxRings; }
33 UShort_t MaxSectors() const { return fMaxSectors; }
34 UShort_t MaxStrips() const { return fMaxStrips; }
35 Int_t CheckIndex(UShort_t det, Char_t ring,
36 UShort_t sec, UShort_t str) const;
38 Int_t CalcIndex(UShort_t det, Char_t ring,
39 UShort_t sec, UShort_t str) const;
40 UShort_t fMaxDetectors; // Maximum # of detectors
41 UShort_t fMaxRings; // Maximum # of rings
42 UShort_t fMaxSectors; // Maximum # of sectors
43 UShort_t fMaxStrips; // Maximum # of strips
44 ClassDef(AliFMDMap, 2) // Cache of per strip information
47 #ifdef MAY_USE_TEMPLATES
51 //____________________________________________________________________
53 // Class template for classes that cache per strip information.
54 // Access to the data goes via
56 // Type& AliFMDMap<Type>::operator()(UShort_t detector,
61 // (as well as a const version of this member function).
62 // The elements can be reset to the default value by calling
63 // AliFMDMap<Type>::Clear(). This resets the values to `Type()'.
65 template <typename Type>
66 class AliFMDMap : public TObject
69 AliFMDMap(UShort_t maxDet=3, UShort_t maxRing=2, UShort_t maxSec=40,
71 virtual ~AliFMDMap() {}
72 void Clear(const Type& val=Type());
73 Type& operator()(UShort_t det, Char_t ring, UShort_t sec, UShort_t str);
74 const Type& operator()(UShort_t det, Char_t ring,
75 UShort_t sec, UShort_t str)const;
77 typedef std::vector<Type> ValueVector; // Type of container
78 ValueVector fValues; // Contained values
79 UShort_t fMaxDetectors; // Maximum # of detectors
80 UShort_t fMaxRings; // Maximum # of rings
81 UShort_t fMaxSectors; // Maximum # of sectors
82 UShort_t fMaxStrips; // Maximum # of strips
84 UShort_t CalcIndex(UShort_t det, Char_t ring,
85 UShort_t sec, UShort_t str) const;
86 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
90 //____________________________________________________________________
91 template <typename Type>
93 AliFMDMap<Type>::AliFMDMap(UShort_t maxDet,
97 : fValues(maxDet * maxRing * maxSec * maxStr),
98 fMaxDetectors(maxDet),
106 // maxDet Maximum # of detectors
107 // maxRinf Maximum # of rings
108 // maxSec Maximum # of sectors
109 // maxStr Maximum # of strips
113 //____________________________________________________________________
114 template <typename Type>
116 AliFMDMap<Type>::CalcIndex(UShort_t det, Char_t ring,
117 UShort_t sec, UShort_t str) const
119 // Calculate index into storage from arguments.
127 // Returns appropriate index into storage
129 UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
131 (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
132 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) {
133 Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
134 "in particular the %s index",
136 (det >= fMaxDetectors ? "Detector" :
137 (ringi >= fMaxRings ? "Ring" :
138 (sec >= fMaxSectors ? "Sector" : "Strip"))));
144 //____________________________________________________________________
145 template <typename Type>
147 AliFMDMap<Type>::Clear(const Type& val)
149 // Resets stored values to the default value for that type
150 for (UShort_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
153 //____________________________________________________________________
154 template <typename Type>
156 AliFMDMap<Type>::operator()(UShort_t det, Char_t ring,
157 UShort_t sec, UShort_t str)
165 // Returns data[det][ring][sec][str]
166 return fValues[CalcIndex(det, ring, sec, str)];
169 //____________________________________________________________________
170 template <typename Type>
172 AliFMDMap<Type>::operator()(UShort_t det,
183 // Returns data[det][ring][sec][str]
184 return fValues[CalcIndex(det, ring, sec, str)];
188 //____________________________________________________________________
190 // Some specialisations
192 typedef AliFMDMap<UShort_t> AliFMDAdcMap;
193 typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
197 //____________________________________________________________________