Storing multiple RooFFTConvPdf into RooArgList to be used in RooAddPdf

Overview/Goal
I have a few individual PDFs which I want to convolve with a Gaussian. I then want to create combined model of those PDFs to fit to some data using extended maximum likelihood. This is an extension of the topic discussed here (Simultaneous 1D likelihood fits in different observables, with multiple PDFs). @StephanH I hope it is alright I tag you here, since you helped me in the previous post and so more familiar with the overall context in which I am doing this.

What I have done
I attached a minimal working code of what I am about to describe. test.cpp (2.5 KB)
To test things out, what I have done was to create three RooGaussians: g1, g2 (the test PDFs) and gconv (the Gaussian to smear/convolve g1 and g2). I store g1 and g2 in a vector. I then loop through this vector, convolving g1 and g2 with gconv, in turn. I then store the convolved Gaussians in a RooArgList in order to pass to RooAddPdf later.

The problem, and what I have tried
After convolving the Gaussians and putting them into RooArgList, the convolved objects doesn’t seem to be in the RooArgList. I thought that maybe the convolved Gaussians need to have different names but that didn’t work after I implemented a simple renaming scheme (still present in the code). I then thought maybe the RooFFTConvPdf objects get deleted once outside the loop. I am not sure if it is a valid check but I created a standard vector for RooFFTConvPdf objects and push_back my convolutions to that vector. When I checked the vector size, it gave me the expected number. The final thought I had is that RooFFTConvPdf somehow does not inherit from RooAbsArg, which is what RooArgList expects. I am a still bit unsure about inheritance so I am not sure how valid this thought it. Any help on how to proceed or pointing out anything I misunderstood/mistakes is greatly appreciated!

@StephanH can probably help you out!

Hi @ilam,

the problem is here:

 RooArgList convlist;
 for (...) {
    RooFFTConvPdf temp(...);
    convlist.add(temp);
 }

This adds a pointer to temp to the arg list. When the loop cycles to the next iteration, the original is destroyed. You should allocate the PDF on the heap, and tell the collection that it owns the pointer:

RooArgList list;
auto pdf = new FFTConvPdf(...);
list.addOwned(*pdf);

Now, list retains the pointer, and knows that it owns the objects.

Hi @StephanH ,

Yes! That worked! Thank you!

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