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

Auxiliary classes and methods for ROOT I/O. More...

Classes

class  JAbstractStreamer
 Forward declaration of writer object. More...
 
class  JCanvas
 Data structure for size of TCanvas. More...
 
class  JChainReader
 Auxiliary class for template TChain reading. More...
 
class  JClassDef
 Test ROOT ClassDef. More...
 
struct  JClassStreamer
 Auxiliary class to add the I/O capabilities of the given template class to the general JRootDictionary class. More...
 
struct  JGraph_t
 Data structure for graph data. More...
 
struct  JGraph
 Auxiliary data structure to build TGraph. More...
 
class  JLineAttributes
 Auxiliary class to set line attributes. More...
 
class  JManager
 Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys. More...
 
class  JMarkerAttributes
 Auxiliary class to set marker attributes. More...
 
struct  JRootAddress
 Auxiliary classd for address handling within TTree or TChain. More...
 
struct  JRootClass
 Auxiliary class to manage access to base classes and data members of ROOT class. More...
 
struct  JAddress
 Simple address wrapper. More...
 
struct  JRootAddressableClass
 Auxiliary class to manage access to base classes and data members of ROOT class objects. More...
 
struct  JRootReadableClass
 ROOT class for reading object. More...
 
struct  JRootWritableClass
 ROOT class for writing object. More...
 
struct  JROOTClassSelector
 Auxiliary class to select ROOT class based on class name. More...
 
struct  JROOTClassSelection
 Auxiliary class for ROOT class selection. More...
 
struct  JRootDictionary_t
 Type definition of ROOT based dictionary for ASCII I/O. More...
 
class  JRootFile
 ROOT file. More...
 
class  JRootInputFile
 ROOT input file. More...
 
class  JRootOutputFile
 ROOT output file. More...
 
class  JRootFileReader
 ROOT file reader. More...
 
class  JRootFileReader< T, false >
 Tempate specialisation of JRootFileReader for TTree incompatible iteration. More...
 
class  JRootFileReader< T, true >
 Tempate specialisation of JRootFileReader for TTree compatible iteration. More...
 
class  JRootObjectOutput
 Template definition of ROOT object output. More...
 
class  JRootObjectOutput< T, false >
 Implementation of object output using TDirectory::WriteTObject method. More...
 
class  JRootObjectOutput< T, true >
 Implementation of object output using TTree. More...
 
class  JRootFileObjectOutput
 Implementation of object output to ROOT file for single data type. More...
 
class  JRootFileObjectOutput< JTypeList< JHead_t, JTail_t > >
 Implementation of object output to ROOT file for multiple data types. More...
 
class  JRootFileObjectOutput< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JRootObjectOutput class. More...
 
class  JRootFileWriter
 ROOT file object output. More...
 
struct  JRootLabel
 Replica of structure JLANG::JLabel for data types with ROOT I/O. More...
 
struct  JRootPrinter
 Auxiliary class for printing objects in ASCII format using JRootWriter. More...
 
class  JRootReader
 Implementation for ASCII input of objects with ROOT dictionary. More...
 
class  JRootWriter
 Implementation for ASCII output of objects with ROOT dictionary. More...
 
struct  JRootStreamer
 Auxiliary template class to define default implementation of the ROOT streamer. More...
 
class  JObjectStreamer
 JObjectStreamer class. More...
 
class  JRootStreamObjectOutput
 Template implementation of stream output for single data type based on ROOT dictionary. More...
 
class  JRootStreamObjectOutput< JTypeList< JHead_t, JTail_t > >
 Template specialisationimplementation of stream object output for multiple data types. More...
 
class  JRootStreamObjectOutput< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JRootStreamObjectOutput class. More...
 
class  JActionAtFileOpen
 Auxiliary class to handle version management of given class at opening of a ROOT file. More...
 
class  JActionAtFileRead
 Auxiliary class to handle version management of given class at reading from a ROOT file. More...
 
struct  JFitParameter_t
 Auxiliary data structure for a parameter index and its value. More...
 
class  JStyle
 Wrapper class around ROOT TStyle. More...
 
class  JTreeParameters
 Data structure for TTree parameters. More...
 
class  JTreeParametersAvailable
 Test availability of TTree parameters for given class. More...
 
struct  JAbstractTreeReader
 Interface for TTree reading. More...
 
class  JTreeReader
 Auxiliary class for template TTree reading. More...
 
class  JTreeReaderObjectIterator
 JTreeReader object iterator. More...
 
class  JTreeReaderAccessibleObjectIterator
 JTemplateTreeReader object iterator. More...
 
class  JTreeWriter
 Auxiliary class for template TTree writing. More...
 
struct  JTreeCopyWriterInterface
 Interface for template TTree writing and copying. More...
 
