-#ifndef ALITRDRAWSTREAM_H\r
-#define ALITRDRAWSTREAM_H\r
-\r
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * See cxx source for full Copyright notice */\r
-\r
-/* $Id: AliTRDrawStream.h 27696 2008-07-31 09:18:53Z cblume $ */\r
-\r
-///////////////////////////////////////////////////////////////////////////////\r
-// //\r
-// This class provides access to TRD digits in raw data. //\r
-// //\r
-///////////////////////////////////////////////////////////////////////////////\r
-\r
-#include "TObject.h"\r
-#include "TString.h"\r
-#include "AliTRDrawStreamBase.h"\r
-\r
-class AliTRDgeometry;\r
-class AliRawReader;\r
-class AliTRDdigitsManager;\r
-class TTreeSRedirector;\r
-class AliTRDfeeParam;\r
-\r
-\r
-class AliTRDrawStream : public AliTRDrawStreamBase\r
-{ // class def begin\r
-\r
- public:\r
- \r
- //--------------------------------------------------------\r
-\r
- // THE STRUCTURES\r
- \r
- //--------------------------------------------------------\r
-\r
- struct AliTRDrawADC\r
- {//adc struct\r
-\r
- UInt_t *fPos; //! position of ADC 1st word in the buffer\r
- Short_t fADCnumber; // number of the ADC 0 .. 20\r
- Short_t fCOL; // column - row from MCM\r
- Int_t fSignals[TRD_MAX_TBINS]; // signals for this adc\r
- Bool_t fIsShared; // is pad chared between MCMs\r
- Short_t fCorrupted; // is adc word corrupted\r
-\r
- AliTRDrawADC()\r
- : fPos(0)\r
- , fADCnumber(0)\r
- , fCOL(0)\r
- , fSignals()\r
- , fIsShared(kFALSE)\r
- , fCorrupted(0)\r
- {\r
- // default constructor\r
- };\r
-\r
- AliTRDrawADC(const AliTRDrawADC& p): \r
- fPos(p.fPos)\r
- , fADCnumber(p.fADCnumber)\r
- , fCOL(p.fCOL)\r
- , fSignals()\r
- , fIsShared(p.fIsShared)\r
- , fCorrupted(p.fCorrupted)\r
- {\r
- // copy constructor\r
- };\r
-\r
- AliTRDrawADC &operator=(const AliTRDrawADC &) \r
- {\r
- // assignment operator\r
- // not implemented\r
- return *this;\r
- };\r
-\r
- };\r
- \r
- //--------------------------------------------------------\r
-\r
- struct AliTRDrawMCM\r
- { // mcm struct\r
- Int_t fROB; // ROB number\r
- Int_t fMCM; // MCM number\r
- Int_t fROW; // row number filed during decoding\r
- \r
- UInt_t fEvCounter; // MCM event counter\r
- UInt_t fADCMask; // ADC mask\r
- UInt_t fADCMaskWord; // word with ADC mask in\r
- UInt_t fADCchannel[TRD_MAX_ADC]; // channels to be decoded accrording to ADC mask\r
- \r
- Int_t fADCmax; // number of ADCs fired\r
- Int_t fADCcount; // number of ADCs fired from double checking bit\r
- Int_t fMCMADCWords; // mcm words to expect\r
- Int_t fSingleADCwords; // n of words per ADC\r
- \r
- Int_t fMCMhdCorrupted; // is mcm header corrupted\r
- Int_t fADCmaskCorrupted; // is mcm adc mask corrupted\r
- Int_t fCorrupted; // is mcm data missing\r
- \r
- UInt_t *fPos; //! position of mcm header in the buffer\r
- UInt_t *fAdcDataPos; //! start of ADC data for this mcm\r
-\r
- Int_t fADCcounter; // count the adcs decoded\r
- AliTRDrawADC fADCs[TRD_MAX_ADC]; // 21 adcs\r
- \r
- AliTRDrawMCM()\r
- : fROB(-1)\r
- , fMCM(-1)\r
- , fROW(-1)\r
- , fEvCounter(0)\r
- , fADCMask(0)\r
- , fADCMaskWord(0)\r
- , fADCchannel() \r
- , fADCmax(0)\r
- , fADCcount(0)\r
- , fMCMADCWords(0) \r
- , fSingleADCwords(0)\r
- , fMCMhdCorrupted(0) \r
- , fADCmaskCorrupted(0) \r
- , fCorrupted(0) \r
- , fPos(0)\r
- , fAdcDataPos(0)\r
- , fADCcounter(0)\r
- , fADCs()\r
- {\r
- // default constructor\r
- };\r
-\r
- AliTRDrawMCM(const AliTRDrawMCM & p):\r
- fROB(p.fROB)\r
- , fMCM(p.fMCM)\r
- , fROW(p.fROW)\r
- , fEvCounter(p.fEvCounter)\r
- , fADCMask(p.fADCMask)\r
- , fADCMaskWord(p.fADCMaskWord)\r
- , fADCchannel() \r
- , fADCmax(p.fADCmax)\r
- , fADCcount(p.fADCcount)\r
- , fMCMADCWords(p.fMCMADCWords) \r
- , fSingleADCwords(p.fSingleADCwords)\r
- , fMCMhdCorrupted(p.fMCMhdCorrupted) \r
- , fADCmaskCorrupted(p.fADCmaskCorrupted) \r
- , fCorrupted(p.fCorrupted) \r
- , fPos(p.fPos)\r
- , fAdcDataPos(p.fAdcDataPos)\r
- , fADCcounter(p.fADCcounter)\r
- , fADCs()\r
- {\r
- // copy constructor\r
- };\r
-\r
- AliTRDrawMCM &operator=(const AliTRDrawMCM &)\r
- {\r
- // assignment operator\r
- // not implemented\r
- return *this;\r
- };\r
-\r
- };\r
-\r
- //--------------------------------------------------------\r
-\r
- struct AliTRDrawHC\r
- { // hc struct\r
- \r
- //tacklet words of given HC\r
- UInt_t fTrackletWords[MAX_TRACKLETS_PERHC]; // array to keep tracklet words [mj]\r
- Short_t fTrackletError; // tracklet error \r
- Short_t fNTracklets; // number of tracklet \r
-\r
- // header word 0\r
- Int_t fSpecialRawV; // Raw data version\r
- Int_t fRawVMajor; // Raw data version\r
- Int_t fRawVMajorOpt; // Raw data version\r
- Int_t fRawVMinor; // Raw data version\r
- Int_t fNExtraWords; // N extra HC header words\r
- Int_t fDCSboard; // DCS board number\r
- Int_t fSM; // Super Module number\r
- Int_t fStack; // Stack number (some people might call it a chamber)\r
- Int_t fLayer; // Layer number (some people might call it a plane)\r
- Int_t fSide; // Side of HC\r
- \r
- // header word 1\r
- Int_t fTimeBins; // N of t bins\r
- UInt_t fBunchCrossCounter; // Bunch crossing counter\r
- UInt_t fPreTriggerCounter; // Pre Trigger counter\r
- UInt_t fPreTriggerPhase; // Pre Trigger phase\r
- \r
- // error \r
- Int_t fH0Corrupted; // is hc header 0 corrupted \r
- Int_t fH1Corrupted; // is hc header 1 corrupted\r
- Int_t fCorrupted; // is hc data corrupted \r
-\r
- UInt_t *fPos[2]; //! position of the header words in buffer\r
- \r
- Int_t fDET; // filled while decoding\r
- Int_t fROC; // filled while decoding\r
- Int_t fRowMax; // filled while decoding\r
- Int_t fColMax; // filled while decoding\r
-\r
- // hc data\r
- Int_t fMCMmax; // number of mcm found\r
- AliTRDrawMCM fMCMs[TRD_MAX_MCM]; // 4 ROBS 16 each \r
-\r
- AliTRDrawHC()\r
- : fTrackletWords() //[mj]\r
- , fTrackletError(0)\r
- , fNTracklets(0)\r
- , fSpecialRawV(0)\r
- , fRawVMajor(0)\r
- , fRawVMajorOpt(0)\r
- , fRawVMinor(0)\r
- , fNExtraWords(0)\r
- , fDCSboard(-1)\r
- , fSM(-1)\r
- , fStack(-1)\r
- , fLayer(-1)\r
- , fSide(-1)\r
- , fTimeBins(0)\r
- , fBunchCrossCounter(0)\r
- , fPreTriggerCounter(0)\r
- , fPreTriggerPhase(0)\r
- , fH0Corrupted(0)\r
- , fH1Corrupted(0)\r
- , fCorrupted(0)\r
- , fPos()\r
- , fDET(-1)\r
- , fROC(-1)\r
- , fRowMax(-1)\r
- , fColMax(-1)\r
- , fMCMmax(0)\r
- , fMCMs()\r
- {\r
- // default constructor hc info \r
- };\r
-\r
- AliTRDrawHC(const AliTRDrawHC & p):\r
- fTrackletWords() //[mj]\r
- , fTrackletError(p.fTrackletError)\r
- , fNTracklets(p.fNTracklets)\r
- , fSpecialRawV(p.fSpecialRawV)\r
- , fRawVMajor(p.fRawVMajor)\r
- , fRawVMajorOpt(p.fRawVMajorOpt)\r
- , fRawVMinor(p.fRawVMinor)\r
- , fNExtraWords(p.fNExtraWords)\r
- , fDCSboard(p.fDCSboard)\r
- , fSM(p.fSM)\r
- , fStack(p.fStack)\r
- , fLayer(p.fLayer)\r
- , fSide(p.fSide)\r
- , fTimeBins(p.fTimeBins)\r
- , fBunchCrossCounter(p.fBunchCrossCounter)\r
- , fPreTriggerCounter(p.fPreTriggerCounter)\r
- , fPreTriggerPhase(p.fPreTriggerPhase)\r
- , fH0Corrupted(p.fH0Corrupted)\r
- , fH1Corrupted(p.fH1Corrupted)\r
- , fCorrupted(p.fCorrupted)\r
- , fPos()\r
- , fDET(p.fDET)\r
- , fROC(p.fROC)\r
- , fRowMax(p.fRowMax)\r
- , fColMax(p.fColMax)\r
- , fMCMmax(p.fMCMmax)\r
- , fMCMs()\r
- {\r
- // copy constructor\r
- };\r
-\r
- AliTRDrawHC &operator=(const AliTRDrawHC &)\r
- {\r
- // assignment operator\r
- // not implemented\r
- return *this;\r
- };\r
-\r
- };\r
-\r
- //--------------------------------------------------------\r
- \r
- struct AliTRDrawStack\r
- {\r
- UInt_t fHeaderSize; // header size of the stack info\r
- Bool_t fLinksActive[12]; // data links active - 1 per half chamber\r
- Short_t fLinksDataType[12]; // 0 indicating real data for the front-end electronics \r
- Short_t fLinksMonitor[12]; // 0 indicating properly operating link \r
- Short_t fLinkMonitorError[12]; // record link monitor error\r
- Int_t fActiveLinks; // number of active links\r
- UInt_t *fPos; //! position in the buffer\r
- \r
- AliTRDrawHC fHalfChambers[12]; // 12 half chambers in a stack\r
- \r
- AliTRDrawStack()\r
- : fHeaderSize(0)\r
- , fLinksActive()\r
- , fLinksDataType()\r
- , fLinksMonitor()\r
- , fLinkMonitorError()\r
- , fActiveLinks(0)\r
- , fPos(0)\r
- , fHalfChambers()\r
- {\r
- // default constructor\r
- }; \r
-\r
- AliTRDrawStack(const AliTRDrawStack & p):\r
- fHeaderSize(p.fHeaderSize)\r
- , fLinksActive()\r
- , fLinksDataType()\r
- , fLinksMonitor()\r
- , fLinkMonitorError()\r
- , fActiveLinks(p.fActiveLinks)\r
- , fPos(p.fPos)\r
- , fHalfChambers()\r
- {\r
- // copy constructor\r
- };\r
-\r
- AliTRDrawStack &operator=(const AliTRDrawStack &)\r
- {\r
- // assignment operator\r
- // not implemented\r
- return *this;\r
- };\r
-\r
- };\r
-\r
- //--------------------------------------------------------\r
-\r
- struct AliTRDrawSM\r
- {\r
- UInt_t fHeaderSize; // size of the header in words\r
- Bool_t fTrackletEnable; // tracklet enable bit\r
- Bool_t fStackActive[5]; // map of active/expected stacks\r
- Int_t fActiveStacks; // number of active stacks\r
- Int_t fCorrupted; // is sm info corrupted\r
- Int_t fNexpectedHalfChambers; // number of half chambers to be read out in this sm\r
- Bool_t fClean; // true if everything went OK - false is some error occured\r
- UInt_t *fPos; // location of the sm info - should be the first word (after CDH if not DDL buffer)\r
-\r
- AliTRDrawStack fStacks[5]; \r
-\r
- AliTRDrawSM()\r
- : fHeaderSize(0)\r
- , fTrackletEnable(0)\r
- , fStackActive()\r
- , fActiveStacks(0)\r
- , fCorrupted(0)\r
- , fNexpectedHalfChambers(0)\r
- , fClean(kTRUE)\r
- , fPos(0)\r
- , fStacks()\r
- {\r
- // Default constructor\r
- }; \r
-\r
- AliTRDrawSM(const AliTRDrawSM & p):\r
- fHeaderSize(p.fHeaderSize)\r
- , fTrackletEnable(p.fTrackletEnable)\r
- , fStackActive()\r
- , fActiveStacks(p.fActiveStacks)\r
- , fCorrupted(p.fCorrupted)\r
- , fNexpectedHalfChambers(p.fNexpectedHalfChambers)\r
- , fClean(p.fClean)\r
- , fPos(p.fPos)\r
- , fStacks()\r
- {\r
- // copy constructor\r
- };\r
-\r
- AliTRDrawSM &operator=(const AliTRDrawSM &)\r
- {\r
- // assignment operator\r
- // not implemented\r
- return *this;\r
- };\r
-\r
- };\r
- \r
- //--------------------------------------------------------\r
- \r
- AliTRDrawStream();\r
- AliTRDrawStream(AliRawReader *rawReader);\r
- virtual ~AliTRDrawStream();\r
-\r
- //--------------------------------------------------------\r
-\r
- virtual Bool_t Next(); // read the next data in the memory\r
- //virtual Int_t NextChamber(AliTRDdigitsManager *man); // read next chamber data in the momory\r
- virtual Int_t NextChamber(AliTRDdigitsManager *man, UInt_t **trackletContainer); // read next chamber data in the memory\r
- virtual Bool_t Init(); // initialize some internal variables\r
-\r
- Int_t NextBuffer(); // go and init next buffer if available - check the implementation file for return values\r
-\r
- Bool_t SetRawVersion(Int_t fraw); // set the raw version - used for backward compat.\r
- \r
- Bool_t IsCurrentPadShared() const {return fADC->fIsShared;} // is current pad shared between mcms\r
- void SetSharedPadReadout(Bool_t fv) {fSharedPadsOn = fv;} // set the flag on if the reader should return the shared pads\r
- \r
- Bool_t DecodeSM(void *buffer, UInt_t length); // decode a buffer\r
- Int_t DecodeSM(); // used with raw reader\r
- Int_t DecodeSM(AliRawReader *reader); // used with raw reader\r
- \r
- Bool_t SetReader(AliRawReader *reader); // set the raw reader to use\r
- \r
- // info from Supermodule Index Word\r
- Bool_t IsTrackletEnableBitSet() const {return fSM.fTrackletEnable;} // get status of tracklet enable bit\r
- Bool_t IsStackActive(Int_t is) const {return fSM.fStackActive[is];} // get status of stack enable bit\r
- Int_t GetNofActiveStacks() const {return fSM.fActiveStacks;} // get number of active stacks from stack mask\r
- UInt_t *GetGTUheaderWords() const {return fSM.fPos;} // get number of active stacks from stack mask\r
-\r
- // info from Stack Index Word\r
- Int_t GetNexpectedHalfChambers() const {return fSM.fNexpectedHalfChambers;} // get number of expected HC in a sm\r
- Int_t GetNofActiveLinksInStack(Int_t is) const {return fSM.fStacks[is].fActiveLinks;} // get number of active links in a stack\r
- Bool_t IsLinkActiveInStack(Int_t is, Int_t il) const {return fSM.fStacks[is].fLinksActive[il];} // check whether the link is active\r
-\r
- // info from Stack Header Word\r
- Short_t GetLinkMonitorError(Int_t is, Int_t il) const {return fSM.fStacks[is].fLinkMonitorError[il];} // get link monitor error\r
-\r
- // info from Tracklet Data\r
- Int_t GetTrackletErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fTrackletError;}\r
- Int_t GetNTracklets(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fNTracklets;} // get number of tracklets \r
-\r
- // info from HC Header Word\r
- Int_t GetSM(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fSM;}\r
- Int_t GetLayer(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fLayer;}\r
- Int_t GetStack(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fStack;}\r
- Int_t GetSide(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fSide;}\r
- Int_t GetH0ErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fH0Corrupted;}\r
- Int_t GetH1ErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fH1Corrupted;}\r
- Int_t GetNumberOfTimeBins(Int_t is, Int_t il) const { return fSM.fStacks[is].fHalfChambers[il].fTimeBins;}\r
- UInt_t *GetTrackletWords(Int_t is, Int_t il) { return fSM.fStacks[is].fHalfChambers[il].fTrackletWords;}\r
-\r
- // info from HC data\r
- Int_t GetHCErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fCorrupted;}\r
- Int_t GetHCMCMmax(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fMCMmax;}\r
-\r
- // from MCM Header Word\r
- // rob and mcm ordering\r
- // side 0(even link) - ROB: 0 2 4 6 MCM: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3 \r
- // side 1( odd link) - ROB: 1 3 5 7 MCM: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3 \r
- Int_t GetMCM(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fMCM;}\r
- Int_t GetROB(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fROB;}\r
- Int_t GetMCMhdErrorCode(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fMCMhdCorrupted;}\r
- Int_t GetMCMADCMaskErrorCode(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCmaskCorrupted;}\r
- Int_t GetEventNumber(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fEvCounter;}\r
- Int_t GetADCcount(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCcount;}\r
-\r
- // info from MCM data words\r
- Int_t GetMCMErrorCode(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fCorrupted;} // get MCM data error code\r
- Int_t GetADCErrorCode(Int_t stack, Int_t link, Int_t mcm, Int_t adc) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fCorrupted;} // get ADC error code\r
- Int_t GetADCnumber(Int_t stack, Int_t link, Int_t mcm, Int_t adc) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fADCnumber;} // get ADC error code\r
-\r
- Int_t GetRow(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fROW;} // get current row number\r
- Int_t GetCol(Int_t stack, Int_t link, Int_t mcm, Int_t adc) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fCOL;} // get current column number\r
-\r
- // info from ADC data words\r
- Int_t *GetSignalDirect(Int_t stack, Int_t link, Int_t mcm, Int_t adc) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fSignals;}\r
-\r
-\r
- // from here, only works with returning ADC channel pointer using Next() \r
- UInt_t *GetTrackletWords() const { return fHC->fTrackletWords;} // return tracklet words pointer per hc [mj]\r
- Int_t GetTrackletErrorCode() const {return fHC ? fHC->fTrackletError : -1;} // get tracklet error code\r
- Int_t GetNTracklets() const {return fHC ? fHC->fNTracklets : -1;} // get number of tracklets \r
-\r
- Int_t GetSpecialRawVersion() const {return fHC ? fHC->fSpecialRawV : -1;} // return special raw version\r
- Int_t GetMajorRawVersion() const {return fHC ? fHC->fRawVMajor : -1;} // major raw version getter\r
- Int_t GetRawVersion() const {return fHC ? fHC->fRawVMajor : -1;} // compatibility see funtion above\r
- Int_t GetMinorRawVersion() const {return fHC ? fHC->fRawVMinor : -1;} // minor raw version\r
-\r
- Int_t GetSM() const {return fHC ? fHC->fSM : -1;} // SM Position of CURRENT half chamber in full TRD\r
- Int_t GetLayer() const {return fHC ? fHC->fLayer : -1;} // Layer Position of CURRENT half chamber in full TRD\r
- Int_t GetStack() const {return fHC ? fHC->fStack : -1;} // Stack Position of CURRENT half chamber in full TRD\r
- Int_t GetSide() const {return fHC ? fHC->fSide : -1;} // get side\r
- Int_t GetDCS() const { return fHC ? fHC->fDCSboard : -1;} // DCS board number read from data (HC header)\r
- Int_t GetROC() const { return fHC ? fHC->fROC : -1;} // ROB Position of CURRENT half chamber in full TRD\r
- Int_t GetNumberOfTimeBins() const { return fHC ? fHC->fTimeBins : 0;} // Get Ntime bins\r
- UInt_t GetBunchCrossCounter() const {return fHC ? fHC->fBunchCrossCounter : 0;} // get bunch cross counter\r
- UInt_t GetPreTriggerCounter() const {return fHC ? fHC->fPreTriggerCounter : 0;} // get pre trigger info\r
- UInt_t GetPreTriggerPhase() const {return fHC ? fHC->fPreTriggerPhase : 0;} // get trigger phase\r
-\r
- Int_t GetRow() const {return fMCM ? fMCM->fROW : -1;} // get current row number\r
- Int_t GetCol() const {return fADC ? fADC->fCOL : -1;} // get current column number\r
- Int_t GetRowMax() const { return fHC ? fHC->fRowMax : -1;} // Get maximum rows in the current HC\r
- Int_t GetColMax() const { return fHC ? fHC->fColMax : -1;} // Get maximum cols in the current HC\r
- // compatibility\r
- Int_t GetMaxRow() const { return fHC ? fHC->fRowMax : -1;} // Get maximum rows in the current HC\r
- Int_t GetMaxCol() const { return fHC ? fHC->fColMax : -1;} // Get maximum cols in the current HC\r
-\r
- UInt_t GetHCword0() const {return fHC ? *fHC->fPos[0] : 0;} // get the HC word 0\r
- UInt_t GetHCword1() const {return fHC ? *fHC->fPos[1] : 0;} // get the HC word 1\r
- \r
- Int_t GetDET() const {return fHC ? fHC->fDET : -1;} // get current det number\r
- Int_t GetDet() const {return fHC ? fHC->fDET : -1;} // get current det number\r
- \r
- Int_t GetROB() const {return fMCM ? fMCM->fROB : -1;} // get current ROB number\r
- Int_t GetMCM() const {return fMCM ? fMCM->fMCM : -1;} // get current MCM number\r
- Int_t GetEventNumber() const { return fMCM->fEvCounter;} // MCM Event number and position of current MCM on TRD chamber\r
-\r
- Int_t GetADC() const { return fADC ? fADC->fADCnumber : -1;} // MCM ADC channel and Time Bin of word 1\r
- Int_t GetTimeBin() const { return 0;} // MCM ADC channel and Time Bin of word 1\r
- Int_t *GetSignals() const { return fADC ? fADC->fSignals : (Int_t *)fgEmptySignals;} // signals in the n-time bins from data word\r
-\r
- Int_t GetHCErrorCode() const {return fHC ? fHC->fCorrupted : -1;} // get HC error code\r
- Int_t GetH0ErrorCode() const {return fHC ? fHC->fH0Corrupted : -1;} // get HC header word0 error code\r
- Int_t GetH1ErrorCode() const {return fHC ? fHC->fH1Corrupted : -1;} // get HC header word1 error code\r
- Int_t GetMCMErrorCode() const {return fMCM ? fMCM->fCorrupted : -1;} // get MCM data error code\r
- Int_t GetADCErrorCode() const {return fADC ? fADC->fCorrupted : -1;} // get ADC data error code\r
- Int_t GetMCMhdErrorCode() const {return fMCM ? fMCM->fMCMhdCorrupted: -1;} // get MCM header word error code\r
- Int_t GetMCMADCMaskErrorCode() const {return fMCM ? fMCM->fADCmaskCorrupted: -1;} // get MCM adc mask error code\r
-\r
- UInt_t *GetSMstreamPosition() const {return fSM.fPos;} // get position of the SM index word in the buffer\r
-\r
- Bool_t IsSMbufferClean() const {return fSM.fClean;} // is data clean\r
-\r
- //----------------------------------------------------------\r
- \r
- static void SetNoDebug() {fgDebugFlag = kFALSE;} // allow debug info\r
- static void EnableMemoryReset() {fgEnableMemoryReset = kTRUE;} // allow memory reset\r
- static void SetNoErrorWarning() {fgWarnError = kFALSE;} // disable warning and error info\r
- static void SetForceCleanDataOnly() {fgCleanDataOnly = kTRUE;} // clean data only\r
- static void AllowCorruptedData() {fgCleanDataOnly = kFALSE;} // accept corrupted data\r
-\r
- static void SetExtraWordsFix() {fgExtraSkip = kTRUE;} // extra skip of 24 32-bit words \r
- static void SetSkipCDH() {fgSkipCDH = kTRUE;} // skip of 8 32-bit words \r
- static void SetDumpHead(Int_t iv) {fgDumpHead = iv;}\r
- static void DisableStackNumberChecker() {fgStackNumberChecker = kFALSE;} // set false to cleanroom data \r
- static void DisableStackLinkNumberChecker() {fgStackLinkNumberChecker = kFALSE;} \r
- static void DisableSkipData() {fgSkipData = kFALSE;} // keep reading next words even previous words were corrupted - debugging purpose \r
- static void SetDumpingEnable() {fgDumpingEnable = kTRUE;} \r
- static void SetDumpingMCM(Int_t sm, Int_t stack, Int_t layer, Int_t rob, Int_t mcm) {fgDumpingSM = sm; fgDumpingStack = stack; fgDumpingLayer = layer; fgDumpingROB = rob; fgDumpingMCM = mcm;}\r
-\r
- // this is a temporary solution!\r
- // baseline should come with the HC header word 2 (count from 0!)\r
- static void SetSubtractBaseline(Int_t baseline) {fgCommonAdditive = baseline;}\r
- Int_t GetCommonAdditive() const {return fgCommonAdditive;} // return the common additive\r
-\r
- static void EnableDecodeConfigData() {fgEnableDecodeConfigData = kTRUE;} // allow configuration data decoding\r
- static Bool_t fgEnableDecodeConfigData;\r
-\r
-\r
- //--------------------------------------------------------\r
- // Decoding functions\r
- //--------------------------------------------------------\r
-\r
- void DecodeSMInfo(const UInt_t *word, struct AliTRDrawSM *sm) const ;\r
- const char *DumpSMInfo(const struct AliTRDrawSM *sm);\r
- void DecodeStackInfo(const UInt_t *word, struct AliTRDrawStack *st) const;\r
- void DecodeStackHeader(const UInt_t *word, struct AliTRDrawStack *st, Int_t iword) const;\r
- const char *DumpStackInfo(const struct AliTRDrawStack *st);\r
- Bool_t DecodeHCwordH0(const UInt_t *word, struct AliTRDrawHC *hc) const;\r
- Bool_t DecodeHCwordH1(const UInt_t *word, struct AliTRDrawHC *hc) const;\r
- const char *DumpHCinfoH0(const struct AliTRDrawHC *hc);\r
- const char *DumpHCinfoH1(const struct AliTRDrawHC *hc);\r
- void DecodeMCMheader(const UInt_t *word, struct AliTRDrawMCM *mcm) const;\r
- UInt_t GetMCMadcMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const;\r
- void DecodeMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const;\r
- void MCMADCwordsWithTbins(UInt_t fTbins, struct AliTRDrawMCM *mcm) const;\r
- const char *DumpMCMinfo(const struct AliTRDrawMCM *mcm);\r
- const char *DumpMCMadcMask(const struct AliTRDrawMCM *mcm);\r
-\r
-\r
- protected:\r
-\r
- Bool_t InitBuffer(void *buffer, UInt_t length); // init the buffer - called by DecodeSM(void*, UInt_t)\r
- Bool_t DumpWords(UInt_t *px, UInt_t iw, UInt_t marker = 0); // dump some words onto the screen\r
-\r
- void SwapOnEndian(); // swap if endian is BIG\r
- Bool_t SkipWords(UInt_t iw); // skip number of words\r
- Bool_t DecodeGTUheader(); // decode data in GTU header\r
- Bool_t DecodeTracklets(); // decode tracklets\r
- Bool_t DecodeHC(); // decode data in HC\r
-\r
- Bool_t DecodeADC(); // decode 10 ADC words\r
-\r
- Bool_t DecodeHCheader(); // decode HC header\r
- Bool_t SeekEndOfData(); // go to next end of raw data marker (actually 1 word after)\r
- Bool_t SkipMCMdata(UInt_t iw); // skip this mcm data due to mcm header corruption\r
- Bool_t SeekNextMCMheader(); // go to next mcm header\r
- Bool_t DecodeMCMheader(); // decode mcm header\r
-\r
- Bool_t IsRowValid(); // check if row within the range\r
- Bool_t IsHCheaderOK(); // check if current hc header data make sense\r
- Bool_t IsMCMheaderOK(); // check if current mcm header data make sense\r
- \r
- void ResetCounters(); // reset some counters\r
- void ResetIterators(); // needed for Next()\r
- void ResetPerSM(); // reset every SM \r
- void ResetPerStack(); // reset every Stack \r
- void ResetPerHC(); // reset every HC \r
- void ResetPerMCM(); // reset every MCM \r
- void ResetPerADC(); // reset every ADC \r
- void ResetMemory(); // reset all data members\r
-\r
- AliTRDrawStream(const AliTRDrawStream& st);\r
- AliTRDrawStream &operator=(const AliTRDrawStream &);\r
-\r
- // ----------------- DATA MEMBERS START\r
-\r
- struct AliTRDrawSM fSM; // one SM per buffer\r
- struct AliTRDrawStack *fStack; //! pointer to the current stack\r
- struct AliTRDrawHC *fHC; //! current HC\r
- struct AliTRDrawMCM *fMCM; //! current MCM\r
- struct AliTRDrawADC *fADC; //! current ADC\r
- \r
- UInt_t *fpPos; // current position in the buffer\r
- UInt_t *fpBegin; // begin - pointer to the buffer word 0\r
- UInt_t *fpEnd; // end of the buffer\r
-\r
- UInt_t fWordLength; // length of the buffer in 32bit words\r
-\r
- Int_t fStackNumber; // current stack number\r
- Int_t fStackLinkNumber; // current link in the stack\r
-\r
- Int_t fhcMCMcounter; // mcm counter inside single hc - used in Next() \r
- Int_t fmcmADCcounter; // adc counrer inside single adc - used in Next() \r
-\r
- Int_t fLinkTrackletCounter; // count the tracklets in the current HC\r
- Int_t fEndOfTrackletCount; // count link by link (hc by hc) used for debug\r
- Int_t fNWordsCounter; // counts words of given hc having link monitor error\r
-\r
- UInt_t fMaskADCword; // temp mask when decoding adcs\r
- UInt_t fTbinADC; // temp adc \r
- Int_t fDecodedADCs; // counter of decoded adcs [mj] do we need?\r
-\r
- UInt_t fEventCounter; // stores the valid/current MCM event counter\r
- UInt_t fLastEventCounter; // last known event counter of MCM\r
-\r
- Bool_t fSharedPadsOn; // do we want to output shared pads - default is off\r
- Int_t fMaxADCgeom; // maximum ADC channels per mcm\r
-\r
- Bool_t fBufferRead;\r
-\r
- AliTRDgeometry *fGeometry; //! TRD geometry\r
- AliRawReader *fRawReader; //! raw reader \r
-\r
- AliTRDfeeParam *fTRDfeeParam; // pointer to the fee params\r
-\r
- // STATIC \r
-\r
- static Bool_t fgExtraSkip; // whether we should skip the leading 24 words\r
- static Bool_t fgSkipCDH; // whether we should skip CDH (8 words)\r
- static Bool_t fgWarnError; // no errors no warnings\r
- static Bool_t fgCleanDataOnly; // release only clean events = no errors\r
- static Bool_t fgDebugFlag; // allow debugging info\r
- static Bool_t fgEnableMemoryReset; // allow memory reset\r
- static Bool_t fgStackNumberChecker; // decide if we check stack number insanity - set false to cleanroom data\r
- static Bool_t fgStackLinkNumberChecker; // decide if we check stack link number insanity - debuging purpose\r
- static Bool_t fgSkipData; // decide if we skip corrupted data of given HC\r
- static Int_t fgDumpHead; // number of words to dump (from the start of the buffer) on each Init\r
- static Int_t fgEmptySignals[30]; // empty signals in case of ADC pointer = NULL\r
- static Short_t fgMCMordering[16]; // mcm number odering for mcm header corruption check\r
- static Short_t fgROBordering[16]; // mcm number odering for mcm header corruption check\r
- static Int_t fgLastHC; \r
- static Int_t fgLastROB; \r
- static Int_t fgLastIndex; \r
-\r
- static Bool_t fgDumpingEnable; \r
-\r
- static Int_t fgDumpingSM;\r
- static Int_t fgDumpingStack;\r
- static Int_t fgDumpingLayer;\r
- static Int_t fgDumpingROB;\r
- static Int_t fgDumpingMCM;\r
-\r
- // this is a temporary solution!\r
- // baseline should come with the HC header word 2 (count from 0!)\r
- static Int_t fgCommonAdditive; // common additive - should be decoded! from HC word2\r
-\r
- // ----------------- DATA MEMBERS STOP\r
-\r
- enum ETRDzRawStreamError \r
- {\r
- kDecodeStackInfo = 1 //\r
- , kMissingData = 2 //\r
- , kLinkDataMissing = 3 //\r
- , kHCdataMissing = 4 //\r
- , kTrackletOverflow = 5 //\r
- , kEOTrackeltsMissing = 6 //\r
- , kWrongPadrow = 7 //\r
- , kMCMheaderCorrupted = 8 //\r
- , kWrongMCMorROB = 9 //\r
- , kMCMeventMissmatch = 10 //\r
- , kMCMADCMaskMissing = 11 //\r
- , kHCHeaderCorrupt = 12 //\r
- , kHCHeaderWrongStack = 13 //\r
- , kHCHeaderWrongLayer = 14 //\r
- , kHCHeaderWrongSide = 15 //\r
- , kHCHeaderWrongSM = 16 //\r
- , kHCHeaderWrongDet = 17 //\r
- , kHCHeaderWrongROC = 18 //\r
- , kHCWordMissing = 19 //\r
- , kMCMdataMissing = 20 //\r
- , kMCMoverflow = 21 //\r
- , kADCdataMissing = 22 //\r
- , kADCmaskMissmatch = 23 //\r
- , kWrongPadcolumn = 24 //\r
- }; \r
-\r
- ClassDef(AliTRDrawStream, 0)\r
-}; //clas def end\r
-\r
-#endif\r
+/* 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
+
+#include "TTree.h"
+#include "AliLog.h"
+#include "TClonesArray.h"
+
+class TObject;
+class TObjArray;
+class TString;
+class TBranch;
+
+class AliRawReader;
+class AliTRDdigitsManager;
+class AliTRDdigitsParam;
+class AliTRDarrayADC;
+class AliTRDSignalIndex;
+class AliTRDtrackletContainer;
+class AliESDTrdTrack;
+
+class AliTRDrawStream : public TObject
+{
+ public:
+ AliTRDrawStream(AliRawReader *rawReader = 0x0);
+ ~AliTRDrawStream();
+
+ enum { kDDLOffset = 0x400, // Offset for DDL numbers
+ kDDLMax = 0x411 }; // Max DDL number for TRD SM
+
+ Bool_t SetReader(AliRawReader *rawReader) { fRawReader = rawReader; return kTRUE; }
+ void SetDigitsManager(AliTRDdigitsManager *digMgr) { fDigitsManager = digMgr; }
+ void SetTrackletArray(TClonesArray *ar) { fTracklets = ar; }
+ void SetTrackArray(TClonesArray *ar) { fTracks = ar; }
+ void SetMarkerArray(TClonesArray *ar) { fMarkers = ar; }
+
+ TClonesArray* GetTrackletArray() const { return fTracklets; }
+ TClonesArray* GetTrackArray() const { return fTracks; }
+ TClonesArray* GetMarkerArray() const { return fMarkers; }
+
+ AliTRDdigitsManager* GetDigitsManager() const { return fDigitsManager; }
+
+ Bool_t ReadEvent();
+
+ Bool_t NextDDL();
+ Int_t NextChamber(AliTRDdigitsManager *digMgr);
+ Int_t NextChamber(AliTRDdigitsManager *digMgr,
+ UInt_t ** /* trackletContainer */, UShort_t ** /* errorContainer */) { AliError("Deprecated, use NextChamber(AliTRDdigitsManger*) instead!"); return NextChamber(digMgr); }
+
+ void StoreErrorsInTree() { fStoreError = &AliTRDrawStream::StoreErrorTree; }
+ void StoreErrorsInArray() { fStoreError = &AliTRDrawStream::StoreErrorArray; }
+ void EnableErrorStorage() { fStoreError = &AliTRDrawStream::StoreErrorTree; }
+ void DisableErrorStorage() { fStoreError = &AliTRDrawStream::ForgetError; }
+
+ // error handling
+ enum ErrorCode_t {
+ kUnknown = 0,
+ kLinkMonitor,
+ kEvCntMismatch,
+ kNonTrdEq,
+ kStackHeaderInvalid,
+ kInvalidDetector,
+ kInvalidPadRow,
+ kNoDigits,
+ kHCmismatch,
+ kHCcheckFailed,
+ kPosUnexp,
+ kTPmodeInvalid,
+ kTPmismatch,
+ kNtimebinsChanged,
+ kAdcMaskInconsistent,
+ kAdcCheckInvalid,
+ kAdcDataAbort,
+ kAdcChannelsMiss,
+ kMissMcmHeaders,
+ kMissTpData,
+ kCRCmismatch,
+ kLastErrorCode
+ };
+
+ enum ErrorBehav_t {
+ kTolerate = 0,
+ kDiscardMCM = 1,
+ kDiscardHC = 2,
+ kDiscardDDL = 4,
+ kAbort = 8
+ };
+
+ enum MarkerCode_t {
+ kHCactive = 1,
+ kSecactive = 2
+ };
+
+ TTree* GetErrorTree() const { return fErrors; }
+ static const char* GetErrorMessage(ErrorCode_t errCode);
+ static void SetErrorDebugLevel(ErrorCode_t error, Int_t level) { fgErrorDebugLevel[error] = level; }
+ static void SetErrorBehaviour(ErrorCode_t error, ErrorBehav_t behav) { fgErrorBehav[error] = behav; }
+
+ class AliTRDrawStreamError : public TObject {
+ public:
+ AliTRDrawStreamError(Int_t error = 0, Int_t sector = -1, Int_t stack = -1, Int_t link = -1, Int_t rob = -1, Int_t mcm = -1);
+ virtual ~AliTRDrawStreamError() {}
+ Int_t fError; // error code
+ Int_t fSector; // sector
+ Int_t fStack; // stack
+ Int_t fLink; // link
+ Int_t fRob; // ROB no
+ Int_t fMcm; // MCM no
+ ClassDef(AliTRDrawStreamError, 1);
+ };
+
+ // event statistics
+ class AliTRDrawStats : public TObject {
+ public:
+ AliTRDrawStats() : TObject(), fBytesRead(0) {}
+ void ClearStats();
+
+ class AliTRDrawStatsSector : public TObject {
+ public:
+ AliTRDrawStatsSector() : TObject(), fBytes(0), fBytesRead(0), fNTracklets(0), fNMCMs(0), fNChannels(0) {}
+ void ClearStats();
+
+ class AliTRDrawStatsHC : public TObject {
+ public:
+ AliTRDrawStatsHC() : TObject(), fBytes(0), fBytesRead(0), fNTracklets(0), fNMCMs(0), fNChannels(0) {}
+ void ClearStats();
+
+ Int_t fBytes; // number of bytes (not necessarily read)
+ Int_t fBytesRead; // number of bytes read
+ Int_t fNTracklets; // number of tracklets
+ Int_t fNMCMs; // number of MCMs (from MCM headers)
+ Int_t fNChannels; // number of channels
+ ClassDef(AliTRDrawStatsHC, 1);
+ };
+
+ Int_t fBytes; // number of bytes (not necessarily read)
+ Int_t fBytesRead; // number of bytes read
+ Int_t fNTracklets; // number of tracklets
+ Int_t fNMCMs; // number of MCMs (from MCM headers)
+ Int_t fNChannels; // number of channels
+ AliTRDrawStatsHC fStatsHC[60]; //[60] HC-wise statistics
+ ClassDef(AliTRDrawStatsSector, 1);
+ };
+
+ AliTRDrawStatsSector fStatsSector[18]; //[18] sector-wise statistics
+ Int_t fBytesRead; // number of bytes read
+ ClassDef(AliTRDrawStats, 1);
+ };
+
+ AliTRDrawStats* GetStats() { return &fStats; }
+ Int_t GetEventSize(Int_t sector) const { return fStats.fStatsSector[sector].fBytes; }
+ Int_t GetEventSize(Int_t sector, Int_t stack) const {
+ Int_t size = 0;
+ for (Int_t iHC = 0; iHC < 12; iHC++) {
+ size += fStats.fStatsSector[sector].fStatsHC[12*stack + iHC].fBytes;
+ }
+ return size;
+ }
+ Int_t GetEventSize(Int_t sector, Int_t stack, Int_t hc) const {
+ return fStats.fStatsSector[sector].fStatsHC[12*stack + hc].fBytes;
+ }
+ Int_t GetNTracklets(Int_t sector) const { return fStats.fStatsSector[sector].fNTracklets; }
+ Int_t GetNMCMs(Int_t sector) const { return fStats.fStatsSector[sector].fNMCMs; }
+ Int_t GetNChannels(Int_t sector) const { return fStats.fStatsSector[sector].fNChannels; }
+
+ ULong64_t GetTrkFlags(Int_t sector, Int_t stack) const { return (fCurrTrgFlags[sector] & (1 << (27 + stack))) ? fCurrTrkFlags[sector*fgkNstacks + stack] : 0; }
+ UInt_t GetTriggerFlags(Int_t sector) const { return fCurrTrgFlags[sector]; }
+ UInt_t GetLinkMonitorFlags(Int_t sector, Int_t stack) const {
+ UInt_t temp = 0;
+ for (Int_t iLink = 0; iLink < 12; iLink++)
+ temp |= (fCurrLinkMonitorFlags[(sector * fgkNstacks + stack) * fgkNlinks + iLink] & 0x3) << (iLink * 2);
+ temp |= ((GetMatchFlagsBP(sector) >> stack) & 0x1) << 24;
+ temp |= ((GetMatchFlagsSRAM(sector) >> stack) & 0x1) << 25;
+ return temp;
+ }
+ UInt_t GetMatchFlagsSRAM(Int_t sector) const { return fCurrMatchFlagsSRAM[sector]; }
+ UInt_t GetMatchFlagsBP(Int_t sector) const { return fCurrMatchFlagsPostBP[sector]; }
+
+#ifdef TRD_RAW_DEBUG
+ UInt_t GetBC(Int_t hc) const { return fCurrBC[hc]; }
+ UInt_t GetEvCount(Int_t det) const { return fCurrEvCount[det]; }
+ UInt_t GetL0Count(Int_t sector) const { return fCurrL0Count[sector]; }
+ UInt_t GetL1aCount(Int_t sector) const { return fCurrL1aCount[sector]; }
+ UInt_t GetL1rCount(Int_t sector) const { return fCurrL1rCount[sector]; }
+ UInt_t GetL2aCount(Int_t sector) const { return fCurrL2aCount[sector]; }
+ UInt_t GetL2rCount(Int_t sector) const { return fCurrL2rCount[sector]; }
+ UInt_t GetChecksumStack(Int_t sector, Int_t stack) const { return fCurrChecksumStack[sector][stack]; }
+#endif
+
+ // raw data dumping
+ void SetDumpMCM(Int_t det, Int_t rob, Int_t mcm, Bool_t dump = kTRUE);
+
+ Bool_t IsDumping() const { return (fNDumpMCMs > 0); }
+ Bool_t DumpingMCM(Int_t det, Int_t rob, Int_t mcm) const;
+
+ TString DumpRaw(TString title, const UInt_t *start, Int_t length, UInt_t endmarker = 0xffffffff);
+ TString DumpMcmHeader(TString title, UInt_t word);
+ TString DumpAdcMask(TString title, UInt_t word);
+
+ static void SortTracklets(TClonesArray *trklArray, TList &sortedTracklets, Int_t *indices);
+ static void AssignTracklets(AliESDTrdTrack *trdTrack, Int_t *trackletIndex, Int_t refIndex[6]);
+
+ // temporary: allow to change expected readout order
+ static void SetMCMReadoutPos(Int_t mcm, Int_t pos) { if (mcm > -1 && mcm < 16) fgMcmOrder[mcm] = pos; }
+ static void SetROBReadoutPos(Int_t robpair, Int_t pos) { if (robpair > -1 && robpair < 4) fgMcmOrder[robpair] = pos; }
+
+ protected:
+ Int_t ReadGTUHeaders(UInt_t *buffer);
+ Int_t ReadSmHeader();
+ Int_t ReadTrackingHeader(Int_t stack);
+ Int_t ReadTriggerHeaders();
+ Int_t ReadStackHeader(Int_t stack);
+ Int_t DecodeGTUtracks();
+ Int_t ReadGTUTrailer();
+
+ Int_t ReadLinkData();
+ Int_t ReadTracklets();
+ Int_t ReadHcHeader();
+ Int_t ReadTPData(Int_t mode = 1);
+ Int_t ReadZSData();
+ Int_t ReadNonZSData();
+
+ UShort_t CalcLinkChecksum(UInt_t *data, Int_t size);
+
+ Int_t SeekNextStack();
+ Int_t SeekNextLink();
+
+ // MCM header decoding
+ 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) ? fgMcmOrder[mcm] : -1; }
+ Int_t GetROBReadoutPos(Int_t rob) const { return (rob > -1 && rob < 4) ? fgRobOrder[rob] : -1; }
+
+ // ADC mask decoding
+ Int_t GetActiveChannels(UInt_t adcmask) const { return 0x1fffff & adcmask >> 4; }
+ inline 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
+ void EquipmentError(ErrorCode_t err = kUnknown, const char *const msg = " ", ...);
+ void StackError (ErrorCode_t err = kUnknown, const char *const msg = " ", ...);
+ void LinkError (ErrorCode_t err = kUnknown, const char *const msg = " ", ...);
+ void ROBError (ErrorCode_t err = kUnknown, const char *const msg = " ", ...);
+ void MCMError (ErrorCode_t err = kUnknown, const char *const msg = " ", ...);
+ void StoreErrorTree() { fErrors->Fill(); }
+ void StoreErrorArray() { new ((*fMarkers)[fMarkers->GetEntriesFast()]) AliTRDrawStreamError(fLastError); }
+ void ForgetError() { return; }
+ void (AliTRDrawStream::*fStoreError)(); //! function pointer to method used for storing the error
+
+ static const char* fgkErrorMessages[kLastErrorCode]; // error messages corresponding to the error codes
+ static Int_t fgErrorDebugLevel[kLastErrorCode]; // error debug level
+ static ErrorBehav_t fgErrorBehav[kLastErrorCode]; // bevhaviour in case of error of given type
+
+ // I/O
+ 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; // tree containing the occured error codes
+ AliTRDrawStreamError fLastError; // last error which occured
+ UInt_t fErrorFlags; // error flags used to steer subsequent reading
+ char fErrorBuffer[100]; // buffer for error message
+
+ AliTRDrawStats fStats; // event statistics, clearing must be done by the user
+
+ 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 (in UInt_t words)
+
+ static const Int_t fgkNlinks; // number of links to read
+ static const Int_t fgkNsectors; // number of sectors
+ static const Int_t fgkNstacks; // number of stacks to read
+ static const Int_t fgkNtriggers; // number of triggers in data stream
+ static const UInt_t fgkDataEndmarker; // data endmarker
+ static const UInt_t fgkTrackletEndmarker; // tracklet endmarker
+ static const UInt_t fgkStackEndmarker[]; // stack endmarker (used from version 0xd on)
+ static Int_t fgMcmOrder []; // expected readout order of the MCMs
+ static Int_t fgRobOrder []; // expected readout order of the ROBs
+
+ // persistent information
+ Int_t fNtimebins; // number of timebins
+ Int_t fLastEvId; // Event ID of last event
+
+ // information valid at current reader position
+ // 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; // current Equipment ID
+
+ // SM header
+ UInt_t fCurrSmHeaderSize; // current size of the SM header
+ UInt_t fCurrSmHeaderVersion; // current version of the SM header
+ UInt_t fCurrTrailerReadout; // current presence of trailer (after the payload)
+ UInt_t fCurrTrgHeaderAvail; // current trigger information availability
+ UInt_t fCurrTrgHeaderReadout; // current readout mode for the trigger headers
+ UInt_t fCurrTrkHeaderAvail; // current tracking information availability
+ UInt_t fCurrStackEndmarkerAvail; // current stack endmarker availability
+ UInt_t fCurrEvType; // current event type
+ UInt_t fCurrTriggerEnable; // current trigger enable
+ UInt_t fCurrTriggerFired; // current trigger fired
+ UInt_t fCurrTrackEnable; // current value of track enable
+ UInt_t fCurrTrackletEnable; // current value of tracklet enable
+ UInt_t fCurrStackMask; // current mask of active stacks
+#ifdef TRD_RAW_DEBUG
+ UInt_t *fCurrL0Count; // number of received L0 triggers
+ UInt_t *fCurrL1aCount; // number of received L1a triggers
+ UInt_t *fCurrL1rCount; // number of received L1r triggers
+ UInt_t *fCurrL2aCount; // number of received L2a triggers
+ UInt_t *fCurrL2rCount; // number of received L2r triggers
+ Int_t fCurrL0offset[540]; // current offset for L0 accepts from GTU and chambers
+ UInt_t fCurrEvCount[540]; // current event count from the MCMs
+#endif
+
+ // Tracking header
+ UInt_t *fCurrTrkHeaderIndexWord; // current tracking header index word
+ UInt_t *fCurrTrkHeaderSize; // current tracking header index word
+ ULong64_t *fCurrTrkFlags; // current tracking done flags
+
+ // Trigger header
+ UInt_t *fCurrTrgHeaderIndexWord; // current tracking header index word
+ UInt_t *fCurrTrgHeaderSize; // current tracking header index word
+ UInt_t *fCurrTrgFlags; // current trigger flags of all sectors
+
+ // Stack header
+ 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 *fCurrHwRevTMU; // current hardware revision
+ UInt_t *fCurrLinkMonitorFlags; // current link monitor flags
+ UInt_t *fCurrLinkDataTypeFlags; // current link data flags
+ UInt_t *fCurrLinkDebugFlags; // current link debug flags
+
+ // CRC checks from trailer
+ Char_t fCurrMatchFlagsSRAM[18];
+ Char_t fCurrMatchFlagsPostBP[18];
+ UInt_t fCurrChecksumStack[18][5];
+ UInt_t fCurrChecksumSIU;
+
+ // HC information
+ 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 fCurrPtrgCnt; // current pretrigger count
+ Int_t fCurrPtrgPhase; // current pretrigger phase
+#ifdef TRD_RAW_DEBUG
+ Int_t fCurrBC[1080]; // current BC
+#endif
+
+ // settings for dumping
+ Int_t fDumpMCM[100]; // MCMs to dump
+ Int_t fNDumpMCMs; // number of MCMs to dump
+
+ // output data
+ AliTRDarrayADC *fAdcArray; // pointer to ADC array
+ AliTRDSignalIndex *fSignalIndex; // pointer to the signal index
+ TClonesArray *fTracklets; // pointer to array of tracklets
+ TClonesArray *fTracks; // pointer to array of GTU tracks
+ TClonesArray *fMarkers; // pointer to array of markers (data present, errors, ...)
+
+ AliTRDrawStream(const AliTRDrawStream&); // not implemented
+ AliTRDrawStream& operator=(const AliTRDrawStream&); // not implemented
+
+ ClassDef(AliTRDrawStream, 0);
+};
+
+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);
+ return (((adcmask + (adcmask >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
+}
+
+#endif