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 /////////////////////////////////////////////////////////////////////////
46 #include "AliTPCMonitorMappingHandler.h"
50 #include <Riostream.h>
52 ClassImp(AliTPCMonitorMappingHandler)
54 //_____________________________________________________________________________________________
55 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(Char_t* name, Char_t* title):
60 fmapping(new Short_t*[24000]),
61 fmappingChannelinRow(new Int_t*[160]),
62 fu2ftestmapping(new Short_t*[7000]),
63 fMapHwFECglobal(new Int_t*[24000]),
64 fecGainMap(new Float_t*[7000])
66 // Constructor : Initialize mapping arrays
68 for(Int_t in = 0; in<160; in++)
70 Int_t* hold = new Int_t[150];
71 for(Int_t jn = 0; jn<150;jn++) hold[jn]=0;
72 fmappingChannelinRow[in]= hold;
75 for(Int_t i = 0; i<7000; i++)
77 Short_t* hold = new Short_t[8];
78 for(Int_t j = 0; j<8;j++) hold[j]=0;
79 fu2ftestmapping[i]= hold;
82 for(Int_t i = 0; i<24000; i++)
84 Int_t* hold = new Int_t[2];
85 for(Int_t j = 0; j<2;j++) hold[j]=0;
86 fMapHwFECglobal[i]= hold;
90 for(Int_t i = 0; i<7000; i++)
92 Float_t* hold = new Float_t[128];
93 for(Int_t j = 0; j<128;j++) hold[j]=0;
98 //____________________________________________________________________________
99 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
100 TNamed(maphand.GetName(),maphand.GetTitle()),
101 fnumofChannels(maphand.fnumofChannels),
102 fmaxHWAdress(maphand.fmaxHWAdress),
103 fsizeofArray(maphand.fsizeofArray),
104 fmapping(new Short_t*[24000]),
105 fmappingChannelinRow(new Int_t*[160]),
106 fu2ftestmapping(new Short_t*[7000]),
107 fMapHwFECglobal(new Int_t*[24000]),
108 fecGainMap(new Float_t*[7000])
113 for(Int_t in = 0; in<160; in++)
115 Int_t* hold = new Int_t[150];
116 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
117 fmappingChannelinRow[in]= hold;
120 for(Int_t i = 0; i<7000; i++)
122 Short_t* hold = new Short_t[8];
123 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
124 fu2ftestmapping[i]= hold;
127 for(Int_t i = 0; i<24000; i++)
129 Int_t* hold = new Int_t[2];
130 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
131 fMapHwFECglobal[i]= hold;
134 for(Int_t i = 0; i<7000; i++)
136 Float_t* hold = new Float_t[128];
137 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
144 //____________________________________________________________________________
145 AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
147 // assignment operator
150 fnumofChannels=maphand.fnumofChannels;
151 fmaxHWAdress=maphand.fmaxHWAdress;
152 fsizeofArray=maphand.fsizeofArray;
154 fmapping = new Short_t*[24000]; // empty
157 fmappingChannelinRow = new Int_t*[160];
158 for(Int_t in = 0; in<160; in++)
160 Int_t* hold = new Int_t[150];
161 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
162 fmappingChannelinRow[in]= hold;
165 fu2ftestmapping = new Short_t*[7000];
166 for(Int_t i = 0; i<7000; i++)
168 Short_t* hold = new Short_t[8];
169 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
170 fu2ftestmapping[i]= hold;
173 fMapHwFECglobal = new Int_t*[24000];
174 for(Int_t i = 0; i<24000; i++)
176 Int_t* hold = new Int_t[2];
177 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
178 fMapHwFECglobal[i]= hold;
181 fecGainMap = new Float_t*[7000];
182 for(Int_t i = 0; i<7000; i++)
184 Float_t* hold = new Float_t[128];
185 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
195 //_____________________________________________________________________________________________
196 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
200 for(Int_t i = 0; i < 24000 ; i++) {
201 temp = (Short_t *) fmapping[i];
205 temp = (Short_t *) fmapping;
210 for(Int_t i = 0; i < 24000 ; i++) {
211 temp1 = (Int_t *) fMapHwFECglobal[i];
214 temp1 = (Int_t *) fMapHwFECglobal;
217 for(Int_t i = 0; i < 7000 ; i++) {
218 temp = (Short_t *) fu2ftestmapping[i];
222 temp = (Short_t *) fu2ftestmapping;
225 for(Int_t i = 0; i < 150 ; i++) {
226 temp1= (Int_t *) fmappingChannelinRow[i];
229 temp1 = (Int_t *) fmappingChannelinRow;
233 for(Int_t i = 0; i<7000; i++)
235 temp2= (Float_t *) fecGainMap[i];
238 temp2 = (Float_t *) fecGainMap;
244 //_____________________________________________________________________________________________
245 void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
247 // Read global Mapping file
248 // Format of data in mapping file:
249 // column 0: hadrware address
250 // column 1: readout index in IROC/OROC
251 // column 2: global pad row number (0-158)
252 // column 3 pad number in row
253 // column 4: connector
255 // column 6: fec number in IROC/OROC
256 // column 7: fec channel
257 // column 8: fec connector
258 // column 9: altro channel
259 // column 10: altro chip
261 // Mapping data for a given hardware address are placed at the
262 // index corresponding to the value of the hardware address in
263 // the fmapping array..
264 // The mapping information for the hardware address 'hwaddr'
265 // can hence be found in fmapping[hwaddr]
274 ifstream *in = new ifstream();
277 version = atoi(readcarry);
280 fnumofChannels = atoi(readcarry);
282 fmaxHWAdress = atoi(readcarry);
283 fsizeofArray = fmaxHWAdress;
285 Short_t *fmappingEmptyRow = new Short_t[11];
286 for(Int_t i = 0; i < 11 ; i++) {
287 fmappingEmptyRow[i] = 0;
289 fmappingEmptyRow[1] = -1;
290 for(Int_t i = 0; i < fnumofChannels ; i++) {
291 mappingRow = new Short_t[11];
292 for(Int_t j = 0 ; j < 11 ; j++) {
294 mappingRow[j] = atoi(readcarry);
296 actPos = mappingRow[0];
297 fmapping[actPos] = mappingRow;
298 if( (actPos - oldPos) > 1) {
299 for(Int_t j = (oldPos+1); j < actPos; j++) {
300 fmapping[j] = fmappingEmptyRow;
304 fmapping[actPos][0] = i;
311 //_____________________________________________________________________________________________
312 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
314 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
315 // Format in Mapping file
316 // column 0: global card number (set to 0 if card number does not exist)
317 // column 1: side of the TPC
318 // column 2: sector on the side (0-17)
319 // column 3: rcu in the sector (0-5)
320 // column 4: fec number in rcu (0-24)
321 // column 5: fec number in branch (0-12)
322 // column 6: branch number (0,1)
323 // column 7: local hardware address of first channel (not used)
325 // Order of data is kept in fu2ftestmapping
327 ifstream datin(u2ftestfile);
332 for(Int_t ind = 0; ind<7000; ind++)
334 for(Int_t entr = 0; entr<8; entr++)
337 fu2ftestmapping[ind][entr] = carry ;
339 if(entr==0 && carry!=0) ncards++;
347 //_____________________________________________________________________________________________
348 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
350 // Create mapping of global FEC numbers to hardware addresses for a given sector
359 Int_t nextHwAddress = 0;
362 if(sector/18==0) fside =65;
365 if(sector>18) fsector= sector-18;
366 else fsector= sector ;
368 for(Int_t ind = 0; ind<7000; ind++)
370 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
373 fec = U2fGetFECinBranch(ind);
374 branch = U2fGetBranch(ind);
375 rcupatch = U2fGetRCU(ind);
377 for(Int_t ch = 0; ch<128; ch++)
382 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
384 fMapHwFECglobal[nextHwAddress][0] = ind;
385 fMapHwFECglobal[nextHwAddress][1] = ch ;
390 //_____________________________________________________________________________________________
391 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
393 // Read global gain calibration pap
395 // colummn 0 : FEC number
396 // colums 1-128 : gain calibration factors
397 ifstream datin(fecgainmap);
405 for(Int_t in = 0; in<128; in++)
408 fecGainMap[fecnr][in] = val;
413 //_____________________________________________________________________________________________
414 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
416 // Read mapping of hardware addresses in rows
418 // column 0: global row number (0-158)
419 // column 1: number of pads in this row (npads)
420 // column 2-npads: hardware addresses for these pads
423 char readcarry2[256];
424 ifstream *in = new ifstream();
425 in->open(fpathtoMappingRowfile);
427 for(Int_t i = 0; i < 159 ; i++) {
428 *in >> readcarry; // row number
429 *in >> readcarry2; // numof pads
430 fmappingChannelinRow[i][0] = atoi(readcarry2);
431 fmappingChannelinRow[i][1] = atoi(readcarry);
433 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
435 fmappingChannelinRow[i][j] = atoi(readcarry);
443 //_____________________________________________________________________________________________
444 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
446 // Return number of channels
447 return fnumofChannels;
450 //_____________________________________________________________________________________________
451 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
453 // Return sise of global mapping fmapping array.
454 // Value orresponds to max value of hardware addresses
459 //_____________________________________________________________________________________________
460 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)const
462 // Return pointer to mapping array for the hardware address hwaddr
464 if(hwaddr <= fsizeofArray)
465 retval = fmapping[hwaddr];
471 //_____________________________________________________________________________________________
472 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
474 // Return readout index for the hardware address hwaddr
476 if(hwaddr <= fsizeofArray)
477 retval = fmapping[hwaddr][1];
483 //_____________________________________________________________________________________________
484 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
486 // Return global pad row for the hardware address hwaddr
488 if(hwaddr <= fsizeofArray)
489 retval = fmapping[hwaddr][2];
495 //_____________________________________________________________________________________________
496 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
498 // Return pad number in row for the hardware address hwaddr
500 if(hwaddr < fsizeofArray)
501 retval = fmapping[hwaddr][3];
507 //_____________________________________________________________________________________________
508 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
510 // Return connector for the hardware address hwaddr
512 if(hwaddr <= fsizeofArray)
513 retval = fmapping[hwaddr][4];
519 //_____________________________________________________________________________________________
520 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
522 // Return pin for the hardware address hwaddr
524 if(hwaddr <= fsizeofArray)
525 retval = fmapping[hwaddr][5];
531 //_____________________________________________________________________________________________
532 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
534 // Return fec number in IROC/OROC for the hardware address hwaddr
536 if(hwaddr <= fsizeofArray)
537 retval = fmapping[hwaddr][6];
543 //_____________________________________________________________________________________________
544 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
546 // Return FEC channel for the hardware address hwaddr
548 if(hwaddr < fsizeofArray)
549 retval = fmapping[hwaddr][7];
555 //_____________________________________________________________________________________________
556 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
558 // Return FEC connector for the hardware address hwaddr
560 if(hwaddr <= fsizeofArray)
561 retval = fmapping[hwaddr][8];
567 //_____________________________________________________________________________________________
568 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
570 // Return Altro channel for the hardware address hwaddr
572 if(hwaddr <= fsizeofArray)
573 retval = fmapping[hwaddr][9];
579 //_____________________________________________________________________________________________
580 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
582 // Return Altro chip number in FEC for the hardware address hwaddr
584 if(hwaddr <= fsizeofArray)
585 retval = fmapping[hwaddr][10];
592 //_____________________________________________________________________________________________
593 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
595 // Return number of pads in row
597 return fmappingChannelinRow[row][0];
599 AliError("Row number to high");
604 //_____________________________________________________________________________________________
605 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
607 // Return hardware address for given pad in row
609 return fmappingChannelinRow[row][pad+2];
611 AliError("Row number to high");
618 //_____________________________________________________________________________________________
619 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
621 // Return FEC number for index (FEC number should be equal to index)
622 return fu2ftestmapping[index][0];
625 //_____________________________________________________________________________________________
626 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
628 // Return side on which FEC is installed
629 return fu2ftestmapping[fecnr][1];
632 //_____________________________________________________________________________________________
633 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
635 // Return sector in which FEC is installed
636 return fu2ftestmapping[fecnr][2];
639 //_____________________________________________________________________________________________
640 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
642 // Rerurn rcu patch in which FEC is installed
643 return fu2ftestmapping[fecnr][3];
646 //_____________________________________________________________________________________________
647 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
649 // Return index of FEC in RCU (0-25)
650 return fu2ftestmapping[fecnr][4];
653 //_____________________________________________________________________________________________
654 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
656 // Return index of FEC in branch (0-12)
657 return fu2ftestmapping[fecnr][5];
660 //_____________________________________________________________________________________________
661 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
663 // Return branch in which FEC is installed (0,1)
664 return fu2ftestmapping[fecnr][6];