Greetings:

I am trying to set a range for a simultaneous combined histogram fit in RooFit. There are two separate things that look like they should work based on the documentation I have read, but they aren’t working. I will try to explain this in steps for a simplified test I am running.

What does work is the simultaneous fit without a range:

I have defined pdfs using my own generated pdf (mypolypdf) and generated histograms according to quadratic, cubic, and quartic polynomials:

Note that “<” and “>” don’t appear when I post this for the RooFit Result and std::map lines below.

```
//Histograms:
RooRealVar *myvar = new RooRealVar("myvar", "myvar",-range, range);
RooDataHist *myroohistquad = new RooDataHist ("myroohistquad","myroohistquad",*myvar,Import(*myhistquad));
RooDataHist *myroohistcubic = new RooDataHist ("myroohistcubic","myroohistcubic",*myvar,Import(*myhistcubic));
RooDataHist *myroohistquartic = new RooDataHist ("myroohistquartic","myroohistquartic",*myvar,Import(*myhistquartic));
//Categories:
RooCategory polytype("polytype","polytype");
polytype.defineType("quadratic");
polytype.defineType("cubic");
polytype.defineType("quartic");
//Combined histogram
std::map <std::string,RooDataHist*> histset;
histset["quadratic"] = myroohistquad;
histset["cubic"] = myroohistcubic;
histset["quartic"] = myroohistquartic;
RooDataHist CombPolyHist ("CombPolyHist", "CombPolyHist", *myvar, Index(polytype),Import(histset));
//pdfs:
mypolypdf mypdfrooquad("mypdfrooquad","mypolypdf",*myvar,*p1roo,*p2roo,*p3rooquad,*p4rooquad);
mypolypdf mypdfroocubic("mypdfroocubic","mypolypdf",*myvar,*p1roo,*p2roo,*p3roocubic,*p4roocubic);
mypolypdf mypdfrooquartic("mypdfrooquartic","mypolypdf",*myvar,*p1roo,*p2roo,*p3rooquartic,*p4rooquartic);
RooSimultaneous polysimulpdf("polysimulpdf", "polysimulpdf", polytype);
polysimulpdf.addPdf(mypdfrooquad,"quadratic");
polysimulpdf.addPdf(mypdfroocubic,"cubic");
polysimulpdf.addPdf(mypdfrooquartic,"quartic");
//Fit:
std::unique_ptr<RooFitResult> fitResult{polysimulpdf.fitTo(CombPolyHist, PrintLevel(-1), Save())};
```

This works fine.

Test 1: Make each histogram a function of a different variable:

Replaced histogram definitions above with:

```
RooRealVar *myvarquad = new RooRealVar("myvarquad", "myvarquad",-range, range);
RooRealVar *myvarcubic = new RooRealVar("myvarcubic", "myvarcubic",-range, range);
RooRealVar *myvarquartic = new RooRealVar("myvarquartic", "myvarquartic",-range, range);
RooDataHist *myroohistquad = new RooDataHist ("myroohistquad","myroohistquad",*myvarquad,Import(*myhistquad));
RooDataHist *myroohistcubic = new RooDataHist ("myroohistcubic","myroohistcubic",*myvarcubic,Import(*myhistcubic));
RooDataHist *myroohistquartic = new RooDataHist ("myroohistquartic","myroohistquartic",*myvarquartic,Import(*myhistquartic));
RooDataHist CombPolyHist ("CombPolyHist", "CombPolyHist", RooArgSet(*myvarcubic,*myvarquad,*myvarquartic), Index(polytype),Import(histset));
```

Trying this gives the following error:

```
[#0] ERROR:InputArguments -- Layout or binning of histogram myroohistquad is not consistent with first processed histogram myroohistcubic
Error in <TRint::HandleTermInput()>: std::invalid_argument caught: Layout or binning of inputs for RooDataHist is inconsistent
```

Test 2:

Keep the same variable for all histograms, and set the range on that variable:

Keep the original code but replace the fitTo with the following:

```
myvar->setRange("highrange_quadratic",0.0,10.0);
myvar->setRange("highrange_cubic",0.0,10.0);
myvar->setRange("highrange_quartic",0.0,10.0);
std::unique_ptr<RooFitResult> fitResult{polysimulpdf.fitTo(CombPolyHist, Range("highrange"), SplitRange(kTRUE), Save(), PrintLevel(-1))};
```

This results in very strange fits over a range of the full histogram for the last histogram (quartic) and with a strange function plotted also outside the histogram (values of x coordinate below that in the plot) for teh other two.

I am using ROOT 6.30/04

Do you have any suggestions on how to fix these?

Thanks very much!