Jpp  16.0.0
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...
 
Double_t getValue (const std::string &text, const int index)
 Get parameter value from text string. More...
 
void setLogarithmic (TAxis *axis)
 Make histogram axis logarithmic (e.g. after using log10()). More...
 
TString getLogarithmic (const TString &formula, const char parameter)
 Make given parameter in formula logarithmic (e.g. after using log10()). More...
 
void copy (const TF1 &from, TF1 &to)
 Copy function parameters. More...
 
void copy (const TF2 &from, TF2 &to)
 Copy function parameters. More...
 
template<class T >
void setLogarithmicX (TList *list)
 Make x-axis of objects in list logarithmic (e.g. after using log10()). More...
 
template<class T >
void setLogarithmicY (TList *list)
 Make y-axis of objects in list logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TF1 *f1)
 Make x-axis of given function logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TF1 *f1)
 Make y-axis of given function logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TF2 *f2)
 Make x-axis of given function logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TF2 *f2)
 Make y-axis of given function logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TH1 *h1)
 Make x-axis and associated functions of given histogram logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TH2 *h2)
 Make x-axis and associated functions of given histogram logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TH2 *h2)
 Make y-axis and associated functions of given histogram logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TGraph *g1)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TGraph *g1)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TGraphErrors *g1)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TGraphErrors *g1)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TGraph2D *g2)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TGraph2D *g2)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TGraph2DErrors *g2)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TGraph2DErrors *g2)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TMultiGraph *gn)
 Make x-axis of given multi-graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TMultiGraph *gn)
 Make y-axis of given multi-graph logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TLine *line)
 Make x-axis of given line logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TLine *line)
 Make y-axis of given line logarithmic (e.g. after using log10()). More...
 
void setLogarithmicX (TEllipse *ellipse)
 Make x-axis of given ellipse logarithmic (e.g. after using log10()). More...
 
void setLogarithmicY (TEllipse *ellipse)
 Make y-axis of given ellipse logarithmic (e.g. after using 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...
 
bool isTObject (const TKey *key)
 Check if given key corresponds to a TObject. 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 102 of file JGizmoToolkit.hh.

103  {
104  using namespace std;
105 
106  gErrorIgnoreLevel = kError;
107 
108  static map<string, TFile*> zmap;
109 
110  map<string, TFile*>::iterator i = zmap.find(file_name);
111 
112  if (i == zmap.end() || i->second == NULL || !i->second->IsOpen()) {
113 
114  TFile* file = TFile::Open(file_name.c_str(), option.c_str());
115 
116  zmap[file_name] = file;
117 
118  return file;
119 
120  } else {
121 
122  return i->second;
123  }
124  }
then set_variable PMT_FILE set_variable DAQ_FILE set_variable OUTPUT_FILE set_variable DETECTOR else fatal Wrong number of arguments fi set_variable RUNBYRUN file
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 135 of file JGizmoToolkit.hh.

136  {
137  TFile* in = getFile(id.getFilename().c_str(), "exist");
138 
139  if (in == NULL || !in->IsOpen()) {
140  return NULL;
141  }
142 
143  if (id.getDirectory() != "")
144  return in->GetDirectory(id.getDirectory());
145  else
146  return in;
147  }
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:42
TObject* JGIZMO::getObject ( const JRootObjectID id)
inline

Get first TObject with given identifier.

Parameters
ididentifier
Returns
pointer to TObject (or NULL)

Definition at line 156 of file JGizmoToolkit.hh.

157  {
158  TDirectory* dir = getDirectory(id);
159 
160  if (dir != NULL) {
161 
162  const TRegexp regexp(id.getObjectName());
163 
164  TIter iter(dir->GetListOfKeys());
165 
166  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
167 
168  const TString tag(key->GetName());
169 
170  // option match
171 
172  if (tag.Index(regexp) != -1) {
173  return key->ReadObj();
174  }
175  }
176  }
177 
178  return NULL;
179  }
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 188 of file JGizmoToolkit.hh.

