Jpp  master_rocky-43-ge265d140c
the software that should make you happy
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 object. More...
 
bool isTAttFill (const TObject *object)
 Get drawing option of object. 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 convertToPDF (TH3 &h3, const std::string &option="NXYW", const double factor=1.0)
 Convert 3D 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...
 
TObjectgetObject (TList *ls, const char *const name)
 Get first object of which name matches given reguar expression. More...
 
TF1 * getFunction (TH1 *h1, const char *const fcn)
 Get function. More...
 
TF1 * getFunction (TGraph *g1, const char *const fcn)
 Get function. More...
 
TF1 * getFunction (TGraph2D *g2, const char *const fcn)
 Get function. 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

◆ getFile()

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

112  {
113  using namespace std;
114 
115  gErrorIgnoreLevel = kError;
116 
117  static map<string, TFile*> zmap;
118 
119  map<string, TFile*>::iterator i = zmap.find(file_name);
120 
121  if (i == zmap.end() || i->second == NULL || !i->second->IsOpen()) {
122 
123  TFile* file = TFile::Open(file_name.c_str(), option.c_str());
124 
125  zmap[file_name] = file;
126 
127  return file;
128 
129  } else {
130 
131  return i->second;
132  }
133  }
Definition: JSTDTypes.hh:14

◆ getDirectory()

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

145  {
146  TFile* in = getFile(id.getFilename().c_str(), "exist");
147 
148  if (in == NULL || !in->IsOpen()) {
149  return NULL;
150  }
151 
152  if (id.getDirectory() != "")
153  return in->GetDirectory(id.getDirectory());
154  else
155  return in;
156  }
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:128
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.

◆ getObject() [1/2]

TObject* JGIZMO::getObject ( const JRootObjectID id)
inline

Get first TObject with given identifier.

Parameters
ididentifier
Returns
pointer to TObject (or NULL)

Definition at line 165 of file JGizmoToolkit.hh.

166  {
167  TDirectory* dir = getDirectory(id);
168 
169  if (dir != NULL) {
170 
171  const TRegexp regexp(id.getObjectName());
172 
173  TIter iter(dir->GetListOfKeys());
174 
175  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
176 
177  const TString tag(key->GetName());
178 
179  // option match
180 
181  if (tag.Index(regexp) != -1) {
182  return key->ReadObj();
183  }
184  }
185  }
186 
187  return NULL;
188  }

◆ isTAttLine()

bool JGIZMO::isTAttLine ( const TObject object)
inline

Get drawing option of object.

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

Definition at line 197 of file JGizmoToolkit.hh.

198  {
199  {
200  if (dynamic_cast<const TH3*>(object) != NULL) {
201  return false;
202  }
203  }
204  {
205  if (dynamic_cast<const TH2*>(object) != NULL) {
206  return false;
207  }
208  }
209  {
210  const TH1* h1 = dynamic_cast<const TH1*>(object);
211 
212  if (h1 != NULL) {
213 
214  if (h1->GetSumw2N()) {
215  for (Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
216  if (h1->GetBinError(i) != 0.0) {
217  return false;
218  }
219  }
220  }
221 
222  return true;
223  }
224  }
225  {
226  const TGraphErrors* g1 = dynamic_cast<const TGraphErrors*>(object);
227 
228  if (g1 != NULL) {
229 
230  for (Int_t i = 0; i != g1->GetN(); ++i) {
231  if (g1->GetEY()[i] != 0.0) {
232  return false;
233  }
234  }
235 
236  return g1->GetN() > 1;
237  }
238  }
239  {
240  const TGraphAsymmErrors* g1 = dynamic_cast<const TGraphAsymmErrors*>(object);
241 
242  if (g1 != NULL) {
243 
244  for (Int_t i = 0; i != g1->GetN(); ++i) {
245  if (g1->GetEYhigh()[i] != 0.0 ||
246  g1->GetEYlow() [i] != 0.0) {
247  return false;
248  }
249  }
250 
251  return g1->GetN() > 1;
252  }
253  }
254  {
255  const TGraph* g1 = dynamic_cast<const TGraph*>(object);
256 
257  if (g1 != NULL) {
258  return g1->GetN() > 1;
259  }
260  }
261 
262  return true;
263  }
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25

◆ isTAttFill()

