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  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 TGraph object and optionally reset contents. More...
 
bool resetObject (TGraph2DErrors *object, const bool reset=false)
 Detach TGraphErrors 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 fonst size [NDC]
46  const Double_t fy = 1.10 * ch/h; // estimated fonst 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  }
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  }
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 53 of file JRootToolkit.hh.

54  {
55  return getName(JType<T>());
56  }
const char * getName()
Get ROOT name of given data type.
Definition: JRootToolkit.hh:53
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 66 of file JRootToolkit.hh.

67  {
68  return T::Class_Name();
69  }
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 79 of file JRootToolkit.hh.

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

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

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

Detach TGraph object and optionally reset contents.

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

Definition at line 152 of file JRootToolkit.hh.

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

Detach TGraphErrors object and optionally reset contents.

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

Definition at line 176 of file JRootToolkit.hh.

177  {
178  if (object != NULL) {
179 
180  if (reset) {
181  for (int i = 0; i != object->GetN(); ++i) {
182  object->SetPoint (i, 0.0, 0.0, 0.0);
183  object->SetPointError(i, 0.0, 0.0, 0.0);
184  }
185  }
186 
187  return true;
188  }
189 
190  return false;
191  }
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 201 of file JRootToolkit.hh.

202  {
203  if (object != NULL) {
204 
205  object->SetDirectory(0);
206 
207  if (reset) {
208  object->Reset();
209  }
210 
211  return true;
212  }
213 
214  return false;
215  }
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 225 of file JRootToolkit.hh.

228  {
229  const Int_t n = g1->GetN();
230 
231  g1->Set(n + 1);
232  g1->SetPoint(n, x, y);
233  }
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 244 of file JRootToolkit.hh.

248  {
249  const Int_t n = g1->GetN();
250 
251  g1->Set(n + 1);
252  g1->SetPoint(n, x, y, z);
253  }
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 265 of file JRootToolkit.hh.

270  {
271  const Int_t n = g1->GetN();
272 
273  g1->Set(n + 1);
274  g1->SetPoint(n, x, y);
275  g1->SetPointError(n, ex, ey);
276  }
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 290 of file JRootToolkit.hh.

297  {
298  const Int_t n = g1->GetN();
299 
300  g1->Set(n + 1);
301  g1->SetPoint(n, x, y, z);
302  g1->SetPointError(n, ex, ey, ez);
303  }
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 313 of file JRootToolkit.hh.

314  {
315  file.WriteTObject(&object);
316 
317  return file;
318  }
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 329 of file JRootToolkit.hh.

330  {
331  if (file != NULL && file->IsOpen()) {
332 
333  const TString buffer(name);
334 
335  TIter iter(file->GetStreamerInfoList());
336 
337  for (const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
338  if (buffer == TString(pStreamerInfo->GetName())) {
339  return pStreamerInfo;
340  }
341  }
342  }
343 
344  return NULL;
345  }
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 356 of file JRootToolkit.hh.

357  {
358  JRootInputFile file(file_name);
359 
360  return getStreamerInfo(file.getFile(), name);
361  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
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 372 of file JRootToolkit.hh.

373  {
374  const TStreamerInfo* pStreamerInfo = getStreamerInfo(file, name);
375 
376  if (pStreamerInfo != NULL)
377  return pStreamerInfo->GetClassVersion();
378  else
379  return -1;
380  }
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
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 391 of file JRootToolkit.hh.

392  {
393  JRootInputFile file(file_name);
394 
395  return getStreamerVersion(file.getFile(), name);
396  }
int getStreamerVersion(TFile *file, const char *name)
Get ROOT streamer version of class with given name.
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 409 of file JRootToolkit.hh.

410  {
411  TPRegexp buffer = regexp;
412  TObjArray* array = buffer.MatchS(string);
413 
414  if (index - 1 < array->GetLast())
415  return ((TObjString*) array->At(index))->GetName();
416  else
417  return string;
418  }
bool JROOT::setParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Set fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 470 of file JRootToolkit.hh.

471  {
472  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
473 
474  f1.SetParameter(parameter.index, parameter.value);
475 
476  return true;
477 
478  } else {
479 
480  return false;
481  }
482  }
bool JROOT::fixParameter ( TF1 &  f1,
const JFitParameter_t parameter 
)
inline