189  {
190  {
191  const TH1* h1 = dynamic_cast<const TH1*>(object);
192 
193  if (h1 != NULL) {
194 
195  if (h1->GetSumw2N()) {
196  for (Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
197  if (h1->GetBinError(i) != 0.0) {
198  return false;
199  }
200  }
201  }
202  }
203  }
204  {
205  const TGraphErrors* g1 = dynamic_cast<const TGraphErrors*>(object);
206 
207  if (g1 != NULL) {
208 
209  for (Int_t i = 0; i != g1->GetN(); ++i) {
210  if (g1->GetEY()[i] != 0.0) {
211  return false;
212  }
213  }
214 
215  return g1->GetN() > 1;
216  }
217  }
218  {
219  const TGraph* g1 = dynamic_cast<const TGraph*>(object);
220 
221  if (g1 != NULL) {
222  return g1->GetN() > 1;
223  }
224  }
225 
226  return true;
227  }
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
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 should return a value that is compatible with Double_t and could have arguments.
For example:

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

Definition at line 244 of file JGizmoToolkit.hh.

245  {
246  TString buffer(text);
247 
248  if (object != NULL) {
249 
250  TClass* p = TClass::GetClass(object->ClassName());
251 
252  if (p != NULL) {
253 
254  for ( ; ; ) {
255 
256  TIterator* iter = p->GetListOfAllPublicMethods()->MakeIterator();
257  TMethod* method = NULL;
258 
259  for (TMethod* p; (p = (TMethod*) iter->Next()) != NULL; ) {
260  if (buffer.Index(p->GetName()) != -1) {
261  if (method == NULL || strlen(p->GetName()) > strlen(method->GetName())) {
262  method = p;
263  }
264  }
265  }
266 
267  if (method == NULL) {
268  break;
269  }
270 
271  for (Ssiz_t index; (index = buffer.Index(method->GetName())) != -1; ) {
272 
273  const TRegexp fp(" *([^)]*)"); // function call
274 
275  Ssiz_t len;
276  Ssiz_t pos = buffer.Index(fp, &len, index);
277 
278  Double_t value;
279 
280  if (pos == -1 || pos != index + (Ssiz_t) strlen(method->GetName())) {
281 
282  TMethodCall(p, method->GetName(), NULL).Execute(object, value);
283 
284  len = strlen(method->GetName());
285 
286  } else {
287 
288  TMethodCall(p, method->GetName(), NULL).Execute(object, TString(buffer(pos + 1, len - 2)), value);
289 
290  len += strlen(method->GetName());
291  }
292 
293  buffer.Replace(index, len, TString::Format("%15.5e", value));
294  }
295  }
296  }
297  }
298 
299  return TFormula("/tmp", buffer.Data()).Eval(0.0);
300  }
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 should return a value that is compatible with Double_t and could have arguments.
For example:

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

Definition at line 317 of file JGizmoToolkit.hh.

318  {
319  return getResult(TString(text.c_str()), object);
320  }
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 331 of file JGizmoToolkit.hh.

332  {
333  const char* regexp("p[0-9]* *=");
334 
335  TString buffer(text.c_str());
336 
337  buffer = buffer(TRegexp(regexp));
338  buffer = buffer(1, buffer.Length() - 2);
339 
340  if (!buffer.IsDigit()) {
341  THROW(JParseError, "Text is not a number " << text << ' ' << regexp);
342  }
343 
344  return buffer.Atoi();
345  }
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:696
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 should return a value that is compatible with Double_t and could have arguments.
For example:

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

Definition at line 362 of file JGizmoToolkit.hh.

363  {
364  const char* regexp("=.*");
365 
366  TString buffer(text.c_str());
367 
368  buffer = buffer(TRegexp(regexp));
369  buffer = buffer(1, buffer.Length() - 1);
370 
371  return getResult(std::string(buffer), object);
372  }
char text[TEXT_SIZE]
Definition: elog.cc:72
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
Double_t JGIZMO::getValue ( const std::string &  text,
const int  index 
)
inline

Get parameter value from text string.

The formula may contain names of member methods of the object pointed to.
These methods should return a value that is compatible with Double_t and could have arguments.
For example:

        getValue("p[..] = 1.0 2.0 3.0", 1);

will return 2.0.

Parameters
texttext
indexindex
Returns
value

Definition at line 390 of file JGizmoToolkit.hh.

391  {
392  using namespace std;
393 
394  const char* regexp("=.*");
395 
396  TString buffer(text.c_str());
397 
398  buffer = buffer(TRegexp(regexp));
399  buffer = buffer(1, buffer.Length() - 1);
400 
401 
402  istringstream is((std::string(buffer)));
403 
404  Double_t value;
405 
406  for (int i = index; is >> value && i > 0; --i) {}
407 
408  if (is)
409  return value;
410  else
411  THROW(JParseError, "Text des not contain a number at given position " << buffer << ' ' << index);
412  }
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:696
is
Definition: JDAQCHSM.chsm:167
void JGIZMO::setLogarithmic ( TAxis *  axis)
inline

