Changeset 2808 in Sophya for trunk/SophyaLib/HiStats
- Timestamp:
- Jun 14, 2005, 1:25:05 PM (20 years ago)
- Location:
- trunk/SophyaLib/HiStats
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/basedtable.cc
r2699 r2808 131 131 } 132 132 133 133 //! Adds a line (or row to the table) with r_8* inout data 134 /*! 135 The data to be added is provided as an array (vector) of double (r_8). 136 The necessary data conversion is performed, depending on each 137 column's data typeconverted to the data type. 138 Return the new number of table rows (lines / entries) 139 \param data : Data for each cell of the row to be appended 140 (data[k] k=0..NbColumns()) 141 */ 134 142 sa_size_t BaseDataTable::AddLine(const r_8* data) 135 143 { … … 155 163 } 156 164 165 //! Adds a line (or row to the table) with input data as an array of MuTyV 166 /*! 167 The data to be added is provided as an array (vector) of MuTyV. 168 The MuTyV class conversion operators are used to match against each 169 cell data type. 170 Return the new number of table rows (lines / entries) 171 \param data : Data (MuTyV*) for each cell of the row to be appended 172 (data[k] k=0..NbColumns()) 173 */ 157 174 sa_size_t BaseDataTable::AddLine(const MuTyV* data) 158 175 { … … 247 264 } 248 265 249 250 //! Prints table definition and number of entries 266 /*! In addition to printing the number of entries and column names, 267 this method prints also minimum/maximum value for each column. 268 This information might be computed when the Show() method is called. 269 This may take some time for tables with large number of entries (>~ 10^6) 270 */ 251 271 void BaseDataTable::Show(ostream& os) const 252 272 { -
trunk/SophyaLib/HiStats/basedtable.h
r2732 r2808 18 18 19 19 namespace SOPHYA { 20 //! Interface definition for classes handling data in a table. 20 21 class BaseDataTable : public AnyDataObj , public NTupleInterface { 21 22 public: … … 33 34 virtual ~BaseDataTable(); 34 35 36 //! Adds a column holding integer, named \b cnom 35 37 inline sa_size_t AddIntegerColumn(const char * cnom) 36 38 { return AddColumn(IntegerField, cnom); } 39 //! Adds a column holding integer, named \b cnom 37 40 inline sa_size_t AddIntegerColumn(string const & cnom) 38 41 { return AddColumn(IntegerField, cnom); } 42 //! Adds a column holding long integer, named \b cnom 39 43 inline sa_size_t AddLongColumn(const char * cnom) 40 44 { return AddColumn(LongField, cnom); } 45 //! Adds a column holding long integer, named \b cnom 41 46 inline sa_size_t AddLongColumn(string const & cnom) 42 47 { return AddColumn(LongField, cnom); } 48 //! Adds a column holding floating values (r_4), named \b cnom 43 49 inline sa_size_t AddFloatColumn(const char * cnom) 44 50 { return AddColumn(FloatField, cnom); } 51 //! Adds a column holding floating values (r_4), named \b cnom 45 52 inline sa_size_t AddFloatColumn(string const & cnom) 46 53 { return AddColumn(FloatField, cnom); } 54 //! Adds a column holding double values (r_8), named \b cnom 47 55 inline sa_size_t AddDoubleColumn(const char * cnom) 48 56 { return AddColumn(DoubleField, cnom); } 57 //! Adds a column holding double values (r_8), named \b cnom 49 58 inline sa_size_t AddDoubleColumn(string const & cnom) 50 59 { return AddColumn(DoubleField, cnom); } 60 //! Adds a column holding character strings, named \b cnom 51 61 inline sa_size_t AddStringColumn(const char * cnom) 52 62 { return AddColumn(StringField, cnom); } 63 //! Adds a column holding character strings, named \b cnom 53 64 inline sa_size_t AddStringColumn(string const & cnom) 54 65 { return AddColumn(StringField, cnom); } … … 69 80 70 81 // Acces to various counts and parameters 82 //! Return the number of lines (rows) in the table) 71 83 inline sa_size_t NEntry() const { return mNEnt ; } 84 //! Return the number of columns in the tables (number of cells in a row) 72 85 inline sa_size_t NVar() const { return mNames.size() ; } 86 //! Return the number of columns in the tables (number of cells in a row) 73 87 inline sa_size_t NVars() const { return mNames.size() ; } 88 //! Return the segment size (SegDBInterface objects corresponding to columns) 74 89 inline sa_size_t SegmentSize() const { return mSegSz ; } 90 //! Return the number of segments (SegDBInterface objects corresponding to columns) 75 91 inline sa_size_t NbSegments() const { return mNSeg ; } 76 92 … … 78 94 virtual sa_size_t AddLine(const r_8* data); 79 95 virtual sa_size_t AddLine(const MuTyV * data); 80 96 97 //! Alias for AddLine() 81 98 inline sa_size_t Fill(const r_8* data) 82 99 { return AddLine(data); } 100 //! Alias for AddLine() 83 101 inline sa_size_t Fill(const MuTyV * data); 84 102 85 103 virtual sa_size_t Extend(); 86 104 87 // Getting a given line (record) information105 //! Return the information stored in line \b n of the table 88 106 virtual MuTyV * GetLine(sa_size_t n) const ; 89 107 108 //! Return the index for column name \b nom 90 109 sa_size_t IndexNom(char const* nom) const ; 110 //! Return the index for column name \b nom 91 111 inline sa_size_t IndexNom(string const & nom) const 92 112 { return IndexNom(nom.c_str()); } 113 //! Return the column name for column index \b k 93 114 string NomIndex(sa_size_t k) const ; 94 115 … … 107 128 virtual void Clear() = 0; 108 129 109 // ---- ASCII I/O130 //! Prints the table content - NOT YET IMPLEMENTED ! 110 131 void Print(int num, int nmax=1) const ; 111 132 133 //! Prints table definition and number of entries 112 134 void Show(ostream& os) const ; 135 //! Prints table definition and number of entries on the standard output stream \b cout 113 136 inline void Show() const { Show(cout) ; } 114 137 … … 144 167 mutable r_8 * mVarD; // Pour retourner une ligne de la table 145 168 mutable MuTyV * mVarMTV; // Pour retourner une ligne de la table en MuTyV 146 169 170 //! \cond Pour pas inclure ds la documentation doxygen 147 171 typedef struct { 148 172 string nom; … … 150 174 sa_size_t ser; 151 175 } colst; 176 //! \endcond 152 177 std::vector<colst> mNames; 153 178 -
trunk/SophyaLib/HiStats/datatable.cc
r2699 r2808 11 11 This class can be used to organize data in table (row-column) form. 12 12 Each column holds homogeneous data (same data type), while different 13 columns can be used for different data types (integer, float, string ...) 13 columns can be used for different data types 14 (integer, float, string ...). 15 The whole data set is kept in memory. 14 16 \sa SOPHYA::MuTyV 15 17 \sa SOPHYA::BaseDataTable 16 \sa SOPHYA:: ObjFileIO<DataTable>18 \sa SOPHYA::SegDataBlock 17 19 18 20 \code … … 43 45 } 44 46 45 //! copy constructor - shares the data 47 //! copy constructor 48 /*! 49 The copy constructur shares the data if \b share=true. 50 Otherwise, the Clone() method is called to make a complete copy. 51 */ 46 52 DataTable::DataTable(DataTable const & a, bool share) 47 53 : BaseDataTable(a.SegmentSize()) … … 53 59 if (a.mInfo) mInfo = new DVList(*(a.mInfo)); 54 60 } 55 61 //! Copy the table structure from \b a and shares the data (columns content) 56 62 void DataTable::Share(DataTable const & a) 57 63 { … … 85 91 } 86 92 93 //! Copy the table structure from \b a and duplicate (copy) the data (columns content) 87 94 void DataTable::Clone(DataTable const & a) 88 95 { … … 115 122 } 116 123 } 117 124 //! Reset (/clear) the table content and structure 118 125 void DataTable::Clear() 119 126 { … … 151 158 152 159 160 /*! 161 Implements the action defined in the BaseDataTable interface. 162 In the current implementation, throws an exception (ParmError) 163 if the table contains some data already. 164 */ 153 165 sa_size_t DataTable::AddColumn(FieldType ft, string const & cnom) 154 166 { -
trunk/SophyaLib/HiStats/datatable.h
r2699 r2808 16 16 class FITS_DataTable; 17 17 18 //! An implementation of BaseDataTable with data (columns) stored in memory. 18 19 class DataTable : public BaseDataTable { 19 20 public: -
trunk/SophyaLib/HiStats/histinit.cc
r2699 r2808 17 17 /*! 18 18 \defgroup HiStats HiStats module 19 This module contains histograms 19 This module contains histograms (1D, 2D) and 20 classes for management of data sets as tables (NTuple, DataTable ...) 20 21 */ 21 22 … … 25 26 \class SOPHYA::HiStatsInitiator 26 27 \ingroup HiStats 27 Histograms initiator 28 This class performs the initialisation for HiStats module. 29 More specifically, it registers PPF handlers for the following classes : 30 - Histo 31 - HProf 32 - HistoErr 33 - Histo2D 34 - NTuple 35 - XNTuple 36 - DataTable 37 - SwPPFDataTable 38 39 If the system linker/loader handles correctly static object initialisation, there 40 is no action required when writing programs. If not, an instance of the class must 41 be present before any other operation on the libray classes. 28 42 */ 43 29 44 HiStatsInitiator::HiStatsInitiator() 30 45 : NToolsInitiator() -
trunk/SophyaLib/HiStats/ntuple.cc
r2682 r2808 53 53 54 54 /* --Methode-- */ 55 //! Default constructor 55 //! Default constructor - To be used when reading in an NTuple. 56 56 //++ 57 57 NTuple::NTuple() -
trunk/SophyaLib/HiStats/ntuple.h
r2682 r2808 22 22 class FITS_NTuple; 23 23 24 //! Class for creation and management of double or float data sets in a table 24 25 class NTuple : public AnyDataObj , public NTupleInterface { 25 26 … … 28 29 NTuple(int nvar, char** noms, int blk=512, bool fgdouble=true); 29 30 NTuple(const NTuple& NT); 30 //A virer NTuple(char* flnm);31 31 virtual ~NTuple(); 32 32 … … 35 35 void Fill(r_4* x); 36 36 void Fill(r_8* x); 37 38 inline int_4 NEntry() const { return(mNEnt); } 37 //! Return the number of lines (rows) in the table) 38 inline int_4 NEntry() const { return(mNEnt); } 39 //! Return the number of columns in the tables (number of cells in a row) 39 40 inline int_4 NVar() const { return(mNVar); } 41 //! Return the bloc size 40 42 inline int_4 BLock() const { return(mBlk); } 41 43 // $CHECK$ Reza 21/10/99 Pourquoi faire BLock() ? 42 44 45 //! Return the content of the cell for line (row) \b n , column \b k 43 46 float GetVal(int n, int k) const; 47 //! Return the content of the cell for line (row) \b and column name \b nom 44 48 inline float GetVal(int n, const char* nom) const 45 49 { return(GetVal(n, IndexNom(nom)) ); } 46 50 int IndexNom(const char* nom) const ; 47 51 char* NomIndex(int k) const; 48 52 //! Return the content of line \b n as a vector of r_4 (float) 49 53 r_4* GetVec(int n, r_4* ret=NULL) const ; 54 //! Return the content of line \b n as a vector of r_8 (double) 50 55 r_8* GetVecD(int n, r_8* ret=NULL) const ; 51 56 … … 55 60 inline void Show() const { Show(cout); } 56 61 62 //! Return the associated DVList object 57 63 DVList& Info(); 58 64 -
trunk/SophyaLib/HiStats/swppfdtable.cc
r2699 r2808 9 9 This class can be used to organize data in table (row-column) form. 10 10 Each column holds homogeneous data (same data type), while different 11 columns can be used for different data types (integer, float, string ...) 11 columns can be used for different data types 12 (integer, float, string ...). 13 A PPF stream is used as swap space. Due to limitations in the current 14 implementation of PPF streams, read operations (acces to table data) cannot 15 be performed when a table is being filled. 16 17 \warning 18 - When creating a table, the output PPF stream (POutPersist) must not be closed 19 (destroyed) before the call to the SwPPFDataTable object. 20 - It is not possible to make a complete (deep) copy of a table SwPPFDataTable 21 Copy constructor and equal operator shares the data. 22 - Although the destructor DOES NOT save the 23 table object itself to the memory. You have to use the << operator on the 24 output PPF stream being used as swap 25 12 26 \sa SOPHYA::MuTyV 13 \sa SOPHYA:: BaseDataTable14 \sa SOPHYA:: ObjFileIO<DataTable>27 \sa SOPHYA::DataTable 28 \sa SOPHYA::SwSegDataBlock SOPHYA::PPFDataSwapper 15 29 16 30 \code 17 31 #include "swppfdtable.h" 18 32 // ... 19 DataTable dt(64); 33 { 34 // ---- Creation of the table 35 // Create the swap stream 36 POutPersist so("myswtable.ppf"); 37 SwPPFDataTable dt(so, 64); 38 // define table columns 20 39 dt.AddFloatColumn("X0_f"); 21 40 dt.AddFloatColumn("X1_f"); 22 41 dt.AddDoubleColumn("X0X0pX1X1_d"); 23 double x[5]; 42 // Fill the table 43 MuTyV x[5]; 24 44 for(int i=0; i<63; i++) { 25 45 x[0] = (i%9)-4.; x[1] = (i/9)-3.; x[2] = x[0]*x[0]+x[1]*x[1]; … … 28 48 // Printing table info 29 49 cout << dt ; 30 // Saving object into a PPF file 31 POutPersist po("dtable.ppf"); 32 po << dt ; 50 // Swap out all data and write the table structure to the PPF stream 51 so << dt ; 52 // .... 53 } 54 { 55 // ---- Accessing information from a previously created table 56 SwPPFDataTable dt; 57 PInPersist si("myswtable.ppf"); 58 si >> dt; 59 // Printing table info 60 cout << dt ; 61 } 33 62 \endcode 34 63 */ 35 /*! Default constructor with optional specification of block (or segment) size - 36 NOT intented for general use 37 */ 64 //! Default constructor with optional specification of block (or segment) size 38 65 SwPPFDataTable::SwPPFDataTable(sa_size_t segsz) 39 66 : BaseDataTable(segsz), … … 205 232 206 233 234 /*! 235 Implements the action defined in the BaseDataTable interface. 236 In the current implementation, throws an exception (ParmError) 237 if the table contains some data already. 238 */ 207 239 sa_size_t SwPPFDataTable::AddColumn(FieldType ft, string const & cnom) 208 240 { … … 271 303 } 272 304 305 //! Adds a line (or row to the table) with r_8* input data. 306 /*! 307 The min/max values for each column is updated, in addition 308 to the actions performed by the base class AddLine() 309 */ 273 310 sa_size_t SwPPFDataTable::AddLine(const r_8* data) 274 311 { … … 284 321 } 285 322 323 //! Adds a line (or row to the table) with input data as an array of MuTyV 324 /*! 325 The min/max values for each column is updated, in addition 326 to the actions performed by the base class AddLine() 327 */ 286 328 sa_size_t SwPPFDataTable::AddLine(const MuTyV * data) 287 329 { -
trunk/SophyaLib/HiStats/swppfdtable.h
r2699 r2808 15 15 namespace SOPHYA { 16 16 17 //! An implementation of BaseDataTable with using a PPF stream as swap space. 17 18 class SwPPFDataTable : public BaseDataTable { 18 19 public: … … 36 37 friend class ObjFileIO<BaseDataTable> ; 37 38 38 //! Reset the table content and structure39 //! Reset(Clear) the table content and structure 39 40 virtual void Clear(); 40 41 /*! This method should be called in order to empty the swapout buffer, … … 64 65 // un comptage de reference pour le detruire lorsque tous les tables 65 66 // l'utilisant sont supprimes 67 //! \cond Pour NE PAS inclure dans la doc 66 68 typedef struct { PInPersist* pis; uint_4 refcnt; } St_InSwap; 69 //! \endcond 67 70 St_InSwap * mSwIn; 68 71 }; -
trunk/SophyaLib/HiStats/xntuple.cc
r2682 r2808 24 24 columns with int, float or string type content. In addition, this class 25 25 can handle large data sets, using swap space on disk. 26 \sa SOPHYA::ObjFileIO<XNTuple> 26 27 \sa SOPHYA::BaseDataTable SOPHYA::DataTable SOPHYA::SwPPFDataTable 28 29 \deprecated 30 This class is being deprecated. Use classes derived from SOPHYA::BaseDataTable 31 whenever possible 32 27 33 28 34 \code -
trunk/SophyaLib/HiStats/xntuple.h
r2682 r2808 27 27 // Bloc de donnees 28 28 // 29 //! \cond Pour ne pas inclure dans la documentation 29 30 struct NTBlk 30 31 { … … 41 42 char* sdata ; 42 43 } ; 43 44 //! \endcond 44 45 // Forward class declaration for Fits handler 45 46 class FITS_XNTuple; 46 47 48 //! Class for creation and management of data sets organised as a table 47 49 class XNTuple : public AnyDataObj , public NTupleInterface { 48 50 public:
Note:
See TracChangeset
for help on using the changeset viewer.