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;
312 //_____________________________________________________________________________________________
313 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
315 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
316 // Format in Mapping file
317 // column 0: global card number (set to 0 if card number does not exist)
318 // column 1: side of the TPC
319 // column 2: sector on the side (0-17)
320 // column 3: rcu in the sector (0-5)
321 // column 4: fec number in rcu (0-24)
322 // column 5: fec number in branch (0-12)
323 // column 6: branch number (0,1)
324 // column 7: local hardware address of first channel (not used)
326 // Order of data is kept in fu2ftestmapping
328 ifstream datin(u2ftestfile);
333 for(Int_t ind = 0; ind<7000; ind++)
335 for(Int_t entr = 0; entr<8; entr++)
338 fu2ftestmapping[ind][entr] = carry ;
340 if(entr==0 && carry!=0) ncards++;
348 //_____________________________________________________________________________________________
349 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
351 // Create mapping of global FEC numbers to hardware addresses for a given sector
360 Int_t nextHwAddress = 0;
363 if(sector/18==0) fside =65;
366 if(sector>18) fsector= sector-18;
367 else fsector= sector ;
369 for(Int_t ind = 0; ind<7000; ind++)
371 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
374 fec = U2fGetFECinBranch(ind);
375 branch = U2fGetBranch(ind);
376 rcupatch = U2fGetRCU(ind);
378 for(Int_t ch = 0; ch<128; ch++)
383 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
385 fMapHwFECglobal[nextHwAddress][0] = ind;
386 fMapHwFECglobal[nextHwAddress][1] = ch ;
391 //_____________________________________________________________________________________________
392 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
394 // Read global gain calibration pap
396 // colummn 0 : FEC number
397 // colums 1-128 : gain calibration factors
398 ifstream datin(fecgainmap);
406 for(Int_t in = 0; in<128; in++)
409 fecGainMap[fecnr][in] = val;
414 //_____________________________________________________________________________________________
415 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
417 // Read mapping of hardware addresses in rows
419 // column 0: global row number (0-158)
420 // column 1: number of pads in this row (npads)
421 // column 2-npads: hardware addresses for these pads
424 char readcarry2[256];
425 ifstream *in = new ifstream();
426 in->open(fpathtoMappingRowfile);
428 for(Int_t i = 0; i < 159 ; i++) {
429 *in >> readcarry; // row number
430 *in >> readcarry2; // numof pads
431 fmappingChannelinRow[i][0] = atoi(readcarry2);
432 fmappingChannelinRow[i][1] = atoi(readcarry);
434 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
436 fmappingChannelinRow[i][j] = atoi(readcarry);
444 //_____________________________________________________________________________________________
445 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
447 // Return number of channels
448 return fnumofChannels;
451 //_____________________________________________________________________________________________
452 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
454 // Return sise of global mapping fmapping array.
455 // Value orresponds to max value of hardware addresses
460 //_____________________________________________________________________________________________
461 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)const
463 // Return pointer to mapping array for the hardware address hwaddr
465 if(hwaddr <= fsizeofArray)
466 retval = fmapping[hwaddr];
472 //_____________________________________________________________________________________________
473 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
475 // Return readout index for the hardware address hwaddr
477 if(hwaddr <= fsizeofArray)
478 retval = fmapping[hwaddr][1];
484 //_____________________________________________________________________________________________
485 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
487 // Return global pad row for the hardware address hwaddr
489 if(hwaddr <= fsizeofArray)
490 retval = fmapping[hwaddr][2];
496 //_____________________________________________________________________________________________
497 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
499 // Return pad number in row for the hardware address hwaddr
501 if(hwaddr < fsizeofArray)
502 retval = fmapping[hwaddr][3];
508 //_____________________________________________________________________________________________
509 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
511 // Return connector for the hardware address hwaddr
513 if(hwaddr <= fsizeofArray)
514 retval = fmapping[hwaddr][4];
520 //_____________________________________________________________________________________________
521 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
523 // Return pin for the hardware address hwaddr
525 if(hwaddr <= fsizeofArray)
526 retval = fmapping[hwaddr][5];
532 //_____________________________________________________________________________________________
533 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
535 // Return fec number in IROC/OROC for the hardware address hwaddr
537 if(hwaddr <= fsizeofArray)
538 retval = fmapping[hwaddr][6];
544 //_____________________________________________________________________________________________
545 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
547 // Return FEC channel for the hardware address hwaddr
549 if(hwaddr < fsizeofArray)
550 retval = fmapping[hwaddr][7];
556 //_____________________________________________________________________________________________
557 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
559 // Return FEC connector for the hardware address hwaddr
561 if(hwaddr <= fsizeofArray)
562 retval = fmapping[hwaddr][8];
568 //_____________________________________________________________________________________________
569 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
571 // Return Altro channel for the hardware address hwaddr
573 if(hwaddr <= fsizeofArray)
574 retval = fmapping[hwaddr][9];
580 //_____________________________________________________________________________________________
581 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
583 // Return Altro chip number in FEC for the hardware address hwaddr
585 if(hwaddr <= fsizeofArray)
586 retval = fmapping[hwaddr][10];
593 //_____________________________________________________________________________________________
594 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
596 // Return number of pads in row
598 return fmappingChannelinRow[row][0];
600 AliError("Row number to high");
605 //_____________________________________________________________________________________________
606 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
608 // Return hardware address for given pad in row
610 return fmappingChannelinRow[row][pad+2];
612 AliError("Row number to high");
619 //_____________________________________________________________________________________________
620 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
622 // Return FEC number for index (FEC number should be equal to index)
623 return fu2ftestmapping[index][0];
626 //_____________________________________________________________________________________________
627 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
629 // Return side on which FEC is installed
630 return fu2ftestmapping[fecnr][1];
633 //_____________________________________________________________________________________________
634 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
636 // Return sector in which FEC is installed
637 return fu2ftestmapping[fecnr][2];
640 //_____________________________________________________________________________________________
641 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
643 // Rerurn rcu patch in which FEC is installed
644 return fu2ftestmapping[fecnr][3];
647 //_____________________________________________________________________________________________
648 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
650 // Return index of FEC in RCU (0-25)
651 return fu2ftestmapping[fecnr][4];
654 //_____________________________________________________________________________________________
655 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
657 // Return index of FEC in branch (0-12)
658 return fu2ftestmapping[fecnr][5];
661 //_____________________________________________________________________________________________
662 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
664 // Return branch in which FEC is installed (0,1)
665 return fu2ftestmapping[fecnr][6];