Make histogram axis logarithmic (e.g. after using log10()).

Parameters
axisaxis

Definition at line 420 of file JGizmoToolkit.hh.

421  {
422  if (axis != NULL) {
423 
424  const Int_t first = axis->GetFirst();
425  const Int_t last = axis->GetLast();
426 
427  const Double_t xmin = axis->GetBinLowEdge(first);
428  const Double_t xmax = axis->GetBinLowEdge(last) + axis->GetBinWidth(last);
429 
430  const Int_t N = axis->GetNbins();
431  Double_t buffer[N+1];
432 
433  buffer[0] = TMath::Power(10.0, axis->GetBinLowEdge(1));
434 
435  for (Int_t i = 1; i <= N; ++i) {
436  buffer[i] = TMath::Power(10.0, axis->GetBinLowEdge(i) + axis->GetBinWidth(i));
437  }
438 
439  axis->Set(N, buffer);
440 
441  if (axis->TestBit(TAxis::kAxisRange)) {
442  axis->SetRangeUser(TMath::Power(10.0, xmin), TMath::Power(10.0, xmax));
443  }
444  }
445  }
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
TString JGIZMO::getLogarithmic ( const TString &  formula,
const char  parameter 
)
inline

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

Parameters
formulaformula
parameterparameter
Returns
formula

Definition at line 455 of file JGizmoToolkit.hh.

