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>
59 ClassImp(AliTPCMonitorMappingHandler)
61 //_____________________________________________________________________________________________
62 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const Char_t* name, const Char_t* title):
68 // Constructor : Initialize mapping arrays
70 for(Int_t in = 0; in<159; ++in)
71 for(Int_t jn = 0; jn<150; ++jn)
72 fmappingChannelinRow[in][jn] = 0;
74 for(Int_t i = 0; i<7000; ++i){
75 for(Int_t j = 0; j<8; ++j)
76 fu2ftestmapping[i][j] = 0;
78 for(Int_t j = 0; j<128; ++j)
79 fecGainMap[i][j] = 0.;
82 for(Int_t i = 0; i<24000; ++i){
83 for(Int_t j = 0; j<2; ++j)
84 fMapHwFECglobal[i][j]=0;
86 for (Int_t j=0; j<11; ++j)
92 //____________________________________________________________________________
93 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
94 TNamed(maphand.GetName(),maphand.GetTitle()),
95 fnumofChannels(maphand.fnumofChannels),
96 fmaxHWAdress(maphand.fmaxHWAdress),
97 fsizeofArray(maphand.fsizeofArray)
102 for(Int_t in = 0; in<159; ++in)
103 for(Int_t jn = 0; jn<150; ++jn)
104 fmappingChannelinRow[in][jn] = maphand.fmappingChannelinRow[in][jn];
106 for(Int_t i = 0; i<7000; ++i){
107 for(Int_t j = 0; j<8; ++j)
108 fu2ftestmapping[i][j] = maphand.fu2ftestmapping[i][j];
110 for(Int_t j = 0; j<128; ++j)
111 fecGainMap[i][j] = maphand.fecGainMap[i][j];
114 for(Int_t i = 0; i<24000; ++i){
115 for (Int_t j = 0; j<2; ++j)
116 fMapHwFECglobal[i][j]=maphand.fMapHwFECglobal[i][j];
118 for (Int_t j=0; j<11; ++j)
119 fmapping[i][j] = maphand.fmapping[i][j];
124 //____________________________________________________________________________
125 AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
127 // assignment operator
128 if (this == &maphand) return *this;
130 fnumofChannels=maphand.fnumofChannels;
131 fmaxHWAdress=maphand.fmaxHWAdress;
132 fsizeofArray=maphand.fsizeofArray;
134 for(Int_t in = 0; in<159; ++in)
135 for(Int_t jn = 0; jn<150; ++jn)
136 fmappingChannelinRow[in][jn] = maphand.fmappingChannelinRow[in][jn];
138 for(Int_t i = 0; i<7000; ++i){
139 for(Int_t j = 0; j<8; ++j)
140 fu2ftestmapping[i][j]=maphand.fu2ftestmapping[i][j];
142 for(Int_t j = 0; j<128; ++j)
143 fecGainMap[i][j] = maphand.fecGainMap[i][j];
146 for(Int_t i = 0; i<24000; ++i){
147 for(Int_t j = 0; j<2; ++j)
148 fMapHwFECglobal[i][j] = maphand.fMapHwFECglobal[i][j];
150 for (Int_t j=0; j<11; ++j)
151 fmapping[i][j] = maphand.fmapping[i][j];
158 //_____________________________________________________________________________________________
159 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
164 //_____________________________________________________________________________________________
165 void AliTPCMonitorMappingHandler::ReadMapping(const char* mapfile)
167 // Read global Mapping file
168 // Format of data in mapping file:
169 // column 0: hadrware address
170 // column 1: readout index in IROC/OROC
171 // column 2: global pad row number (0-158)
172 // column 3 pad number in row
173 // column 4: connector
175 // column 6: fec number in IROC/OROC
176 // column 7: fec channel
177 // column 8: fec connector
178 // column 9: altro channel
179 // column 10: altro chip
181 // Mapping data for a given hardware address are placed at the
182 // index corresponding to the value of the hardware address in
183 // the fmapping array..
184 // The mapping information for the hardware address 'hwaddr'
185 // can hence be found in fmapping[hwaddr]
191 ifstream infile(mapfile,ios::in);
193 // printf("file1: %s\n",mapfile);
194 if (!infile.is_open()) return;
197 // while ( std::getline(infile, line) )
199 // infile.seekg(0,ios::beg);
202 // printf("file: %s - %d\n",mapfile,numLines);
207 infile >> fnumofChannels;
210 infile >> fmaxHWAdress;
211 fsizeofArray = fmaxHWAdress;
215 fnumofChannels=TMath::Abs(fnumofChannels);
216 // fnumofChannels=TMath::Min(fnumofChannels,numLines);
219 for(Int_t i = 0; i < fnumofChannels ; i++) {
223 //set first value of hw address to channel number
224 if (actPos>0 && actPos<24000)
225 fmapping[actPos][0] = (Short_t)i;
227 //loop over channel parameters
228 for(Int_t j = 1 ; j < 11 ; j++) {
230 if (actPos>0 && actPos<24000)
231 fmapping[actPos][j] = (Short_t)val;
238 //_____________________________________________________________________________________________
239 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(const char* u2ftestfile)
241 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
242 // Format in Mapping file
243 // column 0: global card number (set to 0 if card number does not exist)
244 // column 1: side of the TPC
245 // column 2: sector on the side (0-17)
246 // column 3: rcu in the sector (0-5)
247 // column 4: fec number in rcu (0-24)
248 // column 5: fec number in branch (0-12)
249 // column 6: branch number (0,1)
250 // column 7: local hardware address of first channel (not used)
252 // Order of data is kept in fu2ftestmapping
254 ifstream datin(u2ftestfile);
259 for(Int_t ind = 0; ind<7000; ind++) {
260 for(Int_t entr = 0; entr<8; entr++) {
262 fu2ftestmapping[ind][entr] = carry ;
264 if(entr==0 && carry!=0) ncards++;
272 //_____________________________________________________________________________________________
273 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
275 // Create mapping of global FEC numbers to hardware addresses for a given sector
284 Int_t nextHwAddress = 0;
287 if(sector/18==0) fside =65;
290 if(sector>18) fsector= sector-18;
291 else fsector= sector ;
293 for(Int_t ind = 0; ind<7000; ind++) {
294 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector) {
296 fec = U2fGetFECinBranch(ind);
297 branch = U2fGetBranch(ind);
298 rcupatch = U2fGetRCU(ind);
300 for(Int_t ch = 0; ch<128; ch++) {
304 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
306 if (nextHwAddress<0 || nextHwAddress>=24000) continue;
307 fMapHwFECglobal[nextHwAddress][0] = ind;
308 fMapHwFECglobal[nextHwAddress][1] = ch ;
313 //_____________________________________________________________________________________________
314 void AliTPCMonitorMappingHandler::ReadfecGainMap(const char* fecgainmap)
316 // Read global gain calibration pap
318 // colummn 0 : FEC number
319 // colums 1-128 : gain calibration factors
320 ifstream datin(fecgainmap);
328 for(Int_t in = 0; in<128; in++)
331 if (fecnr<0 || fecnr>=7000) continue;
332 fecGainMap[fecnr][in] = val;
337 //_____________________________________________________________________________________________
338 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(const char* fpathtoMappingRowfile)
340 // Read mapping of hardware addresses in rows
342 // column 0: global row number (0-158)
343 // column 1: number of pads in this row (npads)
344 // column 2-npads: hardware addresses for these pads
348 ifstream in(fpathtoMappingRowfile,ios::in);
350 for(Int_t i = 0; i < 159 ; i++) {
351 in >> readcarry; // row number
352 in >> readcarry2; // numof pads
353 fmappingChannelinRow[i][0] = readcarry2.Atoi();
354 fmappingChannelinRow[i][1] = TMath::Min(TMath::Abs(readcarry.Atoi()),140); //maximum number of pads is 140
356 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
358 fmappingChannelinRow[i][j] = readcarry.Atoi();
366 //_____________________________________________________________________________________________
367 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
369 // Return number of channels
370 return fnumofChannels;
373 //_____________________________________________________________________________________________
374 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
376 // Return sise of global mapping fmapping array.
377 // Value orresponds to max value of hardware addresses
382 //_____________________________________________________________________________________________
383 const Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr) const
385 // Return pointer to mapping array for the hardware address hwaddr
386 const Short_t* retval=0x0;
387 if(hwaddr <= fsizeofArray)
388 retval = fmapping[hwaddr];
394 //_____________________________________________________________________________________________
395 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
397 // Return readout index for the hardware address hwaddr
399 if(hwaddr <= fsizeofArray)
400 retval = fmapping[hwaddr][1];
406 //_____________________________________________________________________________________________
407 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
409 // Return global pad row for the hardware address hwaddr
411 if(hwaddr <= fsizeofArray)
412 retval = fmapping[hwaddr][2];
418 //_____________________________________________________________________________________________
419 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
421 // Return pad number in row for the hardware address hwaddr
423 if(hwaddr < fsizeofArray)
424 retval = fmapping[hwaddr][3];
430 //_____________________________________________________________________________________________
431 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
433 // Return connector for the hardware address hwaddr
435 if(hwaddr <= fsizeofArray)
436 retval = fmapping[hwaddr][4];
442 //_____________________________________________________________________________________________
443 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
445 // Return pin for the hardware address hwaddr
447 if(hwaddr <= fsizeofArray)
448 retval = fmapping[hwaddr][5];
454 //_____________________________________________________________________________________________
455 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
457 // Return fec number in IROC/OROC for the hardware address hwaddr
459 if(hwaddr <= fsizeofArray)
460 retval = fmapping[hwaddr][6];
466 //_____________________________________________________________________________________________
467 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
469 // Return FEC channel for the hardware address hwaddr
471 if(hwaddr < fsizeofArray)
472 retval = fmapping[hwaddr][7];
478 //_____________________________________________________________________________________________
479 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
481 // Return FEC connector for the hardware address hwaddr
483 if(hwaddr <= fsizeofArray)
484 retval = fmapping[hwaddr][8];
490 //_____________________________________________________________________________________________
491 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
493 // Return Altro channel for the hardware address hwaddr
495 if(hwaddr <= fsizeofArray)
496 retval = fmapping[hwaddr][9];
502 //_____________________________________________________________________________________________
503 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
505 // Return Altro chip number in FEC for the hardware address hwaddr
507 if(hwaddr <= fsizeofArray)
508 retval = fmapping[hwaddr][10];
515 //_____________________________________________________________________________________________
516 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
518 // Return number of pads in row
520 return fmappingChannelinRow[row][0];
522 AliError("Wrong row number");
527 //_____________________________________________________________________________________________
528 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
530 // Return hardware address for given pad in row
532 return fmappingChannelinRow[row][pad+2];
534 AliError("Wrong row number");
541 //_____________________________________________________________________________________________
542 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
544 // Return FEC number for index (FEC number should be equal to index)
545 return fu2ftestmapping[index][0];
548 //_____________________________________________________________________________________________
549 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
551 // Return side on which FEC is installed
552 return fu2ftestmapping[fecnr][1];
555 //_____________________________________________________________________________________________
556 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
558 // Return sector in which FEC is installed
559 return fu2ftestmapping[fecnr][2];
562 //_____________________________________________________________________________________________
563 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
565 // Rerurn rcu patch in which FEC is installed
566 return fu2ftestmapping[fecnr][3];
569 //_____________________________________________________________________________________________
570 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
572 // Return index of FEC in RCU (0-25)
573 return fu2ftestmapping[fecnr][4];
576 //_____________________________________________________________________________________________
577 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
579 // Return index of FEC in branch (0-12)
580 return fu2ftestmapping[fecnr][5];
583 //_____________________________________________________________________________________________
584 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
586 // Return branch in which FEC is installed (0,1)
587 return fu2ftestmapping[fecnr][6];