hi,
i have a class with a RooPlot* data member, a getter function returning that plot and a method fitting some mass peak:
class MyClass{
...
virtual void FitMassPeak(TH1D& myHisto);
virtual RooPlot* GetPlot() {return myPlot;}
private:
RooPlot* myPlot;
...
}
in the method FitMassPeak i create a temporary RooDatahist object from the TH1D and plot it after fitting:
void FitMassPeak(TH1D& myHisto) {
RooDataHist myData("histName",...,&myHisto);
//fit myData
...
//plot myData on myPlot
myData.plotOn(myPlot, ...);
...
}
my question is now: what happens to the RooDataHist “myData”? it’s a temporary object, so it should be deleted after the funtion call. are the points then still stored in myPlot? cause if i say, e.g. in another class,
MyClass classy;
classy.GetPlot().Draw();
it works fine, everyhting i plotted on the RooPlot is there. but if i try out
MyClass classy;
classy.GetPlot().getAttMarker("histName")->SetMarkerColor(kGreen + 4);
classy.GetPlot().Draw();
i get a segmentation fault.
if i would get a segm fault even with classy.GetPlot().Draw();
i would understand, because then i would assume that the RooDataHist is just not there. but how can it be that i draw the RooPlot but can’t access the data markers?
hope this wasn’t too confusing. thanks for any help,
axel.
ps: just in case someone wants to ask: i made sure that i call getAttMarker(char* name) with the correct name.