]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCMonitorMappingHandler.cxx
Adding rec.C for test TPC data
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitorMappingHandler.cxx
CommitLineData
48265b32 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17 $Log$
fb3305d1 18 Revision 1.2 2007/10/12 13:36:27 cvetan
19 Coding convention fixes from Stefan
20
ca7b8371 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.
23
48265b32 24*/
25
ca7b8371 26////////////////////////////////////////////////////////////////////////
fb3305d1 27////
28//// AliTPCMonitorMappingHandler class
29////
30//// Class for handling mapping information TPC
31////
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.
38////
39////
40//// Authors: Roland Bramm,
41//// Stefan Kniege, IKF, Frankfurt
42////
ca7b8371 43/////////////////////////////////////////////////////////////////////////
44
45
48265b32 46#include "AliTPCMonitorMappingHandler.h"
ca7b8371 47#include "TH1.h"
48#include "TLegend.h"
49#include "AliLog.h"
50#include <Riostream.h>
51
48265b32 52ClassImp(AliTPCMonitorMappingHandler)
53
54//_____________________________________________________________________________________________
ca7b8371 55AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(Char_t* name, Char_t* title):
56 TNamed(name,title),
57 fnumofChannels(0),
58 fmaxHWAdress(0),
59 fsizeofArray(0),
60 fmapping(new Short_t*[24000]),
61 fmappingChannelinRow(new Int_t*[160]),
62 fu2ftestmapping(new Short_t*[7000]),
63 fMapHwFECglobal(new Int_t*[24000]),
64 fecGainMap(new Float_t*[7000])
48265b32 65{
66 // Constructor : Initialize mapping arrays
67
48265b32 68 for(Int_t in = 0; in<160; in++)
69 {
70 Int_t* hold = new Int_t[150];
71 for(Int_t jn = 0; jn<150;jn++) hold[jn]=0;
72 fmappingChannelinRow[in]= hold;
73 }
74
48265b32 75 for(Int_t i = 0; i<7000; i++)
76 {
77 Short_t* hold = new Short_t[8];
78 for(Int_t j = 0; j<8;j++) hold[j]=0;
79 fu2ftestmapping[i]= hold;
80 }
ca7b8371 81
48265b32 82 for(Int_t i = 0; i<24000; i++)
83 {
84 Int_t* hold = new Int_t[2];
85 for(Int_t j = 0; j<2;j++) hold[j]=0;
86 fMapHwFECglobal[i]= hold;
87 }
88
ca7b8371 89
48265b32 90 for(Int_t i = 0; i<7000; i++)
91 {
92 Float_t* hold = new Float_t[128];
93 for(Int_t j = 0; j<128;j++) hold[j]=0;
94 fecGainMap[i]= hold;
95 }
96}
97
ca7b8371 98//____________________________________________________________________________
99AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
100 TNamed(maphand.GetName(),maphand.GetTitle()),
101 fnumofChannels(maphand.fnumofChannels),
102 fmaxHWAdress(maphand.fmaxHWAdress),
103 fsizeofArray(maphand.fsizeofArray),
104 fmapping(new Short_t*[24000]),
105 fmappingChannelinRow(new Int_t*[160]),
106 fu2ftestmapping(new Short_t*[7000]),
107 fMapHwFECglobal(new Int_t*[24000]),
108 fecGainMap(new Float_t*[7000])
109{
110 // copy constructor
111
112
113 for(Int_t in = 0; in<160; in++)
114 {
115 Int_t* hold = new Int_t[150];
116 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
117 fmappingChannelinRow[in]= hold;
118 }
119
120 for(Int_t i = 0; i<7000; i++)
121 {
122 Short_t* hold = new Short_t[8];
123 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
124 fu2ftestmapping[i]= hold;
125 }
126
127 for(Int_t i = 0; i<24000; i++)
128 {
129 Int_t* hold = new Int_t[2];
130 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
131 fMapHwFECglobal[i]= hold;
132 }
133
134 for(Int_t i = 0; i<7000; i++)
135 {
136 Float_t* hold = new Float_t[128];
137 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
138 fecGainMap[i]= hold;
139 }
140
141}
142
143
144//____________________________________________________________________________
145AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
146{
147 // assignment operator
148 if(this!=&maphand)
149 {
150 fnumofChannels=maphand.fnumofChannels;
151 fmaxHWAdress=maphand.fmaxHWAdress;
152 fsizeofArray=maphand.fsizeofArray;
153
154 fmapping = new Short_t*[24000]; // empty
155
156
157 fmappingChannelinRow = new Int_t*[160];
158 for(Int_t in = 0; in<160; in++)
159 {
160 Int_t* hold = new Int_t[150];
161 for(Int_t jn = 0; jn<150;jn++) hold[jn]=maphand.fmappingChannelinRow[in][jn];
162 fmappingChannelinRow[in]= hold;
163 }
164
165 fu2ftestmapping = new Short_t*[7000];
166 for(Int_t i = 0; i<7000; i++)
167 {
168 Short_t* hold = new Short_t[8];
169 for(Int_t j = 0; j<8;j++) hold[j]=maphand.fu2ftestmapping[i][j];
170 fu2ftestmapping[i]= hold;
171 }
172
173 fMapHwFECglobal = new Int_t*[24000];
174 for(Int_t i = 0; i<24000; i++)
175 {
176 Int_t* hold = new Int_t[2];
177 for(Int_t j = 0; j<2;j++) hold[j]=maphand.fMapHwFECglobal[i][j];
178 fMapHwFECglobal[i]= hold;
179 }
180
181 fecGainMap = new Float_t*[7000];
182 for(Int_t i = 0; i<7000; i++)
183 {
184 Float_t* hold = new Float_t[128];
185 for(Int_t j = 0; j<128;j++) hold[j]=maphand.fecGainMap[i][j];
186 fecGainMap[i]= hold;
187 }
188
189
190 }
191 return *this;
192}
193
194
48265b32 195//_____________________________________________________________________________________________
196AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
197{
198 // Destructor
199 Short_t* temp;
200 for(Int_t i = 0; i < 24000 ; i++) {
201 temp = (Short_t *) fmapping[i];
202 if(temp[1] != -1)
203 delete temp;
204 }
205 temp = (Short_t *) fmapping;
206 delete temp;
207
208
209 Int_t* temp1;
210 for(Int_t i = 0; i < 24000 ; i++) {
211 temp1 = (Int_t *) fMapHwFECglobal[i];
212 delete temp1;
213 }
214 temp1 = (Int_t *) fMapHwFECglobal;
215 delete temp1;
216
217 for(Int_t i = 0; i < 7000 ; i++) {
218 temp = (Short_t *) fu2ftestmapping[i];
219 delete temp;
220 }
221
222 temp = (Short_t *) fu2ftestmapping;
223 delete temp;
224
225 for(Int_t i = 0; i < 150 ; i++) {
226 temp1= (Int_t *) fmappingChannelinRow[i];
227 delete temp1;
228 }
229 temp1 = (Int_t *) fmappingChannelinRow;
230 delete temp1;
231
232 Float_t* temp2;
233 for(Int_t i = 0; i<7000; i++)
234 {
235 temp2= (Float_t *) fecGainMap[i];
236 delete temp2;
237 }
238 temp2 = (Float_t *) fecGainMap;
239 delete temp2;
240
241
242}
243
244//_____________________________________________________________________________________________
245void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
246{
247 // Read global Mapping file
248 // Format of data in mapping file:
249 // column 0: hadrware address
250 // column 1: readout index in IROC/OROC
251 // column 2: global pad row number (0-158)
252 // column 3 pad number in row
253 // column 4: connector
254 // column 5: pin
255 // column 6: fec number in IROC/OROC
256 // column 7: fec channel
257 // column 8: fec connector
258 // column 9: altro channel
259 // column 10: altro chip
260
261 // Mapping data for a given hardware address are placed at the
262 // index corresponding to the value of the hardware address in
263 // the fmapping array..
264 // The mapping information for the hardware address 'hwaddr'
265 // can hence be found in fmapping[hwaddr]
266
267
ca7b8371 268 Short_t* mappingRow;
48265b32 269 char readcarry[255];
270 Int_t version = -1;
271 Int_t actPos = 0;
272 Int_t oldPos = 0;
273
274 ifstream *in = new ifstream();
275 in->open(mapfile);
276 *in >> readcarry;
277 version = atoi(readcarry);
278
279 *in >> readcarry;
280 fnumofChannels = atoi(readcarry);
281 *in >> readcarry;
282 fmaxHWAdress = atoi(readcarry);
283 fsizeofArray = fmaxHWAdress;
284
285 Short_t *fmappingEmptyRow = new Short_t[11];
286 for(Int_t i = 0; i < 11 ; i++) {
287 fmappingEmptyRow[i] = 0;
288 }
289 fmappingEmptyRow[1] = -1;
290 for(Int_t i = 0; i < fnumofChannels ; i++) {
ca7b8371 291 mappingRow = new Short_t[11];
48265b32 292 for(Int_t j = 0 ; j < 11 ; j++) {
293 *in >> readcarry;
ca7b8371 294 mappingRow[j] = atoi(readcarry);
48265b32 295 }
ca7b8371 296 actPos = mappingRow[0];
297 fmapping[actPos] = mappingRow;
48265b32 298 if( (actPos - oldPos) > 1) {
299 for(Int_t j = (oldPos+1); j < actPos; j++) {
300 fmapping[j] = fmappingEmptyRow;
301 }
302 }
303 oldPos = actPos;
304 fmapping[actPos][0] = i;
305 }
306
307 in->close();
308 delete in;
309}
310
311//_____________________________________________________________________________________________
312Int_t AliTPCMonitorMappingHandler::ReadFECMapping(char* u2ftestfile)
313{
314 // Read in Mapping of global FEC numbers to branches, rcu patches etc.
315 // Format in Mapping file
316 // column 0: global card number (set to 0 if card number does not exist)
317 // column 1: side of the TPC
318 // column 2: sector on the side (0-17)
319 // column 3: rcu in the sector (0-5)
320 // column 4: fec number in rcu (0-24)
321 // column 5: fec number in branch (0-12)
322 // column 6: branch number (0,1)
323 // column 7: local hardware address of first channel (not used)
324
325 // Order of data is kept in fu2ftestmapping
326
327 ifstream datin(u2ftestfile);
328
329 Int_t carry = 0;
330 Int_t ncards = 0;
331
332 for(Int_t ind = 0; ind<7000; ind++)
333 {
334 for(Int_t entr = 0; entr<8; entr++)
335 {
336 datin >> carry ;
337 fu2ftestmapping[ind][entr] = carry ;
338
339 if(entr==0 && carry!=0) ncards++;
340 }
341 }
342 return ncards ;
343}
344
345
346
347//_____________________________________________________________________________________________
348void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
349{
350 // Create mapping of global FEC numbers to hardware addresses for a given sector
351
352 Int_t fside =0;
353 Int_t fsector = 0;
354 Int_t fec = 0;
355 Int_t branch = 0;
fb3305d1 356 Int_t rcupatch = 0;
48265b32 357 Int_t altrchann = 0;
358 Int_t altrchip = 0;
359 Int_t nextHwAddress = 0;
360 Int_t nfecs = 0;
361
362 if(sector/18==0) fside =65;
363 else fside =67;
364
365 if(sector>18) fsector= sector-18;
366 else fsector= sector ;
367
368 for(Int_t ind = 0; ind<7000; ind++)
369 {
370 if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector)
371 {
372 nfecs++;
373 fec = U2fGetFECinBranch(ind);
374 branch = U2fGetBranch(ind);
fb3305d1 375 rcupatch = U2fGetRCU(ind);
48265b32 376
377 for(Int_t ch = 0; ch<128; ch++)
378 {
379 altrchann = ch%16;
380 altrchip = ch/16;
381
fb3305d1 382 nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
48265b32 383
384 fMapHwFECglobal[nextHwAddress][0] = ind;
385 fMapHwFECglobal[nextHwAddress][1] = ch ;
386 }
387 }
388 }
389}
390//_____________________________________________________________________________________________
391void AliTPCMonitorMappingHandler::ReadfecGainMap(char* fecgainmap)
392{
393 // Read global gain calibration pap
394 // Format in file :
395 // colummn 0 : FEC number
396 // colums 1-128 : gain calibration factors
397 ifstream datin(fecgainmap);
398
399 Int_t fecnr = 0;
400 Float_t val = 0.0 ;
401
402 while(!datin.eof())
403 {
404 datin >> fecnr ;
405 for(Int_t in = 0; in<128; in++)
406 {
407 datin >> val ;
408 fecGainMap[fecnr][in] = val;
409 }
410 }
411}
412
413//_____________________________________________________________________________________________
414void AliTPCMonitorMappingHandler::ReadRowMappingGlob(char* fpathtoMappingRowfile)
415{
416 // Read mapping of hardware addresses in rows
417 // Format of file:
418 // column 0: global row number (0-158)
419 // column 1: number of pads in this row (npads)
420 // column 2-npads: hardware addresses for these pads
421
422 char readcarry[256];
423 char readcarry2[256];
424 ifstream *in = new ifstream();
425 in->open(fpathtoMappingRowfile);
426
427 for(Int_t i = 0; i < 159 ; i++) {
428 *in >> readcarry; // row number
429 *in >> readcarry2; // numof pads
430 fmappingChannelinRow[i][0] = atoi(readcarry2);
431 fmappingChannelinRow[i][1] = atoi(readcarry);
432
433 for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
434 *in >> readcarry;
435 fmappingChannelinRow[i][j] = atoi(readcarry);
436 }
437 }
438 in->close();
439}
440
441
442
443//_____________________________________________________________________________________________
fb3305d1 444Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
48265b32 445{
446 // Return number of channels
447 return fnumofChannels;
448}
449
450//_____________________________________________________________________________________________
fb3305d1 451Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
48265b32 452{
453 // Return sise of global mapping fmapping array.
454 // Value orresponds to max value of hardware addresses
455 return fsizeofArray;
456}
457
458
459//_____________________________________________________________________________________________
fb3305d1 460Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr)const
48265b32 461{
462 // Return pointer to mapping array for the hardware address hwaddr
463 Short_t* retval;
464 if(hwaddr <= fsizeofArray)
465 retval = fmapping[hwaddr];
466 else
467 retval = 0;
468 return retval;
469}
470
471//_____________________________________________________________________________________________
fb3305d1 472Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
48265b32 473{
474 // Return readout index for the hardware address hwaddr
475 Int_t retval;
476 if(hwaddr <= fsizeofArray)
477 retval = fmapping[hwaddr][1];
478 else
479 retval = 0;
480 return retval;
481}
482
483//_____________________________________________________________________________________________
fb3305d1 484Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
48265b32 485{
486 // Return global pad row for the hardware address hwaddr
487 Int_t retval;
488 if(hwaddr <= fsizeofArray)
489 retval = fmapping[hwaddr][2];
490 else
491 retval = 0;
492 return retval;
493}
494
495//_____________________________________________________________________________________________
fb3305d1 496Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
48265b32 497{
498 // Return pad number in row for the hardware address hwaddr
499 Int_t retval;
500 if(hwaddr < fsizeofArray)
501 retval = fmapping[hwaddr][3];
502 else
503 retval = 0;
504 return retval;
505}
506
507//_____________________________________________________________________________________________
fb3305d1 508Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
48265b32 509{
510 // Return connector for the hardware address hwaddr
511 Int_t retval;
512 if(hwaddr <= fsizeofArray)
513 retval = fmapping[hwaddr][4];
514 else
515 retval = 0;
516 return retval;
517}
518
519//_____________________________________________________________________________________________
fb3305d1 520Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
48265b32 521{
522 // Return pin for the hardware address hwaddr
523 Int_t retval;
524 if(hwaddr <= fsizeofArray)
525 retval = fmapping[hwaddr][5];
526 else
527 retval = 0;
528 return retval;
529}
530
531//_____________________________________________________________________________________________
fb3305d1 532Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
48265b32 533{
534 // Return fec number in IROC/OROC for the hardware address hwaddr
535 Int_t retval;
536 if(hwaddr <= fsizeofArray)
537 retval = fmapping[hwaddr][6];
538 else
539 retval = 0;
540 return retval;
541}
542
543//_____________________________________________________________________________________________
fb3305d1 544Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
48265b32 545{
546 // Return FEC channel for the hardware address hwaddr
547 Int_t retval;
548 if(hwaddr < fsizeofArray)
549 retval = fmapping[hwaddr][7];
550 else
551 retval = 0;
552 return retval;
553}
554
555//_____________________________________________________________________________________________
fb3305d1 556Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
48265b32 557{
558 // Return FEC connector for the hardware address hwaddr
559 Int_t retval;
560 if(hwaddr <= fsizeofArray)
561 retval = fmapping[hwaddr][8];
562 else
563 retval = 0;
564 return retval;
565}
566
567//_____________________________________________________________________________________________
fb3305d1 568Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
48265b32 569{
570 // Return Altro channel for the hardware address hwaddr
571 Int_t retval;
572 if(hwaddr <= fsizeofArray)
573 retval = fmapping[hwaddr][9];
574 else
575 retval = 0;
576 return retval;
577}
578
579//_____________________________________________________________________________________________
fb3305d1 580Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
48265b32 581{
582 // Return Altro chip number in FEC for the hardware address hwaddr
583 Int_t retval;
584 if(hwaddr <= fsizeofArray)
585 retval = fmapping[hwaddr][10];
586 else
587 retval = 0;
588 return retval;
589}
590
591
592//_____________________________________________________________________________________________
fb3305d1 593Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
48265b32 594{
595 // Return number of pads in row
596 if(row<159)
597 return fmappingChannelinRow[row][0];
598 else {
599 AliError("Row number to high");
600 return 0;
601 }
602}
603
604//_____________________________________________________________________________________________
605Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
606{
607 // Return hardware address for given pad in row
608 if(row<159)
609 return fmappingChannelinRow[row][pad+2];
610 else {
611 AliError("Row number to high");
612 return 0;
613 }
614}
615
616
617
618//_____________________________________________________________________________________________
fb3305d1 619Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
48265b32 620{
621 // Return FEC number for index (FEC number should be equal to index)
622 return fu2ftestmapping[index][0];
623}
624
625//_____________________________________________________________________________________________
fb3305d1 626Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
48265b32 627{
628 // Return side on which FEC is installed
629 return fu2ftestmapping[fecnr][1];
630}
631
632//_____________________________________________________________________________________________
fb3305d1 633Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
48265b32 634{
635 // Return sector in which FEC is installed
636 return fu2ftestmapping[fecnr][2];
637}
638
639//_____________________________________________________________________________________________
fb3305d1 640Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
48265b32 641{
642 // Rerurn rcu patch in which FEC is installed
643 return fu2ftestmapping[fecnr][3];
644}
645
646//_____________________________________________________________________________________________
fb3305d1 647Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
48265b32 648{
649 // Return index of FEC in RCU (0-25)
650 return fu2ftestmapping[fecnr][4];
651}
652
653//_____________________________________________________________________________________________
fb3305d1 654Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
48265b32 655{
656 // Return index of FEC in branch (0-12)
657 return fu2ftestmapping[fecnr][5];
658}
659
660//_____________________________________________________________________________________________
fb3305d1 661Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
48265b32 662{
663 // Return branch in which FEC is installed (0,1)
664 return fu2ftestmapping[fecnr][6];
665
666}