Hi experts,
I am analyzing some data using RDataFrame and I encountered a problem:
I am trying to extract some info from my data and I’d like to use Define to produce a TTree with branches and leaves (I want the leaves to be both containers (RVec) and normal types).
So I have tried to create both a class and a typedef struct to define columns but in my final TTree RVecs are also treated like objects and so in the TBrowser they appear as subbranches of my class and I also can see some of their methods (?) (I hope the screenshot will clarify). What I expected was just to see them as if I was just defining normal RVec columns or any other collection type associated to a contiguous storage in memory.
Here is the code I am using:
TUPLE_WITH_8_RVEC_DOUBLE analyze ( ROOT::VecOps::RVec<int> v ){
/*my calculation*/
}
class myClass
{
public:
int Nup;
int Ndwn;
ROOT::VecOps::RVec<double> timeUp;
ROOT::VecOps::RVec<double> timeDwn;
};
int main(int argc, char** argv){
//code to obtain input directories...
gInterpreter->Declare("class myClass { public: int Nup; int Ndwn; ROOT::VecOps::RVec<double> timeUp; ROOT::VecOps::RVec<double> timeDwn; };");
auto g = [=]( TUPLE_WITH_8_RVEC_DOUBLE WVF_dec )->myClass{
myClass a;
a.Nup = (int)get<0>(WVF_dec).size();
a.Ndwn = (int)get<1>(WVF_dec).size();
a.timeUp = get<2>(WVF_dec);
a.timeDwn = get<3>(WVF_dec);
return a; };
ROOT::EnableImplicitMT();
ROOT::RDataFrame d(treeInName.c_str(), rootIn.c_str());
auto d0 = d.Define("WVFdecoded" , []( ROOT::VecOps::RVec<int> ADC_ch ){ return analyze(ADC_ch); }, {"ch0"} )
.Define("ch00" , g , {"WVFdecoded" } );
d0.Snapshot(treeOutName.c_str(), rootOut.c_str(), {"event","ch00"});
return 0;
}
The easiest way out would be to give up using myClass and just call each column with a prefix but I think it would be more general using branches and leaves so I would appreciate any help to solve this.
Thanks in advance.
ROOT Version: 6.22/07
Platform: Ubuntu 20.10
Compiler: GCC 10.2.0