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 Int_t CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
33 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
34 size_t fMaxDetectors; // Maximum # of detectors
35 size_t fMaxRings; // Maximum # of rings
36 size_t fMaxSectors; // Maximum # of sectors
37 size_t fMaxStrips; // Maximum # of strips
38 ClassDef(AliFMDMap, 1) // Cache of per strip information
41 #ifdef MAY_USE_TEMPLATES
45 //____________________________________________________________________
47 // Class template for classes that cache per strip information.
48 // Access to the data goes via
50 // Type& AliFMDMap<Type>::operator()(size_t detector,
55 // (as well as a const version of this member function).
56 // The elements can be reset to the default value by calling
57 // AliFMDMap<Type>::Clear(). This resets the values to `Type()'.
59 template <typename Type>
60 class AliFMDMap : public TObject
63 AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40,
65 virtual ~AliFMDMap() {}
66 void Clear(const Type& val=Type());
67 Type& operator()(size_t det, Char_t ring, size_t sec, size_t str);
68 const Type& operator()(size_t det, Char_t ring, size_t sec, size_t str)const;
70 typedef std::vector<Type> ValueVector; // Type of container
71 ValueVector fValues; // Contained values
72 size_t fMaxDetectors; // Maximum # of detectors
73 size_t fMaxRings; // Maximum # of rings
74 size_t fMaxSectors; // Maximum # of sectors
75 size_t fMaxStrips; // Maximum # of strips
77 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
78 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
82 //____________________________________________________________________
83 template <typename Type>
85 AliFMDMap<Type>::AliFMDMap(size_t maxDet,
89 : fValues(maxDet * maxRing * maxSec * maxStr),
90 fMaxDetectors(maxDet),
98 // maxDet Maximum # of detectors
99 // maxRinf Maximum # of rings
100 // maxSec Maximum # of sectors
101 // maxStr Maximum # of strips
105 //____________________________________________________________________
106 template <typename Type>
108 AliFMDMap<Type>::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
110 // Calculate index into storage from arguments.
118 // Returns appropriate index into storage
120 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
122 (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
123 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) {
124 Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
125 "in particular the %s index",
127 (det >= fMaxDetectors ? "Detector" :
128 (ringi >= fMaxRings ? "Ring" :
129 (sec >= fMaxSectors ? "Sector" : "Strip"))));
135 //____________________________________________________________________
136 template <typename Type>
138 AliFMDMap<Type>::Clear(const Type& val)
140 // Resets stored values to the default value for that type
141 for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
144 //____________________________________________________________________
145 template <typename Type>
147 AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)
155 // Returns data[det][ring][sec][str]
156 return fValues[CalcIndex(det, ring, sec, str)];
159 //____________________________________________________________________
160 template <typename Type>
162 AliFMDMap<Type>::operator()(size_t det,
173 // Returns data[det][ring][sec][str]
174 return fValues[CalcIndex(det, ring, sec, str)];
178 //____________________________________________________________________
180 // Some specialisations
182 typedef AliFMDMap<UShort_t> AliFMDAdcMap;
183 typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
187 //____________________________________________________________________