Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
TDirectory * getDirectory (const JRootObjectID &id)
 Get TDirectory pointer.
 
TObjectgetObject (const JRootObjectID &id)
 Get first TObject with given identifier.
 
bool isTAttLine (const TObject *object)
 Get drawing option of object.
 
bool isTAttFill (const TObject *object)
 Get drawing option of object.
 
Double_t getResult (const TString &text, TObject *object=NULL)
 Get result of given textual formula.
 
Double_t getResult (const std::string &text, TObject *object=NULL)
 Get result of given textual formula.
 
int getParameter (const std::string &text)
 Get parameter number from text string.
 
Double_t getValue (const std::string &text, TObject *object=NULL)
 Get parameter value from text string.
 
Double_t getValue (const std::string &text, const int index)
 Get parameter value from text string.
 
void setLogarithmic (TAxis *axis)
 Make histogram axis logarithmic (e.g. after using log10()).
 
TString getLogarithmic (const TString &formula, const char parameter)
 Make given parameter in formula logarithmic (e.g. after using log10()).
 
void copy (const TF1 &from, TF1 &to)
 Copy function parameters.
 
void copy (const TF2 &from, TF2 &to)
 Copy function parameters.
 
template<class T >
void setLogarithmicX (TList *list)
 Make x-axis of objects in list logarithmic (e.g. after using log10()).
 
template<class T >
void setLogarithmicY (TList *list)
 Make y-axis of objects in list logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TF1 *f1)
 Make x-axis of given function logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TF1 *f1)
 Make y-axis of given function logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TF2 *f2)
 Make x-axis of given function logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TF2 *f2)
 Make y-axis of given function logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TH1 *h1)
 Make x-axis and associated functions of given histogram logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TH1 *h1)
 Make y-axis and associated functions of given histogram logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TH2 *h2)
 Make x-axis and associated functions of given histogram logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TH2 *h2)
 Make y-axis and associated functions of given histogram logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TGraph *g1)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TGraph *g1)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TGraphErrors *g1)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TGraphErrors *g1)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TGraph2D *g2)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TGraph2D *g2)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TGraph2DErrors *g2)
 Make x-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TGraph2DErrors *g2)
 Make y-axis and associated functions of given graph logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TMultiGraph *gn)
 Make x-axis of given multi-graph logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TMultiGraph *gn)
 Make y-axis of given multi-graph logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TLine *line)
 Make x-axis of given line logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TLine *line)
 Make y-axis of given line logarithmic (e.g. after using log10()).
 
void setLogarithmicX (TEllipse *ellipse)
 Make x-axis of given ellipse logarithmic (e.g. after using log10()).
 
void setLogarithmicY (TEllipse *ellipse)
 Make y-axis of given ellipse logarithmic (e.g. after using log10()).
 
double convertToCDF (TH1 &h1, const bool reverse=false)
 Convert 1D histogram to CDF.
 
void convertToPDF (TH1 &h1, const std::string &option="NW", const double factor=1.0)
 Convert 1D histogram to PDF.
 
void convertToPDF (TH2 &h2, const std::string &option="NXYW", const double factor=1.0)
 Convert 2D histogram to PDF.
 
void convertToPDF (TH3 &h3, const std::string &option="NXYW", const double factor=1.0)
 Convert 3D histogram to PDF.
 
void setLimits (TGraph &g1)
 Set limits of TGraph.
 
void setLimits (TGraph2D &g2)
 Set limits of TGraph2D.
 
void setRange (double &xmin, double &xmax, const bool logx)
 Set axis range.
 
void setAxisLabels (TAxis *axis, const JModuleAddressMap &memo)
 Set axis with PMT address labels.
 
void setAxisLabels (TH1 &h1, const std::string axis, const JModuleAddressMap &memo)
 Set axis labels with PMT addresses.
 
bool isTObject (const TKey *key)
 Check if given key corresponds to a TObject.
 
TObjectgetObject (TList *ls, const char *const name)
 Get first object of which name matches given reguar expression.
 