456  {
457  const TRegexp regexp[] = {
458  TString("^") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter at start of line
459  TString("[^a-zA-Z_]") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter in middle of line
460  TString("[^a-zA-Z_]") + TString(parameter) + TString("$") // parameter at end of line
461  };
462 
463  const TString replacement = TString("log10(") + TString(parameter) + TString(")");
464 
465  TString buffer(formula);
466 
467  if (buffer.Length() == 1 && buffer[0] == parameter) {
468 
469  buffer = replacement;
470 
471  } else {
472 
473  for (Ssiz_t pos = 0, i; pos < buffer.Length(); pos += replacement.Length()) {
474  if ((i = buffer.Index(regexp[0], pos)) != -1) { buffer.Replace((pos = i + 0), 1, replacement); }
475  else if ((i = buffer.Index(regexp[1], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
476  else if ((i = buffer.Index(regexp[2], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
477  else { break; }
478  }
479  }
480 
481  return buffer;
482  }
void JGIZMO::copy ( const TF1 &  from,
TF1 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 491 of file JGizmoToolkit.hh.

492  {
493  static_cast<TAttLine&> (to) = static_cast<const TAttLine&> (from);
494  static_cast<TAttFill&> (to) = static_cast<const TAttFill&> (from);
495  static_cast<TAttMarker&>(to) = static_cast<const TAttMarker&>(from);
496 
497  to.SetParameters(from.GetParameters());
498 
499  to.SetNpx(from.GetNpx());
500  }
void JGIZMO::copy ( const TF2 &  from,
TF2 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 509 of file JGizmoToolkit.hh.

510  {
511  copy(static_cast<const TF1&>(from), static_cast<TF1&>(to));
512 
513  to.SetNpy(from.GetNpy());
514  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
template<class T >
void JGIZMO::setLogarithmicX ( TList *  list)
inline

Make x-axis of objects in list logarithmic (e.g. after using log10()).

Parameters
listlist

Definition at line 917 of file JGizmoToolkit.hh.

918  {
919  for (TIter i(list); T* p = dynamic_cast<T*>(i.Next()); ) {
920  setLogarithmicX(p);
921  }
922  }
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()).
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class T >
void JGIZMO::setLogarithmicY ( TList *  list)
inline

Make y-axis of objects in list logarithmic (e.g. after using log10()).

Parameters
listlist

Definition at line 931 of file JGizmoToolkit.hh.

932  {
933  for (TIter i(list); T* p = dynamic_cast<T*>(i.Next()); ) {
934  setLogarithmicY(p);
935  }
936  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
void setLogarithmicY(TList *list)
Make y-axis of objects in list logarithmic (e.g. after using log10()).
void JGIZMO::setLogarithmicX ( TF1 *  f1)
inline

Make x-axis of given function logarithmic (e.g. after using log10()).

Parameters
f1function

Definition at line 540 of file JGizmoToolkit.hh.

541  {
542  if (f1 != NULL) {
543 
544  TF1 fn(f1->GetName(), getLogarithmic(f1->GetExpFormula(), 'x'));
545 
546  copy(*f1, fn);
547 
548  fn.SetRange(f1->GetXmin(),
549  f1->GetXmax());
550 
551  *f1 = fn;
552 
553  f1->SetRange(TMath::Power(10.0,f1->GetXmin()),
554  TMath::Power(10.0,f1->GetXmax()));
555  }
556  }
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 using log10()).
void JGIZMO::setLogarithmicY ( TF1 *  f1)
inline

Make y-axis of given function logarithmic (e.g. after using log10()).

Parameters
f1function

Definition at line 564 of file JGizmoToolkit.hh.

565  {
566  if (f1 != NULL) {
567 
568  TString buffer = f1->GetExpFormula();
569 
570  buffer = "pow(10.0, " + buffer + ")";
571 
572  TF1 fn(f1->GetName(), buffer);
573 
574  copy(*f1, fn);
575 
576  *f1 = fn;
577  }
578  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
void JGIZMO::setLogarithmicX ( TF2 *  f2)
inline

Make x-axis of given function logarithmic (e.g. after using log10()).

Parameters
f2function

Definition at line 586 of file JGizmoToolkit.hh.

587  {
588  if (f2 != NULL) {
589 
590  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'x'));
591 
592  copy(*f2, fn);
593 
594  fn.SetRange(f2->GetXmin(),
595  f2->GetYmin(),
596  f2->GetXmax(),
597  f2->GetYmax());
598 
599  *f2 = fn;
600 
601  f2->SetRange(TMath::Power(10.0,f2->GetXmin()),
602  f2->GetYmin(),
603  TMath::Power(10.0,f2->GetXmax()),
604  f2->GetYmax());
605  }
606  }
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 using log10()).
void JGIZMO::setLogarithmicY ( TF2 *  f2)
inline

Make y-axis of given function logarithmic (e.g. after using log10()).

Parameters
f2function

Definition at line 614 of file JGizmoToolkit.hh.

615  {
616  if (f2 != NULL) {
617 
618  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'y'));
619 
620  copy(*f2, fn);
621 
622  fn.SetRange(f2->GetXmin(),
623  f2->GetYmin(),
624  f2->GetXmax(),
625  f2->GetYmax());
626 
627  *f2 = fn;
628 
629  f2->SetRange(f2->GetXmin(),
630  TMath::Power(10.0,f2->GetYmin()),
631  f2->GetXmax(),
632  TMath::Power(10.0,f2->GetYmax()));
633  }
634  }
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 using log10()).
void JGIZMO::setLogarithmicX ( TH1 *  h1)
inline

Make x-axis and associated functions of given histogram logarithmic (e.g. after using log10()).

Parameters
h1histogram

Definition at line 642 of file JGizmoToolkit.hh.

643  {
644  if (h1 != NULL) {
645 
646  setLogarithmicX<TF1>(h1->GetListOfFunctions());
647 
648  setLogarithmic(h1->GetXaxis());
649  }
650  }
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after using log10()).
void JGIZMO::setLogarithmicX ( TH2 *  h2)
inline

Make x-axis and associated functions of given histogram logarithmic (e.g. after using log10()).

Parameters
h2histogram

Definition at line 658 of file JGizmoToolkit.hh.

659  {
660  using namespace std;
661 
662  if (h2 != NULL) {
663 
664  setLogarithmicX<TF2>(h2->GetListOfFunctions());
665 
666  setLogarithmic(h2->GetXaxis());
667  }
668  }
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after using log10()).
void JGIZMO::setLogarithmicY ( TH2 *  h2)
inline

Make y-axis and associated functions of given histogram logarithmic (e.g. after using log10()).

Parameters
h2histogram

Definition at line 676 of file JGizmoToolkit.hh.

677  {
678  if (h2 != NULL) {
679 
680  setLogarithmicY<TF2>(h2->GetListOfFunctions());
681 
682  setLogarithmic(h2->GetYaxis());
683  }
684  }
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after using log10()).
void JGIZMO::setLogarithmicX ( TGraph *  g1)
inline

Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g1graph

