00001
00002
00003 #ifndef XAODCORE_TOOLS_READSTATS_H
00004 #define XAODCORE_TOOLS_READSTATS_H
00005
00006
00007 #include <map>
00008 #include <vector>
00009 #include <string>
00010
00011
00012 #include <TNamed.h>
00013
00014
00015 #ifndef __MAKECINT__
00016 #ifndef __ROOTCLING__
00017 # include "AthContainersInterfaces/AuxTypes.h"
00018 #endif // not __ROOTCLING__
00019 #endif // not __MAKECINT__
00020
00021
00022 class TCollection;
00023 class TTree;
00024 class TH1;
00025
00026 namespace xAOD {
00027
00038 class BranchStats : public ::TNamed {
00039
00040 public:
00042 BranchStats( const char* name = "xAODBranch",
00043 const char* type = "Int_t",
00044 ::Int_t nTreesAccessed = 0, ::Long64_t nReadEntries = 0,
00045 ::Long64_t nUnzippedBytes = 0, ::Long64_t nZippedBytes = 0 );
00047 BranchStats( const BranchStats& parent );
00048
00050 BranchStats& operator= ( const BranchStats& parent );
00051
00054
00056 ::Int_t treesAccessed() const;
00058 void setTreesAccessed( ::Int_t nTreesAccessed );
00059
00061 ::Long64_t readEntries() const;
00063 void setReadEntries( ::Long64_t nReadEntries );
00064
00066 ::Long64_t unzippedBytesRead() const;
00068 void setUnzippedBytesRead( ::Long64_t nUnzippedBytes );
00069
00071 ::Long64_t zippedBytesRead() const;
00073 void setZippedBytesRead( ::Long64_t nZippedBytes );
00074
00076
00078 BranchStats& add( const BranchStats& rh );
00080 BranchStats& operator+= ( const BranchStats& rh );
00081
00084
00086 ::Int_t Merge( ::TCollection* coll );
00087
00089 void Print( ::Option_t* option = "" ) const;
00090
00092
00093 private:
00095 ::Int_t m_treesAccessed;
00097 ::Long64_t m_readEntries;
00099 ::Long64_t m_unzippedBytes;
00101 ::Long64_t m_zippedBytes;
00102
00103 ClassDef( xAOD::BranchStats, 1 )
00104
00105 };
00106
00118 class ReadStats : public ::TNamed {
00119
00120 public:
00122 typedef std::vector< BranchStats* > Vector_t;
00124 typedef std::map< std::string, Vector_t > Map_t;
00125
00127 typedef std::map< std::string, BranchStats > MapC_t;
00128
00130 ReadStats( const char* name = "xAODReadStats",
00131 const char* title = "xAOD reading statistics" );
00133 ReadStats( const ReadStats& parent );
00135 ~ReadStats();
00136
00138 ReadStats& operator= ( const ReadStats& parent );
00139
00141 void Clear( ::Option_t* opt = "" );
00142
00145
00147 void setBytesRead( ::Long64_t num );
00149 ::Long64_t bytesRead() const;
00150
00152 void setBranchNum( ::Int_t num );
00154 ::Int_t branchNum() const;
00155
00157 void setFileReads( ::Int_t num );
00159 ::Int_t fileReads() const;
00160
00162 void setCacheSize( ::Int_t size );
00164 ::Int_t cacheSize() const;
00165
00167 void setReadTime( ::Double_t time );
00169 ::Double_t readTime() const;
00170
00172 void setUnzipTime( ::Double_t time );
00174 ::Double_t unzipTime() const;
00175
00177 void setProcessTime( ::Double_t time );
00179 ::Double_t processTime() const;
00180
00182
00185
00186 #ifndef __MAKECINT__
00187 #ifndef __ROOTCLING__
00189 BranchStats* branch( const std::string& prefix,
00190 SG::auxid_t auxid );
00192 const BranchStats* branch( const std::string& prefix,
00193 SG::auxid_t auxid ) const;
00194 #endif // not __ROOTCLING__
00195 #endif // not __MAKECINT__
00196
00198 BranchStats* container( const std::string& name );
00200 const BranchStats* container( const std::string& name ) const;
00201
00203 const Map_t& branches() const;
00205 const MapC_t& containers() const;
00206
00208
00211
00213 bool isCompatible( const ReadStats& rh ) const;
00215 ReadStats& add( const ReadStats& rh );
00217 ReadStats& operator+= ( const ReadStats& rh );
00218
00220 ::Int_t Merge( ::TCollection* coll );
00221
00223
00226
00228 void addToTreeCache( ::TTree* tree ) const;
00230 void addToTreeCacheByEntries( ::TTree* tree,
00231 ::Long64_t minEntries ) const;
00234 void addToTreeCacheByEntryFrac( ::TTree* tree,
00235 ::Double_t minEvFraction ) const;
00238 void addToTreeCacheByBytes( ::TTree* tree, ::Long64_t minBytes ) const;
00241 void addToTreeCacheByByteFrac( ::TTree* tree,
00242 ::Double_t minByteFraction ) const;
00243
00245
00248
00250 std::vector< std::string >
00251 branchesByEntries( ::Long64_t minEntries ) const;
00253 std::vector< std::string >
00254 branchesByEntryFrac( ::Double_t minEvFraction ) const;
00256 std::vector< std::string >
00257 branchesByBytes( ::Long64_t minBytes ) const;
00260 std::vector< std::string >
00261 branchesByByteFrac( ::Double_t minByteFraction ) const;
00262
00264
00267
00269 ::TH1* treeAccessStat() const;
00271 ::TH1* entryReadStat() const;
00273 ::TH1* zippedByteReadStat() const;
00275 ::TH1* unzippedByteReadStat() const;
00276
00278
00280 void Print( ::Option_t* option = "" ) const;
00281
00283 void printSmartSlimmingBranchList( bool autoIncludeLinks = false ) const;
00284
00286 void nextEvent();
00287
00289 ::Long64_t nEvents() const;
00291 void setNEvents( ::Long64_t nevents );
00292
00293 #ifndef __MAKECINT__
00294 #ifndef __ROOTCLING__
00296 void readBranch( const std::string& prefix,
00297 SG::auxid_t auxid );
00298 #endif // not __ROOTCLING__
00299 #endif // not __MAKECINT__
00300
00302 void readContainer( const std::string& name );
00303
00304 private:
00306 Map_t m_branches;
00308 MapC_t m_containers;
00309
00311 ::Long64_t m_bytesRead;
00313 ::Int_t m_branchNum;
00315 ::Int_t m_fileReads;
00317 ::Int_t m_cacheSize;
00319 ::Double_t m_readTime;
00321 ::Double_t m_unzipTime;
00323 ::Double_t m_processTime;
00324
00326 ::Long64_t m_nEvents;
00328 ::Long64_t m_nEventsProcessed;
00329
00330 ClassDef( xAOD::ReadStats, 1 )
00331
00332 };
00333
00334 }
00335
00336 #endif // XAODCORE_TOOLS_READSTATS_H