36{
39
43 bool batch;
45
46 try {
47
48 JParser<> zap(
"General purpose plot program to draw ROOT objects.");
49
50 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
52 zap[
'w'] =
make_field(canvas,
"size of canvas <nx>x<ny> [pixels]") =
JCanvas(500, 500);
53 zap[
'B'] =
make_field(batch,
"batch processing");
55
56 zap(argc, argv);
57 }
58 catch(const exception &error) {
59 FATAL(error.what() << endl);
60 }
61
62
63 gROOT->SetBatch(batch);
64
65 TApplication* tp = new TApplication("user", NULL, NULL);
66 TCanvas* cv =
new TCanvas(
"c1",
"c1", canvas.
x, canvas.
y);
67
68 if (!batch) {
69 ((TRootCanvas *) cv->GetCanvasImp())->Connect("CloseWindow()", "TApplication", tp, "Terminate()");
70 }
71
72 cv->SetFillStyle(4000);
73 cv->SetFillColor(kWhite);
74 cv->Divide(1,1);
75 cv->cd(1);
76
77 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
78
79 DEBUG(
"Input: " << *input << endl);
80
82
83 if (dir == NULL) {
84 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
85 continue;
86 }
87
88 const TRegexp regexp(input->getObjectName());
89
90 TIter iter(dir->GetListOfKeys());
91
92 for (TKey* key; (
key = (TKey*) iter.Next()) != NULL; ) {
93
94 const TString tag(
key->GetName());
95
96 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
97
98
99
100 if (tag.Contains(regexp) &&
isTObject(key)) {
101
103
104 if (dynamic_cast<TText*> (p) ||
105 dynamic_cast<TLine*> (p) ||
106 dynamic_cast<TEllipse*>(p) ||
107 dynamic_cast<TBox*> (p)) {
108
109 DEBUG(
"Add object: " << tag <<
" with name <" << p->GetName() <<
">" << endl);
110
111 p->Draw("SAME");
112 }
113 }
114 }
115 }
116
117 cv->Update();
118
121 }
122
123 if (!batch) {
124 tp->Run();
125 }
126}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
Data structure for size of TCanvas.
int y
number of pixels in Y
int x
number of pixels in X
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).