Definition at line 692 of file JGizmoToolkit.hh.

693  {
694  if (g1 != NULL) {
695 
696  setLogarithmicX<TF1>(g1->GetListOfFunctions());
697 
698  for (Int_t i = 0; i != g1->GetN(); ++i) {
699  g1->GetX()[i] = pow(10.0, g1->GetX()[i]);
700  }
701  }
702  }
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::setLogarithmicY ( TGraph *  g1)
inline

Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g1graph

Definition at line 710 of file JGizmoToolkit.hh.

711  {
712  if (g1 != NULL) {
713 
714  setLogarithmicY<TF1>(g1->GetListOfFunctions());
715 
716  for (Int_t i = 0; i != g1->GetN(); ++i) {
717  g1->GetY()[i] = pow(10.0, g1->GetY()[i]);
718  }
719  }
720  }
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 ( TGraphErrors *  g1)
inline

Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g1graph

Definition at line 728 of file JGizmoToolkit.hh.

729  {
730  if (g1 != NULL) {
731 
732  setLogarithmicX<TF1>(g1->GetListOfFunctions());
733 
734  for (Int_t i = 0; i != g1->GetN(); ++i) {
735  g1->GetEX()[i] = pow(10.0, g1->GetX()[i] + g1->GetEX()[i]) - pow(10.0, g1->GetX()[i]);
736  g1->GetX() [i] = pow(10.0, g1->GetX()[i]);
737  }
738  }
739  }
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::setLogarithmicY ( TGraphErrors *  g1)
inline

Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g1graph

Definition at line 747 of file JGizmoToolkit.hh.

748  {
749  if (g1 != NULL) {
750 
751  setLogarithmicY<TF1>(g1->GetListOfFunctions());
752 
753  for (Int_t i = 0; i != g1->GetN(); ++i) {
754  g1->GetEY()[i] = pow(10.0, g1->GetY()[i] + g1->GetEY()[i]) - pow(10.0, g1->GetY()[i]);
755  g1->GetY() [i] = pow(10.0, g1->GetY()[i]);
756  }
757  }
758  }
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 x-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g2graph

Definition at line 766 of file JGizmoToolkit.hh.

