Open miranov25 opened 1 year ago
In [10]: rdf2 = makeDefine("arrayD","array1D0[1:10]-array1D2[:20:2]", rdf,3, True)
====================================
arrayD
array1D0[1:10]-array1D2[:20:2]
====================================
Implementation:
auto arrayD(){
RVec<double> result(9);
for(size_t i=0; i<9; i++){
result[i] = (array1D0[1+i*1]) - (array1D2[0+i*2]);
}
return result;
}
Dependencies
['array1D0', 'array1D2']
# rdf2 = makeDefine("arrayD","cos(array1D0[1:10])", rdf,3, True) # TODO Failing - cos is fund as an obect - not function
# rdf2 = makeDefine("arrayD","array1DTrack[1:10].Px()", rdf,3, True) # TODO Failing - member function not found
https://github.com/miranov25/RootInteractive/commit/fd829c5872e6d2d53be2c7b1ed29fd8117ea7b63
-------- -----
Columns in total 14
Columns from defines 14
Event loops run 8
Processing slots 1
Column Type Origin
------ ---- ------
array1D0 ROOT::VecOps::RVec<float> Define
array1D2 ROOT::VecOps::RVec<float> Define
array1DTrack ROOT::VecOps::RVec<TParticle> Define
array2D0 ROOT::VecOps::RVec<ROOT::VecOps::RVec<float> > Define
array2D1 ROOT::VecOps::RVec<ROOT::VecOps::RVec<float> > Define
arrayCos0 ROOT::VecOps::RVec<double> Define
arrayCosAll ROOT::VecOps::RVec<double> Define
arrayD0 ROOT::VecOps::RVec<float> Define
arrayD1D2D ROOT::VecOps::RVec<ROOT::VecOps::RVec<float> > Define
arrayD2D ROOT::VecOps::RVec<ROOT::VecOps::RVec<float> > Define
arrayDAall ROOT::VecOps::RVec<float> Define
arrayPx ROOT::VecOps::RVec<double> Define
nPoints int Define
nPoints2 int Define
In [8]: rdf=makeDefine("arrayD2D","array2D0[:][:]>0", rdf,3, True);
ROOT::VecOps::RVec<float> ROOT::VecOps::RVec<float>
float ('f', 32)
====================================
arrayD2D
array2D0[:][:]>0
====================================
Implementation:
ROOT::VecOps::RVec<char> arrayD2D(ROOT::VecOps::RVec<ROOT::VecOps::RVec<float> > &array2D0){
ROOT::VecOps::RVec<char> result(array2D0[0+i*1].size() - 0);
for(size_t i=0; i<array2D0[0+i*1].size() - 0; i++){
result[i] = ((array2D0[0+i*1][0+i*1]) > (0));
}
return result;
}
Dependencies
['array2D0']
#pragma link C++ class ROOT::RVec < ROOT::RVec < char>> + ;
# test 7 - 2D boolen test
parsed=makeDefine("arrayD20Bool","array2D0[:,:]>0", rdf,3, True);
rdf = makeDefineRDF("arrayD20Bool", parsed["name"], parsed, rdf, verbose=1)
rdf.Snapshot("makeTestRDataFrame","makeTestRDataFrameArrayD1D2D.root");
After fix withaccess to class method in commit above, still some problems observed
In [9]: getClassMethod("o2::tpc::TrackTPC","getAlpha")
Out[9]:
('float o2::track::TrackParametrization<float>::getAlpha()',
'float o2::track::TrackParametrization<float>::getAlpha()')
==>
File ~/github/RootInteractive/RootInteractive/Tools/RDataFrame/RDataFrame_Array.py:74, in scalar_type_str(dtype)
63 def scalar_type_str(dtype):
64 dtypes = {
65 ('f', 32): "float",
66 ('f', 64): "double",
(...)
72 ('i', 8): "char"
73 }
---> 74 return dtypes[dtype]
KeyError: 'float o2::track::TrackParametrization<float>::getAlpha()'
In [24]: getClassMethod("""o2.track.TrackParametrization""","getAlpha")
Non supported o2.track.TrackParametrization.getAlpha
Out[24]: ('', '')
In [25]: getClassMethod("""o2.track.TrackParametrization<float>""","getAlpha")
Non supported o2.track.TrackParametrization<float>.getAlpha
Out[25]: ('', '')
In [28]: getClassMethod("""o2.track.TrackParametrization("float")""","getAlpha")
Out[28]:
('float o2::track::TrackParametrization<float>::getAlpha()',
'float o2::track::TrackParametrization<float>::getAlpha()')
Template arguments to be replaced
The code crash if more than one function is returning. Example:
In [11]: getClassMethod("""o2::track::TrackParametrization<float>""","getAlpha")
Out[11]:
('float o2::track::TrackParametrization<float>::getAlpha()',
'float o2::track::TrackParametrization<float>::getAlpha()')
In [16]: getClassMethod("""o2::track::TrackParametrization<float>""","getYAt")
Out[16]:
('float o2::track::TrackParametrization<float>::getYAt(float xk, float b)',
'float o2::track::TrackParametrization<float>::getYAt(float xk, float b)')
In case the function is generated, in the second time the generation fails, because the function is already in the scope.
What should be error handling?
The problem looks to be random
To simplify the debugging and to make the code faster, it is preferable as an option to save the code in C++ and make a shared library from there.
R"(dfRI=makeDefine('normChi2TPC', 'sqrt(tracksExtra[:].fTPCChi2NCl)', dfRI,0x3,0x2,rdfLib))""\n"
R"(dfRI=makeDefine('normChi2TPC', 'TMath:sqrt(tracksExtra[:].fTPCChi2NCl)', dfRI,0x3,0x2,rdfLib))""\n"
Similarly already done for classes
in example above:
In [12]: ROOT.sqrt.func_doc
Out[12]: 'long double ::sqrt(long double __x)\nfloat ::sqrt(float __x)\ndouble ::sqrt(double __x)'
In [13]: ROOT.TMath.Sqrt.func_doc
Out[13]: 'double TMath::Sqrt(double x)'
parsed = makeDefine("array2D0_cos0", "cos(array2D0[0:0,:])", rdf, None, 3); # this is working
parsed = makeDefine("array2D0_cos1", "TMath::Cos(array2D0[0:0,:])", rdf, None, 3); # this is failing
rdf = makeDefine("array2D0_0", "array2D0[0:0,:]", rdf, None, 3); # this works as intended
#rdf = makeDefine("array2D0_0", "array2D0[0]", rdf, None, 3); # should return 1D RVec at position 0, now it is failing
https://gitter.im/matrix/5ba1f93bd73408ce4fa8a265/@agoose77:matrix.org?at=639f83faa151003b5a7550f4
Possible simplification the creation of RDataFrame function definitions As for simplifying the generation of RDataFrame templates, @pl0xz0rz has implemented something similar in RootInteractive for Python -> javascript with ast. We have replaced the python functions with corresponding javascript functions.