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()),
53 //_______________________________________________________________
55 AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
57 fFEEConfig(new AliTOFFEEConfig())
65 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
68 //_______________________________________________________________
71 AliTOFFEEReader::operator=(const AliTOFFEEReader &source)
79 TObject::operator=(source);
80 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
84 //_______________________________________________________________
86 AliTOFFEEReader::~AliTOFFEEReader()
97 //_______________________________________________________________
100 AliTOFFEEReader::ResetChannelEnabledArray()
104 * reset channel enabled array
108 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++)
109 fChannelEnabled[iIndex] = kFALSE;
112 //_______________________________________________________________
115 AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
123 Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
125 is.open(expandedFileName, std::ios::binary);
126 is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig));
130 //_______________________________________________________________
133 AliTOFFEEReader::ParseFEEConfig()
139 * loops over all FEE channels, checks whether they are enabled
140 * and sets channel enabled
144 AliInfo("parsing TOF FEE config")
146 AliTOFRawStream rawStream;
148 Int_t volume[5], index;
151 ResetChannelEnabledArray();
153 /* loop over all FEE channels */
154 for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++)
155 for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++)
156 for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++)
157 for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++)
158 for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++)
159 /* check whether FEE channel is enabled */
160 if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) {
161 /* convert FEE channel indexes into detector indexes */
162 rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume);
163 /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */
164 temp = volume[4]; volume[4] = volume[3]; volume[3] = temp;
165 /* convert detector indexes into calibration index */
166 index = AliTOFGeometry::GetIndex(volume);
167 /* check calibration index */
168 if (index != -1 && index < GetNumberOfIndexes()) {
169 /* set calibration channel enabled */
170 fChannelEnabled[index] = kTRUE;
177 //_______________________________________________________________
180 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
186 * checks whether a FEE channel is enabled using the
187 * TOF FEE config object.
191 AliTOFFEEConfig *feeConfig;
192 AliTOFCrateConfig *crateConfig;
193 AliTOFTRMConfig *trmConfig;
194 Int_t maskPB, maskTDC;
196 /* get and check fee config */
197 if (!(feeConfig = GetFEEConfig()))
200 /* get and check crate config */
201 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
204 /* get and check TRM config */
205 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
208 /* check DRM enabled */
209 if (!crateConfig->IsDRMEnabled())
212 /* check TRM enabled */
213 if (!crateConfig->IsTRMEnabled(iTRM - 3))
220 /* check chain enabled */
221 if (trmConfig->GetChainAFlag() != 1)
225 case 0: case 1: case 2:
226 maskPB = trmConfig->GetMaskPB0();
228 case 3: case 4: case 5:
229 maskPB = trmConfig->GetMaskPB1();
231 case 6: case 7: case 8:
232 maskPB = trmConfig->GetMaskPB2();
234 case 9: case 10: case 11:
235 maskPB = trmConfig->GetMaskPB3();
237 case 12: case 13: case 14:
238 maskPB = trmConfig->GetMaskPB4();
247 /* check chain enabled */
248 if (trmConfig->GetChainBFlag() != 1)
252 case 0: case 1: case 2:
253 maskPB = trmConfig->GetMaskPB5();
255 case 3: case 4: case 5:
256 maskPB = trmConfig->GetMaskPB6();
258 case 6: case 7: case 8:
259 maskPB = trmConfig->GetMaskPB7();
261 case 9: case 10: case 11:
262 maskPB = trmConfig->GetMaskPB8();
264 case 12: case 13: case 14:
265 maskPB = trmConfig->GetMaskPB9();
277 /* check channel enabled */
278 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
279 if (maskTDC & (0x1 << iChannel))
288 AliTOFFEEReader::DumpFEEConfig()
296 AliTOFFEEConfig *feeConfig = GetFEEConfig();
297 AliTOFCrateConfig *crateConfig;
298 AliTOFDRMConfig *drmConfig;
299 AliTOFLTMConfig *ltmConfig;
300 AliTOFTRMConfig *trmConfig;
302 AliInfo("-------------------------------------");
303 AliInfo("dumping TOF FEE config");
304 AliInfo("-------------------------------------");
305 AliInfo(Form("version: %d", feeConfig->GetVersion()));
306 AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
307 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
308 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
309 AliInfo("-------------------------------------");
311 /* loop over crates */
312 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
313 crateConfig = feeConfig->GetCrateConfig(iCrate);
315 /* check crate config */
319 /* check DRM enabled */
320 if (!crateConfig->IsDRMEnabled())
323 AliInfo(Form("crate id: %02d", iCrate));
325 /* dump DRM config */
326 drmConfig = crateConfig->GetDRMConfig();
327 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
329 /* dump LTM config if enabled */
330 if (crateConfig->IsLTMEnabled()) {
331 ltmConfig = crateConfig->GetLTMConfig();
332 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
335 /* dump CPDM config if enabled */
336 if (crateConfig->IsCPDMEnabled()) {
337 AliInfo(Form("CPDM is enabled"));
341 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
343 trmConfig = crateConfig->GetTRMConfig(iTRM);
345 /* check TRM config */
349 /* check TRM enabled */
350 if (!crateConfig->IsTRMEnabled(iTRM))
353 /* dump TRM config */
354 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
356 /* check TRM chain A flag */
357 if (trmConfig->GetChainAFlag() == 1) {
358 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()));
361 /* check TRM chain B flag */
362 if (trmConfig->GetChainBFlag() == 1) {
363 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()));
368 } /* loop over TRMs */
369 AliInfo("-------------------------------------");
370 } /* loop over crates */