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