1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 ***************************************************************************/
17 * author: Roberto Preghenella (R+), Roberto.Preghenella@bo.infn.it
20 //////////////////////////////////////////////////////////////////////
23 // This class provides the TOF FEE reader. //
26 //////////////////////////////////////////////////////////////////////
29 #include "AliTOFFEEReader.h"
30 #include "AliTOFFEEConfig.h"
31 #include "AliTOFRawStream.h"
32 #include "AliTOFGeometry.h"
36 ClassImp(AliTOFFEEReader)
38 //_______________________________________________________________
40 AliTOFFEEReader::AliTOFFEEReader() :
42 fFEEConfig(new AliTOFFEEConfig()),
55 //_______________________________________________________________
57 AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
59 fFEEConfig(new AliTOFFEEConfig())
67 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
70 //_______________________________________________________________
73 AliTOFFEEReader::operator=(const AliTOFFEEReader &source)
81 TObject::operator=(source);
82 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
86 //_______________________________________________________________
88 AliTOFFEEReader::~AliTOFFEEReader()
99 //_______________________________________________________________
102 AliTOFFEEReader::ResetChannelEnabledArray()
106 * reset channel enabled array
110 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++)
111 fChannelEnabled[iIndex] = kFALSE;
114 //_______________________________________________________________
117 AliTOFFEEReader::Reset()
125 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) {
126 fChannelEnabled[iIndex] = kFALSE;
127 fMatchingWindow[iIndex] = 0;
131 //_______________________________________________________________
134 AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
142 Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
144 is.open(expandedFileName, std::ios::binary);
145 is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig));
149 //_______________________________________________________________
152 AliTOFFEEReader::ParseFEEConfig()
158 * loops over all FEE channels, checks whether they are enabled
159 * and sets channel enabled
163 AliInfo("parsing TOF FEE config")
165 AliTOFRawStream rawStream;
167 Int_t volume[5], index;
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;
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)
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;
197 fMatchingWindow[index] = GetMatchingWindow(iDDL, iTRM + 3, iChain, iTDC, iChannel);
204 //_______________________________________________________________
207 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
213 * checks whether a FEE channel is enabled using the
214 * TOF FEE config object.
218 AliTOFFEEConfig *feeConfig;
219 AliTOFCrateConfig *crateConfig;
220 AliTOFTRMConfig *trmConfig;
221 Int_t maskPB, maskTDC;
223 /* get and check fee config */
224 if (!(feeConfig = GetFEEConfig()))
227 /* get and check crate config */
228 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
231 /* get and check TRM config */
232 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
235 /* check DRM enabled */
236 if (!crateConfig->IsDRMEnabled())
239 /* check TRM enabled */
240 if (!crateConfig->IsTRMEnabled(iTRM - 3))
247 /* check chain enabled */
248 if (trmConfig->GetChainAFlag() != 1)
252 case 0: case 1: case 2:
253 maskPB = trmConfig->GetMaskPB0();
255 case 3: case 4: case 5:
256 maskPB = trmConfig->GetMaskPB1();
258 case 6: case 7: case 8:
259 maskPB = trmConfig->GetMaskPB2();
261 case 9: case 10: case 11:
262 maskPB = trmConfig->GetMaskPB3();
264 case 12: case 13: case 14:
265 maskPB = trmConfig->GetMaskPB4();
274 /* check chain enabled */
275 if (trmConfig->GetChainBFlag() != 1)
279 case 0: case 1: case 2:
280 maskPB = trmConfig->GetMaskPB5();
282 case 3: case 4: case 5:
283 maskPB = trmConfig->GetMaskPB6();
285 case 6: case 7: case 8:
286 maskPB = trmConfig->GetMaskPB7();
288 case 9: case 10: case 11:
289 maskPB = trmConfig->GetMaskPB8();
291 case 12: case 13: case 14:
292 maskPB = trmConfig->GetMaskPB9();
304 /* check channel enabled */
305 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
306 if (maskTDC & (0x1 << iChannel))
313 //_______________________________________________________________
316 AliTOFFEEReader::GetMatchingWindow(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
320 * get matching window
322 * checks whether a FEE channel is enabled using the
323 * TOF FEE config object and return the associated
328 AliTOFFEEConfig *feeConfig;
329 AliTOFCrateConfig *crateConfig;
330 AliTOFTRMConfig *trmConfig;
332 iChain = 0; iTDC = 0; iChannel = 0; /* dummy for the time being */
334 /* get and check fee config */
335 if (!(feeConfig = GetFEEConfig()))
338 /* get and check crate config */
339 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
342 /* get and check TRM config */
343 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
346 /* check DRM enabled */
347 if (!crateConfig->IsDRMEnabled())
350 /* check TRM enabled */
351 if (!crateConfig->IsTRMEnabled(iTRM - 3))
354 return trmConfig->GetMatchingWindow();
359 AliTOFFEEReader::DumpFEEConfig()
367 AliTOFFEEConfig *feeConfig = GetFEEConfig();
368 AliTOFCrateConfig *crateConfig;
369 AliTOFDRMConfig *drmConfig;
370 AliTOFLTMConfig *ltmConfig;
371 AliTOFTRMConfig *trmConfig;
373 AliInfo("-------------------------------------");
374 AliInfo("dumping TOF FEE config");
375 AliInfo("-------------------------------------");
376 AliInfo(Form("version: %d", feeConfig->GetVersion()));
377 AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
378 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
379 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
380 AliInfo("-------------------------------------");
382 /* loop over crates */
383 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
384 crateConfig = feeConfig->GetCrateConfig(iCrate);
386 /* check crate config */
390 /* check DRM enabled */
391 if (!crateConfig->IsDRMEnabled())
394 AliInfo(Form("crate id: %02d", iCrate));
396 /* dump DRM config */
397 drmConfig = crateConfig->GetDRMConfig();
398 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
400 /* dump LTM config if enabled */
401 if (crateConfig->IsLTMEnabled()) {
402 ltmConfig = crateConfig->GetLTMConfig();
403 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
406 /* dump CPDM config if enabled */
407 if (crateConfig->IsCPDMEnabled()) {
408 AliInfo(Form("CPDM is enabled"));
412 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
414 trmConfig = crateConfig->GetTRMConfig(iTRM);
416 /* check TRM config */
420 /* check TRM enabled */
421 if (!crateConfig->IsTRMEnabled(iTRM))
424 /* dump TRM config */
425 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
427 /* check TRM chain A flag */
428 if (trmConfig->GetChainAFlag() == 1) {
429 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()));
432 /* check TRM chain B flag */
433 if (trmConfig->GetChainBFlag() == 1) {
434 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()));
439 } /* loop over TRMs */
440 AliInfo("-------------------------------------");
441 } /* loop over crates */