Error in <Streamer>: Cannot stream interpreted class

Dear experts,

I am working on an LXPLUS machine, with the ROOT version 6.24/08.
Considering my inexperience with ROOT, I would like having suggestions to solve the errors:

Error in < Streamer >: Cannot stream interpreted class.
Error in < Streamer >: Cannot stream interpreted class.
Error in < Streamer >: Cannot stream interpreted class.
Error in < Streamer >: Cannot stream interpreted class.

that I see during the RooWorkspace generation that I defined as:

RooWorkspace workspace("Dsmumu_workspace");
workspace.import(sum);
workspace.import(*data_DsMuMu_RS2, Rename("Dsmumu_data"));
workspace.writeToFile("WorkspaceDsMuMu.root");
workspace.Print();

where “sum” is the p.d.f. defined as:

RooAddPdf sum("sum", "g+g+p", RooArgList(PDF_Ds1_2460, PDF_Ds1_2536, R4_feed, R44_feed, poly), RooArgList(nsig, nsig2, nsig3, nsig4, nbkg));

“data_DsMuMu_RS2” is the dataset defined as:

RooDataSet* data_DsMuMu_RS2 = new RooDataSet("data_DsMuMu_RS2", "dataset with x", RooArgSet(Ds1_M_DTF_Ds_PV, Ds1_M23_DTF_Ds_PV, Ds1_M12_DTF_Ds_PV), Import(*tree));

Thank you a lot for any kind of help!

However, the full output I see on LXPLUS is:

