Adding calibration object for the sharing efficiency
[u/mrichter/AliRoot.git] / FMD / AliFMDAltroMapping.h
CommitLineData
57c3c593 1#ifndef ALIFMDALTROMAPPING_H
2#define ALIFMDALTROMAPPING_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
4 * reserved.
5 *
6 * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
7 *
8 * See cxx source for full Copyright notice
9 */
c2fc1258 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.
14*/
57c3c593 15#ifndef ALIALTROMAPPING_H
16# include <AliAltroMapping.h>
17#endif
02a27b50 18//
19// Map hardware address to detector coordinates.
20//
21// The hardware address consist of a DDL number and 12bits of ALTRO
22// addresses. The ALTRO address are formatted as follows.
23//
24// 12 7 4 0
25// |---------------|---------|------------|
26// | Board # | ALTRO # | Channel # |
27// +---------------+---------+------------+
28//
29//
9f662337 30//____________________________________________________________________
31/** @class AliFMDAltroMapping
32 @brief Class that encodes a map to/from ALTRO hardware address to
33 FMD detector coordinates.
34
35 The hardware address consist of a DDL number and 12bits of ALTRO
36 addresses. The ALTRO address are formatted as follows.
37 @verbatim
38 12 7 4 0
39 |---------------|---------|------------|
40 | Board # | ALTRO # | Channel # |
41 +---------------+---------+------------+
42 @endverbatim
43
44 @ingroup FMD_base
45 */
57c3c593 46class AliFMDAltroMapping : public AliAltroMapping
47{
48public:
9f662337 49 /** Constructor */
57c3c593 50 AliFMDAltroMapping();
02a27b50 51 /** Destructor */
52 virtual ~AliFMDAltroMapping() {}
b995fc28 53 /** Return detector number corresponding to given DDL number
54 @param ddl DDL number
55 @return Detector number */
7af3df7f 56 Short_t DDL2Detector(UInt_t ddl) const
57 {
58 return (ddl<=2 ? Short_t(ddl + 1) : -1);
59 }
b995fc28 60 /** Return the ring identifier corresponding to a board number
61 @param board Board number
62 @return Ring identifier */
63 Char_t Board2Ring(UShort_t board) const { return (board%2)?'O':'I'; }
64
65 /** Return the strip base number corresponding to a channel address
66 @param board Board number
67 @param altro Altro number
68 @param channel Channel number
69 @param ring On return, the ring ID
70 @param sec On return, the sector number
71 @param strip On return, the strip base offset
72 @return @c true on success */
73 Bool_t Channel2StripBase(UShort_t board, UShort_t altro,
74 UShort_t chan, Char_t& ring,
75 UShort_t& sec, Short_t& str) const;
76 /** Return the strip, sample corresponding to a timebin
77 @param sec Sector
78 @param timebin Time bin
79 @param preSamples Number of pre-samples
80 @param sampleRate Oversampling rate
81 @param strip On return, the strip number in this channel
82 @param sam On return, the sample number */
83 void Timebin2Strip(UShort_t sec, UShort_t timebin,
84 UShort_t preSamples, UShort_t sampleRate,
85 Short_t& strip, UShort_t& sample) const;
86
9f662337 87 /** Map a hardware address into a detector index.
408bf2b4 88 @param ddl Hardware DDL number
89 @param hwaddr Hardware address.
f38b1653 90 @param timebin Timebin
91 @param preSamples # of pre samples
92 @param sampleRate Over sampling rate
93 @param det On return, the detector #
94 @param ring On return, the ring ID
95 @param sec On return, the sector #
96 @param str On return, the base of strip #
97 @param sam On return, the sample number for this strip
98 @return @c true on success, false otherwise */
b995fc28 99 Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr,
f38b1653 100 UShort_t timebin, UShort_t preSamples,
101 UShort_t sampleRate,
102 UShort_t& det, Char_t& ring,
103 UShort_t& sec, Short_t& str,
104 UShort_t& sam) const;
f6449cc0 105 /** Map a hardware address into a detector index.
f38b1653 106 @param ddl Hardware DDL number
107 @param board FEC number
108 @param altro ALTRO number
109 @param channel Channel number
110 @param timebin Timebin
111 @param preSamples # of pre samples
112 @param sampleRate Over sampling rate
113 @param det On return, the detector #
114 @param ring On return, the ring ID
115 @param sec On return, the sector #
116 @param str On return, the base of strip #
117 @param sam On return, the sample number for this strip
118 @return @c true on success, false otherwise */
b995fc28 119 Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
120 UShort_t altro, UShort_t chan,
121 UShort_t timebin, UShort_t preSamples,
122 UShort_t sampleRate,
f38b1653 123 UShort_t& det, Char_t& ring,
124 UShort_t& sec, Short_t& str,
125 UShort_t& sam) const;
b995fc28 126
127
128
129 /** Return DDL number corresponding to given detector number
130 @param det Detector number
131 @return DDL number */
132 UShort_t Detector2DDL(UShort_t det) const { return det - 1; }
133 /** Return board address corresponding to a sector
134 @param ring Ring identifier
135 @param sec Sector number
136 @return The board number, or negative number in case of failure */
137 Short_t Sector2Board(Char_t ring, UShort_t sec) const;
138 /** Convert strip address to a channel address.
139 @param ring Ring identifier
140 @param sec Sector number
141 @param str Strip number
142 @param board On return, contains the board number
143 @param altro On return, contains the altro number
144 @param chan On return, contains the channel number
145 @return @c true on success. */
146 Bool_t Strip2Channel(Char_t ring, UShort_t sec,
147 UShort_t str, UShort_t& board,
148 UShort_t& altro, UShort_t& chan) const;
149 /** Get the timebin correspoding to a strip and sample
150 @param sec Sector number
151 @param str Strip number
152 @param sam Sample number
153 @param preSamples Number of pre-samples.
154 @param sampleRate The over-sampling rate
155 @return the timebin corresponding to the passed strip */
156 UShort_t Strip2Timebin(UShort_t sec, UShort_t strip,
157 UShort_t sam, UShort_t preSamples,
158 UShort_t sampleRate) const;
159
f6449cc0 160 /** Map a detector index into a hardware address.
408bf2b4 161 @param det The detector #
162 @param ring The ring ID
163 @param sec The sector #
164 @param str The strip #
f38b1653 165 @param sam The sample number
166 @param preSamples Number of pre-samples
167 @param sampleRate The oversampling rate
168 @param ddl On return, hardware DDL number
169 @param board On return, the FEC board address (local to DDL)
170 @param altro On return, the ALTRO number (local to FEC)
171 @param channel On return, the channel number (local to ALTRO)
172 @param timebin On return, the timebin number (local to ALTRO)
173 @return @c true on success, false otherwise */
174 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
175 UShort_t sec, UShort_t str,
176 UShort_t sam,
b995fc28 177 UShort_t preSamples, UShort_t sampleRate,
178 UShort_t& ddl, UShort_t& board,
179 UShort_t& altro, UShort_t& channel,
f38b1653 180 UShort_t& timebin) const;
181 /** Map a detector index into a hardware address.
f38b1653 182 @param det The detector #
183 @param ring The ring ID
184 @param sec The sector #
185 @param str The strip #
186 @param sam The sample number
187 @param preSamples Number of pre-samples
188 @param sampleRate The oversampling rate
189 @param ddl On return, hardware DDL number
190 @param hwaddr On return, hardware address.
191 @param timebin On return, the timebin number (local to ALTRO)
192 @return @c true on success, false otherwise */
193 Bool_t Detector2Hardware(UShort_t det, Char_t ring,
194 UShort_t sec, UShort_t str,
195 UShort_t sam,
b995fc28 196 UShort_t preSamples, UShort_t sampleRate,
197 UShort_t& ddl, UShort_t& hwaddr,
f38b1653 198 UShort_t& timebin) const;
b995fc28 199 /** Convert board, chip, channel to a hardware address
200 @param board Board number
201 @param altro Altro number
202 @param channel Channel number
203 @return hardware address of a channel */
204 UInt_t ChannelAddress(UShort_t board, UShort_t altro, UShort_t channel) const;
205 /** Convert a channel address to board, altro, channel fields
206 @param hwaddr Channel address
207 @param board On return, the Board number
208 @param altro On return, the Altro number
209 @param channel On return, the Channel number */
210 void ChannelAddress(UShort_t hwaddr, UShort_t& board, UShort_t& altro,
211 UShort_t& channel) const;
9f662337 212 /** convert a partial detector index into a hardware address
213 @param sector Sector number
214 @param str Strip number
215 @param ring Ring ID as an integer
216 @return Hardware address */
573322da 217 Int_t GetHWAddress(Int_t sector, Int_t str, Int_t ring);
9f662337 218 /** Get the pad-row (or sector) corresponding to hardware address
219 @param hwaddr hardware address
220 @return Sector number */
57c3c593 221 Int_t GetPadRow(Int_t hwaddr) const;
9f662337 222 /** Get the pad (or strip) corresponding to hardware address
223 @param hwaddr hardware address
224 @return Strip number */
57c3c593 225 Int_t GetPad(Int_t hwaddr) const;
9f662337 226 /** Get the sector (or ring) corresponding to hardware address
227 @param hwaddr hardware address
228 @return Ring ID as an integer */
57c3c593 229 Int_t GetSector(Int_t hwaddr) const;
f6449cc0 230 /** Print map to standard out
231 @param option Option string (hw, or det) */
232 void Print(Option_t* option="hw") const;
57c3c593 233protected:
9f662337 234 /** Read map from file - not used
235 @return @c true on success */
57c3c593 236 virtual Bool_t ReadMapping();
573322da 237 /** Create the inverse mapping arrays */
238 virtual Bool_t CreateInvMapping();
57c3c593 239
573322da 240 ClassDef(AliFMDAltroMapping, 2) // Read raw FMD Altro data
57c3c593 241};
242
243#endif
244//____________________________________________________________________
245//
246// Local Variables:
247// mode: C++
248// End:
249//
250// EOF
251//