Jpp
Classes | Typedefs | Functions
JROOT Namespace Reference

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

Classes

class  JAbstractStreamer
 Forward declaration of writer object. More...
 
struct  JAbstractTreeReader
 Interface for TTree reading. 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  JAddress
 Simple address wrapper. 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  JFitParameter_t
 Auxiliary data structure for a parameter index and its value. More...
 
class  JObjectStreamer
 JObjectStreamer class. More...
 
struct  JRootAddress
 Auxiliary classd for address handling within TTree or TChain. More...
 
struct  JRootAddressableClass
 Auxiliary class to manage access to base classes and data members of ROOT class objects. More...
 
struct  JRootClass
 Auxiliary class to manage access to base classes and data members of ROOT class. More...
 
struct  JROOTClassSelection
 Auxiliary class for ROOT class selection. More...
 
struct  JROOTClassSelector
 Auxiliary class to select ROOT class based on class name. More...
 
class  JRootDictionary
 Default implementation of ROOT based dictionary for ASCII I/O. More...
 
struct  JRootDictionary_t
 Type definition of ROOT based dictionary for ASCII O. More...
 
class  JRootFile
 ROOT file. More...
 
class  JRootFileObjectOutput
 Implementation of object output to ROOT file for single data type. More...
 
class  JRootFileObjectOutput< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JRootObjectOutput class. More...
 
class  JRootFileObjectOutput< JTypeList< JHead_t, JTail_t > >
 Implementation of object output to ROOT file for multiple data types. 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  JRootFileWriter
 ROOT file object output. More...
 
class  JRootInputFile
 ROOT input file. More...
 
struct  JRootLabel
 Replica of structure JLANG::JLabel for data types with ROOT I/O. 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  JRootOutputFile
 ROOT output file. More...
 
struct  JRootPrinter
 Auxiliary class for printing objects in ASCII format using JRootWriter. More...
 
struct  JRootReadableClass
 ROOT class for reading object. More...
 
class  JRootReader
 Implementation for ASCII input of objects with ROOT dictionary. More...
 
class  JRootStreamObjectOutput
 Template implementation of stream output for single data type based on ROOT dictionary. More...
 
class  JRootStreamObjectOutput< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JRootStreamObjectOutput class. More...
 
class  JRootStreamObjectOutput< JTypeList< JHead_t, JTail_t > >
 Template specialisationimplementation of stream object output for multiple data types. More...
 
struct  JRootWritableClass
 ROOT class for writing object. More...
 
class  JRootWriter
 Implementation for ASCII output of objects with ROOT dictionary. More...
 
class  JTreeCopyWriter
 Implementation for template TTree writing and copying. More...
 
struct  JTreeCopyWriterInterface
 Interface for template TTree writing and copying. More...
 
class  JTreeParameters
 Data structure for TTree parameters. More...
 
class  JTreeParametersAvailable
 Test availability of TTree parameters for given class. More...
 
class  JTreeReader
 Auxiliary class for template TTree reading. More...
 
class  JTreeReaderAccessibleObjectIterator
 JTemplateTreeReader object iterator. More...
 
class  JTreeReaderObjectIterator
 JTreeReader object iterator. More...
 
class  JTreeWriter
 Auxiliary class for template TTree writing. More...
 
class  JTreeWriterObjectOutput
 JTreeWriter object output. More...
 
class  JTreeWriterObjectOutput< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JTreeWriterObjectOutput class. More...
 
class  JTreeWriterObjectOutput< JTypeList< JHead_t, JTail_t > >
 Implementation of JTreeWriterObjectOutput for multiple data types. 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...
 
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 char *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...
 
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 (TPRegexp &regexp, const TString &string, int i=1)
 Match a TString to a TPRegexp, and return the chosen match. 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 (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...
 
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

Typedef Documentation

◆ counter_type

typedef Long64_t JROOT::counter_type

Type definition for counter.

Definition at line 24 of file JCounter.hh.

Function Documentation

◆ advance()

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 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  }

◆ getDataMember() [1/2]

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 634 of file JRootClass.hh.

