#define ALITRDRAWSTREAM_H
#include "TObject.h"
-
-#include "AliTRDrawStreamBase.h"
-//#include "AliRawReader.h"
+#include "TClonesArray.h"
+#include "TTree.h"
class TObjArray;
class TString;
-class TTree;
+class TBranch;
class AliRawReader;
class AliTRDdigitsManager;
class AliTRDdigitsParam;
class AliTRDarrayADC;
class AliTRDSignalIndex;
+class AliTRDtrackletContainer;
+
+#define TRDMAXTBINS 63
+#define TRDMAXADC 21
+#define TRDMAXMCM 4 * 16
+#define MAXTRACKLETSPERHC 256
-class AliTRDrawStream : public AliTRDrawStreamBase
+class AliTRDrawStream : public TObject
{
public:
AliTRDrawStream(AliRawReader *rawReader = 0x0);
~AliTRDrawStream();
+ enum { kDDLOffset = 0x400 }; // Offset for DDL numbers
+
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; }
+ TTree *GetTrackletTree() const { return fTrackletTree; }
Bool_t ReadEvent(TTree *trackletTree = 0x0);
Bool_t NextDDL();
Int_t NextChamber(AliTRDdigitsManager *digMgr,
- UInt_t ** /* trackletContainer */, UShort_t ** /* errorContainer */);
+ UInt_t ** /* trackletContainer */=NULL, UShort_t ** /* errorContainer */=NULL);
Bool_t ConnectTracklets(TTree *trklTree);
- // legacy code, to be removed
- Bool_t SetRawVersion(Int_t) { return kTRUE; }
- void SetSharedPadReadout(Bool_t) {}
- void SetNoErrorWarning() {}
+ 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 {
kLastErrorCode
};
+ enum ErrorBehav_t {
+ kTolerate = 0,
+ kAbort = 1,
+ kDiscardMCM = 2,
+ kDiscardHC = 4
+ };
+
+ enum MarkerCode_t {
+ kHCactive = 1
+ };
+
TTree* GetErrorTree() const { return fErrors; }
static const char* GetErrorMessage(ErrorCode_t errCode);
+ // 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 fStats; // event statistics, clearing must be done by the user
+
+ AliTRDrawStats* GetStats() { return &fStats; }
+ Int_t GetEventSize(Int_t sector) const { return fStats.fStatsSector[sector].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; }
+
+ // 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;
+
+ void DumpRaw(TString title, UInt_t *start, Int_t length);
+
protected:
Int_t ReadSmHeader();
Int_t ReadStackIndexHeader(Int_t stack);
Int_t ReadZSData();
Int_t ReadNonZSData();
+ 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 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 StackError (ErrorCode_t err = kUnknown, TString msg = "");
- TString LinkError (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]; // error messages corresponding to the error codes
+ 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
AliTRDdigitsParam *fDigitsParam; // pointer to the parameters belonging to the digits
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
+ 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);
+ } fLastError; // last error which occured
+ UInt_t fErrorFlags; // error flags used to steer subsequent reading
+ char fErrorBuffer[100]; // buffer for error message
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
+ 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 fgkNstacks; // number of stacks to read
Int_t fCurrPtrgCnt; // current pretrigger count
Int_t fCurrPtrgPhase; // current pretrigger phase
+ // settings for dumping
+ Int_t fDumpMCM[100]; // MCMs to dump
+ Int_t fNDumpMCMs; // number of MCMs to dump
+
// tracklet information
TClonesArray *fTrackletArray; // pointer to array for tracklet storage
AliTRDarrayADC *fAdcArray; // pointer to ADC array
AliTRDSignalIndex *fSignalIndex; // pointer to the signal index
TTree *fTrackletTree; // pointer to the tree for tracklet storage
+ 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