1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 #include "AliTPCMonitorMappingHandler.h"
21 ClassImp(AliTPCMonitorMappingHandler)
23 //_____________________________________________________________________________________________
24 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(Char_t* name, Char_t* title): TNamed(name,title)
26 // Constructor : Initialize mapping arrays
28 fmapping = new Short_t*[24000];
31 fmappingChannelinRow = new Int_t*[160];
32 for(Int_t in = 0; in<160; in++)
34 Int_t* hold = new Int_t[150];
35 for(Int_t jn = 0; jn<150;jn++) hold[jn]=0;
36 fmappingChannelinRow[in]= hold;
40 fu2ftestmapping = new Short_t*[7000];
41 for(Int_t i = 0; i<7000; i++)
43 Short_t* hold = new Short_t[8];
44 for(Int_t j = 0; j<8;j++) hold[j]=0;
45 fu2ftestmapping[i]= hold;
48 fMapHwFECglobal = new Int_t*[24000];
49 for(Int_t i = 0; i<24000; i++)
51 Int_t* hold = new Int_t[2];
52 for(Int_t j = 0; j<2;j++) hold[j]=0;
53 fMapHwFECglobal[i]= hold;
56 fecGainMap = new Float_t*[7000];
57 for(Int_t i = 0; i<7000; i++)
59 Float_t* hold = new Float_t[128];
60 for(Int_t j = 0; j<128;j++) hold[j]=0;
65 //_____________________________________________________________________________________________
66 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
70 for(Int_t i = 0; i < 24000 ; i++) {
71 temp = (Short_t *) fmapping[i];
75 temp = (Short_t *) fmapping;
80 for(Int_t i = 0; i < 24000 ; i++) {
81 temp1 = (Int_t *) fMapHwFECglobal[i];
84 temp1 = (Int_t *) fMapHwFECglobal;
87 for(Int_t i = 0; i < 7000 ; i++) {
88 temp = (Short_t *) fu2ftestmapping[i];
92 temp = (Short_t *) fu2ftestmapping;
95 for(Int_t i = 0; i < 150 ; i++) {
96 temp1= (Int_t *) fmappingChannelinRow[i];
99 temp1 = (Int_t *) fmappingChannelinRow;
103 for(Int_t i = 0; i<7000; i++)
105 temp2= (Float_t *) fecGainMap[i];
108 temp2 = (Float_t *) fecGainMap;
114 //_____________________________________________________________________________________________
115 void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
117 // Read global Mapping file
118 // Format of data in mapping file:
119 // column 0: hadrware address
120 // column 1: readout index in IROC/OROC
121 // column 2: global pad row number (0-158)
122 // column 3 pad number in row
123 // column 4: connector
125 // column 6: fec number in IROC/OROC
126 // column 7: fec channel
127 // column 8: fec connector
128 // column 9: altro channel
129 // column 10: altro chip
131 // Mapping data for a given hardware address are placed at the
132 // index corresponding to the value of the hardware address in
133 // the fmapping array..
134 // The mapping information for the hardware address 'hwaddr'
135 // can hence be found in fmapping[hwaddr]
144 ifstream *in = new ifstream();
147 version = atoi(readcarry);
150 fnumofChannels = atoi(readcarry);
152 fmaxHWAdress = atoi(readcarry);
153 fsizeofArray = fmaxHWAdress;
155 Short_t *fmappingEmptyRow = new Short_t[11];
156 for(Int_t i = 0; i < 11 ; i++) {
157 fmappingEmptyRow[i] = 0;
159 fmappingEmptyRow[1] = -1;
160 for(Int_t i = 0; i < fnumofChannels ; i++) {
161 fmappingRow = new Short_t[11];
162 for(Int_t j = 0 ; j < 11 ; j++) {
164 fmappingRow[j] = atoi(readcarry);
166 actPos = fmappingRow[0];
167 fmapping[actPos] = fmappingRow;
168 if( (actPos - oldPos) > 1) {
169 for(Int_t j = (oldPos+1); j < actPos; j++) {
170 fmapping[j] = fmappingEmptyRow;
174 fmapping[actPos][0] = i;
181 //_____________________________________________________________________________________________
182 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
184 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
185 // Format in Mapping file
186 // column 0: global card number (set to 0 if card number does not exist)
187 // column 1: side of the TPC
188 // column 2: sector on the side (0-17)
189 // column 3: rcu in the sector (0-5)
190 // column 4: fec number in rcu (0-24)
191 // column 5: fec number in branch (0-12)
192 // column 6: branch number (0,1)
193 // column 7: local hardware address of first channel (not used)
195 // Order of data is kept in fu2ftestmapping
197 ifstream datin(u2ftestfile);
202 for(Int_t ind = 0; ind<7000; ind++)
204 for(Int_t entr = 0; entr<8; entr++)
207 fu2ftestmapping[ind][entr] = carry ;
209 if(entr==0 && carry!=0) ncards++;
217 //_____________________________________________________________________________________________
218 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
220 // Create mapping of global FEC numbers to hardware addresses for a given sector
229 Int_t nextHwAddress = 0;
232 if(sector/18==0) fside =65;
235 if(sector>18) fsector= sector-18;
236 else fsector= sector ;
238 for(Int_t ind = 0; ind<7000; ind++)
240 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
243 fec = U2fGetFECinBranch(ind);
244 branch = U2fGetBranch(ind);
245 rcu_patch = U2fGetRCU(ind);
247 for(Int_t ch = 0; ch<128; ch++)
252 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcu_patch-1)<<12) );
254 fMapHwFECglobal[nextHwAddress][0] = ind;
255 fMapHwFECglobal[nextHwAddress][1] = ch ;
260 //_____________________________________________________________________________________________
261 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
263 // Read global gain calibration pap
265 // colummn 0 : FEC number
266 // colums 1-128 : gain calibration factors
267 ifstream datin(fecgainmap);
275 for(Int_t in = 0; in<128; in++)
278 fecGainMap[fecnr][in] = val;
283 //_____________________________________________________________________________________________
284 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
286 // Read mapping of hardware addresses in rows
288 // column 0: global row number (0-158)
289 // column 1: number of pads in this row (npads)
290 // column 2-npads: hardware addresses for these pads
293 char readcarry2[256];
294 ifstream *in = new ifstream();
295 in->open(fpathtoMappingRowfile);
297 for(Int_t i = 0; i < 159 ; i++) {
298 *in >> readcarry; // row number
299 *in >> readcarry2; // numof pads
300 fmappingChannelinRow[i][0] = atoi(readcarry2);
301 fmappingChannelinRow[i][1] = atoi(readcarry);
303 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
305 fmappingChannelinRow[i][j] = atoi(readcarry);
313 //_____________________________________________________________________________________________
314 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels()
316 // Return number of channels
317 return fnumofChannels;
320 //_____________________________________________________________________________________________
321 Int_t AliTPCMonitorMappingHandler::GetSizeofArray()
323 // Return sise of global mapping fmapping array.
324 // Value orresponds to max value of hardware addresses
329 //_____________________________________________________________________________________________
330 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)
332 // Return pointer to mapping array for the hardware address hwaddr
334 if(hwaddr <= fsizeofArray)
335 retval = fmapping[hwaddr];
341 //_____________________________________________________________________________________________
342 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr)
344 // Return readout index for the hardware address hwaddr
346 if(hwaddr <= fsizeofArray)
347 retval = fmapping[hwaddr][1];
353 //_____________________________________________________________________________________________
354 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr)
356 // Return global pad row for the hardware address hwaddr
358 if(hwaddr <= fsizeofArray)
359 retval = fmapping[hwaddr][2];
365 //_____________________________________________________________________________________________
366 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr)
368 // Return pad number in row for the hardware address hwaddr
370 if(hwaddr < fsizeofArray)
371 retval = fmapping[hwaddr][3];
377 //_____________________________________________________________________________________________
378 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr)
380 // Return connector for the hardware address hwaddr
382 if(hwaddr <= fsizeofArray)
383 retval = fmapping[hwaddr][4];
389 //_____________________________________________________________________________________________
390 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr)
392 // Return pin for the hardware address hwaddr
394 if(hwaddr <= fsizeofArray)
395 retval = fmapping[hwaddr][5];
401 //_____________________________________________________________________________________________
402 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr)
404 // Return fec number in IROC/OROC for the hardware address hwaddr
406 if(hwaddr <= fsizeofArray)
407 retval = fmapping[hwaddr][6];
413 //_____________________________________________________________________________________________
414 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr)
416 // Return FEC channel for the hardware address hwaddr
418 if(hwaddr < fsizeofArray)
419 retval = fmapping[hwaddr][7];
425 //_____________________________________________________________________________________________
426 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr)
428 // Return FEC connector for the hardware address hwaddr
430 if(hwaddr <= fsizeofArray)
431 retval = fmapping[hwaddr][8];
437 //_____________________________________________________________________________________________
438 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr)
440 // Return Altro channel for the hardware address hwaddr
442 if(hwaddr <= fsizeofArray)
443 retval = fmapping[hwaddr][9];
449 //_____________________________________________________________________________________________
450 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr)
452 // Return Altro chip number in FEC for the hardware address hwaddr
454 if(hwaddr <= fsizeofArray)
455 retval = fmapping[hwaddr][10];
462 //_____________________________________________________________________________________________
463 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
465 // Return number of pads in row
467 return fmappingChannelinRow[row][0];
469 AliError("Row number to high");
474 //_____________________________________________________________________________________________
475 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
477 // Return hardware address for given pad in row
479 return fmappingChannelinRow[row][pad+2];
481 AliError("Row number to high");
488 //_____________________________________________________________________________________________
489 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index)
491 // Return FEC number for index (FEC number should be equal to index)
492 return fu2ftestmapping[index][0];
495 //_____________________________________________________________________________________________
496 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr)
498 // Return side on which FEC is installed
499 return fu2ftestmapping[fecnr][1];
502 //_____________________________________________________________________________________________
503 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr)
505 // Return sector in which FEC is installed
506 return fu2ftestmapping[fecnr][2];
509 //_____________________________________________________________________________________________
510 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr)
512 // Rerurn rcu patch in which FEC is installed
513 return fu2ftestmapping[fecnr][3];
516 //_____________________________________________________________________________________________
517 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr)
519 // Return index of FEC in RCU (0-25)
520 return fu2ftestmapping[fecnr][4];
523 //_____________________________________________________________________________________________
524 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr)
526 // Return index of FEC in branch (0-12)
527 return fu2ftestmapping[fecnr][5];
530 //_____________________________________________________________________________________________
531 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr)
533 // Return branch in which FEC is installed (0,1)
534 return fu2ftestmapping[fecnr][6];