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

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

Classes

class  JAbstractStreamer
 Forward declaration of writer object. More...
 
struct  JASCIIFileReader
 Auxiliary class to read objects with ROOT dictionary from ASCII formatted file. More...
 
struct  JASCIIFileWriter
 Auxiliary class to write object with ROOT dictionary from ASCII formatted file. 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::vector< TDataMember * > getListOfDataMembers ()
 Get list of ROOT data members for given class. 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...
 
bool putObject (TDirectory &dir, const TObject &object)
 Write object to ROOT directory. More...
 
template<class T >
JAssert<!JConversion< T,
TObject >::is_derived, bool >
::type 
putObject (TDirectory &dir, const T &object)
 Write object to ROOT directory. More...
 
bool putObject (TDirectory *dir, const TObject &object)
 Write object to ROOT directory. More...
 
template<class T >
JAssert<!JConversion< T,
TObject >::is_derived, bool >
::type 
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 (TTree *object, const bool reset=false)
 Detach TTree 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 &h1)
 Helper method to convert a 1D histogram to a graph. More...
 
TH1 * projectHistogram (const TH2 &h2, const Double_t xmin, const Double_t xmax, const char projection)
 Helper method for ROOT histogram projections. 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...
 

Variables

static const char *const ROOT_FILE_RECOVERY_DISABLE = "ROOT_FILE_RECOVERY_DISABLE"
 Environment variable to disable ROOT file recovery. 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 637 of file JRootClass.hh.

639  {
640  if (parent.getClass() != NULL) {
641 
642  TIterator* i = NULL;
643 
644  i = parent.getClass()->GetListOfDataMembers()->MakeIterator();
645 
646  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
647 
648  const JRootClass abc = parent.get(*p);
649 
650  if (abc == member && abc.getOffset() == member.getOffset()) {
651  return p;
652  }
653  }
654 
655  i = parent.getClass()->GetListOfBases()->MakeIterator();
656 
657  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
658 
659  if (JRootClass::is_class(*p) && !JRootClass::is_STLcontainer(*p)) {
660 
661  const TDataMember* q = getDataMember(parent.get(*p), member);
662 
663  if (q != NULL) {
664  return q;
665  }
666  }
667  }
668  }
669 
670  return NULL;
671  }
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:173
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:637
JRootClass get(const TDataMember &data_member) const
Get ROOT class of given data member.
Definition: JRootClass.hh:281
TClass * getClass() const
Get class.
Definition: JRootClass.hh:184
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:40
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 681 of file JRootClass.hh.

682  {
683  return getDataMember(JRootClass(getType<JClass_t>()), JRootClass(pd));
684  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:637
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:40
template<class T >
std::vector<TDataMember*> JROOT::getListOfDataMembers ( )

Get list of ROOT data members for given class.

Definition at line 691 of file JRootClass.hh.

692  {
694 
695  TClass* rc = (TClass*) TDictionary::GetDictionary(typeid(T));
696 
697  TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
698 
699  for (TDataMember* p; (p = (TDataMember*) i->Next()) != NULL; ) {
700  if (JRootClass::is_class(p->GetName())) {
701  buffer.push_back(p);
702  }
703  }
704 
705  return buffer;
706  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
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  }
bool JROOT::putObject ( TDirectory &  dir,
const TObject object 
)
inline

Write object to ROOT directory.

Parameters
dirdirectory
objectobject
Returns
true if OK; else false

Definition at line 41 of file JRootFileWriter.hh.

42  {
43  return dir.WriteTObject(&object) > 0;
44  }
template<class T >
JAssert<!JConversion<T, TObject>::is_derived, bool>::type JROOT::putObject ( TDirectory &  dir,
const T object 
)
inline

Write object to ROOT directory.

Parameters
dirdirectory
objectobject
Returns
true if OK; else false

Definition at line 55 of file JRootFileWriter.hh.

56  {
57  return dir.WriteObject(&object, T::Class_Name()) > 0;
58  }
bool JROOT::putObject ( TDirectory *  dir,
const TObject object 
)
inline

Write object to ROOT directory.

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

Definition at line 68 of file JRootFileWriter.hh.

69  {
70  return (dir != NULL && putObject(*dir, object));
71  }
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
template<class T >
JAssert<!JConversion<T, TObject>::is_derived, bool>::type 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 82 of file JRootFileWriter.hh.

83  {
84  return (dir != NULL && putObject(*dir, object));
85  }
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
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  }
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 57 of file JRootToolkit.hh.

58  {
59  return getName(JType<T>());
60  }
const char * getName()
Get ROOT name of given data type.
Definition: JRootToolkit.hh:57
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 70 of file JRootToolkit.hh.

71  {
72  return T::Class_Name();
73  }
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 83 of file JRootToolkit.hh.

84  {
85  if (object != NULL) {
86 
87  object->SetDirectory(0);
88 
89  if (reset) {
90  object->Reset();
91  }
92 
93  return true;
94  }
95 
96  return false;
97  }
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 107 of file JRootToolkit.hh.

