Jpp  18.0.1-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintRootVersion.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 
12 
13 #include "JDAQ/JDAQEventIO.hh"
14 #include "JDAQ/JDAQTimesliceIO.hh"
16 
18 
19 #include "JROOT/JRootToolkit.hh"
20 #include "JSupport/JSupport.hh"
21 #include "JLang/JTypeList.hh"
22 #include "JLang/JType.hh"
23 #include "JLang/JNullType.hh"
24 
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 
29 namespace {
30 
31  using namespace JPP;
32 
33  /**
34  * Print class streamer version.
35  *
36  * \param out output stream
37  * \param name class name
38  * \param file pointer to ROOT file
39  */
40  inline void print(std::ostream& out, const char* name, TFile* file = NULL)
41  {
42  using namespace std;
43  using namespace JPP;
44 
45  TDictionary* dictionary = TDictionary::GetDictionary(name);
46 
47  out << setw(40) << left << name << ' ';
48 
49  if (dictionary != NULL) {
50  out << setw( 4) << right << dynamic_cast<TClass*>(dictionary)->GetClassVersion() << ' ';
51  }
52 
53  if (file != NULL) {
54  out << setw(4) << right << getStreamerVersion(file, name);
55  }
56 
57  cout << endl;
58  }
59 
60 
61  /**
62  * Print class streamer version.
63  *
64  * \param out output stream
65  * \param typelist type list
66  * \param file pointer to ROOT file
67  */
68  inline void print(std::ostream& out, JType<JNullType> typelist, TFile* file = NULL)
69  {}
70 
71 
72  /**
73  * Print class streamer version.
74  *
75  * \param out output stream
76  * \param typelist type list
77  * \param file pointer to ROOT file
78  */
79  template<class JHead_t, class JTail_t>
80  inline void print(std::ostream& out, JType< JTypeList<JHead_t, JTail_t> > typelist, TFile* file = NULL)
81  {
82  print(out, JHead_t::Class_Name(), file);
83  print(out, JType<JTail_t>(), file);
84  }
85 }
86 
87 
88 /**
89  * \file
90  *
91  * Auxiliary program to print ROOT class version information.
92  * \author mdejong
93  */
94 int main(int argc, char **argv)
95 {
96  using namespace std;
97 
98  string input_file;
99  string class_name;
100  int debug;
101 
102  try {
103 
104  JParser<> zap("Auxiliary program to print ROOT class version information.");
105 
106  zap['f'] = make_field(input_file) = "";
107  zap['c'] = make_field(class_name) = "";
108  zap['d'] = make_field(debug) = 1;
109 
110  zap(argc, argv);
111  }
112  catch(const exception &error) {
113  FATAL(error.what() << endl);
114  }
115 
116 
117  using namespace JPP;
118 
120 
121  if (input_file != "") {
122 
123  try {
124  file.open(input_file.c_str());
125  }
126  catch(const exception& error) {
127  FATAL(error.what() << endl);
128  }
129 
130  if (!file.is_open()) {
131  FATAL("Error opening file " << input_file << endl);
132  }
133  }
134 
135  if (class_name != "")
136  print(cout, class_name.c_str(), file.getFile());
137  else
138  print(cout, JType<JAllDataTypes_t>(), file.getFile());
139 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
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
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
int getStreamerVersion(TFile *file, const char *const name)
Get ROOT streamer version of class with given name.
Auxiliary class for a type holder.
Definition: JType.hh:19
Type list.
Definition: JTypeList.hh:22
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
ROOT input file.
Definition: JRootFile.hh:95
print
Definition: JConvertDusj.sh:44
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
int debug
debug level