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

99  {
100  using namespace std;
101 
102  gErrorIgnoreLevel = kError;
103 
104  static map<string, TFile*> zmap;
105 
106  map<string, TFile*>::iterator i = zmap.find(file_name);
107 
108  if (i == zmap.end() || i->second == NULL || !i->second->IsOpen()) {
109 
110  TFile* file = TFile::Open(file_name.c_str(), option.c_str());
111 
112  zmap[file_name] = file;
113 
114  return file;
115 
116  } else {
117 
118  return i->second;
119  }
120  }
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 131 of file JGizmoToolkit.hh.

132  {
133  TFile* in = getFile(id.getFilename().c_str(), "exist");
134 
135  if (in == NULL || !in->IsOpen()) {
136  return NULL;
137  }
138 
139  if (id.getDirectory() != "")
140  return in->GetDirectory(id.getDirectory());
141  else
142  return in;
143  }
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 152 of file JGizmoToolkit.hh.

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

185  {
186  {
187  const TH1* h1 = dynamic_cast<const TH1*>(object);
188 
189  if (h1 != NULL) {
190 
191  if (h1->GetSumw2N()) {
192  for (Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
193  if (h1->GetBinError(i) != 0.0) {
194  return false;
195  }
196  }
197  }
198  }
199  }
200  {
201  const TGraphErrors* g1 = dynamic_cast<const TGraphErrors*>(object);
202 
203  if (g1 != NULL) {
204 
205  for (Int_t i = 0; i != g1->GetN(); ++i) {
206  if (g1->GetEY()[i] != 0.0) {
207  return false;
208  }
209  }
210 
211  return g1->GetN() > 1;
212  }
213  }
214  {
215  const TGraph* g1 = dynamic_cast<const TGraph*>(object);
216 
217  if (g1 != NULL) {
218  return g1->GetN() > 1;
219  }
220  }
221 
222  return true;
223  }
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
Double_t JGIZMO::getResult ( const TString &  text,
TObject object = NULL 
)
inline

Get result of given textual formula.

The formula may contain names of member methods of the object pointed to.
These methods 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 240 of file JGizmoToolkit.hh.

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

314  {
315  return getResult(TString(text.c_str()), object);
316  }
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 327 of file JGizmoToolkit.hh.

328  {
329  const char* regexp("p[0-9]* *=");
330 
331  TString buffer(text.c_str());
332 
333  buffer = buffer(TRegexp(regexp));
334  buffer = buffer(1, buffer.Length() - 2);
335 
336  if (!buffer.IsDigit()) {
337  THROW(JParseError, "Text is not a number " << text << ' ' << regexp);
338  }
339 
340  return buffer.Atoi();
341  }
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 358 of file JGizmoToolkit.hh.

359  {
360  const char* regexp("=.*");
361 
362  TString buffer(text.c_str());
363 
364  buffer = buffer(TRegexp(regexp));
365  buffer = buffer(1, buffer.Length() - 1);
366 
367  return getResult(std::string(buffer), object);
368  }
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 386 of file JGizmoToolkit.hh.

387  {
388  using namespace std;
389 
390  const char* regexp("=.*");
391 
392  TString buffer(text.c_str());
393 
394  buffer = buffer(TRegexp(regexp));
395  buffer = buffer(1, buffer.Length() - 1);
396 
397 
398  istringstream is((std::string(buffer)));
399 
400  Double_t value;
401 
402  for (int i = index; is >> value && i > 0; --i) {}
403 
404  if (is)
405  return value;
406  else
407  THROW(JParseError, "Text des not contain a number at given position " << buffer << ' ' << index);
408  }
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 416 of file JGizmoToolkit.hh.

