]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFFEEReader.cxx
Compilation warnings
[u/mrichter/AliRoot.git] / TOF / AliTOFFEEReader.cxx
CommitLineData
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
36ClassImp(AliTOFFEEReader)
37
38//_______________________________________________________________
39
40AliTOFFEEReader::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
57AliTOFFEEReader::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
72AliTOFFEEReader &
73AliTOFFEEReader::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
88AliTOFFEEReader::~AliTOFFEEReader()
89{
90 /*
91 *
92 * default destructor
93 *
94 */
95
96 delete fFEEConfig;
97}
98
99//_______________________________________________________________
100
101void
102AliTOFFEEReader::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 116void
117AliTOFFEEReader::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 133void
39dff6a4 134AliTOFFEEReader::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
151Int_t
152AliTOFFEEReader::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
206Bool_t
39dff6a4 207AliTOFFEEReader::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;
71b82bd2 221 Int_t maskPB, maskTDC, activeChip;
1605abc6 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;
71b82bd2 250 /* get active chip mask */
251 activeChip = trmConfig->GetActiveChipA();
1605abc6 252 /* switch TDC */
253 switch (iTDC) {
254 case 0: case 1: case 2:
255 maskPB = trmConfig->GetMaskPB0();
256 break;
257 case 3: case 4: case 5:
258 maskPB = trmConfig->GetMaskPB1();
259 break;
260 case 6: case 7: case 8:
261 maskPB = trmConfig->GetMaskPB2();
262 break;
263 case 9: case 10: case 11:
264 maskPB = trmConfig->GetMaskPB3();
265 break;
266 case 12: case 13: case 14:
267 maskPB = trmConfig->GetMaskPB4();
268 break;
269 default:
270 return kFALSE;
271 break;
272 } /* switch TDC */
273 break; /* chain A */
274 /* chain B */
275 case 1:
276 /* check chain enabled */
277 if (trmConfig->GetChainBFlag() != 1)
278 return kFALSE;
71b82bd2 279 /* get active chip mask */
280 activeChip = trmConfig->GetActiveChipB();
1605abc6 281 /* switch TDC */
282 switch (iTDC) {
283 case 0: case 1: case 2:
284 maskPB = trmConfig->GetMaskPB5();
285 break;
286 case 3: case 4: case 5:
287 maskPB = trmConfig->GetMaskPB6();
288 break;
289 case 6: case 7: case 8:
290 maskPB = trmConfig->GetMaskPB7();
291 break;
292 case 9: case 10: case 11:
293 maskPB = trmConfig->GetMaskPB8();
294 break;
295 case 12: case 13: case 14:
296 maskPB = trmConfig->GetMaskPB9();
297 break;
298 default:
299 return kFALSE;
300 break;
301 } /* switch TDC */
302 break; /* chain B */
303 default:
304 return kFALSE;
305 break;
306 } /* switch chain */
307
71b82bd2 308 /* check chip enabled */
309 if (!(activeChip & (0x1 << iTDC)))
310 return kFALSE;
311
1605abc6 312 /* check channel enabled */
313 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
314 if (maskTDC & (0x1 << iChannel))
315 return kTRUE;
316 else
317 return kFALSE;
318
319}
320
b059882a 321//_______________________________________________________________
322
323Int_t
324AliTOFFEEReader::GetMatchingWindow(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
325{
326 /*
327 *
328 * get matching window
329 *
330 * checks whether a FEE channel is enabled using the
331 * TOF FEE config object and return the associated
332 * matching window
333 *
334 */
bf1a5fa6 335
b059882a 336 AliTOFFEEConfig *feeConfig;
337 AliTOFCrateConfig *crateConfig;
338 AliTOFTRMConfig *trmConfig;
bf1a5fa6 339
340 iChain = 0; iTDC = 0; iChannel = 0; /* dummy for the time being */
b059882a 341
342 /* get and check fee config */
343 if (!(feeConfig = GetFEEConfig()))
344 return 0;
345
346 /* get and check crate config */
347 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
348 return 0;
349
350 /* get and check TRM config */
351 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
352 return 0;
353
354 /* check DRM enabled */
355 if (!crateConfig->IsDRMEnabled())
356 return 0;
357
358 /* check TRM enabled */
359 if (!crateConfig->IsTRMEnabled(iTRM - 3))
360 return 0;
361
362 return trmConfig->GetMatchingWindow();
363}
364
1605abc6 365
366void
367AliTOFFEEReader::DumpFEEConfig()
368{
369 /*
370 *
371 * dump FEE config
372 *
373 */
374
375 AliTOFFEEConfig *feeConfig = GetFEEConfig();
376 AliTOFCrateConfig *crateConfig;
377 AliTOFDRMConfig *drmConfig;
378 AliTOFLTMConfig *ltmConfig;
379 AliTOFTRMConfig *trmConfig;
380
381 AliInfo("-------------------------------------");
382 AliInfo("dumping TOF FEE config");
383 AliInfo("-------------------------------------");
384 AliInfo(Form("version: %d", feeConfig->GetVersion()));
385 AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
386 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
387 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
388 AliInfo("-------------------------------------");
389
390 /* loop over crates */
391 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
392 crateConfig = feeConfig->GetCrateConfig(iCrate);
393
394 /* check crate config */
395 if (!crateConfig)
396 continue;
397
398 /* check DRM enabled */
399 if (!crateConfig->IsDRMEnabled())
400 continue;
401
402 AliInfo(Form("crate id: %02d", iCrate));
403
404 /* dump DRM config */
405 drmConfig = crateConfig->GetDRMConfig();
406 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
407
408 /* dump LTM config if enabled */
409 if (crateConfig->IsLTMEnabled()) {
410 ltmConfig = crateConfig->GetLTMConfig();
411 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
412 }
413
414 /* dump CPDM config if enabled */
415 if (crateConfig->IsCPDMEnabled()) {
416 AliInfo(Form("CPDM is enabled"));
417 }
418
419 /* loop over TRMs */
420 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
421
422 trmConfig = crateConfig->GetTRMConfig(iTRM);
423
424 /* check TRM config */
425 if (!trmConfig)
426 continue;
427
428 /* check TRM enabled */
429 if (!crateConfig->IsTRMEnabled(iTRM))
430 continue;
431
432 /* dump TRM config */
433 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
434
435 /* check TRM chain A flag */
436 if (trmConfig->GetChainAFlag() == 1) {
71b82bd2 437 AliInfo(Form("TRM%02d chainA is enabled: activeChip=%04X, PB0=%06X, PB1=%06X, PB2=%06X, PB3=%06X, PB4=%06X", iTRM + 3, trmConfig->GetActiveChipA(), trmConfig->GetMaskPB0(), trmConfig->GetMaskPB1(), trmConfig->GetMaskPB2(), trmConfig->GetMaskPB3(), trmConfig->GetMaskPB4()));
1605abc6 438 }
439
440 /* check TRM chain B flag */
441 if (trmConfig->GetChainBFlag() == 1) {
71b82bd2 442 AliInfo(Form("TRM%02d chainB is enabled: activeChip=%04X, PB5=%06X, PB6=%06X, PB7=%06X, PB8=%06X, PB9=%06X", iTRM + 3, trmConfig->GetActiveChipB(), trmConfig->GetMaskPB5(), trmConfig->GetMaskPB6(), trmConfig->GetMaskPB7(), trmConfig->GetMaskPB8(), trmConfig->GetMaskPB9()));
1605abc6 443 }
444
445
446
447 } /* loop over TRMs */
448 AliInfo("-------------------------------------");
449 } /* loop over crates */
450}
451