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