]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSMapper.cxx
Coding conventions
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSMapper.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the Experimental Nuclear     *
3  * Physics Group, Dep. of Physics                                         *
4  * University of Oslo, Norway, 2006                                       *
5  *                                                                        * 
6  * Author: Per Thomas Hille perthi@fys.uio.no for the ALICE DCS Project.  *
7  * Contributors are mentioned in the code where appropriate.              *
8  * Please report bugs to perthi@fys.uio.no                                * 
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 //
20 // Mapping class fro mapping
21 // from hardware address to geometrical address
22 //
23 //
24
25 #include "AliHLTPHOSMapper.h"
26
27
28 AliHLTPHOSMapper::AliHLTPHOSMapper() : AliHLTPHOSBase(), fHw2geomapPtr(0)
29 {
30   //  printf("\nCreating new mapper\n");
31   InitAltroMapping(); 
32 }
33
34
35 AliHLTPHOSMapper::~AliHLTPHOSMapper()
36 {
37   
38 }
39
40 void
41 AliHLTPHOSMapper::InitAltroMapping()
42 {
43   // Loads mapping between Altro addresses and geometrical addresses from file
44
45   char filename[256];
46   char *base =  getenv("ALICE_ROOT");
47   int nChannels = 0;
48   int maxaddr = 0;
49   int tmpHwaddr = 0;
50   int tmpZRow = 0;
51   int tmpXCol = 0;
52   int tmpGain = 0;
53
54   if(base !=0)
55     {
56       sprintf(filename,"%s/PHOS/mapping/RCU0.data", base);
57
58       FILE *fp = fopen(filename, "r");
59       if(fp != 0)
60         {
61           cout << "mapping file found" << endl;
62           fscanf(fp, "%d", &nChannels);
63           fscanf(fp, "%d", &maxaddr);
64           printf("nChannels = %d", nChannels);
65           printf("maxaddr = %d", maxaddr);
66           fHw2geomapPtr = new fAltromap[maxaddr +1]; 
67
68           for(int i=0; i< maxaddr + 1 ; i ++)
69             {
70               fHw2geomapPtr[i].fXCol = 0;
71               fHw2geomapPtr[i].fZRow = 0;
72               fHw2geomapPtr[i].fGain = 0;
73             }
74
75           for(int i=0; i<nChannels; i ++)
76             {
77               fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow,  &tmpGain);
78               fHw2geomapPtr[tmpHwaddr].fXCol   = tmpXCol;
79               fHw2geomapPtr[tmpHwaddr].fZRow   = tmpZRow;
80               fHw2geomapPtr[tmpHwaddr].fGain  = tmpGain;
81             }
82           
83         }
84       else
85         {
86           cout << "ERROR could not find mapping file" << endl;
87         }
88
89     }
90   else
91     {
92       printf("AliHLTPHOSMapper::InitAltroMapping(), ERROR environment ALICE_ROOT is not set, cannot find mapping file");
93     }
94
95
96