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

Auxiliary program to print name of ROOT objects. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TObject.h"
#include "TKey.h"
#include "TString.h"
#include "TRegexp.h"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JPrint.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print name of ROOT objects.

The option -f corresponds to <file name>:<object name>.

Author
mdejong

Definition in file JPrintName.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JPrintName.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34 
35  vector<JRootObjectID> inputFile;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Auxiliary program to print name of ROOT objects.");
41 
42  zap['f'] = make_field(inputFile, "<input file>:<object name>");
43  zap['d'] = make_field(debug) = 0;
44 
45  zap(argc, argv);
46  }
47  catch(const exception &error) {
48  FATAL(error.what() << endl);
49  }
50 
51  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
52 
53  DEBUG("Input: " << *input << endl);
54 
55  TDirectory* dir = getDirectory(*input);
56 
57  if (dir == NULL) {
58  ERROR("File: " << input->getFullFilename() << " not opened." << endl);
59  continue;
60  }
61 
62  const TRegexp regexp(input->getObjectName());
63 
64  TIter iter(dir->GetListOfKeys());
65 
66  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
67 
68  const TString tag(key->GetName());
69 
70  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
71 
72  // option match
73 
74  if (tag.Contains(regexp)) {
75 
76  TObject* object = key->ReadObj();
77 
78  cout << object->GetName() << endl;
79  }
80  }
81  }
82 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Definition: JRoot.hh:19
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.