[RDataFrame] Error implementing Lumi Mask

Dear experts,

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

Here is the relevant part of my code: skim/skim_muon.cxx · dev0328 · Hichem Bouchamaoui / Hichem-LUNA-framework · GitLab
I included the relevant headed file (lumiMask.h) and JSON file in that GitLab branch, so I’m not sure why “lumiMask::fromJSON(…)” is undefined.

Thank you for your help,
Hichem


_ROOT Version: 6.26/11
_Platform: lxplus


1 Like

Dear @bouchamaouihichem ,

Thanks for reaching out to the forum!

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).

Cheers,
Vincenzo

Hi Vincenzo,

Thank you for the suggestion! I tried implementing that in .sh file as shown here (skim/runSkim_muon.sh · dev0328 · Hichem Bouchamaoui / Hichem-LUNA-framework · GitLab), but now I get the following (ironic) 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/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

Did I compile the executable incorrectly?

Thank you for your help,
Hichem

Hi @bouchamaouihichem ,

Can you try by splitting skim/helpers/lumiMask.h · dev0328 · Hichem Bouchamaoui / Hichem-LUNA-framework · GitLab into just the declaration in the header file and the definition in the cpp file?

Cheers,
Vincenzo

Hi Vincenzo,

Thank you for the suggestion, I did that and got a little further. I was able to define the lumi mask but now I run into an error when I try to apply it to my df as shown here (skim/skim_muon.cxx · dev0328 · Hichem Bouchamaoui / Hichem-LUNA-framework · GitLab) similar to what is done in the example I’m following (vlq-BtoTW-RDF/analyzer_RDF.cc at main · jmhogan/vlq-BtoTW-RDF · GitHub). Doing this gives me the following error:

skim_muon.cxx:162:67: error: no match for ‘operator=’ (operand types are ‘ROOT::RDataFrame’ and ‘ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void>’)
162
In file included from skim_muon.cxx:12:
/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: candidate: ‘ROOT::RDataFrame& ROOT::RDataFrame::operator=(const ROOT::RDataFrame&)’
50
/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: candidate: ‘ROOT::RDataFrame& ROOT::RDataFrame::operator=(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,
from helpers/lumiMask.cc:4:

Alternatively I tried defining a helper function to apply the lumi mask here (skim/skim_muon.cxx · dev0328 · Hichem Bouchamaoui / Hichem-LUNA-framework · GitLab) and defined here (skim/helpers/ZH-mumu.h · dev0328 · Hichem Bouchamaoui / Hichem-LUNA-framework · GitLab), but it seems that I’m not using the correct type for the object “goldenjson”. To find the type of that object I changed its initialization type from auto to char, which gave me the following error:

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).

Thank you very much for your help,
Hichem

Dear @bouchamaouihichem

https://root.cern/doc/master/classROOT_1_1RDataFrame.html#rnode

ROOT::RDF::RNode sentinel = df;

sentinel = sentinel.Define(...);
sentinel = sentinel.Filter(...);
sentinel.Histo1D().Draw();

Hi Vincenzo,

Thank you for the fix, the problem is resolved now!

best,
Hichem

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.