108  {
109  if (object != NULL) {
110 
111  if (reset) {
112  for (int i = 0; i != object->GetN(); ++i) {
113  object->SetPoint(i, 0.0, 0.0);
114  }
115  }
116 
117  return true;
118  }
119 
120  return false;
121  }
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 131 of file JRootToolkit.hh.

132  {
133  if (object != NULL) {
134 
135  if (reset) {
136 
137  for (int i = 0; i != object->GetN(); ++i) {
138  object->SetPoint (i, 0.0, 0.0);
139  object->SetPointError(i, 0.0, 0.0);
140  }
141  }
142 
143  return true;
144  }
145 
146  return false;
147  }
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 157 of file JRootToolkit.hh.

158  {
159  if (object != NULL) {
160 
161  if (reset) {
162  for (int i = 0; i != object->GetN(); ++i) {
163  object->SetPoint(i, 0.0, 0.0, 0.0);
164  }
165  }
166 
167  return true;
168  }
169 
170  return false;
171  }
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 181 of file JRootToolkit.hh.

182  {
183  if (object != NULL) {
184 
185  if (reset) {
186  for (int i = 0; i != object->GetN(); ++i) {
187  object->SetPoint (i, 0.0, 0.0, 0.0);
188  object->SetPointError(i, 0.0, 0.0, 0.0);
189  }
190  }
191 
192  return true;
193  }
194 
195  return false;
196  }
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 206 of file JRootToolkit.hh.

207  {
208  if (object != NULL) {
209 
210  bool status = true;
211 
212  if (reset) {
213 
214  TIter next(object->GetListOfGraphs());
215 
216  while (TGraph* graph = (TGraph*)next()) {
217 
218  if (!(resetObject(dynamic_cast<TGraph2DErrors*>(graph), reset) ||
219  resetObject(dynamic_cast<TGraph2D*> (graph), reset)) &&
220  !(resetObject(dynamic_cast<TGraphErrors*> (graph), reset) ||
221  resetObject (graph, reset)) ) {
222 
223  status = false;
224  }
225  }
226  }
227 
228  return status;
229  }
230 
231  return false;
232  }
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 ( TTree *  object,
const bool  reset = false 
)
inline

Detach TTree object and optionally reset contents.

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

Definition at line 242 of file JRootToolkit.hh.

243  {
244  if (object != NULL) {
245 
246  object->SetDirectory(0);
247 
248  if (reset) {
249  object->Reset();
250  }
251 
252  return true;
253  }
254 
255  return false;
256  }
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 266 of file JRootToolkit.hh.

269  {
270  const Int_t n = g1->GetN();
271 
272  g1->Set(n + 1);
273  g1->SetPoint(n, x, y);
274  }
const int n
Definition: JPolint.hh:660
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 285 of file JRootToolkit.hh.

289  {
290  const Int_t n = g1->GetN();
291 
292  g1->Set(n + 1);
293  g1->SetPoint(n, x, y, z);
294  }
const int n
Definition: JPolint.hh:660
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 306 of file JRootToolkit.hh.

311  {
312  const Int_t n = g1->GetN();
313 
314  g1->Set(n + 1);
315  g1->SetPoint(n, x, y);
316  g1->SetPointError(n, ex, ey);
317  }
const int n
Definition: JPolint.hh:660
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 331 of file JRootToolkit.hh.

338  {
339  const Int_t n = g1->GetN();
340 
341  g1->Set(n + 1);
342  g1->SetPoint(n, x, y, z);
343  g1->SetPointError(n, ex, ey, ez);
344  }
const int n
Definition: JPolint.hh:660
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
TFile& JROOT::operator<< ( TFile &  file,
const TObject object 
)
inline

Write object to ROOT file.

Parameters
fileROOT file
objectROOT object
Returns
ROOT file

Definition at line 354 of file JRootToolkit.hh.

355  {
356  file.WriteTObject(&object);
357 
358  return file;
359  }
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 370 of file JRootToolkit.hh.

371  {
372  if (file != NULL && file->IsOpen()) {
373 
374  const TString buffer(name);
375 
376  TIter iter(file->GetStreamerInfoList());
377 
378  for (const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
379  if (buffer == TString(pStreamerInfo->GetName())) {
380  return pStreamerInfo;
381  }
382  }
383  }
384 
385  return NULL;
386  }
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
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 397 of file JRootToolkit.hh.

