]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDMap.h
Compiler warnings fixes.
[u/mrichter/AliRoot.git] / FMD / AliFMDMap.h
CommitLineData
4347b38f 1#ifndef ALIFMDMAP_H
2#define ALIFMDMAP_H
3/* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights
4 * reserved.
5 *
6 * See cxx source for full Copyright notice
7 */
e802be3e 8#ifndef ROOT_TObject
9# include <TObject.h>
10#endif
11//____________________________________________________________________
12//
13// Base class for caches of per-strip information.
14//
15
16class AliFMDMap : public TObject
17{
18public:
19 enum {
20 kMaxDetectors = 3,
21 kMaxRings = 2,
c263f0ab 22 kMaxSectors = 40,
e802be3e 23 kMaxStrips = 512
24 };
25 AliFMDMap(size_t maxDet = kMaxDetectors,
26 size_t maxRing= kMaxRings,
27 size_t maxSec = kMaxSectors,
28 size_t maxStr = kMaxStrips);
29 virtual ~AliFMDMap() {}
baa92757 30 Int_t CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
e802be3e 31protected:
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
38};
39
40#ifdef MAY_USE_TEMPLATES
4347b38f 41#ifndef __VECTOR__
42# include <vector>
43#endif
e802be3e 44//____________________________________________________________________
45//
46// Class template for classes that cache per strip information.
47// Access to the data goes via
48//
49// Type& AliFMDMap<Type>::operator()(size_t detector,
50// Char_t ring,
51// size_t sector,
52// size_t strip);
53//
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()'.
57//
4347b38f 58template <typename Type>
59class AliFMDMap : public TObject
60{
42403906 61public:
62 AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40,
63 size_t maxStr=512);
64 virtual ~AliFMDMap() {}
e802be3e 65 void Clear(const Type& val=Type());
42403906 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;
4347b38f 68private:
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
75
76 size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
4347b38f 77 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
78};
79
80
81//____________________________________________________________________
82template <typename Type>
83inline
84AliFMDMap<Type>::AliFMDMap(size_t maxDet,
85 size_t maxRing,
86 size_t maxSec,
87 size_t maxStr)
88 : fValues(maxDet * maxRing * maxSec * maxStr),
89 fMaxDetectors(maxDet),
90 fMaxRings(maxRing),
91 fMaxSectors(maxSec),
92 fMaxStrips(maxStr)
93{
94 // Construct a map
95 //
96 // Parameters:
97 // maxDet Maximum # of detectors
98 // maxRinf Maximum # of rings
99 // maxSec Maximum # of sectors
100 // maxStr Maximum # of strips
101}
102
103
104//____________________________________________________________________
105template <typename Type>
106inline size_t
107AliFMDMap<Type>::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
108{
109 // Calculate index into storage from arguments.
110 //
111 // Parameters:
112 // det Detector #
113 // ring Ring ID
114 // sec Sector #
115 // str Strip #
116 //
117 // Returns appropriate index into storage
118 //
119 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
120 size_t idx =
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",
125 det, ring, sec, str,
126 (det >= fMaxDetectors ? "Detector" :
127 (ringi >= fMaxRings ? "Ring" :
128 (sec >= fMaxSectors ? "Sector" : "Strip"))));
129 return 0;
130 }
131 return idx;
132}
133
134//____________________________________________________________________
135template <typename Type>
136inline void
e802be3e 137AliFMDMap<Type>::Clear(const Type& val)
4347b38f 138{
139 // Resets stored values to the default value for that type
e802be3e 140 for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
4347b38f 141}
142
143//____________________________________________________________________
144template <typename Type>
145inline Type&
146AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)
147{
148 // Parameters:
149 // det Detector #
150 // ring Ring ID
151 // sec Sector #
152 // str Strip #
153 //
154 // Returns data[det][ring][sec][str]
155 return fValues[CalcIndex(det, ring, sec, str)];
156}
157
158//____________________________________________________________________
159template <typename Type>
160inline const Type&
e802be3e 161AliFMDMap<Type>::operator()(size_t det,
162 Char_t ring,
163 size_t sec,
164 size_t str) const
4347b38f 165{
166 // Parameters:
167 // det Detector #
168 // ring Ring ID
169 // sec Sector #
170 // str Strip #
171 //
172 // Returns data[det][ring][sec][str]
173 return fValues[CalcIndex(det, ring, sec, str)];
174}
175
176
e802be3e 177//____________________________________________________________________
178//
179// Some specialisations
180//
181typedef AliFMDMap<UShort_t> AliFMDAdcMap;
182typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
4347b38f 183
e802be3e 184#endif
4347b38f 185#endif
0d0e6995 186//____________________________________________________________________
187//
188// Local Variables:
189// mode: C++
190// End:
4347b38f 191//
192// EOF
193//
194
195