1 #ifndef ALIFMDALTROMAPPING_H
2 #define ALIFMDALTROMAPPING_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
6 * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
8 * See cxx source for full Copyright notice
10 /** @file AliFMDAltroMapping.h
11 @author Christian Holm Christensen <cholm@nbi.dk>
12 @date Sun Mar 26 18:28:11 2006
13 @brief Map HW address to detector coordinates and back again.
15 #ifndef ALIALTROMAPPING_H
16 # include <AliAltroMapping.h>
19 // Map hardware address to detector coordinates.
21 // The hardware address consist of a DDL number and 12bits of ALTRO
22 // addresses. The ALTRO address are formatted as follows.
25 // |---------------|---------|------------|
26 // | Board # | ALTRO # | Channel # |
27 // +---------------+---------+------------+
30 //____________________________________________________________________
31 /** @class AliFMDAltroMapping
32 @brief Class that encodes a map to/from ALTRO hardware address to
33 FMD detector coordinates.
35 The hardware address consist of a DDL number and 12bits of ALTRO
36 addresses. The ALTRO address are formatted as follows.
39 |---------------|---------|------------|
40 | Board # | ALTRO # | Channel # |
41 +---------------+---------+------------+
46 class AliFMDAltroMapping : public AliAltroMapping
56 virtual ~AliFMDAltroMapping() {}
58 * Return detector number corresponding to given DDL number
60 * @param ddl DDL number
61 * @return Detector number
63 Short_t DDL2Detector(UInt_t ddl) const
65 return (ddl<=2 ? Short_t(ddl + 1) : -1);
68 * Return the ring identifier corresponding to a board number
70 * @param board Board number
71 * @return Ring identifier
73 Char_t Board2Ring(UShort_t board) const { return (board%2)?'O':'I'; }
76 * Return the strip base number corresponding to a channel address
78 * @param board Board number
79 * @param altro Altro number
80 * @param channel Channel number
81 * @param ring On return, the ring ID
82 * @param sec On return, the sector number
83 * @param strip On return, the strip base offset
84 * @return @c true on success
86 Bool_t Channel2StripBase(UShort_t board, UShort_t altro,
87 UShort_t chan, Char_t& ring,
88 UShort_t& sec, Short_t& str) const;
90 * Return the strip, sample corresponding to a timebin
93 * @param timebin Time bin
94 * @param preSamples Number of pre-samples
95 * @param sampleRate Oversampling rate
96 * @param strip On return, the strip number in this channel
97 * @param sam On return, the sample number
99 void Timebin2Strip(UShort_t sec, UShort_t timebin,
100 UShort_t preSamples, UShort_t sampleRate,
101 Short_t& strip, UShort_t& sample) const;
104 * Map a hardware address into a detector index.
106 * @param ddl Hardware DDL number
107 * @param hwaddr Hardware address.
108 * @param timebin Timebin
109 * @param preSamples # of pre samples
110 * @param sampleRate Over sampling rate
111 * @param det On return, the detector #
112 * @param ring On return, the ring ID
113 * @param sec On return, the sector #
114 * @param str On return, the base of strip #
115 * @param sam On return, the sample number for this strip
116 * @return @c true on success, false otherwise
118 Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr,
119 UShort_t timebin, UShort_t preSamples,
121 UShort_t& det, Char_t& ring,
122 UShort_t& sec, Short_t& str,
123 UShort_t& sam) const;
125 * Map a hardware address into a detector index.
127 * @param ddl Hardware DDL number
128 * @param board FEC number
129 * @param altro ALTRO number
130 * @param channel Channel number
131 * @param timebin Timebin
132 * @param preSamples # of pre samples
133 * @param sampleRate Over sampling rate
134 * @param det On return, the detector #
135 * @param ring On return, the ring ID
136 * @param sec On return, the sector #
137 * @param str On return, the base of strip #
138 * @param sam On return, the sample number for this strip
139 * @return @c true on success, false otherwise
141 Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
142 UShort_t altro, UShort_t chan,
143 UShort_t timebin, UShort_t preSamples,
145 UShort_t& det, Char_t& ring,
146 UShort_t& sec, Short_t& str,
147 UShort_t& sam) const;
152 * Return DDL number corresponding to given detector number
154 * @param det Detector number
157 UShort_t Detector2DDL(UShort_t det) const { return det - 1; }
159 * Return board address corresponding to a sector
161 * @param ring Ring identifier
162 * @param sec Sector number
163 * @return The board number, or negative number in case of failure
165 Short_t Sector2Board(Char_t ring, UShort_t sec) const;
167 * Convert strip address to a channel address.
169 * @param ring Ring identifier
170 * @param sec Sector number
171 * @param str Strip number
172 * @param board On return, contains the board number
173 * @param altro On return, contains the altro number
174 * @param chan On return, contains the channel number
175 * @return @c true on success.
177 Bool_t Strip2Channel(Char_t ring, UShort_t sec,
178 UShort_t str, UShort_t& board,
179 UShort_t& altro, UShort_t& chan) const;
181 * Get the timebin correspoding to a strip and sample
183 * @param sec Sector number
184 * @param str Strip number
185 * @param sam Sample number
186 * @param preSamples Number of pre-samples.
187 * @param sampleRate The over-sampling rate
188 * @return the timebin corresponding to the passed strip
190 UShort_t Strip2Timebin(UShort_t sec, UShort_t strip,
191 UShort_t sam, UShort_t preSamples,
192 UShort_t sampleRate) const;
195 * Map a detector index into a hardware address.
197 * @param det The detector #
198 * @param ring The ring ID
199 * @param sec The sector #
200 * @param str The strip #
201 * @param sam The sample number
202 * @param preSamples Number of pre-samples
203 * @param sampleRate The oversampling rate
204 * @param ddl On return, hardware DDL number
205 * @param board On return, the FEC board address (local to DDL)
206 * @param altro On return, the ALTRO number (local to FEC)
207 * @param channel On return, the channel number (local to ALTRO)
208 * @param timebin On return, the timebin number (local to ALTRO)
209 * @return @c true on success, false otherwise
211 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
212 UShort_t sec, UShort_t str,
214 UShort_t preSamples, UShort_t sampleRate,
215 UShort_t& ddl, UShort_t& board,
216 UShort_t& altro, UShort_t& channel,
217 UShort_t& timebin) const;
219 * Map a detector index into a hardware address.
221 * @param det The detector #
222 * @param ring The ring ID
223 * @param sec The sector #
224 * @param str The strip #
225 * @param sam The sample number
226 * @param preSamples Number of pre-samples
227 * @param sampleRate The oversampling rate
228 * @param ddl On return, hardware DDL number
229 * @param hwaddr On return, hardware address.
230 * @param timebin On return, the timebin number (local to ALTRO)
231 * @return @c true on success, false otherwise
233 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
234 UShort_t sec, UShort_t str,
236 UShort_t preSamples, UShort_t sampleRate,
237 UShort_t& ddl, UShort_t& hwaddr,
238 UShort_t& timebin) const;
240 * Convert board, chip, channel to a hardware address
242 * @param board Board number
243 * @param altro Altro number
244 * @param channel Channel number
245 * @return hardware address of a channel
247 UInt_t ChannelAddress(UShort_t board, UShort_t altro, UShort_t channel) const;
249 * Convert a channel address to board, altro, channel fields
251 * @param hwaddr Channel address
252 * @param board On return, the Board number
253 * @param altro On return, the Altro number
254 * @param channel On return, the Channel number
256 void ChannelAddress(UShort_t hwaddr, UShort_t& board, UShort_t& altro,
257 UShort_t& channel) const;
259 * convert a partial detector index into a hardware address
261 * @param sector Sector number
262 * @param str Strip number
263 * @param ring Ring ID as an integer
264 * @return Hardware address
266 Int_t GetHWAddress(Int_t sector, Int_t str, Int_t ring);
268 * Get the pad-row (or sector) corresponding to hardware address
270 * @param hwaddr hardware address
271 * @return Sector number
273 Int_t GetPadRow(Int_t hwaddr) const;
275 * Get the pad (or strip) corresponding to hardware address
277 * @param hwaddr hardware address
278 * @return Strip number
280 Int_t GetPad(Int_t hwaddr) const;
282 * Get the sector (or ring) corresponding to hardware address
284 * @param hwaddr hardware address
285 * @return Ring ID as an integer
287 Int_t GetSector(Int_t hwaddr) const;
289 * Print map to standard out
291 * @param option Option string (hw, or det)
293 void Print(Option_t* option="hw") const;
296 * Read map from file - not used
298 * @return @c true on success
300 virtual Bool_t ReadMapping();
302 * Create the inverse mapping arrays
304 virtual Bool_t CreateInvMapping();
306 ClassDef(AliFMDAltroMapping, 2) // Read raw FMD Altro data
310 //____________________________________________________________________