TTable
Wraps the array of the plain C-structures (one C-structure per element)
class TTable provides the automatic schema evolution for
the derived "table" classes saved with ROOT format.
"Automatic Schema evolution" provides:
- skipping data-member if it is not present for the current
implementation of the "table" but was present at the time the
table was written;
- assign a default value ZERO for the brand-new data-members,
those were not in the structure when the object was written but
present now;
- trace propely any change in the order of the data-members
To enjoy this class one has to derive his/her own custom class:
St_dst_track_Table.h:
#ifndef STAF_St_dst_track_Table
#define STAF_St_dst_track_Table
#include "TTable.h"
#include "dst_track.h" the C-structure defintion may be kept
separately
typedef struct dst_track_st {
float r0; /* radius at start (cm). See also comments*
float phi0; /* azimuthal angle at start (deg) *
float z0; /* z-coord. at start (cm) *
float psi; /* azimuthal angle of pT vector (deg) *
float tanl; /* tan(dip) =pz/pt at start *
float invpt; /* 1/pt at start (GeV/c)^(-1) *
float curvature; /* Track curvature (1/cm) *
float covar[15]; /* full covariance matrix *
float chisq[2]; /* Chi-square per degree of freedom *
float x_first[3]; /* coord. of first measured point (cm) *
float x_last[3]; /* coord. of last measured point (cm) *
float length; /* from first to last point (cm) *
float impact; /* primary vertex (cm) *
unsigned long map[2]; /* extrap. info. (see preceeding comments)*
int id; /* Primary key (see comments) *
int iflag; /* bitmask quality info. (see comments) *
int det_id; /* Detector id information *
int method; /* Track finding/fitting method, packed *
int pid; /* Geant particle ID for assumed mass *
int n_point; /* SVT, TPC, FTPC component #s are packed *
int n_max_point; /* SVT, TPC, FTPC component #s are packed *
int n_fit_point; /* SVT, TPC, FTPC component #s are packed *
int icharge; /* Particle charge in units of |e| *
int id_start_vertex; /* final fit and primary track candidates *
} DST_TRACK_ST;
class St_dst_track : public TTable
{
public:
ClassDefTable(St_dst_track,dst_track_st)
ClassDef(St_dst_track,2) //C++ wrapper for <dst_track> StAF table
};
#endif
where the CPP macro defines several convinient methods for the
"table" class (see: $ROOTSYS/table/inc/Ttypes.h for details:
#define ClassDefTable(className,structName)
protected:
static TTableDescriptor *fgColDescriptors;
virtual TTableDescriptor *GetDescriptorPointer() const { return fgColDescriptors;}
virtual void SetDescriptorPointer(TTableDescriptor *list) const { fgColDescriptors = list;}
public:
typedef structName* iterator;
className() : TTable(_QUOTE_(className),sizeof(structName)) {SetType(_QUOTE_(structName));}
className(const Text_t *name) : TTable(name,sizeof(structName)) {SetType(_QUOTE_(structName));}
className(Int_t n) : TTable(_QUOTE_(className),n,sizeof(structName)) {SetType(_QUOTE_(structName));}
className(const Text_t *name,Int_t n) : TTable(name,n,sizeof(structName)) {SetType(_QUOTE_(structName));}
structName *GetTable(Int_t i=0) const { return ((structName *)GetArray())+i;}
structName &operator[](Int_t i){ assert(i>=0 && i < GetNRows()); return *GetTable(i); }
const structName &operator[](Int_t i) const { assert(i>=0 && i < GetNRows()); return *((const structName *)(GetTable(i))); }
structName *begin() const { return GetNRows()? GetTable(0):0;}
structName *end() const {Int_t i = GetNRows(); return i? GetTable(i):0;}
The class implementation file may 2 lines and look as follows:
(for the example above):
St_dst_track_Table.cxx:
#include "St_dst_track_Table.h"
TableClassImpl(St_dst_track, dst_track_st)
LinkDef.h
To provide ROOT I/O for this class TWO CINT dictonary entries
should be defined with your custom LinkDef.h file
1. First entry (as usually) for the class derived from TTable
for example:
#pragma C++ class St_dst_track
2. Second entry for the C-structure wrapped into the class.
Since C-structuire is not derived from TObject it must be
properly defined as "foreign" ROOT class
#pragma C++ class dst_track_st+;
meta-variables i$ and n$ introduced
where "i$" stands for the current row index
"n$" stands for the total number of rows
meta-variable can be used along the normal
table column names in the expressions (see for example
method TTable::Draw