]>
Commit | Line | Data |
---|---|---|
1605abc6 | 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 | * author: Roberto Preghenella (R+), Roberto.Preghenella@bo.infn.it | |
18 | */ | |
19 | ||
20 | ////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // // | |
23 | // This class provides the TOF FEE reader. // | |
24 | // // | |
25 | // // | |
26 | ////////////////////////////////////////////////////////////////////// | |
27 | ||
5b086af5 | 28 | #include <TSystem.h> |
1605abc6 | 29 | #include "AliTOFFEEReader.h" |
30 | #include "AliTOFFEEConfig.h" | |
31 | #include "AliTOFRawStream.h" | |
39dff6a4 | 32 | #include "AliTOFGeometry.h" |
1605abc6 | 33 | #include "AliLog.h" |
34 | #include <fstream> | |
35 | ||
36 | ClassImp(AliTOFFEEReader) | |
37 | ||
38 | //_______________________________________________________________ | |
39 | ||
40 | AliTOFFEEReader::AliTOFFEEReader() : | |
41 | TObject(), | |
42 | fFEEConfig(new AliTOFFEEConfig()), | |
b059882a | 43 | fChannelEnabled(), |
44 | fMatchingWindow() | |
1605abc6 | 45 | { |
46 | /* | |
47 | * | |
48 | * default constructor | |
49 | * | |
50 | */ | |
51 | ||
b059882a | 52 | Reset(); |
1605abc6 | 53 | } |
54 | ||
55 | //_______________________________________________________________ | |
56 | ||
57 | AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) : | |
58 | TObject(source), | |
59 | fFEEConfig(new AliTOFFEEConfig()) | |
60 | { | |
61 | /* | |
62 | * | |
63 | * copy constructor | |
64 | * | |
65 | */ | |
66 | ||
67 | memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig)); | |
68 | } | |
69 | ||
70 | //_______________________________________________________________ | |
71 | ||
72 | AliTOFFEEReader & | |
73 | AliTOFFEEReader::operator=(const AliTOFFEEReader &source) | |
74 | { | |
75 | /* | |
76 | * | |
77 | * operator = | |
78 | * | |
79 | */ | |
80 | ||
81 | TObject::operator=(source); | |
82 | memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig)); | |
83 | return *this; | |
84 | } | |
85 | ||
86 | //_______________________________________________________________ | |
87 | ||
88 | AliTOFFEEReader::~AliTOFFEEReader() | |
89 | { | |
90 | /* | |
91 | * | |
92 | * default destructor | |
93 | * | |
94 | */ | |
95 | ||
96 | delete fFEEConfig; | |
97 | } | |
98 | ||
99 | //_______________________________________________________________ | |
100 | ||
101 | void | |
102 | AliTOFFEEReader::ResetChannelEnabledArray() | |
103 | { | |
104 | /* | |
105 | * | |
106 | * reset channel enabled array | |
107 | * | |
108 | */ | |
109 | ||
110 | for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) | |
111 | fChannelEnabled[iIndex] = kFALSE; | |
112 | } | |
113 | ||
114 | //_______________________________________________________________ | |
115 | ||
b059882a | 116 | void |
117 | AliTOFFEEReader::Reset() | |
118 | { | |
119 | /* | |
120 | * | |
121 | * reset | |
122 | * | |
123 | */ | |
124 | ||
125 | for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) { | |
126 | fChannelEnabled[iIndex] = kFALSE; | |
127 | fMatchingWindow[iIndex] = 0; | |
128 | } | |
129 | } | |
130 | ||
131 | //_______________________________________________________________ | |
132 | ||
1605abc6 | 133 | void |
39dff6a4 | 134 | AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const |
1605abc6 | 135 | { |
136 | /* | |
137 | * | |
138 | * load FEE config | |
139 | * | |
140 | */ | |
141 | ||
5b086af5 | 142 | Char_t *expandedFileName = gSystem->ExpandPathName(FileName); |
1605abc6 | 143 | std::ifstream is; |
5b086af5 | 144 | is.open(expandedFileName, std::ios::binary); |
1605abc6 | 145 | is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig)); |
146 | is.close(); | |
147 | } | |
148 | ||
149 | //_______________________________________________________________ | |
150 | ||
151 | Int_t | |
152 | AliTOFFEEReader::ParseFEEConfig() | |
153 | { | |
154 | /* | |
155 | * | |
156 | * parse FEE config | |
157 | * | |
158 | * loops over all FEE channels, checks whether they are enabled | |
159 | * and sets channel enabled | |
160 | * | |
161 | */ | |
162 | ||
163 | AliInfo("parsing TOF FEE config") | |
164 | ||
165 | AliTOFRawStream rawStream; | |
166 | Int_t nEnabled = 0; | |
167 | Int_t volume[5], index; | |
168 | Int_t temp; | |
169 | ||
b059882a | 170 | Reset(); |
1605abc6 | 171 | |
172 | /* loop over all FEE channels */ | |
173 | for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++) | |
174 | for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++) | |
175 | for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++) | |
176 | for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++) | |
177 | for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++) | |
178 | /* check whether FEE channel is enabled */ | |
179 | if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) { | |
180 | /* convert FEE channel indexes into detector indexes */ | |
181 | rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume); | |
182 | /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */ | |
183 | temp = volume[4]; volume[4] = volume[3]; volume[3] = temp; | |
b059882a | 184 | /* check if index is ok */ |
185 | if (volume[0] < 0 || volume[0] > 17 || | |
186 | volume[1] < 0 || volume[1] > 4 || | |
187 | volume[2] < 0 || volume[2] > 18 || | |
188 | volume[3] < 0 || volume[3] > 1 || | |
189 | volume[4] < 0 || volume[4] > 47) | |
190 | continue; | |
1605abc6 | 191 | /* convert detector indexes into calibration index */ |
192 | index = AliTOFGeometry::GetIndex(volume); | |
193 | /* check calibration index */ | |
194 | if (index != -1 && index < GetNumberOfIndexes()) { | |
195 | /* set calibration channel enabled */ | |
196 | fChannelEnabled[index] = kTRUE; | |
b059882a | 197 | fMatchingWindow[index] = GetMatchingWindow(iDDL, iTRM + 3, iChain, iTDC, iChannel); |
1605abc6 | 198 | nEnabled++; |
199 | } | |
200 | } | |
201 | return nEnabled; | |
202 | } | |
203 | ||
204 | //_______________________________________________________________ | |
205 | ||
206 | Bool_t | |
39dff6a4 | 207 | AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const |
1605abc6 | 208 | { |
209 | /* | |
210 | * | |
211 | * is channel enabled | |
212 | * | |
213 | * checks whether a FEE channel is enabled using the | |
214 | * TOF FEE config object. | |
215 | * | |
216 | */ | |
217 | ||
218 | AliTOFFEEConfig *feeConfig; | |
219 | AliTOFCrateConfig *crateConfig; | |
220 | AliTOFTRMConfig *trmConfig; | |
221 | Int_t maskPB, maskTDC; | |
222 | ||
223 | /* get and check fee config */ | |
224 | if (!(feeConfig = GetFEEConfig())) | |
225 | return kFALSE; | |
226 | ||
227 | /* get and check crate config */ | |
228 | if (!(crateConfig = feeConfig->GetCrateConfig(iDDL))) | |
229 | return kFALSE; | |
230 | ||
231 | /* get and check TRM config */ | |
232 | if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3))) | |
233 | return kFALSE; | |
234 | ||
235 | /* check DRM enabled */ | |
236 | if (!crateConfig->IsDRMEnabled()) | |
237 | return kFALSE; | |
238 | ||
239 | /* check TRM enabled */ | |
240 | if (!crateConfig->IsTRMEnabled(iTRM - 3)) | |
241 | return kFALSE; | |
242 | ||
243 | /* switch chain */ | |
244 | switch (iChain) { | |
245 | /* chain A */ | |
246 | case 0: | |
247 | /* check chain enabled */ | |
248 | if (trmConfig->GetChainAFlag() != 1) | |
249 | return kFALSE; | |
250 | /* switch TDC */ | |
251 | switch (iTDC) { | |
252 | case 0: case 1: case 2: | |
253 | maskPB = trmConfig->GetMaskPB0(); | |
254 | break; | |
255 | case 3: case 4: case 5: | |
256 | maskPB = trmConfig->GetMaskPB1(); | |
257 | break; | |
258 | case 6: case 7: case 8: | |
259 | maskPB = trmConfig->GetMaskPB2(); | |
260 | break; | |
261 | case 9: case 10: case 11: | |
262 | maskPB = trmConfig->GetMaskPB3(); | |
263 | break; | |
264 | case 12: case 13: case 14: | |
265 | maskPB = trmConfig->GetMaskPB4(); | |
266 | break; | |
267 | default: | |
268 | return kFALSE; | |
269 | break; | |
270 | } /* switch TDC */ | |
271 | break; /* chain A */ | |
272 | /* chain B */ | |
273 | case 1: | |
274 | /* check chain enabled */ | |
275 | if (trmConfig->GetChainBFlag() != 1) | |
276 | return kFALSE; | |
277 | /* switch TDC */ | |
278 | switch (iTDC) { | |
279 | case 0: case 1: case 2: | |
280 | maskPB = trmConfig->GetMaskPB5(); | |
281 | break; | |
282 | case 3: case 4: case 5: | |
283 | maskPB = trmConfig->GetMaskPB6(); | |
284 | break; | |
285 | case 6: case 7: case 8: | |
286 | maskPB = trmConfig->GetMaskPB7(); | |
287 | break; | |
288 | case 9: case 10: case 11: | |
289 | maskPB = trmConfig->GetMaskPB8(); | |
290 | break; | |
291 | case 12: case 13: case 14: | |
292 | maskPB = trmConfig->GetMaskPB9(); | |
293 | break; | |
294 | default: | |
295 | return kFALSE; | |
296 | break; | |
297 | } /* switch TDC */ | |
298 | break; /* chain B */ | |
299 | default: | |
300 | return kFALSE; | |
301 | break; | |
302 | } /* switch chain */ | |
303 | ||
304 | /* check channel enabled */ | |
305 | maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8); | |
306 | if (maskTDC & (0x1 << iChannel)) | |
307 | return kTRUE; | |
308 | else | |
309 | return kFALSE; | |
310 | ||
311 | } | |
312 | ||
b059882a | 313 | //_______________________________________________________________ |
314 | ||
315 | Int_t | |
316 | AliTOFFEEReader::GetMatchingWindow(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const | |
317 | { | |
318 | /* | |
319 | * | |
320 | * get matching window | |
321 | * | |
322 | * checks whether a FEE channel is enabled using the | |
323 | * TOF FEE config object and return the associated | |
324 | * matching window | |
325 | * | |
326 | */ | |
327 | ||
328 | AliTOFFEEConfig *feeConfig; | |
329 | AliTOFCrateConfig *crateConfig; | |
330 | AliTOFTRMConfig *trmConfig; | |
331 | Int_t maskPB, maskTDC; | |
332 | ||
333 | /* get and check fee config */ | |
334 | if (!(feeConfig = GetFEEConfig())) | |
335 | return 0; | |
336 | ||
337 | /* get and check crate config */ | |
338 | if (!(crateConfig = feeConfig->GetCrateConfig(iDDL))) | |
339 | return 0; | |
340 | ||
341 | /* get and check TRM config */ | |
342 | if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3))) | |
343 | return 0; | |
344 | ||
345 | /* check DRM enabled */ | |
346 | if (!crateConfig->IsDRMEnabled()) | |
347 | return 0; | |
348 | ||
349 | /* check TRM enabled */ | |
350 | if (!crateConfig->IsTRMEnabled(iTRM - 3)) | |
351 | return 0; | |
352 | ||
353 | return trmConfig->GetMatchingWindow(); | |
354 | } | |
355 | ||
1605abc6 | 356 | |
357 | void | |
358 | AliTOFFEEReader::DumpFEEConfig() | |
359 | { | |
360 | /* | |
361 | * | |
362 | * dump FEE config | |
363 | * | |
364 | */ | |
365 | ||
366 | AliTOFFEEConfig *feeConfig = GetFEEConfig(); | |
367 | AliTOFCrateConfig *crateConfig; | |
368 | AliTOFDRMConfig *drmConfig; | |
369 | AliTOFLTMConfig *ltmConfig; | |
370 | AliTOFTRMConfig *trmConfig; | |
371 | ||
372 | AliInfo("-------------------------------------"); | |
373 | AliInfo("dumping TOF FEE config"); | |
374 | AliInfo("-------------------------------------"); | |
375 | AliInfo(Form("version: %d", feeConfig->GetVersion())); | |
376 | AliInfo(Form("dump time: %d", feeConfig->GetDumpTime())); | |
377 | AliInfo(Form("run number: %d", feeConfig->GetRunNumber())); | |
378 | AliInfo(Form("run type: %d", feeConfig->GetRunType())); | |
379 | AliInfo("-------------------------------------"); | |
380 | ||
381 | /* loop over crates */ | |
382 | for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) { | |
383 | crateConfig = feeConfig->GetCrateConfig(iCrate); | |
384 | ||
385 | /* check crate config */ | |
386 | if (!crateConfig) | |
387 | continue; | |
388 | ||
389 | /* check DRM enabled */ | |
390 | if (!crateConfig->IsDRMEnabled()) | |
391 | continue; | |
392 | ||
393 | AliInfo(Form("crate id: %02d", iCrate)); | |
394 | ||
395 | /* dump DRM config */ | |
396 | drmConfig = crateConfig->GetDRMConfig(); | |
397 | AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask())); | |
398 | ||
399 | /* dump LTM config if enabled */ | |
400 | if (crateConfig->IsLTMEnabled()) { | |
401 | ltmConfig = crateConfig->GetLTMConfig(); | |
402 | AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold())); | |
403 | } | |
404 | ||
405 | /* dump CPDM config if enabled */ | |
406 | if (crateConfig->IsCPDMEnabled()) { | |
407 | AliInfo(Form("CPDM is enabled")); | |
408 | } | |
409 | ||
410 | /* loop over TRMs */ | |
411 | for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) { | |
412 | ||
413 | trmConfig = crateConfig->GetTRMConfig(iTRM); | |
414 | ||
415 | /* check TRM config */ | |
416 | if (!trmConfig) | |
417 | continue; | |
418 | ||
419 | /* check TRM enabled */ | |
420 | if (!crateConfig->IsTRMEnabled(iTRM)) | |
421 | continue; | |
422 | ||
423 | /* dump TRM config */ | |
424 | AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag())); | |
425 | ||
426 | /* check TRM chain A flag */ | |
427 | if (trmConfig->GetChainAFlag() == 1) { | |
428 | AliInfo(Form("TRM%02d chainA is enabled: PB0=%06X, PB1=%06X, PB2=%06X, PB3=%06X, PB4=%06X", iTRM + 3, trmConfig->GetMaskPB0(), trmConfig->GetMaskPB1(), trmConfig->GetMaskPB2(), trmConfig->GetMaskPB3(), trmConfig->GetMaskPB4())); | |
429 | } | |
430 | ||
431 | /* check TRM chain B flag */ | |
432 | if (trmConfig->GetChainBFlag() == 1) { | |
433 | AliInfo(Form("TRM%02d chainB is enabled: PB5=%06X, PB6=%06X, PB7=%06X, PB8=%06X, PB9=%06X", iTRM + 3, trmConfig->GetMaskPB5(), trmConfig->GetMaskPB6(), trmConfig->GetMaskPB7(), trmConfig->GetMaskPB8(), trmConfig->GetMaskPB9())); | |
434 | } | |
435 | ||
436 | ||
437 | ||
438 | } /* loop over TRMs */ | |
439 | AliInfo("-------------------------------------"); | |
440 | } /* loop over crates */ | |
441 | } | |
442 |