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.2 2007/10/12 13:36:27 cvetan
19 Coding convention fixes from Stefan
21 Revision 1.1 2007/09/17 10:23:31 cvetan
22 New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
26 ////////////////////////////////////////////////////////////////////////
28 //// AliTPCMonitorMappingHandler class
30 //// Class for handling mapping information TPC
32 //// The mapping information for the TPC front end electornics (pads, front end cards)
33 //// are handled by this class.
34 //// The information from the design mapping and from the hardware address can be
35 //// cross checked in the TPCMonitor.C.
36 //// Malfunctioning front end cards can be identified by looking at single channels
37 //// displayed with the TPCMonitor.
40 //// Authors: Roland Bramm,
41 //// Stefan Kniege, IKF, Frankfurt
43 /////////////////////////////////////////////////////////////////////////
47 #include "AliTPCMonitorMappingHandler.h"
52 #include <Riostream.h>
55 ClassImp(AliTPCMonitorMappingHandler)
57 //_____________________________________________________________________________________________
58 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const Char_t* name, const Char_t* title):
63 fmapping(new Short_t*[24000]),
64 fmappingChannelinRow(new Int_t*[160]),
65 fu2ftestmapping(new Short_t*[7000]),
66 fMapHwFECglobal(new Int_t*[24000]),
67 fecGainMap(new Float_t*[7000])
69 // Constructor : Initialize mapping arrays
71 for(Int_t in = 0; in<160; in++)
73 Int_t* hold = new Int_t[150];
74 for(Int_t jn = 0; jn<150;jn++) hold[jn]=0;
75 fmappingChannelinRow[in]= hold;
78 for(Int_t i = 0; i<7000; i++)
80 Short_t* hold = new Short_t[8];
81 for(Int_t j = 0; j<8;j++) hold[j]=0;
82 fu2ftestmapping[i]= hold;
85 for(Int_t i = 0; i<24000; i++)
87 Int_t* hold = new Int_t[2];
88 for(Int_t j = 0; j<2;j++) hold[j]=0;
89 fMapHwFECglobal[i]= hold;
93 for(Int_t i = 0; i<7000; i++)
95 Float_t* hold = new Float_t[128];
96 for(Int_t j = 0; j<128;j++) hold[j]=0;
101 //____________________________________________________________________________
102 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
103 TNamed(maphand.GetName(),maphand.GetTitle()),
104 fnumofChannels(maphand.fnumofChannels),
105 fmaxHWAdress(maphand.fmaxHWAdress),
106 fsizeofArray(maphand.fsizeofArray),
107 fmapping(new Short_t*[24000]),
108 fmappingChannelinRow(new Int_t*[160]),
109 fu2ftestmapping(new Short_t*[7000]),
110 fMapHwFECglobal(new Int_t*[24000]),
111 fecGainMap(new Float_t*[7000])
116 for(Int_t in = 0; in<160; in++)
118 Int_t* hold = new Int_t[150];
119 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
120 fmappingChannelinRow[in]= hold;
123 for(Int_t i = 0; i<7000; i++)
125 Short_t* hold = new Short_t[8];
126 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
127 fu2ftestmapping[i]= hold;
130 for(Int_t i = 0; i<24000; i++)
132 Int_t* hold = new Int_t[2];
133 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
134 fMapHwFECglobal[i]= hold;
137 for(Int_t i = 0; i<7000; i++)
139 Float_t* hold = new Float_t[128];
140 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
147 //____________________________________________________________________________
148 AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
150 // assignment operator
153 fnumofChannels=maphand.fnumofChannels;
154 fmaxHWAdress=maphand.fmaxHWAdress;
155 fsizeofArray=maphand.fsizeofArray;
157 fmapping = new Short_t*[24000]; // empty
160 fmappingChannelinRow = new Int_t*[160];
161 for(Int_t in = 0; in<160; in++)
163 Int_t* hold = new Int_t[150];
164 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
165 fmappingChannelinRow[in]= hold;
168 fu2ftestmapping = new Short_t*[7000];
169 for(Int_t i = 0; i<7000; i++)
171 Short_t* hold = new Short_t[8];
172 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
173 fu2ftestmapping[i]= hold;
176 fMapHwFECglobal = new Int_t*[24000];
177 for(Int_t i = 0; i<24000; i++)
179 Int_t* hold = new Int_t[2];
180 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
181 fMapHwFECglobal[i]= hold;
184 fecGainMap = new Float_t*[7000];
185 for(Int_t i = 0; i<7000; i++)
187 Float_t* hold = new Float_t[128];
188 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
198 //_____________________________________________________________________________________________
199 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
203 for(Int_t i = 0; i < 24000 ; i++) {
204 temp = (Short_t *) fmapping[i];
208 temp = (Short_t *) fmapping;
213 for(Int_t i = 0; i < 24000 ; i++) {
214 temp1 = (Int_t *) fMapHwFECglobal[i];
217 temp1 = (Int_t *) fMapHwFECglobal;
220 for(Int_t i = 0; i < 7000 ; i++) {
221 temp = (Short_t *) fu2ftestmapping[i];
225 temp = (Short_t *) fu2ftestmapping;
228 for(Int_t i = 0; i < 150 ; i++) {
229 temp1= (Int_t *) fmappingChannelinRow[i];
232 temp1 = (Int_t *) fmappingChannelinRow;
236 for(Int_t i = 0; i<7000; i++)
238 temp2= (Float_t *) fecGainMap[i];
241 temp2 = (Float_t *) fecGainMap;
247 //_____________________________________________________________________________________________
248 void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
250 // Read global Mapping file
251 // Format of data in mapping file:
252 // column 0: hadrware address
253 // column 1: readout index in IROC/OROC
254 // column 2: global pad row number (0-158)
255 // column 3 pad number in row
256 // column 4: connector
258 // column 6: fec number in IROC/OROC
259 // column 7: fec channel
260 // column 8: fec connector
261 // column 9: altro channel
262 // column 10: altro chip
264 // Mapping data for a given hardware address are placed at the
265 // index corresponding to the value of the hardware address in
266 // the fmapping array..
267 // The mapping information for the hardware address 'hwaddr'
268 // can hence be found in fmapping[hwaddr]
272 // char readcarry[255];
277 ifstream *in = new ifstream();
280 if (!in->is_open()) return;
284 while ( std::getline(*in, line) )
286 in->seekg(0,ios::beg);
289 // version = atoi(readcarry);
293 // fnumofChannels = atoi(readcarry);
294 *in >> fnumofChannels;
298 // fmaxHWAdress = atoi(readcarry);
300 fsizeofArray = fmaxHWAdress;
304 fnumofChannels=TMath::Abs(fnumofChannels);
305 fnumofChannels=TMath::Min(fnumofChannels,numLines);
307 Short_t *fmappingEmptyRow = new Short_t[11];
308 for(Int_t i = 0; i < 11 ; i++) {
309 fmappingEmptyRow[i] = 0;
311 fmappingEmptyRow[1] = -1;
312 for(Int_t i = 0; i < fnumofChannels ; i++) {
313 mappingRow = new Short_t[11];
314 for(Int_t j = 0 ; j < 11 ; j++) {
316 // mappingRow[j] = atoi(readcarry);
317 *in >> mappingRow[j];
319 actPos = mappingRow[0];
320 fmapping[actPos] = mappingRow;
321 if( (actPos - oldPos) > 1) {
322 for(Int_t j = (oldPos+1); j < actPos; j++) {
323 fmapping[j] = fmappingEmptyRow;
327 fmapping[actPos][0] = i;
333 delete [] fmappingEmptyRow;
336 //_____________________________________________________________________________________________
337 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
339 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
340 // Format in Mapping file
341 // column 0: global card number (set to 0 if card number does not exist)
342 // column 1: side of the TPC
343 // column 2: sector on the side (0-17)
344 // column 3: rcu in the sector (0-5)
345 // column 4: fec number in rcu (0-24)
346 // column 5: fec number in branch (0-12)
347 // column 6: branch number (0,1)
348 // column 7: local hardware address of first channel (not used)
350 // Order of data is kept in fu2ftestmapping
352 ifstream datin(u2ftestfile);
357 for(Int_t ind = 0; ind<7000; ind++)
359 for(Int_t entr = 0; entr<8; entr++)
362 fu2ftestmapping[ind][entr] = carry ;
364 if(entr==0 && carry!=0) ncards++;
372 //_____________________________________________________________________________________________
373 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
375 // Create mapping of global FEC numbers to hardware addresses for a given sector
384 Int_t nextHwAddress = 0;
387 if(sector/18==0) fside =65;
390 if(sector>18) fsector= sector-18;
391 else fsector= sector ;
393 for(Int_t ind = 0; ind<7000; ind++)
395 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
398 fec = U2fGetFECinBranch(ind);
399 branch = U2fGetBranch(ind);
400 rcupatch = U2fGetRCU(ind);
402 for(Int_t ch = 0; ch<128; ch++)
407 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
409 fMapHwFECglobal[nextHwAddress][0] = ind;
410 fMapHwFECglobal[nextHwAddress][1] = ch ;
415 //_____________________________________________________________________________________________
416 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
418 // Read global gain calibration pap
420 // colummn 0 : FEC number
421 // colums 1-128 : gain calibration factors
422 ifstream datin(fecgainmap);
430 for(Int_t in = 0; in<128; in++)
433 fecGainMap[fecnr][in] = val;
438 //_____________________________________________________________________________________________
439 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
441 // Read mapping of hardware addresses in rows
443 // column 0: global row number (0-158)
444 // column 1: number of pads in this row (npads)
445 // column 2-npads: hardware addresses for these pads
448 char readcarry2[256];
449 ifstream *in = new ifstream();
450 in->open(fpathtoMappingRowfile);
452 for(Int_t i = 0; i < 159 ; i++) {
453 *in >> readcarry; // row number
454 *in >> readcarry2; // numof pads
455 fmappingChannelinRow[i][0] = atoi(readcarry2);
456 fmappingChannelinRow[i][1] = atoi(readcarry);
458 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
460 fmappingChannelinRow[i][j] = atoi(readcarry);
468 //_____________________________________________________________________________________________
469 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
471 // Return number of channels
472 return fnumofChannels;
475 //_____________________________________________________________________________________________
476 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
478 // Return sise of global mapping fmapping array.
479 // Value orresponds to max value of hardware addresses
484 //_____________________________________________________________________________________________
485 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)const
487 // Return pointer to mapping array for the hardware address hwaddr
489 if(hwaddr <= fsizeofArray)
490 retval = fmapping[hwaddr];
496 //_____________________________________________________________________________________________
497 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
499 // Return readout index for the hardware address hwaddr
501 if(hwaddr <= fsizeofArray)
502 retval = fmapping[hwaddr][1];
508 //_____________________________________________________________________________________________
509 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
511 // Return global pad row for the hardware address hwaddr
513 if(hwaddr <= fsizeofArray)
514 retval = fmapping[hwaddr][2];
520 //_____________________________________________________________________________________________
521 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
523 // Return pad number in row for the hardware address hwaddr
525 if(hwaddr < fsizeofArray)
526 retval = fmapping[hwaddr][3];
532 //_____________________________________________________________________________________________
533 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
535 // Return connector for the hardware address hwaddr
537 if(hwaddr <= fsizeofArray)
538 retval = fmapping[hwaddr][4];
544 //_____________________________________________________________________________________________
545 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
547 // Return pin for the hardware address hwaddr
549 if(hwaddr <= fsizeofArray)
550 retval = fmapping[hwaddr][5];
556 //_____________________________________________________________________________________________
557 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
559 // Return fec number in IROC/OROC for the hardware address hwaddr
561 if(hwaddr <= fsizeofArray)
562 retval = fmapping[hwaddr][6];
568 //_____________________________________________________________________________________________
569 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
571 // Return FEC channel for the hardware address hwaddr
573 if(hwaddr < fsizeofArray)
574 retval = fmapping[hwaddr][7];
580 //_____________________________________________________________________________________________
581 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
583 // Return FEC connector for the hardware address hwaddr
585 if(hwaddr <= fsizeofArray)
586 retval = fmapping[hwaddr][8];
592 //_____________________________________________________________________________________________
593 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
595 // Return Altro channel for the hardware address hwaddr
597 if(hwaddr <= fsizeofArray)
598 retval = fmapping[hwaddr][9];
604 //_____________________________________________________________________________________________
605 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
607 // Return Altro chip number in FEC for the hardware address hwaddr
609 if(hwaddr <= fsizeofArray)
610 retval = fmapping[hwaddr][10];
617 //_____________________________________________________________________________________________
618 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
620 // Return number of pads in row
622 return fmappingChannelinRow[row][0];
624 AliError("Row number to high");
629 //_____________________________________________________________________________________________
630 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
632 // Return hardware address for given pad in row
634 return fmappingChannelinRow[row][pad+2];
636 AliError("Row number to high");
643 //_____________________________________________________________________________________________
644 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
646 // Return FEC number for index (FEC number should be equal to index)
647 return fu2ftestmapping[index][0];
650 //_____________________________________________________________________________________________
651 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
653 // Return side on which FEC is installed
654 return fu2ftestmapping[fecnr][1];
657 //_____________________________________________________________________________________________
658 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
660 // Return sector in which FEC is installed
661 return fu2ftestmapping[fecnr][2];
664 //_____________________________________________________________________________________________
665 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
667 // Rerurn rcu patch in which FEC is installed
668 return fu2ftestmapping[fecnr][3];
671 //_____________________________________________________________________________________________
672 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
674 // Return index of FEC in RCU (0-25)
675 return fu2ftestmapping[fecnr][4];
678 //_____________________________________________________________________________________________
679 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
681 // Return index of FEC in branch (0-12)
682 return fu2ftestmapping[fecnr][5];
685 //_____________________________________________________________________________________________
686 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
688 // Return branch in which FEC is installed (0,1)
689 return fu2ftestmapping[fecnr][6];