68   typedef JRange<double>  JRange_t;
 
   99     JParser<> zap(
"General purpose plot program for 1D ROOT objects.");
 
  101     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
  103     zap[
'w'] = 
make_field(canvas,     
"size of canvas <nx>x<ny> [pixels]")  = JCanvas(500, 500);
 
  105     zap[
'L'] = 
make_field(legend,     
"position legend e.g. TR")            = 
"", 
"TL", 
"TR", 
"BR", 
"BL";
 
  106     zap[
'x'] = 
make_field(
X,          
"abscissa range")                     = JRange_t();
 
  107     zap[
'y'] = 
make_field(
Y,          
"ordinate range")                     = JRange_t();
 
  108     zap[
'z'] = 
make_field(
Z,          
"ordinate range of projection)")      = JRange_t();
 
  109     zap[
'X'] = 
make_field(logx,       
"logarithmic x-axis (-XX log10 axis)");
 
  110     zap[
'Y'] = 
make_field(logy,       
"logarithmic y-axis");
 
  111     zap[
'Z'] = 
make_field(logz,       
"logarithmic y-axis; after projection");
 
  112     zap[
'P'] = 
make_field(project,    
"projection")                         = 
'\0', 
'x', 
'X', 
'y', 
'Y';
 
  113     zap[
'>'] = 
make_field(xLabel,     
"x-axis label")                       = 
"";
 
  114     zap[
'^'] = 
make_field(yLabel,     
"y-axis label")                       = 
"";
 
  117     zap[
'l'] = 
make_field(lineWidth,  
"line width")                         = 2;
 
  118     zap[
'S'] = 
make_field(markerSize, 
"marker size")                        = 1.0;
 
  119     zap[
'O'] = 
make_field(option,     
"plotting option")                    = 
"";
 
  121     zap[
'B'] = 
make_field(batch,      
"batch processing");
 
  122     zap[
'T'] = 
make_field(title,      
"title")                              = 
"KM3NeT preliminary";
 
  124     zap[
'g'] = 
make_field(group,      
"group colour codes of objects")      = 1;
 
  125     zap[
't'] = 
make_field(xTimeFormat, 
"set time format for x-axis, e.g. \%d\\/\%m\\/\\%y%F1970-01-01 00:00:00") = 
"";
 
  130   catch(
const exception &error) {
 
  131     FATAL(error.what() << endl);
 
  135   gROOT->SetBatch(batch);
 
  137   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  138   TCanvas*      cv = 
new TCanvas(
"c1", 
"c1", canvas.x, canvas.y);
 
  140   JSinglePointer<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
 
  142   gROOT->SetStyle(
"gplot");
 
  146   cv->SetFillStyle(4000);
 
  147   cv->SetFillColor(kWhite);
 
  156   Double_t xmin = numeric_limits<double>::max();
 
  157   Double_t xmax = numeric_limits<double>::lowest();
 
  159   Double_t ymin = numeric_limits<double>::max();
 
  160   Double_t ymax = numeric_limits<double>::lowest();
 
  165   const bool px = (project == 
'x' || project == 
'X');  
 
  166   const bool py = (project == 
'y' || project == 
'Y');  
 
  167   const bool pz = (project == 
'z' || project == 
'Z');  
 
  169   logy = (logy || logz);
 
  184     DEBUG(
"Input: " << *input << endl);
 
  189       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  193     const TRegexp regexp(input->getObjectName());
 
  195     TIter iter(dir->GetListOfKeys());
 
  197     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  199       const TString tag(key->GetName());
 
  201       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  205       if (tag.Contains(regexp)) {
 
  207         if        (title == JName_t) {
 
  208           title = key->GetName();
 
  209         } 
else if (title == JTitle_t) {
 
  210           title = key->GetTitle();
 
  213         JRootObject object(key->ReadObj());
 
  226           line.SetLineColor(marker.GetMarkerColor());
 
  232           TProfile& 
h1 = 
dynamic_cast<TProfile&
>(*object);
 
  234           object = h1.ProjectionX();
 
  240           TH2& h2 = 
dynamic_cast<TH2&
>(*object);
 
  246                                       h2.GetYaxis()->FindBin(
Z.getLowerLimit()),
 
  247                                       h2.GetYaxis()->FindBin(
Z.getUpperLimit()) - 1);
 
  251                                       h2.GetYaxis()->GetNbins());
 
  257                                       h2.GetXaxis()->FindBin(
Z.getLowerLimit()),
 
  258                                       h2.GetXaxis()->FindBin(
Z.getUpperLimit()) - 1);
 
  262                                       h2.GetXaxis()->GetNbins());
 
  266             ERROR(
"For 2D histograms, use option option -P for projections or use JPlot2D" << endl);
 
  275           TH3& h3 = 