bool JGIZMO::isTAttFill ( const TObject object)
inline

Get drawing option of object.

Parameters
objectpointer to TObject
Returns
true if object looks like an area; else false

Definition at line 272 of file JGizmoToolkit.hh.

273  {
274  {
275  const TAttFill* t1 = dynamic_cast<const TAttFill*>(object);
276 
277  if (t1 != NULL) {
278  return t1->GetFillColor() != 1 && t1->GetFillStyle() != 0;
279  }
280  }
281 
282  return false;
283  }

◆ getResult() [1/2]

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

301  {
302  TString buffer(text);
303 
304  if (object != NULL) {
305 
306  TClass* p = TClass::GetClass(object->ClassName());
307 
308  if (p != NULL) {
309 
310  for ( ; ; ) {
311 
312  TMethod* method = NULL;
313 
314  for (std::unique_ptr<TIterator> iter(p->GetListOfAllPublicMethods()->MakeIterator()); TMethod* p = (TMethod*) iter->Next(); ) {
315  if (buffer.Index(p->GetName()) != -1) {
316  if (method == NULL || strlen(p->GetName()) > strlen(method->GetName())) {
317  method = p;
318  }
319  }
320  }
321 
322  if (method == NULL) {
323  break;
324  }
325 
326  for (Ssiz_t index; (index = buffer.Index(method->GetName())) != -1; ) {
327 
328  const TRegexp fp(" *([^)]*)"); // function call
329 
330  Ssiz_t len;
331  Ssiz_t pos = buffer.Index(fp, &len, index);
332 
333  Double_t value;
334 
335  if (pos == -1 || pos != index + (Ssiz_t) strlen(method->GetName())) {
336 
337  TMethodCall(p, method->GetName(), NULL).Execute(object, value);
338 
339  len = strlen(method->GetName());
340 
341  } else {
342 
343  TMethodCall(p, method->GetName(), NULL).Execute(object, TString(buffer(pos + 1, len - 2)), value);
344 
345  len += strlen(method->GetName());
346  }
347 
348  buffer.Replace(index, len, TString::Format("%20.10e", value));
349  }
350  }
351  }
352  }
353 
354  return TFormula("/tmp", buffer.Data()).Eval(0.0);
355  }
char text[TEXT_SIZE]
Definition: elog.cc:72

◆ getResult() [2/2]

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

373  {
374  return getResult(TString(text.c_str()), object);
375  }
Double_t getResult(const std::string &text, TObject *object=NULL)
Get result of given textual formula.

◆ getParameter()

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

