25 int main(
int argc,
char *argv[])
30 signal(SIGILL, SIG_DFL);
31 signal(SIGBUS, SIG_DFL);
32 signal(SIGSEGV, SIG_DFL);
33 signal(SIGPIPE, SIG_DFL);
35 const char* hostname = NULL;
36 const char* exptname = NULL;
37 const char* filename = argv[1];
40 bool jsonfile =
false;
44 else if (strstr(filename,
".xml")!=0)
46 else if (strstr(filename,
".json")!=0)
52 int err = midas->
connect(hostname, exptname,
"rootana");
54 fprintf(stderr,
"Cannot connect to MIDAS, error %d\n", err);
62 }
else if (jsonfile) {
70 printf(
"Cannot open input file \"%s\"\n",filename);
84 if ((eventId & 0xFFFF) == 0x8000)
107 printf(
"Failed to load ODB from input file \"%s\"\n",filename);
113 printf(
"read run number (odbReadInt): %d\n",
gOdb->odbReadInt(
"/runinfo/Run number"));
114 printf(
"read array size of /test: %d\n",
gOdb->odbReadArraySize(
"/test"));
115 printf(
"read array size of /runinfo/run number: %d\n",
gOdb->odbReadArraySize(
"/runinfo/Run number"));
116 printf(
"read array size of /test/intarr: %d\n",
gOdb->odbReadArraySize(
"/test/intarr"));
117 printf(
"read array values:\n");
118 int size =
gOdb->odbReadArraySize(
"/test/intarr");
119 for (
int i=0; i<size; i++)
120 printf(
" intarr[%d] = %d\n", i,
gOdb->odbReadInt(
"/test/intarr", i));
121 printf(
"read double value: %f\n",
gOdb->odbReadDouble(
"/test/dblvalue"));
122 printf(
"read uint32 value: %d\n",
gOdb->odbReadUint32(
"/test/dwordvalue"));
123 printf(
"read bool value: %d\n",
gOdb->odbReadBool(
"/test/boolvalue"));
124 const char* s =
gOdb->odbReadString(
"/test/stringvalue");
128 printf(
"read string value: [%s] length %d\n", s, len);
130 printf(
"\nTry non-existent entries...\n\n");
132 printf(
"read array size: %d\n",
gOdb->odbReadArraySize(
"/test/doesnotexist"));
133 printf(
"read uint32 value: %d\n",
gOdb->odbReadUint32(
"/test/doesnotexist", 0, -9999));
135 printf(
"\nTry wrong types...\n\n");
137 printf(
"read float value: %f\n",
gOdb->odbReadDouble(
"/test/fltvalue"));
138 printf(
"read uint32 value: %d\n",
gOdb->odbReadUint32(
"/test/wordvalue"));
139 printf(
"read int value: %d\n",
gOdb->odbReadInt(
"/test/wordvalue"));
141 printf(
"\nTry wrong array indices...\n\n");
143 printf(
"try to index a non-array: %f\n",
gOdb->odbReadDouble(
"/test/dblvalue", 10, -9999));
144 printf(
"try invalid index -1: %d\n",
gOdb->odbReadInt(
"/test/intarr", -1, -9999));
145 printf(
"try invalid index 999: %d\n",
gOdb->odbReadInt(
"/test/intarr", 999, -9999));
146 printf(
"try invalid index 1 for double value: %f\n",
gOdb->odbReadDouble(
"/test/dblvalue", 1, -9999));
uint32_t GetDataSize() const
return the event size
uint16_t GetEventId() const
return the event id
char * GetData()
return pointer to the data buffer
static TMidasOnline * instance()
int connect(const char *hostname, const char *exptname, const char *progname)
Connect to MIDAS experiment.
TMReaderInterface * TMNewReader(const char *source)
TMEvent * TMReadEvent(TMReaderInterface *reader)
MVOdb * MakeMidasOdb(int hDB, MVOdbError *error=NULL)
MVOdb * MakeJsonFileOdb(const char *filename, MVOdbError *error=NULL)
MVOdb * MakeFileDumpOdb(const char *buf, int bufsize, MVOdbError *error=NULL)
Access ODB from a midas file dump. FOrmat could be .xml, .json or .odb.
MVOdb * MakeXmlFileOdb(const char *filename, MVOdbError *error=NULL)
int main(int argc, char *argv[])