Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintMeta.cc File Reference

Auxiliary program to print Jpp meta data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TNamed.h"
#include "TKey.h"
#include "TRegexp.h"
#include "JLang/JLangToolkit.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "Jeep/JeepToolkit.hh"
#include "JSon/JSon.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.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

Auxiliary program to print Jpp meta data.

Author
mdejong

Definition in file JPrintMeta.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 37 of file JPrintMeta.cc.

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:71
Utility class to parse command line options.
Definition: JParser.hh:1493
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
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:1954
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
nlohmann::json json