387  {
388  const char* regexp("p[0-9]* *=");
389 
390  TString buffer(text.c_str());
391 
392  buffer = buffer(TRegexp(regexp));
393  buffer = buffer(1, buffer.Length() - 2);
394 
395  if (!buffer.IsDigit()) {
396  THROW(JParseError, "Text is not a number " << text << ' ' << regexp);
397  }
398 
399  return buffer.Atoi();
400  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for parsing value.
Definition: JException.hh:198

◆ getValue() [1/2]

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

418  {
419  const char* regexp("=.*");
420 
421  TString buffer(text.c_str());
422 
423  buffer = buffer(TRegexp(regexp));
424  buffer = buffer(1, buffer.Length() - 1);
425 
426  return getResult(std::string(buffer), object);
427  }

◆ getValue() [2/2]

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

446  {
447  using namespace std;
448 
449  const char* regexp("=.*");
450 
451  TString buffer(text.c_str());
452 
453  buffer = buffer(TRegexp(regexp));
454  buffer = buffer(1, buffer.Length() - 1);
455 
456 
457  istringstream is((std::string(buffer)));
458 
459  Double_t value;
460 
461  for (int i = index; is >> value && i > 0; --i) {}
462 
463  if (is)
464  return value;
465  else
466  THROW(JParseError, "Text does not contain a number at given position " << buffer << ' ' << index);
467  }

◆ setLogarithmic()

void JGIZMO::setLogarithmic ( TAxis *  axis)
inline

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

Parameters
axisaxis

Definition at line 475 of file JGizmoToolkit.hh.

476  {
477  if (axis != NULL) {
478 
479  const Int_t N = axis->GetNbins();
480  Double_t buffer[N+1];
481 
482  buffer[0] = TMath::Power(10.0, axis->GetBinLowEdge(1));
483 
484  for (Int_t i = 1; i <= N; ++i) {
485  buffer[i] = TMath::Power(10.0, axis->GetBinLowEdge(i) + axis->GetBinWidth(i));
486  }
487 
488  axis->Set(N, buffer);
489  /*
490  if (axis->TestBit(TAxis::kAxisRange)) {
491 
492  const Int_t first = axis->GetFirst();
493  const Int_t last = axis->GetLast();
494 
495  if (first != last) {
496 
497  const Double_t xmin = axis->GetBinLowEdge(first);
498  const Double_t xmax = axis->GetBinLowEdge(last) + axis->GetBinWidth(last);
499 
500  axis->SetRangeUser(TMath::Power(10.0, xmin), TMath::Power(10.0, xmax));
501  }
502  }
503  */
504  }
505  }

◆ getLogarithmic()

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

516  {
517  const TRegexp regexp[] = {
518  TString("^") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter at start of line
519  TString("[^a-zA-Z_]") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter in middle of line
520  TString("[^a-zA-Z_]") + TString(parameter) + TString("$") // parameter at end of line
521  };
522 
523  const TString replacement = TString("log10(") + TString(parameter) + TString(")");
524 
525  TString buffer(formula);
526 
527  if (buffer.Length() == 1 && buffer[0] == parameter) {
528 
529  buffer = replacement;
530 
531  } else {
532 
533  for (Ssiz_t pos = 0, i; pos < buffer.Length(); pos += replacement.Length()) {
534  if ((i = buffer.Index(regexp[0], pos)) != -1) { buffer.Replace((pos = i + 0), 1, replacement); }
535  else if ((i = buffer.Index(regexp[1], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
536  else if ((i = buffer.Index(regexp[2], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
537  else { break; }
538  }
539  }
540 
541  return buffer;
542  }

◆ copy() [1/2]

void JGIZMO::copy ( const TF1 &  from,
TF1 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 551 of file JGizmoToolkit.hh.

552  {
553  static_cast<TAttLine&> (to) = static_cast<const TAttLine&> (from);
554  static_cast<TAttFill&> (to) = static_cast<const TAttFill&> (from);
555  static_cast<TAttMarker&>(to) = static_cast<const TAttMarker&>(from);
556 
557  to.SetParameters(from.GetParameters());
558 
559  to.SetNpx(from.GetNpx());
560  }

◆ copy() [2/2]

void JGIZMO::copy ( const TF2 &  from,
TF2 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 569 of file JGizmoToolkit.hh.

570  {
571  copy(static_cast<const TF1&>(from), static_cast<TF1&>(to));
572 
573  to.SetNpy(from.GetNpy());
574  }
void copy(const TF2 &from, TF2 &to)
Copy function parameters.

◆ setLogarithmicX() [1/12]

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

978  {
979  for (TIter i(list); T* p = dynamic_cast<T*>(i.Next()); ) {
980  setLogarithmicX(p);
981  }
982  }
void setLogarithmicX(TEllipse *ellipse)
Make x-axis of given ellipse logarithmic (e.g. after using log10()).

◆ setLogarithmicY() [1/11]

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

992  {
993  for (TIter i(list); T* p = dynamic_cast<T*>(i.Next()); ) {
994  setLogarithmicY(p);
995  }
996  }
void setLogarithmicY(TEllipse *ellipse)
Make y-axis of given ellipse logarithmic (e.g. after using log10()).

◆ setLogarithmicX() [2/12]

void JGIZMO::setLogarithmicX ( TF1 *  f1)
inline

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

Parameters
f1function

Definition at line 600 of file JGizmoToolkit.hh.

601  {
602  if (f1 != NULL) {
603 
604  TF1 fn(f1->GetName(), getLogarithmic(f1->GetExpFormula(), 'x'));
605 
606  copy(*f1, fn);
607 
608  fn.SetRange(f1->GetXmin(),
609  f1->GetXmax());
610 
611  *f1 = fn;
612 
613  f1->SetRange(TMath::Power(10.0,f1->GetXmin()),
614  TMath::Power(10.0,f1->GetXmax()));
615  }
616  }
const JPolynome f1(1.0, 2.0, 3.0)
Function.
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after using log10()).

◆ setLogarithmicY() [2/11]

void JGIZMO::setLogarithmicY ( TF1 *  f1)
inline

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

Parameters
f1function

Definition at line 624 of file JGizmoToolkit.hh.

625  {
626  if (f1 != NULL) {
627 
628  TString buffer = f1->GetExpFormula();
629 
630  buffer = "pow(10.0, " + buffer + ")";
631 
632  TF1 fn(f1->GetName(), buffer);
633 
634  copy(*f1, fn);
635 
636  *f1 = fn;
637  }
638  }

◆ setLogarithmicX() [3/12]

void JGIZMO::setLogarithmicX ( TF2 *  f2)
inline

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

Parameters
f2function

Definition at line 646 of file JGizmoToolkit.hh.

647  {
648  if (f2 != NULL) {
649 
650  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'x'));
651 
652  copy(*f2, fn);
653 
654  fn.SetRange(f2->GetXmin(),
655  f2->GetYmin(),
656  f2->GetXmax(),
657  f2->GetYmax());
658 
659  *f2 = fn;
660 
661  f2->SetRange(TMath::Power(10.0,f2->GetXmin()),
662  f2->GetYmin(),
663  TMath::Power(10.0,f2->GetXmax()),
664  f2->GetYmax());
665  }
666  }

◆ setLogarithmicY() [3/11]

void JGIZMO::setLogarithmicY ( TF2 *  f2)
inline

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

Parameters
f2function

Definition at line 674 of file JGizmoToolkit.hh.

675  {
676  if (f2 != NULL) {
677 
678  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'y'));
679 
680  copy(*f2, fn);
681 
682  fn.SetRange(f2->GetXmin(),
683  f2->GetYmin(),
684  f2->GetXmax(),
685  f2->GetYmax());
686 
687  *f2 = fn;
688 
689  f2->SetRange(f2->GetXmin(),
690  TMath::Power(10.0,f2->GetYmin()),
691  f2->GetXmax(),
692  TMath::Power(10.0,f2->GetYmax()));
693  }
694  }

◆ setLogarithmicX() [4/12]

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

703  {
704  if (h1 != NULL) {
705 
706  setLogarithmicX<TF1>(h1->GetListOfFunctions());
707 
708  setLogarithmic(h1->GetXaxis());
709  }
710  }
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after using log10()).

◆ setLogarithmicX() [5/12]

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

719  {
720  using namespace std;
721 
722  if (h2 != NULL) {
723 
724  setLogarithmicX<TF2>(h2->GetListOfFunctions());
725 
726  setLogarithmic(h2->GetXaxis());
727  }
728  }

◆ setLogarithmicY() [4/11]

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

737  {
738  if (h2 != NULL) {
739 
740  setLogarithmicY<TF2>(h2->GetListOfFunctions());
741 
742  setLogarithmic(h2->GetYaxis());
743  }
744  }

◆ setLogarithmicX() [6/12]

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

753  {
754  if (g1 != NULL) {
755 
756  setLogarithmicX<TF1>(g1->GetListOfFunctions());
757 
758  for (Int_t i = 0; i != g1->GetN(); ++i) {
759  g1->GetX()[i] = pow(10.0, g1->GetX()[i]);
760  }
761  }
762  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97

◆ setLogarithmicY() [5/11]

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

771  {
772  if (g1 != NULL) {
773 
774  setLogarithmicY<TF1>(g1->GetListOfFunctions());
775 
776  for (Int_t i = 0; i != g1->GetN(); ++i) {
777  g1->GetY()[i] = pow(10.0, g1->GetY()[i]);
778  }
779  }
780  }

◆ setLogarithmicX() [7/12]

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

789  {
790  if (g1 != NULL) {
791 
792  setLogarithmicX<TF1>(g1->GetListOfFunctions());
793 
794  for (Int_t i = 0; i != g1->GetN(); ++i) {
795  g1->GetEX()[i] = pow(10.0, g1->GetX()[i] + g1->GetEX()[i]) - pow(10.0, g1->GetX()[i]);
796  g1->GetX() [i] = pow(10.0, g1->GetX()[i]);
797  }
798  }
799  }

◆ setLogarithmicY() [6/11]

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

808  {
809  if (g1 != NULL) {
810 
811  setLogarithmicY<TF1>(g1->GetListOfFunctions());
812 
813  for (Int_t i = 0; i != g1->GetN(); ++i) {
814  g1->GetEY()[i] = pow(10.0, g1->GetY()[i] + g1->GetEY()[i]) - pow(10.0, g1->GetY()[i]);
815  g1->GetY() [i] = pow(10.0, g1->GetY()[i]);
816  }
817  }
818  }

◆ setLogarithmicX() [8/12]

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

827  {
828  if (g2 != NULL) {
829 
830  setLogarithmicX<TF2>(g2->GetListOfFunctions());
831 
832  for (Int_t i = 0; i != g2->GetN(); ++i) {
833  g2->GetX()[i] = pow(10.0, g2->GetX()[i]);
834  }
835  }
836  }

◆ setLogarithmicY() [7/11]

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

845  {
846  if (g2 != NULL) {
847 
848  setLogarithmicY<TF2>(g2->GetListOfFunctions());
849 
850  for (Int_t i = 0; i != g2->GetN(); ++i) {
851  g2->GetY()[i] = pow(10.0, g2->GetY()[i]);
852  }
853  }
854  }

◆ setLogarithmicX() [9/12]

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

863  {
864  if (g2 != NULL) {
865 
866  setLogarithmicX<TF2>(g2->GetListOfFunctions());
867 
868  for (Int_t i = 0; i != g2->GetN(); ++i) {
869  g2->GetEX()[i] = pow(10.0, g2->GetX()[i] + g2->GetEX()[i]) - pow(10.0, g2->GetX()[i]);
870  g2->GetX() [i] = pow(10.0, g2->GetX()[i]);
871  }
872  }
873  }

◆ setLogarithmicY() [8/11]

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

882  {
883  if (g2 != NULL) {
884 
885  setLogarithmicY<TF2>(g2->GetListOfFunctions());
886 
887  for (Int_t i = 0; i != g2->GetN(); ++i) {
888  g2->GetEY()[i] = pow(10.0, g2->GetY()[i] + g2->GetEY()[i]) - pow(10.0, g2->GetY()[i]);
889  g2->GetY() [i] = pow(10.0, g2->GetY()[i]);
890  }
891  }
892  }

◆ setLogarithmicX() [10/12]

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

901  {
902  if (gn != NULL) {
903  setLogarithmicX<TGraph>(gn->GetListOfGraphs());
904  }
905  }

◆ setLogarithmicY() [9/11]

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

914  {
915  if (gn != NULL) {
916  setLogarithmicY<TGraph>(gn->GetListOfGraphs());
917  }
918  }

◆ setLogarithmicX() [11/12]

void JGIZMO::setLogarithmicX ( TLine *  line)
inline

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

Parameters
lineline

Definition at line 926 of file JGizmoToolkit.hh.

927  {
928  if (line != NULL) {
929  line->SetX1(pow(10.0, line->GetX1()));
930  line->SetX2(pow(10.0, line->GetX2()));
931  }
932  }

◆ setLogarithmicY() [10/11]

void JGIZMO::setLogarithmicY ( TLine *  line)
inline

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

Parameters
lineline

Definition at line 940 of file JGizmoToolkit.hh.

941  {
942  if (line != NULL) {
943  line->SetY1(pow(10.0, line->GetY1()));
944  line->SetY2(pow(10.0, line->GetY2()));
945  }
946  }

◆ setLogarithmicX() [12/12]

void JGIZMO::setLogarithmicX ( TEllipse *  ellipse)
inline

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

Parameters
ellipseellipse

Definition at line 954 of file JGizmoToolkit.hh.

955  {
956  THROW(JFunctionalException, "Operation setLogarithmicX on TEllipse not allowed.");
957  }
Exception for a functional operation.
Definition: JException.hh:144

◆ setLogarithmicY() [11/11]

void JGIZMO::setLogarithmicY ( TEllipse *  ellipse)
inline

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

Parameters
ellipseellipse

Definition at line 965 of file JGizmoToolkit.hh.

966  {
967  THROW(JFunctionalException, "Operation setLogarithmicY on TEllipse not allowed.");
968  }

◆ convertToPDF() [1/3]

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

1012  {
1013  using namespace std;
1014 
1015  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1016  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1017  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1018 
1019  Double_t W = 1.0;
1020 
1021  if (normalise) {
1022 
1023  W = 0.0;
1024 
1025  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
1026  W += h1.GetBinContent(i);
1027  }
1028  }
1029 
1030  if (W != 0.0) {
1031 
1032  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
1033 
1034  const Double_t w = W * (bin_width ? h1.GetXaxis()->GetBinWidth(i) : 1.0);
1035 
1036  h1.SetBinContent(i, h1.GetBinContent(i) * factor / w);
1037 
1038  if (use_error) {
1039  h1.SetBinError(i, h1.GetBinError(i) * factor / w);
1040  }
1041  }
1042  }
1043  }
data_type w[N+1][M+1]
Definition: JPolint.hh:867

◆ convertToPDF() [2/3]

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

1061  {
1062  using namespace std;
1063 
1064  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1065  const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
1066  const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
1067  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1068  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1069 
1070  Double_t W = 1.0;
1071 
1072  if (X && Y) {
1073 
1074  if (normalise) {
1075 
1076  W = 0.0;
1077 
1078  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1079  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1080  W += h2.GetBinContent(ix,iy);
1081  }
1082  }
1083  }
1084 
1085  if (W != 0.0) {
1086 
1087  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1088  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1089 
1090  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1091 
1092  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1093 
1094  if (use_error) {
1095  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1096  }
1097  }
1098  }
1099  }
1100 
1101  } else if (X) {
1102 
1103  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1104 
1105  if (normalise) {
1106 
1107  W = 0.0;
1108 
1109  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1110  W += h2.GetBinContent(ix,iy);
1111  }
1112  }
1113 
1114  if (W != 0.0) {
1115 
1116  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1117 
1118  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1119 
1120  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1121 
1122  if (use_error) {
1123  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1124  }
1125  }
1126  }
1127  }
1128 
1129  } else if (Y) {
1130 
1131  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1132 
1133  if (normalise) {
1134 
1135  W = 0.0;
1136 
1137  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1138  W += h2.GetBinContent(ix,iy);
1139  }
1140  }
1141 
1142  if (W != 0.0) {
1143 
1144  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1145 
1146  const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1147 
1148  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1149 
1150  if (use_error) {
1151  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1152  }
1153  }
1154  }
1155  }
1156  }
1157  }

