00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef EztEmcRawData_hh
00013 #define EztEmcRawData_hh
00014
00015 #include "TObject.h"
00016 #include <TArrayS.h>
00017
00018 class EztEmcRawData : public TObject {
00019 public:
00020 enum { MAXEMCDATABANK=60};
00021 enum { WRDCNT=0,ERRFLG=1,TOKEN=2,CRATE=3};
00022 enum { bitCrateID=1<<0, bitToken=1<<1, bitLenCount=1<<2, bitTrigComm=1<<3,
00023 bitErrFlag=1<<4, bitN256=1<<5, bitGhost=1<<6, bitCrateOff=1<<7,
00024 bitStall=1<<8};
00025
00026 EztEmcRawData();
00027 EztEmcRawData(const EztEmcRawData&);
00028 ~EztEmcRawData();
00029
00030 const UShort_t* header(int) const;
00031 const UShort_t* data(int) const;
00032
00033 const int sizeHeader(int) const;
00034 const int sizeData(int) const;
00035
00036 const int getNBlocks() const { return MAXEMCDATABANK;}
00037 void createBank(int, int, int);
00038
00039 void setHeader(int, unsigned short*);
00040 void setData(int, unsigned short*);
00041
00042 const UShort_t getCorruption(int ib) const { return mCorrupt[ib];}
00043 void setCorruption(int ib, UShort_t x) {mCorrupt[ib]=x;}
00044 bool isCrateVoid(int ib) const { return sizeData(ib)<=0; }
00045
00046 static UShort_t getErrFlag(const UShort_t* hd) {
00047 return hd[ERRFLG] & 0x0FFF; }
00048 static UShort_t getLenCount(const UShort_t* hd) {
00049 return hd[WRDCNT] & 0x0FFF; }
00050 static UShort_t getToken(const UShort_t* hd) {
00051 return hd[TOKEN] & 0x0FFF; }
00052 static UShort_t getTrigComm(const UShort_t* hd) {
00053 return (hd[CRATE] / 0x0100) &0x000F ; }
00054 static UShort_t getCrateID(const UShort_t* hd) {
00055 return hd[CRATE] & 0x00FF ; }
00056
00057 UShort_t getErrFlag(int ib) const { return getErrFlag(header(ib)); }
00058 UShort_t getLenCount(int ib) const { return getLenCount(header(ib)); }
00059 UShort_t getToken(int ib) const { return getToken(header(ib)); }
00060 UShort_t getTrigComm(int ib) const { return getTrigComm(header(ib)); }
00061 UShort_t getCrateID(int ib) const { return getCrateID(header(ib)); }
00062
00063
00064
00065 bool doHeadCorruptionTest(int token,int lenCount, int firstCrId, int errFlag=0) ;
00066
00067 bool doTowerHeadCorruptionTest(int token) {
00068
00069 return doHeadCorruptionTest(token,0xa4,1); }
00070
00071 bool doMapmtHeadCorruptionTest(int token) {
00072
00073 return doHeadCorruptionTest(token,0xc4,64); }
00074
00075 bool purgeCrateOFF(int ib);
00076 void tagHeadValid(int ib, int token, int crId, int len, int trigComm, int errFlag, int dbg=0);
00077
00078
00079 static bool isCrateOFF( const UShort_t* hd);
00080 static UShort_t isHeadValid(const UShort_t* hd, int token, int crId, int len, int trigComm, int errFlag, int dbg=0);
00081
00082 void print(int ib, int flag);
00083 void print(int flag=0);
00084 static void print(const UShort_t* hd, const UShort_t* d=0, int nd=0);
00085
00086 protected:
00087 TArrayS mHeader[MAXEMCDATABANK];
00088 TArrayS mData[MAXEMCDATABANK];
00089 UShort_t mCorrupt[MAXEMCDATABANK];
00090
00091 private:
00092 void deleteBank(int);
00093
00094 ClassDef(EztEmcRawData,2)
00095 };
00096 #endif
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118