Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintMeta.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TROOT.h"
6 #include "TFile.h"
7 #include "TNamed.h"
8 #include "TKey.h"
9 #include "TRegexp.h"
10 
11 #include "JLang/JLangToolkit.hh"
13 #include "Jeep/JeepToolkit.hh"
14 #include "JSon/JSon.hh"
15 
17 #include "JSupport/JMeta.hh"
18 #include "JSupport/JSupport.hh"
19 
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 namespace {
24 
25  /**
26  * Print options.
27  */
28  static const char* plain_t = "plain"; //!< plain text
29  static const char* json_t = "JSON"; //!< JSON format
30 }
31 
32 /**
33  * \file
34  * Auxiliary program to print Jpp meta data.
35  * \author mdejong
36  */
37 int main(int argc, char **argv)
38 {
39  using namespace std;
40  using namespace JPP;
41 
42  string inputFile;
43  JLimit_t numberOfEvents;
44  string application;
45  string option;
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Auxiliary program to print Jpp meta data.");
51 
52  zap['f'] = make_field(inputFile);
53  zap['n'] = make_field(numberOfEvents) = JLimit::max();
54  zap['A'] = make_field(application) = "";
55  zap['O'] = make_field(option) = plain_t, json_t;
56  zap['d'] = make_field(debug) = 1;
57 
58  zap(argc, argv);
59  }
60  catch(const exception &error) {
61  FATAL(error.what() << endl);
62  }
63 
64  cout.tie(&cerr);
65 
66  if (application != "") {
67 
68  TFile* in = TFile::Open(inputFile.c_str(), "exists");
69 
70  if (in != NULL && in->IsOpen()) {
71 
72  const TRegexp regexp(application.c_str());
73 
74  TIter iter(in->GetListOfKeys());
75 
76  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
77 
78  const TString tag(key->GetName());
79 
80  if (tag.Contains(regexp)) {
81 
82  TNamed* named = dynamic_cast<TNamed*>(key->ReadObj());
83 
84  if (named != NULL) {
85  cout << named->GetName() << "[" << key->GetCycle() << "] " << named->GetTitle() << endl;
86  }
87  }
88  }
89 
90  in->Close();
91 
92  } else {
93 
94  ERROR("Error opening file: " << inputFile << endl);
95  }
96 
97  } else {
98 
99  JMultipleFileScanner<JMetaTypes_t> in(inputFile, numberOfEvents);
101 
102  json js;
103 
104  while (abc.hasNext()) {
105 
106  const JMeta* meta = abc.next();
107 
108  if (option == plain_t) {
109  cout << *meta << endl;
110  } else if (option == json_t) {
111  js += json(*meta);
112  }
113  }
114 
115  if (option == json_t) {
116  cout << setw(4) << js << endl;
117  }
118  }
119 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Auxiliary class for multiplexing object iterators.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Auxiliary methods for handling file names, type names and environment.
ROOT I/O of application specific meta data.
#define ERROR(A)
Definition: JMessage.hh:66
virtual const pointer_type & next() override
Get next element.
int debug
debug level
Definition: JSirene.cc:63
virtual bool hasNext() override
Check availability of next element.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
nlohmann::json json
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42