Jpp
Functions
JPrintTitle.cc File Reference
#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 title of ROOT objects.

Author
mdejong

Definition in file JPrintTitle.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JPrintTitle.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 result from ROOT histograms."\
41  "\nNote that the formula may contain method names of the specified object.");
42 
43  zap['f'] = make_field(inputFile, "<input file>:<object name>");
44  zap['d'] = make_field(debug) = 0;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
53 
54  DEBUG("Input: " << *input << endl);
55 
56  TDirectory* dir = getDirectory(*input);
57 
58  if (dir == NULL) {
59  ERROR("File: " << input->getFullFilename() << " not opened." << endl);
60  continue;
61  }
62 
63  const TRegexp regexp(input->getObjectName());
64 
65  TIter iter(dir->GetListOfKeys());
66 
67  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
68 
69  const TString tag(key->GetName());
70 
71  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
72 
73  // option match
74 
75  if (tag.Contains(regexp)) {
76 
77  TObject* object = key->ReadObj();
78 
79  cout << object->GetTitle() << endl;
80  }
81  }
82  }
83 }
TObject
Definition: JRoot.hh:19
std::vector
Definition: JSTDTypes.hh:12
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
ERROR
#define ERROR(A)
Definition: JMessage.hh:66
debug
int debug
debug level
Definition: JSirene.cc:59
JGIZMO::getDirectory
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Definition: JGizmoToolkit.hh:121
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67