TF1 * getFunction (TH1 *h1, const char *const fcn)
 Get function.
 
TF1 * getFunction (TGraph *g1, const char *const fcn)
 Get function.
 
TF1 * getFunction (TGraph2D *g2, const char *const fcn)
 Get function.
 

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.
 
static const char LABEL_TERMINATOR = '&'
 label terminator
 

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 }

◆ 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 }
TFile * getFile(const std::string &file_name, const std::string &option="exist")
Get TFile pointer corresponding to give file name.

◆ 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 }
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.

◆ 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 return false;
260 }
261 }
262
263 return true;
264 }
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 273 of file JGizmoToolkit.hh.

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

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

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

374 {
375 return getResult(TString(text.c_str()), object);
376 }
Double_t getResult(const TString &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 387 of file JGizmoToolkit.hh.

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

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

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

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

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

◆ setLogarithmic()

void JGIZMO::setLogarithmic ( TAxis * axis)
inline

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

Parameters
axisaxis

Definition at line 476 of file JGizmoToolkit.hh.

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

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

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

◆ copy() [1/2]

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

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 552 of file JGizmoToolkit.hh.

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

◆ copy() [2/2]

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

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 570 of file JGizmoToolkit.hh.

571 {
572 copy(static_cast<const TF1&>(from), static_cast<TF1&>(to));
573
574 to.SetNpy(from.GetNpy());
575 }

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

1014 {
1015 for (TIter i(list); T* p = dynamic_cast<T*>(i.Next()); ) {
1016 setLogarithmicX(p);
1017 }
1018 }
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()).

◆ setLogarithmicY() [1/12]

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

1028 {
1029 for (TIter i(list); T* p = dynamic_cast<T*>(i.Next()); ) {
1030 setLogarithmicY(p);
1031 }
1032 }
void setLogarithmicY(TList *list)
Make y-axis of objects in list 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 601 of file JGizmoToolkit.hh.

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

◆ setLogarithmicY() [2/12]

void JGIZMO::setLogarithmicY ( TF1 * f1)
inline

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

Parameters
f1function

Definition at line 622 of file JGizmoToolkit.hh.

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

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

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

◆ setLogarithmicY() [3/12]

void JGIZMO::setLogarithmicY ( TF2 * f2)
inline

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

Parameters
f2function

Definition at line 675 of file JGizmoToolkit.hh.

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

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

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

◆ setLogarithmicY() [4/12]

void JGIZMO::setLogarithmicY ( TH1 * h1)
inline

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

Parameters
h1histogram

Definition at line 719 of file JGizmoToolkit.hh.

720 {
721 if (h1 != NULL) {
722
723 setLogarithmicY<TF1>(h1->GetListOfFunctions());
724
725 for (Int_t ix = 1; ix <= h1->GetXaxis()->GetNbins(); ++ix) {
726
727 const Double_t y = h1->GetBinContent(ix);
728
729 h1->SetBinContent(ix, pow(10.0,y));
730 }
731 }
732 }

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

741 {
742 if (h2 != NULL) {
743
744 setLogarithmicX<TF2>(h2->GetListOfFunctions());
745
746 setLogarithmic(h2->GetXaxis());
747 }
748 }

◆ setLogarithmicY() [5/12]

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

757 {
758 if (h2 != NULL) {
759
760 setLogarithmicY<TF2>(h2->GetListOfFunctions());
761
762 setLogarithmic(h2->GetYaxis());
763 }
764 }

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

773 {
774 if (g1 != NULL) {
775
776 setLogarithmicX<TF1>(g1->GetListOfFunctions());
777
778 for (Int_t i = 0; i != g1->GetN(); ++i) {
779 g1->GetX()[i] = pow(10.0, g1->GetX()[i]);
780 }
781
782 setLogarithmic(g1->GetXaxis());
783 }
784 }

◆ setLogarithmicY() [6/12]

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

793 {
794 if (g1 != NULL) {
795
796 setLogarithmicY<TF1>(g1->GetListOfFunctions());
797
798 for (Int_t i = 0; i != g1->GetN(); ++i) {
799 g1->GetY()[i] = pow(10.0, g1->GetY()[i]);
800 }
801
802 setLogarithmic(g1->GetYaxis());
803 }
804 }

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