636  {
637  if (parent.getClass() != NULL) {
638 
639  TIterator* i = NULL;
640 
641  i = parent.getClass()->GetListOfDataMembers()->MakeIterator();
642 
643  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
644 
645  const JRootClass abc = parent.get(*p);
646 
647  if (abc == member && abc.getOffset() == member.getOffset()) {
648  return p;
649  }
650  }
651 
652  i = parent.getClass()->GetListOfBases()->MakeIterator();
653 
654  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
655 
656  if (JRootClass::is_class(*p) && !JRootClass::is_STLcontainer(*p)) {
657 
658  const TDataMember* q = getDataMember(parent.get(*p), member);
659 
660  if (q != NULL) {
661  return q;
662  }
663  }
664  }
665  }
666 
667  return NULL;
668  }

◆ getDataMember() [2/2]

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 678 of file JRootClass.hh.

679  {
680  return getDataMember(JRootClass(getType<JClass_t>()), JRootClass(pd));
681  }

◆ getROOTClassSelection()

template<class T >
std::set<JROOTClassSelector> JROOT::getROOTClassSelection ( )
inline

Get ROOT class selection.

Returns
ROOT class selection

Definition at line 220 of file JROOTClassSelector.hh.

221  {
222  return JROOTClassSelection(JType<T>());
223  }

◆ getObject()

template<class T >
void JROOT::getObject ( TFile *  file,
const char *  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  }

◆ putObject()

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  }

◆ actionAtFileOpen()

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  }

◆ actionAtFileRead()

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  }

◆ getName() [1/2]

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 45 of file JRootToolkit.hh.

46  {
47  return getName(JType<T>());
48  }

◆ getName() [2/2]

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 58 of file JRootToolkit.hh.

59  {
60  return T::Class_Name();
61  }

◆ operator<<()

TFile& JROOT::operator<< ( TFile &  file,
const TObject object 
)

Write object to ROOT file.

Parameters
fileROOT file
objectROOT object
Returns
ROOT file

Definition at line 71 of file JRootToolkit.hh.

72  {
73  file.WriteTObject(&object);
74 
75  return file;
76  }

◆ getStreamerInfo() [1/2]

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 87 of file JRootToolkit.hh.

88  {
89  if (file != NULL && file->IsOpen()) {
90 
91  const TString buffer(name);
92 
93  TIter iter(file->GetStreamerInfoList());
94 
95  for (const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
96  if (buffer == TString(pStreamerInfo->GetName())) {
97  return pStreamerInfo;
98  }
99  }
100  }
101 
102  return NULL;
103  }

◆ getStreamerInfo() [2/2]

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 114 of file JRootToolkit.hh.

115  {
116  JRootInputFile file(file_name);
117 
118  return getStreamerInfo(file.getFile(), name);
119  }

◆ getStreamerVersion() [1/2]

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 130 of file JRootToolkit.hh.

131  {
132  const TStreamerInfo* pStreamerInfo = getStreamerInfo(file, name);
133 
134  if (pStreamerInfo != NULL)
135  return pStreamerInfo->GetClassVersion();
136  else
137  return -1;
138  }

◆ getStreamerVersion() [2/2]

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 149 of file JRootToolkit.hh.

150  {
151  JRootInputFile file(file_name);
152 
153  return getStreamerVersion(file.getFile(), name);
154  }

◆ parse()

TString JROOT::parse ( TPRegexp &  regexp,
const TString &  string,
int  i = 1 
)
inline

Match a TString to a TPRegexp, and return the chosen match.

If no matches are found corresponding to the indicated index, the original TString is returned.

Parameters
stringstring to parse
regexpregular expression
iindex of match to return
Returns
match; (original string in case that matches are not found)

Definition at line 167 of file JRootToolkit.hh.

168  {
169  TObjArray* a = regexp.MatchS(string);
170  TString s = string;
171  if (a->GetLast() > i-1){
172  s = ((TObjString*)a->At(i))->GetName();
173  }
174 
175  return s;
176  }

◆ setParameter()

bool JROOT::setParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Set fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 228 of file JRootToolkit.hh.

229  {
230  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
231 
232  f1.SetParameter(parameter.index, parameter.value);
233 
234  return true;
235 
236  } else {
237 
238  return false;
239  }
240  }

◆ fixParameter()

bool JROOT::fixParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Fix fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 249 of file JRootToolkit.hh.

250  {
251  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
252 
253  f1.FixParameter(parameter.index, parameter.value);
254 
255  return true;
256 
257  } else {
258 
259  return false;
260  }
261  }

◆ releaseParameter()

bool JROOT::releaseParameter ( TF1 &  f1,
const Int_t  index 
)
inline

Release fit parameter.

Parameters
f1fit function
indexparameter index

Definition at line 270 of file JRootToolkit.hh.

