Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
Module.h
Go to the documentation of this file.
1#ifndef Podd_Module_h_
2#define Podd_Module_h_
3
5//
6// Module
7// Abstract interface for a module that sits in a slot of a crate.
8//
10
11#include "TNamed.h"
12#include "Decoder.h"
13#include <set>
14#include <fstream>
15#include <vector>
16#include <string>
17#include <stdexcept>
18
19namespace Decoder {
20
21 class Module : public TNamed {
22
23 public:
24
25 Module() : Module(0,0) {} // for ROOT TClass & I/O
26 Module(UInt_t crate, UInt_t slot);
27 virtual ~Module() = default;
28
29 class ModuleType {
30 public:
31 ModuleType ( const char *c1, UInt_t i1 )
32 : fClassName(c1), fMapNum(i1), fTClass(nullptr) {}
33 ModuleType() : fClassName(nullptr), fMapNum(0), fTClass(nullptr) {} // For ROOT RTTI
34 bool operator<( const ModuleType& rhs ) const { return fMapNum < rhs.fMapNum; }
35 const char* fClassName;
37 mutable TClass* fTClass;
38 };
39 using TypeSet_t = std::set<ModuleType>;
40 using TypeIter_t = TypeSet_t::iterator;
41 static TypeSet_t& fgModuleTypes();
42 static TypeIter_t DoRegister( const ModuleType& registration_info );
43
45 Bool_t BlockIsDone() const { return fBlockIsDone; };
46 virtual void SetFirmware(Int_t fw) {fFirmwareVers=fw;};
47
48 UInt_t GetBlockSize() const { return block_size; };
49
50 // inheriting classes need to implement one or more of these
51 virtual UInt_t GetData( UInt_t /*chan*/) const { return 0; };
52 virtual UInt_t GetData( UInt_t /*chan*/, UInt_t /*hit*/) const { return 0; };
53 virtual UInt_t GetData( UInt_t, UInt_t, UInt_t) const { return 0; };
55 UInt_t /*chan*/, UInt_t /*ievent*/) const { return 0; };
57 UInt_t, UInt_t, UInt_t ) const { return 0; };
58 virtual UInt_t GetOpt( UInt_t /* rdata */) const { return 0; };
59
60 virtual UInt_t GetOpt( UInt_t /*chan*/, UInt_t /*hit*/) const { return 0; }; //1190
61
62 virtual Int_t Decode(const UInt_t *p) = 0; // FIXME: unused, remove from public interface
63 // Loads slot data from [evbuffer,pstop]. pstop points to last word of data
64 // This is used in decoding based on header words (roc_decode)
65 virtual UInt_t LoadSlot( THaSlotData *sldat, const UInt_t *evbuffer,
66 const UInt_t *pstop ) = 0;
67 // Loads slot data from [pos,pos+len). pos = start of data, len = num words
68 // This is used in bank decoding (bank_decode)
69 virtual UInt_t LoadSlot( THaSlotData* sldat, const UInt_t *evbuffer,
70 UInt_t pos, UInt_t len);
71 virtual UInt_t LoadNextEvBuffer( THaSlotData* /* sldat */) { return 0; };
72
73 virtual UInt_t GetNumChan() const { return fNumChan; };
74
76 UInt_t /*chan*/ ) const { return 0; };
77 virtual UInt_t GetNumEvents( UInt_t ) const { return 0; };
78 virtual UInt_t GetNumEvents() const { return 0; };
79 virtual UInt_t GetNumSamples( UInt_t ) const { return 0; };
80 virtual Int_t GetMode() const { return fMode; };
81
82 virtual void SetSlot( UInt_t crate, UInt_t slot, UInt_t header = 0,
83 UInt_t mask = 0, Int_t modelnum = 0 ) {
84 fCrate = crate;
85 fSlot = slot;
86 fHeader = header;
88 fModelNum = modelnum;
89 }
90
91 virtual void SetBank( Int_t bank ) { fBank = bank; };
92 virtual void SetMode( Int_t mode ) { fMode = mode; };
93
94 virtual void Init();
95 virtual void Init( const char* configstr );
96
97 virtual void Clear( Option_t* = "" );
98
99 virtual Bool_t IsSlot( UInt_t rdata );
100
101 virtual UInt_t GetCrate() const { return fCrate; };
102 virtual UInt_t GetSlot() const { return fSlot; };
103
104 virtual void SetDebugFile( std::ofstream* file )
105 {
106 if (file) fDebugFile = file;
107 }
108
109 virtual void SetHeader( UInt_t header, UInt_t mask ) {
110 fHeader = header;
112 }
113
114 virtual void DoPrint() const;
115
116 virtual Bool_t IsMultiFunction() { return false; };
117 virtual Bool_t HasCapability( Decoder::EModuleType ) { return false; };
118
119 // Invalid input data exception, thrown by "Load*" functions
120 class module_data_error : public std::runtime_error {
121 public:
122 explicit module_data_error( const std::string& what_arg )
123 : std::runtime_error(what_arg) {}
124 explicit module_data_error( const char* what_arg )
125 : std::runtime_error(what_arg) {}
126 };
127
128 // Wrappers for LoadSlot methods to allow buffer preprocessing
129 virtual UInt_t LoadBlock( THaSlotData* sldat, const UInt_t* evbuffer,
130 const UInt_t* pstop ) {
131 return LoadSlot(sldat, evbuffer, pstop);
132 }
133 virtual UInt_t LoadBank( THaSlotData* sldat, const UInt_t* evbuffer,
134 UInt_t pos, UInt_t len ) {
135 return LoadSlot(sldat, evbuffer, pos, len);
136 }
137
138 protected:
139
140 std::vector<UInt_t> fData; // Raw data
141
154
156 std::ofstream *fDebugFile;
157
158 TObject* fExtra; // additional member data, for binary compatibility
159
161 std::string name; // (Optional) parameter name ("name=value")
162 UInt_t& data; // Reference to variable to which to assign data
163 };
164 static void ParseConfigStr( const char* configstr,
165 const std::vector<ConfigStrReq>& req );
166
167 private:
168
169 ClassDef(Module,0) // A module in a crate and slot
170
171 };
172
173}
174
175#endif
int Int_t
unsigned int UInt_t
bool Bool_t
const char Option_t
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
ModuleType(const char *c1, UInt_t i1)
Definition Module.h:31
const char * fClassName
Definition Module.h:35
bool operator<(const ModuleType &rhs) const
Definition Module.h:34
module_data_error(const char *what_arg)
Definition Module.h:124
module_data_error(const std::string &what_arg)
Definition Module.h:122
UInt_t fCrate
Definition Module.h:142
UInt_t fNumChan
Definition Module.h:148
virtual UInt_t GetSlot() const
Definition Module.h:102
static TypeIter_t DoRegister(const ModuleType &registration_info)
Definition Module.cxx:198
virtual UInt_t GetNumEvents(Decoder::EModuleType, UInt_t) const
Definition Module.h:75
Bool_t IsMultiBlockMode() const
Definition Module.h:44
virtual void Clear(Option_t *="")
Definition Module.cxx:72
virtual UInt_t GetData(UInt_t, UInt_t, UInt_t) const
Definition Module.h:53
virtual void Init()
Definition Module.cxx:51
virtual ~Module()=default
virtual UInt_t GetNumChan() const
Definition Module.h:73
Bool_t fMultiBlockMode
Definition Module.h:152
std::set< ModuleType > TypeSet_t
Definition Module.h:39
virtual UInt_t LoadBank(THaSlotData *sldat, const UInt_t *evbuffer, UInt_t pos, UInt_t len)
Definition Module.h:133
std::ofstream * fDebugFile
Definition Module.h:156
virtual void SetHeader(UInt_t header, UInt_t mask)
Definition Module.h:109
virtual UInt_t GetData(Decoder::EModuleType, UInt_t, UInt_t) const
Definition Module.h:54
UInt_t fWdcntMask
Definition Module.h:146
virtual UInt_t GetNumEvents() const
Definition Module.h:78
virtual Bool_t IsMultiFunction()
Definition Module.h:116
Int_t fFirmwareVers
Definition Module.h:153
virtual Int_t GetMode() const
Definition Module.h:80
virtual void SetFirmware(Int_t fw)
Definition Module.h:46
virtual UInt_t LoadSlot(THaSlotData *sldat, const UInt_t *evbuffer, const UInt_t *pstop)=0
Int_t fModelNum
Definition Module.h:147
virtual UInt_t GetData(UInt_t, UInt_t) const
Definition Module.h:52
virtual void SetMode(Int_t mode)
Definition Module.h:92
UInt_t fWdcntShift
Definition Module.h:146
virtual UInt_t GetData(Decoder::EModuleType, UInt_t, UInt_t, UInt_t) const
Definition Module.h:56
TObject * fExtra
Definition Module.h:158
UInt_t fWordsExpect
Definition Module.h:145
virtual void SetBank(Int_t bank)
Definition Module.h:91
virtual UInt_t GetCrate() const
Definition Module.h:101
UInt_t block_size
Definition Module.h:150
virtual UInt_t GetNumSamples(UInt_t) const
Definition Module.h:79
Bool_t fBlockIsDone
Definition Module.h:152
static TypeSet_t & fgModuleTypes()
Definition Module.cxx:187
virtual Bool_t IsSlot(UInt_t rdata)
Definition Module.cxx:164
static void ParseConfigStr(const char *configstr, const std::vector< ConfigStrReq > &req)
Definition Module.cxx:100
virtual void DoPrint() const
Definition Module.cxx:174
UInt_t fHeader
Definition Module.h:143
UInt_t fSlot
Definition Module.h:142
virtual Int_t Decode(const UInt_t *p)=0
UInt_t fHeaderMask
Definition Module.h:143
virtual UInt_t GetOpt(UInt_t, UInt_t) const
Definition Module.h:60
Bool_t BlockIsDone() const
Definition Module.h:45
UInt_t fWordsSeen
Definition Module.h:145
virtual UInt_t LoadNextEvBuffer(THaSlotData *)
Definition Module.h:71
virtual void SetSlot(UInt_t crate, UInt_t slot, UInt_t header=0, UInt_t mask=0, Int_t modelnum=0)
Definition Module.h:82
std::vector< UInt_t > fData
Definition Module.h:140
UInt_t GetBlockSize() const
Definition Module.h:48
virtual Bool_t HasCapability(Decoder::EModuleType)
Definition Module.h:117
virtual void SetDebugFile(std::ofstream *file)
Definition Module.h:104
virtual UInt_t GetOpt(UInt_t) const
Definition Module.h:58
TypeSet_t::iterator TypeIter_t
Definition Module.h:40
virtual UInt_t GetData(UInt_t) const
Definition Module.h:51
virtual UInt_t GetNumEvents(UInt_t) const
Definition Module.h:77
Bool_t IsInit
Definition Module.h:151
virtual UInt_t LoadBlock(THaSlotData *sldat, const UInt_t *evbuffer, const UInt_t *pstop)
Definition Module.h:129
return c1
EModuleType
Definition Decoder.h:57
STL namespace.