◆ convertToPDF() [3/3]

void JGIZMO::convertToPDF ( TH3 &  h3,
const std::string &  option = "NXYW",
const double  factor = 1.0 
)
inline

Convert 3D histogram to PDF.

Possible options are:

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

Definition at line 1175 of file JGizmoToolkit.hh.

1176  {
1177  using namespace std;
1178 
1179  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1180  const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
1181  const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
1182  const bool Z = (option.find('Z') != string::npos || option.find('z') != string::npos);
1183  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1184  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1185 
1186  Double_t W = 1.0;
1187 
1188  if (X && Y && Z) {
1189 
1190  if (normalise) {
1191 
1192  W = 0.0;
1193 
1194  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1195  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1196  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1197  W += h3.GetBinContent(ix,iy,iz);
1198  }
1199  }
1200  }
1201  }
1202 
1203  if (W != 0.0) {
1204 
1205  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1206  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1207  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1208 
1209  const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1210 
1211  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1212 
1213  if (use_error) {
1214  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1215  }
1216  }
1217  }
1218  }
1219  }
1220 
1221  } else if (X && Z) {
1222 
1223  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1224 
1225  if (normalise) {
1226 
1227  W = 0.0;
1228 
1229  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1230  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1231  W += h3.GetBinContent(ix,iy,iz);
1232  }
1233  }
1234  }
1235 
1236  if (W != 0.0) {
1237 
1238  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1239  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1240 
1241  const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1242 
1243  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1244 
1245  if (use_error) {
1246  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1247  }
1248  }
1249  }
1250  }
1251  }
1252 
1253  } else if (Y && Z) {
1254 
1255  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1256 
1257  if (normalise) {
1258 
1259  W = 0.0;
1260 
1261  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1262  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1263  W += h3.GetBinContent(ix,iy,iz);
1264  }
1265  }
1266  }
1267 
1268  if (W != 0.0) {
1269 
1270  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1271  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1272 
1273  const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1274 
1275  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1276 
1277  if (use_error) {
1278  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1279  }
1280  }
1281  }
1282  }
1283  }
1284 
1285  } else if (X && Y) {
1286 
1287  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1288 
1289  if (normalise) {
1290 
1291  W = 0.0;
1292 
1293  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1294  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1295  W += h3.GetBinContent(ix,iy,iz);
1296  }
1297  }
1298  }
1299 
1300  if (W != 0.0) {
1301 
1302  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1303  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1304 
1305  const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1306 
1307  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1308 
1309  if (use_error) {
1310  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1311  }
1312  }
1313  }
1314  }
1315  }
1316 
1317  } else if (X) {
1318 
1319  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1320  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1321 
1322  if (normalise) {
1323 
1324  W = 0.0;
1325 
1326  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1327  W += h3.GetBinContent(ix,iy,iz);
1328  }
1329  }
1330 
1331  if (W != 0.0) {
1332 
1333  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1334 
1335  const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) : 1.0);
1336 
1337  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1338 
1339  if (use_error) {
1340  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1341  }
1342  }
1343  }
1344  }
1345  }
1346 
1347  } else if (Y) {
1348 
1349  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1350  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1351 
1352  if (normalise) {
1353 
1354  W = 0.0;
1355 
1356  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1357  W += h3.GetBinContent(ix,iy,iz);
1358  }
1359  }
1360 
1361  if (W != 0.0) {
1362 
1363  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1364 
1365  const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1366 
1367  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1368 
1369  if (use_error) {
1370  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1371  }
1372  }
1373  }
1374  }
1375  }
1376 
1377  } else if (Z) {
1378 
1379  for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1380  for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1381 
1382  if (normalise) {
1383 
1384  W = 0.0;
1385 
1386  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1387  W += h3.GetBinContent(ix,iy,iz);
1388  }
1389  }
1390 
1391  if (W != 0.0) {
1392 
1393  for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1394 
1395  const Double_t w = W * (bin_width ? h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1396 
1397  h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1398 
1399  if (use_error) {
1400  h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1401  }
1402  }
1403  }
1404  }
1405  }
1406  }
1407  }