767  {
768  if (g2 != NULL) {
769 
770  setLogarithmicX<TF2>(g2->GetListOfFunctions());
771 
772  for (Int_t i = 0; i != g2->GetN(); ++i) {
773  g2->GetX()[i] = pow(10.0, g2->GetX()[i]);
774  }
775  }
776  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicY ( TGraph2D *  g2)
inline

Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g2graph

Definition at line 784 of file JGizmoToolkit.hh.

785  {
786  if (g2 != NULL) {
787 
788  setLogarithmicY<TF2>(g2->GetListOfFunctions());
789 
790  for (Int_t i = 0; i != g2->GetN(); ++i) {
791  g2->GetY()[i] = pow(10.0, g2->GetY()[i]);
792  }
793  }
794  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicX ( TGraph2DErrors *  g2)
inline

Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g2graph

Definition at line 802 of file JGizmoToolkit.hh.

803  {
804  if (g2 != NULL) {
805 
806  setLogarithmicX<TF2>(g2->GetListOfFunctions());
807 
808  for (Int_t i = 0; i != g2->GetN(); ++i) {
809  g2->GetEX()[i] = pow(10.0, g2->GetX()[i] + g2->GetEX()[i]) - pow(10.0, g2->GetX()[i]);
810  g2->GetX() [i] = pow(10.0, g2->GetX()[i]);
811  }
812  }
813  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicY ( TGraph2DErrors *  g2)
inline

Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).

Parameters
g2graph

Definition at line 821 of file JGizmoToolkit.hh.

822  {
823  if (g2 != NULL) {
824 
825  setLogarithmicY<TF2>(g2->GetListOfFunctions());
826 
827  for (Int_t i = 0; i != g2->GetN(); ++i) {
828  g2->GetEY()[i] = pow(10.0, g2->GetY()[i] + g2->GetEY()[i]) - pow(10.0, g2->GetY()[i]);
829  g2->GetY() [i] = pow(10.0, g2->GetY()[i]);
830  }
831  }
832  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicX ( TMultiGraph *  gn)
inline

Make x-axis of given multi-graph logarithmic (e.g. after using log10()).

Parameters
gnmulti graph

Definition at line 840 of file JGizmoToolkit.hh.

841  {
842  if (gn != NULL) {
843  setLogarithmicX<TGraph>(gn->GetListOfGraphs());
844  }
845  }
void JGIZMO::setLogarithmicY ( TMultiGraph *  gn)
inline

Make y-axis of given multi-graph logarithmic (e.g. after using log10()).

Parameters
gnmulti graph

Definition at line 853 of file JGizmoToolkit.hh.

854  {
855  if (gn != NULL) {
856  setLogarithmicY<TGraph>(gn->GetListOfGraphs());
857  }
858  }
void JGIZMO::setLogarithmicX ( TLine *  line)
inline

Make x-axis of given line logarithmic (e.g. after using log10()).

Parameters
lineline

Definition at line 866 of file JGizmoToolkit.hh.

867  {
868  if (line != NULL) {
869  line->SetX1(pow(10.0, line->GetX1()));
870  line->SetX2(pow(10.0, line->GetX2()));
871  }
872  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicY ( TLine *  line)
inline

Make y-axis of given line logarithmic (e.g. after using log10()).

Parameters
lineline

Definition at line 880 of file JGizmoToolkit.hh.

881  {
882  if (line != NULL) {
883  line->SetY1(pow(10.0, line->GetY1()));
884  line->SetY2(pow(10.0, line->GetY2()));
885  }
886  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicX ( TEllipse *  ellipse)
inline

Make x-axis of given ellipse logarithmic (e.g. after using log10()).

Parameters
ellipseellipse

Definition at line 894 of file JGizmoToolkit.hh.

895  {
896  THROW(JFunctionalException, "Operation setLogarithmicX on TEllipse not allowed.");
897  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
void JGIZMO::setLogarithmicY ( TEllipse *  ellipse)
inline

Make y-axis of given ellipse logarithmic (e.g. after using log10()).

Parameters
ellipseellipse

Definition at line 905 of file JGizmoToolkit.hh.

906  {
907  THROW(JFunctionalException, "Operation setLogarithmicY on TEllipse not allowed.");
908  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
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 951 of file JGizmoToolkit.hh.

952  {
953  using namespace std;
954 
955  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
956  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
957  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
958 
959  Double_t W = 1.0;
960 
961  if (normalise) {
962 
963  W = 0.0;
964 
965  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
966  W += h1.GetBinContent(i);
967  }
968  }
969 
970  if (W != 0.0) {
971 
972  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
973 
974  const Double_t w = W * (bin_width ? h1.GetXaxis()->GetBinWidth(i) : 1.0);
975 
976  h1.SetBinContent(i, h1.GetBinContent(i) * factor / w);
977 
978  if (use_error) {
979  h1.SetBinError(i, h1.GetBinError(i) * factor / w);
980  }
981  }
982  }
983  }
data_type w[N+1][M+1]
Definition: JPolint.hh:757
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
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 1000 of file JGizmoToolkit.hh.

1001  {
1002  using namespace std;
1003 
1004  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1005  const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
1006  const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
1007  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1008  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1009 
1010  Double_t W = 1.0;
1011 
1012  if (X && Y) {
1013 
1014  if (normalise) {
1015 
1016  W = 0.0;
1017 
1018  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1019  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1020  W += h2.GetBinContent(ix,iy);
1021  }
1022  }
1023  }
1024 
1025  if (W != 0.0) {
1026 
1027  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1028  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1029 
1030  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1031 
1032  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1033 
1034  if (use_error) {
1035  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1036  }
1037  }
1038  }
1039  }
1040 
1041  } else if (X) {
1042 
1043  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1044 
1045  if (normalise) {
1046 
1047  W = 0.0;
1048 
1049  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1050  W += h2.GetBinContent(ix,iy);
1051  }
1052  }
1053 
1054  if (W != 0.0) {
1055 
1056  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1057 
1058  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1059 
1060  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1061 
1062  if (use_error) {
1063  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1064  }
1065  }
1066  }
1067  }
1068 
1069  } else if (Y) {
1070 
1071  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1072 
1073  if (normalise) {
1074 
1075  W = 0.0;
1076 
1077  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1078  W += h2.GetBinContent(ix,iy);
1079  }
1080  }
1081 
1082  if (W != 0.0) {
1083 
1084  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1085 
1086  const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1087 
1088  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1089 
1090  if (use_error) {
1091  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1092  }
1093  }
1094  }
1095  }
1096  }
1097  }
data_type w[N+1][M+1]
Definition: JPolint.hh:757
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
then break fi done getCenter read X Y Z let X
void JGIZMO::setLimits ( TGraph &  g1)
inline