Fix fit parameter.

Parameters
f1fit function
parameterparameter index and value

Definition at line 491 of file JRootToolkit.hh.

492  {
493  if (parameter.index >= 0 && parameter.index < f1.GetNpar()) {
494 
495  f1.FixParameter(parameter.index, parameter.value);
496 
497  return true;
498 
499  } else {
500 
501  return false;
502  }
503  }
bool JROOT::releaseParameter ( TF1 &  f1,
const Int_t  index 
)
inline

Release fit parameter.

Parameters
f1fit function
indexparameter index

Definition at line 512 of file JRootToolkit.hh.

513  {
514  if (index >= 0 && index < f1.GetNpar()) {
515 
516  f1.ReleaseParameter(index);
517 
518  return true;
519 
520  } else {
521 
522  return false;
523  }
524  }
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 535 of file JRootToolkit.hh.

536  {
537  using namespace std;
538 
539  if (index >= 0 && index < f1.GetNpar()) {
540 
541  if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
542  if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
543 
544  f1.SetParLimits(index, xmin, xmax);
545 
546  return true;
547 
548  } else {
549 
550  return false;
551  }
552  }
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 561 of file JRootToolkit.hh.

562  {
563  if (index >= 0 && index < f1.GetNpar()) {
564 
565  Double_t xmin;
566  Double_t xmax;
567 
568  f1.GetParLimits(index, xmin, xmax);
569 
570  return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
571 
572  } else {
573 
574  return false;
575  }
576  }
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 594 of file JRootToolkit.hh.

597  {
598  using namespace std;
599  using namespace JPP;
600 
601  string buffer = (const char*) text;
602 
603  for (string::size_type pos = 0; pos != buffer.size(); ) {
604 
605  if (isalpha(buffer[pos]) || buffer[pos] == '_') {
606 
607  string::size_type len = 1;
608 
609  while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] == '_' || buffer[pos+len] == '.')) {
610  ++len;
611  }
612 
613  ostringstream os;
614 
615  os.setf(ios::fixed);
616  os.precision(10);
617 
618  JRootPrinter::print(os, object, buffer.substr(pos,len), dictionary);
619 
620  buffer.replace(pos, len, os.str());
621 
622  pos += os.str().size();
623 
624  } else {
625 
626  pos += 1;
627  }
628  }
629 
630  return TFormula("/tmp", buffer.c_str()).Eval(0.0);
631  }
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 640 of file JRootToolkit.hh.

640  {
641 
642  const int N = in.GetNbinsX();
643 
644  std::vector<double> x(N), y(N);
645 
646  for (int i = 0; i < N; i++) {
647  x[i] = in.GetBinCenter (i + 1);
648  y[i] = in.GetBinContent(i + 1);
649  }
650 
651  TGraph* out = new TGraph(N, &x[0], &y[0]);
652 
653  return out;
654 
655  }
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
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 665 of file JRootToolkit.hh.

665  {
666 
667  int inf_bin, sup_bin;
668 
669  switch(coordinate) {
670 
671  case 'x':
672  case 'X':
673  inf_bin = in.GetYaxis()->FindBin(inf);
674  sup_bin = in.GetYaxis()->FindBin(sup);
675  return in.ProjectionX("_px", inf_bin, sup_bin);
676 
677  case 'y':
678  case 'Y':
679  inf_bin = in.GetXaxis()->FindBin(inf);
680  sup_bin = in.GetXaxis()->FindBin(sup);
681  return in.ProjectionY("_py", inf_bin, sup_bin);
682 
683  default:
684  return NULL;
685 
686  }
687 
688  }
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
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