class  JTreeCopyWriter
 Implementation for template TTree writing and copying. More...
 
class  JTreeWriterObjectOutput
 JTreeWriter object output. More...
 
class  JTreeWriterObjectOutput< JTypeList< JHead_t, JTail_t > >
 Implementation of JTreeWriterObjectOutput for multiple data types. More...
 
class  JTreeWriterObjectOutput< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JTreeWriterObjectOutput class. More...
 
class  JRootDictionary
 Default implementation of ROOT based dictionary for ASCII I/O. More...
 

Typedefs

typedef Long64_t counter_type
 Type definition for counter. More...
 

Functions

counter_type advance (counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
 Advance counter. More...
 
TLegend * getLegend (const Int_t width, const Int_t height, const std::string option="TR")
 Get legend. More...
 
template<class JKey_t , class JValue_t >
bool resetObject (JManager< JKey_t, JValue_t > *object, const bool reset=false)
 Reset JManager object. More...
 
const TDataMember * getDataMember (const JRootClass &parent, const JRootClass &member)
 Get ROOT data member for given parent and member class. More...
 
template<class JType_t , class JClass_t >
const TDataMember * getDataMember (JType_t JClass_t::*pd)
 Get ROOT data member for given C++ data member. More...
 
template<class T >
std::set< JROOTClassSelectorgetROOTClassSelection ()
 Get ROOT class selection. More...
 
template<class T >
void getObject (TFile *file, const TString &key, T *&ps)
 Read object from ROOT file. More...
 
template<class T >
bool putObject (TDirectory *dir, const T &object)
 Write object to ROOT directory. More...
 
template<class T >
void actionAtFileOpen (TFile *file)
 General action method at file open. More...
 
template<class T >
void actionAtFileRead (T *object)
 General action method at file read. More...
 
template<class T >
const char * getName ()
 Get ROOT name of given data type. More...
 
template<class T >
const char * getName (const JType< T > &type)
 Get ROOT name of given data type. More...
 
bool resetObject (TH1 *object, const bool reset=false)
 Detach TH1 object and optionally reset contents. More...
 
bool resetObject (TGraph *object, const bool reset=false)
 Detach TGraph object and optionally reset contents. More...
 
bool resetObject (TGraphErrors *object, const bool reset=false)
 Detach TGraphErrors object and optionally reset contents. More...
 
bool resetObject (TGraph2D *object, const bool reset=false)
 Detach TGraph2D object and optionally reset contents. More...
 
bool resetObject (TGraph2DErrors *object, const bool reset=false)
 Detach TGraph2DErrors object and optionally reset contents. More...
 
bool resetObject (TMultiGraph *object, const bool reset=false)
 Detach TMultiGraph object and optionally reset contents. More...
 
bool resetObject (TNtuple *object, const bool reset=false)
 Detach TNtuple object and optionally reset contents. More...
 
void AddPoint (TGraph *g1, const Double_t x, const Double_t y)
 Add point to TGraph. More...
 
void AddPoint (TGraph2D *g1, const Double_t x, const Double_t y, const Double_t z)
 Add point to TGraph2D. More...
 
void AddPoint (TGraphErrors *g1, const Double_t x, const Double_t y, const Double_t ex, const Double_t ey)
 Add point to TGraphErrors. More...
 
void AddPoint (TGraph2DErrors *g1, const Double_t x, const Double_t y, const Double_t z, const Double_t ex, const Double_t ey, const Double_t ez)
 Add point to TGraph2DErrors. More...
 
TFile & operator<< (TFile &file, const TObject &object)
 Write object to ROOT file. More...
 
const TStreamerInfo * getStreamerInfo (TFile *file, const char *name)
 Get ROOT streamer information of class with given name. More...
 
const TStreamerInfo * getStreamerInfo (const char *file_name, const char *name)
 Get ROOT streamer information of class with given name. More...
 
int getStreamerVersion (TFile *file, const char *name)
 Get ROOT streamer version of class with given name. More...
 
int getStreamerVersion (const char *file_name, const char *name)
 Get ROOT streamer version of class with given name. More...
 
TString parse (const TPRegexp &regexp, const TString &string, const int index=1)
 Match a regular expression with given string and return the specified matched parts. More...
 
bool setParameter (TF1 &f1, const JFitParameter_t &parameter)
 Set fit parameter. More...
 
bool fixParameter (TF1 &f1, const JFitParameter_t &parameter)
 Fix fit parameter. More...
 
bool releaseParameter (TF1 &f1, const Int_t index)
 Release fit parameter. More...
 
bool setParLimits (TF1 &f1, const Int_t index, Double_t xmin, Double_t xmax)
 Set fit parameter limits. More...
 
bool isParameterFixed (const TF1 &f1, const Int_t index)
 Check if fit parameter is fixed. More...
 
template<class T >
Double_t getResult (const TString &text, const T &object, const JRootDictionary_t &dictionary=JRootDictionary::getInstance())
 Get result of given textual formula. More...
 
TGraph * histogramToGraph (const TH1 &in)
 Converts a 1D histogram to a TGraph with: More...
 
TH1 * projectHistogram (const TH2 &in, Double_t inf, Double_t sup, const char coordinate= 'x')
 Helper method for ROOT Projection(X|Y) based on a JRange object and a coordinate. More...
 
template<class T >
JTreeParameters getTreeParameters ()
 Template definition for method returning TTree parameters. More...
 
template<class T >
JNullType getTreeParameters (const JType< T > &type)
 Method with argument definition for obtaining TTree parameters. More...
 
template<class T >
JTreeCopyWriter< T > & getTreeCopyWriter ()
 Get the TTree writer and copy for this type of object. More...
 

Detailed Description

Auxiliary classes and methods for ROOT I/O.

Author
mdejong
mdejong, mlincett

Typedef Documentation

typedef Long64_t JROOT::counter_type

Type definition for counter.

Definition at line 24 of file JROOT/JCounter.hh.

Function Documentation

counter_type JROOT::advance ( counter_type counter,
const counter_type  value,
const counter_type  limit = std::numeric_limits<counter_type>::max() 
)
inline

Advance counter.

Parameters
countercounter (I/O)
valueoffset
limitlimit
Returns
increment

Definition at line 35 of file JROOT/JCounter.hh.

38  {
39  const counter_type previous = counter;
40 
41  if (counter + value < limit)
42  counter += value;
43  else
44  counter = limit;
45 
46  return counter - previous;
47  }
Long64_t counter_type
Type definition for counter.
TLegend* JROOT::getLegend ( const Int_t  width,
const Int_t  height,
const std::string  option = "TR" 
)
inline

Get legend.

Parameters
widthwidth [characters]
heightheight [lines]
optionposition [TR TL BL BR]
Returns
legend

Definition at line 28 of file JLegend.hh.

31  {
32  using namespace std;
33 
34  gPad->Update();
35 
36  const Double_t X1 = 0.0 + gPad->GetLeftMargin();
37  const Double_t X2 = 1.0 - gPad->GetRightMargin();
38  const Double_t Y1 = 0.0 + gPad->GetBottomMargin();
39  const Double_t Y2 = 1.0 - gPad->GetTopMargin();
40 
41  const Double_t w = gPad->XtoPixel(gPad->GetX2());
42  const Double_t h = gPad->YtoPixel(gPad->GetY1());
43  const Double_t ch = gStyle->GetStatFontSize() * (w < h ? w : h);
44 
45  const Double_t fx = 0.70 * ch/w; // estimated font size [NDC]
46  const Double_t fy = 1.10 * ch/h; // estimated font size [NDC]
47  const Double_t eps = 0.005; // extra space [NDC]
48  const Int_t nc = 3; // number of characters reserved for margin
49 
50  Int_t wd = width;
51 
52  if (wd < 2) {
53  wd = 2;
54  }
55 
56  Double_t W = (wd + nc) * fx; // width [NDC]
57  Double_t H = (height) * fy; // height [NDC]
58 
59  Double_t fc = 1.0; // scaling factor
60 
61  if (fc * W > X2 - X1 - 2*eps) {
62  fc *= (X2 - X1 - 2*eps) / W;
63  }
64 
65  if (fc * H > Y2 - Y1 - 2*eps) {
66  fc *= (Y2 - Y1 - 2*eps) / H;
67  }
68 
69  W *= fc;
70  H *= fc;
71 
72  // default position is top-right
73 
74  Double_t x1 = X2 - W - eps;
75  Double_t y1 = Y2 - H - eps;
76  Double_t x2 = X2 - eps;
77  Double_t y2 = Y2 - eps;
78 
79  int halign = 2;
80  int valign = 2;
81 
82  if (option.find('T') != string::npos && option.find('B') == string::npos) { // top
83 
84  y1 = Y2 - H - eps;
85  y2 = Y2 - eps;
86 
87  //valign = 1;
88  }
89 
90  if (option.find('B') != string::npos && option.find('T') == string::npos) { // bottom
91 
92  y1 = Y1 + eps;
93  y2 = Y1 + H + eps;
94 
95  //valign = 3;
96  }
97 
98  if (option.find('R') != string::npos && option.find('L') == string::npos) { // right
99 
100  x1 = X2 - W - eps;
101  x2 = X2 - eps;
102 
103  halign = 1;
104  }
105 
106  if (option.find('L') != string::npos && option.find('R') == string::npos) { // left
107 
108  x1 = X1 + eps;
109  x2 = X1 + W + eps;
110 
111  halign = 1;
112  }
113 
114  TLegend* lg = new TLegend(x1, y1, x2, y2);
115 
116  lg->SetTextAlign(halign*10 + valign);
117 
118  //lg->SetFillStyle(4000);
119  lg->SetFillColor(kWhite);
120  lg->SetBorderSize(0);
121  lg->SetTextAlign(12);
122  lg->SetTextFont(gStyle->GetStatFont());
123  lg->SetTextSize(gStyle->GetStatFontSize());
124  //lg->SetTextSize(lg->GetTextSize() * fc);
125  lg->SetMargin((Double_t) nc / (Double_t) (wd + nc));
126 
127  return lg;
128  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
static const double H
Planck constant [eV s].
template<class JKey_t , class JValue_t >
bool JROOT::resetObject ( JManager< JKey_t, JValue_t > *  object,
const bool  reset = false 
)
inline

Reset JManager object.

Parameters
objectmanager
resetreset contents if true
Returns
true if successful; else false

Definition at line 366 of file JManager.hh.

367  {
368  if (object->is_valid()) {
369  JROOT::resetObject(object->get(), reset);
370  }
371 
372  for (typename JManager<JKey_t, JValue_t>::iterator i = object->begin(); i != object->end(); ++i) {
373  JROOT::resetObject(i->second.get(), reset);
374  }
375 
376  return true;
377  }
bool is_valid() const
Check validity of pointer.
bool resetObject(JManager< JKey_t, JValue_t > *object, const bool reset=false)
Reset JManager object.
Definition: JManager.hh:366
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
void reset(T &value)
Reset value.
virtual JClass_t * get() const override
Get pointer.
Definition: JPointer.hh:64
const TDataMember* JROOT::getDataMember ( const JRootClass parent,
const JRootClass member 
)
inline

Get ROOT data member for given parent and member class.

Parameters
parentROOT class
memberROOT class
Returns
pointer to ROOT data member

Definition at line 636 of file JRootClass.hh.

638  {
639  if (parent.getClass() != NULL) {
640 
641  TIterator* i = NULL;
642 
643  i = parent.getClass()->GetListOfDataMembers()->MakeIterator();
644 
645  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
646 
647  const JRootClass abc = parent.get(*p);
648 
649  if (abc == member && abc.getOffset() == member.getOffset()) {
650  return p;
651  }
652  }
653 
654  i = parent.getClass()->GetListOfBases()->MakeIterator();
655 
656  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
657 
658  if (JRootClass::is_class(*p) && !JRootClass::is_STLcontainer(*p)) {
659 
660  const TDataMember* q = getDataMember(parent.get(*p), member);
661 
662  if (q != NULL) {
663  return q;
664  }
665  }
666  }
667  }
668 
669  return NULL;
670  }
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:172
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:636
JRootClass get(const TDataMember &data_member) const
Get ROOT class of given data member.
Definition: JRootClass.hh:280
TClass * getClass() const
Get class.
Definition: JRootClass.hh:183
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:39
template<class JType_t , class JClass_t >
const TDataMember* JROOT::getDataMember ( JType_t JClass_t::*  pd)
inline