271  {
272  if (index >= 0 && index < f1.GetNpar()) {
273 
274  f1.ReleaseParameter(index);
275 
276  return true;
277 
278  } else {
279 
280  return false;
281  }
282  }

◆ setParLimits()

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 293 of file JRootToolkit.hh.

294  {
295  using namespace std;
296 
297  if (index >= 0 && index < f1.GetNpar()) {
298 
299  if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
300  if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
301 
302  f1.SetParLimits(index, xmin, xmax);
303 
304  return true;
305 
306  } else {
307 
308  return false;
309  }
310  }

◆ isParameterFixed()

bool JROOT::isParameterFixed ( TF1 &  f1,
const Int_t  index 
)
inline

Check if fit parameter is fixed.

Parameters
f1fit function
indexparameter index

Definition at line 319 of file JRootToolkit.hh.

320  {
321  if (index >= 0 && index < f1.GetNpar()) {
322 
323  Double_t xmin;
324  Double_t xmax;
325 
326  f1.GetParLimits(index, xmin, xmax);
327 
328  return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
329 
330  } else {
331 
332  return false;
333  }
334  }

◆ getResult()

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 352 of file JRootToolkit.hh.

355  {
356  using namespace std;
357  using namespace JPP;
358 
359  string buffer = (const char*) text;
360 
361  for (string::size_type pos = 0; pos != buffer.size(); ) {
362 
363  if (isalpha(buffer[pos]) || buffer[pos] == '_') {
364 
365  string::size_type len = 1;
366 
367  while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] == '_' || buffer[pos+len] == '.')) {
368  ++len;
369  }
370 
371  ostringstream os;
372 
373  os.precision(10);
374 
375  JRootPrinter::print(os, object, buffer.substr(pos,len), dictionary);
376 
377  buffer.replace(pos, len, os.str());
378 
379  pos += os.str().size();
380 
381  } else {
382 
383  pos += 1;
384  }
385  }
386 
387  return TFormula("/tmp", buffer.c_str()).Eval(0.0);
388  }

◆ getTreeParameters() [1/2]

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 149 of file JTreeParameters.hh.

150  {
151  return getTreeParameters(JType<T>());
152  }

◆ getTreeParameters() [2/2]

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

◆ getTreeCopyWriter()

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  }
text
char text[TEXT_SIZE]
Definition: elog.cc:72
JROOT::JRootClass::getClass
TClass * getClass() const
Get class.
Definition: JRootClass.hh:181
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:73
JROOT::JRootClass::get
JRootClass get(const TDataMember &data_member) const
Get ROOT class of given data member.
Definition: JRootClass.hh:278
JROOT::JRootClass::getOffset
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:170
JROOT::JActionAtFileOpen
Auxiliary class to handle version management of given class at opening of a ROOT file.
Definition: JRootSupportkit.hh:31
JROOT::getStreamerVersion
int getStreamerVersion(const char *file_name, const char *name)
Get ROOT streamer version of class with given name.
Definition: JRootToolkit.hh:149
JROOT::getDataMember
const TDataMember * getDataMember(JType_t JClass_t::*pd)
Get ROOT data member for given C++ data member.
Definition: JRootClass.hh:678
JROOT::JRootClass
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:38
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JROOT::JFitParameter_t::index
Int_t index
Definition: JRootToolkit.hh:217
JROOT::JRootInputFile
ROOT input file.
Definition: JRootFile.hh:101
JROOT::getStreamerInfo
const TStreamerInfo * getStreamerInfo(const char *file_name, const char *name)
Get ROOT streamer information of class with given name.
Definition: JRootToolkit.hh:114
JROOT::JROOTClassSelection
Auxiliary class for ROOT class selection.
Definition: JROOTClassSelector.hh:91
JROOT::JActionAtFileRead
Auxiliary class to handle version management of given class at reading from a ROOT file.
Definition: JRootSupportkit.hh:85
JROOT::getTreeParameters
JNullType getTreeParameters(const JType< T > &type)
Method with argument definition for obtaining TTree parameters.
std
Definition: jaanetDictionary.h:36
JROOT::getName
const char * getName(const JType< T > &type)
Get ROOT name of given data type.
Definition: JRootToolkit.hh:58
JROOT::JFitParameter_t::value
Double_t value
Definition: JRootToolkit.hh:218
print
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
Definition: JTriggerMonitor.cc:38
JROOT::counter_type
Long64_t counter_type
Type definition for counter.
Definition: JCounter.hh:24