I’m using RDataFrame for my analysis I tried to apply a lumi mask on Data following a similar implementation done here (vlq-BtoTW-RDF/analyzer_RDF.cc at main · jmhogan/vlq-BtoTW-RDF · GitHub) in RDataFrame. However, after including the necessary header files and files, I keep getting the following error:
/cvmfs/cms.cern.ch/el9_amd64_gcc11/external/gcc/11.2.1-f9b9dfdd886f71cd63f5538223d8f161/bin/…/lib/gcc/x86_64-redhat-linux-gnu/11.2.1/…/…/…/…/x86_64-redhat-linux-gnu/bin/ld: /tmp/hboucham/ccEGkCCJ.o: in function main': /afs/cern.ch/user/h/hboucham/work/H4B/CMSSW_13_1_0_pre4/src/demo-luna-framework/skim/skim_muon.cxx:101: undefined reference to lumiMask::fromJSON(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned int, unsigned int)’
collect2: error: ld returned 1 exit status
I see you have added the header lumiMask.h and implementation lumiMask.cc files to the branch of your repositories, but I don’t see anywhere in the repo where the compilation happens. If the lumiMask class is not compiled your linker won’t be able to find its symbols (and the definitions of the functions of the class). There are a few ways to go about this: one usually builds a shared library, but you can also just compile the .cc file together with your main file e.g. g++ skim_muon.cxx lumiMask.cxx and that could be enough. As soon as your application becomes closer to a collection of classes and functionalities, you will need to start packaging it as a library, which is usually done via CMake (see CMakeLists.txt files written everywhere in C++ libraries, including ROOT or CMSSW).
/cvmfs/cms.cern.ch/el9_amd64_gcc11/external/gcc/11.2.1-f9b9dfdd886f71cd63f5538223d8f161/bin/…/lib/gcc/x86_64-redhat-linux-gnu/11.2.1/…/…/…/…/x86_64-redhat-linux-gnu/bin/ld: /tmp/hboucham/ccYNyZEo.o: in function lumiMask::LumiBlockRange::run() const': /afs/cern.ch/user/h/hboucham/work/H4B/CMSSW_13_1_0_pre4/src/demo-luna-framework/skim/helpers/lumiMask.h:27: multiple definition of operator<(lumiMask::LumiBlockRange const&, lumiMask::LumiBlockRange const&)'; /tmp/hboucham/ccEO2w8V.o:/afs/cern.ch/user/h/hboucham/work/H4B/CMSSW_13_1_0_pre4/src/demo-luna-framework/skim/helpers/lumiMask.h:27: first defined here
collect2: error: ld returned 1 exit status
skim_muon.cxx:162:67: error: no match for ‘operator=’ (operand types are ‘ROOT::RDataFrame’ and ‘ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void>’)
/cvmfs/cms.cern.ch/el9_amd64_gcc11/cms/cmssw/CMSSW_13_1_0_pre4/external/el9_amd64_gcc11/bin/…/…/…/…/…/…/…/el9_amd64_gcc11/lcg/root/6.26.11-c74497fa7b0ab8f85c01e868f4d2fa9e/include/ROOT/RDataFrame.hxx:50:7: note: no known conversion for argument 1 from ‘ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void>’ to ‘const ROOT::RDataFrame&’
/cvmfs/cms.cern.ch/el9_amd64_gcc11/cms/cmssw/CMSSW_13_1_0_pre4/external/el9_amd64_gcc11/bin/…/…/…/…/…/…/…/el9_amd64_gcc11/lcg/root/6.26.11-c74497fa7b0ab8f85c01e868f4d2fa9e/include/ROOT/RDataFrame.hxx:50:7: note: no known conversion for argument 1 from ‘ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void>’ to ‘ROOT::RDataFrame&&’
In file included from /usr/include/boost/bind.hpp:30,
from /usr/include/boost/property_tree/json_parser/detail/parser.hpp:7,
from /usr/include/boost/property_tree/json_parser/detail/read.hpp:13,
from /usr/include/boost/property_tree/json_parser.hpp:16,
skim_muon.cxx:105:133: error: cannot convert ‘main(int, char**)::<lambda(unsigned int&, unsigned int&)>’ to ‘char’ in initialization
105 char goldenjson = [myLumiMask](unsigned int &run, unsigned int &luminosityBlock){return myLumiMask.accept(run, luminosityBlock);};|
So I assumed it was of type <lambda(unsigned int&, unsigned int&)>, which is wrong. ( note that type main(int, char**)::<lambda(unsigned int&, unsigned int&)> and LumiMask::<lambda(unsigned int&, unsigned int&)> did not work as well).