Set limits of TGraph.

Parameters
g1graph

Definition at line 1105 of file JGizmoToolkit.hh.

1106  {
1107  using namespace std;
1108 
1109  Double_t ymin = numeric_limits<Double_t>::max();
1110  Double_t ymax = numeric_limits<Double_t>::lowest();
1111 
1112  for (Int_t i = 0; i != g1.GetN(); ++i) {
1113 
1114  const Double_t y = g1.GetY()[i];
1115 
1116  if (y > ymax) { ymax = y; }
1117  if (y < ymin) { ymin = y; }
1118  }
1119 
1120  g1.SetMinimum(ymin);
1121  g1.SetMaximum(ymax);
1122  }
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 1130 of file JGizmoToolkit.hh.

1131  {
1132  using namespace std;
1133 
1134  Double_t zmin = numeric_limits<Double_t>::max();
1135  Double_t zmax = numeric_limits<Double_t>::lowest();
1136 
1137  for (Int_t i = 0; i != g2.GetN(); ++i) {
1138 
1139  const Double_t z = g2.GetZ()[i];
1140 
1141  if (z > zmax) { zmax = z; }
1142  if (z < zmin) { zmin = z; }
1143  }
1144 
1145  g2.SetMinimum(zmin);
1146  g2.SetMaximum(zmax);
1147  }
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 1157 of file JGizmoToolkit.hh.

1160  {
1161  if (logx) {
1162  xmin = log(xmin);
1163  xmax = log(xmax);
1164  }
1165 
1166  double dx = (xmax - xmin) * 0.1;
1167 
1168  if (xmin > dx || xmin < 0.0)
1169  xmin -= dx;
1170  else
1171  xmin = 0.0;
1172 
1173  xmax += dx;
1174 
1175  if (logx) {
1176  xmin = exp(xmin);
1177  xmax = exp(xmax);
1178  }
1179  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcoustics.sh -- typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
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 1196 of file JGizmoToolkit.hh.

1197  {
1198  using namespace JPP;
1199 
1200  if (axis->GetNbins() == (int) memo.size()) {
1201 
1202  for (int i = 0; i != axis->GetNbins(); ++i) {
1203 
1204  const JPMTPhysicalAddress& address = memo[i];
1205 
1206  axis->SetBinLabel(i + 1, address.toString().c_str());
1207  }
1208 
1209  } else {
1210 
1211  THROW(JValueOutOfRange, "Number of bins " << axis->GetNbins() << " != " << memo.size());
1212  }
1213  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
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 1227 of file JGizmoToolkit.hh.

1228  {
1229  using namespace JPP;
1230 
1231  TAxis* pax = NULL;
1232 
1233  if (axis == "x" || axis == "X")
1234  pax = h1.GetXaxis();
1235  else if (axis == "y" || axis == "Y")
1236  pax = h1.GetYaxis();
1237  else if (axis == "z" || axis == "Z")
1238  pax = h1.GetZaxis();
1239  else
1240  THROW(JValueOutOfRange, "Invalid axis " << axis);
1241 
1242  if (pax->GetNbins() == (int) memo.size()) {
1243 
1244  for (int i = 0; i != pax->GetNbins(); ++i) {
1245 
1246  const JPMTPhysicalAddress& address = memo.getAddressTranslator(i);
1247 
1248  pax->SetBinLabel(i + 1, address.toString().c_str());
1249  }
1250 
1251  h1.LabelsOption("a", axis.c_str()); // sort labels
1252 
1253  } else {
1254 
1255  THROW(JValueOutOfRange, "Number of bins " << pax->GetNbins() << " != " << memo.size());
1256  }
1257  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
bool JGIZMO::isTObject ( const TKey *  key)
inline

Check if given key corresponds to a TObject.

Parameters
keyROOT key
Returns
true if given key corresponds to a TObject; else false

Definition at line 1266 of file JGizmoToolkit.hh.

1267  {
1268  return (key != NULL && TClass::GetClass(key->GetClassName())->IsTObject());
1269  }

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 89 of file JGizmoToolkit.hh.

const char JGIZMO::LABEL_TERMINATOR = '&'
static

label terminator

Definition at line 23 of file JRootObject.hh.