417  {
418  if (axis != NULL) {
419 
420  const Int_t first = axis->GetFirst();
421  const Int_t last = axis->GetLast();
422 
423  const Double_t xmin = axis->GetBinLowEdge(first);
424  const Double_t xmax = axis->GetBinLowEdge(last) + axis->GetBinWidth(last);
425 
426  const Int_t N = axis->GetNbins();
427  Double_t buffer[N+1];
428 
429  buffer[0] = TMath::Power(10.0, axis->GetBinLowEdge(1));
430 
431  for (Int_t i = 1; i <= N; ++i) {
432  buffer[i] = TMath::Power(10.0, axis->GetBinLowEdge(i) + axis->GetBinWidth(i));
433  }
434 
435  axis->Set(N, buffer);
436 
437  if (axis->TestBit(TAxis::kAxisRange)) {
438  axis->SetRangeUser(TMath::Power(10.0, xmin), TMath::Power(10.0, xmax));
439  }
440  }
441  }
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:35
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 451 of file JGizmoToolkit.hh.

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

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 486 of file JGizmoToolkit.hh.

487  {
488  static_cast<TAttLine&> (to) = static_cast<const TAttLine&> (from);
489  static_cast<TAttFill&> (to) = static_cast<const TAttFill&> (from);
490  static_cast<TAttMarker&>(to) = static_cast<const TAttMarker&>(from);
491 
492  to.SetParameters(from.GetParameters());
493 
494  to.SetNpx(from.GetNpx());
495  }
void JGIZMO::copy ( const TF2 &  from,
TF2 &  to 
)
inline

Copy function parameters.

Parameters
fromfunction
tofunction

Definition at line 504 of file JGizmoToolkit.hh.

505  {
506  copy(static_cast<const TF1&>(from), static_cast<TF1&>(to));
507 
508  to.SetNpy(from.GetNpy());
509  }
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 517 of file JGizmoToolkit.hh.

518  {
519  if (f1 != NULL) {
520 
521  TF1 fn(f1->GetName(), getLogarithmic(f1->GetExpFormula(), 'x'));
522 
523  copy(*f1, fn);
524 
525  fn.SetRange(f1->GetXmin(),
526  f1->GetXmax());
527 
528  *f1 = fn;
529 
530  f1->SetRange(TMath::Power(10.0,f1->GetXmin()),
531  TMath::Power(10.0,f1->GetXmax()));
532  }
533  }
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 541 of file JGizmoToolkit.hh.

542  {
543  if (f2 != NULL) {
544 
545  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'x'));
546 
547  copy(*f2, fn);
548 
549  fn.SetRange(f2->GetXmin(),
550  f2->GetYmin(),
551  f2->GetXmax(),
552  f2->GetYmax());
553 
554  *f2 = fn;
555 
556  f2->SetRange(TMath::Power(10.0,f2->GetXmin()),
557  f2->GetYmin(),
558  TMath::Power(10.0,f2->GetXmax()),
559  f2->GetYmax());
560  }
561  }
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 569 of file JGizmoToolkit.hh.

570  {
571  if (f2 != NULL) {
572 
573  TF2 fn(f2->GetName(), getLogarithmic(f2->GetExpFormula(), 'y'));
574 
575  copy(*f2, fn);
576 
577  fn.SetRange(f2->GetXmin(),
578  f2->GetYmin(),
579  f2->GetXmax(),
580  f2->GetYmax());
581 
582  *f2 = fn;
583 
584  f2->SetRange(f2->GetXmin(),
585  TMath::Power(10.0,f2->GetYmin()),
586  f2->GetXmax(),
587  TMath::Power(10.0,f2->GetYmax()));
588  }
589  }
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 597 of file JGizmoToolkit.hh.

598  {
599  if (h1 != NULL) {
600 
601  for (TIter iter(h1->GetListOfFunctions()); TF1* f1 = dynamic_cast<TF1*>(iter.Next()); ) {
602  setLogarithmicX(f1);
603  }
604 
605  setLogarithmic(h1->GetXaxis());
606  }
607  }
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 615 of file JGizmoToolkit.hh.