813 {
814 if (g1 != NULL) {
815
816 setLogarithmicX<TF1>(g1->GetListOfFunctions());
817
818 for (Int_t i = 0; i != g1->GetN(); ++i) {
819 g1->GetEX()[i] = pow(10.0, g1->GetX()[i] + g1->GetEX()[i]) - pow(10.0, g1->GetX()[i]);
820 g1->GetX() [i] = pow(10.0, g1->GetX()[i]);
821 }
822
823 setLogarithmic(g1->GetXaxis());
824 }
825 }

◆ setLogarithmicY() [7/12]

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

834 {
835 if (g1 != NULL) {
836
837 setLogarithmicY<TF1>(g1->GetListOfFunctions());
838
839 for (Int_t i = 0; i != g1->GetN(); ++i) {
840 g1->GetEY()[i] = pow(10.0, g1->GetY()[i] + g1->GetEY()[i]) - pow(10.0, g1->GetY()[i]);
841 g1->GetY() [i] = pow(10.0, g1->GetY()[i]);
842 }
843
844 setLogarithmic(g1->GetYaxis());
845 }
846 }

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

855 {
856 if (g2 != NULL) {
857
858 setLogarithmicX<TF2>(g2->GetListOfFunctions());
859
860 for (Int_t i = 0; i != g2->GetN(); ++i) {
861 g2->GetX()[i] = pow(10.0, g2->GetX()[i]);
862 }
863
864 setLogarithmic(g2->GetXaxis());
865 }
866 }

◆ setLogarithmicY() [8/12]

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

875 {
876 if (g2 != NULL) {
877
878 setLogarithmicY<TF2>(g2->GetListOfFunctions());
879
880 for (Int_t i = 0; i != g2->GetN(); ++i) {
881 g2->GetY()[i] = pow(10.0, g2->GetY()[i]);
882 }
883
884 setLogarithmic(g2->GetYaxis());
885 }
886 }

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

895 {
896 if (g2 != NULL) {
897
898 setLogarithmicX<TF2>(g2->GetListOfFunctions());
899
900 for (Int_t i = 0; i != g2->GetN(); ++i) {
901 g2->GetEX()[i] = pow(10.0, g2->GetX()[i] + g2->GetEX()[i]) - pow(10.0, g2->GetX()[i]);
902 g2->GetX() [i] = pow(10.0, g2->GetX()[i]);
903 }
904
905 setLogarithmic(g2->GetXaxis());
906 }
907 }

◆ setLogarithmicY() [9/12]

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

916 {
917 if (g2 != NULL) {
918
919 setLogarithmicY<TF2>(g2->GetListOfFunctions());
920
921 for (Int_t i = 0; i != g2->GetN(); ++i) {
922 g2->GetEY()[i] = pow(10.0, g2->GetY()[i] + g2->GetEY()[i]) - pow(10.0, g2->GetY()[i]);
923 g2->GetY() [i] = pow(10.0, g2->GetY()[i]);
924 }
925
926 setLogarithmic(g2->GetYaxis());
927 }
928 }

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

937 {
938 if (gn != NULL) {
939 setLogarithmicX<TGraph>(gn->GetListOfGraphs());
940 }
941 }

◆ setLogarithmicY() [10/12]

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

950 {
951 if (gn != NULL) {
952 setLogarithmicY<TGraph>(gn->GetListOfGraphs());
953 }
954 }

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

963 {
964 if (line != NULL) {
965 line->SetX1(pow(10.0, line->GetX1()));
966 line->SetX2(pow(10.0, line->GetX2()));
967 }
968 }

◆ setLogarithmicY() [11/12]

void JGIZMO::setLogarithmicY ( TLine * line)
inline

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

Parameters
lineline

Definition at line 976 of file JGizmoToolkit.hh.

