TClonesArray && RooDataSet

Dear Support,

I am running into a weird thing during compilation, please find below a minimum file reproducing the problem.

#include "TROOT.h"
#include <TSystem.h>
#include <TClonesArray.h>
#include "RooRealVar.h"
#include "RooDataSet.h"

using namespace std;
using namespace RooFit;

int main()
{
  TClonesArray pof("RooRealVar", 10);
  new (pof[0]) RooRealVar();

  TClonesArray paf("RooDataSet", 10);
  new (paf[0]) RooDataSet();

}

I am under OS X 10.8.2, and load root using

export ROOTSYS=/afs/cern.ch/sw/lcg/app/releases/ROOT/5.34.05_python2.7/x86_64-mac106-gcc42-opt/root
source ${ROOTSYS}/bin/thisroot.sh

While trying to compile I obtain the following

g++ -Wall -g `root-config --cflags` -c test.C -o test.o
test.C: In function ‘int main()’:
test.C:16: error: no matching function for call to ‘RooDataSet::operator new(long unsigned int, TObject*&)’
/afs/cern.ch/sw/lcg/app/releases/ROOT/5.34.05_python2.7/x86_64-mac106-gcc42-opt/root/include/RooDataSet.h:33: note: candidates are: static void* RooDataSet::operator new(size_t)

am I forgetting something ? It seems weird to me that the crash happens for RooDataSet but not RooRealVar, which anyway both derive from TObject…

I also want to say that the code compiles fine if I use 5.27.06 instead of 5.34.05_python2.7… But I did not try other releases.

Any idea is welcome !

Thanks in advance,
Olivier

Dear support,

is there any checks/tries I can do ? Any idea about how to move on would be quite welcome…

Thanks,
Olivier

Hi Olivier,

(Due to allocation rules), RooRealVar objects can not be stored in a TClonesArray. Use a TList of TObjArray instead.

Cheers,
Philippe.

Hello,
could you please put an example how to make it?

I know how to make RooRealVar mean0( ..... ); … etc
But I need an array like RooRealVar mean[10]; - I cannot make it still in root 5.34
Is there a possible solution to it with

TObjArray mean( 10); new (mean[0]) RooRealVar(name, name, pk[i],min,max); ... RooCBShape cb[0]("cb0","CBShape(x,mean,sigma)", x,*mean[0],*sigm[0],*nalph[0],n1); ? ....
mean,cb,sigm,nalph being kind of arrays of RooRealVar and Pdf ?
Thank you
Jaromir