Jpp  18.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMeta.cc File Reference

Example program to test JSUPPORT::JMeta class. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "TFile.h"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JSUPPORT::JMeta class.

Author
mdejong

Definition in file JMeta.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file JMeta.cc.

21 {
22  using namespace std;
23  using namespace JPP;
24 
25  string outputFile;
26  vector<int> buffer;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Example program to test meta.");
32 
33  zap['o'] = make_field(outputFile) = "meta.root";
34  zap['x'] = make_field(buffer);
35  zap['d'] = make_field(debug) = 2;
36 
37  zap(argc, argv);
38  }
39  catch(const exception &error) {
40  FATAL(error.what() << endl);
41  }
42 
43  argv[0] = (char*) "test"; // rename
44 
45  const JMeta meta(argc, argv);
46 
47  DEBUG(meta << endl);
48  DEBUG(meta.toString() << endl);
49 
50  ASSERT(JMeta::valueOf(meta.toString()) == meta);
51 
52  {
53  TFile* file = TFile::Open(outputFile.c_str(), "recreate");
54 
55  putObject(file, meta);
56 
57  file->Write();
58  file->Close();
59  }
60 
61  {
62  TFile* file = TFile::Open(outputFile.c_str(), "exists");
63 
64  ASSERT(file != NULL);
65 
66  JMeta* p = NULL;
67 
68  const int cycle = 1;
69 
70  getObject(file, MAKE_CSTRING(META_NAME << ';' << cycle), p);
71 
72  ASSERT(p != NULL);
73 
74  DEBUG(*p);
75 
76  ASSERT(meta == *p);
77 
78  file->Close();
79  }
80 
81  return 0;
82 }
Utility class to parse command line options.
Definition: JParser.hh:1514
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Definition: JDataQuality.sh:19
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
string outputFile
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
#define FATAL(A)
Definition: JMessage.hh:67
static const char *const META_NAME
ROOT name for meta data.
Definition: JMeta.hh:46
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62