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;
283 // while ( std::getline(*in, std::string()) )
285 // in->seekg(0,ios::beg);
288 // version = atoi(readcarry);
292 // fnumofChannels = atoi(readcarry);
293 *in >> fnumofChannels;
297 // fmaxHWAdress = atoi(readcarry);
299 fsizeofArray = fmaxHWAdress;
302 // fnumofChannels=TMath::Min(fnumofChannels,numLines);
304 Short_t *fmappingEmptyRow = new Short_t[11];
305 for(Int_t i = 0; i < 11 ; i++) {
306 fmappingEmptyRow[i] = 0;
308 fmappingEmptyRow[1] = -1;
309 for(Int_t i = 0; i < fnumofChannels ; i++) {
310 mappingRow = new Short_t[11];
311 for(Int_t j = 0 ; j < 11 ; j++) {
313 // mappingRow[j] = atoi(readcarry);
314 *in >> mappingRow[j];
316 actPos = mappingRow[0];
317 fmapping[actPos] = mappingRow;
318 if( (actPos - oldPos) > 1) {
319 for(Int_t j = (oldPos+1); j < actPos; j++) {
320 fmapping[j] = fmappingEmptyRow;
324 fmapping[actPos][0] = i;
330 delete [] fmappingEmptyRow;
333 //_____________________________________________________________________________________________
334 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
336 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
337 // Format in Mapping file
338 // column 0: global card number (set to 0 if card number does not exist)
339 // column 1: side of the TPC
340 // column 2: sector on the side (0-17)
341 // column 3: rcu in the sector (0-5)
342 // column 4: fec number in rcu (0-24)
343 // column 5: fec number in branch (0-12)
344 // column 6: branch number (0,1)
345 // column 7: local hardware address of first channel (not used)
347 // Order of data is kept in fu2ftestmapping
349 ifstream datin(u2ftestfile);
354 for(Int_t ind = 0; ind<7000; ind++)
356 for(Int_t entr = 0; entr<8; entr++)
359 fu2ftestmapping[ind][entr] = carry ;
361 if(entr==0 && carry!=0) ncards++;
369 //_____________________________________________________________________________________________
370 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
372 // Create mapping of global FEC numbers to hardware addresses for a given sector
381 Int_t nextHwAddress = 0;
384 if(sector/18==0) fside =65;
387 if(sector>18) fsector= sector-18;
388 else fsector= sector ;
390 for(Int_t ind = 0; ind<7000; ind++)
392 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
395 fec = U2fGetFECinBranch(ind);
396 branch = U2fGetBranch(ind);
397 rcupatch = U2fGetRCU(ind);
399 for(Int_t ch = 0; ch<128; ch++)
404 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
406 fMapHwFECglobal[nextHwAddress][0] = ind;
407 fMapHwFECglobal[nextHwAddress][1] = ch ;
412 //_____________________________________________________________________________________________
413 void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
415 // Read global gain calibration pap
417 // colummn 0 : FEC number
418 // colums 1-128 : gain calibration factors
419 ifstream datin(fecgainmap);
427 for(Int_t in = 0; in<128; in++)
430 fecGainMap[fecnr][in] = val;
435 //_____________________________________________________________________________________________
436 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
438 // Read mapping of hardware addresses in rows
440 // column 0: global row number (0-158)
441 // column 1: number of pads in this row (npads)
442 // column 2-npads: hardware addresses for these pads
445 char readcarry2[256];
446 ifstream *in = new ifstream();
447 in->open(fpathtoMappingRowfile);
449 for(Int_t i = 0; i < 159 ; i++) {
450 *in >> readcarry; // row number
451 *in >> readcarry2; // numof pads
452 fmappingChannelinRow[i][0] = atoi(readcarry2);
453 fmappingChannelinRow[i][1] = atoi(readcarry);
455 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
457 fmappingChannelinRow[i][j] = atoi(readcarry);
465 //_____________________________________________________________________________________________
466 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
468 // Return number of channels
469 return fnumofChannels;
472 //_____________________________________________________________________________________________
473 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
475 // Return sise of global mapping fmapping array.
476 // Value orresponds to max value of hardware addresses
481 //_____________________________________________________________________________________________
482 Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)const
484 // Return pointer to mapping array for the hardware address hwaddr
486 if(hwaddr <= fsizeofArray)
487 retval = fmapping[hwaddr];
493 //_____________________________________________________________________________________________
494 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
496 // Return readout index for the hardware address hwaddr
498 if(hwaddr <= fsizeofArray)
499 retval = fmapping[hwaddr][1];
505 //_____________________________________________________________________________________________
506 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
508 // Return global pad row for the hardware address hwaddr
510 if(hwaddr <= fsizeofArray)
511 retval = fmapping[hwaddr][2];
517 //_____________________________________________________________________________________________
518 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
520 // Return pad number in row for the hardware address hwaddr
522 if(hwaddr < fsizeofArray)
523 retval = fmapping[hwaddr][3];
529 //_____________________________________________________________________________________________
530 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
532 // Return connector for the hardware address hwaddr
534 if(hwaddr <= fsizeofArray)
535 retval = fmapping[hwaddr][4];
541 //_____________________________________________________________________________________________
542 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
544 // Return pin for the hardware address hwaddr
546 if(hwaddr <= fsizeofArray)
547 retval = fmapping[hwaddr][5];
553 //_____________________________________________________________________________________________
554 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
556 // Return fec number in IROC/OROC for the hardware address hwaddr
558 if(hwaddr <= fsizeofArray)
559 retval = fmapping[hwaddr][6];
565 //_____________________________________________________________________________________________
566 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
568 // Return FEC channel for the hardware address hwaddr
570 if(hwaddr < fsizeofArray)
571 retval = fmapping[hwaddr][7];
577 //_____________________________________________________________________________________________
578 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
580 // Return FEC connector for the hardware address hwaddr
582 if(hwaddr <= fsizeofArray)
583 retval = fmapping[hwaddr][8];
589 //_____________________________________________________________________________________________
590 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
592 // Return Altro channel for the hardware address hwaddr
594 if(hwaddr <= fsizeofArray)
595 retval = fmapping[hwaddr][9];
601 //_____________________________________________________________________________________________
602 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
604 // Return Altro chip number in FEC for the hardware address hwaddr
606 if(hwaddr <= fsizeofArray)
607 retval = fmapping[hwaddr][10];
614 //_____________________________________________________________________________________________
615 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
617 // Return number of pads in row
619 return fmappingChannelinRow[row][0];
621 AliError("Row number to high");
626 //_____________________________________________________________________________________________
627 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
629 // Return hardware address for given pad in row
631 return fmappingChannelinRow[row][pad+2];
633 AliError("Row number to high");
640 //_____________________________________________________________________________________________
641 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
643 // Return FEC number for index (FEC number should be equal to index)
644 return fu2ftestmapping[index][0];
647 //_____________________________________________________________________________________________
648 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
650 // Return side on which FEC is installed
651 return fu2ftestmapping[fecnr][1];
654 //_____________________________________________________________________________________________
655 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
657 // Return sector in which FEC is installed
658 return fu2ftestmapping[fecnr][2];
661 //_____________________________________________________________________________________________
662 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
664 // Rerurn rcu patch in which FEC is installed
665 return fu2ftestmapping[fecnr][3];
668 //_____________________________________________________________________________________________
669 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
671 // Return index of FEC in RCU (0-25)
672 return fu2ftestmapping[fecnr][4];
675 //_____________________________________________________________________________________________
676 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
678 // Return index of FEC in branch (0-12)
679 return fu2ftestmapping[fecnr][5];
682 //_____________________________________________________________________________________________
683 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
685 // Return branch in which FEC is installed (0,1)
686 return fu2ftestmapping[fecnr][6];