977 {
978 if (line != NULL) {
979 line->SetY1(pow(10.0, line->GetY1()));
980 line->SetY2(pow(10.0, line->GetY2()));
981 }
982 }

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

991 {
992 THROW(JFunctionalException, "Operation setLogarithmicX on TEllipse not allowed.");
993 }
Exception for a functional operation.

◆ setLogarithmicY() [12/12]

void JGIZMO::setLogarithmicY ( TEllipse * ellipse)
inline

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

Parameters
ellipseellipse

Definition at line 1001 of file JGizmoToolkit.hh.

1002 {
1003 THROW(JFunctionalException, "Operation setLogarithmicY on TEllipse not allowed.");
1004 }

◆ convertToCDF()

double JGIZMO::convertToCDF ( TH1 & h1,
const bool reverse = false )
inline

Convert 1D histogram to CDF.

Parameters
h1histogram
reversereverse
Returns
integral

Definition at line 1042 of file JGizmoToolkit.hh.

1043 {
1044 using namespace std;
1045
1046 Double_t W = 0.0;
1047
1048 if (reverse) {
1049
1050 for (Int_t i = h1.GetXaxis()->GetNbins() + 1; i >= 0; --i) {
1051
1052 W += h1.GetBinContent(i);
1053
1054 h1.SetBinContent(i, W);
1055 }
1056
1057 } else {
1058
1059 for (Int_t i = 0; i <= h1.GetXaxis()->GetNbins() + 1; ++i) {
1060
1061 W += h1.GetBinContent(i);
1062
1063 h1.SetBinContent(i, W);
1064 }
1065 }
1066
1067 if (W != 0.0) {
1068 h1.Scale(1.0/W);
1069 }
1070
1071 return W;
1072 }

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

1088 {
1089 using namespace std;
1090
1091 const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1092 const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1093 const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1094
1095 Double_t W = 1.0;
1096
1097 if (normalise) {
1098
1099 W = 0.0;
1100
1101 for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
1102 W += h1.GetBinContent(i);
1103 }
1104 }
1105
1106 if (W != 0.0) {
1107
1108 for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
1109
1110 const Double_t w = W * (bin_width ? h1.GetXaxis()->GetBinWidth(i) : 1.0);
1111
1112 h1.SetBinContent(i, h1.GetBinContent(i) * factor / w);
1113
1114 if (use_error) {
1115 h1.SetBinError(i, h1.GetBinError(i) * factor / w);
1116 }
1117 }
1118 }
1119 }

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

1137 {
1138 using namespace std;
1139
1140 const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1141 const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
1142 const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
1143 const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1144 const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1145
1146 Double_t W = 1.0;
1147
1148 if (X && Y) {
1149
1150 if (normalise) {
1151
1152 W = 0.0;
1153
1154 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1155 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1156 W += h2.GetBinContent(ix,iy);
1157 }
1158 }
1159 }
1160
1161 if (W != 0.0) {
1162
1163 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1164 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1165
1166 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1167
1168 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1169
1170 if (use_error) {
1171 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1172 }
1173 }
1174 }
1175 }
1176
1177 } else if (X) {
1178
1179 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1180
1181 if (normalise) {
1182
1183 W = 0.0;
1184
1185 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1186 W += h2.GetBinContent(ix,iy);
1187 }
1188 }
1189
1190 if (W != 0.0) {
1191
1192 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1193
1194 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1195
1196 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1197
1198 if (use_error) {
1199 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1200 }
1201 }
1202 }
1203 }
1204
1205 } else if (Y) {
1206
1207 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1208
1209 if (normalise) {
1210
1211 W = 0.0;
1212
1213 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1214 W += h2.GetBinContent(ix,iy);
1215 }
1216 }
1217
1218 if (W != 0.0) {
1219
1220 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1221
1222 const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1223
1224 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1225
1226 if (use_error) {
1227 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1228 }
1229 }
1230 }
1231 }
1232 }
1233 }

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