◆ setLimits() [1/2]

void JGIZMO::setLimits ( TGraph &  g1)
inline

Set limits of TGraph.

Parameters
g1graph

Definition at line 1415 of file JGizmoToolkit.hh.

1416  {
1417  using namespace std;
1418 
1419  Double_t ymin = numeric_limits<Double_t>::max();
1420  Double_t ymax = numeric_limits<Double_t>::lowest();
1421 
1422  for (Int_t i = 0; i != g1.GetN(); ++i) {
1423 
1424  const Double_t y = g1.GetY()[i];
1425 
1426  if (y > ymax) { ymax = y; }
1427  if (y < ymin) { ymin = y; }
1428  }
1429 
1430  g1.SetMinimum(ymin);
1431  g1.SetMaximum(ymax);
1432  }

◆ setLimits() [2/2]

void JGIZMO::setLimits ( TGraph2D &  g2)
inline

Set limits of TGraph2D.

Parameters
g2graph

Definition at line 1440 of file JGizmoToolkit.hh.

1441  {
1442  using namespace std;
1443 
1444  Double_t zmin = numeric_limits<Double_t>::max();
1445  Double_t zmax = numeric_limits<Double_t>::lowest();
1446 
1447  for (Int_t i = 0; i != g2.GetN(); ++i) {
1448 
1449  const Double_t z = g2.GetZ()[i];
1450 
1451  if (z > zmax) { zmax = z; }
1452  if (z < zmin) { zmin = z; }
1453  }
1454 
1455  g2.SetMinimum(zmin);
1456  g2.SetMaximum(zmax);
1457  }

