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

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

Classes

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

Functions

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

Variables

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

Detailed Description

Auxiliary applications for use of ROOT and more.

Author
mdejong

Function Documentation

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

Get TFile pointer corresponding to give file name.

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

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

Definition at line 97 of file JGizmoToolkit.hh.

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

Get TDirectory pointer.

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

Parameters
ididentifier
Returns
pointer to TDirectory

Definition at line 130 of file JGizmoToolkit.hh.

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

Get first TObject with given identifier.

Parameters
ididentifier
Returns
pointer to TObject (or NULL)

Definition at line 151 of file JGizmoToolkit.hh.

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

Get drawing option of TH1.

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

Definition at line 183 of file JGizmoToolkit.hh.

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

Get result of given textual formula.

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

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

Definition at line 222 of file JGizmoToolkit.hh.

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

Get result of given textual formula.

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

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

Definition at line 295 of file JGizmoToolkit.hh.

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

Get parameter number from text string.

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

Parameters
texttext
Returns
parameter number

Definition at line 309 of file JGizmoToolkit.hh.

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

Get parameter value from text string.

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

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

Definition at line 340 of file JGizmoToolkit.hh.

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

Get parameter value from text string.

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

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

will return 2.0.

Parameters
texttext
indexindex
Returns
value

Definition at line 368 of file JGizmoToolkit.hh.

369  {
370  using namespace std;
371 
372  const char* regexp("=.*");
373 
374  TString buffer(text.c_str());
375 
376  buffer = buffer(TRegexp(regexp));
377  buffer = buffer(1, buffer.Length() - 1);
378 
379 
380  istringstream is((std::string(buffer)));
381 
382  Double_t value;
383 
384  for (int i = index; is >> value && i > 0; --i) {}
385 
386  if (is)
387  return value;
388  else
389  THROW(JParseError, "Text des not contain a number at given position " << buffer << ' ' << index);
390  }
char text[TEXT_SIZE]
Definition: elog.cc:72
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
is
Definition: JDAQCHSM.chsm:167
void JGIZMO::setLogarithmic ( TAxis *  axis)
inline

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

Parameters
axisaxis

Definition at line 398 of file JGizmoToolkit.hh.

