Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions | Variables
JGIZMO Namespace Reference

Auxiliary applications for use of ROOT and more. More...

Classes

struct  JOpera
 Auxiliary data structure for JOpera1D.cc and JOpera2D.cc applications. More...
 
class  JRootObject
 Auxiliary data structure for TObject with a user defined label. More...
 
class  JRootObjectID
 Auxiliary class to handle file name, ROOT directory and object name. More...
 

Functions

TFile * getFile (const std::string &file_name, const std::string &option="exist")
 Get TFile pointer corresponding to give file name. More...
 
TDirectory * getDirectory (const JRootObjectID &id)
 Get TDirectory pointer. More...
 
TObjectgetObject (const JRootObjectID &id)
 Get first TObject with given identifier. More...
 
bool isTAttLine (const TObject *object)
 Get drawing option of TH1. More...
 
Double_t getResult (const TString &text, TObject *object=NULL)
 Get result of given textual formula. More...
 
Double_t getResult (const std::string &text, TObject *object=NULL)
 Get result of given textual formula. More...
 
int getParameter (const std::string &text)
 Get parameter number from text string. More...
 
Double_t getValue (const std::string &text, TObject *object=NULL)
 Get parameter value from text string. More...
 
void setLogarithmic (TAxis *axis)
 Make histogram axis logarithmic (e.g. after filling with log10()). More...
 
TString getLogarithmic (const TString &formula, const char parameter)
 Make given parameter in formula logarithmic (e.g. after filling with log10()). More...
 
void copy (const TF1 &from, TF1 &to)
 Copy function parameters. More...
 
void copy (const TF2 &from, TF2 &to)
 Copy function parameters. More...
 
void setLogarithmicX (TF1 *f1)
 Make parameter x of function logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicX (TF2 *f2)
 Make parameter x of function logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicY (TF2 *f2)
 Make parameter y of function logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicX (TH1 *h1)
 Make X-axis and associated functions of given histogram logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicX (TH2 *h2)
 Make X-axis and associated functions of given histogram logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicY (TH2 *h2)
 Make Y-axis and associated functions of given histogram logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicX (TGraph *g1)
 Make parameter x of graph logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicX (TGraph2D *g2)
 Make parameter x of graph logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicY (TGraph2D *g2)
 Make parameter y of graph logarithmic (e.g. after filling with log10()). More...
 
void setLogarithmicX (TMultiGraph *m1)
 Make parameter x of multi graph logarithmic (e.g. after filling with log10()). More...
 
void convertToPDF (TH1 &h1, const std::string &option="NW", const double factor=1.0)
 Convert 1D histogram to PDF. More...
 
void convertToPDF (TH2 &h2, const std::string &option="NXYW", const double factor=1.0)
 Convert 2D histogram to PDF. More...
 
void setLimits (TGraph &g1)
 Set limits of TGraph. More...
 
void setLimits (TGraph2D &g2)
 Set limits of TGraph2D. More...
 
void setRange (double &xmin, double &xmax, const bool logx)
 Set axis range. More...
 
void setAxisLabels (TAxis *axis, const JModuleAddressMap &memo)
 Set axis with PMT address labels. More...
 
void setAxisLabels (TH1 &h1, const std::string axis, const JModuleAddressMap &memo)
 Set axis labels with PMT addresses. More...
 

Variables

static const char *const TIMESTAMP = "#splitline{}{#splitline{%d:%m:%y}{ %H:%M}}%F1970-01-01 00:00:00"
 Time stamp of earliest UTC time. More...
 
static const char LABEL_TERMINATOR = '&'
 label terminator More...
 

Detailed Description

Auxiliary applications for use of ROOT and more.

Author
mdejong

Function Documentation

TFile* JGIZMO::getFile ( const std::string &  file_name,
const std::string &  option = "exist" 
)
inline

Get TFile pointer corresponding to give file name.

The TFile pointer of an already opened file is recovered, else a new file is opened.
Note that the closure of the opened files should be done by the caller of this method.

Parameters
file_namefile name
optionTFile::Open option
Returns
pointer to TFile

Definition at line 96 of file JGizmoToolkit.hh.