◆ setRange()

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

1470  {
1471  if (logx) {
1472  xmin = log(xmin);
1473  xmax = log(xmax);
1474  }
1475 
1476  double dx = (xmax - xmin) * 0.1;
1477 
1478  if (logx || xmin >= dx || xmin < 0.0)
1479  xmin -= dx;
1480  else
1481  xmin = 0.0;
1482 
1483  xmax += dx;
1484 
1485  if (logx) {
1486  xmin = exp(xmin);
1487  xmax = exp(xmax);
1488  }
1489  }
const double xmax
Definition: JQuadrature.cc:24
const double xmin
Definition: JQuadrature.cc:23

◆ setAxisLabels() [1/2]

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

1507  {
1508  using namespace JPP;
1509 
1510  if (axis->GetNbins() == (int) memo.size()) {
1511 
1512  for (int i = 0; i != axis->GetNbins(); ++i) {
1513 
1514  const JPMTPhysicalAddress& address = memo[i];
1515 
1516  axis->SetBinLabel(i + 1, address.toString().c_str());
1517  }
1518 
1519  } else {
1520 
1521  THROW(JValueOutOfRange, "Number of bins " << axis->GetNbins() << " != " << memo.size());
1522  }
1523  }
Data structure for PMT physical address.
std::string toString() const
Convert PMT physical address to string.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

