]>
Commit | Line | Data |
---|---|---|
88b2ce82 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the Experimental Nuclear * | |
3 | * Physics Group, Dep. of Physics * | |
4 | * University of Oslo, Norway, 2007 * | |
5 | * * | |
6 | * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT 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 | #include "AliHLTEMCALMapper.h" | |
19 | ||
20 | #include "AliHLTEMCALConstants.h" | |
21 | ||
22 | using namespace EmcalHLTConst; | |
23 | ||
24 | //AliHLTCaloMapper | |
25 | ||
26 | AliHLTEMCALMapper::AliHLTEMCALMapper() | |
27 | { | |
28 | InitAltroMapping(); | |
29 | InitDDLSpecificationMapping(); | |
30 | fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok | |
31 | } | |
32 | ||
33 | AliHLTEMCALMapper::~AliHLTEMCALMapper() | |
34 | { | |
35 | ||
36 | } | |
37 | ||
38 | ||
39 | ||
40 | void | |
41 | AliHLTEMCALMapper::InitAltroMapping() | |
42 | { | |
43 | // Loads mapping between Altro addresses and geometrical addresses from file | |
44 | // char filename[256]; | |
45 | char *base = getenv("ALICE_ROOT"); | |
46 | int nChannels = 0; | |
47 | int maxaddr = 0; | |
48 | int tmpHwaddr = 0; | |
49 | int tmpZRow = 0; | |
50 | int tmpXCol = 0; | |
51 | int tmpGain = 0; | |
52 | int res = 0; | |
53 | ||
54 | if(base !=0) | |
55 | { | |
56 | sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base); | |
57 | FILE *fp = fopen(fFilepath, "r"); | |
58 | if(fp != 0) | |
59 | { | |
60 | res = fscanf(fp, "%d", &nChannels); | |
61 | res = fscanf(fp, "%d", &maxaddr); | |
62 | fHw2geomapPtr = new fAltromap[maxaddr +1]; | |
63 | ||
64 | for(int i=0; i< maxaddr + 1 ; i ++) | |
65 | { | |
66 | fHw2geomapPtr[i].fXCol = 0; | |
67 | fHw2geomapPtr[i].fZRow = 0; | |
68 | fHw2geomapPtr[i].fGain = 0; | |
69 | } | |
70 | for(int i=0; i<nChannels; i ++) | |
71 | { | |
72 | res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain); | |
73 | if(tmpGain < 2) | |
74 | { | |
75 | fHw2geomapPtr[tmpHwaddr].fXCol = tmpXCol; | |
76 | fHw2geomapPtr[tmpHwaddr].fZRow = tmpZRow; | |
77 | fHw2geomapPtr[tmpHwaddr].fGain = tmpGain; | |
78 | } | |
79 | } | |
80 | fIsInitializedMapping = true; | |
81 | fclose(fp); | |
82 | } | |
83 | else | |
84 | { | |
85 | fIsInitializedMapping = false; | |
86 | } | |
87 | } | |
88 | else | |
89 | { | |
90 | fIsInitializedMapping = false; | |
91 | } | |
92 | ||
93 | ||
94 | } | |
95 | ||
96 | ||
97 | void | |
98 | AliHLTEMCALMapper::InitDDLSpecificationMapping() | |
99 | { | |
100 | fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE]; | |
101 | ||
102 | for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++) | |
103 | { | |
104 | ||
105 | fSpecificationMapPtr[ddl].fModId = ddl/EmcalHLTConst::NRCUSPERMODULE; | |
106 | ||
107 | if(ddl%4 == 0) | |
108 | { | |
109 | fSpecificationMapPtr[ddl].fRcuX = 0; | |
110 | fSpecificationMapPtr[ddl].fRcuZ = 0; | |
111 | } | |
112 | ||
113 | else if(ddl%4 == 1) | |
114 | { | |
115 | fSpecificationMapPtr[ddl].fRcuX = 1; | |
116 | fSpecificationMapPtr[ddl].fRcuZ = 0; | |
117 | } | |
118 | ||
119 | else if( ddl%4 == 2) | |
120 | { | |
121 | fSpecificationMapPtr[ddl].fRcuX = 2; | |
122 | fSpecificationMapPtr[ddl].fRcuZ = 0; | |
123 | } | |
124 | else | |
125 | { | |
126 | fSpecificationMapPtr[ddl].fRcuX = 3; | |
127 | fSpecificationMapPtr[ddl].fRcuZ = 0; | |
128 | } | |
129 | ||
130 | fSpecificationMapPtr[ddl].fRcuZOffset = NZROWSRCU*(fSpecificationMapPtr[ddl].fRcuZ); | |
131 | fSpecificationMapPtr[ddl].fRcuXOffset = NXCOLUMNSRCU*(fSpecificationMapPtr[ddl].fRcuX); | |
132 | } | |
133 | } | |
134 | ||
135 | ||
136 | const int | |
137 | AliHLTEMCALMapper::GetDDLFromSpec( const AliHLTUInt32_t specification ) | |
138 | { | |
139 | Int_t index = -1; | |
140 | if(specification == 0x00001) index = 0; | |
141 | else if(specification == 0x00002) index = 1; | |
142 | else if(specification == 0x00004) index = 2; | |
143 | else if(specification == 0x00008) index = 3; | |
144 | ||
145 | else if(specification == 0x00010) index = 4; | |
146 | else if(specification == 0x00020) index = 5; | |
147 | else if(specification == 0x00040) index = 6; | |
148 | else if(specification == 0x00080) index = 7; | |
149 | ||
150 | else if(specification == 0x00100) index = 8; | |
151 | else if(specification == 0x00200) index = 9; | |
152 | else if(specification == 0x00400) index = 10; | |
153 | else if(specification == 0x00800) index = 11; | |
154 | ||
155 | else if(specification == 0x01000) index = 12; | |
156 | else if(specification == 0x02000) index = 13; | |
157 | else if(specification == 0x04000) index = 14; | |
158 | else if(specification == 0x08000) index = 15; | |
159 | ||
160 | else if(specification == 0x10000) index = 16; | |
161 | else if(specification == 0x20000) index = 17; | |
162 | else if(specification == 0x40000) index = 18; | |
163 | else if(specification == 0x80000) index = 19; | |
164 | ||
165 | else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification); | |
166 | ||
167 | return index; | |
168 | } | |
169 | ||
170 | ||
171 | const int | |
172 | AliHLTEMCALMapper::GetChannelID(const AliHLTUInt32_t specification, const Int_t hwAddress ) | |
173 | { | |
174 | //Short_t index = 0; | |
175 | ||
176 | Short_t index = GetDDLFromSpec( specification); | |
177 | ||
178 | if(index < 0) | |
179 | { | |
180 | HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification); | |
181 | } | |
182 | ||
183 | // else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification); | |
184 | ||
185 | return ((fHw2geomapPtr[hwAddress].fXCol + fSpecificationMapPtr[index].fRcuXOffset) | | |
186 | ((fHw2geomapPtr[hwAddress].fZRow + fSpecificationMapPtr[index].fRcuZOffset) << 6) | | |
187 | (fHw2geomapPtr[hwAddress].fGain << 12) | | |
188 | fSpecificationMapPtr[index].fModId << 13); | |
189 | } |