616  {
617  using namespace std;
618 
619  if (h2 != NULL) {
620 
621  for (TIter iter(h2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
622  setLogarithmicX(f2);
623  }
624 
625  setLogarithmic(h2->GetXaxis());
626  }
627  }
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 635 of file JGizmoToolkit.hh.

636  {
637  if (h2 != NULL) {
638 
639  for (TIter iter(h2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
640  setLogarithmicY(f2);
641  }
642 
643  setLogarithmic(h2->GetYaxis());
644  }
645  }
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 653 of file JGizmoToolkit.hh.

654  {
655  if (g1 != NULL) {
656 
657  for (TIter iter(g1->GetListOfFunctions()); TF1* f1 = dynamic_cast<TF1*>(iter.Next()); ) {
658  setLogarithmicX(f1);
659  }
660 
661  for (Int_t i = 0; i != g1->GetN(); ++i) {
662  g1->GetX()[i] = pow(10.0, g1->GetX()[i]);
663  }
664  }
665  }
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 673 of file JGizmoToolkit.hh.

674  {
675  if (g2 != NULL) {
676 
677  for (TIter iter(g2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
678  setLogarithmicX(f2);
679  }
680 
681  for (Int_t i = 0; i != g2->GetN(); ++i) {
682  g2->GetX()[i] = pow(10.0, g2->GetX()[i]);
683  }
684  }
685  }
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 693 of file JGizmoToolkit.hh.

694  {
695  if (g2 != NULL) {
696 
697  for (TIter iter(g2->GetListOfFunctions()); TF2* f2 = dynamic_cast<TF2*>(iter.Next()); ) {
698  setLogarithmicY(f2);
699  }
700 
701  for (Int_t i = 0; i != g2->GetN(); ++i) {
702  g2->GetY()[i] = pow(10.0, g2->GetY()[i]);
703  }
704  }
705  }
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 713 of file JGizmoToolkit.hh.

714  {
715  if (m1 != NULL) {
716 
717  for (TIter i1(m1->GetListOfGraphs()); TGraph* g1 = dynamic_cast<TGraph*>(i1()); ) {
718  setLogarithmicX(g1);
719  }
720  }
721  }
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 736 of file JGizmoToolkit.hh.

737  {
738  using namespace std;
739 
740  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
741  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
742  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
743 
744  Double_t W = 1.0;
745 
746  if (normalise) {
747 
748  W = 0.0;
749 
750  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
751  W += h1.GetBinContent(i);
752  }
753  }
754 
755  if (W != 0.0) {
756 
757  for (Int_t i = 1; i <= h1.GetXaxis()->GetNbins(); ++i) {
758 
759  const Double_t w = W * (bin_width ? h1.GetXaxis()->GetBinWidth(i) : 1.0);
760 
761  h1.SetBinContent(i, h1.GetBinContent(i) * factor / w);
762 
763  if (use_error) {
764  h1.SetBinError(i, h1.GetBinError(i) * factor / w);
765  }
766  }
767  }
768  }
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 785 of file JGizmoToolkit.hh.

786  {
787  using namespace std;
788 
789  const bool normalise = (option.find('N') != string::npos || option.find('n') != string::npos);
790  const bool X = (option.find('X') != string::npos || option.find('x') != string::npos);
791  const bool Y = (option.find('Y') != string::npos || option.find('y') != string::npos);
792  const bool bin_width = (option.find('W') != string::npos || option.find('w') != string::npos);
793  const bool use_error = (option.find('E') != string::npos || option.find('e') != string::npos);
794 
795  Double_t W = 1.0;
796 
797  if (X && Y) {
798 
799  if (normalise) {
800 
801  W = 0.0;
802 
803  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
804  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
805  W += h2.GetBinContent(ix,iy);
806  }
807  }
808  }
809 
810  if (W != 0.0) {
811 
812  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
813  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
814 
815  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
816 
817  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
818 
819  if (use_error) {
820  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
821  }
822  }
823  }
824  }
825 
826  } else if (X) {
827 
828  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
829 
830  if (normalise) {
831 
832  W = 0.0;
833 
834  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
835  W += h2.GetBinContent(ix,iy);
836  }
837  }
838 
839  if (W != 0.0) {
840 
841  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
842 
843  const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
844 
845  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
846 
847  if (use_error) {
848  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
849  }
850  }
851  }
852  }
853 
854  } else if (Y) {
855 
856  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
857 
858  if (normalise) {
859 
860  W = 0.0;
861 
862  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
863  W += h2.GetBinContent(ix,iy);
864  }
865  }
866 
867  if (W != 0.0) {
868 
869  for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
870 
871  const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
872 
873  h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
874 
875  if (use_error) {
876  h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
877  }
878  }
879  }
880  }
881  }
882  }
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 890 of file JGizmoToolkit.hh.