◆ setAxisLabels() [2/2]

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

1538  {
1539  using namespace JPP;
1540 
1541  TAxis* pax = NULL;
1542 
1543  if (axis == "x" || axis == "X")
1544  pax = h1.GetXaxis();
1545  else if (axis == "y" || axis == "Y")
1546  pax = h1.GetYaxis();
1547  else if (axis == "z" || axis == "Z")
1548  pax = h1.GetZaxis();
1549  else
1550  THROW(JValueOutOfRange, "Invalid axis " << axis);
1551 
1552  if (pax->GetNbins() == (int) memo.size()) {
1553 
1554  for (int i = 0; i != pax->GetNbins(); ++i) {
1555 
1556  const JPMTPhysicalAddress& address = memo.getAddressTranslator(i);
1557 
1558  pax->SetBinLabel(i + 1, address.toString().c_str());
1559  }
1560 
1561  h1.LabelsOption("a", axis.c_str()); // sort labels
1562 
1563  } else {
1564 
1565  THROW(JValueOutOfRange, "Number of bins " << pax->GetNbins() << " != " << memo.size());
1566  }
1567  }
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.

◆ isTObject()

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

1577  {
1578  return (key != NULL && TClass::GetClass(key->GetClassName())->IsTObject());
1579  }

◆ getObject() [2/2]

