Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaUsrstrutils.h
Go to the documentation of this file.
1#ifndef _USRSTRUTILS_INCLUDED
2#define _USRSTRUTILS_INCLUDED
3
5//
6// R. Michaels, March 2000
7// THaUsrstrutils = USeR STRing UTILitieS.
8// The code below is what is used by DAQ to interpret strings
9// like prescale factors
10// Yes, this is mostly old-style C, but it
11// has the advantage that the interpretation should
12// be identical to what the DAQ used.
13//
15
16#include "Rtypes.h"
17#include <string>
18
19namespace Decoder {
20
22
23/* usrstrutils
24
25 utilities to extract information from configuration string passed
26 to ROC in the *.config file in rcDatabase.
27
28 The config line can be of the form
29
30 keyword[=value][,keyword[=value]] ...
31
32 CRL code can use the following three routines to look for keywords and
33 the associated values.
34
35 int getflag(char *s) - Return 0 if s not present as a keyword
36 1 if keyword is present with no value
37 2 if keyword is present with a value
38 int getint(char *s) - If keyword present, interpret value as an integer.
39 Value assumed decimal, unless preceded by 0x for hex
40 Return 0 if keyword not present or has no value.
41 int getSignedInt(char *s) - If keyword present, interpret value as an
42 integer and it can have a sign.
43 Value assumed decimal, unless preceded by 0x for hex
44 Return 0 if keyword not present or has no value.
45
46 char *getstr(char *s) - Return ptr to string value associated with
47 the keyword. Return null if keyword not present.
48 return null string if keyword has no value.
49 Caller must delete [] the string.
50
51 string_from_evbuffer(int evbuffer) - load the confuguration
52 string using event buffer 'evbuffer'
53
54 string_from_file(char *ffile) -- read file *ffile to get config string.
55 This is closest to the original init_strings
56 of S. Wood
57
58*/
59/* Define some common keywords as symbols, so we have just one place to
60 change them*/
61#define BUFFERED "buf"
62#define PARALLEL "par"
63#define THRESHOLDS "tfile"
64#define FLAG_FILE "ffile"
65#define SCALERS "sfile"
66#define SCALER_PERIOD "tscaler"
67#define BASE_SCALER "bscaler"
68#define FILE_CONFIG "fconfig"
69#define SYNC "sync"
70#define PS1 "ps1"
71#define PS2 "ps2"
72#define PS3 "ps3"
73#define PS4 "ps4"
74#define PS5 "ps5"
75#define PS6 "ps6"
76#define PS7 "ps7"
77#define PS8 "ps8"
78#define PEDESTALS "nped"
79#define PEDSUP "pedsup"
80#define ELECTRON "electron"
81#define HADRON "hadron"
82#define ECOINC "ecoinc"
83#define HCOINC "hcoinc"
84#define NOFPP "nofpp"
85#define DISABLE "disable"
86#define ESCALE "escale"
87#define HSCALE "hscale"
88#define RETIME "retime"
89#define PHELICITY "phelicity"
90#define BPM "bpm"
91#define CNTRM "cntrm"
92#define COUNTING_HOUSE "ch"
93#define COMMENT_CHAR ';'
94
95public:
96 THaUsrstrutils() = default;
97 virtual ~THaUsrstrutils() = default;
98 int getflag(const char *s) const;
99 char *getstr(const char *s) const;
100 unsigned int getint(const char *s) const;
101 long getSignedInt(const char *s) const;
102 void string_from_evbuffer(const UInt_t* evbuffer, UInt_t nlen);
103 void string_from_file(const char *ffile_name);
104
105protected:
106
107 std::string configstr;
108 void getflagpos(const char *s, const char **pos_ret,
109 const char **val_ret) const;
110 static void getflagpos_instring( const char *confstr, const char *s,
111 const char **pos_ret, const char **val_ret);
112
113 ClassDef(THaUsrstrutils,0) // User string utilities, DAQ parsing code.
114
115};
116
117//=============== inline functions ================================
118
119inline
120void THaUsrstrutils::getflagpos(const char *s, const char **pos_ret,
121 const char **val_ret) const
122{
123 getflagpos_instring(configstr.c_str(),s,pos_ret,val_ret);
124}
125
126}
127
128#endif /* _USRSTRUTILS_INCLUDED */
unsigned int UInt_t
#define ClassDef(name, id)
char * getstr(const char *s) const
void string_from_evbuffer(const UInt_t *evbuffer, UInt_t nlen)
long getSignedInt(const char *s) const
unsigned int getint(const char *s) const
int getflag(const char *s) const
void getflagpos(const char *s, const char **pos_ret, const char **val_ret) const
static void getflagpos_instring(const char *confstr, const char *s, const char **pos_ret, const char **val_ret)
virtual ~THaUsrstrutils()=default
void string_from_file(const char *ffile_name)