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"
34 ClassImp(AliTOFFEEReader)
36 //_______________________________________________________________
38 AliTOFFEEReader::AliTOFFEEReader() :
40 fFEEConfig(new AliTOFFEEConfig()),
51 //_______________________________________________________________
53 AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
55 fFEEConfig(new AliTOFFEEConfig())
63 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
66 //_______________________________________________________________
69 AliTOFFEEReader::operator=(const AliTOFFEEReader &source)
77 TObject::operator=(source);
78 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
82 //_______________________________________________________________
84 AliTOFFEEReader::~AliTOFFEEReader()
95 //_______________________________________________________________
98 AliTOFFEEReader::ResetChannelEnabledArray()
102 * reset channel enabled array
106 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++)
107 fChannelEnabled[iIndex] = kFALSE;
110 //_______________________________________________________________
113 AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName)
122 is.open(FileName, std::ios::binary);
123 is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig));
127 //_______________________________________________________________
130 AliTOFFEEReader::ParseFEEConfig()
136 * loops over all FEE channels, checks whether they are enabled
137 * and sets channel enabled
141 AliInfo("parsing TOF FEE config")
143 AliTOFRawStream rawStream;
145 Int_t volume[5], index;
148 ResetChannelEnabledArray();
150 /* loop over all FEE channels */
151 for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++)
152 for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++)
153 for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++)
154 for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++)
155 for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++)
156 /* check whether FEE channel is enabled */
157 if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) {
158 /* convert FEE channel indexes into detector indexes */
159 rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume);
160 /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */
161 temp = volume[4]; volume[4] = volume[3]; volume[3] = temp;
162 /* convert detector indexes into calibration index */
163 index = AliTOFGeometry::GetIndex(volume);
164 /* check calibration index */
165 if (index != -1 && index < GetNumberOfIndexes()) {
166 /* set calibration channel enabled */
167 fChannelEnabled[index] = kTRUE;
174 //_______________________________________________________________
177 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel)
183 * checks whether a FEE channel is enabled using the
184 * TOF FEE config object.
188 AliTOFFEEConfig *feeConfig;
189 AliTOFCrateConfig *crateConfig;
190 AliTOFTRMConfig *trmConfig;
191 Int_t maskPB, maskTDC;
193 /* get and check fee config */
194 if (!(feeConfig = GetFEEConfig()))
197 /* get and check crate config */
198 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
201 /* get and check TRM config */
202 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
205 /* check DRM enabled */
206 if (!crateConfig->IsDRMEnabled())
209 /* check TRM enabled */
210 if (!crateConfig->IsTRMEnabled(iTRM - 3))
217 /* check chain enabled */
218 if (trmConfig->GetChainAFlag() != 1)
222 case 0: case 1: case 2:
223 maskPB = trmConfig->GetMaskPB0();
225 case 3: case 4: case 5:
226 maskPB = trmConfig->GetMaskPB1();
228 case 6: case 7: case 8:
229 maskPB = trmConfig->GetMaskPB2();
231 case 9: case 10: case 11:
232 maskPB = trmConfig->GetMaskPB3();
234 case 12: case 13: case 14:
235 maskPB = trmConfig->GetMaskPB4();
244 /* check chain enabled */
245 if (trmConfig->GetChainBFlag() != 1)
249 case 0: case 1: case 2:
250 maskPB = trmConfig->GetMaskPB5();
252 case 3: case 4: case 5:
253 maskPB = trmConfig->GetMaskPB6();
255 case 6: case 7: case 8:
256 maskPB = trmConfig->GetMaskPB7();
258 case 9: case 10: case 11:
259 maskPB = trmConfig->GetMaskPB8();
261 case 12: case 13: case 14:
262 maskPB = trmConfig->GetMaskPB9();
274 /* check channel enabled */
275 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
276 if (maskTDC & (0x1 << iChannel))
285 AliTOFFEEReader::DumpFEEConfig()
293 AliTOFFEEConfig *feeConfig = GetFEEConfig();
294 AliTOFCrateConfig *crateConfig;
295 AliTOFDRMConfig *drmConfig;
296 AliTOFLTMConfig *ltmConfig;
297 AliTOFTRMConfig *trmConfig;
299 AliInfo("-------------------------------------");
300 AliInfo("dumping TOF FEE config");
301 AliInfo("-------------------------------------");
302 AliInfo(Form("version: %d", feeConfig->GetVersion()));
303 AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
304 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
305 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
306 AliInfo("-------------------------------------");
308 /* loop over crates */
309 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
310 crateConfig = feeConfig->GetCrateConfig(iCrate);
312 /* check crate config */
316 /* check DRM enabled */
317 if (!crateConfig->IsDRMEnabled())
320 AliInfo(Form("crate id: %02d", iCrate));
322 /* dump DRM config */
323 drmConfig = crateConfig->GetDRMConfig();
324 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
326 /* dump LTM config if enabled */
327 if (crateConfig->IsLTMEnabled()) {
328 ltmConfig = crateConfig->GetLTMConfig();
329 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
332 /* dump CPDM config if enabled */
333 if (crateConfig->IsCPDMEnabled()) {
334 AliInfo(Form("CPDM is enabled"));
338 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
340 trmConfig = crateConfig->GetTRMConfig(iTRM);
342 /* check TRM config */
346 /* check TRM enabled */
347 if (!crateConfig->IsTRMEnabled(iTRM))
350 /* dump TRM config */
351 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
353 /* check TRM chain A flag */
354 if (trmConfig->GetChainAFlag() == 1) {
355 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()));
358 /* check TRM chain B flag */
359 if (trmConfig->GetChainBFlag() == 1) {
360 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()));
365 } /* loop over TRMs */
366 AliInfo("-------------------------------------");
367 } /* loop over crates */