]>
Commit | Line | Data |
---|---|---|
2f09efe8 | 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 | #include "AliHLTPHOSMapper.h" | |
20 | ||
21 | AliHLTPHOSMapper::AliHLTPHOSMapper() | |
22 | { | |
23 | // printf("\nCreating new mapper\n"); | |
24 | InitAltroMapping(0); | |
25 | } | |
26 | ||
27 | void | |
28 | AliHLTPHOSMapper::GenerateACL(int startZ, int endZ, int startX, int endX, int modID, int acl[RCUS_PER_MODULE][256], unsigned long int afl[RCUS_PER_MODULE]) | |
29 | { | |
30 | ||
31 | for(int i=0; i<RCUS_PER_MODULE; i++) | |
32 | { | |
33 | for(int j=0; j<256; j++) | |
34 | { | |
35 | acl[i][j] = 0; | |
36 | } | |
37 | } | |
38 | ||
39 | int index; | |
40 | int aclIndex; | |
41 | ||
42 | int rcu = 99; | |
43 | int branch = 99; | |
44 | int card = 99;; | |
45 | int altro = 99; | |
46 | int channel = 99; | |
47 | int csp = 99; | |
48 | ||
49 | for(int i = startZ; i <= endZ; i++) | |
50 | { | |
51 | for(int j = startX; j <= endX; j++) | |
52 | { | |
53 | for(int k = 0; k < PHOS_GAINS; k++) | |
54 | { | |
55 | index = geo2hdw[modID][k][j][i]; | |
56 | rcu = ALTRO_MAP[index].rcu; | |
57 | branch = ALTRO_MAP[index].branch; | |
58 | card = ALTRO_MAP[index].card; | |
59 | altro = ALTRO_MAP[index].chip; | |
60 | channel = ALTRO_MAP[index].chan; | |
61 | csp = ALTRO_MAP[index].csp; | |
62 | ||
63 | if(altro > 0) | |
64 | { | |
65 | altro = altro + 1; //to fix bug in mp | |
66 | } | |
67 | ||
68 | aclIndex = branch*128+(card +1)*8+altro; | |
69 | acl[rcu][aclIndex] = acl[rcu][aclIndex] | 1<<channel; | |
70 | afl[rcu] = (long int)afl[rcu] | (1<< ((long int)(card+1) +(long int)branch*16)); | |
71 | } | |
72 | } | |
73 | } | |
74 | } | |
75 | ||
76 | void | |
77 | AliHLTPHOSMapper::AddCsp(int csp, int chip, int chHi, int chLo, int numHi, int numLo) | |
78 | { | |
79 | // Find row & col by CSP | |
80 | int col = csp / 16; | |
81 | int row = csp % 16; | |
82 | //In 2004 beam test was also: if(row>7)row=23-row; | |
83 | // Check if arguments Ok | |
84 | assert((col>=0)&&(col<2)); | |
85 | assert((row>=0)&&(row<16)); | |
86 | assert((csp>=0)&&(csp<32)); | |
87 | assert((numHi>=0)&&(numHi<64)); | |
88 | assert((numLo>=0)&&(numLo<64)); | |
89 | assert((chHi>=0)&&(chHi<FEE_CHANS)); | |
90 | assert((chLo>=0)&&(chLo<FEE_CHANS)); | |
91 | assert((chip>=0)&&(chip<FEE_ALTROS)); | |
92 | // Fill CSP array | |
93 | CSP_MAP[chip][chHi].row=row; CSP_MAP[chip][chLo].row=row; | |
94 | CSP_MAP[chip][chHi].col=col; CSP_MAP[chip][chLo].col=col; | |
95 | CSP_MAP[chip][chHi].gain=1; CSP_MAP[chip][chLo].gain=0; | |
96 | CSP_MAP[chip][chHi].csp=csp; CSP_MAP[chip][chLo].csp=csp; | |
97 | CSP_MAP[chip][chHi].num=numHi; CSP_MAP[chip][chLo].num=numLo; | |
98 | } | |
99 | ||
100 | ///////////////////////////////////////////////////////////////// | |
101 | // Initialize CSP mapping table. | |
102 | // Note we use (0,1,2,3) instead of (0,2,3,4) ALTRO chip numbers. | |
103 | // So strange numbers we have due to well known RCU firmware bug. | |
104 | ///////////////////////////////////////////////////////////////// | |
105 | void | |
106 | AliHLTPHOSMapper::InitAltroCspMapping() | |
107 | { | |
108 | // T1 csp chip chHi chLo numHi numLo | |
109 | AddCsp( 0, 1, 10, 11, 26, 27); | |
110 | AddCsp( 1, 1, 14, 15, 30, 31); | |
111 | AddCsp( 2, 1, 5, 4, 21, 20); | |
112 | AddCsp( 3, 1, 1, 0, 17, 16); | |
113 | AddCsp( 4, 2, 1, 0, 33, 32); | |
114 | AddCsp( 5, 2, 5, 4, 37, 36); | |
115 | AddCsp( 6, 2, 14, 15, 46, 47); | |
116 | AddCsp( 7, 2, 10, 11, 42, 43); | |
117 | // T2 csp chip chHi chLo numHi numLo | |
118 | AddCsp( 8, 0, 10, 11, 10, 11); | |
119 | AddCsp( 9, 0, 14, 15, 14, 15); | |
120 | AddCsp( 10, 0, 5, 4, 5, 4); | |
121 | AddCsp( 11, 0, 1, 0, 1, 0); | |
122 | AddCsp( 12, 3, 1, 0, 49, 48); | |
123 | AddCsp( 13, 3, 5, 4, 53, 52); | |
124 | AddCsp( 14, 3, 14, 15, 62, 63); | |
125 | AddCsp( 15, 3, 10, 11, 58, 59); | |
126 | // T3 csp chip chHi chLo numHi numLo | |
127 | AddCsp( 16, 1, 8, 9, 24, 25); | |
128 | AddCsp( 17, 1, 12, 13, 28, 29); | |
129 | AddCsp( 18, 1, 7, 6, 23, 22); | |
130 | AddCsp( 19, 1, 3, 2, 19, 18); | |
131 | AddCsp( 20, 2, 3, 2, 35, 34); | |
132 | AddCsp( 21, 2, 7, 6, 39, 38); | |
133 | AddCsp( 22, 2, 12, 13, 44, 45); | |
134 | AddCsp( 23, 2, 8, 9, 40, 41); | |
135 | // T4 csp chip chHi chLo numHi numLo | |
136 | AddCsp( 24, 0, 8, 9, 8, 9); | |
137 | AddCsp( 25, 0, 12, 13, 12, 13); | |
138 | AddCsp( 26, 0, 7, 6, 7, 6); | |
139 | AddCsp( 27, 0, 3, 2, 3, 2); | |
140 | AddCsp( 28, 3, 3, 2, 51, 50); | |
141 | AddCsp( 29, 3, 7, 6, 55, 54); | |
142 | AddCsp( 30, 3, 12, 13, 60, 61); | |
143 | AddCsp( 31, 3, 8, 9, 56, 57); | |
144 | } | |
145 | ||
146 | //void | |
147 | //AliHLTPHOSMapper::GeomToAFL(int startZ, int endZ, int startX, int endX, int rcuZ, int rcuX) | |
148 | //{ | |
149 | // | |
150 | // | |
151 | //} | |
152 | ||
153 | //inline int | |
154 | int | |
155 | AliHLTPHOSMapper::Geo2hid(int mod, int gain, int row, int col) | |
156 | { | |
157 | return mod*100000+gain*10000+row*100+col; | |
158 | } | |
159 | ||
160 | //inline int | |
161 | int | |
162 | AliHLTPHOSMapper::Hid2mod(int hid) | |
163 | { | |
164 | return hid/100000; | |
165 | } | |
166 | ||
167 | ||
168 | //inline int | |
169 | int | |
170 | AliHLTPHOSMapper::Hid2gain(int hid) | |
171 | { | |
172 | return (hid/10000)%10; | |
173 | } | |
174 | ||
175 | //inline int | |
176 | int | |
177 | AliHLTPHOSMapper::Hid2row(int hid) | |
178 | { | |
179 | return (hid/100)%100; | |
180 | } | |
181 | ||
182 | //inline int | |
183 | int | |
184 | AliHLTPHOSMapper::Hid2col(int hid) | |
185 | { | |
186 | return hid%100; | |
187 | } | |
188 | ||
189 | //////////////////////////////////////////////////////////////////////// | |
190 | // ALTRO mapping first time initialization (do it once in startup time). | |
191 | //////////////////////////////////////////////////////////////////////// | |
192 | ||
193 | ||
194 | ||
195 | //inline void | |
196 | //AliHLTPHOSMapper::initAltroMapping(int saveMapping=0) | |
197 | // initAltroMapping(int)' | |
198 | void | |
199 | AliHLTPHOSMapper::InitAltroMapping(int saveMapping) | |
200 | { | |
201 | // | |
202 | // Init CSP mapping first. | |
203 | // | |
204 | InitAltroCspMapping(); | |
205 | // | |
206 | ||
207 | // Clear index arrays | |
208 | // | |
209 | for(int m=0; m<PHOS_MODS; m++) | |
210 | for(int g=0; g<PHOS_GAINS;g++) | |
211 | for(int r=0; r<PHOS_ROWS; r++) | |
212 | for(int c=0; c<PHOS_COLS; c++) | |
213 | { | |
214 | geo2hdw[m][g][r][c]=-1; | |
215 | } | |
216 | ||
217 | for(int m=0; m<PHOS_MODS; m++) | |
218 | for(int r=0; r<FEE_RCUS; r++) | |
219 | for(int b=0; b<FEE_BRANCHS; b++) | |
220 | for(int f=0; f<FEE_FECS; f++) | |
221 | for(int a=0; a<FEE_ALTROS; a++) | |
222 | for(int c=0; c<FEE_CHANS; c++) | |
223 | { | |
224 | hdw2geo[m][r][b][f][a][c]=-1; | |
225 | } | |
226 | // | |
227 | // Fill all FEE cards via formula | |
228 | // | |
229 | int index=0; | |
230 | for(int m=0; m<PHOS_MODS; m++) | |
231 | for(int r=0; r<FEE_RCUS; r++) | |
232 | for(int b=0; b<FEE_BRANCHS; b++) | |
233 | for(int f=0; f<FEE_FECS; f++) | |
234 | for(int a=0; a<FEE_ALTROS; a++) | |
235 | for(int c=0; c<FEE_CHANS; c++) | |
236 | { | |
237 | int row = (r/2)*32 + b*16 + CSP_MAP[a][c].row; | |
238 | int col = (r%2)*28 + f*2 + CSP_MAP[a][c].col; | |
239 | int gain = CSP_MAP[a][c].gain; | |
240 | int csp = CSP_MAP[a][c].csp; | |
241 | int num = CSP_MAP[a][c].num; | |
242 | ALTRO_MAP[index].mod=m; | |
243 | ALTRO_MAP[index].row=row; | |
244 | ALTRO_MAP[index].col=col; | |
245 | ALTRO_MAP[index].gain=gain; | |
246 | ALTRO_MAP[index].rcu=r; | |
247 | ALTRO_MAP[index].branch=b; | |
248 | ALTRO_MAP[index].card=f; | |
249 | ALTRO_MAP[index].chip=a; | |
250 | ALTRO_MAP[index].chan=c; | |
251 | ALTRO_MAP[index].csp=csp; | |
252 | ALTRO_MAP[index].num=num; | |
253 | ALTRO_MAP[index].hid=Geo2hid(m,gain,row,col); | |
254 | hdw2geo[m][r][b][f][a][c]=index; | |
255 | if((row>=0)&&(row<PHOS_ROWS)) | |
256 | if((col>=0)&&(col<PHOS_COLS)) | |
257 | if((gain>=0)&&(gain<PHOS_GAINS)) geo2hdw[m][gain][row][col]=index; | |
258 | index++; | |
259 | } | |
260 | ||
261 | // | |
262 | // Check if geo2hdw map table is filled | |
263 | // | |
264 | for(int m=0; m<PHOS_MODS; m++) | |
265 | for(int g=0; g<PHOS_GAINS;g++) | |
266 | for(int r=0; r<PHOS_ROWS; r++) | |
267 | for(int c=0; c<PHOS_COLS; c++) | |
268 | { | |
269 | assert(geo2hdw[m][g][r][c] >= 0); | |
270 | } | |
271 | // | |
272 | // Check if hdw2geo map table is filled | |
273 | // | |
274 | for(int m=0; m<PHOS_MODS; m++) | |
275 | for(int r=0; r<FEE_RCUS; r++) | |
276 | for(int b=0; b<FEE_BRANCHS; b++) | |
277 | for(int f=0; f<FEE_FECS; f++) | |
278 | for(int a=0; a<FEE_ALTROS; a++) | |
279 | for(int c=0; c<FEE_CHANS; c++) | |
280 | { | |
281 | assert(hdw2geo[m][r][b][f][a][c] >= 0); | |
282 | } | |
283 | } | |
284 | ||
285 | //////////////////////////////////////////////////////////////////////// | |
286 | // Return histogramm id from histogramm name or -1 on error. | |
287 | // extractHid("hMax011426")=11426; | |
288 | //////////////////////////////////////////////////////////////////////// | |
289 | //inline int | |
290 | int | |
291 | AliHLTPHOSMapper::ExtractHid(char *objName){ | |
292 | // char *perr= NULL; | |
293 | char *perr= 0; | |
294 | if(strlen(objName)<7) return -1; | |
295 | int hid=strtol(&objName[strlen(objName)-6],&perr,10); | |
296 | if(strlen(perr))return -1; | |
297 | return hid; | |
298 | } | |
299 | ||
300 | //////////////////////////////////////////////////////////////////////// | |
301 | // Print geometry and hardware information for given histogramm | |
302 | // printHistMapInfo("hMax011426"); | |
303 | // hid mod gain row col rcu bran fee chip chan csp num | |
304 | // 011426 0 1 14 26 0 0 13 3 14 14 62 | |
305 | //////////////////////////////////////////////////////////////////////// | |
306 | //inline void | |
307 | void | |
308 | AliHLTPHOSMapper::PrintHistMapInfo(char *objName){ | |
309 | int hid=ExtractHid(objName); | |
310 | if(hid>=0){ | |
311 | int mod=Hid2mod(hid); | |
312 | int gain=Hid2gain(hid); | |
313 | int row=Hid2row(hid); | |
314 | int col=Hid2col(hid); | |
315 | int index=geo2hdw[mod][gain][row][col]; assert(index>=0); | |
316 | int rcu = ALTRO_MAP[index].rcu; | |
317 | int bran = ALTRO_MAP[index].branch; | |
318 | int fec = ALTRO_MAP[index].card; | |
319 | int chip = ALTRO_MAP[index].chip; | |
320 | int chan = ALTRO_MAP[index].chan; | |
321 | int csp = ALTRO_MAP[index].csp; | |
322 | int num = ALTRO_MAP[index].num; | |
323 | printf("%s attributes:\nhid\tmod\tgain\trow\tcol\trcu\tbran\tfee\tchip\tchan\tcsp\tnum\n",objName); | |
324 | printf("%06d\t%d\t%d\t%02d\t%02d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",hid,mod,gain,row,col,rcu,bran,fec,chip,chan,csp,num); | |
325 | } | |
326 | } |