Line data Source code
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 : /// \class AliTPCmapper
17 : /// \brief AliTPCmapper
18 : ///
19 : /// Class to map detector coordinates (row, pad, sector, ...) to
20 : /// hardware coordinates (RCU, Branch, FEC, Altro, channel, Equipment ID, ...)
21 : ///
22 : /// There are two different ways to number padrows:
23 : /// 1) local padrow: for each ROC, 0 ... 62 for an IROC, 0 ... 95 for an OROC,
24 : /// 2) global padrow: for each sector, from 0 ... 158.
25 : /// If the global numbering is used, it is denoted by the variable name
26 : /// globalpadrow in this class.
27 : ///
28 : /// There are two different ways to number sectors:
29 : /// 1) Sectors contain one IROC and one OROC and are counted from 0 to 17 on
30 : /// each of the two sides (A=0 and C=1),
31 : /// 2) ROCs are numbered from 0 to 71 where the ROCs 0 ... 35 are IROCS and
32 : /// ROCs 36 ... 71 are OROCs. A ROC is often named "sector" in aliroot,
33 : /// which can be very confusing!
34 : ///
35 : /// \author Christian.Lippmann@cern.ch, J.Wiechula@gsi.de
36 :
37 : #include <TMath.h>
38 : #include <TSystem.h>
39 : #include <TString.h>
40 :
41 : #include "AliTPCmapper.h"
42 : #include "AliTPCAltroMapping.h"
43 : #include "AliTPCROC.h"
44 : #include "AliLog.h"
45 : #include "AliDAQ.h"
46 :
47 : /// \cond CLASSIMP
48 24 : ClassImp(AliTPCmapper)
49 : /// \endcond
50 : //______________________________________________________________
51 0 : AliTPCmapper::AliTPCmapper() :
52 0 : fNside(0),
53 0 : fNsector(0),
54 0 : fNrcu(0),
55 0 : fNbranch(0),
56 0 : fNaltro(0),
57 0 : fNchannel(0),
58 0 : fNpadrow(0),
59 0 : fNpadrowIROC(0),
60 0 : fNpadrowOROC(0),
61 0 : fTpcDdlOffset(0)
62 0 : {
63 : //
64 : // Constructor
65 : //
66 0 : for ( Int_t i = 0; i < 6; i++ ) fMapping[i]=0;
67 0 : }
68 :
69 : //______________________________________________________________
70 6 : AliTPCmapper::AliTPCmapper(const char * dirname) :
71 6 : fNside(0),
72 6 : fNsector(0),
73 6 : fNrcu(0),
74 6 : fNbranch(0),
75 6 : fNaltro(0),
76 6 : fNchannel(0),
77 6 : fNpadrow(0),
78 6 : fNpadrowIROC(0),
79 6 : fNpadrowOROC(0),
80 6 : fTpcDdlOffset(0)
81 30 : {
82 : /// Constructor
83 : ///
84 : /// dirname - specify the directory with the ascii Altro mapping files
85 :
86 6 : Init(dirname);
87 12 : }
88 :
89 : //______________________________________________________________
90 : AliTPCmapper::~AliTPCmapper()
91 12 : {
92 : /// Destructor
93 :
94 42 : for ( Int_t i = 0; i < fNrcu; i++ ) {
95 36 : delete fMapping[i];
96 18 : fMapping[i] = 0;
97 : }
98 6 : }
99 :
100 :
101 : //_____________________________________________________________________________
102 : AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
103 0 : TObject(mapper),
104 0 : fNside(mapper.fNside),
105 0 : fNsector(mapper.fNsector),
106 0 : fNrcu(mapper.fNrcu),
107 0 : fNbranch(mapper.fNbranch),
108 0 : fNaltro(mapper.fNaltro),
109 0 : fNchannel(mapper.fNchannel),
110 0 : fNpadrow(mapper.fNpadrow),
111 0 : fNpadrowIROC(mapper.fNpadrowIROC),
112 0 : fNpadrowOROC(mapper.fNpadrowOROC),
113 0 : fTpcDdlOffset(mapper.fTpcDdlOffset)
114 0 : {
115 : /// Copy Constructor
116 :
117 0 : for ( Int_t i = 0; i < 6; i++ ) fMapping[i]=0;
118 0 : for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
119 0 : }
120 :
121 : //_____________________________________________________________________________
122 : AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
123 : {
124 : /// Assignment operator
125 :
126 0 : if(&mapper == this) return *this;
127 0 : ((TObject *)this)->operator=(mapper);
128 :
129 0 : for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
130 :
131 0 : fNside = mapper.fNside;
132 0 : fNsector = mapper.fNsector;
133 0 : fNrcu = mapper.fNrcu;
134 0 : fNbranch = mapper.fNbranch;
135 0 : fNaltro = mapper.fNaltro;
136 0 : fNchannel = mapper.fNchannel;
137 0 : fNpadrow = mapper.fNpadrow;
138 0 : fNpadrowIROC = mapper.fNpadrowIROC;
139 0 : fNpadrowOROC = mapper.fNpadrowOROC;
140 0 : fTpcDdlOffset = mapper.fTpcDdlOffset;
141 :
142 0 : return *this;
143 0 : }
144 :
145 : //______________________________________________________________
146 : void AliTPCmapper::Init(const char *dirname)
147 : {
148 : /// Initialize all
149 :
150 12 : fNside = 2;
151 6 : fNsector = 18;
152 6 : fNrcu = 6;
153 6 : fNbranch = 2;
154 6 : fNaltro = 8;
155 6 : fNchannel = 16;
156 :
157 : // Load and read mapping files. AliTPCAltroMapping contains the mapping for
158 : // each patch (rcu).
159 6 : TString path;
160 6 : if (dirname==0){
161 6 : path =gSystem->Getenv("ALICE_ROOT");
162 3 : path += "/TPC/mapping/Patch";
163 : }else{
164 3 : path = dirname;
165 3 : path +="Patch";
166 : }
167 :
168 6 : TString path2;
169 84 : for(Int_t i = 0; i < fNrcu; i++) {
170 36 : path2 = path;
171 36 : path2 += i;
172 36 : path2 += ".data";
173 144 : fMapping[i] = new AliTPCAltroMapping(path2.Data());
174 : }
175 :
176 : // Get instance of AliTPCROC object
177 6 : AliTPCROC *fROC = AliTPCROC::Instance();
178 6 : fNpadrowIROC = fROC->GetNRows(0);
179 6 : fNpadrowOROC = fROC->GetNRows(36);
180 6 : fNpadrow = fNpadrowIROC+fNpadrowOROC;
181 :
182 6 : AliDAQ daq;
183 12 : fTpcDdlOffset = daq.DdlIDOffset("TPC");
184 :
185 6 : }
186 :
187 :
188 : //_____________________________________________________________________________
189 : Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
190 : {
191 : /// Get the hardware address from pad coordinates for a given ROC
192 :
193 0 : Int_t patch = GetPatch(roc, padrow, pad);
194 0 : if ( (patch >= fNrcu) || (patch < 0) ) return -1;
195 0 : return fMapping[patch]->GetHWAddress(padrow, pad, roc);
196 0 : }
197 :
198 :
199 : //_____________________________________________________________________________
200 : Int_t AliTPCmapper::GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
201 : {
202 : /// Get the hardware address from pad coordinates
203 :
204 : Int_t patch = 0;
205 : Int_t hwAddress=-1;
206 0 : if ( globalpadrow < fNpadrowIROC ) {
207 0 : patch = GetPatch(0, globalpadrow, pad);
208 0 : if (patch>-1)
209 0 : hwAddress = fMapping[patch]->GetHWAddress(globalpadrow, pad, 0);
210 0 : } else if ( globalpadrow < fNpadrow ) {
211 0 : patch = GetPatch(36, globalpadrow - fNpadrowIROC, pad);
212 0 : if (patch>-1)
213 0 : hwAddress = fMapping[patch]->GetHWAddress(globalpadrow - fNpadrowIROC, pad, 36);
214 : } else {
215 0 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
216 : hwAddress = -1;
217 : }
218 0 : return hwAddress;
219 : }
220 :
221 :
222 : //_____________________________________________________________________________
223 : Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
224 : {
225 : /// Get the patch (rcu) index from the pad coordinates. The Roc index is
226 : /// needed as well to determine if it is IROC or OROC.
227 :
228 0 : return GetPatch(roc, padrow, pad);
229 : }
230 :
231 :
232 : //_____________________________________________________________________________
233 : Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
234 : {
235 : /// Get the patch (rcu) index from the pad coordinates. The Roc index is
236 : /// needed as well to determine if it is IROC or OROC.
237 :
238 3345408 : if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
239 0 : AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
240 0 : return -1;
241 : }
242 :
243 1672704 : if ( roc < 36 ) {
244 : // IROC (ROCs 0 ... 35)
245 594432 : Int_t padsInRow = GetNpads(padrow);
246 1188864 : if ( (padsInRow < 0) || (pad >= padsInRow) ) {
247 0 : AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
248 0 : return -1;
249 : }
250 841968 : if ( padrow < 30 ) { return 0;
251 346896 : } else if ( padrow == 30 ) { // padrow 30 is shared between rcus 0 and 1
252 17280 : if ( (pad < 37) || (pad > 48) ) return 1;
253 1296 : else return 0;
254 675216 : } else if ( padrow < fNpadrowIROC ) { return 1;
255 : } else {
256 0 : AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
257 0 : return -1;
258 : }
259 1078272 : } else if ( roc < 72 ) {
260 : // OROC (ROCs 36 ... 71)
261 1078272 : Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
262 2156544 : if ( (padsInRow < 0) || (pad >= padsInRow) ) {
263 0 : AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
264 0 : return -1;
265 : }
266 1317816 : if ( padrow < 27 ) { return 2;
267 838728 : } else if ( padrow == 27 ) { // padrow 27 is shared between rcus 2 and 3
268 10152 : if ( (pad >= 43) && (pad <= 46) ) return 3;
269 9288 : else return 2;
270 1105056 : } else if ( padrow < 54 ) { return 3;
271 822312 : } else if ( padrow < 76 ) { return 4;
272 283608 : } else if ( padrow == 76) { // padrow 76 is shared between rcus 4 and 5
273 19224 : if ( (pad >= 33) && (pad <= 88) ) return 5;
274 7128 : else return 4;
275 540864 : } else if ( padrow < fNpadrowOROC ) { return 5;
276 : } else {
277 0 : AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
278 0 : return -1;
279 : }
280 : }
281 0 : return -1;
282 1672704 : }
283 :
284 :
285 : //_____________________________________________________________________________
286 : Int_t AliTPCmapper::GetRcuSector(Int_t globalpadrow, Int_t pad) const
287 : {
288 : /// Get the patch (rcu) index from the pad coordinates for a sector
289 :
290 0 : return GetPatchSector(globalpadrow, pad);
291 : }
292 :
293 :
294 : //_____________________________________________________________________________
295 : Int_t AliTPCmapper::GetPatchSector(Int_t globalpadrow, Int_t pad) const
296 : {
297 : /// Get the patch (rcu) index from the pad coordinates for a sector
298 :
299 0 : if ( globalpadrow >= fNpadrow ) {
300 0 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
301 0 : return -1;
302 : }
303 0 : if ( globalpadrow < fNpadrowIROC ) return GetPatch(0, globalpadrow, pad);
304 0 : else return GetPatch(36, globalpadrow-fNpadrowIROC, pad);
305 0 : }
306 :
307 :
308 : //_____________________________________________________________________________
309 : Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
310 : {
311 : /// Get Pad Row (for a ROC) from the hardware address
312 :
313 0 : if ( (patch >= fNrcu) || (patch < 0) ) {
314 0 : AliWarning(Form("Patch index outside range (patch %d) !", patch));
315 0 : return -1;
316 : }
317 0 : return fMapping[patch]->GetPadRow(hwAddress);
318 0 : }
319 :
320 :
321 : //_____________________________________________________________________________
322 : Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
323 : {
324 : /// Get Pad Row (for full sector) from the hardware address
325 :
326 0 : if ( patch < 2 ) return GetPadRow(patch, hwAddress);
327 0 : else return GetPadRow(patch, hwAddress) + fNpadrowIROC;
328 0 : }
329 :
330 :
331 : //_____________________________________________________________________________
332 : Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
333 : {
334 : /// Get Pad index from the hardware address
335 :
336 0 : if ( (patch >= fNrcu) || (patch < 0) ) {
337 0 : AliWarning(Form("Patch index outside range (patch %d) !", patch));
338 0 : return -1;
339 : }
340 0 : return fMapping[patch]->GetPad(hwAddress);
341 0 : }
342 :
343 :
344 : //_____________________________________________________________________________
345 : Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
346 : Int_t channel) const
347 : {
348 : /// Get pad row (for a ROC) from hardware coordinates
349 :
350 0 : if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
351 0 : || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
352 0 : AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
353 : patch, branch, fec, chip, channel));
354 0 : return -1;
355 : }
356 0 : return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
357 0 : }
358 :
359 :
360 : //_____________________________________________________________________________
361 : Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
362 : Int_t channel) const
363 : {
364 : /// Get Pad Row (for full sector) from the hardware address
365 :
366 0 : if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
367 0 : || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
368 0 : AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
369 : patch, branch, fec, chip, channel));
370 0 : return -1;
371 : }
372 0 : if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
373 0 : else return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
374 0 : }
375 :
376 :
377 : //_____________________________________________________________________________
378 : Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
379 : {
380 : /// Get pad from hardware coordinates
381 :
382 0 : if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
383 0 : || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
384 0 : AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
385 : patch, branch, fec, chip, channel));
386 0 : return -1;
387 : }
388 0 : return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
389 0 : }
390 :
391 :
392 : //_____________________________________________________________________________
393 : Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
394 : {
395 : /// Get the branch to which this pad is connected. The FECs connected to
396 : /// one RCU are divided into two branches: A(=0) and B(=1). This information
397 : /// can be extracted from the hardware address.
398 :
399 0 : return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
400 : }
401 :
402 :
403 : //_____________________________________________________________________________
404 : Int_t AliTPCmapper::GetBranchSector(Int_t globalpadrow, Int_t pad) const
405 : {
406 : /// Get Branch from pad coordinates, where globalpadrow is counted
407 : /// for a full sector (0 ... 158)
408 :
409 0 : return DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
410 : }
411 :
412 :
413 : //_____________________________________________________________________________
414 : Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
415 : {
416 : /// Get the FEC number in hardware numbering. The FECs are numbered from 0 (in the
417 : /// center of the partition) to 8 (partition 3, 4, 5), 9 (partition 0, 2), 11
418 : /// (partition 1, branch A) or 12 (partition 1, branch B). This information
419 : /// can be extracted from the hardware address.
420 :
421 0 : return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
422 : }
423 :
424 :
425 : //_____________________________________________________________________________
426 : Int_t AliTPCmapper::GetFEChwSector(Int_t globalpadrow, Int_t pad) const
427 : {
428 : /// Get the FEC number in hardware numbering from pad coordinates, where
429 : /// globalpadrow is counted for a full sector (0 ... 158)
430 :
431 0 : return DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
432 : }
433 :
434 :
435 : //_____________________________________________________________________________
436 : Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
437 : {
438 : /// Get the FEC number in offline-oriented numbering. The FECs are numbered from 0
439 : /// 17 (partition 3, 4, 5), 19 (partition 0, 2) or 24 (partition 1).
440 :
441 0 : Int_t patch = GetPatch(roc, padrow, pad);
442 0 : Int_t fec = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
443 0 : Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
444 0 : if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
445 0 : return HwToOffline(patch, branch, fec);
446 0 : }
447 :
448 :
449 : //_____________________________________________________________________________
450 : Int_t AliTPCmapper::GetFECSector(Int_t globalpadrow, Int_t pad) const
451 : {
452 : /// Get the FEC number in offline-oriented numbering. globalpadrow is
453 : /// counted for a full sector (0 ... 158)
454 :
455 0 : Int_t patch = GetPatchSector(globalpadrow, pad);
456 0 : Int_t fec = DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
457 0 : Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
458 0 : if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
459 0 : return HwToOffline(patch, branch, fec);
460 0 : }
461 :
462 :
463 : //_____________________________________________________________________________
464 : Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
465 : {
466 : /// Get Chip (ALTRO) index (0 ... 7) from pad coordinates
467 :
468 0 : return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
469 : }
470 :
471 :
472 : //_____________________________________________________________________________
473 : Int_t AliTPCmapper::GetChipSector(Int_t globalpadrow, Int_t pad) const
474 : {
475 : /// Get Chip (ALTRO) index (0 ... 7) from pad coordinates, where
476 : /// globalpadrow is counted for a full sector (0 ... 158)
477 :
478 0 : return DecodedHWAddressChipaddr(GetHWAddressSector(globalpadrow, pad));
479 : }
480 :
481 :
482 : //_____________________________________________________________________________
483 : Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
484 : {
485 : /// Get Channel index (0 ... 15) from pad coordinates
486 :
487 0 : return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
488 : }
489 :
490 :
491 : //_____________________________________________________________________________
492 : Int_t AliTPCmapper::GetChannelSector(Int_t globalpadrow, Int_t pad) const
493 : {
494 : /// Get Channel index (0 ... 15) from pad coordinates, where
495 : /// globalpadrow is counted for a full sector (0 ... 158)
496 :
497 0 : return DecodedHWAddressChanneladdr(GetHWAddressSector(globalpadrow, pad));
498 : }
499 :
500 :
501 : //_____________________________________________________________________________
502 : Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
503 : {
504 : /// Get Hardware address from channel, altro, fec and branch coordinates
505 :
506 0 : return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
507 : }
508 :
509 :
510 : //_____________________________________________________________________________
511 : Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
512 : {
513 : /// Get branch index (0, 1) from hardware address
514 :
515 0 : if ( hwAddress < 0 ) return -1;
516 0 : return ((hwAddress>>11)&1);
517 0 : }
518 :
519 :
520 : //_____________________________________________________________________________
521 : Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
522 : {
523 : /// Get FEC index (0 ... 12) from hardware address
524 :
525 0 : if ( hwAddress < 0 ) return -1;
526 0 : return ((hwAddress>>7)&0xf);
527 0 : }
528 :
529 :
530 : //_____________________________________________________________________________
531 : Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
532 : {
533 : /// Get ALTRO index (0 ... 7) from hardware address
534 :
535 0 : if ( hwAddress < 0 ) return -1;
536 0 : return ((hwAddress>>4)&0x7);
537 0 : }
538 :
539 :
540 : //_____________________________________________________________________________
541 : Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
542 : {
543 : /// Get channel index (0 ... 15) from hardware address
544 :
545 0 : if ( hwAddress < 0 ) return -1;
546 0 : return ((hwAddress&0xf));
547 0 : }
548 :
549 :
550 : //______________________________________________________________
551 : Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
552 : /// Get number of pads in padrow for this ROC.
553 :
554 3345408 : AliTPCROC *fROC = AliTPCROC::Instance();
555 1672704 : Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
556 1672704 : return retval;
557 : }
558 :
559 :
560 : //______________________________________________________________
561 : Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
562 : /// Get number of pads in padrow, where globalpadrow is counted for a full sector (0 ... 158)
563 :
564 3345408 : if ( globalpadrow >= fNpadrow ) {
565 0 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
566 0 : return -1;
567 : }
568 2267136 : if ( globalpadrow < fNpadrowIROC ) return GetNpads(0, globalpadrow); // IROC
569 1078272 : else return GetNpads(36, globalpadrow - fNpadrowIROC); // OROC
570 :
571 : return -1;
572 1672704 : }
573 :
574 :
575 : //______________________________________________________________
576 : Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
577 : {
578 : /// Get number of padrows
579 :
580 0 : if (roc < 36) return fNpadrowIROC;
581 0 : else if (roc < 72) return fNpadrowOROC;
582 0 : return -1;
583 0 : }
584 :
585 :
586 : //______________________________________________________________
587 : /*
588 : Double_t AliTPCmapper::GetPadXlocal(Int_t globalpadrow) const
589 : {
590 : // Get local x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
591 :
592 : if ( globalpadrow >= fNpadrow ) {
593 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
594 : return -1.0;
595 : }
596 :
597 : //IROC
598 : if ( globalpadrow < fNpadrowIROC )
599 : return (852.25 + 7.5*(Double_t)globalpadrow)/10.; //divide by 10 to get cm
600 :
601 : globalpadrow -= fNpadrowIROC;
602 :
603 : if ( globalpadrow < 64 ) //OROC inner part
604 : return (10.* globalpadrow + 1351.)/10.; //divide by 10 to get cm
605 :
606 : //OROC outer part
607 : return (15.*(globalpadrow - 64) + 1993.5)/10.; //divide by 10 to get cm
608 : }
609 : */
610 :
611 : //______________________________________________________________
612 : /*
613 : Double_t AliTPCmapper::GetPadYlocal(Int_t globalpadrow, Int_t pad) const
614 : {
615 : // Get local y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
616 :
617 : if ( globalpadrow >= fNpadrow ) {
618 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
619 : return -1.0;
620 : }
621 :
622 : Int_t padsInRow = GetNpads(globalpadrow);
623 : if ( (padsInRow < 0) || (pad >= padsInRow) ) {
624 : AliWarning(Form("Pad index outside range (pad %d) !", pad));
625 : return -1.0;
626 : }
627 :
628 : //IROC
629 : if ( globalpadrow < fNpadrowIROC )
630 : return (2.* padsInRow - 4.*pad - 2.)*1.e-1; //divide by 10 to get cm
631 :
632 : //OROC
633 : return (3.* padsInRow -6.*pad - 3.)*1.e-1; //divide by 10 to get cm
634 : }
635 : */
636 :
637 : //______________________________________________________________
638 : /*
639 : Double_t AliTPCmapper::GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const
640 : {
641 : // Get global x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
642 :
643 : if ( globalpadrow >= fNpadrow ) {
644 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
645 : return -1.0;
646 : }
647 :
648 : Int_t padsInRow = GetNpads(globalpadrow);
649 : if ( (padsInRow < 0) || (pad >= padsInRow) ) {
650 : AliWarning(Form("Pad index outside range (pad %d) !", pad));
651 : return -1.0;
652 : }
653 :
654 : Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
655 : return GetPadXlocal(globalpadrow) * TMath::Cos(angle) -
656 : GetPadYlocal(globalpadrow, pad) * TMath::Sin(angle);
657 : }
658 : */
659 :
660 : //______________________________________________________________
661 : /*
662 : Double_t AliTPCmapper::GetPadYglobal(Int_t globalpadrow, Int_t pad,Int_t sector) const
663 : {
664 : // Get global y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
665 :
666 : if ( globalpadrow >= fNpadrow ) {
667 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
668 : return -1.0;
669 : }
670 :
671 : Int_t padsInRow = GetNpads(globalpadrow);
672 : if ( (padsInRow < 0) || (pad >= padsInRow) ) {
673 : AliWarning(Form("Pad index outside range (pad %d) !", pad));
674 : return -1.0;
675 : }
676 :
677 : Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
678 : return GetPadXlocal(globalpadrow) * TMath::Sin(angle) +
679 : GetPadYlocal(globalpadrow, pad) * TMath::Cos(angle);
680 : }
681 : */
682 :
683 : //______________________________________________________________
684 : /*
685 : Double_t AliTPCmapper::GetPadWidth(Int_t globalpadrow) const
686 : {
687 : // Get pad width, where globalpadrow is counted for a full sector (0 ... 158)
688 :
689 : if ( globalpadrow >= fNpadrow ) {
690 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
691 : return -1.0;
692 : }
693 :
694 : if (globalpadrow < fNpadrowIROC ) // IROC
695 : return 0.4;
696 : return 0.6;
697 : }
698 : */
699 :
700 : //______________________________________________________________
701 : /*
702 : Double_t AliTPCmapper::GetPadLength(Int_t globalpadrow) const
703 : {
704 : // Get pad length, where globalpadrow is counted for a full sector (0 ... 158)
705 :
706 : if ( globalpadrow >= fNpadrow ) {
707 : AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
708 : return -1.0;
709 : }
710 :
711 : if ( globalpadrow < fNpadrowIROC ) return 0.75;
712 : if ( globalpadrow < 127 ) return 1.0;
713 : return 1.5;
714 : }
715 : */
716 :
717 : //_____________________________________________________________________________
718 : Int_t AliTPCmapper::GetNfec(Int_t patch) const
719 : {
720 : /// Get size of readout partition (number of FECs) for this rcu (patch) index (0 ... 5)
721 :
722 : Int_t retval = 0;
723 0 : switch(patch){
724 : case(0):
725 : retval = 18;
726 0 : break;
727 : case(1):
728 : retval = 25;
729 0 : break;
730 : case(2):
731 : retval = 18;
732 0 : break;
733 : case(3):
734 : retval = 20;
735 0 : break;
736 : case(4):
737 : retval = 20;
738 0 : break;
739 : case(5):
740 : retval = 20;
741 0 : break;
742 : };
743 0 : return retval;
744 : }
745 :
746 :
747 : //_____________________________________________________________________________
748 : Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
749 : {
750 : /// Get size of readout partition (number of FECs) for this branch
751 :
752 : Int_t retval = 0;
753 0 : switch(patch){
754 : case(0):
755 : retval = 9;
756 0 : break;
757 : case(1):
758 : retval = 13;
759 0 : break;
760 : case(2):
761 : retval = 9;
762 0 : break;
763 : case(3):
764 : retval = 10;
765 0 : break;
766 : case(4):
767 : retval = 10;
768 0 : break;
769 : case(5):
770 : retval = 10;
771 0 : break;
772 : };
773 :
774 0 : if( (branch == 1) && (patch == 1) ){
775 : retval = 12;
776 0 : }
777 :
778 0 : return retval;
779 : }
780 :
781 :
782 : //_____________________________________________________________________________
783 : Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
784 : {
785 : /// Convert FEC position in offline-like numbering to hardware numbering (fec).
786 :
787 0 : if ( (patch < 0) || (fec < 0) ) {
788 0 : AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
789 0 : return -1;
790 : }
791 0 : if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
792 0 : AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
793 0 : return -1;
794 : }
795 :
796 0 : Int_t fecsInBranchA = GetNfec(patch, 0);
797 0 : if ( fec < fecsInBranchA ) // branch A
798 0 : return (fecsInBranchA - 1 - fec);
799 : else // branch B
800 0 : return (fec - fecsInBranchA);
801 :
802 : return -1;
803 0 : }
804 :
805 :
806 : //_____________________________________________________________________________
807 : Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
808 : {
809 : /// Convert fec position in offline-like numbering to hardware numbering (branch).
810 :
811 0 : if ( (patch < 0) || (fec < 0) ) {
812 0 : AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
813 0 : return -1;
814 : }
815 0 : if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
816 0 : AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
817 0 : return -1;
818 : }
819 0 : if ( fec < GetNfec(patch, 0) ) return 0; // branch A
820 0 : else return 1; // branch B
821 :
822 : return -1;
823 0 : }
824 :
825 :
826 : //_____________________________________________________________________________
827 : Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
828 : {
829 : /// Convert hardware FEC position (branch, fec) to the offline-oriented numbering
830 :
831 0 : if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
832 0 : AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
833 0 : return -1;
834 : }
835 0 : if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
836 0 : AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
837 0 : return -1;
838 : }
839 0 : Int_t fecsInBranchA = GetNfec(patch, 0);
840 0 : if ( branch == 0 ) // branch A
841 0 : return (fecsInBranchA - 1 - fec);
842 : else // branch B
843 0 : return (fec + fecsInBranchA);
844 :
845 : return -1;
846 0 : }
847 :
848 :
849 : //_____________________________________________________________________________
850 : Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
851 : {
852 : /// Get EqID from pad coordinate. The Roc index is
853 : /// needed as well to determine if it is IROC or OROC.
854 :
855 3345408 : Int_t side = GetSideFromRoc(roc);
856 1672704 : if ( side < 0 ) return -1;
857 1672704 : Int_t sector = GetSectorFromRoc(roc);
858 1672704 : if ( sector < 0 ) return -1;
859 1672704 : Int_t patch = GetPatch(roc, padrow, pad);
860 1672704 : if ( patch < 0 ) return -1;
861 1672704 : return GetEquipmentIDfromPatch(side, sector, patch);
862 1672704 : }
863 :
864 :
865 : //_____________________________________________________________________________
866 : Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
867 : {
868 : /// Get EqID from pad coordinate, where padrow is counted for a full sector (0 ... 158)
869 :
870 0 : Int_t patch = GetPatchSector(globalpadrow, pad);
871 0 : if ( patch < 0 ) return -1;
872 0 : Int_t roc = GetRocFromPatch(side, sector, patch);
873 0 : if ( roc < 0 ) return -1;
874 :
875 0 : if ( globalpadrow < fNpadrowIROC )
876 0 : return GetEquipmentID(roc, globalpadrow, pad);
877 : else
878 0 : return GetEquipmentID(roc, globalpadrow-fNpadrowIROC, pad);
879 0 : }
880 :
881 :
882 : //_____________________________________________________________________________
883 : Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
884 : {
885 : /// Get EqID from patch (rcu).
886 :
887 3345408 : Int_t roc = GetRocFromPatch(side, sector, patch);
888 : Int_t ddl = 0;
889 1672704 : if (patch < 2) // IROC
890 594432 : ddl = roc*2 + patch;
891 : else // OROC
892 1078272 : ddl = (roc-36)*4 + 36*2 + (patch-2);
893 : // Add offset. TPC has detectorID = 3
894 1672704 : return ddl+fTpcDdlOffset;
895 : }
896 :
897 :
898 : //_____________________________________________________________________________
899 : Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
900 : {
901 : /// Get rcu (patch) index (0 ... 5) from equipment ID
902 :
903 : Int_t retval = 0;
904 :
905 0 : if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
906 0 : AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
907 0 : return -1;
908 : }
909 0 : if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
910 0 : else retval = (equipmentID-840)%4 + 2;
911 0 : return retval;
912 0 : }
913 :
914 :
915 : //_____________________________________________________________________________
916 : Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
917 : {
918 : /// Get side from Eq ID
919 :
920 0 : if ( equipmentID < fTpcDdlOffset ) {
921 0 : AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
922 0 : return -1;
923 : }
924 0 : if ( equipmentID < 804 ) return 0;
925 0 : else if ( equipmentID < 840 ) return 1;
926 0 : else if ( equipmentID < 912 ) return 0;
927 0 : else if ( equipmentID < 984 ) return 1;
928 : else {
929 0 : AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
930 0 : return -1;
931 : }
932 0 : }
933 :
934 :
935 : //_____________________________________________________________________________
936 : Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
937 : {
938 : /// Get sector index (0 ... 17) from equipment ID
939 :
940 : Int_t retval = 0;
941 0 : if ( (equipmentID < fTpcDdlOffset) || (equipmentID >= fTpcDdlOffset+216) ) {
942 0 : AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
943 0 : return -1;
944 : }
945 0 : Int_t side = GetSideFromEquipmentID(equipmentID);
946 0 : if ( side < 0 ) return -1;
947 :
948 0 : if ( (equipmentID - 840) < 0 ) { // IROC
949 0 : if ( side == 0 ) retval = (equipmentID-fTpcDdlOffset)/2;
950 0 : else retval = (equipmentID-fTpcDdlOffset-18*2)/2;
951 : } else { // OROC
952 0 : if ( side == 0 ) retval = (equipmentID-840)/4;
953 0 : else retval = (equipmentID-840-18*4)/4;
954 : }
955 0 : return retval;
956 0 : }
957 :
958 :
959 : //_____________________________________________________________________________
960 : Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
961 : {
962 : /// Get ROC index (0 ... 71) from equipment ID
963 :
964 0 : Int_t side = GetSideFromEquipmentID(equipmentID);
965 0 : if ( side < 0 ) return -1;
966 0 : Int_t sector = GetSectorFromEquipmentID(equipmentID);
967 0 : if ( sector < 0 ) return -1;
968 0 : Int_t patch = GetPatchFromEquipmentID(equipmentID);
969 0 : if ( patch < 0 ) return -1;
970 :
971 0 : return GetRocFromPatch(side, sector, patch);
972 0 : }
973 :
974 :
975 : //_____________________________________________________________________________
976 : Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
977 : {
978 : /// get the sector number (0 ... 17) from the roc number (0 ... 71)
979 :
980 3345408 : if ( roc < 0 ) {
981 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
982 0 : return -1;
983 1672704 : } else if ( roc < 18 ) { // inner sector, A side
984 297216 : return roc;
985 1375488 : } else if ( roc < 36 ) { // inner sector, C side
986 297216 : return (roc-18);
987 1078272 : } else if ( roc < 54 ) { // outer sector, A side
988 539136 : return (roc-36);
989 539136 : } else if ( roc < 72 ) { // outer sector, C side
990 539136 : return (roc-54);
991 : } else {
992 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
993 0 : return -1;
994 : }
995 1672704 : }
996 :
997 :
998 : //_____________________________________________________________________________
999 : Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
1000 : {
1001 : /// get the side (0, 1) from the roc number (0 ... 71)
1002 :
1003 3345408 : if ( roc < 0 ) {
1004 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
1005 0 : return -1;
1006 1672704 : } else if ( roc < 18 ) { // inner sector, A side
1007 297216 : return 0;
1008 1375488 : } else if ( roc < 36 ) { // inner sector, C side
1009 297216 : return 1;
1010 1078272 : } else if ( roc < 54 ) { // outer sector, A side
1011 539136 : return 0;
1012 539136 : } else if ( roc < 72 ) { // outer sector, C side
1013 539136 : return 1;
1014 : } else {
1015 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
1016 0 : return -1;
1017 : }
1018 1672704 : }
1019 :
1020 :
1021 : //_____________________________________________________________________________
1022 : Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
1023 : {
1024 : /// Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and patch (0 ... 5)
1025 :
1026 5018112 : if ( (side < 0) || (side >= fNside) ) {
1027 0 : AliWarning(Form("Side outside range (side %d) !", side));
1028 0 : return -1;
1029 : }
1030 3345408 : if ( (sector < 0) || (sector >= fNsector) ) {
1031 0 : AliWarning(Form("Sector outside range (sector %d) !", sector));
1032 0 : return -1;
1033 : }
1034 3345408 : if ( (patch < 0) || (patch >= fNrcu) ) {
1035 0 : AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
1036 0 : return -1;
1037 : }
1038 :
1039 3345408 : if ( side == 0 ) { // A side
1040 2806272 : if ( patch < 2 ) return sector; // IROC
1041 539136 : else return 36+sector; // OROC
1042 : } else { // C side
1043 1133568 : if ( patch < 2 ) return 18+sector; // IROC
1044 539136 : else return 54+sector; // OROC
1045 : }
1046 1672704 : }
1047 :
1048 :
1049 : //_____________________________________________________________________________
1050 : Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
1051 : {
1052 : /// Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and pad coordinates
1053 :
1054 0 : Int_t patch = GetPatchSector(globalpadrow, pad);
1055 0 : if ( patch < 0 ) return -1;
1056 0 : return GetRocFromPatch(side, sector, patch);
1057 0 : }
1058 :
1059 :
1060 : //_____________________________________________________________________________
1061 : Bool_t AliTPCmapper::IsIROC(Int_t roc) const
1062 : {
1063 : /// Is this ROC an IROC?
1064 :
1065 0 : if ( roc < 0 ) {
1066 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
1067 0 : return -1;
1068 0 : } else if ( roc < 36 ) { // inner sector
1069 0 : return true;
1070 0 : } else if ( roc < 72 ) { // outer sector, C side
1071 0 : return false;
1072 : } else {
1073 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
1074 0 : return -1;
1075 : }
1076 0 : }
1077 :
1078 :
1079 : //_____________________________________________________________________________
1080 : Bool_t AliTPCmapper::IsOROC(Int_t roc) const
1081 : {
1082 : /// Is this ROC an OROC?
1083 :
1084 0 : if ( roc < 0 ) {
1085 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
1086 0 : return -1;
1087 0 : } else if ( roc < 36 ) { // inner sector
1088 0 : return false;
1089 0 : } else if ( roc < 72 ) { // outer sector, C side
1090 0 : return true;
1091 : } else {
1092 0 : AliWarning(Form("Roc outside range (roc %d) !", roc));
1093 0 : return -1;
1094 : }
1095 0 : }
1096 :
1097 : // EOF
|