Default calibration (A.Colla)
[u/mrichter/AliRoot.git] / PMD / AliPMDRawStream.cxx
CommitLineData
a09a2da4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19///
20/// This class provides access to PMD digits in raw data.
21///
22/// It loops over all PMD digits in the raw data given by the AliRawReader.
23/// The Next method goes to the next digit. If there are no digits left
24/// it returns kFALSE.
25/// Several getters provide information about the current digit.
26///
27///////////////////////////////////////////////////////////////////////////////
28
ecee2a1a 29#include "AliLog.h"
a09a2da4 30#include "AliPMDRawStream.h"
31#include "AliRawReader.h"
32
33ClassImp(AliPMDRawStream)
34
35
36//_____________________________________________________________________________
37AliPMDRawStream::AliPMDRawStream(AliRawReader* rawReader) :
38 fRawReader(rawReader),
39 fModule(-1),
40 fPrevModule(-1),
41 fMCM(-1),
42 fChannel(-1),
43 fRow(-1),
44 fColumn(-1),
45 fSignal(-1),
46 fDetector(-1),
47 fSMN(-1)
48{
49// create an object to read PMD raw digits
50
51 fRawReader->Select(12);
52}
53
54//_____________________________________________________________________________
55AliPMDRawStream::AliPMDRawStream(const AliPMDRawStream& stream) :
56 TObject(stream),
57 fRawReader(NULL),
58 fModule(-1),
59 fPrevModule(-1),
60 fMCM(-1),
61 fChannel(-1),
62 fRow(-1),
63 fColumn(-1),
64 fSignal(-1),
65 fDetector(-1),
66 fSMN(-1)
67{
68// copy constructor
69
ecee2a1a 70 AliFatal("Copy constructor not implemented");
a09a2da4 71}
72
73//_____________________________________________________________________________
74AliPMDRawStream& AliPMDRawStream::operator = (const AliPMDRawStream&
75 /* stream */)
76{
77// assignment operator
78
ecee2a1a 79 AliFatal("operator = assignment operator not implemented");
a09a2da4 80 return *this;
81}
82
83//_____________________________________________________________________________
84AliPMDRawStream::~AliPMDRawStream()
85{
86// destructor
87
88}
89
90
91//_____________________________________________________________________________
92Bool_t AliPMDRawStream::Next()
93{
94// read the next raw digit
95// returns kFALSE if there is no digit left
96
97 fPrevModule = fModule;
98
99 UInt_t data;
100 if (!fRawReader->ReadNextInt(data)) return kFALSE;
101
102 fSignal = data & 0x0FFF;
103 fChannel = (data >> 12) & 0x003F;
104 fMCM = (data >> 18) & 0x07FF;
105
106 Int_t iddl = fRawReader->GetDDLID();
107 Int_t ium;
a09a2da4 108
e54787da 109 GetRowCol(iddl, fMCM, fChannel, ium, fRow, fColumn);
110 ConvertDDL2SMN(iddl, ium, fSMN, fModule, fDetector);
111 TransformH2S(fSMN, fRow, fColumn);
a09a2da4 112
113 return kTRUE;
114}
a09a2da4 115//_____________________________________________________________________________
116void AliPMDRawStream::GetRowCol(Int_t ddlno, UInt_t mcmno, UInt_t chno,
117 Int_t &um, Int_t &row, Int_t &col) const
118{
119// decode: ddlno, mcmno, chno -> um, row, col
120
121
122 Int_t remmcm = 0;
123 Int_t divmcm = 0;
124
125 static const UInt_t kCh[64] = { 21, 25, 29, 28, 17, 24, 20, 16,
126 12, 13, 8, 4, 0, 1, 9, 5,
127 10, 6, 2, 3, 14, 7, 11, 15,
128 19, 18, 23, 27, 31, 30, 22, 26,
129 53, 57, 61, 60, 49, 56, 52, 48,
130 44, 45, 40, 36, 32, 33, 41, 37,
131 42, 38, 34, 35, 46, 39, 43, 47,
132 51, 50, 55, 59, 63, 62, 54, 58 };
133
134 if (ddlno == 0 || ddlno == 1)
135 {
136 um = mcmno/72;
137 Int_t mcmnonew = mcmno - 72*um;
138 Int_t rowcol = kCh[chno];
139 Int_t irownew = rowcol/4;
140 Int_t icolnew = rowcol%4;
141
142 remmcm = mcmnonew%12;
143 divmcm = mcmnonew/12;
144
145 row = 16*divmcm + irownew;
146 col = 4*remmcm + icolnew;
147 // This obtatined row and col (0,0) are the top left corner.
148 // Needs transformation to get the Geant (0,0)
149
150 }
151 else if (ddlno == 2 || ddlno == 3)
152 {
153 um = mcmno/72;
154 Int_t mcmnonew = mcmno - 72*um;
155 Int_t rowcol = kCh[chno];
156 Int_t irownew = rowcol/4;
157 Int_t icolnew = rowcol%4;
158
159 remmcm = mcmnonew%24;
160 divmcm = mcmnonew/24;
161
162 row = 16*divmcm + irownew;
163 col = 4*remmcm + icolnew;
164 // This obtatined row and col (0,0) are the top left corner.
165 // Needs transformation to get the Geant (0,0)
166
167 }
168 else if (ddlno == 4 || ddlno == 5)
169 {
170 um = mcmno/72;
171 Int_t mcmnonew = mcmno - 72*um;
172 Int_t rowcol = kCh[chno];
173 Int_t irownew = rowcol/4;
174 Int_t icolnew = rowcol%4;
175
176 if (um < 6)
177 {
178 remmcm = mcmnonew%12;
179 divmcm = mcmnonew/12;
180 }
181 else if (um >= 6)
182 {
183 remmcm = mcmnonew%24;
184 divmcm = mcmnonew/24;
185 }
186
187 row = 16*divmcm + irownew;
188 col = 4*remmcm + icolnew;
189 // This obtatined row and col (0,0) are the top left corner.
190 // Needs transformation to get the Geant (0,0)
191
192 }
193
194}
e54787da 195//_____________________________________________________________________________
196void AliPMDRawStream::ConvertDDL2SMN(Int_t iddl, Int_t ium, Int_t &smn,
197 Int_t &module, Int_t &detector) const
198{
199 // This converts the DDL number to Module Number which runs from 0-47
200 // Serial module number in one detector which runs from 0-23
201 // Also gives the detector number (0:PRE plane, 1:CPV plane)
202 if (iddl < 4)
203 {
204 module = iddl*6 + ium;
205 detector = 0;
206 smn = iddl*6 + ium;
207 }
208 else if (iddl == 4)
209 {
210 if (ium < 6)
211 {
212 module = 24 + ium;
213 smn = ium;
214 }
215 else if (ium >= 6)
216 {
217 module = 30 + ium;
218 smn = 6 + ium;
219 }
220 detector = 1;
221 }
222 else if (iddl == 5)
223 {
224
225 if (ium < 6)
226 {
227 module = 30 + ium;
228 smn = 6 + ium;
229 }
230 else if (ium >= 6)
231 {
232 module = 36 + ium;
233 smn = 12 + ium;
234 }
235 detector = 1;
236 }
237}
238//_____________________________________________________________________________
239void AliPMDRawStream::TransformH2S(Int_t smn, Int_t &row, Int_t &col) const
240{
241 // Transform the Hardware (0,0) coordinate to Software (0,0) coordinate
242 // and also writes in the digit form
243 // i.e., For SuperModule 1 &2, instead of 96x48 it is 48x96
244 // For Supermodule 3 & 4, 48x96
245
246 Int_t irownew1 = 0;
247 Int_t icolnew1 = 0;
248 Int_t irownew = 0;
249 Int_t icolnew = 0;
250 // Transform all the (0,0) coordinates to the geant frame
251 if(smn < 6)
252 {
253 irownew1 = 95 - row;
254 icolnew1 = col;
255 }
256 else if(smn >= 6 && smn < 12)
257 {
258 irownew1 = row;
259 icolnew1 = 47 - col;
260 }
261 else if(smn >= 12 && smn < 18)
262 {
263 irownew1 = 47 - row;
264 icolnew1 = col;
265 }
266 else if(smn >= 18 && smn < 24)
267 {
268 irownew1 = row;
269 icolnew1 = 95 - col;
270 }
271
272 // for smn < 12 : row = 96, column = 48
273 // for smn>= 12 and < 24 : row = 48, column = 96
274 // In order to make it uniform dimension, smn < 12 are inverted
275 // i.e., row becomes column and column becomes row
276 // for others it remains same
277 // This is further inverted back while calculating eta and phi
278 if(smn < 12)
279 {
280 // SupeModule 1 and 2 : Rows are inverted to columns and vice versa
281 // and at the time of calculating the eta,phi it is again reverted
282 // back
283 irownew = icolnew1;
284 icolnew = irownew1;
285 }
286 else if( smn >= 12 && smn < 24)
287 {
288 irownew = irownew1;
289 icolnew = icolnew1;
290 }
291
292 row = irownew;
293 col = icolnew;
294}
295//_____________________________________________________________________________