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>
56 ClassImp(AliTPCMonitorMappingHandler)
58 //_____________________________________________________________________________________________
59 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const Char_t* name, const Char_t* title):
65 // Constructor : Initialize mapping arrays
67 for(Int_t in = 0; in<159; ++in)
68 for(Int_t jn = 0; jn<150; ++jn)
69 fmappingChannelinRow[in][jn] = 0;
71 for(Int_t i = 0; i<7000; ++i){
72 for(Int_t j = 0; j<8; ++j)
73 fu2ftestmapping[i][j] = 0;
75 for(Int_t j = 0; j<128; ++j)
76 fecGainMap[i][j] = 0.;
79 for(Int_t i = 0; i<24000; ++i){
80 for(Int_t j = 0; j<2; ++j)
81 fMapHwFECglobal[i][j]=0;
83 for (Int_t j=0; j<11; ++j)
89 //____________________________________________________________________________
90 AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
91 TNamed(maphand.GetName(),maphand.GetTitle()),
92 fnumofChannels(maphand.fnumofChannels),
93 fmaxHWAdress(maphand.fmaxHWAdress),
94 fsizeofArray(maphand.fsizeofArray)
99 for(Int_t in = 0; in<159; ++in)
100 for(Int_t jn = 0; jn<150; ++jn)
101 fmappingChannelinRow[in][jn] = maphand.fmappingChannelinRow[in][jn];
103 for(Int_t i = 0; i<7000; ++i){
104 for(Int_t j = 0; j<8; ++j)
105 fu2ftestmapping[i][j] = maphand.fu2ftestmapping[i][j];
107 for(Int_t j = 0; j<128; ++j)
108 fecGainMap[i][j] = maphand.fecGainMap[i][j];
111 for(Int_t i = 0; i<24000; ++i){
112 for (Int_t j = 0; j<2; ++j)
113 fMapHwFECglobal[i][j]=maphand.fMapHwFECglobal[i][j];
115 for (Int_t j=0; j<11; ++j)
116 fmapping[i][j] = maphand.fmapping[i][j];
121 //____________________________________________________________________________
122 AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
124 // assignment operator
125 if (this == &maphand) return *this;
127 fnumofChannels=maphand.fnumofChannels;
128 fmaxHWAdress=maphand.fmaxHWAdress;
129 fsizeofArray=maphand.fsizeofArray;
131 for(Int_t in = 0; in<159; ++in)
132 for(Int_t jn = 0; jn<150; ++jn)
133 fmappingChannelinRow[in][jn] = maphand.fmappingChannelinRow[in][jn];
135 for(Int_t i = 0; i<7000; ++i){
136 for(Int_t j = 0; j<8; ++j)
137 fu2ftestmapping[i][j]=maphand.fu2ftestmapping[i][j];
139 for(Int_t j = 0; j<128; ++j)
140 fecGainMap[i][j] = maphand.fecGainMap[i][j];
143 for(Int_t i = 0; i<24000; ++i){
144 for(Int_t j = 0; j<2; ++j)
145 fMapHwFECglobal[i][j] = maphand.fMapHwFECglobal[i][j];
147 for (Int_t j=0; j<11; ++j)
148 fmapping[i][j] = maphand.fmapping[i][j];
155 //_____________________________________________________________________________________________
156 AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
161 //_____________________________________________________________________________________________
162 void AliTPCMonitorMappingHandler::ReadMapping(const char* mapfile)
164 // Read global Mapping file
165 // Format of data in mapping file:
166 // column 0: hadrware address
167 // column 1: readout index in IROC/OROC
168 // column 2: global pad row number (0-158)
169 // column 3 pad number in row
170 // column 4: connector
172 // column 6: fec number in IROC/OROC
173 // column 7: fec channel
174 // column 8: fec connector
175 // column 9: altro channel
176 // column 10: altro chip
178 // Mapping data for a given hardware address are placed at the
179 // index corresponding to the value of the hardware address in
180 // the fmapping array..
181 // The mapping information for the hardware address 'hwaddr'
182 // can hence be found in fmapping[hwaddr]
188 ifstream infile(mapfile,ios::in);
190 // printf("file1: %s\n",mapfile);
191 if (!infile.is_open()) return;
194 // while ( std::getline(infile, line) )
196 // infile.seekg(0,ios::beg);
199 // printf("file: %s - %d\n",mapfile,numLines);
204 infile >> fnumofChannels;
207 infile >> fmaxHWAdress;
208 fsizeofArray = fmaxHWAdress;
212 fnumofChannels=TMath::Abs(fnumofChannels);
213 // fnumofChannels=TMath::Min(fnumofChannels,numLines);
216 for(Int_t i = 0; i < fnumofChannels ; i++) {
220 //set first value of hw address to channel number
221 if (actPos>0 && actPos<24000)
222 fmapping[actPos][0] = (Short_t)i;
224 //loop over channel parameters
225 for(Int_t j = 1 ; j < 11 ; j++) {
227 if (actPos>0 && actPos<24000)
228 fmapping[actPos][j] = (Short_t)val;
235 //_____________________________________________________________________________________________
236 Int_t AliTPCMonitorMappingHandler::ReadFECMapping(const char* u2ftestfile)
238 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
239 // Format in Mapping file
240 // column 0: global card number (set to 0 if card number does not exist)
241 // column 1: side of the TPC
242 // column 2: sector on the side (0-17)
243 // column 3: rcu in the sector (0-5)
244 // column 4: fec number in rcu (0-24)
245 // column 5: fec number in branch (0-12)
246 // column 6: branch number (0,1)
247 // column 7: local hardware address of first channel (not used)
249 // Order of data is kept in fu2ftestmapping
251 ifstream datin(u2ftestfile);
256 for(Int_t ind = 0; ind<7000; ind++) {
257 for(Int_t entr = 0; entr<8; entr++) {
259 fu2ftestmapping[ind][entr] = carry ;
261 if(entr==0 && carry!=0) ncards++;
269 //_____________________________________________________________________________________________
270 void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
272 // Create mapping of global FEC numbers to hardware addresses for a given sector
281 Int_t nextHwAddress = 0;
284 if(sector/18==0) fside =65;
287 if(sector>18) fsector= sector-18;
288 else fsector= sector ;
290 for(Int_t ind = 0; ind<7000; ind++) {
291 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector) {
293 fec = U2fGetFECinBranch(ind);
294 branch = U2fGetBranch(ind);
295 rcupatch = U2fGetRCU(ind);
297 for(Int_t ch = 0; ch<128; ch++) {
301 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
303 if (nextHwAddress<0 || nextHwAddress>=24000) continue;
304 fMapHwFECglobal[nextHwAddress][0] = ind;
305 fMapHwFECglobal[nextHwAddress][1] = ch ;
310 //_____________________________________________________________________________________________
311 void AliTPCMonitorMappingHandler::ReadfecGainMap(const char* fecgainmap)
313 // Read global gain calibration pap
315 // colummn 0 : FEC number
316 // colums 1-128 : gain calibration factors
317 ifstream datin(fecgainmap);
325 for(Int_t in = 0; in<128; in++)
328 if (fecnr<0 || fecnr>=7000) continue;
329 fecGainMap[fecnr][in] = val;
334 //_____________________________________________________________________________________________
335 void AliTPCMonitorMappingHandler::ReadRowMappingGlob(const char* fpathtoMappingRowfile)
337 // Read mapping of hardware addresses in rows
339 // column 0: global row number (0-158)
340 // column 1: number of pads in this row (npads)
341 // column 2-npads: hardware addresses for these pads
345 ifstream in(fpathtoMappingRowfile,ios::in);
347 for(Int_t i = 0; i < 159 ; i++) {
348 in >> readcarry; // row number
349 in >> readcarry2; // numof pads
350 fmappingChannelinRow[i][0] = readcarry2.Atoi();
351 fmappingChannelinRow[i][1] = TMath::Min(TMath::Abs(readcarry.Atoi()),140); //maximum number of pads is 140
353 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
355 fmappingChannelinRow[i][j] = readcarry.Atoi();
363 //_____________________________________________________________________________________________
364 Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
366 // Return number of channels
367 return fnumofChannels;
370 //_____________________________________________________________________________________________
371 Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
373 // Return sise of global mapping fmapping array.
374 // Value orresponds to max value of hardware addresses
379 //_____________________________________________________________________________________________
380 const Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr) const
382 // Return pointer to mapping array for the hardware address hwaddr
383 const Short_t* retval=0x0;
384 if(hwaddr <= fsizeofArray)
385 retval = fmapping[hwaddr];
391 //_____________________________________________________________________________________________
392 Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
394 // Return readout index for the hardware address hwaddr
396 if(hwaddr <= fsizeofArray)
397 retval = fmapping[hwaddr][1];
403 //_____________________________________________________________________________________________
404 Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
406 // Return global pad row for the hardware address hwaddr
408 if(hwaddr <= fsizeofArray)
409 retval = fmapping[hwaddr][2];
415 //_____________________________________________________________________________________________
416 Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
418 // Return pad number in row for the hardware address hwaddr
420 if(hwaddr < fsizeofArray)
421 retval = fmapping[hwaddr][3];
427 //_____________________________________________________________________________________________
428 Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
430 // Return connector for the hardware address hwaddr
432 if(hwaddr <= fsizeofArray)
433 retval = fmapping[hwaddr][4];
439 //_____________________________________________________________________________________________
440 Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
442 // Return pin for the hardware address hwaddr
444 if(hwaddr <= fsizeofArray)
445 retval = fmapping[hwaddr][5];
451 //_____________________________________________________________________________________________
452 Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
454 // Return fec number in IROC/OROC for the hardware address hwaddr
456 if(hwaddr <= fsizeofArray)
457 retval = fmapping[hwaddr][6];
463 //_____________________________________________________________________________________________
464 Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
466 // Return FEC channel for the hardware address hwaddr
468 if(hwaddr < fsizeofArray)
469 retval = fmapping[hwaddr][7];
475 //_____________________________________________________________________________________________
476 Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
478 // Return FEC connector for the hardware address hwaddr
480 if(hwaddr <= fsizeofArray)
481 retval = fmapping[hwaddr][8];
487 //_____________________________________________________________________________________________
488 Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
490 // Return Altro channel for the hardware address hwaddr
492 if(hwaddr <= fsizeofArray)
493 retval = fmapping[hwaddr][9];
499 //_____________________________________________________________________________________________
500 Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
502 // Return Altro chip number in FEC for the hardware address hwaddr
504 if(hwaddr <= fsizeofArray)
505 retval = fmapping[hwaddr][10];
512 //_____________________________________________________________________________________________
513 Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
515 // Return number of pads in row
517 return fmappingChannelinRow[row][0];
519 AliError("Wrong row number");
524 //_____________________________________________________________________________________________
525 Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
527 // Return hardware address for given pad in row
529 return fmappingChannelinRow[row][pad+2];
531 AliError("Wrong row number");
538 //_____________________________________________________________________________________________
539 Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
541 // Return FEC number for index (FEC number should be equal to index)
542 return fu2ftestmapping[index][0];
545 //_____________________________________________________________________________________________
546 Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
548 // Return side on which FEC is installed
549 return fu2ftestmapping[fecnr][1];
552 //_____________________________________________________________________________________________
553 Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
555 // Return sector in which FEC is installed
556 return fu2ftestmapping[fecnr][2];
559 //_____________________________________________________________________________________________
560 Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
562 // Rerurn rcu patch in which FEC is installed
563 return fu2ftestmapping[fecnr][3];
566 //_____________________________________________________________________________________________
567 Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
569 // Return index of FEC in RCU (0-25)
570 return fu2ftestmapping[fecnr][4];
573 //_____________________________________________________________________________________________
574 Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
576 // Return index of FEC in branch (0-12)
577 return fu2ftestmapping[fecnr][5];
580 //_____________________________________________________________________________________________
581 Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
583 // Return branch in which FEC is installed (0,1)
584 return fu2ftestmapping[fecnr][6];