Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
BdataLoc.h
Go to the documentation of this file.
1#ifndef Podd_BdataLoc_h_
2#define Podd_BdataLoc_h_
3
5//
6// BdataLoc
7//
9
10#include "THaAnalysisObject.h"
11#include "TString.h"
12#include <vector>
13#include <cassert>
14#include <set>
15
16class THaEvData;
17class TObjArray;
18
19//___________________________________________________________________________
20class BdataLoc : public TNamed {
21 // Utility class used by THaDecData.
22 // Data location, either in (crates, slots, channel), or
23 // relative to a unique header in a crate or in an event.
24public:
25 // Helper class for holding info on BdataLoc classes
27 public:
28 BdataLocType( const char* cl, const char* key, Int_t np, void* ptr = nullptr )
29 : fClassName(cl), fDBkey(key), fNparams(np), fOptptr(ptr), fTClass(nullptr) {}
30 // The database keys have to be unique, so use them for sorting
31 bool operator<( const BdataLocType& rhs ) const { return fDBkey < rhs.fDBkey; }
32
33 const char* fClassName; // Name of class to use for this data type
34 const char* fDBkey; // Database key name to search for definitions
35 Int_t fNparams; // Number of database parameters for this type
36 void* fOptptr; // Optional pointer to arbitrary data
37 mutable TClass* fTClass; // Pointer to ROOT class representing the type
38 };
39 typedef std::set<BdataLocType> TypeSet_t;
40 typedef TypeSet_t::iterator TypeIter_t;
41 // Returns set of all defined (i.e. compiled & loaded) BdataLoc classes
42 static TypeSet_t& fgBdataLocTypes();
43
44 BdataLoc() : crate(0), data(0) {} // For ROOT TClass & I/O
45 virtual ~BdataLoc();
46
47 // Main function: extract the defined data from the event
48 virtual void Load( const THaEvData& evt ) = 0;
49
50 // Initialization from TObjString parameters in TObjArray
51 virtual Int_t Configure( const TObjArray* params, Int_t start = 0 );
52 // Type-specific data
53 virtual Int_t GetNparams() const = 0;
54 virtual const char* GetTypeKey() const = 0;
55 // Optional data passed in via generic pointer
56 virtual Int_t OptionPtr( void* ) { return 0; }
57
58 virtual void Clear( const Option_t* ="" ) { data = kMaxUInt; }
59 virtual Bool_t DidLoad() const { return (data != kMaxUInt); }
60 virtual UInt_t NumHits() const { return DidLoad() ? 1 : 0; }
61 virtual UInt_t Get( UInt_t i = 0 ) const { assert(DidLoad() && i == 0); return data; }
62 virtual void Print( Option_t* opt="" ) const;
63 //TODO: Needed?
64 Bool_t operator==( const char* aname ) const { return fName == aname; }
65 // operator== and != compare the hardware definitions of two BdataLoc's
66 // virtual Bool_t operator==( const BdataLoc& rhs ) const
67 // { return (crate == rhs.crate); }
68 // Bool_t operator!=( const BdataLoc& rhs ) const { return !(*this==rhs); }
69
72
73 // Helper function for parameter parsing
74 static TString& GetString( const TObjArray* params, Int_t pos )
75 { return Podd::GetObjArrayString(params, pos); }
76
77protected:
78 // Abstract base class constructor
79 BdataLoc( const char* name, UInt_t cra )
80 : TNamed(name,name), crate(cra), data(kMaxUInt) { }
81
82 UInt_t crate; // Data location: crate number
83 UInt_t data; // Raw data word
84
85 Int_t CheckConfigureParams( const TObjArray* params, Int_t start ) const;
86 void PrintNameType( Option_t* opt="" ) const;
87
88 static TypeIter_t DoRegister( const BdataLocType& registration_info );
89
90 // Bit used by DefineVariables
91 enum { kIsSetup = BIT(14) };
92
94};
95
96//___________________________________________________________________________
97class CrateLoc : public BdataLoc {
98public:
99 // c'tor for (crate,slot,channel) selection
100 CrateLoc( const char* nm, UInt_t cra, UInt_t slo, UInt_t cha )
101 : BdataLoc(nm,cra), slot(slo), chan(cha) { ResetBit(kIsSetup); }
102 CrateLoc() : slot(0), chan(0) {}
103 virtual ~CrateLoc() = default;
104
105 virtual void Load( const THaEvData& evt );
106 virtual Int_t Configure( const TObjArray* params, Int_t start = 0 );
107 virtual Int_t GetNparams() const { return fgThisType->fNparams; }
108 virtual const char* GetTypeKey() const { return fgThisType->fDBkey; };
109 virtual void Print( Option_t* opt="" ) const;
110
111 // virtual Bool_t operator==( const BdataLoc& rhs ) const
112 // { return (crate == rhs.crate && slot == rhs.slot && chan == rhs.chan); }
113
114protected:
115 UInt_t slot, chan; // Data location: slot and channel
116
117 void PrintCrateLocHeader( Option_t* opt="" ) const;
118
119private:
121
123};
124
125//___________________________________________________________________________
126class CrateLocMulti : public CrateLoc {
127public:
128 // (crate,slot,channel) allowing for multiple hits per channel
129 CrateLocMulti( const char* nm, UInt_t cra, UInt_t slo, UInt_t cha )
130 : CrateLoc(nm,cra,slo,cha) { }
131 CrateLocMulti() = default;
132 virtual ~CrateLocMulti() = default;
133
134 virtual void Load( const THaEvData& evt );
135
136 virtual void Clear( const Option_t* ="" ) { CrateLoc::Clear(); rdata.clear(); }
137 virtual UInt_t NumHits() const { return rdata.size(); }
138 virtual UInt_t Get( UInt_t i = 0 ) const { return rdata.at(i); }
139 virtual Int_t GetNparams() const { return fgThisType->fNparams; }
140 virtual const char* GetTypeKey() const { return fgThisType->fDBkey; };
141 virtual void Print( Option_t* opt="" ) const;
142
144
145protected:
146 std::vector<UInt_t> rdata; // raw data
147
148 void PrintMultiData( Option_t* opt="" ) const;
149
150private:
152
154};
155
156//___________________________________________________________________________
157class WordLoc : public BdataLoc {
158public:
159 // c'tor for header search
160 WordLoc( const char* nm, UInt_t cra, UInt_t head, UInt_t skip )
161 : BdataLoc(nm,cra), header(head), ntoskip(skip) { }
162 WordLoc() : header(0), ntoskip(1) {}
163 virtual ~WordLoc() = default;
164
165 virtual void Load( const THaEvData& evt );
166 virtual Int_t Configure( const TObjArray* params, Int_t start = 0 );
167 virtual Int_t GetNparams() const { return fgThisType->fNparams; }
168 virtual const char* GetTypeKey() const { return fgThisType->fDBkey; };
169 virtual void Print( Option_t* opt="" ) const;
170
171 // virtual Bool_t operator==( const BdataLoc& rhs ) const
172 // { return (crate == rhs.crate &&
173 // header == rhs.header && ntoskip == rhs.ntoskip); }
174
175protected:
176 UInt_t header; // header (unique either in data or in crate)
177 UInt_t ntoskip; // how far to skip beyond header
178
179private:
181
182 ClassDef(WordLoc,0)
183};
184
185//___________________________________________________________________________
186class RoclenLoc : public BdataLoc {
187public:
188 // Event length of a crate
189 RoclenLoc( const char* nm, UInt_t cra ) : BdataLoc(nm, cra) { }
190 RoclenLoc() = default;
191 virtual ~RoclenLoc() = default;
192
193 virtual void Load( const THaEvData& evt );
194 virtual Int_t GetNparams() const { return fgThisType->fNparams; }
195 virtual const char* GetTypeKey() const { return fgThisType->fDBkey; };
196
197private:
199
201};
202
204
205#endif
int Int_t
unsigned int UInt_t
bool Bool_t
const UInt_t kMaxUInt
const char Option_t
#define ClassDef(name, id)
#define BIT(n)
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 np
char name[80]
const char * fClassName
Definition BdataLoc.h:33
const char * fDBkey
Definition BdataLoc.h:34
BdataLocType(const char *cl, const char *key, Int_t np, void *ptr=nullptr)
Definition BdataLoc.h:28
bool operator<(const BdataLocType &rhs) const
Definition BdataLoc.h:31
virtual UInt_t Get(UInt_t i=0) const
Definition BdataLoc.h:61
virtual void Clear(const Option_t *="")
Definition BdataLoc.h:58
virtual ~BdataLoc()
Definition BdataLoc.cxx:44
TypeSet_t::iterator TypeIter_t
Definition BdataLoc.h:40
virtual const char * GetTypeKey() const =0
virtual void Print(Option_t *opt="") const
Definition BdataLoc.cxx:166
THaAnalysisObject::EMode EMode
Definition BdataLoc.h:70
virtual void Load(const THaEvData &evt)=0
Int_t CheckConfigureParams(const TObjArray *params, Int_t start) const
Definition BdataLoc.cxx:78
static TString & GetString(const TObjArray *params, Int_t pos)
Definition BdataLoc.h:74
virtual UInt_t NumHits() const
Definition BdataLoc.h:60
static TypeIter_t DoRegister(const BdataLocType &registration_info)
Definition BdataLoc.cxx:130
UInt_t data
Definition BdataLoc.h:83
Bool_t operator==(const char *aname) const
Definition BdataLoc.h:64
virtual Int_t GetNparams() const =0
virtual Int_t OptionPtr(void *)
Definition BdataLoc.h:56
virtual Bool_t DidLoad() const
Definition BdataLoc.h:59
virtual Int_t Configure(const TObjArray *params, Int_t start=0)
Definition BdataLoc.cxx:101
std::set< BdataLocType > TypeSet_t
Definition BdataLoc.h:39
static TypeSet_t & fgBdataLocTypes()
Definition BdataLoc.cxx:119
UInt_t crate
Definition BdataLoc.h:82
void PrintNameType(Option_t *opt="") const
Definition BdataLoc.cxx:153
BdataLoc(const char *name, UInt_t cra)
Definition BdataLoc.h:79
virtual Int_t DefineVariables(EMode mode=THaAnalysisObject::kDefine)
Definition BdataLoc.cxx:57
BdataLoc()
Definition BdataLoc.h:44
@ kIsSetup
Definition BdataLoc.h:91
CrateLocMulti(const char *nm, UInt_t cra, UInt_t slo, UInt_t cha)
Definition BdataLoc.h:129
virtual Int_t DefineVariables(EMode mode=THaAnalysisObject::kDefine)
Definition BdataLoc.cxx:225
virtual Int_t GetNparams() const
Definition BdataLoc.h:139
virtual const char * GetTypeKey() const
Definition BdataLoc.h:140
virtual UInt_t Get(UInt_t i=0) const
Definition BdataLoc.h:138
virtual UInt_t NumHits() const
Definition BdataLoc.h:137
CrateLocMulti()=default
void PrintMultiData(Option_t *opt="") const
Definition BdataLoc.cxx:258
virtual void Clear(const Option_t *="")
Definition BdataLoc.h:136
virtual void Load(const THaEvData &evt)
Definition BdataLoc.cxx:247
static TypeIter_t fgThisType
Definition BdataLoc.h:151
virtual void Print(Option_t *opt="") const
Definition BdataLoc.cxx:273
virtual ~CrateLocMulti()=default
std::vector< UInt_t > rdata
Definition BdataLoc.h:146
virtual Int_t GetNparams() const
Definition BdataLoc.h:107
UInt_t slot
Definition BdataLoc.h:115
virtual void Load(const THaEvData &evt)
Definition BdataLoc.cxx:194
void PrintCrateLocHeader(Option_t *opt="") const
Definition BdataLoc.cxx:204
CrateLoc(const char *nm, UInt_t cra, UInt_t slo, UInt_t cha)
Definition BdataLoc.h:100
virtual const char * GetTypeKey() const
Definition BdataLoc.h:108
virtual void Print(Option_t *opt="") const
Definition BdataLoc.cxx:216
static TypeIter_t fgThisType
Definition BdataLoc.h:120
virtual Int_t Configure(const TObjArray *params, Int_t start=0)
Definition BdataLoc.cxx:179
virtual ~CrateLoc()=default
UInt_t chan
Definition BdataLoc.h:115
RoclenLoc()=default
static TypeIter_t fgThisType
Definition BdataLoc.h:198
RoclenLoc(const char *nm, UInt_t cra)
Definition BdataLoc.h:189
virtual ~RoclenLoc()=default
virtual const char * GetTypeKey() const
Definition BdataLoc.h:195
virtual void Load(const THaEvData &evt)
Definition BdataLoc.cxx:365
virtual Int_t GetNparams() const
Definition BdataLoc.h:194
TString fName
void Clear(Option_t *option="") override
void ResetBit(UInt_t f)
UInt_t ntoskip
Definition BdataLoc.h:177
virtual ~WordLoc()=default
virtual Int_t GetNparams() const
Definition BdataLoc.h:167
virtual void Print(Option_t *opt="") const
Definition BdataLoc.cxx:351
virtual Int_t Configure(const TObjArray *params, Int_t start=0)
Definition BdataLoc.cxx:283
static TypeIter_t fgThisType
Definition BdataLoc.h:180
virtual const char * GetTypeKey() const
Definition BdataLoc.h:168
UInt_t header
Definition BdataLoc.h:176
WordLoc(const char *nm, UInt_t cra, UInt_t head, UInt_t skip)
Definition BdataLoc.h:160
WordLoc()
Definition BdataLoc.h:162
virtual void Load(const THaEvData &evt)
Definition BdataLoc.cxx:306