399  {
400  if (axis != NULL) {
401 
402  const Int_t first = axis->GetFirst();
403  const Int_t last = axis->GetLast();
404 
405  const Double_t xmin = axis->GetBinLowEdge(first);
406  const Double_t xmax = axis->GetBinLowEdge(last) + axis->GetBinWidth(last);
407 
408  const Int_t N = axis->GetNbins();
409  Double_t buffer[N+1];
410 
411  buffer[0] = TMath::Power(10.0, axis->GetBinLowEdge(1));
412 
413  for (Int_t i = 1; i <= N; ++i) {
414  buffer[i] = TMath::Power(10.0, axis->GetBinLowEdge(i) + axis->GetBinWidth(i));
415  }
416 
417  axis->Set(N, buffer);
418 
419  if (axis->TestBit(TAxis::kAxisRange)) {
420  axis->SetRangeUser(TMath::Power(10.0, xmin), TMath::Power(10.0, xmax));
421  }
422  }
423  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
TString JGIZMO::getLogarithmic ( const TString &  formula,
const char  parameter 
)
inline

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

Parameters
formulaformula
parameterparameter
Returns
formula

Definition at line 433 of file JGizmoToolkit.hh.

434  {
435  const TRegexp regexp[] = {
436  TString("^") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter at start of line
437  TString("[^a-zA-Z_]") + TString(parameter) + TString("[^a-zA-Z_]"), // parameter in middle of line
438  TString("[^a-zA-Z_]") + TString(parameter) + TString("$") // parameter at end of line
439  };
440 
441  const TString replacement = TString("log10(") + TString(parameter) + TString(")");
442 
443  TString buffer(formula);
444 
445  if (buffer.Length() == 1 && buffer[0] == parameter) {
446 
447  buffer = replacement;
448 
449  } else {
450 
451  for (Ssiz_t pos = 0, i; pos < buffer.Length(); pos += replacement.Length()) {
452  if ((i = buffer.Index(regexp[0], pos)) != -1) { buffer.Replace((pos = i + 0), 1, replacement); }
453  else if ((i = buffer.Index(regexp[1], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
454  else if ((i = buffer.Index(regexp[2], pos)) != -1) { buffer.Replace((pos = i + 1), 1, replacement); }
455  else { break; }
456  }
457  }
458  return buffer;
459  }
void JGIZMO::copy ( const TF1 &  from,
TF1 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 468 of file JGizmoToolkit.hh.

469  {
470  static_cast<TAttLine&> (to) = static_cast<const TAttLine&> (from);
471  static_cast<TAttFill&> (to) = static_cast<const TAttFill&> (from);
472  static_cast<TAttMarker&>(to) = static_cast<const TAttMarker&>(from);
473 
474  to.SetParameters(from.GetParameters());
475 
476  to.SetNpx(from.GetNpx());
477  }
void JGIZMO::copy ( const TF2 &  from,
TF2 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 486 of file JGizmoToolkit.hh.

487  {
488  copy(static_cast<const TF1&>(from), static_cast<TF1&>(to));
489 
490  to.SetNpy(from.GetNpy());
491  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
void JGIZMO::setLogarithmicX ( TF1 *  f1)
inline

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

Parameters
f1function

Definition at line 499 of file JGizmoToolkit.hh.

500  {
501  if (f1 != NULL) {
502 
503  TF1 fn(f1->GetName(), getLogarithmic(f1->GetExpFormula(), 'x'));
504 
505  copy(*f1, fn);
506 
507  fn.SetRange(f1->GetXmin(),
508  f1->GetXmax());
509 
510  *f1 = fn;
511 
512  f1->SetRange(TMath::Power(10.0,f1->GetXmin()),
513  TMath::Power(10.0,f1->GetXmax()));
514  }
515  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TF2 *  f2)
inline

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

Parameters
f2function

Definition at line 523 of file JGizmoToolkit.hh.

524  {
525  if (f2 != NULL) {
526 
527  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'x'));
528 
529  copy(*f2, fn);
530 
531  fn.SetRange(f2->GetXmin(),
532  f2->GetYmin(),
533  f2->GetXmax(),
534  f2->GetYmax());
535 
536  *f2 = fn;
537 
538  f2->SetRange(TMath::Power(10.0,f2->GetXmin()),
539  f2->GetYmin(),
540  TMath::Power(10.0,f2->GetXmax()),
541  f2->GetYmax());
542  }
543  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicY ( TF2 *  f2)
inline

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

Parameters
f2function

Definition at line 551 of file JGizmoToolkit.hh.

552  {
553  if (f2 != NULL) {
554 
555  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'y'));
556 
557  copy(*f2, fn);
558 
559  fn.SetRange(f2->GetXmin(),
560  f2->GetYmin(),
561  f2->GetXmax(),
562  f2->GetYmax());
563 
564  *f2 = fn;
565 
566  f2->SetRange(f2->GetXmin(),
567  TMath::Power(10.0,f2->GetYmin()),
568  f2->GetXmax(),
569  TMath::Power(10.0,f2->GetYmax()));
570  }
571  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
TString getLogarithmic(const TString &formula, const char parameter)
Make given parameter in formula logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TH1 *  h1)
inline

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

Parameters
h1histogram

Definition at line 579 of file JGizmoToolkit.hh.

580  {
581  if (h1 != NULL) {
582 
583  for (TIter iter(h1->GetListOfFunctions()); TF1* f1 = dynamic_cast<TF1*>(iter.Next()); ) {
584  setLogarithmicX(f1);
585  }
586 
587  setLogarithmic(h1->GetXaxis());
588  }
589  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TH2 *  h2)
inline

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

Parameters
h2histogram

Definition at line 597 of file JGizmoToolkit.hh.

598  {
599  using namespace std;
600 
601  if (h2 != NULL) {
602 
603  for (TIter iter(h2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
604  setLogarithmicX(f2);
605  }
606 
607  setLogarithmic(h2->GetXaxis());
608  }
609  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicY ( TH2 *  h2)
inline

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

Parameters
h2histogram

Definition at line 617 of file JGizmoToolkit.hh.

618  {
619  if (h2 != NULL) {
620 
621  for (TIter iter(h2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
622  setLogarithmicY(f2);
623  }
624 
625  setLogarithmic(h2->GetYaxis());
626  }
627  }
void setLogarithmic(TAxis *axis)
Make histogram axis logarithmic (e.g. after filling with log10()).
void setLogarithmicY(TF2 *f2)
Make parameter y of function logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TGraph *  g1)
inline

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

Parameters
g1graph

Definition at line 635 of file JGizmoToolkit.hh.

636  {
637  if (g1 != NULL) {
638 
639  for (TIter iter(g1->GetListOfFunctions()); TF1* f1 = dynamic_cast<TF1*>(iter.Next()); ) {
640  setLogarithmicX(f1);
641  }
642 
643  for (Int_t i = 0; i != g1->GetN(); ++i) {
644  g1->GetX()[i] = pow(10.0, g1->GetX()[i]);
645  }
646  }
647  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JGIZMO::setLogarithmicX ( TGraph2D *  g2)
inline

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

Parameters
g2graph

Definition at line 655 of file JGizmoToolkit.hh.

656  {
657  if (g2 != NULL) {
658 
659  for (TIter iter(g2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
660  setLogarithmicX(f2);
661  }
662 
663  for (Int_t i = 0; i != g2->GetN(); ++i) {
664  g2->GetX()[i] = pow(10.0, g2->GetX()[i]);
665  }
666  }
667  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void JGIZMO::setLogarithmicY ( TGraph2D *  g2)
inline

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

Parameters
g2graph

Definition at line 675 of file JGizmoToolkit.hh.

676  {
677  if (g2 != NULL) {
678 
679  for (TIter iter(g2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
680  setLogarithmicY(f2);
681  }
682 
683  for (Int_t i = 0; i != g2->GetN(); ++i) {
684  g2->GetY()[i] = pow(10.0, g2->GetY()[i]);
685  }
686  }
687  }
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
void setLogarithmicY(TF2 *f2)
Make parameter y of function logarithmic (e.g. after filling with log10()).
void JGIZMO::setLogarithmicX ( TMultiGraph *  m1)
inline

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

Parameters
m1multi graph

Definition at line 695 of file JGizmoToolkit.hh.

696  {
697  if (m1 != NULL) {
698 
699  for (TIter i1(m1->GetListOfGraphs()); TGraph* g1 = dynamic_cast<TGraph*>(i1()); ) {
700  setLogarithmicX(g1);
701  }
702  }
703  }
void setLogarithmicX(TF1 *f1)
Make parameter x of function logarithmic (e.g. after filling with log10()).
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JGIZMO::convertToPDF ( TH1 &  h1,
const std::string &  option = "NW",
const double  factor = 1.0 
)
inline

Convert 1D histogram to PDF.

Possible options are:

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

Definition at line 718 of file JGizmoToolkit.hh.

719  {
720  using namespace std;
721 
722  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
723  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
724  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
725 
726  Double_t W = 1.0;
727 
728  if (normalise) {
729 
730  W = 0.0;
731 
732  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
733  W += h1.GetBinContent(i);
734  }
735  }
736 
737  if (W != 0.0) {
738 
739  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
740 
741  const Double_t w = W * (bin_width ? h1.GetXaxis()->GetBinWidth(i) : 1.0);
742 
743  h1.SetBinContent(i, h1.GetBinContent(i) * factor / w);
744 
745  if (use_error) {
746  h1.SetBinError(i, h1.GetBinError(i) * factor / w);
747  }
748  }
749  }
750  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
void JGIZMO::convertToPDF ( TH2 &  h2,
const std::string &  option = "NXYW",
const double  factor = 1.0 
)
inline

Convert 2D histogram to PDF.

Possible options are:

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

Definition at line 767 of file JGizmoToolkit.hh.

768  {
769  using namespace std;
770 
771  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
772  const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
773  const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
774  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
775  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
776 
777  Double_t W = 1.0;
778 
779  if (X && Y) {
780 
781  if (normalise) {
782 
783  W = 0.0;
784 
785  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
786  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
787  W += h2.GetBinContent(ix,iy);
788  }
789  }
790  }
791 
792  if (W != 0.0) {
793 
794  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
795  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
796 
797  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
798 
799  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
800 
801  if (use_error) {
802  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
803  }
804  }
805  }
806  }
807 
808  } else if (X) {
809 
810  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
811 
812  if (normalise) {
813 
814  W = 0.0;
815 
816  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
817  W += h2.GetBinContent(ix,iy);
818  }
819  }
820 
821  if (W != 0.0) {
822 
823  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
824 
825  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
826 
827  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
828 
829  if (use_error) {
830  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
831  }
832  }
833  }
834  }
835 
836  } else if (Y) {
837 
838  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
839 
840  if (normalise) {
841 
842  W = 0.0;
843 
844  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
845  W += h2.GetBinContent(ix,iy);
846  }
847  }
848 
849  if (W != 0.0) {
850 
851  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
852 
853  const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
854 
855  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
856 
857  if (use_error) {
858  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
859  }
860  }
861  }
862  }
863  }
864  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
then break fi done getCenter read X Y Z let X
void JGIZMO::setLimits ( TGraph &  g1)
inline