97  {
98  using namespace std;
99 
100  gErrorIgnoreLevel = kError;
101 
102  static map<string, TFile*> zmap;
103 
104  map<string, TFile*>::iterator i = zmap.find(file_name);
105 
106  if (i == zmap.end() || i->second == NULL || !i->second->IsOpen()) {
107 
108  TFile* file = TFile::Open(file_name.c_str(), option.c_str());
109 
110  zmap[file_name] = file;
111 
112  return file;
113 
114  } else {
115 
116  return i->second;
117  }
118  }
then usage $script< string identifier >< detectorfile > input file(toashort file)+" "\nNote that the input files and toashort files should be one-to-one related." fi if (( $
TDirectory* JGIZMO::getDirectory ( const JRootObjectID id)
inline

Get TDirectory pointer.

The TFile pointer of an already opened file is recovered, else a new file is opened.

Parameters
ididentifier
Returns
pointer to TDirectory

Definition at line 129 of file JGizmoToolkit.hh.

130  {
131  TFile* in = getFile(id.getFilename().c_str(), "exist");
132 
133  if (in == NULL || !in->IsOpen()) {
134  return NULL;
135  }
136 
137  if (id.getDirectory() != "")
138  return in->GetDirectory(id.getDirectory());
139  else
140  return in;
141  }
TFile * getFile(const std::string &file_name, const std::string &option="exist")
Get TFile pointer corresponding to give file name.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:88
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
TObject* JGIZMO::getObject ( const JRootObjectID id)
inline

Get first TObject with given identifier.

Parameters
ididentifier
Returns
pointer to TObject (or NULL)

Definition at line 150 of file JGizmoToolkit.hh.

151  {
152  TDirectory* dir = getDirectory(id);
153 
154  if (dir != NULL) {
155 
156  const TRegexp regexp(id.getObjectName());
157 
158  TIter iter(dir->GetListOfKeys());
159 
160  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
161 
162  const TString tag(key->GetName());
163 
164  // option match
165 
166  if (tag.Index(regexp) != -1) {
167  return key->ReadObj();
168  }
169  }
170  }
171 
172  return NULL;
173  }
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
bool JGIZMO::isTAttLine ( const TObject object)
inline

Get drawing option of TH1.

Parameters
objectpointer to TObject
Returns
true if TH1 looks like a line; else false

Definition at line 182 of file JGizmoToolkit.hh.

183  {
184  const TH1* h1 = dynamic_cast<const TH1*>(object);
185 
186  if (h1 != NULL) {
187 
188  if (h1->GetSumw2N()) {
189 
190  for (Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
191 
192  if (h1->GetBinError(i) != 0.0) {
193  return false;
194  }
195  }
196  }
197 
198  return true;
199 
200  } else {
201 
202  return false;
203  }
204  }
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Double_t JGIZMO::getResult ( const TString &  text,
TObject object = NULL 
)
inline

Get result of given textual formula.

The formula may contain names of member methods of the object pointed to.
These methods could have arguments and the return type should be compatible with Double_t.
Example:

        getResult("1.0/GetEntries", TH1*);
Parameters
texttext
objectpointer to object
Returns
value

Definition at line 221 of file JGizmoToolkit.hh.

