00001
00002
00014 #ifndef RootNTuple_H
00015 #define RootNTuple_H
00016
00017 #include "RootDataType.h"
00018
00019 #include "datasrcs/DataSource.h"
00020
00021 class TTree;
00022 class TBranch;
00023
00024 namespace hippodraw {
00025
00026 class RootBranch;
00027
00037 class MDL_HIPPOPLOT_API RootNTuple : public DataSource
00038 {
00039
00040 private:
00041
00044 typedef std::vector < RootBranch * > BranchList_t;
00045
00048 BranchList_t m_data;
00049
00052 typedef std::vector < std::vector < double > * > CacheList_t;
00055 CacheList_t m_data_cache;
00056
00060 std::vector < bool > m_multiDimensional;
00061
00064 TTree * m_tree;
00065
00068 mutable unsigned int m_cur_entry;
00069
00071 bool rotateWheels( std::vector< int > & wheels,
00072 const std::vector < int > & sz,
00073 unsigned int d );
00074
00086 int addColumn ( const std::string & label, RootBranch * );
00087
00090 TBranch * getTBranch( const std::string & column );
00091
00092
00093 protected:
00094
00100 RootNTuple ();
00101
00104 RootNTuple ( const RootNTuple & );
00105
00106 public:
00107
00109 RootNTuple ( TTree * tree );
00110
00113 virtual ~RootNTuple();
00114
00118 virtual void notifyObservers ( ) const;
00119
00122 virtual unsigned int rows () const;
00123
00126 virtual bool empty () const;
00127
00131 virtual void clear ();
00132
00135 virtual void reserve ( unsigned int );
00136
00140 virtual double
00141 operator [] ( std::vector < unsigned int > & indices ) const;
00142
00143 virtual double valueAt ( unsigned int row, unsigned int column ) const;
00144
00145 virtual double valueAtNoCache ( unsigned int row,
00146 unsigned int column ) const;
00147
00150 hippodraw::RootData::Type getType ( unsigned int column ) const;
00151
00154 virtual double * doubleArrayAt ( unsigned int row,
00155 unsigned int column ) const;
00156
00159 virtual float * floatArrayAt ( unsigned int row,
00160 unsigned int column ) const;
00161
00164 virtual int * intArrayAt ( unsigned int row,
00165 unsigned int column ) const;
00166
00170 virtual unsigned int * uintArrayAt ( unsigned int row,
00171 unsigned int column ) const;
00172
00181 int addColumn ( const std::string & label,
00182 const std::vector < double > & column );
00183
00191 void replaceColumn ( unsigned int index,
00192 const std::vector < double > & data );
00193
00194 virtual const std::vector < double > &
00195 getColumn ( const std::string & name ) const;
00196
00201 virtual const std::vector < double > &
00202 getColumn ( const std::string & name,
00203 const std::vector < int > & indices ) const;
00204
00205 virtual const std::vector < double > &
00206 getColumn ( unsigned int index ) const;
00207
00212 virtual const std::vector < double > & getRow ( unsigned int i ) const;
00213
00220 virtual void setShape ( std::vector < unsigned int > & shape );
00221
00224 const std::vector < unsigned int > & getShape () const;
00225
00228 virtual bool isMultiDimensional ( const std::string & column ) const;
00229
00234 virtual bool isUseable ( const std::string & label ) const;
00235
00239 virtual bool setReleventIndex( const std::string & column,
00240 const std::vector< unsigned int >& index );
00241
00248 virtual void fillShape ( std::vector < int > & v,
00249 unsigned int column ) const;
00250
00257 void smartExpandRootNTuple( const std::string & column ) const;
00258
00266 void expandIfNeeded ( const std::vector < std::string > & labels ) const;
00267
00271 std::string
00272 createBinding ( const std::string & name,
00273 const std::vector < int > & indices ) const;
00274
00275 private:
00276
00277 void expandIfNeeded ( const std::string & label ) const;
00278
00281 void initBranches ();
00282
00285 void fillDataCache ( unsigned int column );
00286
00287 };
00288
00289 }
00290
00291 #endif // RootNTuple_H