dynamic_cast<TH3&
>(*object);
 
  291             ERROR(
"For 3D histograms, use option option -P for projections or use JPlot2D -P <projection>" << endl);
 
  301           if (dynamic_cast<TMarker*>(
object.
get()) == NULL) {
 
  302             dynamic_cast<TAttMarker&
>(*object) = marker; 
 
  307           if (dynamic_cast<TLine*>(
object.
get())   == NULL) {
 
  308             dynamic_cast<TAttLine&
>  (*object) = line;
 
  317             TAttFill& fill = 
dynamic_cast<TAttFill&
>(*object);
 
  319             fill.SetFillColor(marker.GetMarkerColor()); 
 
  330             TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  332             for (
int i = 1; i <= h1.GetNbinsX(); ++i) {
 
  333               h1.SetBinError(i, 0.0);
 
  340             TGraphErrors& 
g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  342             for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  354           TH1& h1 = 
dynamic_cast<TH1&
>(*object);
 
  356           h1.SetStats(stats != -1);
 
  358           xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  359           xmax = max(xmax, h1.GetXaxis()->GetXmax());       
 
  360           ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  361           ymax = max(ymax, h1.GetMaximum());
 
  367           TGraph& g1 = 
dynamic_cast<TGraph&
>(*object);
 
  369           for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  371             xmin = min(xmin, g1.GetX()[i]);
 
  372             xmax = max(xmax, g1.GetX()[i]);
 
  374             if (!logy || g1.GetY()[i] > 0.0) {
 
  375               ymin = min(ymin, g1.GetY()[i]);
 
  376               ymax = max(ymax, g1.GetY()[i]);
 
  384           TGraphErrors& g1 = 
dynamic_cast<TGraphErrors&
>(*object);
 
  386           for (Int_t i = 0; i != g1.GetN(); ++i) {
 
  387             if (!logy || g1.GetY()[i] - g1.GetEY()[i] > 0.0) { ymin = min(ymin, g1.GetY()[i] - g1.GetEY()[i]); }
 
  388             if (!logy || g1.GetY()[i] + g1.GetEY()[i] > 0.0) { ymax = max(ymax, g1.GetY()[i] + g1.GetEY()[i]); }
 
  395           TMultiGraph& m1 = 
dynamic_cast<TMultiGraph&
>(*object);
 
  397           for (TIter i1(m1.GetListOfGraphs()); TGraph* g1 = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  399             for (Int_t i = 0; i != g1->GetN(); ++i) {
 
  401               xmin = min(xmin, g1->GetX()[i]);
 
  402               xmax = max(xmax, g1->GetX()[i]);
 
  404               if (!logy || g1->GetY()[i] > 0.0) {
 
  405                 ymin = min(ymin, g1->GetY()[i]);
 
  406                 ymax = max(ymax, g1->GetY()[i]);
 
  415           TF2& f2 = 
dynamic_cast<TF2&
>(*object);
 
  418           TString formula = f2.GetExpFormula();
 
  419           TString _z_     = TString::Format(
"%f", 0.5 * (
Z.getLowerLimit() + 
Z.getUpperLimit()));
 
  426           f2.GetRange(__xmin, __ymin, __xmax, __ymax);
 
  430             formula.ReplaceAll(
"y", _z_);
 
  434             f1->SetRange(__xmin, __xmax);
 
  438             formula.ReplaceAll(
"x", _z_);
 
  439             formula.ReplaceAll(
"y", 
"x");
 
  443             f1->SetRange(__ymin, __ymax);
 
  447             ERROR(
"For 2D functions, use option option -P for projections or use JPlot2D" << endl);
 
  452           DEBUG(
"TF1: " << f1->GetExpFormula() << endl);
 
  454           f1->SetParameters(f2.GetParameters());
 
  462           TF1& f1 = 
dynamic_cast<TF1&
>(*object);
 
  467           f1.GetRange(__xmin, __xmax);
 
  469           xmin = min(xmin, __xmin);
 
  470           xmax = max(xmax, __xmax);
 
  471           ymin = min(ymin, f1.GetMinimum());
 
  472           ymax = max(ymax, f1.GetMaximum());
 
  478           THStack& hs = 
dynamic_cast<THStack&
>(*object);
 
  480           NOTICE(
"THStack" << endl);
 
  482           TIterator* 
iterator = hs.GetHists()->MakeIterator();
 
  484           for (
size_t index = 1; 
TObject* i = iterator->Next(); ++index) {
 
  486             TH1& h1 = 
dynamic_cast<TH1&
>(*i);
 
  488             NOTICE(
"TH1[" << index << 
"] " << h1.GetName() << endl);
 
  490             xmin = min(xmin, h1.GetXaxis()->GetXmin());
 
  491             xmax = max(xmax, h1.GetXaxis()->GetXmax());
 
  493             ymin = min(ymin, logy ? h1.GetMinimum(0.0) : h1.GetMinimum());
 
  494             ymax = max(ymax, h1.GetMaximum());
 
  497             h1.SetLineColor(kBlack);
 
  506           TLine& h1 = 
dynamic_cast<TLine&
>(*object);
 
  508           xmin = min(xmin, h1.GetX1());
 
  509           xmax = max(xmax, h1.GetX2());
 
  510           ymin = min(ymin, h1.GetY1());
 
  511           ymax = max(ymax, h1.GetY2());
 
  517         for (TString buffer[] = { 
object.getLabel(), input->getFilename().c_str(), 
"" }, *i = buffer; *i != 
""; ++i) {
 
  519           *i = (*i)(TRegexp(
"\\[.*\\]"));
 
  521           DEBUG(
"Label: <" << *i << 
">" << endl); 
 
  523           if (i->Length() > 2) {
 
  524             object.setLabel((*i)(1, i->Length() - 2));
 
  528         DEBUG(
"Add object: " << tag << 
" with label " << 
object.
getLabel() << endl);
 
  531           master = 
dynamic_cast<TH1*
>(
object.get());
 
  534         listOfObjects.push_back(
object);
 
  539   if (listOfObjects.empty()) {
 
  540     ERROR(
"Nothing to draw." << endl);
 
  549     TH1*         h1 = 
dynamic_cast<TH1*
>        (i->get());
 
  550     TGraph*      g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  551     TMultiGraph* m1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  552     TAttLine*    ls = 
dynamic_cast<TAttLine*
>   (i->get());
 
  555     TIterator*   iterator = NULL;
 
  559       iterator = h1->GetListOfFunctions()->MakeIterator();
 
  561     } 
else if (g1 != NULL) {
 
  563       iterator = g1->GetListOfFunctions()->MakeIterator();
 
  565     } 
else if (m1 != NULL) {
 
  567       for (TIter i1(m1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  568         for (TIter i2(gi->GetListOfFunctions()); TF1* fi = 
dynamic_cast<TF1*
>(i2()); ) {
 
  573       iterator = list.MakeIterator();
 
  576     if (iterator != NULL) {
 
  578       Double_t x1[] = { numeric_limits<Double_t>::max(),    numeric_limits<Double_t>::max() };
 
  579       Double_t x2[] = { numeric_limits<Double_t>::lowest(), numeric_limits<Double_t>::lowest() };
 
  581       for (
int nf = 0, ns = 0, nc = 1; TF1* f1 = (TF1*) iterator->Next(); ++nf) {
 
  583         f1->GetRange(x1[1], x2[1]);
 
  588         if (listOfObjects.size() == 1) {
 
  590           if      (x1[0] == x1[1] && 
 
  603           f1->SetLineColor(ls->GetLineColor());
 
  615         f1->GetRange(__xmin, __xmax);
 
  617         ymin = min(ymin, f1->GetMinimum(__xmin, __xmax));
 
  618         ymax = max(ymax, f1->GetMaximum(__xmin, __xmax));
 
  625   if (
X != JRange_t()) { 
 
  626     xmin = 
X.getLowerLimit();
 
  627     xmax = 
X.getUpperLimit();
 
  630   if (
Y != JRange_t()) {
 
  631     ymin = 
Y.getLowerLimit();
 
  632     ymax = 
Y.getUpperLimit();
 
  639   if (!listOfObjects.empty()) {
 
  641     if (
master == NULL || 
master->GetXaxis()->GetXmin() > xmin  || 
master->GetXaxis()->GetXmax() < xmax) {
 
  643       if        (
X != JRange_t()) {
 
  645         master = 
new TH1D(
"__H__", NULL, 100, 
X.getLowerLimit(), 
X.getUpperLimit());
 
  649       } 
else if (xmin < xmax) {
 
  651         master = 
new TH1D(
"__H__", NULL, 100, xmin, xmax);
 
  660     TText* p = 
new TText(0.5, 0.5, 
MAKE_CSTRING(
"No data"));
 
  668     if (logx) { gPad->SetLogx(); }
 
  669     if (logy) { gPad->SetLogy(); }
 
  671     master->GetXaxis()->SetRangeUser(xmin, xmax);
 
  677     master->SetTitle(title.c_str());
 
  682     if (xLabel != 
"") { 
master->GetXaxis()->SetTitle(xLabel.c_str()); 
master->GetXaxis()->CenterTitle(
true); }
 
  683     if (yLabel != 
"") { 
master->GetYaxis()->SetTitle(yLabel.c_str()); 
master->GetYaxis()->CenterTitle(
true); }
 
  685     master->GetXaxis()->SetMoreLogLabels((logx == 1 && log10(xmax/xmin) < 2) ||
 
  686                                          (logx >  1 &&      (xmax-xmin) < 2));
 
  688     master->GetYaxis()->SetMoreLogLabels( logy      && log10(ymax/ymin) < 2);
 
  689     master->GetYaxis()->SetNoExponent   ( logy      && log10(ymax/ymin) < 2);
 
  691     if (Ndivisions.first != 
"") {
 
  692       master->SetNdivisions(Ndivisions.second, Ndivisions.first.c_str());
 
  695     if (xTimeFormat != 
"") {
 
  697       master->GetXaxis()->SetTimeDisplay(1);
 
  699       if        (xTimeFormat == 
"utc") {
 
  700         master->GetXaxis()->SetTimeFormat(
"#splitline{}{#splitline{%d-%m-%y}{ %H:%M}}");
 
  701         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  702       } 
else if (xTimeFormat == 
"UTC") {
 
  703         master->GetXaxis()->SetTimeFormat(
"%d-%m-%y");
 
  704         master->GetXaxis()->SetTimeOffset(0.0, 
"gmt");
 
  706         master->GetXaxis()->SetTimeFormat(xTimeFormat.c_str());
 
  710     master->Draw(option.c_str());
 
  715       if (dynamic_cast<TH1*>(i->get()) != 
master) {
 
  724   if (grid.count(
'x') || grid.count(
'X')) { gPad->SetGridx(); }
 
  725   if (grid.count(
'y') || grid.count(
'Y')) { gPad->SetGridy(); }
 
  728     gStyle->SetOptStat(stats);
 
  730     gStyle->SetOptFit(kFALSE);
 
  735     DEBUG(
"Draw " << (*i)->GetName() << 
' ' << (*i)->GetTitle() << endl);
 
  737     string buffer(option);
 
  745     TF1*         f1 = 
dynamic_cast<TF1*
>        (i->get());
 
  746     TGraph*      g1 = 
dynamic_cast<TGraph*
>     (i->get());
 
  747     TMultiGraph* q1 = 
dynamic_cast<TMultiGraph*
>(i->get());
 
  754       if (g1->GetN() > 1 && drawLine)
 
  762       for (TIter i1(q1->GetListOfGraphs()); TGraph* gi = 
dynamic_cast<TGraph*
>(i1()); ) {
 
  764         string zbuf = buffer;
 
  766         if (gi->GetN() > 1 && drawLine)
 
  771         gi->Draw(zbuf.c_str());
 
  776       (*i).Draw(buffer.c_str());
 
  784     Ssiz_t height = listOfObjects.size();
 
  788       width = max(width, i->getLabel().Length());
 
  791     TLegend* lg = 
getLegend(width, height, legend);
 
  794       lg->AddEntry(*i, 
" " + i->getLabel(), 
isTAttLine(*i) ? 
"L" : 
"LPF"); 
 
  810   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 ))
 
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()). 
 
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. 
 
T & getInstance(const T &object)
Get static instance from temporary object. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
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. 
 
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.