Jpp
 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  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  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  JRootAddressableClass
 Auxiliary class to manage access to base classes and data members of ROOT class objects. More...
 
struct  JRootClassReader
 ROOT class for reading object. More...
 
struct  JRootClassWriter
 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...
 
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...
 
class  JRootReader
 Implementation for ASCII input of objects with ROOT dictionary. More...
 
class  JRootWriter
 Implementation for ASCII output of objects with ROOT dictionary. More...
 
class  JObjectStreamer
 JObjectStreamer 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  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  JRootDictionary
 ROOT dictionary. More...
 

Typedefs

typedef Long64_t counter_type
 Type definition for counter. More...
 
typedef std::map< std::string,
JSharedPointer
< JAbstractStreamer > > 
JRootDictionary_t
 Type definition of ROOT dictionary. 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...
 
template<class T >
std::set< JROOTClassSelectorgetROOTClassSelection ()
 Get ROOT class selection. 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...
 
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 print (std::ostream &out, const T &object, const std::string &key, const JRootDictionary_t &dictionary)
 Write content to output. 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...
 
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...
 
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 >
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

typedef Long64_t JROOT::counter_type

Type definition for counter.

Definition at line 24 of file JCounter.hh.

Type definition of ROOT dictionary.

Definition at line 43 of file JRootStreamer.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 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.
Definition: JCounter.hh:24
template<class T >
std::set<JROOTClassSelector> JROOT::getROOTClassSelection ( )
inline

Get ROOT class selection.

Returns
ROOT class selection

Definition at line 227 of file JROOTClassSelector.hh.

228  {
229  return JROOTClassSelection(JType<T>());
230  }
Auxiliary class for ROOT class selection.
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 40 of file JRootFileReader.hh.

41  {
42  return getName(JType<T>());
43  }
const char * getName()
Get ROOT name of given data type.
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 53 of file JRootFileReader.hh.

54  {
55  return T::Class_Name();
56  }
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 67 of file JRootFileReader.hh.

68  {
69  if (file != NULL) {
70  file->GetObject(key, ps);
71  }
72  }
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 41 of file JRootFileWriter.hh.

42  {
43  return (dir != NULL && dir->WriteTObject(&object) > 0);
44  }
template<class T >
void JROOT::print ( std::ostream &  out,
const T &  object,
const std::string &  key,
const JRootDictionary_t dictionary 
)
inline

Write content to output.

Parameters
outoutput stream
objectobject
key'.' separated list of data member names
dicttionarydictionary

Definition at line 771 of file JRootStreamer.hh.

775  {
776  using namespace std;
777  using namespace JPP;
778 
779  const char separator = '.';
780 
781  JRootWriter writer(out, JEquationParameters("=", "\n", ".", ""), dictionary);
782 
783  JRootClassWriter cls(object);
784 
785  if (key != "") {
786  for (string::size_type i = 0, j = 0; j != string::npos && cls.is_valid(); i = j + 1) {
787  j = key.substr(i).find(separator);
788  cls = cls.find(key.substr(i, j - i).c_str());
789  }
790  }
791 
792  if (cls.is_valid()) {
793  if (writer.getDictionary().find(cls.getTypename()) != writer.getDictionary().end())
794  writer.putObject(cls);
795  else
796  writer.put(cls);
797  }
798  }
Implementation for ASCII output of objects with ROOT dictionary.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
ROOT class for writing object.
Definition: JRootClass.hh:568
std::ostream & separator(std::ostream &out)
Print separator.
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...
TFile& JROOT::operator<< ( TFile &  file,
const TObject object 
)

Write object to ROOT file.

Parameters
fileROOT file
objectROOT object
Returns
ROOT file

Definition at line 33 of file JRootToolkit.hh.

34  {
35  file.WriteTObject(&object);
36 
37  return file;
38  }
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 49 of file JRootToolkit.hh.

50  {
51  if (file != NULL && file->IsOpen()) {
52 
53  const TString buffer(name);
54 
55  TIter iter(file->GetStreamerInfoList());
56 
57  for (const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
58  if (buffer == TString(pStreamerInfo->GetName())) {
59  return pStreamerInfo;
60  }
61  }
62  }
63 
64  return NULL;
65  }
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 76 of file JRootToolkit.hh.

77  {
78  JRootInputFile file(file_name);
79 
80  return getStreamerInfo(file.getFile(), name);
81  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
Definition: JRootToolkit.hh:49
ROOT input file.
Definition: JRootFile.hh:101
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 92 of file JRootToolkit.hh.

93  {
94  const TStreamerInfo* pStreamerInfo = getStreamerInfo(file, name);
95 
96  if (pStreamerInfo != NULL)
97  return pStreamerInfo->GetClassVersion();
98  else
99  return -1;
100  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
Definition: JRootToolkit.hh:49
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 111 of file JRootToolkit.hh.

112  {
113  JRootInputFile file(file_name);
114 
115  return getStreamerVersion(file.getFile(), name);
116  }
int getStreamerVersion(TFile *file, const char *name)
Get ROOT streamer version of class with given name.
Definition: JRootToolkit.hh:92
ROOT input file.
Definition: JRootFile.hh:101
bool JROOT::setParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Set fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 168 of file JRootToolkit.hh.

169  {
170  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
171 
172  f1.SetParameter(parameter.index, parameter.value);
173 
174  return true;
175 
176  } else {
177 
178  return false;
179  }
180  }
bool JROOT::fixParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Fix fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 189 of file JRootToolkit.hh.

190  {
191  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
192 
193  f1.FixParameter(parameter.index, parameter.value);
194 
195  return true;
196 
197  } else {
198 
199  return false;
200  }
201  }
bool JROOT::releaseParameter ( TF1 &  f1,
const Int_t  index 
)
inline

Release fit parameter.

Parameters
f1fit function
indexparameter index

Definition at line 210 of file JRootToolkit.hh.

211  {
212  if (index >= 0 && index < f1.GetNpar()) {
213 
214  f1.ReleaseParameter(index);
215 
216  return true;
217 
218  } else {
219 
220  return false;
221  }
222  }
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 233 of file JRootToolkit.hh.

234  {
235  using namespace std;
236 
237  if (index >= 0 && index < f1.GetNpar()) {
238 
239  if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
240  if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
241 
242  f1.SetParLimits(index, xmin, xmax);
243 
244  return true;
245 
246  } else {
247 
248  return false;
249  }
250  }
bool JROOT::isParameterFixed ( TF1 &  f1,
const Int_t  index 
)
inline

Check if fit parameter is fixed.

Parameters
f1fit function
indexparameter index

Definition at line 259 of file JRootToolkit.hh.

260  {
261  if (index >= 0 && index < f1.GetNpar()) {
262 
263  Double_t xmin;
264  Double_t xmax;
265 
266  f1.GetParLimits(index, xmin, xmax);
267 
268  return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
269 
270  } else {
271 
272  return false;
273  }
274  }
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  }
JROOT::JTreeParameters getTreeParameters(JLANG::JType< JFIT::JEvt >)
Get TTree parameters for given data type.
Definition: JEvt.hh:367
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:73