00001
00012 #ifdef HAVE_CONFIG_H
00013
00014 #include "config.h"
00015 #endif
00016
00017
00018 #ifdef _MSC_VER
00019 #include "msdevstudio/MSconfig.h"
00020 #endif
00021
00022
00023 #include <boost/python.hpp>
00024
00025 #include "root/QtRootNTuple.h"
00026
00027 #ifdef HAVE_NUMARRAY
00028 #include "numarray/num_util.h"
00029 #endif
00030
00031 #include <utility>
00032
00033 using std::string;
00034 using std::vector;
00035
00036 using namespace boost::python;
00037
00038 namespace hippodraw {
00039 namespace Python {
00040
00041 void
00042 export_RootNTuple()
00043 {
00044 class_ < QtRootNTuple, bases<DataSource>,
00045 QtRootNTuple, boost::noncopyable>
00046 ( "RootNTuple",
00047 "The RootNTuple class provides access to data in a ROOT file.\n"
00048 "A ROOT TTree is taken as an ntuple and a ROOT TBranch is taken as a\n"
00049 "column, the TBranch name as the column label.\n\n"
00050 "If the hippo module was configured with numeric array support,\n"
00051 "consider using DataArray to wrap an object of this class.",
00052 no_init )
00053
00054 .add_property ( "rows", &QtRootNTuple::rows )
00055
00056 .add_property ( "columns", &QtRootNTuple::columns )
00057
00058 .def ( "addColumn",
00059 &QtRootNTuple::addColumn,
00060 "addColumn ( label, list ) -> value\n"
00061 "\n"
00062 "Adds a column to the ntuple. Adds a column to the ntuple by \n"
00063 "copying the contents of the list. The new column will take its\n"
00064 "label from the first argument. Returns the index of the newly \n"
00065 "created column.\n\n"
00066 "Note: The column is not added to the ROOT file, just logically\n"
00067 "to it for the current session.\n")
00068
00069 .def ( "replaceColumn",
00070 ( void ( RootNTuple::* )
00071 ( const std::string &,
00072 const std::vector < double > & ) )
00073 &RootNTuple::replaceColumn,
00074 "replaceColumn ( index, list ) -> None\n"
00075 "replaceColumn ( label, list ) -> None\n"
00076 "\n"
00077 "Replaces the column of data by index or label. Does not\n"
00078 "modify the ROOT file." )
00079
00080 .def ( "replaceColumn",
00081 ( void ( RootNTuple::* )
00082 ( unsigned int,
00083 const std::vector < double > & ) )
00084 &RootNTuple::replaceColumn )
00085
00086 .def ( "getColumn",
00087 ( const std::vector < double > & (QtRootNTuple::* )
00088 ( const std::string & ) const)
00089 &QtRootNTuple::getColumn,
00090 return_value_policy < copy_const_reference> (),
00091 "getColumn ( index ) -> list\n"
00092 "getColumn ( label ) -> list\n"
00093 "getColumn ( label, indices ) -> list\n"
00094 "\n"
00095 "Returns a copy of the column as a list. In the first form the\n"
00096 "the column is specified by its index. In the second form it\n"
00097 "is specified by its label which could be a simple variable or\n"
00098 "an array variable. If an array variable, the indices should be\n"
00099 "part of the label. The third form, the column is specified by\n"
00100 "an array variables name and list of indices.\n" )
00101
00102 .def ( "getColumn",
00103 ( const std::vector < double > & (QtRootNTuple::* )
00104 ( const std::string &,
00105 const std::vector < int > & ) const)
00106 &QtRootNTuple::getColumn,
00107 return_value_policy < copy_const_reference> () )
00108
00109 .def ( "getColumn",
00110 ( const std::vector < double > & (QtRootNTuple::* )
00111 ( unsigned int ) const)
00112 &QtRootNTuple::getColumn,
00113 return_value_policy < copy_const_reference> () )
00114
00115 .def ( "getRow",
00116 &QtRootNTuple::getRow,
00117 return_value_policy < copy_const_reference> (),
00118 "getRow ( index ) -> tuple\n"
00119 "\n"
00120 "Returns a row from the ROOT file." )
00121
00122 .def ( "isMultiDimensional",
00123 &QtRootNTuple::isMultiDimensional,
00124 "isMultiDimensional ( label ) -> Boolean\n"
00125 "\n"
00126 "Returns True if the column specified by label is an array." )
00127
00128 .def ( "rowDataDimSize",
00129 &QtRootNTuple::getColumnShape,
00130 return_value_policy < return_by_value > (),
00131 "rowDataDimSize ( label )\n"
00132 "\n"
00133 "Returns a tuple of the dimensions (shape) of the array elements\n"
00134 "for the column specified by label." )
00135
00136 .def ( "getLabels",
00137 &QtRootNTuple::getLabels,
00138 return_value_policy < copy_const_reference > (),
00139 "getLabels () -> list\n"
00140 "\n"
00141 "Returns the column labels. Note: if a column is an array the\n"
00142 "shape does not appear as part of the label.\n" )
00143
00144 #ifdef HAVE_NUMARRAY
00145 .def ( "valueAt",
00146 &QtRootNTuple::valueAt,
00147 return_value_policy < return_by_value > (),
00148 "valueAt ( index, label ) -> array\n"
00149 "\n"
00150 "Returns the numerical array for the array variable in column\n"
00151 "specified by label, for the row index. Note: this method is\n"
00152 "only available if the hippo module was configured for numerical\n"
00153 "array support." )
00154 #endif
00155 ;
00156 }
00157
00158 }
00159 }