93   typedef JRange<double>  JRange_t;
 
  124     JParser<> zap(
"General purpose plot program for 1D ROOT objects.");
 
  126     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
  128     zap[
'w'] = 
make_field(canvas,     
"size of canvas <nx>x<ny> [pixels]")  = JCanvas(500, 500);
 
  130     zap[
'L'] = 
make_field(legend,     
"position legend e.g. TR")            = 
"", 
"TL", 
"TR", 
"BR", 
"BL";
 
  131     zap[
'x'] = 
make_field(
X,          
"abscissa range")                     = JRange_t();
 
  132     zap[
'y'] = 
make_field(
Y,          
"ordinate range")                     = JRange_t();
 
  133     zap[
'z'] = 
make_field(
Z,          
"ordinate range of projection)")      = JRange_t();
 
  134     zap[
'X'] = 
make_field(logx,       
"logarithmic x-axis (-XX log10 axis)");
 
  135     zap[
'Y'] = 
make_field(logy,       
"logarithmic y-axis");
 
  136     zap[
'Z'] = 
make_field(logz,       
"logarithmic y-axis; after projection");
 
  137     zap[
'P'] = 
make_field(project,    
"projection")                         = 
'\0', 
'x', 
'X', 
'y', 
'Y';
 
  138     zap[
'>'] = 
make_field(xLabel,     
"x-axis label")                       = 
"";
 
  139     zap[
'^'] = 
make_field(yLabel,     
"y-axis label")                       = 
"";
 
  142     zap[
'l'] = 
make_field(lineWidth,  
"line width")                         = 2;
 
  143     zap[
'S'] = 
make_field(markerSize, 
"marker size")                        = 1.0;
 
  144     zap[
'O'] = 
make_field(option,     
"plotting option")                    = 
"";
 
  146     zap[
'B'] = 
make_field(batch,      
"batch processing");
 
  147     zap[
'T'] = 
make_field(title,      
"title")                              = 
"KM3NeT preliminary";
 
  149     zap[
'g'] = 
make_field(group,      
"group colour codes of objects")      = 1;
 
  150     zap[
't'] = 
make_field(xTimeFormat, 
"set time format for x-axis, e.g. \%d\\/\%m\\/\\%y%F1970-01-01 00:00:00") = 
"";
 
  155   catch(
const exception &error) {
 
  156     FATAL(error.what() << endl);
 
  160   gROOT->SetBatch(batch);
 
  162   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  163   TCanvas*      cv = 
new TCanvas(
"c1", 
"c1", canvas.x, canvas.y);
 
  165   JSinglePointer<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
 
  167   gROOT->SetStyle(
"gplot");
 
  171   cv->SetFillStyle(4000);
 
  172   cv->SetFillColor(kWhite);
 
  181   Double_t xmin = numeric_limits<double>::max();
 
  182   Double_t xmax = numeric_limits<double>::lowest();
 
  184   Double_t ymin = numeric_limits<double>::max();
 
  185   Double_t ymax = numeric_limits<double>::lowest();
 
  190   const bool px = (project == 
'x' || project == 
'X');  
 
  191   const bool py = (project == 
'y' || project == 
'Y');  
 
  192   const bool pz = (project == 
'z' || project == 
'Z');  
 
  194   logy = (logy || logz);
 
  209     DEBUG(
"Input: " << *input << endl);
 
  214       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  218     const TRegexp regexp(input->getObjectName());
 
  220     TIter iter(dir->GetListOfKeys());
 
  222     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  224       const TString tag(key->GetName());
 
  226       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  230       if (tag.Contains(regexp) && 
isTObject(key)) {
 
  232         if        (title == JName_t) {
 
  233           title = key->GetName();
 
  234         } 
else if (title == JTitle_t) {
 
  235           title = key->GetTitle();
 
  238         JRootObject object(key->ReadObj());
 
  251           line.SetLineColor(marker.GetMarkerColor());
 
  257           TProfile& 
h1 = 
dynamic_cast<TProfile&
>(*object);
 
  259           object = h1.ProjectionX();
 
  265           TH2& h2 = 
dynamic_cast<TH2&
>(*object);
 
  271                                       h2.GetYaxis()->FindBin(
Z.getLowerLimit()),
 
  272                                       h2.GetYaxis()->FindBin(
Z.getUpperLimit()) - 1);
 
  276                                       h2.GetYaxis()->GetNbins());
 
  282                                       h2.GetXaxis()->FindBin(
Z.getLowerLimit()),
 
  283                                       h2.GetXaxis()->FindBin(
Z.getUpperLimit()) - 1);
 
  287                                       h2.GetXaxis()->GetNbins());
 
  291             ERROR(
"For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
 
  300           TH3& h3 = 
dynamic_cast<TH3&
>(*object);
 
  316             ERROR(
"For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" << endl);
 
  326           if (dynamic_cast<TMarker*>(
object.
get()) == NULL) {
 
  327             dynamic_cast<TAttMarker&
>(*object) = marker; 
 
  332           if (dynamic_cast<TLine*>(
object.
get())   == NULL) {
 
  333             dynamic_cast<TAttLine&
>  (*object) = line;
 
  342             TAttFill& fill = 
dynamic_cast<TAttFill&
>(*object);
 
  344             fill.SetFillColor(marker.GetMarkerColor()); 
 
  355             TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  357             for (
int i = 1; i <= h1.GetNbinsX(); ++i) {
 
  358               h1.SetBinError(i, 0.0);
 
  365             TGraphErrors& 
g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  367             for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  379           TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  381           h1.SetStats(stats != -1);
 
  383           xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  384           xmax = max(xmax, h1.GetXaxis()->GetXmax());       
 
  385           ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  386           ymax = max(ymax, h1.GetMaximum());
 
  392           TGraph& g1 = 
dynamic_cast<TGraph&
>(*object);
 
  394           for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  396             xmin = min(xmin, g1.GetX()[i]);
 
  397             xmax = max(xmax, g1.GetX()[i]);
 
  399             if (!logy || g1.GetY()[i] > 0.0) {
 
  400               ymin = min(ymin, g1.GetY()[i]);
 
  401               ymax = max(ymax, g1.GetY()[i]);
 
  409           TGraphErrors& g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  411           for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  412             if (!logy || g1.GetY()[i] - g1.GetEY()[i] > 0.0) { ymin = min(ymin, g1.GetY()[i] - g1.GetEY()[i]); }
 
  413             if (!logy || g1.GetY()[i] + g1.GetEY()[i] > 0.0) { ymax = max(ymax, g1.GetY()[i] + g1.GetEY()[i]); }
 
  420           TMultiGraph& m1 = 
dynamic_cast<TMultiGraph&
>(*object);
 
  422           for (TIter i1(m1.GetListOfGraphs()); TGraph* g1 = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  424             for (Int_t i = 0; i != g1->GetN(); ++i) {
 
  426               xmin = min(xmin, g1->GetX()[i]);
 
  427               xmax = max(xmax, g1->GetX()[i]);
 
  429               if (!logy || g1->GetY()[i] > 0.0) {
 
  430                 ymin = min(ymin, g1->GetY()[i]);
 
  431                 ymax = max(ymax, g1->GetY()[i]);
 
  440           TF2& f2 = 
dynamic_cast<TF2&
>(*object);
 
  443           TString formula = f2.GetExpFormula();
 
  444           TString _z_     = TString::Format(
"%f", 0.5 * (
Z.getLowerLimit() + 
Z.getUpperLimit()));
 
  451           f2.GetRange(__xmin, __ymin, __xmax, __ymax);
 
  455             formula.ReplaceAll(
"y", _z_);
 
  459             f1->SetRange(__xmin, __xmax);
 
  463             formula.ReplaceAll(
"x", _z_);
 
  464             formula.ReplaceAll(
"y", 
"x");
 
  468             f1->SetRange(__ymin, __ymax);
 
  472             ERROR(
"For 2D functions, use option option -P for projections or use JPlot2D" << endl);
 
  477           DEBUG(
"TF1: " << f1->GetExpFormula() << endl);
 
  479           f1->SetParameters(f2.GetParameters());
 
  487           TF1& f1 = 
dynamic_cast<TF1&
>(*object);
 
  492           f1.GetRange(__xmin, __xmax);
 
  494           xmin = min(xmin, __xmin);
 
  495           xmax = max(xmax, __xmax);
 
  496           ymin = min(ymin, f1.GetMinimum());
 
  497           ymax = max(ymax, f1.GetMaximum());
 
  503           THStack& hs = 
dynamic_cast<THStack&
>(*object);
 
  505           NOTICE(
"THStack" << endl);
 
  507           TIterator* 
iterator = hs.GetHists()->MakeIterator();
 
  509           for (
size_t index = 1; 
TObject* i = iterator->Next(); ++index) {
 
  511             TH1& h1 = 
dynamic_cast<TH1&
>(*i);
 
  513             NOTICE(
"TH1[" << index << 
"] " << h1.GetName() << endl);
 
  515             xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  516             xmax = max(xmax, h1.GetXaxis()->GetXmax());
 
  518             ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  519             ymax = max(ymax, h1.GetMaximum());
 
  522             h1.SetLineColor(kBlack);
 
  531           TLine& h1 = 
dynamic_cast<TLine&
>(*object);
 
  533           xmin = min(xmin, h1.GetX1());
 
  534           xmax = max(xmax, h1.GetX2());
 
  535           ymin = min(ymin, h1.GetY1());
 
  536           ymax = max(ymax, h1.GetY2());
 
  542         for (TString buffer[] = { 
object.getLabel(), input->getFilename().c_str(), 
"" }, *i = buffer; *i != 
""; ++i) {
 
  544           *i = (*i)(TRegexp(
"\\[.*\\]"));
 
  546           if (i->Length() > 2) {
 
  547             object.setLabel((*i)(1, i->Length() - 2));
 
  551         DEBUG(
"Add object: " << tag << 
" with label <" << 
object.
getLabel() << 
">" << endl);
 
  554           master = 
dynamic_cast<TH1*
>(
object.get());
 
  557         listOfObjects.push_back(
object);
 
  562   if (listOfObjects.empty()) {
 
  563     ERROR(
"Nothing to draw." << endl);
 
  572     TH1*         h1 = 
dynamic_cast<TH1*
>        (i->get());
 
  573     TGraph*      g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  574     TMultiGraph* m1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  575     TAttLine*    ls = 
dynamic_cast<TAttLine*
>   (i->get());
 
  578     TIterator*   iterator = NULL;
 
  582       iterator = h1->GetListOfFunctions()->MakeIterator();
 
  584     } 
else if (g1 != NULL) {
 
  586       iterator = g1->GetListOfFunctions()->MakeIterator();
 
  588     } 
else if (m1 != NULL) {
 
  590       for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  591         for (TIter i2(gi->GetListOfFunctions()); TF1* fi = 
dynamic_cast<TF1*
>(i2()); ) {
 
  596       iterator = list.MakeIterator();
 
  599     if (iterator != NULL) {
 
  601       Double_t x1[] = { numeric_limits<Double_t>::max(),    numeric_limits<Double_t>::max() };
 
  602       Double_t x2[] = { numeric_limits<Double_t>::lowest(), numeric_limits<Double_t>::lowest() };
 
  604       for (
int nf = 0, ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ++nf) {
 
  606         f1->GetRange(x1[1], x2[1]);
 
  611         if (listOfObjects.size() == 1) {
 
  613           if      (x1[0] == x1[1] && 
 
  626           f1->SetLineColor(ls->GetLineColor());
 
  638         f1->GetRange(__xmin, __xmax);
 
  640         ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
 
  641         ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
 
  648   if (
X != JRange_t()) { 
 
  649     xmin = 
X.getLowerLimit();
 
  650     xmax = 
X.getUpperLimit();
 
  653   if (
Y != JRange_t()) {
 
  654     ymin = 
Y.getLowerLimit();
 
  655     ymax = 
Y.getUpperLimit();
 
  662   if (!listOfObjects.empty()) {
 
  666       master = 
new TH1D(MASTER.c_str(), NULL, 100, xmin, xmax);
 
  670       for (Int_t i = 1; i <= 
master->GetXaxis()->GetNbins(); ++i) {
 
  671         master->SetBinContent(i, ymin);
 
  678     TText* p = 
new TText(0.5, 0.5, 
MAKE_CSTRING(
"No data"));
 
  686     if (logx) { gPad->SetLogx(); }
 
  687     if (logy) { gPad->SetLogy(); }
 
  689     master->GetXaxis()->SetRangeUser(xmin, xmax);
 
  690     master->SetTitle(title.c_str());
 
  699     if (xLabel != 
"") { 
master->GetXaxis()->SetTitle(xLabel.c_str()); 
master->GetXaxis()->CenterTitle(
true); }
 
  700     if (yLabel != 
"") { 
master->GetYaxis()->SetTitle(yLabel.c_str()); 
master->GetYaxis()->CenterTitle(
true); }
 
  702     master->GetXaxis()->SetMoreLogLabels((logx == 1 && 
log10(xmax/xmin) < 2) ||
 
  703                                          (logx >  1 &&      (xmax-xmin) < 2));
 
  705     master->GetYaxis()->SetMoreLogLabels( logy      && 
log10(ymax/ymin) < 2);
 
  706     master->GetYaxis()->SetNoExponent   ( logy      && 
log10(ymax/ymin) < 2);
 
  708     if (Ndivisions.first != 
"") {
 
  709       master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
 
  712     if (xTimeFormat != 
"") {
 
  714       master->GetXaxis()->SetTimeDisplay(1);
 
  716       if        (xTimeFormat == 
"utc") {
 
  717         master->GetXaxis()->SetTimeFormat(
"#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
 
  718         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  719       } 
else if (xTimeFormat == 
"UTC") {
 
  720         master->GetXaxis()->SetTimeFormat(
"%d-%m-%y");
 
  721         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  723         master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
 
  727     master->Draw(option.c_str());
 
  732       if (dynamic_cast<TH1*>(i->get()) != 
master) {
 
  733         if      (setLogX<TH1>         (i->get())) {}
 
  734         else if (setLogX<TF1>         (i->get())) {}
 
  735         else if (setLogX<TGraphErrors>(i->get())) {}
 
  736         else if (setLogX<TGraph>      (i->get())) {}
 
  737         else if (setLogX<TMultiGraph> (i->get())) {}
 
  738         else if (setLogX<TLine>       (i->get())) {}
 
  739         else if (setLogX<TEllipse>    (i->get())) {}
 
  744   if (grid.count(
'x') || grid.count(
'X')) { gPad->SetGridx(); }
 
  745   if (grid.count(
'y') || grid.count(
'Y')) { gPad->SetGridy(); }
 
  748     gStyle->SetOptStat(stats);
 
  750     gStyle->SetOptFit(kFALSE);
 
  755     DEBUG(
"Draw " << (*i)->GetName() << 
' ' << (*i)->GetTitle() << endl);
 
  757     string buffer(option);
 
  765     TF1*         f1 = 
dynamic_cast<TF1*
>        (i->get());
 
  766     TGraph*      g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  767     TMultiGraph* q1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  774       if (g1->GetN() > 1 && drawLine)
 
  782       for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  784         string zbuf = buffer;
 
  786         if (gi->GetN() > 1 && drawLine)
 
  791         gi->Draw(zbuf.c_str());
 
  796       (*i).Draw(buffer.c_str());
 
  804     Ssiz_t height = listOfObjects.size();
 
  808       width = max(width, i->getLabel().Length());
 
  811     TLegend* lg = 
getLegend(width, height, legend);
 
  814       lg->AddEntry(*i, 
" " + i->getLabel(), 
isTAttLine(*i) ? 
"L" : 
"LPF"); 
 
  830   return (
master != NULL ? 0 : 1);
 
Utility class to parse command line options. 
 
then echo Test string reversed by master(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho" -rC fi if (( 1 ))
 
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications. 
 
#define MAKE_CSTRING(A)
Make C-string. 
 
then for HISTOGRAM in h0 h1
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
 
bool isTAttLine(const TObject *object)
Get drawing option of TH1. 
 
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()). 
 
T & getInstance(const T &object)
Get static instance from temporary object. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
set_variable E_E log10(E_{fit}/E_{#mu})"
 
then break fi done getCenter read X Y Z let X
 
static const char LABEL_TERMINATOR
label terminator 
 
void setRange(double &xmin, double &xmax, const bool logx)
Set axis range. 
 
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option="TR")
Get legend. 
 
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
 
Auxiliary class to handle multiple boolean-like I/O. 
 
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject. 
 
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer. 
 
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
 
Double_t g1(const Double_t x)
Function.