Please read tips for efficient and successful posting and posting code
ROOT Version: 6.18.00
Platform: lxplus
Hi, I am trying to initialize the RVec in C++, but I can’t.
I would like to make a new RVec which is filled with “1.0” to multiply to Data in ROOT::RDataFrame
.
#include "ROOT/RDataFrame.hxx"
#include "ROOT/RVec.hxx"
#include "ROOT/RDF/RInterface.hxx"
#include "Math/Vector4D.h"
#include "Math/Vector4Dfwd.h"
#include <vector>
using namespace ROOT::VecOps;
using rvec_f = const RVec<float> &;
rvec_f data_scale( rvec_f pt ){
vector<float> tmp;
for( int i = 0; i < pt.size() ; i++){
tmp.push_back(1.0);
}
rvec_f out(tmp.data(), tmp.size());
return out;
}
I just found that “Owning and adopting memory part in the template references (https://root.cern.ch/doc/v614/classROOT_1_1VecOps_1_1RVec.html)”, but it does not work.
The error messages start with:
/cms/ldap_home/sarakm0704/WORK/ttbb/ana_rdf.C:22:10: error: reference cannot be initialized with multiple values
rvec_f out(tmp.data(), tmp.size());
^ ~~~~~~~~~~~~~~~~~~~~~~
Thanks!
Jieun