Get ROOT data member for given C++ data member.

Parameters
pdpointer to C++ data member
Returns
pointer to ROOT data member

Definition at line 680 of file JRootClass.hh.

681  {
682  return getDataMember(JRootClass(getType<JClass_t>()), JRootClass(pd));
683  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:636
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:39
template<class T >
std::set<JROOTClassSelector> JROOT::getROOTClassSelection ( )
inline

Get ROOT class selection.

Returns
ROOT class selection

Definition at line 240 of file JROOTClassSelector.hh.

241  {
242  return JROOTClassSelection(JType<T>());
243  }
Auxiliary class for ROOT class selection.
template<class T >
void JROOT::getObject ( TFile *  file,
const TString &  key,
T *&  ps 
)
inline

Read object from ROOT file.

Parameters
filepointer to file
keykey of object to be read
pspointer to object

Definition at line 42 of file JRootFileReader.hh.

43  {
44  if (file != NULL) {
45  file->GetObject(key, ps);
46  }
47  }
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 (( $
template<class T >
bool JROOT::putObject ( TDirectory *  dir,
const T object 
)
inline

Write object to ROOT directory.

Parameters
dirpointer to directory
objectobject
Returns
true if OK; else false

Definition at line 38 of file JRootFileWriter.hh.

39  {
40  return (dir != NULL && dir->WriteTObject(&object) > 0);
41  }
template<class T >
void JROOT::actionAtFileOpen ( TFile *  file)
inline

General action method at file open.

The class T should provide the policy method:

   static void actionAtFileOpen(int version);

whenever an action specific to this data type has to be executed after opening a file.
This method will then be called following each file open operation.

Parameters
filepointer to file

Definition at line 148 of file JRootSupportkit.hh.

149  {
150  if (file != NULL) {
152  }
153  }
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 (( $
Auxiliary class to handle version management of given class at opening of a ROOT file.
template<class T >
void JROOT::actionAtFileRead ( T object)
inline

General action method at file read.

The class T should provide the policy method:

   void actionAtFileRead();

whenever an action specific to this data type has to be executed after reading from a file.
This method will then be called following each file read operation.

Parameters
objectpointer to object (I/O)

Definition at line 169 of file JRootSupportkit.hh.

170  {
171  if (object != NULL) {
173  }
174  }
Auxiliary class to handle version management of given class at reading from a ROOT file...
template<class T >
const char* JROOT::getName ( )
inline

Get ROOT name of given data type.

Returns
name of object to be read

Definition at line 54 of file JRootToolkit.hh.

55  {
56  return getName(JType<T>());
57  }
const char * getName()
Get ROOT name of given data type.
Definition: JRootToolkit.hh:54
template<class T >
const char* JROOT::getName ( const JType< T > &  type)
inline

Get ROOT name of given data type.

Parameters
typedata type
Returns
name of object to be read

Definition at line 67 of file JRootToolkit.hh.

68  {
69  return T::Class_Name();
70  }
bool JROOT::resetObject ( TH1 *  object,
const bool  reset = false 
)
inline

Detach TH1 object and optionally reset contents.

Parameters
objectROOT TH1 object
resetreset contents if true
Returns
true if successful; else false

Definition at line 80 of file JRootToolkit.hh.

81  {
82  if (object != NULL) {
83 
84  object->SetDirectory(0);
85 
86  if (reset) {
87  object->Reset();
88  }
89 
90  return true;
91  }
92 
93  return false;
94  }
void reset(T &value)
Reset value.
bool JROOT::resetObject ( TGraph *  object,
const bool  reset = false 
)
inline

Detach TGraph object and optionally reset contents.

Parameters
objectROOT TGraph object
resetreset contents if true
Returns
true if successful; else false

Definition at line 104 of file JRootToolkit.hh.

105  {
106  if (object != NULL) {
107 
108  if (reset) {
109  for (int i = 0; i != object->GetN(); ++i) {
110  object->SetPoint(i, 0.0, 0.0);
111  }
112  }
113 
114  return true;
115  }
116 
117  return false;
118  }
void reset(T &value)
Reset value.
bool JROOT::resetObject ( TGraphErrors *  object,
const bool  reset = false 
)
inline

Detach TGraphErrors object and optionally reset contents.

Parameters
objectROOT TGraphErrors object
resetreset contents if true
Returns
true if successful; else false

Definition at line 128 of file JRootToolkit.hh.

129  {
130  if (object != NULL) {
131 
132  if (reset) {
133 
134  for (int i = 0; i != object->GetN(); ++i) {
135  object->SetPoint (i, 0.0, 0.0);
136  object->SetPointError(i, 0.0, 0.0);
137  }
138  }
139 
140  return true;
141  }
142 
143  return false;
144  }
void reset(T &value)
Reset value.
bool JROOT::resetObject ( TGraph2D *  object,
const bool  reset = false 
)
inline

Detach TGraph2D object and optionally reset contents.

Parameters
objectROOT TGraph2D object
resetreset contents if true
Returns
true if successful; else false

Definition at line 154 of file JRootToolkit.hh.

155  {
156  if (object != NULL) {
157 
158  if (reset) {
159  for (int i = 0; i != object->GetN(); ++i) {
160  object->SetPoint(i, 0.0, 0.0, 0.0);
161  }
162  }
163 
164  return true;
165  }
166 
167  return false;
168  }
void reset(T &value)
Reset value.
bool JROOT::resetObject ( TGraph2DErrors *  object,
const bool  reset = false 
)
inline

Detach TGraph2DErrors object and optionally reset contents.

Parameters
objectROOT TGraph2DErrors object
resetreset contents if true
Returns
true if successful; else false

Definition at line 178 of file JRootToolkit.hh.

179  {
180  if (object != NULL) {
181 
182  if (reset) {
183  for (int i = 0; i != object->GetN(); ++i) {
184  object->SetPoint (i, 0.0, 0.0, 0.0);
185  object->SetPointError(i, 0.0, 0.0, 0.0);
186  }
187  }
188 
189  return true;
190  }
191 
192  return false;
193  }
void reset(T &value)
Reset value.
bool JROOT::resetObject ( TMultiGraph *  object,
const bool  reset = false 
)
inline

Detach TMultiGraph object and optionally reset contents.

Parameters
objectROOT TMultiGraph object
resetreset contents if true
Returns
true if successful; else false

Definition at line 203 of file JRootToolkit.hh.

204  {
205  if (object != NULL) {
206 
207  bool status = true;
208 
209  if (reset) {
210 
211  TIter next(object->GetListOfGraphs());
212 
213  while (TGraph* graph = (TGraph*)next()) {
214 
215  if (graph->InheritsFrom(TGraph2DErrors::Class())) {
216 
217  status = (resetObject(dynamic_cast<TGraph2DErrors*>(graph), reset) ? status : false);
218 
219  } else if (graph->InheritsFrom(TGraph2D::Class())) {
220 
221  status = (resetObject(dynamic_cast<TGraph2D*>(graph), reset) ? status : false);
222 
223  } else if (graph->InheritsFrom(TGraphErrors::Class())) {
224 
225  status = (resetObject(dynamic_cast<TGraphErrors*>(graph), reset) ? status : false);
226 
227  } else {
228 
229  status = (resetObject(graph, reset) ? status : false);
230  }
231  }
232  }
233 
234  return status;
235  }
236 
237  return false;
238  }
bool resetObject(JManager< JKey_t, JValue_t > *object, const bool reset=false)
Reset JManager object.
Definition: JManager.hh:366
void reset(T &value)
Reset value.
bool JROOT::resetObject ( TNtuple *  object,
const bool  reset = false 
)
inline

Detach TNtuple object and optionally reset contents.

Parameters
objectROOT TNtuple object
resetreset contents if true
Returns
true if successful; else false

Definition at line 248 of file JRootToolkit.hh.

249  {
250  if (object != NULL) {
251 
252  object->SetDirectory(0);
253 
254  if (reset) {
255  object->Reset();
256  }
257 
258  return true;
259  }
260 
261  return false;
262  }
void reset(T &value)
Reset value.
void JROOT::AddPoint ( TGraph *  g1,
const Double_t  x,
const Double_t  y 
)
inline

Add point to TGraph.

Parameters
g1pointer to valid ROOT TGraph object
xx value
yy value

Definition at line 272 of file JRootToolkit.hh.

275  {
276  const Int_t n = g1->GetN();
277 
278  g1->Set(n + 1);
279  g1->SetPoint(n, x, y);
280  }
alias put_queue eval echo n
Definition: qlib.csh:19
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JROOT::AddPoint ( TGraph2D *  g1,
const Double_t  x,
const Double_t  y,
const Double_t  z 
)
inline

Add point to TGraph2D.

Parameters
g1pointer to valid ROOT TGraph object
xx value
yy value
zz value

Definition at line 291 of file JRootToolkit.hh.

295  {
296  const Int_t n = g1->GetN();
297 
298  g1->Set(n + 1);
299  g1->SetPoint(n, x, y, z);
300  }
alias put_queue eval echo n
Definition: qlib.csh:19
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JROOT::AddPoint ( TGraphErrors *  g1,
const Double_t  x,
const Double_t  y,
const Double_t  ex,
const Double_t  ey 
)
inline

Add point to TGraphErrors.

Parameters
g1pointer to valid ROOT TGraph object
xx value
yy value
exx error
eyy error

Definition at line 312 of file JRootToolkit.hh.

317  {
318  const Int_t n = g1->GetN();
319 
320  g1->Set(n + 1);
321  g1->SetPoint(n, x, y);
322  g1->SetPointError(n, ex, ey);
323  }
alias put_queue eval echo n
Definition: qlib.csh:19
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JROOT::AddPoint ( TGraph2DErrors *  g1,
const Double_t  x,
const Double_t  y,
const Double_t  z,
const Double_t  ex,
const Double_t  ey,
const Double_t  ez 
)
inline

Add point to TGraph2DErrors.

Parameters
g1pointer to valid ROOT TGraph object
xx value
yy value
zz value
exx error
eyy error
ezz error

Definition at line 337 of file JRootToolkit.hh.

344  {
345  const Int_t n = g1->GetN();
346 
347  g1->Set(n + 1);
348  g1->SetPoint(n, x, y, z);
349  g1->SetPointError(n, ex, ey, ez);
350  }
alias put_queue eval echo n
Definition: qlib.csh:19
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
TFile& JROOT::operator<< ( TFile &  file,
const TObject object 
)

Write object to ROOT file.

Parameters
fileROOT file
objectROOT object
Returns
ROOT file

Definition at line 360 of file JRootToolkit.hh.

361  {
362  file.WriteTObject(&object);
363 
364  return file;
365  }
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 (( $
const TStreamerInfo* JROOT::getStreamerInfo ( TFile *  file,
const char *  name 
)
inline

Get ROOT streamer information of class with given name.

Note that the class name should include the name space, if any.

Parameters
filepointer to ROOT file
nameclass name
Returns
pointer to TStreamerInfo (NULL in case of error)

Definition at line 376 of file JRootToolkit.hh.

377  {
378  if (file != NULL && file->IsOpen()) {
379 
380  const TString buffer(name);
381 
382  TIter iter(file->GetStreamerInfoList());
383 
384  for (const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
385  if (buffer == TString(pStreamerInfo->GetName())) {
386  return pStreamerInfo;
387  }
388  }
389  }
390 
391  return NULL;
392  }
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 (( $
then echo n User name
Definition: JCookie.sh:45
const TStreamerInfo* JROOT::getStreamerInfo ( const char *  file_name,
const char *  name 
)
inline

Get ROOT streamer information of class with given name.

Note that the class name should include the name space, if any.

Parameters
file_namefile name
nameclass name
Returns
pointer to TStreamerInfo (NULL in case of error)

Definition at line 403 of file JRootToolkit.hh.

404  {
405  JRootInputFile file(file_name);
406 
407  return getStreamerInfo(file.getFile(), name);
408  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
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 (( $
ROOT input file.
Definition: JRootFile.hh:101
then echo n User name
Definition: JCookie.sh:45
int JROOT::getStreamerVersion ( TFile *  file,
const char *  name 
)
inline

Get ROOT streamer version of class with given name.

Note that the class name should include the name space, if any.

Parameters
filepointer to ROOT file
nameclass name
Returns
streamer version; (-1 in case of error)

Definition at line 419 of file JRootToolkit.hh.

420  {
421  const TStreamerInfo* pStreamerInfo = getStreamerInfo(file, name);
422 
423  if (pStreamerInfo != NULL)
424  return pStreamerInfo->GetClassVersion();
425  else
426  return -1;
427  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
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 (( $
then echo n User name
Definition: JCookie.sh:45
int JROOT::getStreamerVersion ( const char *  file_name,
const char *  name 
)
inline

Get ROOT streamer version of class with given name.

Note that the class name should include the name space, if any.

Parameters
file_namefile name
nameclass name
Returns
streamer version; (-1 in case of error)

Definition at line 438 of file JRootToolkit.hh.

439  {
440  JRootInputFile file(file_name);
441 
442  return getStreamerVersion(file.getFile(), name);
443  }
int getStreamerVersion(TFile *file, const char *name)
Get ROOT streamer version of class with given name.
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 (( $
ROOT input file.
Definition: JRootFile.hh:101
then echo n User name
Definition: JCookie.sh:45
TString JROOT::parse ( const TPRegexp &  regexp,
const TString &  string,
const int  index = 1 
)
inline

Match a regular expression with given string and return the specified matched parts.

If no matches are found corresponding to the specified index, the original string is returned.

Parameters
regexpregular expression
stringinput string
indexindex of matched parts (starting at 1)
Returns
matched part of string

Definition at line 456 of file JRootToolkit.hh.

457  {
458  TPRegexp buffer = regexp;
459  TObjArray* array = buffer.MatchS(string);
460 
461  if (index - 1 < array->GetLast())
462  return ((TObjString*) array->At(index))->GetName();
463  else
464  return string;
465  }
bool JROOT::setParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Set fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 517 of file JRootToolkit.hh.

518  {
519  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
520 
521  f1.SetParameter(parameter.index, parameter.value);
522 
523  return true;
524 
525  } else {
526 
527  return false;
528  }
529  }
bool JROOT::fixParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Fix fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 538 of file JRootToolkit.hh.

539  {
540  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
541 
542  f1.FixParameter(parameter.index, parameter.value);
543 
544  return true;
545 
546  } else {
547 
548  return false;
549  }
550  }
bool JROOT::releaseParameter ( TF1 &  f1,
const Int_t  index 
)
inline

Release fit parameter.

Parameters
f1fit function
indexparameter index

Definition at line 559 of file JRootToolkit.hh.

560  {
561  if (index >= 0 && index < f1.GetNpar()) {
562 
563  f1.ReleaseParameter(index);
564 
565  return true;
566 
567  } else {
568 
569  return false;
570  }
571  }
bool JROOT::setParLimits ( TF1 &  f1,
const Int_t  index,
Double_t  xmin,
Double_t  xmax 
)
inline

Set fit parameter limits.

Parameters
f1fit function
indexparameter index
xminlower limit
xmaxupper limit

Definition at line 582 of file JRootToolkit.hh.

583  {
584  using namespace std;
585 
586  if (index >= 0 && index < f1.GetNpar()) {
587 
588  if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
589  if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
590 
591  f1.SetParLimits(index, xmin, xmax);
592 
593  return true;
594 
595  } else {
596 
597  return false;
598  }
599  }
bool JROOT::isParameterFixed ( const TF1 &  f1,
const Int_t  index 
)
inline

Check if fit parameter is fixed.

Parameters
f1fit function
indexparameter index

Definition at line 608 of file JRootToolkit.hh.

609  {
610  if (index >= 0 && index < f1.GetNpar()) {
611 
612  Double_t xmin;
613  Double_t xmax;
614 
615  f1.GetParLimits(index, xmin, xmax);
616 
617  return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
618 
619  } else {
620 
621  return false;
622  }
623  }
template<class T >
Double_t JROOT::getResult ( const TString &  text,
const T object,
const JRootDictionary_t dictionary = JRootDictionary::getInstance() 
)
inline

Get result of given textual formula.


The formula may contain names of data members of the given object. Example:

        getResult("a/b", object, ..);

In this, the corresponding data type should have (at least) data members a and b.

Parameters
texttext
objectobject
dictionarydictionary
Returns
value

Definition at line 641 of file JRootToolkit.hh.

644  {
645  using namespace std;
646  using namespace JPP;
647 
648  string buffer = (const char*) text;
649 
650  for (string::size_type pos = 0; pos != buffer.size(); ) {
651 
652  if (isalpha(buffer[pos]) || buffer[pos] == '_') {
653 
654  string::size_type len = 1;
655 
656  while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] == '_' || buffer[pos+len] == '.')) {
657  ++len;
658  }
659 
660  ostringstream os;
661 
662  os.setf(ios::fixed);
663  os.precision(10);
664 
665  JRootPrinter::print(os, object, buffer.substr(pos,len), dictionary);
666 
667  buffer.replace(pos, len, os.str());
668 
669  pos += os.str().size();
670 
671  } else {
672 
673  pos += 1;
674  }
675  }
676 
677  return TFormula("/tmp", buffer.c_str()).Eval(0.0);
678  }
char text[TEXT_SIZE]
Definition: elog.cc:72
print
Definition: JConvertDusj.sh:44
TGraph* JROOT::histogramToGraph ( const TH1 &  in)
inline

Converts a 1D histogram to a TGraph with:

  • bin centers as x values;
  • bin contents as y values. Underflow and overflow bins are ignored.
    Parameters
    ininput histogram

Definition at line 687 of file JRootToolkit.hh.

687  {
688 
689  const int N = in.GetNbinsX();
690 
691  std::vector<double> x(N), y(N);
692 
693  for (int i = 0; i < N; i++) {
694  x[i] = in.GetBinCenter (i + 1);
695  y[i] = in.GetBinContent(i + 1);
696  }
697 
698  TGraph* out = new TGraph(N, &x[0], &y[0]);
699 
700  return out;
701 
702  }
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
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
TH1* JROOT::projectHistogram ( const TH2 &  in,
Double_t  inf,
Double_t  sup,
const char  coordinate = 'x' 
)
inline

Helper method for ROOT Projection(X|Y) based on a JRange object and a coordinate.

Parameters
in2D histogram
inflower limit
supupper limit
coordinateprojection coordinate

Definition at line 712 of file JRootToolkit.hh.

712  {
713 
714  int inf_bin, sup_bin;
715 
716  switch(coordinate) {
717 
718  case 'x':
719  case 'X':
720  inf_bin = in.GetYaxis()->FindBin(inf);
721  sup_bin = in.GetYaxis()->FindBin(sup);
722  return in.ProjectionX("_px", inf_bin, sup_bin);
723 
724  case 'y':
725  case 'Y':
726  inf_bin = in.GetXaxis()->FindBin(inf);
727  sup_bin = in.GetXaxis()->FindBin(sup);
728  return in.ProjectionY("_py", inf_bin, sup_bin);
729 
730  default:
731  return NULL;
732 
733  }
734 
735  }
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
template<class T >
JTreeParameters JROOT::getTreeParameters ( )
inline

Template definition for method returning TTree parameters.

The template argument refers to the class for which ROOT TTree I/O is desired.

Returns
TTree parameters

Definition at line 171 of file JTreeParameters.hh.

172  {
173  return getTreeParameters(JType<T>());
174  }
JROOT::JTreeParameters getTreeParameters(JLANG::JType< JRECONSTRUCTION::JEvt >)
Get TTree parameters for given data type.
template<class T >
JNullType JROOT::getTreeParameters ( const JType< T > &  type)
inline

Method with argument definition for obtaining TTree parameters.

The method argument refers to the class for which ROOT TTree I/O is desired. This method should then be overloaded and the overloaded method should return a JTreeParameters object with the corresponding TTree parameters.

Parameters
typedata type
Returns
TTree parameters
template<class T >
JTreeCopyWriter<T>& JROOT::getTreeCopyWriter ( )
inline

Get the TTree writer and copy for this type of object.

Returns
TTree writer and copy for this type of object

Definition at line 168 of file JTreeWriter.hh.

169  {
171  }
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75