I have a hopefully simple (but possibly not…) question.
In one of my projects I’ve been writing RooPlot objects to ROOT files, so that I could draw them in a follow-up session, after a fit was done. For this I simply used code like:
outputFile->cd();
plot->Write("fitPlot");
This worked very well in the past. But now that I tried to use this code with ROOT 6.34, I’m getting tons of the following warnings from that RooPlot::Write call.
...
Warning in <TBufferFile::WriteObjectAny>: since RooFit::Detail::RooNormalizedPdf has no public constructor
which can be called without argument, objects of this class
can not be read with the current library. You will need to
add a default constructor before attempting to read it.
Warning in <TBufferFile::WriteObjectAny>: since RooFit::Detail::RooNLLVarNew has no public constructor
which can be called without argument, objects of this class
can not be read with the current library. You will need to
add a default constructor before attempting to read it.
...
And sure enough, just like the warnings suggest, I cannot read the object back.
root [3] bestFitPlot->Draw()
Error in <TClass::New>: cannot create object of class RooFit::Detail::RooNormalizedPdf
Error in <TBufferFile::ReadObject>: could not create object of class RooFit::Detail::RooNormalizedPdf
Error in <TExMap::Remove>: key 589824 not found at 310
Warning in <TBufferFile::CheckObject>: reference to object of unavailable class TObject, offset=589824 pointer will be 0
Error in <TExMap::Remove>: key 16391 not found at 295
Warning in <TBufferFile::CheckObject>: reference to object of unavailable class RooAbsArg, offset=16391 pointer will be 0
Error in <TExMap::Remove>: key 771424261 not found at 323
Warning in <TBufferFile::CheckObject>: reference to unavailable class RooAbsArg, pointers of this type will be 0
Error in <TBufferFile::CheckByteCount>: object of class vector<RooAbsArg*> read too few bytes: 59 instead of 503356
Error in <TClass::New>: cannot create object of class RooFit::Detail::RooNormalizedPdf
Error in <TBufferFile::ReadObject>: could not create object of class RooFit::Detail::RooNormalizedPdf
Error in <TExMap::Remove>: key 4194304 not found at 291
So… Am I actually doing something unsupported by trying to persistify a RooPlot object? Is it intentional that this should not work?
Cheers,
Attila
P.S. To point it out again, this is something that used to work just fine with previous versions of ROOT.
Though the even crazier thing is that the script in which I read these objects, after printing a ton of errors, actually produces an output plot as I would expect.
...
Error in <TClass::New>: cannot create object of class RooFit::Detail::RooNormalizedPdf
Error in <TBufferFile::ReadObject>: could not create object of class RooFit::Detail::RooNormalizedPdf
Error in <TExMap::Remove>: key 37342 not found at 830
Warning in <TBufferFile::CheckObject>: reference to object of unavailable class RooAbsArg, offset=37342 pointer will be 0
Error in <TClass::New>: cannot create object of class RooFit::Detail::RooNLLVarNew
Error in <TBufferFile::ReadObject>: could not create object of class RooFit::Detail::RooNLLVarNew
Error in <TBufferFile::CheckByteCount>: object of class vector<RooAbsArg*> read too few bytes: 43 instead of 2417628
Info in <TCanvas::Print>: eps file signalMultiPlot.eps has been created
Info in <TCanvas::Print>: pdf file signalMultiPlot.pdf has been created
Info in <TCanvas::Print>: png file signalMultiPlot.png has been created
I.e. the produced images look more or less okay. So what’s the idea here? Should I be doing something different…?
The “important note” says that one shouldn’t use 6.34 as a long term supported (data taking) release of ROOT. And sure enough, we’re not doing that in ATLAS. We still use it in our main branch to do all of our developments with. We even use it to produce files for analyzers.
When it comes to something like RooFit / RooStats, I’m okay with it not being in tip-top shape in 6.35/XX. (Though even there, if I ran into a bug, I would first come here to ask about that bug.) But 6.34/XX is surely fair game.
Worst of all: While 3.32/12 (the one I tried just now) doesn’t print warnings when saving a RooPlot object, reading it back still is very much broken.
Processing /home/krasznaa/XXX/configs/2023-march-2023-07-26/bestFitPlot.C("/home/krasznaa/XXX/2025-04-19-18:40/ipc-2023-marc.root")...
Info in <bestFitPlot>: Opened file: /home/krasznaa/XXX/2025-04-19-18:40/ipc-2023-marc.root
input_line_35:5:21: error: allocating an object of abstract class type 'RooAbsPdf'
*ret = new RooAbsPdf;
^
/home/krasznaa/software/hep/root-6.32.12/x86_64-ubuntu2404-gcc13-opt/include/RooAbsArg.h:88:20: note: unimplemented pure virtual method 'clone' in 'RooAbsPdf'
virtual TObject* clone(const char* newname=nullptr) const = 0 ;
^
/home/krasznaa/software/hep/root-6.32.12/x86_64-ubuntu2404-gcc13-opt/include/RooAbsReal.h:460:18: note: unimplemented pure virtual method 'evaluate' in 'RooAbsPdf'
virtual double evaluate() const = 0;
^
input_line_35:8:21: error: allocating an object of abstract class type 'RooAbsPdf'
*ret = new RooAbsPdf[nary];
^
input_line_35:13:29: error: allocating an object of abstract class type 'RooAbsPdf'
*ret = new (arena) RooAbsPdf;
^
input_line_35:16:29: error: allocating an object of abstract class type 'RooAbsPdf'
*ret = new (arena) RooAbsPdf[nary];
...
Error in <TClingCallFunc::make_ctor_wrapper>: Failed to compile
==== SOURCE BEGIN ====
__attribute__((used)) extern "C" void __ctor_449(void** ret, void* arena, unsigned long nary)
{
if (!arena) {
if (!nary) {
*ret = new RooAbsPdf;
}
else {
*ret = new RooAbsPdf[nary];
}
}
else {
if (!nary) {
*ret = new (arena) RooAbsPdf;
}
else {
*ret = new (arena) RooAbsPdf[nary];
}
}
}
==== SOURCE END ====
Error in <TClingCallFunc::ExecDefaultConstructor>: Called with no wrapper, not implemented!
Error in <TClingClassInfo::New()>: Call of default constructor failed to return an object for class: RooAbsPdf
Error in <TClass::New>: cannot create object of class RooAbsPdf
Error in <TBufferFile::ReadObject>: could not create object of class RooAbsPdf
Error in <TExMap::Remove>: key 29925 not found at 5575
Warning in <TBufferFile::CheckObject>: reference to object of unavailable class RooAbsArg, offset=29925 pointer will be 0
Info in <TCanvas::Print>: eps file bestFitPlot.eps has been created
Info in <TCanvas::Print>: pdf file bestFitPlot.pdf has been created
Info in <TCanvas::Print>: png file bestFitPlot.png has been created
Which I would still love some help with. (The same as I wrote before, there are plots coming out after all these errors.)
Since this is a piece of code that I very rarely update to newer ROOT versions with, I can only say that with ROOT 6.26 it still works without any errors.
------------------------------------------------------------------
| Welcome to ROOT 6.26/16 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Mar 20 2024, 08:44:17 |
| From tags/v6-26-16@v6-26-16 |
| With c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Processing /home/krasznaa/XXX/configs/2023-march-2023-07-26/bestFitPlot.C("/home/krasznaa/XXX/2025-04-19-18:59/ipc-2023-marc.root")...
RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
Info in <bestFitPlot>: Opened file: /home/krasznaa/XXX/2025-04-19-18:59/ipc-2023-marc.root
Info in <TCanvas::Print>: eps file bestFitPlot.eps has been created
Info in <TCanvas::Print>: pdf file bestFitPlot.pdf has been created
Info in <TCanvas::Print>: png file bestFitPlot.png has been created
But I’m not sure with exactly which version of ROOT this changes. (Though I might go and test this out, as there aren’t that many major versions between the already mentioned one…)