891  {
892  using namespace std;
893 
894  Double_t ymin = numeric_limits<Double_t>::max();
895  Double_t ymax = numeric_limits<Double_t>::lowest();
896 
897  for (Int_t i = 0; i != g1.GetN(); ++i) {
898 
899  const Double_t y = g1.GetY()[i];
900 
901  if (y > ymax) { ymax = y; }
902  if (y < ymin) { ymin = y; }
903  }
904 
905  g1.SetMinimum(ymin);
906  g1.SetMaximum(ymax);
907  }
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 915 of file JGizmoToolkit.hh.

916  {
917  using namespace std;
918 
919  Double_t zmin = numeric_limits<Double_t>::max();
920  Double_t zmax = numeric_limits<Double_t>::lowest();
921 
922  for (Int_t i = 0; i != g2.GetN(); ++i) {
923 
924  const Double_t z = g2.GetZ()[i];
925 
926  if (z > zmax) { zmax = z; }
927  if (z < zmin) { zmin = z; }
928  }
929 
930  g2.SetMinimum(zmin);
931  g2.SetMaximum(zmax);
932  }
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 942 of file JGizmoToolkit.hh.

945  {
946  if (logx) {
947  xmin = log(xmin);
948  xmax = log(xmax);
949  }
950 
951  double dx = (xmax - xmin) * 0.1;
952 
953  if (xmin > dx || xmin < 0.0)
954  xmin -= dx;
955  else
956  xmin = 0.0;
957 
958  xmax += dx;
959 
960  if (logx) {
961  xmin = exp(xmin);
962  xmax = exp(xmax);
963  }
964  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` typeset -Z 4 STRING JOpera1D -f hydrophone.root
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 981 of file JGizmoToolkit.hh.

982  {
983  using namespace JPP;
984 
985  if (axis->GetNbins() == (int) memo.size()) {
986 
987  for (int i = 0; i != axis->GetNbins(); ++i) {
988 
989  const JPMTPhysicalAddress& address = memo[i];
990 
991  axis->SetBinLabel(i + 1, address.toString().c_str());
992  }
993 
994  } else {
995 
996  THROW(JValueOutOfRange, "Number of bins " << axis->GetNbins() << " != " << memo.size());
997  }
998  }
#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 1012 of file JGizmoToolkit.hh.

1013  {
1014  using namespace JPP;
1015 
1016  TAxis* pax = NULL;
1017 
1018  if (axis == "x" || axis == "X")
1019  pax = h1.GetXaxis();
1020  else if (axis == "y" || axis == "Y")
1021  pax = h1.GetYaxis();
1022  else if (axis == "z" || axis == "Z")
1023  pax = h1.GetZaxis();
1024  else
1025  THROW(JValueOutOfRange, "Invalid axis " << axis);
1026 
1027  if (pax->GetNbins() == (int) memo.size()) {
1028 
1029  for (int i = 0; i != pax->GetNbins(); ++i) {
1030 
1031  const JPMTPhysicalAddress& address = memo.getAddressTranslator(i);
1032 
1033  pax->SetBinLabel(i + 1, address.toString().c_str());
1034  }
1035 
1036  h1.LabelsOption("a", axis.c_str()); // sort labels
1037 
1038  } else {
1039 
1040  THROW(JValueOutOfRange, "Number of bins " << pax->GetNbins() << " != " << memo.size());
1041  }
1042  }
#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 85 of file JGizmoToolkit.hh.

const char JGIZMO::LABEL_TERMINATOR = '&'
static

label terminator

Definition at line 23 of file JRootObject.hh.