]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliFMDMap.h
From Ludovic: new files for visualization of V0s.
[u/mrichter/AliRoot.git] / STEER / AliFMDMap.h
CommitLineData
9da38871 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 */
8#ifndef ROOT_TObject
9# include <TObject.h>
10#endif
11//____________________________________________________________________
12//
13// Base class for caches of per-strip information.
14// This is used to index a strip.
15// Data stored depends on derived class.
16//
17class AliFMDMap : public TObject
18{
19public:
20 enum {
21 kMaxDetectors = 3,
22 kMaxRings = 2,
23 kMaxSectors = 40,
24 kMaxStrips = 512
25 };
9eeb02aa 26 AliFMDMap(UShort_t maxDet = kMaxDetectors,
27 UShort_t maxRing= kMaxRings,
28 UShort_t maxSec = kMaxSectors,
29 UShort_t maxStr = kMaxStrips);
9da38871 30 virtual ~AliFMDMap() {}
9eeb02aa 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;
9da38871 37protected:
5664d15a 38 Int_t CalcIndex(UShort_t det, Char_t ring,
39 UShort_t sec, UShort_t str) const;
9eeb02aa 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
9da38871 45};
46
47#ifdef MAY_USE_TEMPLATES
48#ifndef __VECTOR__
49# include <vector>
50#endif
51//____________________________________________________________________
52//
53// Class template for classes that cache per strip information.
54// Access to the data goes via
55//
9eeb02aa 56// Type& AliFMDMap<Type>::operator()(UShort_t detector,
9da38871 57// Char_t ring,
9eeb02aa 58// UShort_t sector,
59// UShort_t strip);
9da38871 60//
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()'.
64//
65template <typename Type>
66class AliFMDMap : public TObject
67{
68public:
9eeb02aa 69 AliFMDMap(UShort_t maxDet=3, UShort_t maxRing=2, UShort_t maxSec=40,
70 UShort_t maxStr=512);
9da38871 71 virtual ~AliFMDMap() {}
72 void Clear(const Type& val=Type());
9eeb02aa 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;
9da38871 76private:
77 typedef std::vector<Type> ValueVector; // Type of container
78 ValueVector fValues; // Contained values
9eeb02aa 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
9da38871 83
9eeb02aa 84 UShort_t CalcIndex(UShort_t det, Char_t ring,
85 UShort_t sec, UShort_t str) const;
9da38871 86 ClassDef(AliFMDMap, 0); // Map of FMD index's to values
87};
88
89
90//____________________________________________________________________
91template <typename Type>
92inline
9eeb02aa 93AliFMDMap<Type>::AliFMDMap(UShort_t maxDet,
94 UShort_t maxRing,
95 UShort_t maxSec,
96 UShort_t maxStr)
9da38871 97 : fValues(maxDet * maxRing * maxSec * maxStr),
98 fMaxDetectors(maxDet),
99 fMaxRings(maxRing),
100 fMaxSectors(maxSec),
101 fMaxStrips(maxStr)
102{
103 // Construct a map
104 //
105 // Parameters:
106 // maxDet Maximum # of detectors
107 // maxRinf Maximum # of rings
108 // maxSec Maximum # of sectors
109 // maxStr Maximum # of strips
110}
111
112
113//____________________________________________________________________
114template <typename Type>
9eeb02aa 115inline UShort_t
116AliFMDMap<Type>::CalcIndex(UShort_t det, Char_t ring,
117 UShort_t sec, UShort_t str) const
9da38871 118{
119 // Calculate index into storage from arguments.
120 //
121 // Parameters:
122 // det Detector #
123 // ring Ring ID
124 // sec Sector #
125 // str Strip #
126 //
127 // Returns appropriate index into storage
128 //
9eeb02aa 129 UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
130 UShort_t idx =
9da38871 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",
135 det, ring, sec, str,
136 (det >= fMaxDetectors ? "Detector" :
137 (ringi >= fMaxRings ? "Ring" :
138 (sec >= fMaxSectors ? "Sector" : "Strip"))));
139 return 0;
140 }
141 return idx;
142}
143
144//____________________________________________________________________
145template <typename Type>
146inline void
147AliFMDMap<Type>::Clear(const Type& val)
148{
149 // Resets stored values to the default value for that type
9eeb02aa 150 for (UShort_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
9da38871 151}
152
153//____________________________________________________________________
154template <typename Type>
155inline Type&
9eeb02aa 156AliFMDMap<Type>::operator()(UShort_t det, Char_t ring,
157 UShort_t sec, UShort_t str)
9da38871 158{
159 // Parameters:
160 // det Detector #
161 // ring Ring ID
162 // sec Sector #
163 // str Strip #
164 //
165 // Returns data[det][ring][sec][str]
166 return fValues[CalcIndex(det, ring, sec, str)];
167}
168
169//____________________________________________________________________
170template <typename Type>
171inline const Type&
9eeb02aa 172AliFMDMap<Type>::operator()(UShort_t det,
9da38871 173 Char_t ring,
9eeb02aa 174 UShort_t sec,
175 UShort_t str) const
9da38871 176{
177 // Parameters:
178 // det Detector #
179 // ring Ring ID
180 // sec Sector #
181 // str Strip #
182 //
183 // Returns data[det][ring][sec][str]
184 return fValues[CalcIndex(det, ring, sec, str)];
185}
186
187
188//____________________________________________________________________
189//
190// Some specialisations
191//
192typedef AliFMDMap<UShort_t> AliFMDAdcMap;
193typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
194
195#endif
196#endif
197//____________________________________________________________________
198//
199// Local Variables:
200// mode: C++
201// End:
202//
203// EOF
204//
205
206