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)
82 TObject::operator=(source);
83 memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
87 //_______________________________________________________________
89 AliTOFFEEReader::~AliTOFFEEReader()
100 //_______________________________________________________________
103 AliTOFFEEReader::ResetChannelEnabledArray()
107 * reset channel enabled array
111 for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++)
112 fChannelEnabled[iIndex] = kFALSE;
115 //_______________________________________________________________
118 AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
126 Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
128 is.open(expandedFileName, std::ios::binary);
129 is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig));
133 //_______________________________________________________________
136 AliTOFFEEReader::ParseFEEConfig()
142 * loops over all FEE channels, checks whether they are enabled
143 * and sets channel enabled
147 AliInfo("parsing TOF FEE config")
149 AliTOFRawStream rawStream;
151 Int_t volume[5], index;
154 ResetChannelEnabledArray();
156 /* loop over all FEE channels */
157 for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++)
158 for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++)
159 for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++)
160 for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++)
161 for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++)
162 /* check whether FEE channel is enabled */
163 if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) {
164 /* convert FEE channel indexes into detector indexes */
165 rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume);
166 /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */
167 temp = volume[4]; volume[4] = volume[3]; volume[3] = temp;
168 /* convert detector indexes into calibration index */
169 index = AliTOFGeometry::GetIndex(volume);
170 /* check calibration index */
171 if (index != -1 && index < GetNumberOfIndexes()) {
172 /* set calibration channel enabled */
173 fChannelEnabled[index] = kTRUE;
180 //_______________________________________________________________
183 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
189 * checks whether a FEE channel is enabled using the
190 * TOF FEE config object.
194 AliTOFFEEConfig *feeConfig;
195 AliTOFCrateConfig *crateConfig;
196 AliTOFTRMConfig *trmConfig;
197 Int_t maskPB, maskTDC;
199 /* get and check fee config */
200 if (!(feeConfig = GetFEEConfig()))
203 /* get and check crate config */
204 if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
207 /* get and check TRM config */
208 if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
211 /* check DRM enabled */
212 if (!crateConfig->IsDRMEnabled())
215 /* check TRM enabled */
216 if (!crateConfig->IsTRMEnabled(iTRM - 3))
223 /* check chain enabled */
224 if (trmConfig->GetChainAFlag() != 1)
228 case 0: case 1: case 2:
229 maskPB = trmConfig->GetMaskPB0();
231 case 3: case 4: case 5:
232 maskPB = trmConfig->GetMaskPB1();
234 case 6: case 7: case 8:
235 maskPB = trmConfig->GetMaskPB2();
237 case 9: case 10: case 11:
238 maskPB = trmConfig->GetMaskPB3();
240 case 12: case 13: case 14:
241 maskPB = trmConfig->GetMaskPB4();
250 /* check chain enabled */
251 if (trmConfig->GetChainBFlag() != 1)
255 case 0: case 1: case 2:
256 maskPB = trmConfig->GetMaskPB5();
258 case 3: case 4: case 5:
259 maskPB = trmConfig->GetMaskPB6();
261 case 6: case 7: case 8:
262 maskPB = trmConfig->GetMaskPB7();
264 case 9: case 10: case 11:
265 maskPB = trmConfig->GetMaskPB8();
267 case 12: case 13: case 14:
268 maskPB = trmConfig->GetMaskPB9();
280 /* check channel enabled */
281 maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
282 if (maskTDC & (0x1 << iChannel))
291 AliTOFFEEReader::DumpFEEConfig()
299 AliTOFFEEConfig *feeConfig = GetFEEConfig();
300 AliTOFCrateConfig *crateConfig;
301 AliTOFDRMConfig *drmConfig;
302 AliTOFLTMConfig *ltmConfig;
303 AliTOFTRMConfig *trmConfig;
305 AliInfo("-------------------------------------");
306 AliInfo("dumping TOF FEE config");
307 AliInfo("-------------------------------------");
308 AliInfo(Form("version: %d", feeConfig->GetVersion()));
309 AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
310 AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
311 AliInfo(Form("run type: %d", feeConfig->GetRunType()));
312 AliInfo("-------------------------------------");
314 /* loop over crates */
315 for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) {
316 crateConfig = feeConfig->GetCrateConfig(iCrate);
318 /* check crate config */
322 /* check DRM enabled */
323 if (!crateConfig->IsDRMEnabled())
326 AliInfo(Form("crate id: %02d", iCrate));
328 /* dump DRM config */
329 drmConfig = crateConfig->GetDRMConfig();
330 AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask()));
332 /* dump LTM config if enabled */
333 if (crateConfig->IsLTMEnabled()) {
334 ltmConfig = crateConfig->GetLTMConfig();
335 AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold()));
338 /* dump CPDM config if enabled */
339 if (crateConfig->IsCPDMEnabled()) {
340 AliInfo(Form("CPDM is enabled"));
344 for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) {
346 trmConfig = crateConfig->GetTRMConfig(iTRM);
348 /* check TRM config */
352 /* check TRM enabled */
353 if (!crateConfig->IsTRMEnabled(iTRM))
356 /* dump TRM config */
357 AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag()));
359 /* check TRM chain A flag */
360 if (trmConfig->GetChainAFlag() == 1) {
361 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()));
364 /* check TRM chain B flag */
365 if (trmConfig->GetChainBFlag() == 1) {
366 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()));
371 } /* loop over TRMs */
372 AliInfo("-------------------------------------");
373 } /* loop over crates */