export_RootNTuple.cxx
Go to the documentation of this file.
1 
12 #ifdef HAVE_CONFIG_H
13 // for have numarray
14 #include "config.h"
15 #endif
16 
17 // For truncation warning
18 #ifdef _MSC_VER
19 #include "msdevstudio/MSconfig.h"
20 #endif
21 
22 // include first to avoid _POSIX_C_SOURCE warning.
23 #include <boost/python.hpp>
24 
25 #include "root/QtRootNTuple.h"
26 
27 #ifdef HAVE_NUMARRAY
28 #include "numarray/num_util.h"
29 #endif
30 
31 #include <utility>
32 
33 using std::string;
34 using std::vector;
35 
36 using namespace boost::python;
37 
38 namespace hippodraw {
39 namespace Python {
40 
41 void
43 {
44  class_ < QtRootNTuple, bases<DataSource>,
45  QtRootNTuple, boost::noncopyable>
46  ( "RootNTuple",
47  "The RootNTuple class provides access to data in a ROOT file.\n"
48  "A ROOT TTree is taken as an ntuple and a ROOT TBranch is taken as a\n"
49  "column, the TBranch name as the column label.\n\n"
50  "If the hippo module was configured with numeric array support,\n"
51  "consider using DataArray to wrap an object of this class.",
52  no_init )
53 
54  .add_property ( "rows", &QtRootNTuple::rows )
55 
56  .add_property ( "columns", &QtRootNTuple::columns )
57 
58  .def ( "addColumn",
59  &QtRootNTuple::addColumn,
60  "addColumn ( label, list ) -> value\n"
61  "\n"
62  "Adds a column to the ntuple. Adds a column to the ntuple by \n"
63  "copying the contents of the list. The new column will take its\n"
64  "label from the first argument. Returns the index of the newly \n"
65  "created column.\n\n"
66  "Note: The column is not added to the ROOT file, just logically\n"
67  "to it for the current session.\n")
68 
69  .def ( "replaceColumn",
70  ( void ( RootNTuple::* ) // function pointer
71  ( const std::string &,
72  const std::vector < double > & ) ) // signature
73  &RootNTuple::replaceColumn,
74  "replaceColumn ( index, list ) -> None\n"
75  "replaceColumn ( label, list ) -> None\n"
76  "\n"
77  "Replaces the column of data by index or label. Does not\n"
78  "modify the ROOT file." )
79 
80  .def ( "replaceColumn",
81  ( void ( RootNTuple::* ) // function pointer
82  ( unsigned int,
83  const std::vector < double > & ) ) // signature
84  &RootNTuple::replaceColumn )
85 
86  .def ( "getColumn",
87  ( const std::vector < double > & (QtRootNTuple::* ) // fptr
88  ( const std::string & ) const) // function signature
89  &QtRootNTuple::getColumn,
90  return_value_policy < copy_const_reference> (),
91  "getColumn ( index ) -> list\n"
92  "getColumn ( label ) -> list\n"
93  "getColumn ( label, indices ) -> list\n"
94  "\n"
95  "Returns a copy of the column as a list. In the first form the\n"
96  "the column is specified by its index. In the second form it\n"
97  "is specified by its label which could be a simple variable or\n"
98  "an array variable. If an array variable, the indices should be\n"
99  "part of the label. The third form, the column is specified by\n"
100  "an array variables name and list of indices.\n" )
101 
102  .def ( "getColumn",
103  ( const std::vector < double > & (QtRootNTuple::* ) // fptr
104  ( const std::string &,
105  const std::vector < int > & ) const) // function signature
106  &QtRootNTuple::getColumn,
107  return_value_policy < copy_const_reference> () )
108 
109  .def ( "getColumn",
110  ( const std::vector < double > & (QtRootNTuple::* ) // fptr
111  ( unsigned int ) const) // function signature
112  &QtRootNTuple::getColumn,
113  return_value_policy < copy_const_reference> () )
114 
115  .def ( "getRow",
116  &QtRootNTuple::getRow,
117  return_value_policy < copy_const_reference> (),
118  "getRow ( index ) -> tuple\n"
119  "\n"
120  "Returns a row from the ROOT file." )
121 
122  .def ( "isMultiDimensional",
123  &QtRootNTuple::isMultiDimensional,
124  "isMultiDimensional ( label ) -> Boolean\n"
125  "\n"
126  "Returns True if the column specified by label is an array." )
127 
128  .def ( "rowDataDimSize",
129  &QtRootNTuple::getColumnShape,
130  return_value_policy < return_by_value > (),
131  "rowDataDimSize ( label )\n"
132  "\n"
133  "Returns a tuple of the dimensions (shape) of the array elements\n"
134  "for the column specified by label." )
135 
136  .def ( "getLabels",
137  &QtRootNTuple::getLabels,
138  return_value_policy < copy_const_reference > (),
139  "getLabels () -> list\n"
140  "\n"
141  "Returns the column labels. Note: if a column is an array the\n"
142  "shape does not appear as part of the label.\n" )
143 
144 #ifdef HAVE_NUMARRAY
145  .def ( "valueAt",
146  &QtRootNTuple::valueAt,
147  return_value_policy < return_by_value > (),
148  "valueAt ( index, label ) -> array\n"
149  "\n"
150  "Returns the numerical array for the array variable in column\n"
151  "specified by label, for the row index. Note: this method is\n"
152  "only available if the hippo module was configured for numerical\n"
153  "array support." )
154 #endif
155  ;
156 }
157 
158 } // namespace Python
159 } // namespace hippodraw

Generated for HippoDraw Class Library by doxygen