Setting precedence in CMakeList.txt


So I have a project that I am trying to manipulate so that it compiles a copy of RooSimultaneous.cxx and RooSimultaneous.h from my source directory instead of going into the ROOT libraries.
I have attached a copy of my CMakeLists.txt file.

Incase you need to run the project here is the link to the project:

The command used to run the code is:

./StandardHypoTestInv …/Input/test_24GeV/HZdZd4l_mZd24_GeV_combined_allsys_model.root -w combined -d obsData -p 1 -n 1000 -t 5


CMakeLists.txt (5.4 KB)


I don’t think this can work. You can either replace the files, and recompile root, or you rename the RooSimultaneous class, and use that instead of the “original” one.

So I have already tried that. But I have noticed that when I use the Clion debugger, the code stack shows that the function RooAbsPdf::autoGenContext() from RooSimultaneous is the one that steps out from my local directory to the ROOT library. All the other functions before autoGenContext() are called from my local directory.

It’s probably better to inherit from the RooSimultaneous, and override all the functions that you want to change. In this way, you have full control over which functions are being used, and you “RooSimultaneous” will have a different name, so there are no surprises and name clashes.

Hi. Sorry for the extremely late reply. I was trying out the other solutions that we discussed.

So I have created a class that inherits from RooSimultaneous.h called RooSimultaneous1.h. It initially complained about RooAbsPdf not being a base class for the function

  RooAbsPdf* getPdf(const char* catName) const ;

I then went to the class definition in RooSimultaneous.h and made the base class RooAbsPdf virtual

class RooSimultaneous : virtual public RooAbsPdf {

I then went and included RooSimultaneous1.h in one of the source codes in my project directory and tweeked one line of code where an object is dynamically casted from RooAbsPdf to RooSimultaneous by replacing RooSimultaneous with RooSimultaneous1

  const RooSimultaneous* pdf= dynamic_cast<const RooSimultaneous*>(pdfIn);

but then the compiler gives me the following warning:

/Users/cashcrusaders/Documents/UJ_LimitSetting_almost/src/WorkspaceCalculator.cxx:1183:41: error: 'indexCat' is a private member of 'RooSimultaneous1'
  const RooAbsCategoryLValue& cat= pdf->indexCat();

why does the compiler complain about indexCat being a private member of RooSimultaneous1 but does not complain about RooSimultaneous?

Hi @Xola,

No worries. If a topic remains silent, I just work on other things.

Don’t change anything in RooFit, this should work:

class RooSimultaneous1 : public RooSimultaneous {
// Override the function that should change its behaviour:

If you don’t see why this makes sense, or you need a bit more info what overriding a function means, you can google for an introduction of how inheritance works in C++. That will be worth reading.