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"
51 #include <Riostream.h>
53 ClassImp(AliTPCMonitorMappingHandler)
55 //_____________________________________________________________________________________________
56 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(Char_t* name, Char_t* title):
61 fmapping(new Short_t*[24000]),
62 fmappingChannelinRow(new Int_t*[160]),
63 fu2ftestmapping(new Short_t*[7000]),
64 fMapHwFECglobal(new Int_t*[24000]),
65 fecGainMap(new Float_t*[7000])
67 // Constructor : Initialize mapping arrays
69 for(Int_t in = 0; in<160; in++)
71 Int_t* hold = new Int_t[150];
72 for(Int_t jn = 0; jn<150;jn++) hold[jn]=0;
73 fmappingChannelinRow[in]= hold;
76 for(Int_t i = 0; i<7000; i++)
78 Short_t* hold = new Short_t[8];
79 for(Int_t j = 0; j<8;j++) hold[j]=0;
80 fu2ftestmapping[i]= hold;
83 for(Int_t i = 0; i<24000; i++)
85 Int_t* hold = new Int_t[2];
86 for(Int_t j = 0; j<2;j++) hold[j]=0;
87 fMapHwFECglobal[i]= hold;
91 for(Int_t i = 0; i<7000; i++)
93 Float_t* hold = new Float_t[128];
94 for(Int_t j = 0; j<128;j++) hold[j]=0;
99 //____________________________________________________________________________
100 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
101 TNamed(maphand.GetName(),maphand.GetTitle()),
102 fnumofChannels(maphand.fnumofChannels),
103 fmaxHWAdress(maphand.fmaxHWAdress),
104 fsizeofArray(maphand.fsizeofArray),
105 fmapping(new Short_t*[24000]),
106 fmappingChannelinRow(new Int_t*[160]),
107 fu2ftestmapping(new Short_t*[7000]),
108 fMapHwFECglobal(new Int_t*[24000]),
109 fecGainMap(new Float_t*[7000])
114 for(Int_t in = 0; in<160; in++)
116 Int_t* hold = new Int_t[150];
117 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
118 fmappingChannelinRow[in]= hold;
121 for(Int_t i = 0; i<7000; i++)
123 Short_t* hold = new Short_t[8];
124 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
125 fu2ftestmapping[i]= hold;
128 for(Int_t i = 0; i<24000; i++)
130 Int_t* hold = new Int_t[2];
131 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
132 fMapHwFECglobal[i]= hold;
135 for(Int_t i = 0; i<7000; i++)
137 Float_t* hold = new Float_t[128];
138 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
145 //____________________________________________________________________________
146 AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
148 // assignment operator
151 fnumofChannels=maphand.fnumofChannels;
152 fmaxHWAdress=maphand.fmaxHWAdress;
153 fsizeofArray=maphand.fsizeofArray;
155 fmapping = new Short_t*[24000]; // empty
158 fmappingChannelinRow = new Int_t*[160];
159 for(Int_t in = 0; in<160; in++)
161 Int_t* hold = new Int_t[150];
162 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
163 fmappingChannelinRow[in]= hold;
166 fu2ftestmapping = new Short_t*[7000];
167 for(Int_t i = 0; i<7000; i++)
169 Short_t* hold = new Short_t[8];
170 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
171 fu2ftestmapping[i]= hold;
174 fMapHwFECglobal = new Int_t*[24000];
175 for(Int_t i = 0; i<24000; i++)
177 Int_t* hold = new Int_t[2];
178 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
179 fMapHwFECglobal[i]= hold;
182 fecGainMap = new Float_t*[7000];
183 for(Int_t i = 0; i<7000; i++)
185 Float_t* hold = new Float_t[128];
186 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
196 //_____________________________________________________________________________________________
197 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
201 for(Int_t i = 0; i < 24000 ; i++) {
202 temp = (Short_t *) fmapping[i];
206 temp = (Short_t *) fmapping;
211 for(Int_t i = 0; i < 24000 ; i++) {
212 temp1 = (Int_t *) fMapHwFECglobal[i];
215 temp1 = (Int_t *) fMapHwFECglobal;
218 for(Int_t i = 0; i < 7000 ; i++) {
219 temp = (Short_t *) fu2ftestmapping[i];
223 temp = (Short_t *) fu2ftestmapping;
226 for(Int_t i = 0; i < 150 ; i++) {
227 temp1= (Int_t *) fmappingChannelinRow[i];
230 temp1 = (Int_t *) fmappingChannelinRow;
234 for(Int_t i = 0; i<7000; i++)
236 temp2= (Float_t *) fecGainMap[i];
239 temp2 = (Float_t *) fecGainMap;
245 //_____________________________________________________________________________________________
246 void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
248 // Read global Mapping file
249 // Format of data in mapping file:
250 // column 0: hadrware address
251 // column 1: readout index in IROC/OROC
252 // column 2: global pad row number (0-158)
253 // column 3 pad number in row
254 // column 4: connector
256 // column 6: fec number in IROC/OROC
257 // column 7: fec channel
258 // column 8: fec connector
259 // column 9: altro channel
260 // column 10: altro chip
262 // Mapping data for a given hardware address are placed at the
263 // index corresponding to the value of the hardware address in
264 // the fmapping array..
265 // The mapping information for the hardware address 'hwaddr'
266 // can hence be found in fmapping[hwaddr]
275 ifstream *in = new ifstream();
278 version = atoi(readcarry);
281 fnumofChannels = atoi(readcarry);
283 fmaxHWAdress = atoi(readcarry);
284 fsizeofArray = fmaxHWAdress;
286 Short_t *fmappingEmptyRow = new Short_t[11];
287 for(Int_t i = 0; i < 11 ; i++) {
288 fmappingEmptyRow[i] = 0;
290 fmappingEmptyRow[1] = -1;
291 for(Int_t i = 0; i < fnumofChannels ; i++) {
292 mappingRow = new Short_t[11];
293 for(Int_t j = 0 ; j < 11 ; j++) {
295 mappingRow[j] = atoi(readcarry);
297 actPos = mappingRow[0];
298 fmapping[actPos] = mappingRow;
299 if( (actPos - oldPos) > 1) {
300 for(Int_t j = (oldPos+1); j < actPos; j++) {
301 fmapping[j] = fmappingEmptyRow;
305 fmapping[actPos][0] = i;
311 delete [] fmappingEmptyRow;
314 //_____________________________________________________________________________________________
315 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
317 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
318 // Format in Mapping file
319 // column 0: global card number (set to 0 if card number does not exist)
320 // column 1: side of the TPC
321 // column 2: sector on the side (0-17)
322 // column 3: rcu in the sector (0-5)
323 // column 4: fec number in rcu (0-24)
324 // column 5: fec number in branch (0-12)
325 // column 6: branch number (0,1)
326 // column 7: local hardware address of first channel (not used)
328 // Order of data is kept in fu2ftestmapping
330 ifstream datin(u2ftestfile);
335 for(Int_t ind = 0; ind<7000; ind++)
337 for(Int_t entr = 0; entr<8; entr++)
340 fu2ftestmapping[ind][entr] = carry ;
342 if(entr==0 && carry!=0) ncards++;
350 //_____________________________________________________________________________________________
351 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
353 // Create mapping of global FEC numbers to hardware addresses for a given sector
362 Int_t nextHwAddress = 0;
365 if(sector/18==0) fside =65;
368 if(sector>18) fsector= sector-18;
369 else fsector= sector ;
371 for(Int_t ind = 0; ind<7000; ind++)
373 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
376 fec = U2fGetFECinBranch(ind);
377 branch = U2fGetBranch(ind);
378 rcupatch = U2fGetRCU(ind);
380 for(Int_t ch = 0; ch<128; ch++)
385 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
387 fMapHwFECglobal[nextHwAddress][0] = ind;
388 fMapHwFECglobal[nextHwAddress][1] = ch ;
393 //_____________________________________________________________________________________________
394 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
396 // Read global gain calibration pap
398 // colummn 0 : FEC number
399 // colums 1-128 : gain calibration factors
400 ifstream datin(fecgainmap);
408 for(Int_t in = 0; in<128; in++)
411 fecGainMap[fecnr][in] = val;
416 //_____________________________________________________________________________________________
417 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
419 // Read mapping of hardware addresses in rows
421 // column 0: global row number (0-158)
422 // column 1: number of pads in this row (npads)
423 // column 2-npads: hardware addresses for these pads
426 char readcarry2[256];
427 ifstream *in = new ifstream();
428 in->open(fpathtoMappingRowfile);
430 for(Int_t i = 0; i < 159 ; i++) {
431 *in >> readcarry; // row number
432 *in >> readcarry2; // numof pads
433 fmappingChannelinRow[i][0] = atoi(readcarry2);
434 fmappingChannelinRow[i][1] = atoi(readcarry);
436 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
438 fmappingChannelinRow[i][j] = atoi(readcarry);
446 //_____________________________________________________________________________________________
447 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
449 // Return number of channels
450 return fnumofChannels;
453 //_____________________________________________________________________________________________
454 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
456 // Return sise of global mapping fmapping array.
457 // Value orresponds to max value of hardware addresses
462 //_____________________________________________________________________________________________
463 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)const
465 // Return pointer to mapping array for the hardware address hwaddr
467 if(hwaddr <= fsizeofArray)
468 retval = fmapping[hwaddr];
474 //_____________________________________________________________________________________________
475 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
477 // Return readout index for the hardware address hwaddr
479 if(hwaddr <= fsizeofArray)
480 retval = fmapping[hwaddr][1];
486 //_____________________________________________________________________________________________
487 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
489 // Return global pad row for the hardware address hwaddr
491 if(hwaddr <= fsizeofArray)
492 retval = fmapping[hwaddr][2];
498 //_____________________________________________________________________________________________
499 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
501 // Return pad number in row for the hardware address hwaddr
503 if(hwaddr < fsizeofArray)
504 retval = fmapping[hwaddr][3];
510 //_____________________________________________________________________________________________
511 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
513 // Return connector for the hardware address hwaddr
515 if(hwaddr <= fsizeofArray)
516 retval = fmapping[hwaddr][4];
522 //_____________________________________________________________________________________________
523 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
525 // Return pin for the hardware address hwaddr
527 if(hwaddr <= fsizeofArray)
528 retval = fmapping[hwaddr][5];
534 //_____________________________________________________________________________________________
535 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
537 // Return fec number in IROC/OROC for the hardware address hwaddr
539 if(hwaddr <= fsizeofArray)
540 retval = fmapping[hwaddr][6];
546 //_____________________________________________________________________________________________
547 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
549 // Return FEC channel for the hardware address hwaddr
551 if(hwaddr < fsizeofArray)
552 retval = fmapping[hwaddr][7];
558 //_____________________________________________________________________________________________
559 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
561 // Return FEC connector for the hardware address hwaddr
563 if(hwaddr <= fsizeofArray)
564 retval = fmapping[hwaddr][8];
570 //_____________________________________________________________________________________________
571 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
573 // Return Altro channel for the hardware address hwaddr
575 if(hwaddr <= fsizeofArray)
576 retval = fmapping[hwaddr][9];
582 //_____________________________________________________________________________________________
583 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
585 // Return Altro chip number in FEC for the hardware address hwaddr
587 if(hwaddr <= fsizeofArray)
588 retval = fmapping[hwaddr][10];
595 //_____________________________________________________________________________________________
596 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
598 // Return number of pads in row
600 return fmappingChannelinRow[row][0];
602 AliError("Row number to high");
607 //_____________________________________________________________________________________________
608 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
610 // Return hardware address for given pad in row
612 return fmappingChannelinRow[row][pad+2];
614 AliError("Row number to high");
621 //_____________________________________________________________________________________________
622 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
624 // Return FEC number for index (FEC number should be equal to index)
625 return fu2ftestmapping[index][0];
628 //_____________________________________________________________________________________________
629 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
631 // Return side on which FEC is installed
632 return fu2ftestmapping[fecnr][1];
635 //_____________________________________________________________________________________________
636 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
638 // Return sector in which FEC is installed
639 return fu2ftestmapping[fecnr][2];
642 //_____________________________________________________________________________________________
643 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
645 // Rerurn rcu patch in which FEC is installed
646 return fu2ftestmapping[fecnr][3];
649 //_____________________________________________________________________________________________
650 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
652 // Return index of FEC in RCU (0-25)
653 return fu2ftestmapping[fecnr][4];
656 //_____________________________________________________________________________________________
657 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
659 // Return index of FEC in branch (0-12)
660 return fu2ftestmapping[fecnr][5];
663 //_____________________________________________________________________________________________
664 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
666 // Return branch in which FEC is installed (0,1)
667 return fu2ftestmapping[fecnr][6];