223{
226
228
234 JRange_t X;
235 JRange_t Y;
236 JRange_t Z;
245 string option;
248 string title;
252
253 try {
254
256
257 JParser<> zap(
"General purpose plot program for 2D ROOT objects.");
258
259 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
264 zap[
'x'] =
make_field(X,
"x-abscissa range") = JRange_t::DEFAULT_RANGE();
265 zap[
'y'] =
make_field(Y,
"y-abscissa range") = JRange_t::DEFAULT_RANGE();
266 zap[
'z'] =
make_field(Z,
"ordinate range") = JRange_t::DEFAULT_RANGE();
267 zap[
'X'] =
make_field(logx,
"logarithmic x-axis (-XX log10 axis)");
270 zap[
'P'] =
make_field(project,
"projection") =
"",
"xy",
"yx",
"xz",
"zx",
"yz",
"zy";
279 <<
"\"" <<
JName_t <<
"\" -> ROOT name; "
280 <<
"\"" <<
JTitle_t <<
"\" -> ROOT title)") =
"KM3NeT preliminary";
284
286 }
287 catch(const exception &error) {
289 }
290
291
293
296
298 ((
TRootCanvas *) cv->GetCanvasImp())->
Connect(
"CloseWindow()",
"TApplication", tp,
"Terminate()");
299 }
300
302
305 }
306
307 gROOT->SetStyle(
"gplot");
309
310
311 cv->SetFillStyle(4000);
313 cv->Divide(1,1);
314 cv->cd(1);
315
316 JMarkerAttributes::getInstance().setMarkerSize(
markerSize);
317
324
326
327
329
331
333
335
337 ERROR(
"File: " << input->getFullFilename() <<
" not opened." <<
endl);
338 continue;
339 }
340
342
344
346
347 const TString tag(
key->GetName());
348
350
351
352
354
356 title =
key->GetName();
358 title =
key->GetTitle();
359 }
360
362
363 try {
364
365 TH3&
h3 =
dynamic_cast<TH3&
>(*object);
366
368 }
369 catch(exception&) {}
370
371 try {
372
373 TH2& h2 =
dynamic_cast<TH2&
>(*object);
374
375 h2.SetStats(
stats != -1);
376
377 xmin = min(xmin, h2.GetXaxis()->GetXmin());
378 xmax = max(xmax, h2.GetXaxis()->GetXmax());
379 ymin = min(
ymin, h2.GetYaxis()->GetXmin());
380 ymax = max(
ymax, h2.GetYaxis()->GetXmax());
382 zmax = max(zmax, h2.GetMaximum());
383 }
384 catch(exception&) {}
385
386 try {
387
388 TGraph&
g1 =
dynamic_cast<TGraph&
>(*object);
389
390 for (
Int_t i = 0; i !=
g1.GetN(); ++i) {
395 }
396
398
400 if (
dynamic_cast<TGraph*
>(i->get()) !=
NULL) {
402 }
403 }
404
405 static_cast<TAttMarker&
>(
g1) = JMarkerAttributes::getInstance().get(
ng);
406 }
407 catch(exception&) {}
408
409 try {
410
411 TGraph2D& g2 = dynamic_cast<TGraph2D&>(*object);
412
413 for (
Int_t i = 0; i != g2.GetN(); ++i) {
414 if (!
logz || g2.GetZ()[i] > 0.0) {
415 xmin = min(xmin, g2.GetX()[i]);
416 xmax = max(xmax, g2.GetX()[i]);
419 zmin = min(zmin, g2.GetZ()[i]);
420 zmax = max(zmax, g2.GetZ()[i]);
421 }
422 }
423
424 if (Z.is_valid()) {
425 g2.SetMinimum(Z.getLowerLimit());
426 g2.SetMaximum(Z.getUpperLimit());
427 }
428 }
429 catch(exception&) {}
430
431 try {
432
433 TF2& f2 = dynamic_cast<TF2&>(*object);
434
435 f2.SetLineColor(
kRed);
437
442
444
449 zmin = min(zmin, f2.GetMinimum());
450 zmax = max(zmax, f2.GetMaximum());
451 }
452 catch(exception&) {}
453
454
455
456 for (TString buffer[] = { object.getLabel(), input->getFilename().c_str(), "" }, *i = buffer; *i != ""; ++i) {
457
458 *i = (*i)(
TRegexp(
"\\[.*\\]"));
459
460 if ((*i).Length() > 2) {
461 object.setLabel((*i)(1, (*i).Length() - 2));
462 }
463 }
464
465 if (
dynamic_cast<TH2*
> (
object.get()) !=
NULL ||
466 dynamic_cast<TGraph*
> (
object.get()) !=
NULL ||
467 dynamic_cast<TGraph2D*
>(
object.get()) !=
NULL ||
469 dynamic_cast<TLine*
> (
object.get()) !=
NULL ||
470 dynamic_cast<TText*
> (
object.get()) !=
NULL ||
471 dynamic_cast<TF2*
> (
object.get()) !=
NULL) {
472
473 DEBUG(
"Add object: " << tag <<
" with label <" <<
object.
getLabel() <<
">" <<
endl);
474
476
478 }
479
481
482 } else {
483 ERROR(
"For other objects than 2D histograms, use JPlot1D" <<
endl);
484 }
485 }
486 }
487 }
488
491 }
492
493
494
495 cv->cd(1);
496
497 if (option.find("COLZ") != string::npos ||
498 option.find("colz") != string::npos) {
499 gPad->SetRightMargin(0.20);
500 }
501
502 if (X.is_valid()) {
503 xmin = X.getLowerLimit();
504 xmax = X.getUpperLimit();
505 }
506
507 if (Y.is_valid()) {
508 ymin = Y.getLowerLimit();
509 ymax = Y.getUpperLimit();
510 }
511
512 if (Z.is_valid()) {
513 zmin = Z.getLowerLimit();
514 zmax = Z.getUpperLimit();
515 } else if (zmax > zmin) {
517 }
518
520
522
524 100, xmin, xmax,
526
528 }
529 }
530
532
534
535 p->SetTextAlign(21);
536 p->SetTextAngle(45);
537 p->Draw();
538
539 } else {
540
541 if (logx) {
gPad->SetLogx(); }
544
545 master->SetTitle(title.c_str());
546
547 master->GetXaxis()->SetRangeUser(xmin, xmax);
549
552
553 if (logx > 2) {
master->GetXaxis()->SetNoExponent(); }
554 if (
logy > 2) {
master->GetYaxis()->SetNoExponent(); }
555
558
562
563 master->GetXaxis()->SetMoreLogLabels((logx == 1 &&
log10(xmax/xmin) < 2) ||
564 (logx > 1 && xmax-xmin < 2));
567
569 master->SetNdivisions(i->second, i->first.c_str());
570 }
571
573
574 master->Draw(option.c_str());
575 }
576
577 if (logx > 1 ||
logy > 1) {
579 if (
dynamic_cast<TH2*
> (i->get()) !=
master &&
580 dynamic_cast<TGraph2D*
>(i->get()) !=
master) {
581 if (logx > 1) {
590 }
600 }
601 }
602 }
603 }
604
605 if (
grid.count(
'x') ||
grid.count(
'X')) {
gPad->SetGridx(); }
606 if (
grid.count(
'y') ||
grid.count(
'Y')) {
gPad->SetGridy(); }
607
610 else
612
613
615
617
618 DEBUG(
"Draw " << (*i)->GetName() <<
' ' << (*i)->GetTitle() <<
endl);
619
620 string buffer(option);
621
622 buffer += "SAME";
623
624 try {
625
626 TH2& h2 =
dynamic_cast<TH2&
>(*(*i));
627
628 h2.SetMinimum(zmin);
629 h2.SetMaximum(zmax);
630 }
631 catch(exception&) {}
632
633 try {
634
635 TGraph&
g1 =
dynamic_cast<TGraph&
>(*(*i));
636
637 buffer = "P";
638 }
639 catch(exception&) {}
640
641 try {
642
643 TGraph2D& g2 = dynamic_cast<TGraph2D&>(*(*i));
644
645 g2.SetMinimum(zmin);
646 g2.SetMaximum(zmax);
647 }
648 catch(exception&) {}
649
650 try {
651
652 TF2& f2 = dynamic_cast<TF2&>(*(*i));
653
654 f2.SetNpx(1000);
655 f2.SetNpy(1000);
656
657
658
659
660 }
661 catch(exception&) {}
662
663 (*i)->Draw(buffer.c_str());
664 }
665 }
666
667
668
669 cv->Update();
670
673 }
674
676 tp->Run();
677 }
678
680}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t g1(const Double_t x)
Function.
Utility class to parse parameter values.
Auxiliary data structure for TObject with a user defined label.
Template definition of a multi-dimensional oscillation probability interpolation table.
Auxiliary class to handle multiple boolean-like I/O.
Utility class to parse command line options.
Data structure for size of TCanvas.
Wrapper class around ROOT TStyle.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()).
void setRange(double &xmin, double &xmax, const bool logx)
Set axis range.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
void setLogarithmicY(TList *list)
Make y-axis of objects in list logarithmic (e.g. after using log10()).
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).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
JProperties getProperties()
Get properties of this class.