1 if __name__ ==
'__main__':
2 print(
"This is the source file that implements the cafana python module.")
3 print(
"You should 'import cafana' at the top of a .py script")
4 print(
"and execute it with 'cafe myscript.py'")
9 if 'SBNANA_INC' in os.environ:
10 inc = os.environ[
'SBNANA_INC']
12 inc = os.environ[
'MRB_INSTALL']+
'/sbnana/'+os.environ[
'SBNANA_VERSION']+
'/include/'
14 if 'SBNANAOBJ_INC' in os.environ:
15 sao_inc = os.environ[
'SBNANAOBJ_INC']
17 sao_inc = os.environ[
'MRB_INSTALL']+
'/sbnanaobj/'+os.environ[
'SBNANAOBJ_VERSION']+
'/include/'
19 os.environ[
'ROOT_INCLUDE_PATH'] = \
24 os.environ[
'EIGEN_INC'],
25 os.environ[
'OSCLIB_INC'],
26 os.environ[
'SRPROXY_INC']])
30 if 'SBNANA_FQ_DIR' in os.environ:
31 ROOT.gApplication.ExecuteFile(
'${SBNANA_FQ_DIR}/bin/rootlogon.C')
33 ROOT.gApplication.ExecuteFile(
'$MRB_BUILDDIR/sbnana/bin/rootlogon.C')
35 ROOT.gROOT.ForceStyle()
37 print(
'Load libraries...')
38 for lib
in [
'Minuit2',
39 'sbnanaobj_StandardRecordProxy',
51 ROOT.gSystem.Load(
'lib'+lib+
'.so')
56 print(
'Load dictionaries... (please ignore errors about .pcm files)')
57 for d
in [
'CAFAna',
'SBNAna']:
59 cppyy.load_reflection_info(
'lib'+d+
'_dict.so')
66 '''Construct a new slice Var given the C++ body as a string'''
67 var =
'pyvar_'+self._cppyy.gbl.ana.UniqueName()
68 text =
'#include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"\ndouble '+var+
'_func(const caf::SRSliceProxy* srp){\nconst caf::SRSliceProxy& sr = *srp;\n'+body+
'\n}\nconst ana::Var '+var+
'('+var+
'_func);'
69 self._cppyy.cppdef(text)
70 return getattr(self._cppyy.gbl, var)
73 '''Construct a new spill Var given the C++ body as a string'''
74 var =
'pyvar_'+self._cppyy.gbl.ana.UniqueName()
75 text =
'#include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"\ndouble '+var+
'_func(const caf::SRSpillProxy* srp){\nconst caf::SRSpillProxy& sr = *srp;\n'+body+
'\n}\nconst ana::Var '+var+
'('+var+
'_func);'
76 self._cppyy.cppdef(text)
77 return getattr(self._cppyy.gbl, var)
80 '''Equivalent of the SIMPLEVAR() macro'''
81 return self.
CSliceVar(
'return sr.'+name+
';')
84 '''Equivalent of the SIMPLEVAR() macro'''
85 return self.
CSpillVar(
'return sr.'+name+
';')
88 '''Construct a new Cut given the C++ body as a string'''
89 cut =
'pycut_'+self._cppyy.gbl.ana.UniqueName()
90 text =
'#include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"\nbool '+cut+
'_func(const caf::SRSliceProxy* srp){\nconst caf::SRSliceProxy& sr = *srp;\n'+body+
'\n}\nconst ana::Cut '+cut+
'('+cut+
'_func);'
91 self._cppyy.cppdef(text)
92 return getattr(self._cppyy.gbl, cut)
95 '''Construct a new Cut given the C++ body as a string'''
96 cut =
'pycut_'+self._cppyy.gbl.ana.UniqueName()
97 text =
'#include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"\nbool '+cut+
'_func(const caf::SRSpillProxy* srp){\nconst caf::SRSpillProxy& sr = *srp;\n'+body+
'\n}\nconst ana::Cut '+cut+
'('+cut+
'_func);'
98 self._cppyy.cppdef(text)
99 return getattr(self._cppyy.gbl, cut)
104 return getattr(self._cppyy.gbl.ana, name)
107 sys.modules[
'cafana'] =
PyCAFAna(cppyy)
do one_file $F done echo for F in find $TOP name CMakeLists txt print
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.