TTable


class description - source file - inheritance tree

class TTable : public TDataSet, public TArray


    protected:
virtual void Clear(Option_t* opt) void CopyStruct(Char_t* dest, const Char_t* src) Char_t* Create() virtual void Delete(Option_t* opt) virtual Bool_t EntryLoop(const Char_t* exprFileName, Int_t& action, TObject* obj, Int_t nentries = 1000000000, Int_t firstentry = 0, Option_t* option) virtual TTableDescriptor* GetDescriptorPointer() const int PointerToPointer(G__DataMemberInfo& m) void ReAlloc(Int_t newsize) virtual void SetDescriptorPointer(TTableDescriptor* list) const Int_t SetfN(Long_t len) void SetTablePointer(void* table) void SetType(const Text_t *const type) void SetUsedRows(Int_t n) void StreamerHeader(TBuffer& b, Version_t version = 3) void StreamerTable(TBuffer& b, Version_t version = 3) public:
TTable TTable(const Text_t* name = 0, Int_t size = 0) TTable TTable(const Text_t* name, Int_t n, Int_t size) TTable TTable(const Text_t* name, Int_t n, Char_t* array, Int_t size) TTable TTable(const Text_t* name, const Text_t* type, Int_t n, Char_t* array, Int_t size) TTable TTable(const TTable& table) virtual void ~TTable() virtual Int_t AddAt(const void* c) virtual void AddAt(const void* c, Int_t i) virtual void Adopt(Int_t n, void* array) virtual void AsString(void* buf, const char* name, Int_t width = 0) const const void* At(Int_t i) const virtual void Browse(TBrowser* b) static TClass* Class() Int_t CopyRows(const TTable* srcTable, Int_t srcRow = 0, Int_t dstRow = 0, Int_t nRows = 0, Bool_t expand = kFALSE) virtual void CopySet(TTable& array) virtual void Draw(Option_t* opt) virtual TH1* Draw(TCut varexp, TCut selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual TH1* Draw(const Text_t* varexp, const Text_t* selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual void Fit(const Text_t* formula, const Text_t* varexp, const Text_t* selection, Option_t* option, Option_t* goption, Int_t nentries = 1000000000, Int_t firstentry = 0) void* GetArray() const virtual Int_t GetColumnIndex(const Char_t* columnName) const virtual const Char_t* GetColumnName(Int_t columnIndex) const virtual UInt_t GetColumnSize(Int_t columnIndex) const virtual Int_t GetColumnSize(const Char_t* columnName = 0) const virtual TTable::EColumnType GetColumnType(Int_t columnIndex) const virtual TTable::EColumnType GetColumnType(const Char_t* columnName = 0) const virtual UInt_t GetDimensions(Int_t columnIndex) const virtual Int_t GetDimensions(const Char_t* columnName = 0) const virtual const UInt_t* GetIndexArray(Int_t columnIndex) const virtual Long_t GetNRows() const virtual UInt_t GetNumberOfColumns() const virtual UInt_t GetOffset(Int_t columnIndex) const virtual Int_t GetOffset(const Char_t* columnName = 0) const virtual TClass* GetRowClass() const virtual TTableDescriptor* GetRowDescriptors() const virtual Long_t GetRowSize() const virtual TTableDescriptor* GetTableDescriptors() const virtual Long_t GetTableSize() const virtual const Char_t* GetType() const virtual UInt_t GetTypeSize(Int_t columnIndex) const virtual Int_t GetTypeSize(const Char_t* columnName = 0) const virtual Long_t HasData() const virtual TClass* IsA() const virtual Bool_t IsFolder() const virtual void ls(Option_t* option) const virtual void ls(Int_t deep) const virtual Char_t* MakeExpression(const Char_t** expressions, Int_t nExpressions) Int_t NaN() static TTable* New(const Char_t* name, const Char_t* type, void* array, UInt_t size) TTable& operator=(const TTable& rhs) void* operator[](Int_t i) const void* operator[](Int_t i) const virtual Char_t* Print(Char_t* buf, Int_t n) const virtual void Print(Option_t* opt) virtual const Char_t* Print(Int_t row, Int_t rownumber = 10, const Char_t* colfirst, const Char_t* collast) const virtual const Char_t* PrintHeader() const virtual void Project(const Text_t* hname, const Text_t* varexp, const Text_t* selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual Int_t Purge(Option_t* opt) void* ReAllocate(Int_t newsize) void* ReAllocate() virtual void Reset(Int_t c = 0) virtual void SavePrimitive(ofstream& out, Option_t* option) virtual void Set(Int_t n) virtual void Set(Int_t n, Char_t* array) virtual void SetNRows(Int_t n) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) virtual void Update() virtual void Update(TDataSet* set, UInt_t opt = 0)

Data Members

private:
Long_t fSize Size of the one element (row) of the table protected:
Char_t* fTable Array of (fN*fSize) longs Long_t fMaxIndex The used capacity of this array public:
static const TTable::EColumnType kNAN static const TTable::EColumnType kFloat static const TTable::EColumnType kInt static const TTable::EColumnType kLong static const TTable::EColumnType kShort static const TTable::EColumnType kDouble static const TTable::EColumnType kUInt static const TTable::EColumnType kULong static const TTable::EColumnType kUShort static const TTable::EColumnType kUChar static const TTable::EColumnType kChar


See also

TTableDescriptor

Class Description

                                                                      
 TTable                                                               
                                                                      
 Wraps the array of the STAF C-structures (one STAF Table 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       
                                                                      
  


TTableDescriptor* GetTableDescriptors() const
 protected: create a new TTableDescriptor descriptor for this table

void AsString(void *buf, const char *name, Int_t width) const
 AsString represents the value provided via "void *b" with type defined
          by "name"

   void *buf  - the pointer to the value to be printed out.
        name  - the name of the type for the value above
       width  - the number of psotion to be used to print the value out


const void* At(Int_t i) const
 Returns a pointer to the i-th row of the table

Int_t CopyRows(const TTable *srcTable, Int_t srcRow, Int_t dstRow, Int_t nRows, Bool_t expand)
 CopyRows copies nRows from starting from the srcRow of srcTable
 to the dstRow in this table upto nRows or by the end of this table.

 This table if automaticaly increased if expand = kTRUE.
 The old values of this table rows are to be destroyed and
 replaced with the new ones.

 PARAMETERS:
   srcTable - a pointer to the table "donor"
   srcRow   - the index of the first row of the table donor to copy from
   dstRow   - the index of the first row of this table to copy to
   nRows    - the total number of rows to be copied. This table will be expanded
              as needed if expand = kTRUE (it is kFALSE "by default")
          = 0 to copy ALL remain rows from the srcTable.
   expand   - flag whether this table should reallocated if needed.

 RETURN:
          the number of the rows been copied

TH1* Draw(TCut varexp, TCut selection, Option_t *option, Int_t nentries, Int_t firstentry)
*-*-*-*-*-*-*-*-*-*-*Draw expression varexp for specified entries-*-*-*-*-*
*-*                  ===========================================

   This function accepts TCut objects as arguments.
   Useful to use the string operator +
         example:
            table.Draw("x",cut1+cut2+cut3);

   TCutG object with "CUTG" name can be created via the graphics editor.


TH1* Draw(const Text_t *varexp00, const Text_t *selection, Option_t *option,Int_t nentries, Int_t firstentry)
*-*-*-*-*-*-*-*-*-*-*Draw expression varexp for specified entries-*-*-*-*-*
*-*                  ===========================================

  varexp is an expression of the general form e1:e2:e3
    where e1,etc is a C++ expression referencing a combination of the TTable columns
  Example:
     varexp = x     simplest case: draw a 1-Dim distribution of column named x
            = sqrt(x)            : draw distribution of sqrt(x)
            = x*y/z
            = y:sqrt(x) 2-Dim dsitribution of y versus sqrt(x)
            = phep[0]:sqrt(phep[3]) 2-Dim dsitribution of phep[0] versus sqrt(phep[3])
  Note that the variables e1, e2 or e3 may contain a boolean expression as well.
  example, if e1= x*(y<0), the value histogrammed will be x if y<0
  and will be 0 otherwise.

  selection is a C++ expression with a combination of the columns.
  The value corresponding to the selection expression is used as a weight
  to fill the histogram.
  If the expression includes only boolean operations, the result
  is 0 or 1. If the result is 0, the histogram is not filled.
  In general, the expression may be of the form:
      value*(boolean expression)
  if boolean expression is true, the histogram is filled with
  a weight = value.
  Examples:
      selection1 = "x<y && sqrt(z)>3.2"
      selection2 = "(x+y)*(sqrt(z)>3.2"
      selection3 = "signal*(log(signal)>1.2)"
  selection1 returns a weigth = 0 or 1
  selection2 returns a weight = x+y if sqrt(z)>3.2
             returns a weight = 0 otherwise.
  selection3 returns a weight = signal if log(signal)>1.2

  option is the drawing option
      see TH1::Draw for the list of all drawing options.
      If option contains the string "goff", no graphics is generated.

  nentries is the number of entries to process (default is all)
  first is the first entry to process (default is 0)

     Saving the result of Draw to an histogram
     =========================================
  By default the temporary histogram created is called htemp.
  If varexp0 contains >>hnew (following the variable(s) name(s),
  the new histogram created is called hnew and it is kept in the current
  directory.
  Example:
    tree.Draw("sqrt(x)>>hsqrt","y>0")
    will draw sqrt(x) and save the histogram as "hsqrt" in the current
    directory.

  By default, the specified histogram is reset.
  To continue to append data to an existing histogram, use "+" in front
  of the histogram name;
    table.Draw("sqrt(x)>>+hsqrt","y>0")
      will not reset hsqrt, but will continue filling.

     Making a Profile histogram
     ==========================
  In case of a 2-Dim expression, one can generate a TProfile histogram
  instead of a TH2F histogram by specyfying option=prof or option=profs.
  The option=prof is automatically selected in case of y:x>>pf
  where pf is an existing TProfile histogram.

     Saving the result of Draw to a TEventList
     =========================================
  TTable::Draw can be used to fill a TEventList object (list of entry numbers)
  instead of histogramming one variable.
  If varexp0 has the form >>elist , a TEventList object named "elist"
  is created in the current directory. elist will contain the list
  of entry numbers satisfying the current selection.
  Example:
    tree.Draw(">>yplus","y>0")
    will create a TEventList object named "yplus" in the current directory.
    In an interactive session, one can type (after TTable::Draw)
       yplus.Print("all")
    to print the list of entry numbers in the list.

  By default, the specified entry list is reset.
  To continue to append data to an existing list, use "+" in front
  of the list name;
    table.Draw(">>+yplus","y>0")
      will not reset yplus, but will enter the selected entries at the end
      of the existing list.


Bool_t EntryLoop(const Char_t *exprFileName,Int_t &action, TObject *obj ,Int_t nentries, Int_t firstentry, Option_t *option)
 EntryLoop creates a CINT bytecode to evaluate the given expressions for
 all table rows in loop and fill the appropriated histograms.

 Solution for Byte code
 From: Masaharu Goto <MXJ02154@nifty.ne.jp>
 To: <fine@bnl.gov>
 Cc: <rootdev@hpsalo.cern.ch>
 Sent: 13-th august 1999 year  23:01

  action =  1  Fill 1-D histogram obj
         =  2  Fill 2-D histogram obj
         =  3  Fill 3-D histogram obj
         =  4  Fill Profile histogram obj
         =  5  Fill a TEventlist
         = 11  Estimate Limits
         = 12  Fill 2-D PolyMarker obj
         = 13  Fill 3-D PolyMarker obj
  action < 0   Evaluate Limits for case abs(action)

  Load file

TTable(const Text_t *name, Int_t size) : TDataSet(name), fSize(size),fTable(0),fMaxIndex(0)
 Default TTable ctor.

TTable(const Text_t *name, Int_t n,Int_t size) : TDataSet(name), fSize(size),fTable(0),fMaxIndex(0)
 Create TTable object and set array size to n longs.

TTable(const Text_t *name, Int_t n, Char_t *table,Int_t size) : TDataSet(name), fSize(size),fTable(0),fMaxIndex(0)
 Create TTable object and initialize it with values of array.

TTable(const Text_t *name, const Text_t *type, Int_t n, Char_t *array, Int_t size) : TDataSet(name),fSize(size),fTable(0),fMaxIndex(0)
 Create TTable object and initialize it with values of array.

TTable(const TTable &table)
 Copy constructor.

~TTable()
 Delete TTable object.

void Adopt(Int_t n, void *arr)
 Adopt array arr into TTable, i.e. don't copy arr but use it directly
 in TTable. User may not delete arr, TTable dtor will do it.

Int_t AddAt(const void *row)
 Add        the "row" at the GetNRows() position, and
 reallocate the table if neccesary,               and
 return     the row index the "row" has occupied.

 row == 0 see method TTable::AddAt(const void *row, Int_t i)

void AddAt(const void *row, Int_t i)
 Add    one element ("row") of structure at position "i".
 Check  for out of bounds.

        If the row == 0 the "i" cell is still occupied and
 filled with the pattern "ff"

void CopyStruct(Char_t *dest, const Char_t *src)
 Copy the C-structure src into the new location
 the length of the strucutre is defined by this class descriptor

void CopySet(TTable &array)

void* ReAllocate()
 Reallocate this table leaving only (used rows)+1 allocated
 GetTableSize() = GetNRows() + 1
 returns a pointer to the first row of the reallocated table
 Note:
 The table is reallocated if it is an owner of the internal array

void* ReAllocate(Int_t newsize)
 Reallocate this table leaving only <newsize> allocated
 GetTableSize() = newsize;
 returns a pointer to the first row of the reallocated table
 Note:
 The table is reallocated if it is an owner of the internal array

void ReAlloc(Int_t newsize)
 The table is reallocated if it is an owner of the internal array

Char_t* Create()
 Allocate a space for the new table
 Sleep for a while if space is not available and try again

void Browse(TBrowser *b)
 Wrap each table coulumn with TColumnView object to browse.

void Clear(Option_t *opt)
 Deletes the internal array of this class
 if this object does own its internal table

void Delete(Option_t *opt)
 Delete the internal array and free the memory it occupied
 if this object did own this array

 Then perform TDataSet::Delete(opt)

TClass* GetRowClass() const

Long_t GetNRows() const
 Returns the number of the used rows for the wrapped table

Long_t GetRowSize() const
 Returns the size (in bytes) of one table row

Long_t GetTableSize() const
 Returns the number of the allocated rows

void Fit(const Text_t *formula ,const Text_t *varexp, const Text_t *selection,Option_t *option ,Option_t *goption,Int_t nentries, Int_t firstentry)
*-*-*-*-*-*-*-*-*Fit a projected item(s) from a TTable*-*-*-*-*-*-*-*-*-*
*-*              =======================================

  formula is a TF1 expression.

  See TTable::Draw for explanations of the other parameters.

  By default the temporary histogram created is called htemp.
  If varexp contains >>hnew , the new histogram created is called hnew
  and it is kept in the current directory.
  Example:
    table.Fit(pol4,"sqrt(x)>>hsqrt","y>0")
    will fit sqrt(x) and save the histogram as "hsqrt" in the current
    directory.


const Char_t* GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title

Bool_t IsFolder() const
 return Folder flag to be used by TBrowse object
 The tablke is a folder if
  - it has sub-dataset
  - GetNRows > 0

void ls(Option_t *option) const

void ls(Int_t deep) const

Int_t NaN()
 return the total number of the NaN for float/double cells of this table
 Thanks Victor Perevoztchikov


TTable* New(const Char_t *name, const Char_t *type, void *array, UInt_t size)
 This static method creates a new TTable object if provided

Char_t* Print(Char_t *strbuf,Int_t lenbuf) const
 Create IDL table defintion (to be used for XDF I/O)

const Char_t* PrintHeader() const
 Print general table inforamtion

const Char_t* Print(Int_t row, Int_t rownumber, const Char_t *, const Char_t *) const
/const Char_t *TTable::Print(Int_t row, Int_t rownumber, const Char_t *colfirst, const Char_t *collast) const

///const Char_t* Print(Int_t row, Int_t rownumber, const Char_t *colfirst, const Char_t *collast) const // // Print the contents of STAF tables per COLUMN. // // row - the index of the first row to print (counting from ZERO) // rownumber - the total number of rows to print out (=10 by default) // // (No use !) Char_t *colfirst, *collast - the names of the first/last // to print out (not implemented yet) // //-------------------------------------------------------------- // Check bounds and adjust it Int_t const width = 8; Int_t rowStep = 10; // The maximun values to print per line Int_t rowNumber = rownumber; if (row > Int_t(GetSize()) || GetSize() == UInt_t(0))

void Project(const Text_t *hname, const Text_t *varexp, const Text_t *selection, Option_t *option,Int_t nentries, Int_t firstentry)
*-*-*-*-*-*-*-*-*Make a projection of a TTable using selections*-*-*-*-*-*-*
*-*              =============================================

   Depending on the value of varexp (described in Draw) a 1-D,2-D,etc
   projection of the TTable will be filled in histogram hname.
   Note that the dimension of hname must match with the dimension of varexp.


Int_t Purge(Option_t *opt)
 Shrink the table to free the unused but still allocated rows

void SavePrimitive(ofstream &out, Option_t *)
   Save a primitive as a C++ statement(s) on output stream "out".

void Set(Int_t n)
 Set array size of TTable object to n longs. If n<0 leave array unchanged.

void SetTablePointer(void *table)

void SetType(const Text_t *const type)

int PointerToPointer(G__DataMemberInfo &m)

Char_t* MakeExpression(const Char_t *expressions[],Int_t nExpressions)
 return the name of temporary file with the current expressions

void Reset(Int_t c)
 Fill the entire table with byte "c" ;
/     c=0 "be default"

void Set(Int_t n, Char_t *array)
 Set array size of TTable object to n longs and copy array.
 If n<0 leave array unchanged.

void StreamerTable(TBuffer &b,Version_t version)
 Stream an object of class TTable.

void StreamerHeader(TBuffer &b, Version_t version)
 Read "table parameters first"

Int_t SetfN(Long_t len)

TTableDescriptor* GetRowDescriptors() const

TTableDescriptor* GetDescriptorPointer() const

void SetDescriptorPointer(TTableDescriptor *) const

void Streamer(TBuffer &R__b)
 Stream an array of the "plain" C-structures

void Update()

void Update(TDataSet *set, UInt_t opt)
 Kill the table current data
 and adopt those from set

Int_t GetColumnIndex(const Char_t *columnName) const

const Char_t* GetColumnName(Int_t columnIndex) const

const UInt_t* GetIndexArray(Int_t columnIndex) const

UInt_t GetNumberOfColumns() const

UInt_t GetOffset(Int_t columnIndex) const

Int_t GetOffset(const Char_t *columnName) const

UInt_t GetColumnSize(Int_t columnIndex) const

Int_t GetColumnSize(const Char_t *columnName) const

UInt_t GetTypeSize(Int_t columnIndex) const

Int_t GetTypeSize(const Char_t *columnName) const

UInt_t GetDimensions(Int_t columnIndex) const

Int_t GetDimensions(const Char_t *columnName) const



Inline Functions


                       void SetUsedRows(Int_t n)
                    TTable& operator=(const TTable& rhs)
                       TH1* Draw(const Text_t* varexp, const Text_t* selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0)
                      void* GetArray() const
                     Long_t HasData() const
                       void SetNRows(Int_t n)
                      void* operator[](Int_t i)
                const void* operator[](Int_t i) const
        TTable::EColumnType GetColumnType(Int_t columnIndex) const
        TTable::EColumnType GetColumnType(const Char_t* columnName = 0) const
                    TClass* Class()
                    TClass* IsA() const
                       void ShowMembers(TMemberInspector& insp, char* parent)
                       void StreamerNVirtual(TBuffer& b)


Author: Valery Fine(fine@mail.cern.ch) 03/07/98
Last update: root/star:$Name: $:$Id: TTable.cxx,v 1.7 2000/12/11 09:35:06 brun Exp $


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.