TObject* JGIZMO::getObject ( TList *  ls,
const char *const  name 
)
inline

Get first object of which name matches given reguar expression.

Parameters
lspointer to list of objects
nameregular expression
Returns
pointer to object (maybe NULL)

Definition at line 1589 of file JGizmoToolkit.hh.

1590  {
1591  const TRegexp regexp(name);
1592 
1593  TIter iter(ls);
1594 
1595  for (TObject* p1; (p1 = (TObject*) iter.Next()) != NULL; ) {
1596 
1597  const TString tag(p1->GetName());
1598 
1599  if (tag.Contains(regexp)) {
1600  return p1;
1601  }
1602  }
1603 
1604  return NULL;
1605  }
TPaveText * p1
Auxiliary data structure to list files in directory.
Definition: JFilesystem.hh:20
Definition: JRoot.hh:19

◆ getFunction() [1/3]

TF1* JGIZMO::getFunction ( TH1 *  h1,
const char *const  fcn 
)
inline

Get function.

Parameters
h1histogram
fcnfunction name
Returns
pointer to function (maybe NULL)

Definition at line 1615 of file JGizmoToolkit.hh.

1616  {
1617  return (TF1*) getObject(h1->GetListOfFunctions(), fcn);
1618  }
TObject * getObject(TList *ls, const char *const name)
Get first object of which name matches given reguar expression.

◆ getFunction() [2/3]

TF1* JGIZMO::getFunction ( TGraph *  g1,
const char *const  fcn 
)
inline

Get function.

Parameters
g1graph
fcnfunction name
Returns
pointer to function (maybe NULL)

Definition at line 1628 of file JGizmoToolkit.hh.

1629  {
1630  return (TF1*) getObject(g1->GetListOfFunctions(), fcn);
1631  }

◆ getFunction() [3/3]

TF1* JGIZMO::getFunction ( TGraph2D *  g2,
const char *const  fcn 
)
inline

Get function.

Parameters
g2graph
fcnfunction name
Returns
pointer to function (maybe NULL)

Definition at line 1641 of file JGizmoToolkit.hh.

1642  {
1643  return (TF1*) getObject(g2->GetListOfFunctions(), fcn);
1644  }

Variable Documentation

◆ TIMESTAMP

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

◆ LABEL_TERMINATOR

const char JGIZMO::LABEL_TERMINATOR = '&'
static

label terminator

Definition at line 23 of file JRootObject.hh.