Set limits of TGraph.

Parameters
g1graph

Definition at line 872 of file JGizmoToolkit.hh.

873  {
874  using namespace std;
875 
876  Double_t ymin = numeric_limits<Double_t>::max();
877  Double_t ymax = numeric_limits<Double_t>::lowest();
878 
879  for (Int_t i = 0; i != g1.GetN(); ++i) {
880 
881  const Double_t y = g1.GetY()[i];
882 
883  if (y > ymax) { ymax = y; }
884  if (y < ymin) { ymin = y; }
885  }
886 
887  g1.SetMinimum(ymin);
888  g1.SetMaximum(ymax);
889  }
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JGIZMO::setLimits ( TGraph2D &  g2)
inline

Set limits of TGraph2D.

Parameters
g2graph

Definition at line 897 of file JGizmoToolkit.hh.

898  {
899  using namespace std;
900 
901  Double_t zmin = numeric_limits<Double_t>::max();
902  Double_t zmax = numeric_limits<Double_t>::lowest();
903 
904  for (Int_t i = 0; i != g2.GetN(); ++i) {
905 
906  const Double_t z = g2.GetZ()[i];
907 
908  if (z > zmax) { zmax = z; }
909  if (z < zmin) { zmin = z; }
910  }
911 
912  g2.SetMinimum(zmin);
913  g2.SetMaximum(zmax);
914  }
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 924 of file JGizmoToolkit.hh.

