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 "AliTOFFEElightConfig.h"
32 #include "AliTOFRawStream.h"
33 #include "AliTOFGeometry.h"
34 #include "AliTOFcalibHisto.h"
38 ClassImp(AliTOFFEEReader)
40 //_______________________________________________________________
42 AliTOFFEEReader::AliTOFFEEReader() :
44 fFEEConfig(new AliTOFFEEConfig()),
45 fFEElightConfig(new AliTOFFEElightConfig()),
59 //_______________________________________________________________
61 AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
63 fFEEConfig(new AliTOFFEEConfig()),
64 fFEElightConfig(new AliTOFFEElightConfig())
72 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
73 memcpy(fFEElightConfig, source.fFEElightConfig, sizeof(AliTOFFEElightConfig));
76 //_______________________________________________________________
79 AliTOFFEEReader::operator=(const AliTOFFEEReader &source)
87 TObject::operator=(source);
88 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
89 memcpy(fFEElightConfig, source.fFEElightConfig, sizeof(AliTOFFEElightConfig));
93 //_______________________________________________________________
95 AliTOFFEEReader::~AliTOFFEEReader()
104 delete fFEElightConfig;
107 //_______________________________________________________________
110 AliTOFFEEReader::ResetChannelEnabledArray()
114 * reset channel enabled array
118 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++)
119 fChannelEnabled[iIndex] = kFALSE;
122 //_______________________________________________________________
125 AliTOFFEEReader::ResetTriggerMaskArray()
129 * reset trigger mask array
133 for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++)
134 fTriggerMask[iddl] = 0x0;
137 //_______________________________________________________________
140 AliTOFFEEReader::Reset()
148 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) {
149 fChannelEnabled[iIndex] = kFALSE;
150 fMatchingWindow[iIndex] = 0;
151 fLatencyWindow[iIndex] = 0;
154 for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++)
155 fTriggerMask[iddl] = 0x0;
158 //_______________________________________________________________
161 AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
169 Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
171 is.open(expandedFileName, std::ios::binary);
172 is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig));
176 //_______________________________________________________________
179 AliTOFFEEReader::LoadFEElightConfig(const Char_t *FileName) const
183 * load FEElight config
187 Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
189 is.open(expandedFileName, std::ios::binary);
190 is.read((Char_t *)fFEElightConfig, sizeof(AliTOFFEElightConfig));
194 //_______________________________________________________________
197 AliTOFFEEReader::ParseFEEConfig()
203 * loops over all FEE channels, checks whether they are enabled
204 * and sets channel enabled
208 AliInfo("parsing TOF FEE config");
210 AliTOFRawStream rawStream;
212 Int_t volume[5], index;
217 /* loop over all FEE channels */
218 for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++)
219 for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++)
220 for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++)
221 for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++)
222 for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++)
223 /* check whether FEE channel is enabled */
224 if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) {
225 /* convert FEE channel indexes into detector indexes */
226 rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume);
227 /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */
228 temp = volume[4]; volume[4] = volume[3]; volume[3] = temp;
229 /* check if index is ok */
230 if (volume[0] < 0 || volume[0] > 17 ||
231 volume[1] < 0 || volume[1] > 4 ||
232 volume[2] < 0 || volume[2] > 18 ||
233 volume[3] < 0 || volume[3] > 1 ||
234 volume[4] < 0 || volume[4] > 47)
236 /* convert detector indexes into calibration index */
237 index = AliTOFGeometry::GetIndex(volume);
238 /* check calibration index */
239 if (index != -1 && index < GetNumberOfIndexes()) {
240 /* set calibration channel enabled */
241 fChannelEnabled[index] = kTRUE;
242 fMatchingWindow[index] = GetMatchingWindow(iDDL, iTRM + 3, iChain, iTDC, iChannel);
249 //_______________________________________________________________
252 AliTOFFEEReader::ParseFEElightConfig()
256 * parse FEElight config
258 * loops over all FEE channels, checks whether they are enabled
259 * and sets channel enabled
263 AliInfo("parsing TOF FEElight config");
267 AliTOFcalibHisto calibHisto;
268 calibHisto.LoadCalibHisto();
270 Int_t nEnabled = 0, index;
271 AliTOFFEEchannelConfig *channelConfig = NULL;
272 for (Int_t i = 0; i < GetNumberOfIndexesEO(); i++) {
273 channelConfig = fFEElightConfig->GetChannelConfig(i);
274 if (!channelConfig->IsEnabled()) continue;
275 /* get index DO from index EO */
276 index = (Int_t)calibHisto.GetCalibMap(AliTOFcalibHisto::kIndex, i);
277 if (index == -1) continue;
279 fChannelEnabled[index] = channelConfig->IsEnabled();
280 fMatchingWindow[index] = channelConfig->GetMatchingWindow();
281 fLatencyWindow[index] = channelConfig->GetLatencyWindow();
284 AliTOFFEEtriggerConfig *triggerConfig = NULL;
285 for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++) {
286 triggerConfig = fFEElightConfig->GetTriggerConfig(iddl);
287 fTriggerMask[iddl] = triggerConfig->GetStatusMap();
293 //_______________________________________________________________
296 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
302 * checks whether a FEE channel is enabled using the
303 * TOF FEE config object.
307 AliTOFFEEConfig *feeConfig;
308 AliTOFCrateConfig *crateConfig;
309 AliTOFTRMConfig *trmConfig;
310 Int_t maskPB, maskTDC, activeChip;
312 /* get and check fee config */
313 if (!(feeConfig = GetFEEConfig()))
316 /* get and check crate config */
317 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
320 /* get and check TRM config */
321 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
324 /* check DRM enabled */
325 if (!crateConfig->IsDRMEnabled())
328 /* check TRM enabled */
329 if (!crateConfig->IsTRMEnabled(iTRM - 3))
336 /* check chain enabled */
337 if (trmConfig->GetChainAFlag() != 1)
339 /* get active chip mask */
340 activeChip = trmConfig->GetActiveChipA();
343 case 0: case 1: case 2:
344 maskPB = trmConfig->GetMaskPB0();
346 case 3: case 4: case 5:
347 maskPB = trmConfig->GetMaskPB1();
349 case 6: case 7: case 8:
350 maskPB = trmConfig->GetMaskPB2();
352 case 9: case 10: case 11:
353 maskPB = trmConfig->GetMaskPB3();
355 case 12: case 13: case 14:
356 maskPB = trmConfig->GetMaskPB4();
365 /* check chain enabled */
366 if (trmConfig->GetChainBFlag() != 1)
368 /* get active chip mask */
369 activeChip = trmConfig->GetActiveChipB();
372 case 0: case 1: case 2:
373 maskPB = trmConfig->GetMaskPB5();
375 case 3: case 4: case 5:
376 maskPB = trmConfig->GetMaskPB6();
378 case 6: case 7: case 8:
379 maskPB = trmConfig->GetMaskPB7();
381 case 9: case 10: case 11:
382 maskPB = trmConfig->GetMaskPB8();
384 case 12: case 13: case 14:
385 maskPB = trmConfig->GetMaskPB9();
397 /* check chip enabled */
398 if (!(activeChip & (0x1 << iTDC)))
401 /* check channel enabled */
402 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
403 if (maskTDC & (0x1 << iChannel))
410 //_______________________________________________________________
413 AliTOFFEEReader::GetMatchingWindow(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
417 * get matching window
419 * checks whether a FEE channel is enabled using the
420 * TOF FEE config object and return the associated
425 AliTOFFEEConfig *feeConfig;
426 AliTOFCrateConfig *crateConfig;
427 AliTOFTRMConfig *trmConfig;
429 iChain = 0; iTDC = 0; iChannel = 0; /* dummy for the time being */
431 /* get and check fee config */
432 if (!(feeConfig = GetFEEConfig()))
435 /* get and check crate config */
436 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
439 /* get and check TRM config */
440 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
443 /* check DRM enabled */
444 if (!crateConfig->IsDRMEnabled())
447 /* check TRM enabled */
448 if (!crateConfig->IsTRMEnabled(iTRM - 3))
451 return trmConfig->GetMatchingWindow();
456 AliTOFFEEReader::DumpFEEConfig()
464 AliTOFFEEConfig *feeConfig = GetFEEConfig();
465 AliTOFCrateConfig *crateConfig;
466 AliTOFDRMConfig *drmConfig;
467 AliTOFLTMConfig *ltmConfig;
468 AliTOFTRMConfig *trmConfig;
470 AliInfo("-------------------------------------");
471 AliInfo("dumping TOF FEE config");
472 AliInfo("-------------------------------------");
473 AliInfo(Form("version: %d", feeConfig->GetVersion()));
474 AliInfo(Form("dump time: %d", (Int_t)feeConfig->GetDumpTime()));
475 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
476 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
477 AliInfo("-------------------------------------");
479 /* loop over crates */
480 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
481 crateConfig = feeConfig->GetCrateConfig(iCrate);
483 /* check crate config */
487 /* check DRM enabled */
488 if (!crateConfig->IsDRMEnabled())
491 AliInfo(Form("crate id: %02d", iCrate));
493 /* dump DRM config */
494 drmConfig = crateConfig->GetDRMConfig();
495 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
497 /* dump LTM config if enabled */
498 if (crateConfig->IsLTMEnabled()) {
499 ltmConfig = crateConfig->GetLTMConfig();
500 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
503 /* dump CPDM config if enabled */
504 if (crateConfig->IsCPDMEnabled()) {
505 AliInfo(Form("CPDM is enabled"));
509 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
511 trmConfig = crateConfig->GetTRMConfig(iTRM);
513 /* check TRM config */
517 /* check TRM enabled */
518 if (!crateConfig->IsTRMEnabled(iTRM))
521 /* dump TRM config */
522 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
524 /* check TRM chain A flag */
525 if (trmConfig->GetChainAFlag() == 1) {
526 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()));
529 /* check TRM chain B flag */
530 if (trmConfig->GetChainBFlag() == 1) {
531 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()));
536 } /* loop over TRMs */
537 AliInfo("-------------------------------------");
538 } /* loop over crates */
541 //_______________________________________________________________
544 AliTOFFEEReader::CreateFEElightConfig(const Char_t *filename)
548 * create FEElight config
552 AliTOFFEElightConfig lightConfig;
554 for (Int_t i = 0; i < GetNumberOfIndexes(); i++) {
555 if (fChannelEnabled[i]) {
556 lightConfig.GetChannelConfig(i)->SetStatus(AliTOFFEEchannelConfig::kStatusEnabled);
557 lightConfig.GetChannelConfig(i)->SetMatchingWindow(fMatchingWindow[i]);
558 lightConfig.GetChannelConfig(i)->SetLatencyWindow(fLatencyWindow[i]);
561 lightConfig.GetChannelConfig(i)->SetStatus(0x0);
562 lightConfig.GetChannelConfig(i)->SetMatchingWindow(0);
563 lightConfig.GetChannelConfig(i)->SetLatencyWindow(0);
567 Char_t *expandedFileName = gSystem->ExpandPathName(filename);
569 os.open(expandedFileName, std::ios::binary);
570 os.write((Char_t *)&lightConfig, sizeof(AliTOFFEElightConfig));