]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSMapper.cxx
Standard logging
[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(), 
29                                        fHw2geomapPtr(0),
30                                        fIsInitializedMapping(false)
31 {
32   InitAltroMapping(); 
33 }
34
35
36 AliHLTPHOSMapper::~AliHLTPHOSMapper()
37 {
38   delete []  fHw2geomapPtr;
39   fHw2geomapPtr = 0;
40 }
41
42 void
43 AliHLTPHOSMapper::InitAltroMapping()
44 {
45   // Loads mapping between Altro addresses and geometrical addresses from file
46
47   //  char filename[256];
48   char *base =  getenv("ALICE_ROOT");
49   int nChannels = 0;
50   int maxaddr = 0;
51   int tmpHwaddr = 0;
52   int tmpZRow = 0;
53   int tmpXCol = 0;
54   int tmpGain = 0;
55
56   if(base !=0)
57     {
58       sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
59       
60       FILE *fp = fopen(fFilepath, "r");
61       if(fp != 0)
62         {
63           fscanf(fp, "%d", &nChannels);
64           fscanf(fp, "%d", &maxaddr);
65           fHw2geomapPtr = new fAltromap[maxaddr +1]; 
66
67           for(int i=0; i< maxaddr + 1 ; i ++)
68             {
69               fHw2geomapPtr[i].fXCol = 0;
70               fHw2geomapPtr[i].fZRow = 0;
71               fHw2geomapPtr[i].fGain = 0;
72             }
73
74           for(int i=0; i<nChannels; i ++)
75             {
76               fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow,  &tmpGain);
77               fHw2geomapPtr[tmpHwaddr].fXCol   = tmpXCol;
78               fHw2geomapPtr[tmpHwaddr].fZRow   = tmpZRow;
79               fHw2geomapPtr[tmpHwaddr].fGain  = tmpGain;
80             }
81           fIsInitializedMapping = true;   
82           fclose(fp);
83         }
84       else
85         {
86           fIsInitializedMapping = false;          
87         }
88     }
89   else
90     {
91       fIsInitializedMapping = false;
92     }
93
94
95
96 bool 
97 AliHLTPHOSMapper::GetIsInitializedMapping()
98 {
99   return  fIsInitializedMapping;
100 }
101
102
103 char* 
104 AliHLTPHOSMapper::GetFilePath()
105 {
106   return  fFilepath;
107 }