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 //////////////////////////////////////////////////////////////////////
28 #include "AliTOFFEEReader.h"
29 #include "AliTOFFEEConfig.h"
30 #include "AliTOFRawStream.h"
31 #include "AliTOFGeometry.h"
35 ClassImp(AliTOFFEEReader)
37 //_______________________________________________________________
39 AliTOFFEEReader::AliTOFFEEReader() :
41 fFEEConfig(new AliTOFFEEConfig()),
52 //_______________________________________________________________
54 AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
56 fFEEConfig(new AliTOFFEEConfig())
64 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
67 //_______________________________________________________________
70 AliTOFFEEReader::operator=(const AliTOFFEEReader &source)
78 TObject::operator=(source);
79 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
83 //_______________________________________________________________
85 AliTOFFEEReader::~AliTOFFEEReader()
96 //_______________________________________________________________
99 AliTOFFEEReader::ResetChannelEnabledArray()
103 * reset channel enabled array
107 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++)
108 fChannelEnabled[iIndex] = kFALSE;
111 //_______________________________________________________________
114 AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
123 is.open(FileName, std::ios::binary);
124 is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig));
128 //_______________________________________________________________
131 AliTOFFEEReader::ParseFEEConfig()
137 * loops over all FEE channels, checks whether they are enabled
138 * and sets channel enabled
142 AliInfo("parsing TOF FEE config")
144 AliTOFRawStream rawStream;
146 Int_t volume[5], index;
149 ResetChannelEnabledArray();
151 /* loop over all FEE channels */
152 for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++)
153 for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++)
154 for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++)
155 for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++)
156 for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++)
157 /* check whether FEE channel is enabled */
158 if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) {
159 /* convert FEE channel indexes into detector indexes */
160 rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume);
161 /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */
162 temp = volume[4]; volume[4] = volume[3]; volume[3] = temp;
163 /* convert detector indexes into calibration index */
164 index = AliTOFGeometry::GetIndex(volume);
165 /* check calibration index */
166 if (index != -1 && index < GetNumberOfIndexes()) {
167 /* set calibration channel enabled */
168 fChannelEnabled[index] = kTRUE;
175 //_______________________________________________________________
178 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
184 * checks whether a FEE channel is enabled using the
185 * TOF FEE config object.
189 AliTOFFEEConfig *feeConfig;
190 AliTOFCrateConfig *crateConfig;
191 AliTOFTRMConfig *trmConfig;
192 Int_t maskPB, maskTDC;
194 /* get and check fee config */
195 if (!(feeConfig = GetFEEConfig()))
198 /* get and check crate config */
199 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
202 /* get and check TRM config */
203 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
206 /* check DRM enabled */
207 if (!crateConfig->IsDRMEnabled())
210 /* check TRM enabled */
211 if (!crateConfig->IsTRMEnabled(iTRM - 3))
218 /* check chain enabled */
219 if (trmConfig->GetChainAFlag() != 1)
223 case 0: case 1: case 2:
224 maskPB = trmConfig->GetMaskPB0();
226 case 3: case 4: case 5:
227 maskPB = trmConfig->GetMaskPB1();
229 case 6: case 7: case 8:
230 maskPB = trmConfig->GetMaskPB2();
232 case 9: case 10: case 11:
233 maskPB = trmConfig->GetMaskPB3();
235 case 12: case 13: case 14:
236 maskPB = trmConfig->GetMaskPB4();
245 /* check chain enabled */
246 if (trmConfig->GetChainBFlag() != 1)
250 case 0: case 1: case 2:
251 maskPB = trmConfig->GetMaskPB5();
253 case 3: case 4: case 5:
254 maskPB = trmConfig->GetMaskPB6();
256 case 6: case 7: case 8:
257 maskPB = trmConfig->GetMaskPB7();
259 case 9: case 10: case 11:
260 maskPB = trmConfig->GetMaskPB8();
262 case 12: case 13: case 14:
263 maskPB = trmConfig->GetMaskPB9();
275 /* check channel enabled */
276 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
277 if (maskTDC & (0x1 << iChannel))
286 AliTOFFEEReader::DumpFEEConfig()
294 AliTOFFEEConfig *feeConfig = GetFEEConfig();
295 AliTOFCrateConfig *crateConfig;
296 AliTOFDRMConfig *drmConfig;
297 AliTOFLTMConfig *ltmConfig;
298 AliTOFTRMConfig *trmConfig;
300 AliInfo("-------------------------------------");
301 AliInfo("dumping TOF FEE config");
302 AliInfo("-------------------------------------");
303 AliInfo(Form("version: %d", feeConfig->GetVersion()));
304 AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
305 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
306 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
307 AliInfo("-------------------------------------");
309 /* loop over crates */
310 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
311 crateConfig = feeConfig->GetCrateConfig(iCrate);
313 /* check crate config */
317 /* check DRM enabled */
318 if (!crateConfig->IsDRMEnabled())
321 AliInfo(Form("crate id: %02d", iCrate));
323 /* dump DRM config */
324 drmConfig = crateConfig->GetDRMConfig();
325 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
327 /* dump LTM config if enabled */
328 if (crateConfig->IsLTMEnabled()) {
329 ltmConfig = crateConfig->GetLTMConfig();
330 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
333 /* dump CPDM config if enabled */
334 if (crateConfig->IsCPDMEnabled()) {
335 AliInfo(Form("CPDM is enabled"));
339 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
341 trmConfig = crateConfig->GetTRMConfig(iTRM);
343 /* check TRM config */
347 /* check TRM enabled */
348 if (!crateConfig->IsTRMEnabled(iTRM))
351 /* dump TRM config */
352 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
354 /* check TRM chain A flag */
355 if (trmConfig->GetChainAFlag() == 1) {
356 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()));
359 /* check TRM chain B flag */
360 if (trmConfig->GetChainBFlag() == 1) {
361 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()));
366 } /* loop over TRMs */
367 AliInfo("-------------------------------------");
368 } /* loop over crates */