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 **************************************************************************/
18 Revision 1.1 2007/09/17 10:23:31 cvetan
19 New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
23 ////////////////////////////////////////////////////////////////////////
25 // AliTPCMonitorMappingHandler class
27 // Class for handling mapping information TPC
29 // The mapping information for the TPC front end electornics (pads, front end cards)
30 // are handled by this class.
31 // The information from the design mapping and from the hardware address can be
32 // cross checked in the TPCMonitor.C.
33 // Malfunctioning front end cards can be identified by looking at single channels
34 // displayed with the TPCMonitor.
37 // Authors: Roland Bramm,
38 // Stefan Kniege, IKF, Frankfurt
40 /////////////////////////////////////////////////////////////////////////
43 #include "AliTPCMonitorMappingHandler.h"
47 #include <Riostream.h>
49 ClassImp(AliTPCMonitorMappingHandler)
51 //_____________________________________________________________________________________________
52 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(Char_t* name, Char_t* title):
57 fmapping(new Short_t*[24000]),
58 fmappingChannelinRow(new Int_t*[160]),
59 fu2ftestmapping(new Short_t*[7000]),
60 fMapHwFECglobal(new Int_t*[24000]),
61 fecGainMap(new Float_t*[7000])
63 // Constructor : Initialize mapping arrays
65 for(Int_t in = 0; in<160; in++)
67 Int_t* hold = new Int_t[150];
68 for(Int_t jn = 0; jn<150;jn++) hold[jn]=0;
69 fmappingChannelinRow[in]= hold;
72 for(Int_t i = 0; i<7000; i++)
74 Short_t* hold = new Short_t[8];
75 for(Int_t j = 0; j<8;j++) hold[j]=0;
76 fu2ftestmapping[i]= hold;
79 for(Int_t i = 0; i<24000; i++)
81 Int_t* hold = new Int_t[2];
82 for(Int_t j = 0; j<2;j++) hold[j]=0;
83 fMapHwFECglobal[i]= hold;
87 for(Int_t i = 0; i<7000; i++)
89 Float_t* hold = new Float_t[128];
90 for(Int_t j = 0; j<128;j++) hold[j]=0;
95 //____________________________________________________________________________
96 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
97 TNamed(maphand.GetName(),maphand.GetTitle()),
98 fnumofChannels(maphand.fnumofChannels),
99 fmaxHWAdress(maphand.fmaxHWAdress),
100 fsizeofArray(maphand.fsizeofArray),
101 fmapping(new Short_t*[24000]),
102 fmappingChannelinRow(new Int_t*[160]),
103 fu2ftestmapping(new Short_t*[7000]),
104 fMapHwFECglobal(new Int_t*[24000]),
105 fecGainMap(new Float_t*[7000])
110 for(Int_t in = 0; in<160; in++)
112 Int_t* hold = new Int_t[150];
113 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
114 fmappingChannelinRow[in]= hold;
117 for(Int_t i = 0; i<7000; i++)
119 Short_t* hold = new Short_t[8];
120 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
121 fu2ftestmapping[i]= hold;
124 for(Int_t i = 0; i<24000; i++)
126 Int_t* hold = new Int_t[2];
127 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
128 fMapHwFECglobal[i]= hold;
131 for(Int_t i = 0; i<7000; i++)
133 Float_t* hold = new Float_t[128];
134 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
141 //____________________________________________________________________________
142 AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
144 // assignment operator
147 fnumofChannels=maphand.fnumofChannels;
148 fmaxHWAdress=maphand.fmaxHWAdress;
149 fsizeofArray=maphand.fsizeofArray;
151 fmapping = new Short_t*[24000]; // empty
154 fmappingChannelinRow = new Int_t*[160];
155 for(Int_t in = 0; in<160; in++)
157 Int_t* hold = new Int_t[150];
158 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
159 fmappingChannelinRow[in]= hold;
162 fu2ftestmapping = new Short_t*[7000];
163 for(Int_t i = 0; i<7000; i++)
165 Short_t* hold = new Short_t[8];
166 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
167 fu2ftestmapping[i]= hold;
170 fMapHwFECglobal = new Int_t*[24000];
171 for(Int_t i = 0; i<24000; i++)
173 Int_t* hold = new Int_t[2];
174 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
175 fMapHwFECglobal[i]= hold;
178 fecGainMap = new Float_t*[7000];
179 for(Int_t i = 0; i<7000; i++)
181 Float_t* hold = new Float_t[128];
182 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
192 //_____________________________________________________________________________________________
193 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
197 for(Int_t i = 0; i < 24000 ; i++) {
198 temp = (Short_t *) fmapping[i];
202 temp = (Short_t *) fmapping;
207 for(Int_t i = 0; i < 24000 ; i++) {
208 temp1 = (Int_t *) fMapHwFECglobal[i];
211 temp1 = (Int_t *) fMapHwFECglobal;
214 for(Int_t i = 0; i < 7000 ; i++) {
215 temp = (Short_t *) fu2ftestmapping[i];
219 temp = (Short_t *) fu2ftestmapping;
222 for(Int_t i = 0; i < 150 ; i++) {
223 temp1= (Int_t *) fmappingChannelinRow[i];
226 temp1 = (Int_t *) fmappingChannelinRow;
230 for(Int_t i = 0; i<7000; i++)
232 temp2= (Float_t *) fecGainMap[i];
235 temp2 = (Float_t *) fecGainMap;
241 //_____________________________________________________________________________________________
242 void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
244 // Read global Mapping file
245 // Format of data in mapping file:
246 // column 0: hadrware address
247 // column 1: readout index in IROC/OROC
248 // column 2: global pad row number (0-158)
249 // column 3 pad number in row
250 // column 4: connector
252 // column 6: fec number in IROC/OROC
253 // column 7: fec channel
254 // column 8: fec connector
255 // column 9: altro channel
256 // column 10: altro chip
258 // Mapping data for a given hardware address are placed at the
259 // index corresponding to the value of the hardware address in
260 // the fmapping array..
261 // The mapping information for the hardware address 'hwaddr'
262 // can hence be found in fmapping[hwaddr]
271 ifstream *in = new ifstream();
274 version = atoi(readcarry);
277 fnumofChannels = atoi(readcarry);
279 fmaxHWAdress = atoi(readcarry);
280 fsizeofArray = fmaxHWAdress;
282 Short_t *fmappingEmptyRow = new Short_t[11];
283 for(Int_t i = 0; i < 11 ; i++) {
284 fmappingEmptyRow[i] = 0;
286 fmappingEmptyRow[1] = -1;
287 for(Int_t i = 0; i < fnumofChannels ; i++) {
288 mappingRow = new Short_t[11];
289 for(Int_t j = 0 ; j < 11 ; j++) {
291 mappingRow[j] = atoi(readcarry);
293 actPos = mappingRow[0];
294 fmapping[actPos] = mappingRow;
295 if( (actPos - oldPos) > 1) {
296 for(Int_t j = (oldPos+1); j < actPos; j++) {
297 fmapping[j] = fmappingEmptyRow;
301 fmapping[actPos][0] = i;
308 //_____________________________________________________________________________________________
309 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
311 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
312 // Format in Mapping file
313 // column 0: global card number (set to 0 if card number does not exist)
314 // column 1: side of the TPC
315 // column 2: sector on the side (0-17)
316 // column 3: rcu in the sector (0-5)
317 // column 4: fec number in rcu (0-24)
318 // column 5: fec number in branch (0-12)
319 // column 6: branch number (0,1)
320 // column 7: local hardware address of first channel (not used)
322 // Order of data is kept in fu2ftestmapping
324 ifstream datin(u2ftestfile);
329 for(Int_t ind = 0; ind<7000; ind++)
331 for(Int_t entr = 0; entr<8; entr++)
334 fu2ftestmapping[ind][entr] = carry ;
336 if(entr==0 && carry!=0) ncards++;
344 //_____________________________________________________________________________________________
345 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
347 // Create mapping of global FEC numbers to hardware addresses for a given sector
356 Int_t nextHwAddress = 0;
359 if(sector/18==0) fside =65;
362 if(sector>18) fsector= sector-18;
363 else fsector= sector ;
365 for(Int_t ind = 0; ind<7000; ind++)
367 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
370 fec = U2fGetFECinBranch(ind);
371 branch = U2fGetBranch(ind);
372 rcu_patch = U2fGetRCU(ind);
374 for(Int_t ch = 0; ch<128; ch++)
379 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcu_patch-1)<<12) );
381 fMapHwFECglobal[nextHwAddress][0] = ind;
382 fMapHwFECglobal[nextHwAddress][1] = ch ;
387 //_____________________________________________________________________________________________
388 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
390 // Read global gain calibration pap
392 // colummn 0 : FEC number
393 // colums 1-128 : gain calibration factors
394 ifstream datin(fecgainmap);
402 for(Int_t in = 0; in<128; in++)
405 fecGainMap[fecnr][in] = val;
410 //_____________________________________________________________________________________________
411 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
413 // Read mapping of hardware addresses in rows
415 // column 0: global row number (0-158)
416 // column 1: number of pads in this row (npads)
417 // column 2-npads: hardware addresses for these pads
420 char readcarry2[256];
421 ifstream *in = new ifstream();
422 in->open(fpathtoMappingRowfile);
424 for(Int_t i = 0; i < 159 ; i++) {
425 *in >> readcarry; // row number
426 *in >> readcarry2; // numof pads
427 fmappingChannelinRow[i][0] = atoi(readcarry2);
428 fmappingChannelinRow[i][1] = atoi(readcarry);
430 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
432 fmappingChannelinRow[i][j] = atoi(readcarry);
440 //_____________________________________________________________________________________________
441 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels()
443 // Return number of channels
444 return fnumofChannels;
447 //_____________________________________________________________________________________________
448 Int_t AliTPCMonitorMappingHandler::GetSizeofArray()
450 // Return sise of global mapping fmapping array.
451 // Value orresponds to max value of hardware addresses
456 //_____________________________________________________________________________________________
457 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)
459 // Return pointer to mapping array for the hardware address hwaddr
461 if(hwaddr <= fsizeofArray)
462 retval = fmapping[hwaddr];
468 //_____________________________________________________________________________________________
469 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr)
471 // Return readout index for the hardware address hwaddr
473 if(hwaddr <= fsizeofArray)
474 retval = fmapping[hwaddr][1];
480 //_____________________________________________________________________________________________
481 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr)
483 // Return global pad row for the hardware address hwaddr
485 if(hwaddr <= fsizeofArray)
486 retval = fmapping[hwaddr][2];
492 //_____________________________________________________________________________________________
493 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr)
495 // Return pad number in row for the hardware address hwaddr
497 if(hwaddr < fsizeofArray)
498 retval = fmapping[hwaddr][3];
504 //_____________________________________________________________________________________________
505 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr)
507 // Return connector for the hardware address hwaddr
509 if(hwaddr <= fsizeofArray)
510 retval = fmapping[hwaddr][4];
516 //_____________________________________________________________________________________________
517 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr)
519 // Return pin for the hardware address hwaddr
521 if(hwaddr <= fsizeofArray)
522 retval = fmapping[hwaddr][5];
528 //_____________________________________________________________________________________________
529 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr)
531 // Return fec number in IROC/OROC for the hardware address hwaddr
533 if(hwaddr <= fsizeofArray)
534 retval = fmapping[hwaddr][6];
540 //_____________________________________________________________________________________________
541 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr)
543 // Return FEC channel for the hardware address hwaddr
545 if(hwaddr < fsizeofArray)
546 retval = fmapping[hwaddr][7];
552 //_____________________________________________________________________________________________
553 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr)
555 // Return FEC connector for the hardware address hwaddr
557 if(hwaddr <= fsizeofArray)
558 retval = fmapping[hwaddr][8];
564 //_____________________________________________________________________________________________
565 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr)
567 // Return Altro channel for the hardware address hwaddr
569 if(hwaddr <= fsizeofArray)
570 retval = fmapping[hwaddr][9];
576 //_____________________________________________________________________________________________
577 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr)
579 // Return Altro chip number in FEC for the hardware address hwaddr
581 if(hwaddr <= fsizeofArray)
582 retval = fmapping[hwaddr][10];
589 //_____________________________________________________________________________________________
590 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
592 // Return number of pads in row
594 return fmappingChannelinRow[row][0];
596 AliError("Row number to high");
601 //_____________________________________________________________________________________________
602 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
604 // Return hardware address for given pad in row
606 return fmappingChannelinRow[row][pad+2];
608 AliError("Row number to high");
615 //_____________________________________________________________________________________________
616 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index)
618 // Return FEC number for index (FEC number should be equal to index)
619 return fu2ftestmapping[index][0];
622 //_____________________________________________________________________________________________
623 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr)
625 // Return side on which FEC is installed
626 return fu2ftestmapping[fecnr][1];
629 //_____________________________________________________________________________________________
630 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr)
632 // Return sector in which FEC is installed
633 return fu2ftestmapping[fecnr][2];
636 //_____________________________________________________________________________________________
637 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr)
639 // Rerurn rcu patch in which FEC is installed
640 return fu2ftestmapping[fecnr][3];
643 //_____________________________________________________________________________________________
644 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr)
646 // Return index of FEC in RCU (0-25)
647 return fu2ftestmapping[fecnr][4];
650 //_____________________________________________________________________________________________
651 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr)
653 // Return index of FEC in branch (0-12)
654 return fu2ftestmapping[fecnr][5];
657 //_____________________________________________________________________________________________
658 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr)
660 // Return branch in which FEC is installed (0,1)
661 return fu2ftestmapping[fecnr][6];