#include <TSystem.h>
#include "AliTOFFEEReader.h"
#include "AliTOFFEEConfig.h"
+#include "AliTOFFEElightConfig.h"
#include "AliTOFRawStream.h"
#include "AliTOFGeometry.h"
+#include "AliTOFcalibHisto.h"
#include "AliLog.h"
#include <fstream>
AliTOFFEEReader::AliTOFFEEReader() :
TObject(),
fFEEConfig(new AliTOFFEEConfig()),
- fChannelEnabled()
+ fFEElightConfig(new AliTOFFEElightConfig()),
+ fChannelEnabled(),
+ fMatchingWindow(),
+ fLatencyWindow()
{
/*
*
*
*/
+ Reset();
}
//_______________________________________________________________
AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
TObject(source),
- fFEEConfig(new AliTOFFEEConfig())
+ fFEEConfig(new AliTOFFEEConfig()),
+ fFEElightConfig(new AliTOFFEElightConfig())
{
/*
*
*
*/
+ Reset();
memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
+ memcpy(fFEElightConfig, source.fFEElightConfig, sizeof(AliTOFFEElightConfig));
}
//_______________________________________________________________
*
*/
- if (this == &source)
- return *this;
-
TObject::operator=(source);
memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
+ memcpy(fFEElightConfig, source.fFEElightConfig, sizeof(AliTOFFEElightConfig));
return *this;
}
*/
delete fFEEConfig;
+ delete fFEElightConfig;
}
//_______________________________________________________________
//_______________________________________________________________
+void
+AliTOFFEEReader::ResetTriggerMaskArray()
+{
+ /*
+ *
+ * reset trigger mask array
+ *
+ */
+
+ for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++)
+ fTriggerMask[iddl] = 0x0;
+}
+
+//_______________________________________________________________
+
+void
+AliTOFFEEReader::Reset()
+{
+ /*
+ *
+ * reset
+ *
+ */
+
+ for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) {
+ fChannelEnabled[iIndex] = kFALSE;
+ fMatchingWindow[iIndex] = 0;
+ fLatencyWindow[iIndex] = 0;
+ }
+
+ for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++)
+ fTriggerMask[iddl] = 0x0;
+}
+
+//_______________________________________________________________
+
void
AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
{
//_______________________________________________________________
+void
+AliTOFFEEReader::LoadFEElightConfig(const Char_t *FileName) const
+{
+ /*
+ *
+ * load FEElight config
+ *
+ */
+
+ Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
+ std::ifstream is;
+ is.open(expandedFileName, std::ios::binary);
+ is.read((Char_t *)fFEElightConfig, sizeof(AliTOFFEElightConfig));
+ is.close();
+}
+
+//_______________________________________________________________
+
Int_t
AliTOFFEEReader::ParseFEEConfig()
{
*
*/
- AliInfo("parsing TOF FEE config")
+ AliInfo("parsing TOF FEE config");
AliTOFRawStream rawStream;
Int_t nEnabled = 0;
Int_t volume[5], index;
Int_t temp;
- ResetChannelEnabledArray();
+ Reset();
/* loop over all FEE channels */
for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++)
rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume);
/* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */
temp = volume[4]; volume[4] = volume[3]; volume[3] = temp;
+ /* check if index is ok */
+ if (volume[0] < 0 || volume[0] > 17 ||
+ volume[1] < 0 || volume[1] > 4 ||
+ volume[2] < 0 || volume[2] > 18 ||
+ volume[3] < 0 || volume[3] > 1 ||
+ volume[4] < 0 || volume[4] > 47)
+ continue;
/* convert detector indexes into calibration index */
index = AliTOFGeometry::GetIndex(volume);
/* check calibration index */
if (index != -1 && index < GetNumberOfIndexes()) {
/* set calibration channel enabled */
fChannelEnabled[index] = kTRUE;
+ fMatchingWindow[index] = GetMatchingWindow(iDDL, iTRM + 3, iChain, iTDC, iChannel);
nEnabled++;
}
}
//_______________________________________________________________
+Int_t
+AliTOFFEEReader::ParseFEElightConfig()
+{
+ /*
+ *
+ * parse FEElight config
+ *
+ * loops over all FEE channels, checks whether they are enabled
+ * and sets channel enabled
+ *
+ */
+
+ AliInfo("parsing TOF FEElight config");
+
+ Reset();
+
+ AliTOFcalibHisto calibHisto;
+ calibHisto.LoadCalibHisto();
+
+ Int_t nEnabled = 0, index;
+ AliTOFFEEchannelConfig *channelConfig = NULL;
+ for (Int_t i = 0; i < GetNumberOfIndexesEO(); i++) {
+ channelConfig = fFEElightConfig->GetChannelConfig(i);
+ if (!channelConfig->IsEnabled()) continue;
+ /* get index DO from index EO */
+ index = (Int_t)calibHisto.GetCalibMap(AliTOFcalibHisto::kIndex, i);
+ if (index == -1) continue;
+ nEnabled++;
+ fChannelEnabled[index] = channelConfig->IsEnabled();
+ fMatchingWindow[index] = channelConfig->GetMatchingWindow();
+ fLatencyWindow[index] = channelConfig->GetLatencyWindow();
+ }
+
+ AliTOFFEEtriggerConfig *triggerConfig = NULL;
+ for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++) {
+ triggerConfig = fFEElightConfig->GetTriggerConfig(iddl);
+ fTriggerMask[iddl] = triggerConfig->GetStatusMap();
+ }
+
+ return nEnabled;
+}
+
+//_______________________________________________________________
+
Bool_t
AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
{
AliTOFFEEConfig *feeConfig;
AliTOFCrateConfig *crateConfig;
AliTOFTRMConfig *trmConfig;
- Int_t maskPB, maskTDC;
+ Int_t maskPB, maskTDC, activeChip;
/* get and check fee config */
if (!(feeConfig = GetFEEConfig()))
/* check chain enabled */
if (trmConfig->GetChainAFlag() != 1)
return kFALSE;
+ /* get active chip mask */
+ activeChip = trmConfig->GetActiveChipA();
/* switch TDC */
switch (iTDC) {
case 0: case 1: case 2:
/* check chain enabled */
if (trmConfig->GetChainBFlag() != 1)
return kFALSE;
+ /* get active chip mask */
+ activeChip = trmConfig->GetActiveChipB();
/* switch TDC */
switch (iTDC) {
case 0: case 1: case 2:
break;
} /* switch chain */
+ /* check chip enabled */
+ if (!(activeChip & (0x1 << iTDC)))
+ return kFALSE;
+
/* check channel enabled */
maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8);
if (maskTDC & (0x1 << iChannel))
}
+//_______________________________________________________________
+
+Int_t
+AliTOFFEEReader::GetMatchingWindow(Int_t iDDL, Int_t iTRM, Int_t, Int_t, Int_t) const
+{
+ /*
+ *
+ * get matching window
+ *
+ * checks whether a FEE channel is enabled using the
+ * TOF FEE config object and return the associated
+ * matching window
+ *
+ */
+
+ AliTOFFEEConfig *feeConfig;
+ AliTOFCrateConfig *crateConfig;
+ AliTOFTRMConfig *trmConfig;
+
+ /* get and check fee config */
+ if (!(feeConfig = GetFEEConfig()))
+ return 0;
+
+ /* get and check crate config */
+ if (!(crateConfig = feeConfig->GetCrateConfig(iDDL)))
+ return 0;
+
+ /* get and check TRM config */
+ if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3)))
+ return 0;
+
+ /* check DRM enabled */
+ if (!crateConfig->IsDRMEnabled())
+ return 0;
+
+ /* check TRM enabled */
+ if (!crateConfig->IsTRMEnabled(iTRM - 3))
+ return 0;
+
+ return trmConfig->GetMatchingWindow();
+}
+
void
AliTOFFEEReader::DumpFEEConfig()
AliInfo("dumping TOF FEE config");
AliInfo("-------------------------------------");
AliInfo(Form("version: %d", feeConfig->GetVersion()));
- AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
+ AliInfo(Form("dump time: %d", (Int_t)feeConfig->GetDumpTime()));
AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
AliInfo(Form("run type: %d", feeConfig->GetRunType()));
AliInfo("-------------------------------------");
/* check TRM chain A flag */
if (trmConfig->GetChainAFlag() == 1) {
- 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()));
+ 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()));
}
/* check TRM chain B flag */
if (trmConfig->GetChainBFlag() == 1) {
- 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()));
+ 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()));
}
} /* loop over crates */
}
+//_______________________________________________________________
+
+void
+AliTOFFEEReader::CreateFEElightConfig(const Char_t *filename)
+{
+ /*
+ *
+ * create FEElight config
+ *
+ */
+
+ AliTOFFEElightConfig lightConfig;
+
+ for (Int_t i = 0; i < GetNumberOfIndexes(); i++) {
+ if (fChannelEnabled[i]) {
+ lightConfig.GetChannelConfig(i)->SetStatus(AliTOFFEEchannelConfig::kStatusEnabled);
+ lightConfig.GetChannelConfig(i)->SetMatchingWindow(fMatchingWindow[i]);
+ lightConfig.GetChannelConfig(i)->SetLatencyWindow(fLatencyWindow[i]);
+ }
+ else {
+ lightConfig.GetChannelConfig(i)->SetStatus(0x0);
+ lightConfig.GetChannelConfig(i)->SetMatchingWindow(0);
+ lightConfig.GetChannelConfig(i)->SetLatencyWindow(0);
+ }
+ }
+
+ Char_t *expandedFileName = gSystem->ExpandPathName(filename);
+ std::ofstream os;
+ os.open(expandedFileName, std::ios::binary);
+ os.write((Char_t *)&lightConfig, sizeof(AliTOFFEElightConfig));
+ os.close();
+
+}