Dear all
I have to calibrate data in my columns with a linear function. I would like to that with the use of a reusable function. In order to do that, I am looping .Define, as explained in this post. The problem I have now is how to pass information about which column is being called to my calibrating function, in order to get proper calibration parameters.
Calibrating Function below
ROOT::VecOps::RVec<float> calibrateMe(ROOT::VecOps::RVec<unsigned short> &inputArray)
{
auto mySize = array.size();
ROOT::VecOps::RVec<float> outputArray(mySize);
for (size_t iii = 0; iii < mySize; iii++)
{
outputArray.at(iii) = B[iii] + A[iii] * inputArray[iii];
}
return outputArray;
}
Looped Define function
ROOT::RDF::RNode ApplyDefines(
ROOT::RDF::RNode df,
const std::vector<std::string> &colNames,
unsigned int iii = 0)
{
if (iii == colNames.size())
{
return df;
}
std::string newColumn = colNames[iii];
inputColumn.insert(0, cal_);
return ApplyDefines(df.Define(newColumn.c_str(), calibrateMe, {colNames[iii].c_str()}), colNames, iii + 1);
}
I figured out that I could modify the first entry in the input tree to contain some ID, but that doesn’t seem to be an elegant solution. Does anybody have any idea?
Cheers,
Bogumił
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.22/00
Platform: Ubuntu 18.04
Compiler: gcc version 7.5.0