#include "AliAltroRawStream.h"
#include "AliRawReader.h"
#include "AliLog.h"
+#include "AliRawEventHeaderBase.h"
ClassImp(AliAltroRawStream)
//_____________________________________________________________________________
AliAltroRawStream::AliAltroRawStream(AliRawReader* rawReader) :
- fNoAltroMapping(kTRUE),
fIsShortDataHeader(kFALSE),
fDDLNumber(-1),
fPrevDDLNumber(-1),
fData(NULL),
fPosition(0),
fCount(0),
+ fChannelPayloadSize(-1),
fBunchLength(0),
fRCUTrailerData(NULL),
fRCUTrailerSize(0),
fFECERRA(0),
fFECERRB(0),
fERRREG2(0),
+ fERRREG3(0),
+ fERRREG4(0),
fActiveFECsA(0),
fActiveFECsB(0),
fAltroCFG1(0),
fAltroCFG2(0)
{
// create an object to read Altro raw digits
- fSegmentation[0] = fSegmentation[1] = fSegmentation[2] = -1;
}
//_____________________________________________________________________________
AliAltroRawStream::AliAltroRawStream(const AliAltroRawStream& stream) :
TObject(stream),
- fNoAltroMapping(stream.fNoAltroMapping),
fIsShortDataHeader(stream.fIsShortDataHeader),
fDDLNumber(stream.fDDLNumber),
fPrevDDLNumber(stream.fPrevDDLNumber),
fData(stream.fData),
fPosition(stream.fPosition),
fCount(stream.fCount),
+ fChannelPayloadSize(stream.fChannelPayloadSize),
fBunchLength(stream.fBunchLength),
fRCUTrailerData(stream.fRCUTrailerData),
fRCUTrailerSize(stream.fRCUTrailerSize),
fFECERRA(stream.fFECERRA),
fFECERRB(stream.fFECERRB),
fERRREG2(stream.fERRREG2),
+ fERRREG3(stream.fERRREG3),
+ fERRREG4(stream.fERRREG4),
fActiveFECsA(stream.fActiveFECsA),
fActiveFECsB(stream.fActiveFECsB),
fAltroCFG1(stream.fAltroCFG1),
fAltroCFG2(stream.fAltroCFG2)
{
- fSegmentation[0] = stream.fSegmentation[0];
- fSegmentation[1] = stream.fSegmentation[1];
- fSegmentation[2] = stream.fSegmentation[2];
}
//_____________________________________________________________________________
{
if(&stream == this) return *this;
- fNoAltroMapping = stream.fNoAltroMapping;
fIsShortDataHeader = stream.fIsShortDataHeader;
fDDLNumber = stream.fDDLNumber;
fPrevDDLNumber = stream.fPrevDDLNumber;
fData = stream.fData;
fPosition = stream.fPosition;
fCount = stream.fCount;
+ fChannelPayloadSize= stream.fChannelPayloadSize;
fBunchLength = stream.fBunchLength;
fRCUTrailerData = stream.fRCUTrailerData;
fRCUTrailerSize = stream.fRCUTrailerSize;
fFECERRA = stream.fFECERRA;
fFECERRB = stream.fFECERRB;
fERRREG2 = stream.fERRREG2;
+ fERRREG3 = stream.fERRREG3;
+ fERRREG4 = stream.fERRREG4;
fActiveFECsA = stream.fActiveFECsA;
fActiveFECsB = stream.fActiveFECsB;
fAltroCFG1 = stream.fAltroCFG1;
fAltroCFG2 = stream.fAltroCFG2;
- fSegmentation[0] = stream.fSegmentation[0];
- fSegmentation[1] = stream.fSegmentation[1];
- fSegmentation[2] = stream.fSegmentation[2];
-
return *this;
}
// reset altro raw stream params
fPosition = fCount = fBunchLength = 0;
+ fChannelPayloadSize = -1;
fRCUTrailerData = NULL;
fRCUTrailerSize = 0;
- fFECERRA = fFECERRB = fERRREG2 = fActiveFECsA = fActiveFECsB = fAltroCFG1 = fAltroCFG2 = 0;
+ fFECERRA = fFECERRB = fERRREG2 = fERRREG3 = fERRREG4 = fActiveFECsA = fActiveFECsB = fAltroCFG1 = fAltroCFG2 = 0;
fDDLNumber = fPrevDDLNumber = fRCUId = fPrevRCUId = fHWAddress = fPrevHWAddress = fTime = fPrevTime = fSignal = fTimeBunch = -1;
if (fRawReader) fRawReader->Reset();
-
- fSegmentation[0] = fSegmentation[1] = fSegmentation[2] = -1;
}
//_____________________________________________________________________________
fPrevTime = fTime;
while (fCount == 0) { // next trailer
- if (fPosition <= 0) { // next payload
+ while (fPosition <= 0) { // next payload
do {
if (!fRawReader->ReadNextData(fData)) return kFALSE;
} while (fRawReader->GetDataSize() == 0);
return kTRUE;
}
+//_____________________________________________________________________________
+Bool_t AliAltroRawStream::NextDDL(UChar_t *data)
+{
+ if (!data) {
+ do {
+ if (!fRawReader->ReadNextData(fData)) return kFALSE;
+ } while (fRawReader->GetDataSize() == 0);
+ }
+ else {
+ fData = data;
+ }
+
+ fDDLNumber = fRawReader->GetDDLID();
+ fChannelPayloadSize = -1;
+ fPosition = GetPosition();
+
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAltroRawStream::NextChannel()
+{
+ if (fPosition <= 0) return kFALSE;
+
+ ReadTrailer();
+
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAltroRawStream::NextBunch(UShort_t *bunchData,
+ Int_t &bunchLength,
+ Int_t &startTimeBin)
+{
+ if (fCount == 0) return kFALSE;
+
+ ReadBunch();
+ bunchLength = fTimeBunch;
+ startTimeBin = fTime;
+
+ while (fBunchLength > 0) {
+ ReadAmplitude();
+ bunchData[bunchLength-fBunchLength-1] = fSignal;
+ }
+
+ return kTRUE;
+}
+
//_____________________________________________________________________________
void AliAltroRawStream::SelectRawData(Int_t detId)
{
Bool_t AliAltroRawStream::ReadTrailer()
{
//Read a trailer of 40 bits in the backward reading mode
- //In case of no mapping is provided, read a dummy trailer
- if (fNoAltroMapping) {
- AliError("No ALTRO mapping information is loaded! Reading a dummy trailer!");
- return ReadDummyTrailer();
- }
-
//First reading filling words
UShort_t temp;
Int_t nFillWords = 0;
if (nFillWords == 0) {
fRawReader->AddMajorErrorLog(kAltroTrailerErr,"no 0x2AA");
// PrintDebug();
- AliWarning("Incorrect trailer found ! Expected 0x2AA not found !");
+ AliWarning(Form("Incorrect trailer found ! Expected 0x2AA not found (0x%x != 0x2AA) ! Current position %d, DDL=%d",
+ temp,fPosition,fDDLNumber));
// trying to recover and find the next bunch
- while ((fPosition > 5) && (temp != 0x2AA)) temp = GetNextWord();
+ while ((fPosition > 2) && (temp != 0x2AA)) temp = GetNextWord();
if (temp != 0x2AA) {
fCount = fPosition = 0;
return kFALSE;
}
//Then read the trailer
- if (fPosition < 5) {
+ if (fPosition < 2) {
fRawReader->AddMajorErrorLog(kAltroTrailerErr,Form("size %d < 5",
- fPosition));
+ fPosition));
// PrintDebug();
AliWarning(Form("Incorrect raw data size ! Expected at least 5 words but found %d !",fPosition));
fCount = fPosition = 0;
return kFALSE;
}
fCount |= ((temp & 0x3FF) >> 6);
- if (fCount == 0) return kFALSE;
+ fChannelPayloadSize = fCount;
+
if (fCount >= fPosition) {
fRawReader->AddMajorErrorLog(kAltroTrailerErr,"invalid size");
// PrintDebug();
return kTRUE;
}
-//_____________________________________________________________________________
-Bool_t AliAltroRawStream::ReadDummyTrailer()
-{
- //Read a trailer of 40 bits in the backward reading mode
- //In case of no mapping is provided, read a dummy trailer
- UShort_t temp;
- while ((temp = GetNextWord()) == 0x2AA);
-
- fSegmentation[0] = temp;
- fSegmentation[1] = GetNextWord();
- fSegmentation[2] = GetNextWord();
- fCount = GetNextWord();
- if (fCount == 0) return kFALSE;
- fHWAddress = -1;
-
- fPosition -= (4 - (fCount % 4)) % 4; // skip fill words
-
- return kTRUE;
-}
-
//_____________________________________________________________________________
void AliAltroRawStream::ReadBunch()
{
}
Int_t position = ReadRCUTrailer(index,trailerSize);
- // The size is specified in a number of 40bits
- // Therefore we need to transform it to number of bytes
- position *= 5;
+ if (fRawReader->GetType() != AliRawEventHeaderBase::kStartOfData) {
+ // The size is specified in a number of 40bits
+ // Therefore we need to transform it to number of bytes
+ position *= 5;
- // Check the consistency of the header and trailer
- if (((fRawReader->GetDataSize() - trailerSize*4) < position) ||
- ((fRawReader->GetDataSize() - trailerSize*4) >= (position + 4))) {
- fRawReader->AddMajorErrorLog(kRCUTrailerSizeErr,Form("h=%d tr=%d rcu=%d bytes",
- fRawReader->GetDataSize(),
- trailerSize*4,
- position));
- AliWarning(Form("Inconsistent raw data size ! Raw data size - %d bytes (from the header), RCU trailer - %d bytes, raw data paylod - %d bytes !",
- fRawReader->GetDataSize(),
- trailerSize*4,
- position));
- position = fRawReader->GetDataSize() - trailerSize*4;
- }
+ // Check the consistency of the header and trailer
+ if (((fRawReader->GetDataSize() - trailerSize*4) < position) ||
+ ((fRawReader->GetDataSize() - trailerSize*4) >= (position + 4))) {
+ fRawReader->AddMajorErrorLog(kRCUTrailerSizeErr,Form("h=%d tr=%d rcu=%d bytes",
+ fRawReader->GetDataSize(),
+ trailerSize*4,
+ position));
+ AliWarning(Form("Inconsistent raw data size ! Raw data size - %d bytes (from the header), RCU trailer - %d bytes, raw data paylod - %d bytes !",
+ fRawReader->GetDataSize(),
+ trailerSize*4,
+ position));
+ position = fRawReader->GetDataSize() - trailerSize*4;
+ }
- return position * 8 / 10;
+ return position * 8 / 10;
+ }
+ else {
+ // Special RCU payload in case of SOD events
+ // The decoding is left to the user code
+ // Here we just retrieve the payload size
+ return position;
+ }
}
else {
// In case of the Old RCU trailer format
break;
case 3:
// ERR_REG3
- if (parData != 0xAAAAAA) {
- fRawReader->AddMinorErrorLog(kRCUTrailerErr,"no 0xAAAAAA");
- AliWarning(Form("Parameter code %d : no 0xAAAAAA found !",
- parCode));
- }
+ fERRREG3 = parData & 0xFFF;
break;
case 4:
// ERR_REG4
- if (parData != 0xAAAAAA) {
- fRawReader->AddMinorErrorLog(kRCUTrailerErr,"no 0xAAAAAA");
- AliWarning(Form("Parameter code %d : no 0xAAAAAA found !",
- parCode));
- }
+ fERRREG4 = parData & 0xFFF;
break;
case 5:
// FEC_RO_A
break;
case 7:
// RDO_CFG1
- fAltroCFG1 = parData & 0x7FFFF;
+ fAltroCFG1 = parData & 0xFFFFF;
break;
case 8:
// RDO_CFG2
if (index < 4) {
fRawReader->AddMajorErrorLog(kRCUTrailerErr,Form("tr=%d raw=%d bytes",
- trailerSize*4,
+ fRCUTrailerSize,
fRawReader->GetDataSize()));
AliWarning(Form("Invalid trailer size found (%d bytes) ! The size is bigger than the raw data size (%d bytes)!",
- trailerSize*4,
+ fRCUTrailerSize,
fRawReader->GetDataSize()));
}
- fRCUTrailerSize = trailerSize*4;
fRCUTrailerData = fData + index;
Int_t position = Get32bitWord(index);
Double_t tSample = GetTSample();
if (phase >= tSample) {
- AliWarning(Form("Invalid L1 trigger phase (%f >= %d) !",
+ AliWarning(Form("Invalid L1 trigger phase (%f >= %f) !",
phase,tSample));
phase = 0.;
}
printf("RCU trailer:\n===========\n");
printf("FECERRA: 0x%x\nFECERRB: 0x%x\n",fFECERRA,fFECERRB);
printf("ERRREG2: 0x%x\n",fERRREG2);
+ printf("#channels skipped due to address mismatch: %d\n",GetNChAddrMismatch());
+ printf("#channels skipped due to bad block length: %d\n",GetNChLengthMismatch());
printf("Active FECs (branch A): 0x%x\nActive FECs (branch B): 0x%x\n",fActiveFECsA,fActiveFECsB);
printf("Baseline corr: 0x%x\n",GetBaselineCorr());
printf("Number of presamples: %d\nNumber of postsamples: %d\n",GetNPresamples(),GetNPostsamples());
printf("Number of pretrigger samples: %d\n",GetNPretriggerSamples());
printf("Number of samples per channel: %d\n",GetNSamplesPerCh());
printf("Sparse readout: %d\n",GetSparseRO());
- printf("Sampling time: %f s\n",GetTSample());
- printf("L1 Phase: %f s\n",GetL1Phase());
+ printf("Sampling time: %e s\n",GetTSample());
+ printf("L1 Phase: %e s\n",GetL1Phase());
+ printf("AltroCFG1: 0x%x\nAltroCFG2: 0x%x\n",GetAltroCFG1(),GetAltroCFG2());
printf("===========\n");
}
if (fRawReader) fRawReader->AddMinorErrorLog(kBadAltroMapping,message);
}
+
+//_____________________________________________________________________________
+Int_t AliAltroRawStream::GetRCUPayloadSizeInSOD() const
+{
+ // Get the size of the RCU data in case
+ // of SOD events
+ if (fRawReader) {
+ if (fRawReader->GetType() == AliRawEventHeaderBase::kStartOfData) {
+ return fPosition;
+ }
+ }
+ return -1;
+}