[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooAddPdf::sum
[#1] INFO:Caching -- RooExpensiveObjectCache::importCache() importing cache object PDF_Ds1_2460_RBW_2460_CONV_Ip_2460_CACHEHIST_Obs[Ds1_M_DTF_Ds_PV]_BufFrac0.1_BufStrat0 associated with object PDF_Ds1_2460
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooFFTConvPdf::PDF_Ds1_2460
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::Ds1_M_DTF_Ds_PV
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRelBreitWigner::RBW_2460
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooAddition::sigmean
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::m_{D_{s1}(2460)}-m_{D_{s1}(2536)}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::m_{D_{s1}(2536)}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::#Gamma_{D_{s1}(2460)}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::spin
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::radius
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mDau1
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mDau2
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooIpatia2::Ip_2460
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_Lb
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_zetab
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_betab
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooProduct::mcI1_res_2460b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::resratiot
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_res_2536b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::dM_2460b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_a1b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_n1b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_a2b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::mcI1_n2b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::nsig_{D_{s1}(2460) #rightarrow D_{s}#mu#mu}
[#1] INFO:Caching -- RooExpensiveObjectCache::importCache() importing cache object PDF_Ds1_2536_RBW_2536_CONV_Ip_2536_CACHEHIST_Obs[Ds1_M_DTF_Ds_PV]_BufFrac0.1_BufStrat0 associated with object PDF_Ds1_2536
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooFFTConvPdf::PDF_Ds1_2536
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRelBreitWigner::RBW_2536
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::#Gamma_{D_{s1}(2536)}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooIpatia2::Ip_2536
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::dM_2536b
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::nsig_{D_{s1}(2536) #rightarrow D_{s}#mu#mu}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooKeysPdf::R4_feed
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::nsig_{D_{s1}(2460) #rightarrow D_{s}*#mu#mu}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooKeysPdf::R44_feed
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::nsig_{D_{s1}(2536) #rightarrow D_{s}*#mu#mu}
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooChebychev::poly
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::pzero
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::pone
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::nbkg
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing dataset data_DsMuMu_RS2
[#1] INFO:ObjectHandling -- RooWorkSpace::import(Dsmumu_workspace) changing name of dataset from  data_DsMuMu_RS2 to Dsmumu_data
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::Ds1_M23_DTF_Ds_PV
[#1] INFO:ObjectHandling -- RooWorkspace::import(Dsmumu_workspace) importing RooRealVar::Ds1_M12_DTF_Ds_PV
Error in <Streamer>: Cannot stream interpreted class.
Error in <Streamer>: Cannot stream interpreted class.
Error in <Streamer>: Cannot stream interpreted class.
Error in <Streamer>: Cannot stream interpreted class.
.
.
.

Hi @fdeberna,

Could you attach here a full minimal reproducer of the issue? @jonas have you seen this before?

Cheers,
J.

Hi @jalopezg,
thank you for answering.

I am attaching the full minimal script where the RooWorkspace is built:
DsMuMu_TotalFit__FORUM.C (8.8 KB)

and I am attaching the .log file where all the full ROOT otput is shown:
ROOT_output.txt (21.4 KB)

Thank you a lot for any kind of help!

Hi @fdeberna, sorry for the late reply!

The problem is that you are using a custom class in your PDF that is not part of ROOT, this RooRelBreitWigner.h.

Now, you are running your script from the terminal like root DsMuMu_TotalFit__FORUM.C I guess. In this case, it interprets all the source code, including the code of the RooRealBreitWigner class. And unless you have compiled the RooRealBreitWigner also in some separate library, the ROOT interpreter will create some additional functions for the RooRealBreitWigner on the fly, expanding the ClassDef macro that you can probably see in RooRealBreitWigner.h.

The problem is that interpreted classes like this don’t support the saving and writing to ROOT files. You can see the same problem in this much simpler reproducer that doesn’t even use RooFit:

#include <TFile.h>
#include <TNamed.h>

class MyObject : public TNamed {
public:
    using TNamed::TNamed;

private:

    ClassDefOverride(MyObject, 1);
};

void repro()
{
    std::unique_ptr<TFile> file{TFile::Open("file.root", "RECREATE")};

    MyObject myObj("myObj", "myObj");

    myObj.Write();
}

You will get the Cannot stream interpreted class error again if you try to run this script with root repro.C.

One solution to your problem is to compile your script to a library before running this. Like that, it’s not executed by the interpreter and you get the full IO functionality for your custom classes. You can read more about this in the ROOT manual that has a section about compiling ROOT macros.

The summary of that page is: to compile your script before running it, all you need to do is to add a “+” to the command that executed the script. For example, root repro.C+ for the simple example in this post, or root DsMuMu_TotalFit__FORUM.C+ for your script.

I hope that works for you, and don’t hesitate to follow up with more questions if you have any!

Cheers,
Jonas

1 Like

Dear @jonas,
first of all, thank you so much for your help!!

To run my script I used to do the following steps
(I am sorry if I am unnecessary detailed):

  1. On LXPLUS I give the following command:
    . /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.06/x86_64-centos7-gcc48-opt/bin/thisroot.sh
    corresponding to the ROOT version I always use.
    then I open ROOT on LXPLUS doing: root -l

  2. root[] .L RooIpatia2.cxx

  3. root[] .L RooRelBreitWigner.cxx
    (this .cxx file and the previous one are in the same directory with the corresponding .h files. It is the same directory in which my script DsMuMu_TotalFit__FORUM.C is located)

  4. root[] .L DsMuMu_TotalFit__FORUM.C

  5. At the end I launch the “DsMuMu_TotalFit__FD()” function defined in my script:
    root[] DsMuMu_TotalFit__FD()
    and everything seems to be fine (except the errors from RooWorkspace)

After your suggestion, at first I added the following lines in my script to not have errors from ROOT:

 #include <TROOT.h>
 #include <TStyle.h>
 #include <TH1F.h>
 #include <TTree.h>
 #include "RooRealVar.h"
 #include "RooFitResult.h"
 #include <RooFFTConvPdf.h>
 #include "RooProduct.h"
 #include <RooAddition.h>
 #include "RooDataSet.h"
 #include "RooAddPdf.h"
 namespace RooStats {}

then, after the “…/thisroot.sh” setting shown before, I do the following steps:

  1. root[] .L RooIpatia2.cxx

  2. root[] .L RooRelBreitWigner.cxx

  3. root[] .L DsMuMu_TotalFit__FORUM.C+

but, at this point I see following error (the full message is attached)

collect2: error: ld returned 1 exit status

1_exit__status.txt (6.9 KB)

Considering my poor experience, what am I forgetting now?

Cheers,
Francesco

You’re almost there!

Just like with the final script, you got to compile the two .cxx files with the “+” option to create a shared library that your compiled script can be linked against.

Does it work then?

1 Like

Dear @jonas,

it works perfectly.
Thank you so much!

Francesco

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