1252 {
1253 using namespace std;
1254
1255 const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
1256 const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
1257 const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
1258 const bool Z = (option.find('Z') != string::npos || option.find('z') != string::npos);
1259 const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
1260 const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
1261
1262 Double_t W = 1.0;
1263
1264 if (X && Y && Z) {
1265
1266 if (normalise) {
1267
1268 W = 0.0;
1269
1270 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1271 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1272 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1273 W += h3.GetBinContent(ix,iy,iz);
1274 }
1275 }
1276 }
1277 }
1278
1279 if (W != 0.0) {
1280
1281 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1282 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1283 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1284
1285 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1286
1287 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1288
1289 if (use_error) {
1290 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1291 }
1292 }
1293 }
1294 }
1295 }
1296
1297 } else if (X && Z) {
1298
1299 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1300
1301 if (normalise) {
1302
1303 W = 0.0;
1304
1305 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1306 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1307 W += h3.GetBinContent(ix,iy,iz);
1308 }
1309 }
1310 }
1311
1312 if (W != 0.0) {
1313
1314 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1315 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1316
1317 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1318
1319 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1320
1321 if (use_error) {
1322 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1323 }
1324 }
1325 }
1326 }
1327 }
1328
1329 } else if (Y && Z) {
1330
1331 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1332
1333 if (normalise) {
1334
1335 W = 0.0;
1336
1337 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1338 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1339 W += h3.GetBinContent(ix,iy,iz);
1340 }
1341 }
1342 }
1343
1344 if (W != 0.0) {
1345
1346 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1347 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1348
1349 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1350
1351 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1352
1353 if (use_error) {
1354 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1355 }
1356 }
1357 }
1358 }
1359 }
1360
1361 } else if (X && Y) {
1362
1363 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1364
1365 if (normalise) {
1366
1367 W = 0.0;
1368
1369 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1370 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1371 W += h3.GetBinContent(ix,iy,iz);
1372 }
1373 }
1374 }
1375
1376 if (W != 0.0) {
1377
1378 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1379 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1380
1381 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1382
1383 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1384
1385 if (use_error) {
1386 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1387 }
1388 }
1389 }
1390 }
1391 }
1392
1393 } else if (X) {
1394
1395 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1396 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1397
1398 if (normalise) {
1399
1400 W = 0.0;
1401
1402 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1403 W += h3.GetBinContent(ix,iy,iz);
1404 }
1405 }
1406
1407 if (W != 0.0) {
1408
1409 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1410
1411 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) : 1.0);
1412
1413 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1414
1415 if (use_error) {
1416 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1417 }
1418 }
1419 }
1420 }
1421 }
1422
1423 } else if (Y) {
1424
1425 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1426 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1427
1428 if (normalise) {
1429
1430 W = 0.0;
1431
1432 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1433 W += h3.GetBinContent(ix,iy,iz);
1434 }
1435 }
1436
1437 if (W != 0.0) {
1438
1439 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1440
1441 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1442
1443 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1444
1445 if (use_error) {
1446 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1447 }
1448 }
1449 }
1450 }
1451 }
1452
1453 } else if (Z) {
1454
1455 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1456 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1457
1458 if (normalise) {
1459
1460 W = 0.0;
1461
1462 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1463 W += h3.GetBinContent(ix,iy,iz);
1464 }
1465 }
1466
1467 if (W != 0.0) {
1468
1469 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1470
1471 const Double_t w = W * (bin_width ? h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1472
1473 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1474
1475 if (use_error) {
1476 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1477 }
1478 }
1479 }
1480 }
1481 }
1482 }
1483 }

◆ setLimits() [1/2]

void JGIZMO::setLimits ( TGraph & g1)
inline

Set limits of TGraph.

Parameters
g1graph

Definition at line 1491 of file JGizmoToolkit.hh.

1492 {
1493 using namespace std;
1494
1495 Double_t ymin = numeric_limits<Double_t>::max();
1496 Double_t ymax = numeric_limits<Double_t>::lowest();
1497
1498 for (Int_t i = 0; i != g1.GetN(); ++i) {
1499
1500 const Double_t y = g1.GetY()[i];
1501
1502 if (y > ymax) { ymax = y; }
1503 if (y < ymin) { ymin = y; }
1504 }
1505
1506 g1.SetMinimum(ymin);
1507 g1.SetMaximum(ymax);
1508 }

