StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EztEmcRawData.h
1 /***************************************************************************
2  *
3  * $Id: EztEmcRawData.h,v 1.6 2009/04/20 16:36:20 tone421 Exp $
4  *
5  * Author: Alex Suaide, Mar 2004, JB
6  ***************************************************************************
7  *
8  * Description: ~1:1 copy of StEztEmcRawData but without StElephant dependence
9  *
10  ***************************************************************************/
11 
12 #ifndef EztEmcRawData_hh
13 #define EztEmcRawData_hh
14 
15 #include "TObject.h"
16 #include <TArrayS.h>
17 
18 class EztEmcRawData : public TObject {
19 public:
20  enum { MAXEMCDATABANK=60}; // 48 would be enough for EEMC
21  enum { WRDCNT=0,ERRFLG=1,TOKEN=2,CRATE=3}; // header words
22  enum { bitCrateID=1<<0, bitToken=1<<1, bitLenCount=1<<2, bitTrigComm=1<<3,
23  bitErrFlag=1<<4, bitN256=1<<5, bitGhost=1<<6, bitCrateOff=1<<7,
24  bitStall=1<<8};
25 
26  EztEmcRawData();
28  ~EztEmcRawData();
29 
30  const UShort_t* header(int) const;
31  const UShort_t* data(int) const;
32 
33  const int sizeHeader(int) const;
34  const int sizeData(int) const;
35 
36  const int getNBlocks() const { return MAXEMCDATABANK;}
37  void createBank(int, int, int);
38 
39  void setHeader(int, unsigned short*);
40  void setData(int, unsigned short*);
41 
42  const UShort_t getCorruption(int ib) const { return mCorrupt[ib];}
43  void setCorruption(int ib, UShort_t x) {mCorrupt[ib]=x;}
44  bool isCrateVoid(int ib) const { return sizeData(ib)<=0; }
45 
46  static UShort_t getErrFlag(const UShort_t* hd) {
47  return hd[ERRFLG] & 0x0FFF; }
48  static UShort_t getLenCount(const UShort_t* hd) {
49  return hd[WRDCNT] & 0x0FFF; }
50  static UShort_t getToken(const UShort_t* hd) {
51  return hd[TOKEN] & 0x0FFF; }
52  static UShort_t getTrigComm(const UShort_t* hd) {
53  return (hd[CRATE] / 0x0100) &0x000F ; }
54  static UShort_t getCrateID(const UShort_t* hd) {
55  return hd[CRATE] & 0x00FF ; }
56 
57  UShort_t getErrFlag(int ib) const { return getErrFlag(header(ib)); }
58  UShort_t getLenCount(int ib) const { return getLenCount(header(ib)); }
59  UShort_t getToken(int ib) const { return getToken(header(ib)); }
60  UShort_t getTrigComm(int ib) const { return getTrigComm(header(ib)); }
61  UShort_t getCrateID(int ib) const { return getCrateID(header(ib)); }
62 
63  //........ corruption tests ......
64  // scans whole block
65  bool doHeadCorruptionTest(int token,int lenCount, int firstCrId, int errFlag=0) ;
66 
67  bool doTowerHeadCorruptionTest(int token) {
68  //before 2004 another params are needed
69  return doHeadCorruptionTest(token,0xa4,1); }
70 
71  bool doMapmtHeadCorruptionTest(int token) {
72  //before 2005 another params are needed
73  return doHeadCorruptionTest(token,0xc4,64); }
74 
75  bool purgeCrateOFF(int ib);// discards header & data for one crate
76  void tagHeadValid(int ib, int token, int crId, int len, int trigComm, int errFlag, int dbg=0); // test one header & fill saninty
77 
78  //..... working horse(s)
79  static bool isCrateOFF( const UShort_t* hd);
80  static UShort_t isHeadValid(const UShort_t* hd, int token, int crId, int len, int trigComm, int errFlag, int dbg=0);
81 
82  void print(int ib, int flag); // one block
83  void print(int flag=0); // all nonzero blocks
84  static void print(const UShort_t* hd, const UShort_t* d=0, int nd=0);
85 
86  protected:
87  TArrayS mHeader[MAXEMCDATABANK];
88  TArrayS mData[MAXEMCDATABANK];
89  UShort_t mCorrupt[MAXEMCDATABANK];// encodes all corruptions, filled in fly
90 
91  private:
92  void deleteBank(int);
93 
94  ClassDef(EztEmcRawData,2)
95 };
96 #endif
97 
98 /**************************************************************************
99  *
100  * $Log: EztEmcRawData.h,v $
101  * Revision 1.6 2009/04/20 16:36:20 tone421
102  * Added const to isCrateVoid function
103  *
104  * Revision 1.5 2005/03/10 16:59:54 mvl
105  * New routine for corruption checking by Jan Balewski
106  *
107  * Revision 1.4 2005/01/11 21:33:40 mvl
108  * Minor mod to hearder checking (do not delete data for certain error states ) By Jan Balewski.
109  *
110  * Revision 1.2 2004/11/29 18:36:59 mvl
111  * New code for header checks and some printing (by Jan Balewski)
112  *
113  * Revision 1.1 2004/10/28 00:10:19 mvl
114  * Initial revision of ezTree classes (for EEmc raw data)
115  *
116  *
117  **************************************************************************/
118