222  {
223  TString buffer(text);
224 
225  if (object != NULL) {
226 
227  TClass* p = TClass::GetClass(object->ClassName());
228 
229  if (p != NULL) {
230 
231  for ( ; ; ) {
232 
233  TIterator* iter = p->GetListOfAllPublicMethods()->MakeIterator();
234  TMethod* method = NULL;
235 
236  for (TMethod* p; (p = (TMethod*) iter->Next()) != NULL; ) {
237  if (buffer.Index(p->GetName()) != -1) {
238  if (method == NULL || strlen(p->GetName()) > strlen(method->GetName())) {
239  method = p;
240  }
241  }
242  }
243 
244  if (method == NULL) {
245  break;
246  }
247 
248  for (Ssiz_t index; (index = buffer.Index(method->GetName())) != -1; ) {
249 
250  const TRegexp fp(" *([^)]*)"); // function call
251 
252  Ssiz_t len;
253  Ssiz_t pos = buffer.Index(fp, &len, index);
254 
255  Double_t value;
256 
257  if (pos == -1 || pos != index + (Ssiz_t) strlen(method->GetName())) {
258 
259  TMethodCall(p, method->GetName(), NULL).Execute(object, value);
260 
261  len = strlen(method->GetName());
262 
263  } else {
264 
265  TMethodCall(p, method->GetName(), NULL).Execute(object, TString(buffer(pos + 1, len - 2)), value);
266 
267  len += strlen(method->GetName());
268  }
269 
270  buffer.Replace(index, len, TString::Format("%15.5e", value));
271  }
272  }
273  }
274  }
275 
276  return TFormula("/tmp", buffer.Data()).Eval(0.0);
277  }
char text[TEXT_SIZE]
Definition: elog.cc:72
Double_t JGIZMO::getResult ( const std::string &  text,
TObject object = NULL 
)
inline

Get result of given textual formula.

The formula may contain names of member methods of the object pointed to.
These methods could have arguments and the return type should be compatible with Double_t.
Example:

        getResult("1.0/GetEntries", TH1*);
Parameters
texttext
objectpointer to object
Returns
value

Definition at line 294 of file JGizmoToolkit.hh.

295  {
296  return getResult(TString(text.c_str()), object);
297  }
char text[TEXT_SIZE]
Definition: elog.cc:72
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
int JGIZMO::getParameter ( const std::string &  text)
inline

Get parameter number from text string.

The number corresponds to the value [0-9]* in the expression "p[0-9]* = ..".

Parameters
texttext
Returns
parameter number

Definition at line 308 of file JGizmoToolkit.hh.

309  {
310  const char* regexp("p[0-9]* *=");
311 
312  TString buffer(text.c_str());
313 
314  buffer = buffer(TRegexp(regexp));
315  buffer = buffer(1, buffer.Length() - 2);
316 
317  if (!buffer.IsDigit()) {
318  THROW(JParseError, "Text is not a number " << text << ' ' << regexp);
319  }
320 
321  return buffer.Atoi();
322  }
char text[TEXT_SIZE]
Definition: elog.cc:72
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
Double_t JGIZMO::getValue ( const std::string &  text,
TObject object = NULL 
)
inline

Get parameter value from text string.

The formula may contain names of member methods of the object pointed to.
These methods could have arguments and the return type should be compatible with Double_t.
Example:

        getValue("p[..] = 2*GetMaximum", TH1*);
Parameters
texttext
objectpointer to object
Returns
value

Definition at line 339 of file JGizmoToolkit.hh.

340  {
341  const char* regexp("=.*");
342 
343  TString buffer(text.c_str());
344 
345  buffer = buffer(TRegexp(regexp));
346  buffer = buffer(1, buffer.Length() - 1);
347 
348  return getResult(std::string(buffer), object);
349  }
char text[TEXT_SIZE]
Definition: elog.cc:72
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
void JGIZMO::setLogarithmic ( TAxis *  axis)
inline

Make histogram axis logarithmic (e.g. after filling with log10()).

Parameters
axisaxis

Definition at line 357 of file JGizmoToolkit.hh.

