HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hemctrb3lookup.h
Go to the documentation of this file.
1 #ifndef HEMCTRB3LOOKUP_H
2 #define HEMCTRB3LOOKUP_H
3 
4 #include "TObjArray.h"
5 #include "TObject.h"
6 
7 #include "hparset.h"
8 #include "htrbnetdef.h"
9 
10 using namespace Trbnet;
11 using namespace std;
12 
13 // define meaning of flag bits here:
14 #define EMC_CHANNEL_FASTBIT (0x1 << 0)
15 #define EMC_CHANNEL_SLOWBIT (0x1 << 1)
16 #define EMC_CHANNEL_BROKENBIT (0x1 << 7)
17 
18 class HEmcTrb3LookupChan : public TObject {
19 protected:
20  Int_t sector; // sector number
21  Int_t cell; // cell number
22  UChar_t flag; // tdc channel mode flag
23 public:
24  HEmcTrb3LookupChan(void) {clear();}
25  virtual ~HEmcTrb3LookupChan(void) {}
26  Int_t getSector() { return sector;}
27  Int_t getCell() { return cell;}
28  UChar_t getFlag() { return flag;}
29  Bool_t isSlowChannel() { return ((flag & EMC_CHANNEL_SLOWBIT) == EMC_CHANNEL_SLOWBIT); }
30  Bool_t isFastChannel() { return ((flag & EMC_CHANNEL_FASTBIT) == EMC_CHANNEL_FASTBIT); }
31  Bool_t isDefinedChannel() { return ( isFastChannel() || isSlowChannel()); }
32  Bool_t isBrokenChannel() { return ((flag & EMC_CHANNEL_BROKENBIT) == EMC_CHANNEL_BROKENBIT); }
33  void setSlowChannel (Bool_t on) { on ? (flag |=EMC_CHANNEL_SLOWBIT) : (flag &= ~EMC_CHANNEL_SLOWBIT); }
34  void setBrokenChannel(Bool_t on) { on ? (flag |=EMC_CHANNEL_BROKENBIT) : (flag &= ~EMC_CHANNEL_BROKENBIT); }
35  void setFastChannel(Bool_t on) { on ? (flag |=EMC_CHANNEL_FASTBIT) : (flag &= ~EMC_CHANNEL_FASTBIT); }
36 
37  void getAddress(Int_t& s, Int_t& c) const { s = sector; c = cell; }
38  void fill(Int_t s, Int_t c, UChar_t f) { sector = s; cell = c; flag = f; }
39  void fill(HEmcTrb3LookupChan& r) { sector = r.getSector(); cell = r.getCell(); flag = r.getFlag(); }
40  void setSector(const Int_t s) {sector = s;}
41  void setCell(const Int_t c) {cell = c;}
42  void setFlag(const UChar_t f) {flag = f;}
43  void clear(void) {sector = cell = -1; flag=0;}
44  ClassDef(HEmcTrb3LookupChan, 1) // Channel level of the lookup table for the EMC TRB3 unpacker
45 };
46 
47 
48 class HEmcTrb3LookupBoard: public TObject {
49  friend class HEmcTrb3Lookup;
50 protected:
51  TObjArray* array; // pointer array containing HEmcTrb3LookupChan objects
52 public:
53  HEmcTrb3LookupBoard(void);
54  virtual ~HEmcTrb3LookupBoard(void);
55  Int_t getSize() { return array ? array->GetLast() + 1 : 0; }
56  HEmcTrb3LookupChan* getChannel(Int_t c) { if (c >= 0 && c < getSize()) return &((*this)[c]); else return 0; }
57  HEmcTrb3LookupChan& operator[](Int_t i) { return *static_cast<HEmcTrb3LookupChan*>((*array)[i]); }
58  void clear(void);
59  ClassDef(HEmcTrb3LookupBoard, 1) // Board level of the lookup table for the EMC TRB3 unpacker
60 };
61 
62 
63 class HEmcTrb3Lookup : public HParSet {
64 protected:
65  TObjArray* array; // array of pointers of type HEmcTrb3LookupBoard
66  Int_t arrayOffset; // offset to calculate the index
67 public:
68  HEmcTrb3Lookup(const Char_t* name = "EmcTrb3Lookup",
69  const Char_t* title = "Lookup table for the TRB3 unpacker of the EMC detector",
70  const Char_t* context = "EmcTrb3LookupProduction",
71  Int_t minTrbnetAddress = Trbnet::kEmcTrb3MinTrbnetAddress,
72  Int_t maxTrbnetAddress = Trbnet::kEmcTrb3MaxTrbnetAddress);
73  virtual ~HEmcTrb3Lookup(void);
74  HEmcTrb3LookupBoard* getBoard(Int_t trbnetAddress) {
75  if ((arrayOffset <= trbnetAddress) && (trbnetAddress <= (array->GetSize() + arrayOffset)))
76  return (HEmcTrb3LookupBoard*)(array->At(trbnetAddress - arrayOffset));
77  return 0;
78  }
79  HEmcTrb3LookupBoard* operator[](Int_t i) { return static_cast<HEmcTrb3LookupBoard*>((*array)[i]); }
80  Int_t getSize(void) { return array->GetLast() + 1; }
81  Int_t getArrayOffset(void) { return arrayOffset; }
82  Bool_t init(HParIo* input, Int_t* set);
83  Int_t write(HParIo* output);
84  void clear(void);
85  void printParam(void);
86  Bool_t fill(Int_t, Int_t, Int_t, Int_t, Int_t);
87  Bool_t readline(const Char_t*);
88  void putAsciiHeader(TString&);
89  void write(fstream&);
90  ClassDef(HEmcTrb3Lookup, 1) // Lookup table for the TRB3 unpacker of the EMC detector
91 };
92 
93 #endif /*!HEMCTRB3LOOKUP_H*/
void setFastChannel(Bool_t on)
void setFlag(const UChar_t f)
HEmcTrb3LookupBoard * getBoard(Int_t trbnetAddress)
#define EMC_CHANNEL_SLOWBIT
void setCell(const Int_t c)
TObjArray * array
HEmcTrb3LookupBoard * operator[](Int_t i)
virtual ~HEmcTrb3LookupChan(void)
HEmcTrb3LookupChan & operator[](Int_t i)
void fill(Int_t s, Int_t c, UChar_t f)
void clear(void)
void fill(HEmcTrb3LookupChan &r)
Definition: hpario.h:11
void setSlowChannel(Bool_t on)
Int_t getArrayOffset(void)
TString input
Definition: GarReader.C:5
#define EMC_CHANNEL_FASTBIT
HEmcTrb3LookupChan * getChannel(Int_t c)
Definition: hparset.h:9
void setSector(const Int_t s)
Bool_t isDefinedChannel()
return output
Int_t getSize(void)
Bool_t isBrokenChannel()
#define EMC_CHANNEL_BROKENBIT
void setBrokenChannel(Bool_t on)
void getAddress(Int_t &s, Int_t &c) const