◆ setLimits() [2/2]

void JGIZMO::setLimits ( TGraph2D & g2)
inline

Set limits of TGraph2D.

Parameters
g2graph

Definition at line 1516 of file JGizmoToolkit.hh.

1517 {
1518 using namespace std;
1519
1520 Double_t zmin = numeric_limits<Double_t>::max();
1521 Double_t zmax = numeric_limits<Double_t>::lowest();
1522
1523 for (Int_t i = 0; i != g2.GetN(); ++i) {
1524
1525 const Double_t z = g2.GetZ()[i];
1526
1527 if (z > zmax) { zmax = z; }
1528 if (z < zmin) { zmin = z; }
1529 }
1530
1531 g2.SetMinimum(zmin);
1532 g2.SetMaximum(zmax);
1533 }

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

1546 {
1547 if (logx) {
1548 xmin = log(xmin);
1549 xmax = log(xmax);
1550 }
1551
1552 double dx = (xmax - xmin) * 0.1;
1553
1554 if (logx || xmin >= dx || xmin < 0.0)
1555 xmin -= dx;
1556 else
1557 xmin = 0.0;
1558
1559 xmax += dx;
1560
1561 if (logx) {
1562 xmin = exp(xmin);
1563 xmax = exp(xmax);
1564 }
1565 }

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

1583 {
1584 using namespace JPP;
1585
1586 if (axis->GetNbins() == (int) memo.size()) {
1587
1588 for (int i = 0; i != axis->GetNbins(); ++i) {
1589
1590 const JPMTPhysicalAddress& address = memo[i];
1591
1592 axis->SetBinLabel(i + 1, address.toString().c_str());
1593 }
1594
1595 } else {
1596
1597 THROW(JValueOutOfRange, "Number of bins " << axis->GetNbins() << " != " << memo.size());
1598 }
1599 }
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.
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 1613 of file JGizmoToolkit.hh.

1614 {
1615 using namespace JPP;
1616
1617 TAxis* pax = NULL;
1618
1619 if (axis == "x" || axis == "X")
1620 pax = h1.GetXaxis();
1621 else if (axis == "y" || axis == "Y")
1622 pax = h1.GetYaxis();
1623 else if (axis == "z" || axis == "Z")
1624 pax = h1.GetZaxis();
1625 else
1626 THROW(JValueOutOfRange, "Invalid axis " << axis);
1627
1628 if (pax->GetNbins() == (int) memo.size()) {
1629
1630 for (int i = 0; i != pax->GetNbins(); ++i) {
1631
1632 const JPMTPhysicalAddress& address = memo.getAddressTranslator(i);
1633
1634 pax->SetBinLabel(i + 1, address.toString().c_str());
1635 }
1636
1637 h1.LabelsOption("a", axis.c_str()); // sort labels
1638
1639 } else {
1640
1641 THROW(JValueOutOfRange, "Number of bins " << pax->GetNbins() << " != " << memo.size());
1642 }
1643 }
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 1652 of file JGizmoToolkit.hh.

1653 {
1654 return (key != NULL && TClass::GetClass(key->GetClassName())->IsTObject());
1655 }

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

1666 {
1667 const TRegexp regexp(name);
1668
1669 TIter iter(ls);
1670
1671 for (TObject* p1; (p1 = (TObject*) iter.Next()) != NULL; ) {
1672
1673 const TString tag(p1->GetName());
1674
1675 if (tag.Contains(regexp)) {
1676 return p1;
1677 }
1678 }
1679
1680 return NULL;
1681 }
TPaveText * p1

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

1692 {
1693 return (TF1*) getObject(h1->GetListOfFunctions(), fcn);
1694 }
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.

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

1705 {
1706 return (TF1*) getObject(g1->GetListOfFunctions(), fcn);
1707 }

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

1718 {
1719 return (TF1*) getObject(g2->GetListOfFunctions(), fcn);
1720 }

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.