// @(#)root/treeplayer:$Id$
// Author: Rene Brun 29/10/09

/*************************************************************************
 * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TTreePerfStats
#define ROOT_TTreePerfStats

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TTreePerfStats                                                       //
//                                                                      //
// TTree I/O performance measurement                                    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


#ifndef ROOT_TVirtualPerfStats
#include "TVirtualPerfStats.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif


class TBrowser;
class TFile;
class TTree;
class TStopwatch;
class TPaveText;
class TGraphErrors;
class TGaxis;
class TText;
class TTreePerfStats : public TVirtualPerfStats {

protected:
   Int_t         fTreeCacheSize; //TTreeCache buffer size
   Int_t         fNleaves;       //Number of leaves in the tree
   Int_t         fReadCalls;     //Number of read calls
   Int_t         fReadaheadSize; //Readahead cache size
   Long64_t      fBytesRead;     //Number of bytes read
   Long64_t      fBytesReadExtra;//Number of bytes (overhead) of the readahead cache
   Double_t      fRealNorm;      //Real time scale factor for fGraphTime
   Double_t      fRealTime;      //Real time
   Double_t      fCpuTime;       //Cpu time
   Double_t      fDiskTime;      //Time spent in pure raw disk IO
   Double_t      fUnzipTime;     //Time spent uncompressing the data.
   Double_t      fCompress;      //Tree compression factor
   TString       fName;          //name of this TTreePerfStats
   TString       fHostInfo;      //name of the host system, ROOT version and date
   TFile        *fFile;          //!pointer to the file containing the Tree
   TTree        *fTree;          //!pointer to the Tree being monitored
   TGraphErrors *fGraphIO ;      //pointer to the graph with IO data
   TGraphErrors *fGraphTime ;    //pointer to the graph with timestamp info
   TPaveText    *fPave;          //pointer to annotation pavetext
   TStopwatch   *fWatch;         //TStopwatch pointer
   TGaxis       *fRealTimeAxis;  //pointer to TGaxis object showing real-time
   TText        *fHostInfoText;  //Graphics Text object with the fHostInfo data

public:
   TTreePerfStats();
   TTreePerfStats(const char *name, TTree *T);
   virtual ~TTreePerfStats();
   virtual void     Browse(TBrowser *b);
   virtual Int_t    DistancetoPrimitive(Int_t px, Int_t py);
   virtual void     Draw(Option_t *option="");
   virtual void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
   virtual void     Finish();
   virtual Long64_t GetBytesRead() const {return fBytesRead;}
   virtual Long64_t GetBytesReadExtra() const {return fBytesReadExtra;}
   virtual Double_t GetCpuTime()   const {return fCpuTime;}
   virtual Double_t GetDiskTime()  const {return fDiskTime;}
   TGraphErrors    *GetGraphIO()     {return fGraphIO;}
   TGraphErrors    *GetGraphTime()   {return fGraphTime;}
   const char      *GetHostInfo() const{return fHostInfo.Data();}
   const char      *GetName()    const{return fName.Data();}
   virtual Int_t    GetNleaves() const {return fNleaves;}
   virtual Long64_t GetNumEvents() const {return 0;}
   TPaveText       *GetPave()      {return fPave;}
   virtual Int_t    GetReadaheadSize() const {return fReadaheadSize;}
   virtual Int_t    GetReadCalls() const {return fReadCalls;}
   virtual Double_t GetRealTime()  const {return fRealTime;}
   TStopwatch      *GetStopwatch() const {return fWatch;}
   virtual Int_t    GetTreeCacheSize() const {return fTreeCacheSize;}
   virtual Double_t GetUnzipTime() const {return fUnzipTime; }
   virtual void     Paint(Option_t *chopt="");
   virtual void     Print(Option_t *option="") const;

   virtual void     SimpleEvent(EEventType) {}
   virtual void     PacketEvent(const char *, const char *, const char *,
                            Long64_t , Double_t ,Double_t , Double_t ,Long64_t ) {}
   virtual void     FileEvent(const char *, const char *, const char *, const char *, Bool_t) {}
   virtual void     FileOpenEvent(TFile *, const char *, Double_t) {}
   virtual void     FileReadEvent(TFile *file, Int_t len, Double_t start);
   virtual void     UnzipEvent(TObject *tree, Long64_t pos, Double_t start, Int_t complen, Int_t objlen);
   virtual void     RateEvent(Double_t , Double_t , Long64_t , Long64_t) {}

   virtual void     SaveAs(const char *filename="",Option_t *option="") const;
   virtual void     SavePrimitive(std::ostream &out, Option_t *option = "");
   virtual void     SetBytesRead(Long64_t nbytes) {fBytesRead = nbytes;}
   virtual void     SetBytesReadExtra(Long64_t nbytes) {fBytesReadExtra = nbytes;}
   virtual void     SetCompress(Double_t cx) {fCompress = cx;}
   virtual void     SetDiskTime(Double_t t) {fDiskTime = t;}
   virtual void     SetNumEvents(Long64_t) {}
   virtual void     SetCpuTime(Double_t cptime) {fCpuTime = cptime;}
   virtual void     SetGraphIO(TGraphErrors *gr) {fGraphIO = gr;}
   virtual void     SetGraphTime(TGraphErrors *gr) {fGraphTime = gr;}
   virtual void     SetHostInfo(const char *info) {fHostInfo = info;}
   virtual void     SetName(const char *name) {fName = name;}
   virtual void     SetNleaves(Int_t nleaves) {fNleaves = nleaves;}
   virtual void     SetReadaheadSize(Int_t nbytes) {fReadaheadSize = nbytes;}
   virtual void     SetReadCalls(Int_t ncalls) {fReadCalls = ncalls;}
   virtual void     SetRealNorm(Double_t rnorm) {fRealNorm = rnorm;}
   virtual void     SetRealTime(Double_t rtime) {fRealTime = rtime;}
   virtual void     SetTreeCacheSize(Int_t nbytes) {fTreeCacheSize = nbytes;}
   virtual void     SetUnzipTime(Double_t uztime) {fUnzipTime = uztime;}

   ClassDef(TTreePerfStats,1)  // TTree I/O performance measurement
};

#endif
 TTreePerfStats.h:1
 TTreePerfStats.h:2
 TTreePerfStats.h:3
 TTreePerfStats.h:4
 TTreePerfStats.h:5
 TTreePerfStats.h:6
 TTreePerfStats.h:7
 TTreePerfStats.h:8
 TTreePerfStats.h:9
 TTreePerfStats.h:10
 TTreePerfStats.h:11
 TTreePerfStats.h:12
 TTreePerfStats.h:13
 TTreePerfStats.h:14
 TTreePerfStats.h:15
 TTreePerfStats.h:16
 TTreePerfStats.h:17
 TTreePerfStats.h:18
 TTreePerfStats.h:19
 TTreePerfStats.h:20
 TTreePerfStats.h:21
 TTreePerfStats.h:22
 TTreePerfStats.h:23
 TTreePerfStats.h:24
 TTreePerfStats.h:25
 TTreePerfStats.h:26
 TTreePerfStats.h:27
 TTreePerfStats.h:28
 TTreePerfStats.h:29
 TTreePerfStats.h:30
 TTreePerfStats.h:31
 TTreePerfStats.h:32
 TTreePerfStats.h:33
 TTreePerfStats.h:34
 TTreePerfStats.h:35
 TTreePerfStats.h:36
 TTreePerfStats.h:37
 TTreePerfStats.h:38
 TTreePerfStats.h:39
 TTreePerfStats.h:40
 TTreePerfStats.h:41
 TTreePerfStats.h:42
 TTreePerfStats.h:43
 TTreePerfStats.h:44
 TTreePerfStats.h:45
 TTreePerfStats.h:46
 TTreePerfStats.h:47
 TTreePerfStats.h:48
 TTreePerfStats.h:49
 TTreePerfStats.h:50
 TTreePerfStats.h:51
 TTreePerfStats.h:52
 TTreePerfStats.h:53
 TTreePerfStats.h:54
 TTreePerfStats.h:55
 TTreePerfStats.h:56
 TTreePerfStats.h:57
 TTreePerfStats.h:58
 TTreePerfStats.h:59
 TTreePerfStats.h:60
 TTreePerfStats.h:61
 TTreePerfStats.h:62
 TTreePerfStats.h:63
 TTreePerfStats.h:64
 TTreePerfStats.h:65
 TTreePerfStats.h:66
 TTreePerfStats.h:67
 TTreePerfStats.h:68
 TTreePerfStats.h:69
 TTreePerfStats.h:70
 TTreePerfStats.h:71
 TTreePerfStats.h:72
 TTreePerfStats.h:73
 TTreePerfStats.h:74
 TTreePerfStats.h:75
 TTreePerfStats.h:76
 TTreePerfStats.h:77
 TTreePerfStats.h:78
 TTreePerfStats.h:79
 TTreePerfStats.h:80
 TTreePerfStats.h:81
 TTreePerfStats.h:82
 TTreePerfStats.h:83
 TTreePerfStats.h:84
 TTreePerfStats.h:85
 TTreePerfStats.h:86
 TTreePerfStats.h:87
 TTreePerfStats.h:88
 TTreePerfStats.h:89
 TTreePerfStats.h:90
 TTreePerfStats.h:91
 TTreePerfStats.h:92
 TTreePerfStats.h:93
 TTreePerfStats.h:94
 TTreePerfStats.h:95
 TTreePerfStats.h:96
 TTreePerfStats.h:97
 TTreePerfStats.h:98
 TTreePerfStats.h:99
 TTreePerfStats.h:100
 TTreePerfStats.h:101
 TTreePerfStats.h:102
 TTreePerfStats.h:103
 TTreePerfStats.h:104
 TTreePerfStats.h:105
 TTreePerfStats.h:106
 TTreePerfStats.h:107
 TTreePerfStats.h:108
 TTreePerfStats.h:109
 TTreePerfStats.h:110
 TTreePerfStats.h:111
 TTreePerfStats.h:112
 TTreePerfStats.h:113
 TTreePerfStats.h:114
 TTreePerfStats.h:115
 TTreePerfStats.h:116
 TTreePerfStats.h:117
 TTreePerfStats.h:118
 TTreePerfStats.h:119
 TTreePerfStats.h:120
 TTreePerfStats.h:121
 TTreePerfStats.h:122
 TTreePerfStats.h:123
 TTreePerfStats.h:124
 TTreePerfStats.h:125
 TTreePerfStats.h:126
 TTreePerfStats.h:127