927  {
928  if (logx) {
929  xmin = log(xmin);
930  xmax = log(xmax);
931  }
932 
933  double dx = (xmax - xmin) * 0.1;
934 
935  if (xmin > dx || xmin < 0.0)
936  xmin -= dx;
937  else
938  xmin = 0.0;
939 
940  xmax += dx;
941 
942  if (logx) {
943  xmin = exp(xmin);
944  xmax = exp(xmax);
945  }
946  }
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))*exp(-0.5 *(y-[1])*(y-[1])/([2]*[2]))" JF2 -o $WORKDIR/f2.root -F "$FORMULA" -@ "p0
void JGIZMO::setAxisLabels ( TAxis *  axis,
const JModuleAddressMap &  memo 
)
inline

Set axis with PMT address labels.

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

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

Parameters
axisaxis
memomodule address map

Definition at line 963 of file JGizmoToolkit.hh.

964  {
965  using namespace JPP;
966 
967  if (axis->GetNbins() == (int) memo.size()) {
968 
969  for (int i = 0; i != axis->GetNbins(); ++i) {
970 
971  const JPMTPhysicalAddress& address = memo[i];
972 
973  axis->SetBinLabel(i + 1, address.toString().c_str());
974  }
975 
976  } else {
977 
978  THROW(JValueOutOfRange, "Number of bins " << axis->GetNbins() << " != " << memo.size());
979  }
980  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
void JGIZMO::setAxisLabels ( TH1 &  h1,
const std::string  axis,
const JModuleAddressMap &  memo 
)
inline

Set axis labels with PMT addresses.

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

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

Definition at line 994 of file JGizmoToolkit.hh.

995  {
996  using namespace JPP;
997 
998  TAxis* pax = NULL;
999 
1000  if (axis == "x" || axis == "X")
1001  pax = h1.GetXaxis();
1002  else if (axis == "y" || axis == "Y")
1003  pax = h1.GetYaxis();
1004  else if (axis == "z" || axis == "Z")
1005  pax = h1.GetZaxis();
1006  else
1007  THROW(JValueOutOfRange, "Invalid axis " << axis);
1008 
1009  if (pax->GetNbins() == (int) memo.size()) {
1010 
1011  for (int i = 0; i != pax->GetNbins(); ++i) {
1012 
1013  const JPMTPhysicalAddress& address = memo.getAddressTranslator(i);
1014 
1015  pax->SetBinLabel(i + 1, address.toString().c_str());
1016  }
1017 
1018  h1.LabelsOption("a", axis.c_str()); // sort labels
1019 
1020  } else {
1021 
1022  THROW(JValueOutOfRange, "Number of bins " << pax->GetNbins() << " != " << memo.size());
1023  }
1024  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69

Variable Documentation

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

Time stamp of earliest UTC time.

Definition at line 84 of file JGizmoToolkit.hh.

const char JGIZMO::LABEL_TERMINATOR = '&'
static

label terminator

Definition at line 23 of file JRootObject.hh.