398  {
399  JRootInputFile file(file_name);
400 
401  return getStreamerInfo(file.getFile(), name);
402  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
ROOT input file.
Definition: JRootFile.hh:113
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 413 of file JRootToolkit.hh.

414  {
415  const TStreamerInfo* pStreamerInfo = getStreamerInfo(file, name);
416 
417  if (pStreamerInfo != NULL)
418  return pStreamerInfo->GetClassVersion();
419  else
420  return -1;
421  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
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 432 of file JRootToolkit.hh.

433  {
434  JRootInputFile file(file_name);
435 
436  return getStreamerVersion(file.getFile(), name);
437  }
int getStreamerVersion(TFile *file, const char *name)
Get ROOT streamer version of class with given name.
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
ROOT input file.
Definition: JRootFile.hh:113
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 450 of file JRootToolkit.hh.

451  {
452  TPRegexp buffer = regexp;
453  TObjArray* array = buffer.MatchS(string);
454 
455  if (index - 1 < array->GetLast())
456  return ((TObjString*) array->At(index))->GetName();
457  else
458  return string;
459  }
bool JROOT::setParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Set fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 511 of file JRootToolkit.hh.

512  {
513  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
514 
515  f1.SetParameter(parameter.index, parameter.value);
516 
517  return true;
518 
519  } else {
520 
521  return false;
522  }
523  }
bool JROOT::fixParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Fix fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 532 of file JRootToolkit.hh.

533  {
534  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
535 
536  f1.FixParameter(parameter.index, parameter.value);
537 
538  return true;
539 
540  } else {
541 
542  return false;
543  }
544  }
bool JROOT::releaseParameter ( TF1 &  f1,
const Int_t  index 
)
inline

Release fit parameter.

Parameters
f1fit function
indexparameter index

Definition at line 553 of file JRootToolkit.hh.

554  {
555  if (index >= 0 && index < f1.GetNpar()) {
556 
557  f1.ReleaseParameter(index);
558 
559  return true;
560 
561  } else {
562 
563  return false;
564  }
565  }
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 576 of file JRootToolkit.hh.

577  {
578  using namespace std;
579 
580  if (index >= 0 && index < f1.GetNpar()) {
581 
582  if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
583  if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
584 
585  f1.SetParLimits(index, xmin, xmax);
586 
587  return true;
588 
589  } else {
590 
591  return false;
592  }
593  }
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 602 of file JRootToolkit.hh.

603  {
604  if (index >= 0 && index < f1.GetNpar()) {
605 
606  Double_t xmin;
607  Double_t xmax;
608 
609  f1.GetParLimits(index, xmin, xmax);
610 
611  return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
612 
613  } else {
614 
615  return false;
616  }
617  }
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. For example:

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

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

Parameters
texttext
objectobject
dictionarydictionary
Returns
value

Definition at line 637 of file JRootToolkit.hh.

640  {
641  using namespace std;
642  using namespace JPP;
643 
644  const TRegexp DOUBLE("[0-9.][eE][+-0-9]");
645 
646  string buffer = (const char*) text;
647 
648  for (string::size_type pos = 0; pos != buffer.size(); ) {
649 
650  if (isalpha(buffer[pos]) || buffer[pos] == '_') {
651 
652  string::size_type len = 1;
653 
654  while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] == '_' || buffer[pos+len] == '.')) {
655  ++len;
656  }
657 
658  if (len != 1 || pos == 0 || TString(buffer.substr(pos-1).c_str()).Index(DOUBLE) != 0) {
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  continue;
672  }
673  }
674 
675  pos += 1;
676  }
677 
678  return TFormula("/tmp", buffer.c_str()).Eval(0.0);
679  }
char text[TEXT_SIZE]
Definition: elog.cc:72
print
Definition: JConvertDusj.sh:44
TGraph* JROOT::histogramToGraph ( const TH1 &  h1)
inline

Helper method to convert a 1D histogram to a graph.

The graph consists of:

  • bin centers as x values;
  • bin contents as y values.

Note that underflow and overflow bins are ignored.

Parameters
h11D histogram
Returns
pointer to newly create graph

Definition at line 694 of file JRootToolkit.hh.

695  {
696  const int N = h1.GetNbinsX();
697 
698  std::vector<double> x(N), y(N);
699 
700  for (int i = 0; i < N; i++) {
701  x[i] = h1.GetBinCenter (i + 1);
702  y[i] = h1.GetBinContent(i + 1);
703  }
704 
705  return new TGraph(N, &x[0], &y[0]);
706  }
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
TH1* JROOT::projectHistogram ( const TH2 &  h2,
const Double_t  xmin,
const Double_t  xmax,
const char  projection 
)
inline

Helper method for ROOT histogram projections.

Parameters
h22D histogram
xminlower limit
xmaxupper limit
projectionprojection (x|X|y|Y)
Returns
pointer to newly created 1D histogram

Definition at line 718 of file JRootToolkit.hh.

719  {
720  switch (projection) {
721 
722  case 'x':
723  case 'X':
724  return h2.ProjectionX("_px", h2.GetYaxis()->FindBin(xmin), h2.GetYaxis()->FindBin(xmax));
725 
726  case 'y':
727  case 'Y':
728  return h2.ProjectionY("_py", h2.GetXaxis()->FindBin(xmin), h2.GetXaxis()->FindBin(xmax));
729 
730  default:
731  return NULL;
732  }
733  }
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

Variable Documentation

const char* const JROOT::ROOT_FILE_RECOVERY_DISABLE = "ROOT_FILE_RECOVERY_DISABLE"
static

Environment variable to disable ROOT file recovery.

If not set or set to 0, allow recovery of ROOT file, else do not.

Definition at line 37 of file JRootFile.hh.