LCOV - code coverage report
Current view: top level - STEER/STEERBase - TTreeStream.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 27 11.1 %
Date: 2016-06-14 17:26:59 Functions: 3 41 7.3 %

          Line data    Source code
       1             : #ifndef TTREESTREAM_H
       2             : #define TTREESTREAM_H
       3             : ///////////////////////////////////////////////////////////////////////////////
       4             : //                                                                           //
       5             : //  TTreeSRedirector                                                              //                      
       6             : 
       7             : #include "TObject.h"
       8             : #include "TString.h"
       9             : #include "TTree.h"
      10             : #include "TDirectory.h"
      11             : #include "TFile.h"
      12             : class TObjArray;
      13             : class TTree;
      14             : class TDataType;
      15             : 
      16           0 : class TTreeDataElement: public TNamed {
      17             :   friend class TTreeStream;
      18             :  public:
      19             :   TTreeDataElement(Char_t type);
      20             :   TTreeDataElement(TDataType* type);
      21             :   TTreeDataElement(TClass* cl);
      22           0 :   void   SetPointer(void* pointer) {fPointer=pointer;} 
      23           0 :   Char_t GetType() const {return fType;}
      24             :  protected:
      25             : 
      26             :   TTreeDataElement(const TTreeDataElement & tde);
      27             :   TTreeDataElement & operator=(const TTreeDataElement & tde);
      28             : 
      29             :   Char_t  fType;     // type of data element
      30             :   TDataType *fDType; //data type pointer 
      31             :   TClass    *fClass; //data type pointer
      32             :   void * fPointer;  // pointer to element
      33         176 :   ClassDef(TTreeDataElement,2)
      34             : };
      35             : 
      36             : class TTreeStream: public TNamed {
      37             :   friend class TTreeSRedirector;
      38             : public:
      39             :   TTreeStream(const char *treename, TTree* externalTree=NULL);
      40             :   ~TTreeStream();
      41             :   void Close();
      42             :   static void Test();
      43             :   Int_t CheckIn(Char_t type, void *pointer);  
      44             :   //Int_t CheckIn(const char *type, void *pointer);
      45             :   Int_t CheckIn(TObject *o);
      46             :   void BuildTree();
      47             :   void Fill();
      48           0 :   Double_t GetSize(){ return fTree->GetZipBytes();}
      49             :   TTreeStream& Endl();
      50             :   //
      51           0 :   TTreeStream  &operator<<(Bool_t   &b){CheckIn('B',&b);return *this;}
      52           0 :   TTreeStream  &operator<<(Char_t   &c){CheckIn('B',&c);return *this;}
      53           0 :   TTreeStream  &operator<<(UChar_t  &c){CheckIn('b',&c);return *this;}
      54           0 :   TTreeStream  &operator<<(Short_t  &h){CheckIn('S',&h);return *this;}
      55           0 :   TTreeStream  &operator<<(UShort_t &h){CheckIn('s',&h);return *this;}
      56           0 :   TTreeStream  &operator<<(Int_t    &i){CheckIn('I',&i);return *this;}
      57           0 :   TTreeStream  &operator<<(UInt_t   &i){CheckIn('i',&i);return *this;}
      58           0 :   TTreeStream  &operator<<(Long_t   &l){CheckIn('L',&l);return *this;}
      59           0 :   TTreeStream  &operator<<(ULong_t  &l){CheckIn('l',&l);return *this;}
      60           0 :   TTreeStream  &operator<<(Long64_t &l){CheckIn('L',&l);return *this;}
      61           0 :   TTreeStream  &operator<<(ULong64_t &l){CheckIn('l',&l);return *this;}
      62           0 :   TTreeStream  &operator<<(Float_t   &f){CheckIn('F',&f);return *this;}
      63           0 :   TTreeStream  &operator<<(Double_t  &d){CheckIn('D',&d);return *this;}
      64           0 :   TTreeStream  &operator<<(TObject*o){CheckIn(o);return *this;} 
      65             :   TTreeStream  &operator<<(const Char_t *name);
      66           0 :   TTree * GetTree() const { return fTree;}
      67             :  protected:
      68             :   //
      69             : 
      70             :   TTreeStream(const TTreeStream & ts);
      71             :   TTreeStream & operator=(const TTreeStream & ts);
      72             : 
      73             :   TObjArray *fElements; //array of elements
      74             :   TObjArray *fBranches; //pointers to branches
      75             :   TTree *fTree;         //data storage
      76             :   Int_t fCurrentIndex;  //index of current element
      77             :   Int_t fId;            //identifier of layout
      78             :   TString fNextName;    //name for next entry
      79             :   Int_t   fNextNameCounter; //next name counter
      80             :   Int_t   fStatus;      //status of the layout
      81         176 :   ClassDef(TTreeStream,1)
      82             : };
      83             : 
      84             : 
      85             : class TTreeSRedirector: public TObject { 
      86             : public:
      87             :   TTreeSRedirector(const char *fname="", const char * option="update");
      88             :   virtual ~TTreeSRedirector();
      89             :   void Close();
      90             :   static void Test();
      91             :   static void Test2();
      92             :   static void UnitTestSparse(Double_t scale, Int_t testEntries);
      93             :   static void UnitTest(Int_t testEntries=5000);
      94             :   void StoreObject(TObject* object);
      95           0 :   TFile * GetFile() {return fDirectory->GetFile();}
      96           0 :   TDirectory * GetDirectory() {return fDirectory;}
      97             :   virtual   TTreeStream  &operator<<(Int_t id);
      98             :   virtual   TTreeStream  &operator<<(const char *name);
      99             :   void      SetDirectory(TDirectory *sfile); 
     100           0 :   void      SetFile(TFile *sfile) {SetDirectory(sfile);} 
     101             :   void SetExternalTree(const char* name, TTree* externalTree);
     102           0 :   static void SetDisabled(Bool_t b=kTRUE) {fgDisabled=b;}
     103           0 :   static Bool_t IsDisabled()        {return fgDisabled;}
     104             :  
     105             : private:
     106             : 
     107             :   TTreeSRedirector(const TTreeSRedirector & tsr);
     108             :   TTreeSRedirector & operator=(const TTreeSRedirector & tsr);
     109             : 
     110             :   TDirectory* fDirectory;        //file
     111             :   Bool_t      fDirectoryOwner;   //do we own the directory?
     112             :   TObjArray *fDataLayouts;   //array of data layouts
     113             :   static Bool_t fgDisabled;  //disable - do not open any files
     114         176 :   ClassDef(TTreeSRedirector,2) 
     115             : };
     116             : 
     117             : 
     118             : 
     119             : 
     120             : #endif

Generated by: LCOV version 1.11