Jpp
18.0.1-rc.2
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JGizmo
JPrintName.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
#include <sstream>
5
#include <cmath>
6
7
#include "TROOT.h"
8
#include "TFile.h"
9
#include "TObject.h"
10
#include "TKey.h"
11
#include "TString.h"
12
#include "TRegexp.h"
13
14
#include "
JGizmo/JRootObjectID.hh
"
15
#include "
JGizmo/JGizmoToolkit.hh
"
16
17
#include "
Jeep/JParser.hh
"
18
#include "
Jeep/JMessage.hh
"
19
#include "
Jeep/JPrint.hh
"
20
21
22
/**
23
* \file
24
*
25
* Auxiliary program to print name of ROOT objects.
26
*
27
* The option <tt>-f</tt> corresponds to <tt><file name>:<object name></tt>.
28
* \author mdejong
29
*/
30
int
main
(
int
argc,
char
**argv)
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) &&
isTObject
(key)) {
75
76
TObject
*
object
= key->ReadObj();
77
78
cout <<
object
->GetName() << endl;
79
}
80
}
81
}
82
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
TObject
Definition:
JRoot.hh:19
std::vector
Definition:
JSTDTypes.hh:12
JPrint.hh
I/O formatting auxiliaries.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
JGizmoToolkit.hh
JRootObjectID.hh
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JGIZMO::isTObject
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
Definition:
JGizmoToolkit.hh:1517
JGIZMO::getDirectory
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Definition:
JGizmoToolkit.hh:137
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5