358  {
359  if (axis != NULL) {
360 
361  const Int_t first = axis->GetFirst();
362  const Int_t last = axis->GetLast();
363 
364  const Double_t xmin = axis->GetBinLowEdge(first);
365  const Double_t xmax = axis->GetBinLowEdge(last) + axis->GetBinWidth(last);
366 
367  const Int_t N = axis->GetNbins();
368  Double_t buffer[N+1];
369 
370  buffer[0] = TMath::Power(10.0, axis->GetBinLowEdge(1));
371 
372  for (Int_t i = 1; i <= N; ++i) {
373  buffer[i] = TMath::Power(10.0, axis->GetBinLowEdge(i) + axis->GetBinWidth(i));
374  }
375 
376  axis->Set(N, buffer);
377 
378  if (axis->TestBit(TAxis::kAxisRange)) {
379  axis->SetRangeUser(TMath::Power(10.0, xmin), TMath::Power(10.0, xmax));
380  }
381  }
382  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
TString JGIZMO::getLogarithmic ( const TString &  formula,
const char  parameter 
)
inline

Make given parameter in formula logarithmic (e.g. after filling with log10()).

Parameters
formulaformula
parameterparameter
Returns
formula

Definition at line 392 of file JGizmoToolkit.hh.

393  {
394  const TRegexp regexp[] = {
395  TString("^") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter at start of line
396  TString("[^a-zA-Z_]") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter in middle of line
397  TString("[^a-zA-Z_]") + TString(parameter) + TString("$") // parameter at end of line
398  };
399 
400  const TString replacement = TString("log10(") + TString(parameter) + TString(")");
401 
402  TString buffer(formula);
403 
404  if (buffer.Length() == 1 && buffer[0] == parameter) {
405 
406  buffer = replacement;
407 
408  } else {
409 
410  for (Ssiz_t pos = 0, i; pos < buffer.Length(); pos += replacement.Length()) {
411  if ((i = buffer.Index(regexp[0], pos)) != -1) { buffer.Replace((pos = i + 0), 1, replacement); }
412  else if ((i = buffer.Index(regexp[1], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
413  else if ((i = buffer.Index(regexp[2], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
414  else { break; }
415  }
416  }
417  return buffer;
418  }
void JGIZMO::copy ( const TF1 &  from,
TF1 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 427 of file JGizmoToolkit.hh.

428  {
429  static_cast<TAttLine&> (to) = static_cast<const TAttLine&> (from);
430  static_cast<TAttFill&> (to) = static_cast<const TAttFill&> (from);
431  static_cast<TAttMarker&>(to) = static_cast<const TAttMarker&>(from);
432 
433  to.SetParameters(from.GetParameters());
434 
435  to.SetNpx(from.GetNpx());
436  }
void JGIZMO::copy ( const TF2 &  from,
TF2 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 445 of file JGizmoToolkit.hh.

446  {
447  copy(static_cast<const TF1&>(from), static_cast<TF1&>(to));
448 
449  to.SetNpy(from.GetNpy());
450  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
void JGIZMO::setLogarithmicX ( TF1 *  f1)
inline

Make parameter x of function logarithmic (e.g. after filling with log10()).

Parameters
f1function

Definition at line 458 of file JGizmoToolkit.hh.

459  {
460  if (f1 != NULL) {
461 
462  TF1 fn(f1->GetName(), getLogarithmic(f1->GetExpFormula(), 'x'));
463 
464  copy(*f1, fn);
465 
466  fn.SetRange(f1->GetXmin(),
467  f1->GetXmax());
468 
469  *f1 = fn;
470 
471  f1->SetRange(TMath::Power(10.0,f1->GetXmin()),
472  TMath::Power(10.0,f1->GetXmax()));
473  }
474  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TF2 *  f2)
inline

Make parameter x of function logarithmic (e.g. after filling with log10()).

Parameters
f2function

Definition at line 482 of file JGizmoToolkit.hh.

483  {
484  if (f2 != NULL) {
485 
486  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'x'));
487 
488  copy(*f2, fn);
489 
490  fn.SetRange(f2->GetXmin(),
491  f2->GetYmin(),
492  f2->GetXmax(),
493  f2->GetYmax());
494 
495  *f2 = fn;
496 
497  f2->SetRange(TMath::Power(10.0,f2->GetXmin()),
498  f2->GetYmin(),
499  TMath::Power(10.0,f2->GetXmax()),
500  f2->GetYmax());
501  }
502  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicY ( TF2 *  f2)
inline

Make parameter y of function logarithmic (e.g. after filling with log10()).

Parameters
f2function

Definition at line 510 of file JGizmoToolkit.hh.

511  {
512  if (f2 != NULL) {
513 
514  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'y'));
515 
516  copy(*f2, fn);
517 
518  fn.SetRange(f2->GetXmin(),
519  f2->GetYmin(),
520  f2->GetXmax(),
521  f2->GetYmax());
522 
523  *f2 = fn;
524 
525  f2->SetRange(f2->GetXmin(),
526  TMath::Power(10.0,f2->GetYmin()),
527  f2->GetXmax(),
528  TMath::Power(10.0,f2->GetYmax()));
529  }
530  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TH1 *  h1)
inline

Make X-axis and associated functions of given histogram logarithmic (e.g. after filling with log10()).

Parameters
h1histogram

Definition at line 538 of file JGizmoToolkit.hh.

539  {
540  if (h1 != NULL) {
541 
542  for (TIter iter(h1->GetListOfFunctions()); TF1* f1 = dynamic_cast<TF1*>(iter.Next()); ) {
543  setLogarithmicX(f1);
544  }
545 
546  setLogarithmic(h1->GetXaxis());
547  }
548  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TH2 *  h2)
inline

Make X-axis and associated functions of given histogram logarithmic (e.g. after filling with log10()).

Parameters
h2histogram

Definition at line 556 of file JGizmoToolkit.hh.

557  {
558  using namespace std;
559 
560  if (h2 != NULL) {
561 
562  for (TIter iter(h2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
563  setLogarithmicX(f2);
564  }
565 
566  setLogarithmic(h2->GetXaxis());
567  }
568  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicY ( TH2 *  h2)
inline

Make Y-axis and associated functions of given histogram logarithmic (e.g. after filling with log10()).

Parameters
h2histogram

Definition at line 576 of file JGizmoToolkit.hh.

577  {
578  if (h2 != NULL) {
579 
580  for (TIter iter(h2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
581  setLogarithmicY(f2);
582  }
583 
584  setLogarithmic(h2->GetYaxis());
585  }
586  }
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after filling with log10()).
void setLogarithmicY(TF2 *f2)
Make parameter y of function logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TGraph *  g1)
inline

Make parameter x of graph logarithmic (e.g. after filling with log10()).

Parameters
g1graph

Definition at line 594 of file JGizmoToolkit.hh.

595  {
596  if (g1 != NULL) {
597 
598  for (TIter iter(g1->GetListOfFunctions()); TF1* f1 = dynamic_cast<TF1*>(iter.Next()); ) {
599  setLogarithmicX(f1);
600  }
601 
602  for (Int_t i = 0; i != g1->GetN(); ++i) {
603  g1->GetX()[i] = pow(10.0, g1->GetX()[i]);
604  }
605  }
606  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JGIZMO::setLogarithmicX ( TGraph2D *  g2)
inline

Make parameter x of graph logarithmic (e.g. after filling with log10()).

Parameters
g2graph

Definition at line 614 of file JGizmoToolkit.hh.

615  {
616  if (g2 != NULL) {
617 
618  for (TIter iter(g2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
619  setLogarithmicX(f2);
620  }
621 
622  for (Int_t i = 0; i != g2->GetN(); ++i) {
623  g2->GetX()[i] = pow(10.0, g2->GetX()[i]);
624  }
625  }
626  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicY ( TGraph2D *  g2)
inline

Make parameter y of graph logarithmic (e.g. after filling with log10()).

Parameters
g2graph

Definition at line 634 of file JGizmoToolkit.hh.

635  {
636  if (g2 != NULL) {
637 
638  for (TIter iter(g2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
639  setLogarithmicY(f2);
640  }
641 
642  for (Int_t i = 0; i != g2->GetN(); ++i) {
643  g2->GetY()[i] = pow(10.0, g2->GetY()[i]);
644  }
645  }
646  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void setLogarithmicY(TF2 *f2)
Make parameter y of function logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TMultiGraph *  m1)
inline

Make parameter x of multi graph logarithmic (e.g. after filling with log10()).

Parameters
m1multi graph

Definition at line 654 of file JGizmoToolkit.hh.

655  {
656  if (m1 != NULL) {
657 
658  for (TIter i1(m1->GetListOfGraphs()); TGraph* g1 = dynamic_cast<TGraph*>(i1()); ) {
659  setLogarithmicX(g1);
660  }
661  }
662  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JGIZMO::convertToPDF ( TH1 &  h1,
const std::string &  option = "NW",
const double  factor = 1.0 
)
inline

Convert 1D histogram to PDF.

Possible options are:

  • N normalise to histogram contents;
  • W divide by bin width;
  • E convert also bin errors.
Parameters
h1histogram
optionoption
factorscaling factor

Definition at line 677 of file JGizmoToolkit.hh.

678  {
679  using namespace std;
680 
681  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
682  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
683  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
684 
685  Double_t W = 1.0;
686 
687  if (normalise) {
688 
689  W = 0.0;
690 
691  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
692  W += h1.GetBinContent(i);
693  }
694  }
695 
696  if (W != 0.0) {
697 
698  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
699 
700  const Double_t w = W * (bin_width ? h1.GetXaxis()->GetBinWidth(i) : 1.0);
701 
702  h1.SetBinContent(i, h1.GetBinContent(i) * factor / w);
703 
704  if (use_error) {
705  h1.SetBinError(i, h1.GetBinError(i) * factor / w);
706  }
707  }
708  }
709  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
void JGIZMO::convertToPDF ( TH2 &  h2,
const std::string &  option = "NXYW",
const double  factor = 1.0 
)
inline

Convert 2D histogram to PDF.

Possible options are:

  • N normalise to histogram contents;
  • X convert x-axis to PDF;
  • Y convert y-axis to PDF;
  • W divide by bin width;
  • E convert also bin errors.
Parameters
h2histogram
optionoption
factorscaling factor

Definition at line 726 of file JGizmoToolkit.hh.

727  {
728  using namespace std;
729 
730  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
731  const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
732  const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
733  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
734  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
735 
736  Double_t W = 1.0;
737 
738  if (X && Y) {
739 
740  if (normalise) {
741 
742  W = 0.0;
743 
744  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
745  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
746  W += h2.GetBinContent(ix,iy);
747  }
748  }
749  }
750 
751  if (W != 0.0) {
752 
753  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
754  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
755 
756  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
757 
758  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
759 
760  if (use_error) {
761  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
762  }
763  }
764  }
765  }
766 
767  } else if (X) {
768 
769  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
770 
771  if (normalise) {
772 
773  W = 0.0;
774 
775  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
776  W += h2.GetBinContent(ix,iy);
777  }
778  }
779 
780  if (W != 0.0) {
781 
782  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
783 
784  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
785 
786  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
787 
788  if (use_error) {
789  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
790  }
791  }
792  }
793  }
794 
795  } else if (Y) {
796 
797  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
798 
799  if (normalise) {
800 
801  W = 0.0;
802 
803  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
804  W += h2.GetBinContent(ix,iy);
805  }
806  }
807 
808  if (W != 0.0) {
809 
810  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
811 
812  const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
813 
814  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
815 
816  if (use_error) {
817  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
818  }
819  }
820  }
821  }
822  }
823  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
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
void JGIZMO::setLimits ( TGraph &  g1)
inline

Set limits of TGraph.

Parameters
g1graph

Definition at line 831 of file JGizmoToolkit.hh.

832  {
833  using namespace std;
834 
835  Double_t ymin = numeric_limits<Double_t>::max();
836  Double_t ymax = numeric_limits<Double_t>::lowest();
837 
838  for (Int_t i = 0; i != g1.GetN(); ++i) {
839 
840  const Double_t y = g1.GetY()[i];
841 
842  if (y > ymax) { ymax = y; }
843  if (y < ymin) { ymin = y; }
844  }
845 
846  g1.SetMinimum(ymin);
847  g1.SetMaximum(ymax);
848  }
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JGIZMO::setLimits ( TGraph2D &  g2)
inline

Set limits of TGraph2D.

Parameters
g2graph

Definition at line 856 of file JGizmoToolkit.hh.

857  {
858  using namespace std;
859 
860  Double_t zmin = numeric_limits<Double_t>::max();
861  Double_t zmax = numeric_limits<Double_t>::lowest();
862 
863  for (Int_t i = 0; i != g2.GetN(); ++i) {
864 
865  const Double_t z = g2.GetZ()[i];
866 
867  if (z > zmax) { zmax = z; }
868  if (z < zmin) { zmin = z; }
869  }
870 
871  g2.SetMinimum(zmin);
872  g2.SetMaximum(zmax);
873  }
void JGIZMO::setRange ( double &  xmin,
double &  xmax,
const bool  logx 
)
inline

Set axis range.

Parameters
xminlower limit (I/O)
xmaxupper limit (I/O)
logxlogarithmic

Definition at line 883 of file JGizmoToolkit.hh.

886  {
887  if (logx) {
888  xmin = log(xmin);
889  xmax = log(xmax);
890  }
891 
892  double dx = (xmax - xmin) * 0.1;
893 
894  if (xmin > dx || xmin < 0.0)
895  xmin -= dx;
896  else
897  xmin = 0.0;
898 
899  xmax += dx;
900 
901  if (logx) {
902  xmin = exp(xmin);
903  xmax = exp(xmax);
904  }
905  }
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))*exp(-0.5 *(y-[1])*(y-[1])/([2]*[2]))" JF2 -o $WORKDIR/f2.root -F "$FORMULA" -@ "p0
void JGIZMO::setAxisLabels ( TAxis *  axis,
const JModuleAddressMap &  memo 
)
inline

Set axis with PMT address labels.

This methods sets the labels of the given axis to the sorted values of the PMT ring and position.
It should normally be called before filling of the corresponding histogram.
The filling should then be made with the textual representation of the PMT ring and position (i.e. JDETECTOR::JPMTPhysicalAddress::toString).

Alternatively, the filling can be made with the index of the PMT in the address map of the corresponding module (i.e. JDETECTOR::JModuleAddressMap::getIndex).
In that case, the method can be called before or after filling of the histogram.

Parameters
axisaxis
memomodule address map

Definition at line 922 of file JGizmoToolkit.hh.

923  {
924  using namespace JPP;
925 
926  if (axis->GetNbins() == (int) memo.size()) {
927 
928  for (int i = 0; i != axis->GetNbins(); ++i) {
929 
930  const JPMTPhysicalAddress& address = memo[i];
931 
932  axis->SetBinLabel(i + 1, address.toString().c_str());
933  }
934 
935  } else {
936 
937  THROW(JValueOutOfRange, "Number of bins " << axis->GetNbins() << " != " << memo.size());
938  }
939  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
void JGIZMO::setAxisLabels ( TH1 &  h1,
const std::string  axis,
const JModuleAddressMap &  memo 
)
inline

Set axis labels with PMT addresses.

This methods sets the labels of the given axis to the sorted values of the PMT ring and position.
It should be called after filling of the corresponding histogram.
The filling should have been made with the PMT number (e.g. KM3NETDAQ::JDAQHit::getPMT).

Parameters
h1histogram
axisaxis (x, X, y, Y, z, Z)
memomodule address map

Definition at line 953 of file JGizmoToolkit.hh.

954  {
955  using namespace JPP;
956 
957  TAxis* pax = NULL;
958 
959  if (axis == "x" || axis == "X")
960  pax = h1.GetXaxis();
961  else if (axis == "y" || axis == "Y")
962  pax = h1.GetYaxis();
963  else if (axis == "z" || axis == "Z")
964  pax = h1.GetZaxis();
965  else
966  THROW(JValueOutOfRange, "Invalid axis " << axis);
967 
968  if (pax->GetNbins() == (int) memo.size()) {
969 
970  for (int i = 0; i != pax->GetNbins(); ++i) {
971 
972  const JPMTPhysicalAddress& address = memo.getAddressTranslator(i);
973 
974  pax->SetBinLabel(i + 1, address.toString().c_str());
975  }
976 
977  h1.LabelsOption("a", axis.c_str()); // sort labels
978 
979  } else {
980 
981  THROW(JValueOutOfRange, "Number of bins " << pax->GetNbins() << " != " << memo.size());
982  }
983  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69

Variable Documentation

const char* const JGIZMO::TIMESTAMP = "#splitline{}{#splitline{%d:%m:%y}{ %H:%M}}%F1970-01-01 00:00:00"
static

Time stamp of earliest UTC time.

Definition at line 83 of file JGizmoToolkit.hh.

const char JGIZMO::LABEL_TERMINATOR = '&'
static

label terminator

Definition at line 23 of file JRootObject.hh.