+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////
+// //
+// Decoding data from the TRD raw stream //
+// and translation into ADC values //
+// //
+// Author: J. Klein (jochen.klein@cern.ch) //
+// //
+////////////////////////////////////////////////////////////////////////////
+
#include "TClonesArray.h"
#include "TTree.h"
Bool_t AliTRDrawStream::NextDDL()
{
+ // continue reading with the next equipment
+
if (!fRawReader)
return kFALSE;
Int_t AliTRDrawStream::NextChamber(AliTRDdigitsManager *digMgr, UInt_t ** /* trackletContainer */, UShort_t ** /* errorContainer */)
{
+ // read the data for the next chamber
+ // in case you only want to read the data of a single chamber
+ // to read all data ReadEvent(...) is recommended
+
fDigitsManager = digMgr;
fDigitsParam = 0x0;
((fCurrStackMask & (1 << fCurrSlot) == 0) ||
(fCurrLinkMask[fCurrSlot] & (1 << fCurrLink)) == 0));
- return fCurrHC / 2;
+ return (fCurrSm * 30 + fCurrStack * 6 + fCurrLayer);
}
// and store the information in the corresponding variables
if (fPayloadCurr - fPayloadStart >= fPayloadSize - 1) {
- AliError(EquipmentError(kUnknown, "SM Header aborted"));
+ AliError(EquipmentError(kUnknown, "SM Header incomplete"));
return -1;
}
// feeding TRAP config
AliTRDtrapConfig *trapcfg = AliTRDtrapConfig::Instance();
- // trapcfg->ReadPackedConfig(fCurrHC, startPos, fPayloadCurr - startPos);
+ trapcfg->ReadPackedConfig(fCurrHC, startPos, fPayloadCurr - startPos);
}
else {
Int_t tpmode = fCurrMajor & 0x7;
fCurrSide = (*fPayloadCurr >> 2) & 0x1;
fCurrCheck = (*fPayloadCurr) & 0x3;
- if (fCurrSm != (fCurrEquipmentId - 1024) ||
+ if (fCurrSm != (((Int_t) fCurrEquipmentId) - 1024) ||
fCurrStack != fCurrSlot ||
fCurrLayer != fCurrLink / 2 ||
fCurrSide != fCurrLink % 2) {
UInt_t *start = fPayloadCurr;
Int_t mcmcount = 0;
- Int_t mcmcount_exp = fCurrStack == 2 ? 48 : 64;
+ Int_t mcmcountExp = fCurrStack == 2 ? 48 : 64;
Int_t channelcount = 0;
- Int_t channelcount_exp = 0;
- Int_t channelcount_max = 0;
+ Int_t channelcountExp = 0;
+ Int_t channelcountMax = 0;
Int_t timebins;
Int_t currentTimebin = 0;
Int_t adcwc = 0;
// ----- analysing the ADC mask -----
channelcount = 0;
- channelcount_exp = GetNActiveChannelsFromMask(*fPayloadCurr);
- channelcount_max = GetNActiveChannels(*fPayloadCurr);
+ channelcountExp = GetNActiveChannelsFromMask(*fPayloadCurr);
+ channelcountMax = GetNActiveChannels(*fPayloadCurr);
Int_t channelmask = GetActiveChannels(*fPayloadCurr);
Int_t channelno = -1;
fPayloadCurr++;
- if (channelcount_exp != channelcount_max) {
- if (channelcount_exp > channelcount_max) {
- Int_t temp = channelcount_exp;
- channelcount_exp = channelcount_max;
- channelcount_max = temp;
+ if (channelcountExp != channelcountMax) {
+ if (channelcountExp > channelcountMax) {
+ Int_t temp = channelcountExp;
+ channelcountExp = channelcountMax;
+ channelcountMax = temp;
}
- while (channelcount_exp < channelcount_max && channelcount_exp < 21 &&
- fPayloadCurr - fPayloadStart < fPayloadSize - 10 * channelcount_exp - 1) {
+ while (channelcountExp < channelcountMax && channelcountExp < 21 &&
+ fPayloadCurr - fPayloadStart < fPayloadSize - 10 * channelcountExp - 1) {
AliError(MCMError(kAdcMaskInconsistent,
Form("Possible MCM-H: 0x%08x, possible ADC-mask: 0x%08x",
- *(fPayloadCurr + 10 * channelcount_exp),
- *(fPayloadCurr + 10 * channelcount_exp + 1) ) ));
- if (!CouldBeMCMhdr( *(fPayloadCurr + 10 * channelcount_exp)) && !CouldBeADCmask( *(fPayloadCurr + 10 * channelcount_exp + 1)))
- channelcount_exp++;
+ *(fPayloadCurr + 10 * channelcountExp),
+ *(fPayloadCurr + 10 * channelcountExp + 1) ) ));
+ if (!CouldBeMCMhdr( *(fPayloadCurr + 10 * channelcountExp)) && !CouldBeADCmask( *(fPayloadCurr + 10 * channelcountExp + 1)))
+ channelcountExp++;
else {
break;
}
}
AliError(MCMError(kAdcMaskInconsistent,
Form("Inconsistency in no. of active channels: Counter: %i, Mask: %i, chosen: %i!",
- GetNActiveChannels(fPayloadCurr[-1]), GetNActiveChannelsFromMask(fPayloadCurr[-1]), channelcount_exp) ));
+ GetNActiveChannels(fPayloadCurr[-1]), GetNActiveChannelsFromMask(fPayloadCurr[-1]), channelcountExp) ));
}
- AliDebug(2, Form("expecting %i active channels, timebins: %i", channelcount_exp, fCurrNtimebins));
+ AliDebug(2, Form("expecting %i active channels, timebins: %i", channelcountExp, fCurrNtimebins));
// ----- reading marked ADC channels -----
- while (channelcount < channelcount_exp && *(fPayloadCurr) != fgkDataEndmarker) {
+ while (channelcount < channelcountExp && *(fPayloadCurr) != fgkDataEndmarker) {
if (channelno < 21)
channelno++;
while (channelno < 21 && (channelmask & 1 << channelno) == 0)
channelcount++;
}
- if (channelcount != channelcount_exp)
+ if (channelcount != channelcountExp)
AliError(MCMError(kAdcChannelsMiss));
mcmcount++;
}
// check for missing MCMs (if header suppression is inactive)
- if (fCurrMajor & 0x1 == 0 && mcmcount != mcmcount_exp) {
+ if (fCurrMajor & 0x1 == 0 && mcmcount != mcmcountExp) {
AliError(LinkError(kMissMcmHeaders,
Form("No. of MCM headers %i not as expected: %i",
- mcmcount, mcmcount_exp) ));
+ mcmcount, mcmcountExp) ));
}
return (fPayloadCurr - start);
UInt_t *start = fPayloadCurr;
Int_t mcmcount = 0;
- Int_t mcmcount_exp = fCurrStack == 2 ? 48 : 64;
+ Int_t mcmcountExp = fCurrStack == 2 ? 48 : 64;
Int_t channelcount = 0;
- Int_t channelcount_exp = 0;
+ Int_t channelcountExp = 0;
Int_t timebins;
Int_t currentTimebin = 0;
Int_t adcwc = 0;
}
channelcount = 0;
- channelcount_exp = 21;
+ channelcountExp = 21;
int channelno = -1;
Int_t adccoloff = AdcColOffset(*fPayloadCurr);
fPayloadCurr++;
// ----- reading marked ADC channels -----
- while (channelcount < channelcount_exp &&
+ while (channelcount < channelcountExp &&
*(fPayloadCurr) != fgkDataEndmarker) {
if (channelno < 21)
channelno++;
channelcount++;
}
- if (channelcount != channelcount_exp)
+ if (channelcount != channelcountExp)
AliError(MCMError(kAdcChannelsMiss));
mcmcount++;
// continue with next MCM
}
// check for missing MCMs (if header suppression is inactive)
- if (mcmcount != mcmcount_exp) {
+ if (mcmcount != mcmcountExp) {
AliError(LinkError(kMissMcmHeaders,
- Form("%i not as expected: %i", mcmcount, mcmcount_exp) ));
+ Form("%i not as expected: %i", mcmcount, mcmcountExp) ));
}
return (fPayloadCurr - start);
}
-Int_t AliTRDrawStream::GetNActiveChannelsFromMask(UInt_t adcmask)
+Int_t AliTRDrawStream::GetNActiveChannelsFromMask(UInt_t adcmask) const
{
+ // return number of active bits in the ADC mask
+
adcmask = GetActiveChannels(adcmask);
adcmask = adcmask - ((adcmask >> 1) & 0x55555555);
adcmask = (adcmask & 0x33333333) + ((adcmask >> 2) & 0x33333333);
TString AliTRDrawStream::EquipmentError(ErrorCode_t err, TString msg)
{
+ // register error according to error code on equipment level
+ // and return the corresponding error message
+
fLastError.fSector = fCurrEquipmentId - 1024;
fLastError.fStack = -1;
fLastError.fLink = -1;
TString AliTRDrawStream::StackError(ErrorCode_t err, TString msg)
{
+ // register error according to error code on stack level
+ // and return the corresponding error message
+
fLastError.fSector = fCurrEquipmentId - 1024;
fLastError.fStack = fCurrSlot;
fLastError.fLink = -1;
TString AliTRDrawStream::LinkError(ErrorCode_t err, TString msg)
{
+ // register error according to error code on link level
+ // and return the corresponding error message
+
fLastError.fSector = fCurrEquipmentId - 1024;
fLastError.fStack = fCurrSlot;
fLastError.fLink = fCurrLink;
TString AliTRDrawStream::ROBError(ErrorCode_t err, TString msg)
{
+ // register error according to error code on ROB level
+ // and return the corresponding error message
+
fLastError.fSector = fCurrEquipmentId - 1024;
fLastError.fStack = fCurrSlot;
fLastError.fLink = fCurrLink;
TString AliTRDrawStream::MCMError(ErrorCode_t err, TString msg)
{
+ // register error according to error code on MCM level
+ // and return the corresponding error message
+
fLastError.fSector = fCurrEquipmentId - 1024;
fLastError.fStack = fCurrSlot;
fLastError.fLink = fCurrLink;
const char* AliTRDrawStream::GetErrorMessage(ErrorCode_t errCode)
{
+ // return the error message for the given error code
+
if (errCode > 0 && errCode < kLastErrorCode)
return fgErrorMessages[errCode];
else
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+//-----------------------------------
+//
+// decoding of TRD raw data stream
+// and translation into digits
+//
+//----------------------------------
+
#ifndef ALITRDRAWSTREAM_H
#define ALITRDRAWSTREAM_H
kLastErrorCode
};
- TTree* GetErrorTree() { return fErrors; }
+ TTree* GetErrorTree() const { return fErrors; }
static const char* GetErrorMessage(ErrorCode_t errCode);
protected:
Int_t ReadNonZSData();
// MCM header decoding
- Int_t ROB(UInt_t mcmhdr) { return 0x7 & mcmhdr >> 28; }
- Int_t MCM(UInt_t mcmhdr) { return 0xf & mcmhdr >> 24; }
- Int_t Row(UInt_t mcmhdr) { return (ROB(mcmhdr) / 2) * 4 + MCM(mcmhdr) / 4; }
- Int_t AdcColOffset(UInt_t mcmhdr) { return (MCM(mcmhdr) % 4 + 1) * 21 + (ROB(mcmhdr) % 2) * 84 - 1; }
- Int_t PadColOffset(UInt_t mcmhdr) { return (MCM(mcmhdr) % 4 + 1) * 18 + (ROB(mcmhdr) % 2) * 72 + 1; }
- Int_t EvNo(UInt_t mcmhdr) { return 0xfffff & mcmhdr >> 4; }
- Int_t Check(UInt_t mcmhdr) { return 0xf & mcmhdr; }
- Int_t CouldBeMCMhdr(UInt_t mcmhdr) { return ((0xf & mcmhdr) == 0xc); }
-
- Int_t GetMCMReadoutPos(Int_t mcm) { return (mcm > -1 && mcm < 16) ? fgkMcmOrder[mcm] : -1; }
- Int_t GetROBReadoutPos(Int_t rob) { return (rob > -1 && rob < 4) ? fgkRobOrder[rob] : -1; }
+ Int_t ROB(UInt_t mcmhdr) const { return 0x7 & mcmhdr >> 28; }
+ Int_t MCM(UInt_t mcmhdr) const { return 0xf & mcmhdr >> 24; }
+ Int_t Row(UInt_t mcmhdr) const { return (ROB(mcmhdr) / 2) * 4 + MCM(mcmhdr) / 4; }
+ Int_t AdcColOffset(UInt_t mcmhdr) const { return (MCM(mcmhdr) % 4 + 1) * 21 + (ROB(mcmhdr) % 2) * 84 - 1; }
+ Int_t PadColOffset(UInt_t mcmhdr) const { return (MCM(mcmhdr) % 4 + 1) * 18 + (ROB(mcmhdr) % 2) * 72 + 1; }
+ Int_t EvNo(UInt_t mcmhdr) const { return 0xfffff & mcmhdr >> 4; }
+ Int_t Check(UInt_t mcmhdr) const { return 0xf & mcmhdr; }
+ Int_t CouldBeMCMhdr(UInt_t mcmhdr) const { return ((0xf & mcmhdr) == 0xc); }
+
+ Int_t GetMCMReadoutPos(Int_t mcm) const { return (mcm > -1 && mcm < 16) ? fgkMcmOrder[mcm] : -1; }
+ Int_t GetROBReadoutPos(Int_t rob) const { return (rob > -1 && rob < 4) ? fgkRobOrder[rob] : -1; }
// ADC mask decoding
- Int_t GetActiveChannels(UInt_t adcmask) { return 0x1fffff & adcmask >> 4; }
- Int_t GetNActiveChannelsFromMask(UInt_t adcmask); // { Int_t nch = 0; for (Int_t i = 0; i < 21; i++) if ((GetActiveChannels(adcmask) & 1 << i)) nch++; return nch; }
- Int_t GetNActiveChannels(UInt_t adcmask) { return (0x1f & ~(adcmask >> 25)); }
- Int_t CouldBeADCmask(UInt_t adcmask) { return ((0xf & adcmask) == 0xc && (0x3 & adcmask >> 30) == 0x1); }
+ Int_t GetActiveChannels(UInt_t adcmask) const { return 0x1fffff & adcmask >> 4; }
+ Int_t GetNActiveChannelsFromMask(UInt_t adcmask) const; // { Int_t nch = 0; for (Int_t i = 0; i < 21; i++) if ((GetActiveChannels(adcmask) & 1 << i)) nch++; return nch; }
+ Int_t GetNActiveChannels(UInt_t adcmask) const { return (0x1f & ~(adcmask >> 25)); }
+ Int_t CouldBeADCmask(UInt_t adcmask) const { return ((0xf & adcmask) == 0xc && (0x3 & adcmask >> 30) == 0x1); }
// error message generation
TString EquipmentError(ErrorCode_t err = kUnknown, TString msg = "");
TString ROBError (ErrorCode_t err = kUnknown, TString msg = "");
TString MCMError (ErrorCode_t err = kUnknown, TString msg = "");
- static char* fgErrorMessages[kLastErrorCode];
+ static char* fgErrorMessages[kLastErrorCode]; // error messages corresponding to the error codes
// I/O
- AliRawReader *fRawReader;
- AliTRDdigitsManager *fDigitsManager;
- AliTRDdigitsParam *fDigitsParam;
+ AliRawReader *fRawReader; // pointer to the raw reader to take the data from
+ AliTRDdigitsManager *fDigitsManager; // pointer to the digitsManager to fill the data
+ AliTRDdigitsParam *fDigitsParam; // pointer to the parameters belonging to the digits
- TTree *fErrors;
- struct { Int_t fSector; Int_t fStack; Int_t fLink; Int_t fError; Int_t fRob; Int_t fMcm; } fLastError;
+ TTree *fErrors; // tree containing the occured error codes
+ struct { Int_t fSector; Int_t fStack; Int_t fLink; Int_t fError; Int_t fRob; Int_t fMcm; }
+ fLastError; // last error which occured
- UInt_t *fPayloadStart;
- UInt_t *fPayloadCurr;
- Int_t fPayloadSize;
+ UInt_t *fPayloadStart; // pointer to start of data payload
+ UInt_t *fPayloadCurr; // pointer to current reading position in the payload
+ Int_t fPayloadSize; // size of the payload
- static const Int_t fgkNlinks;
- static const Int_t fgkNstacks;
- static const UInt_t fgkDataEndmarker;
- static const UInt_t fgkTrackletEndmarker;
- static const Int_t fgkMcmOrder [];
- static const Int_t fgkRobOrder [];
+ static const Int_t fgkNlinks; // number of links to read
+ static const Int_t fgkNstacks; // number of stacks to read
+ static const UInt_t fgkDataEndmarker; // data endmarker
+ static const UInt_t fgkTrackletEndmarker; // tracklet endmarker
+ static const Int_t fgkMcmOrder []; // expected readout order of the MCMs
+ static const Int_t fgkRobOrder []; // expected readout order of the ROBs
// persistent information
- Int_t fNtimebins;
- Int_t fLastEvId;
+ Int_t fNtimebins; // number of timebins
+ Int_t fLastEvId; // Event ID of last event
// information valid at current reader position
- Int_t fCurrSlot;
- Int_t fCurrLink;
- Int_t fCurrRobPos;
- Int_t fCurrMcmPos;
+ // all the variables fCurr... refer to the value at the current
+ // reading position
+ Int_t fCurrSlot; // current slot
+ Int_t fCurrLink; // current link
+ Int_t fCurrRobPos; // current ROB number
+ Int_t fCurrMcmPos; // current MCM number
// DDL header
- UInt_t fCurrEquipmentId;
+ UInt_t fCurrEquipmentId; // current Equipment ID
// SMU index header
- UInt_t fCurrSmuIndexHeaderSize;
- UInt_t fCurrSmuIndexHeaderVersion;
- UInt_t fCurrTrackEnable;
- UInt_t fCurrTrackletEnable;
- UInt_t fCurrStackMask;
+ UInt_t fCurrSmuIndexHeaderSize; // current size of the SMU index header
+ UInt_t fCurrSmuIndexHeaderVersion; // current version of the SMU index header
+ UInt_t fCurrTrackEnable; // current value of track enable
+ UInt_t fCurrTrackletEnable; // current value of tracklet enable
+ UInt_t fCurrStackMask; // current mask of active stacks
// Stack index header
- UInt_t *fCurrStackIndexWord;
- UInt_t *fCurrStackHeaderSize;
- UInt_t *fCurrStackHeaderVersion;
- UInt_t *fCurrLinkMask;
- UInt_t *fCurrCleanCheckout;
- UInt_t *fCurrBoardId;
- UInt_t *fCurrHwRev;
- UInt_t *fCurrLinkMonitorFlags;
- UInt_t *fCurrLinkDataTypeFlags;
- UInt_t *fCurrLinkDebugFlags;
+ UInt_t *fCurrStackIndexWord; // current stack index words
+ UInt_t *fCurrStackHeaderSize; // current stack index sizes
+ UInt_t *fCurrStackHeaderVersion; // current stack header versions
+ UInt_t *fCurrLinkMask; // current link masks
+ UInt_t *fCurrCleanCheckout; // current clean checkout flags
+ UInt_t *fCurrBoardId; // current board IDs
+ UInt_t *fCurrHwRev; // current hardware revision
+ UInt_t *fCurrLinkMonitorFlags; // current link monitor flags
+ UInt_t *fCurrLinkDataTypeFlags; // current link data flags
+ UInt_t *fCurrLinkDebugFlags; // current link debug flags
// HC information
- Int_t fCurrSpecial;
- Int_t fCurrMajor;
- Int_t fCurrMinor;
- Int_t fCurrAddHcWords;
- Int_t fCurrSm;
- Int_t fCurrStack;
- Int_t fCurrLayer;
- Int_t fCurrSide;
- Int_t fCurrHC;
- Int_t fCurrCheck;
- Int_t fCurrNtimebins;
- Int_t fCurrBC;
- Int_t fCurrPtrgCnt;
- Int_t fCurrPtrgPhase;
+ Int_t fCurrSpecial; // current value of the special flag
+ Int_t fCurrMajor; // current major version
+ Int_t fCurrMinor; // current minor version
+ Int_t fCurrAddHcWords; // current number of additional HC-header words
+ Int_t fCurrSm; // current sector
+ Int_t fCurrStack; // current stack
+ Int_t fCurrLayer; // current layer
+ Int_t fCurrSide; // current side
+ Int_t fCurrHC; // current HC
+ Int_t fCurrCheck; // current check bits
+ Int_t fCurrNtimebins; // current number of timebins
+ Int_t fCurrBC; // current BC
+ Int_t fCurrPtrgCnt; // current pretrigger count
+ Int_t fCurrPtrgPhase; // current pretrigger phase
// tracklet information
- TClonesArray *fTrackletArray;
+ TClonesArray *fTrackletArray; // pointer to array for tracklet storage
// output data
- AliTRDarrayADC *fAdcArray;
- AliTRDSignalIndex *fSignalIndex;
- TTree *fTrackletTree;
+ AliTRDarrayADC *fAdcArray; // pointer to ADC array
+ AliTRDSignalIndex *fSignalIndex; // pointer to the signal index
+ TTree *fTrackletTree; // pointer to the tree for tracklet storage
AliTRDrawStream(const AliTRDrawStream&); // not implemented
- AliTRDrawStream operator=(const AliTRDrawStream&); // not implemented
+ AliTRDrawStream& operator=(const AliTRDrawStream&); // not implemented
ClassDef(AliTRDrawStream, 0);
};