LinkdDef instruction and class informations to add for inherithed classes in RooFit

Dear ROOT and ROoFit experts

I have a simple question .
We have written a class inherithin from RooNLLVar

class AdaptiveNLL : public RooNLLVar{ 

In the LinkDef.h file we use we have

#pragma link C++ class AdaptiveNLL+;

When we compile we get

Warning: Unused class rule: AdaptiveNLL

Are we doing something wrong with LinkDef with inheritances ?

THe same kind of code is working when we write a class inherithing from TObject and we write the ClassDef, and ClassImp stuff inside our classes. I wonder if there ClassDef/Imp is special for TObject based classes or it can be expanded also in RooFit world.
Thanks
Renato


For the records, i added the ClassDef and ClassImp around, the messages disappear but it seems like i must reimplement something related to the TBuffer and streaming to disk of this class.
I guess that inside RooFit, any extension of RooRealVar , or other classes should have some extra method to be written down for persistency, things you don’t need for inherithed classes from TObject. Is that correct?

Hi @RENATO_QUAGLIANI,
Can you confirm you have includeed a default constructor to your class? ROOT I/O requires it. For RooFit specifics, I believe @StephanH can help you out.
Cheers,
Vincenzo

Hi Renato,

I’m not the super I/O expert, but I dare say these things:

  • You need a ClassDef macro and mention it in the LinkDef.h if you want to do I/O with the classes.
  • ClassImp seems to be unnecessary these days.
  • You don’t need to write your own streamers. Use ClassDef(ClassName, 1) and #pragma link C++ class ClassName+;, and you get automatic streamers.
    • A - in LinkDef means that you want to write the streamer yourself. Not recommended!!!
    • A ClassDef(ClassName, 0) means that you don’t want I/O.

More info about streamers:
https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#streamers

Check also chapter 15, adding a class.

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