00001 #ifndef __BCDATASET__H 00002 #define __BCDATASET__H 00003 00004 /*! 00005 * \class BCDataSet 00006 * \brief A class representing a set of data points. 00007 * \author Daniel Kollar 00008 * \author Kevin Kröninger 00009 * \version 1.0 00010 * \date 08.2008 00011 * \detail This class represents a data set containing a set of data 00012 * points. The data points are organized in a vector. The class 00013 * provides functions to read in data from a file. 00014 */ 00015 00016 /* 00017 * Copyright (C) 2008-2010, Daniel Kollar and Kevin Kroeninger. 00018 * All rights reserved. 00019 * 00020 * For the licensing terms see doc/COPYING. 00021 */ 00022 00023 // --------------------------------------------------------- 00024 00025 #include <vector> 00026 00027 // BAT classes 00028 class BCDataPoint; 00029 00030 // --------------------------------------------------------- 00031 00032 typedef std::vector<BCDataPoint*> BCDataVector; 00033 00034 // --------------------------------------------------------- 00035 00036 class BCDataSet 00037 { 00038 public: 00039 00040 /** \name Constructors and destructors */ 00041 /* @{ */ 00042 00043 /* 00044 * Default constructor */ 00045 BCDataSet(); 00046 00047 /* 00048 * Default destructor */ 00049 virtual ~BCDataSet(); 00050 00051 /* @} */ 00052 00053 /** \name Member functions (get) */ 00054 /* @{ */ 00055 00056 /* 00057 * @param The vector of data points. */ 00058 // BCDataVector * GetDataVector(); 00059 00060 /* 00061 * @return The number of data points. */ 00062 unsigned int GetNDataPoints(); 00063 00064 /* 00065 * @return number of values per data point (dimension of data). */ 00066 unsigned int GetNValuesPerPoint(); 00067 00068 /* 00069 * @param index The index of the data point to be returned. 00070 * @return The data point at the index. */ 00071 BCDataPoint * GetDataPoint(unsigned int index); 00072 00073 /** 00074 * Viewing the data set as a table with one row per point, 00075 * this method returns a specified column. 00076 * @param index The index of the component to be returned. 00077 * @return The (index)th component of all data points */ 00078 std::vector<double> GetDataComponents(int index); 00079 00080 00081 /* @} */ 00082 00083 /** \name Member functions (miscellaneous methods) */ 00084 /* @{ */ 00085 00086 /** 00087 * Reads data from a file. For a description see the following 00088 * member functions. */ 00089 int ReadDataFromFile(const char * filename, const char * treename, const char * branchnames) 00090 { return this -> ReadDataFromFileTree(filename, treename, branchnames); }; 00091 00092 int ReadDataFromFile(const char * filename, int nvariables) 00093 { return this -> ReadDataFromFileTxt(filename, nvariables); }; 00094 00095 /** 00096 * Reads a TTree from a .root file. Opens a .root file and 00097 * gets a TTree. It creates data points containing the values 00098 * read from the file. 00099 * @param filename The name of the .root file. 00100 * @param treename The name of the TTree. 00101 * @param branchnames A list of the names of the branches 00102 * separated by a comma 00103 * @return An error code. 00104 * @see ReadDataFromFileTxt(char* filename, int nbranches); 00105 * @see ReadDataFromFileUser(const char * filename, std::vector<int> options_int, std::vector<double> options_double, const char * options_char); 00106 */ 00107 int ReadDataFromFileTree(const char * filename, const char * treename, const char * branchnames); 00108 00109 /** 00110 * Reads data from a .txt file. Opens a .txt file and creates 00111 * data objects containing the values read from the file. 00112 * @param filename The name of the .txt file. 00113 * @param nvariables The number of variables. 00114 * @see ReadDataFromFileTree(char* filename, char* treename, std::vector<char*> branchnames) 00115 * @see ReadDataFromFileUser(const char * filename, std::vector<int> options_int, std::vector<double> options_double, const char * options_char); 00116 */ 00117 int ReadDataFromFileTxt(const char * filename, int nvariables); 00118 00119 /** 00120 * Adds a data point to the data set. 00121 * @param datapoint The data point to be added */ 00122 void AddDataPoint(BCDataPoint * datapoint); 00123 00124 /** 00125 * Resets the content of the data set */ 00126 void Reset(); 00127 00128 /** 00129 * Dump the data to the standard output */ 00130 void Dump(); 00131 00132 /* @} */ 00133 00134 private: 00135 00136 /* 00137 * A vector containing the data points */ 00138 BCDataVector * fBCDataVector; 00139 00140 }; 00141 00142 // --------------------------------------------------------- 00143 00144 #endif 00145