RooDataSet: change fitRange

Hi all,

I have a situation I don’t know how to solve: I have a mass variable in a RooDataSet, let’s say Mass, which is defined between 100 and 200. I want to recalibrate that mass to create Mass_Calib using some complex formula, and I add this into the dataset.
In order to avoid border effects, however, I need to define the RooRealVar I use for the Mass_Calib between 50 and 250. It is clear, however, that when I want to fit my data I only want to use the 100, 200 range.

Later on I define on a workspace my pdf, and I restrict the observable of my model to the 100-200 range. If I plot this variable, it is fine, but the fit is taking into account the full range (50,250), and not the one defined in the observable of my pdf.

I thought the RooDataSet did not have any “memory”, but it’s clearly doing something I didn’t expect.

Any hints on how to perform this recalibration?

Thanks,
Albert

Hi Albert-

I’m not certain that I 100% understand what you need but would it be worthwhile creating a “reduced” dataset that only contains the mass_calib values in the required range (100-200) before trying to fit?

I think I do something similar to you. I work on D(s)->KS0H (H=pi/K) decays at LHCb and need to fit e.g. the D(s)->KS0pi candidate mass distribution. This distribution is contaminated with D(s)->KS0K cross-feed. To get a handle on this cross-feed contribution I take the D(s)->KS0K mass distribution and recalculate the mass of a D(s) candidate if the pion is actually a kaon i.e. I calculate a mass_calib variable - but I only want to fit the mass_calib distribution in the required range…much like you seem to.

I’d suggest (and I’m new to RooFit and this may be a bad/non-elegant solution) that you calculate mass_calib, add the column to the dataset, then reduce the dataset using a cut on mass_calib before fitting. I use the following code:

// Define a RooDataSet called "Data"...

// Recalculate mother mass and add it to Data - 
RooFormulaVar Mother_mass("Mother_mass", "sqrt(Mother_mass_squared)"
,RooArgSet(Mother_mass_squared)) ;  
RooRealVar* Mother_mass_var = (RooRealVar*) Data.addColumn(Mother_mass);

// Reduce the dataset with a cut 
 RooDataSet * Data_new = new RooDataSet("Data_new","Data_new", (observables,*Mother_mass_var));
 Data_new = (RooDataSet*)Data.reduce("sqrt(Mother_mass_squared)>1700");

Data_new is now a dataset that only contains Mother_mass values > 1700

Hope that is helpful…Merry Xmas

p.s. In return could you tell me about how a “workspace” operates/what it is? Can I store a dataset there and load it? It takes me ages to create a dataset from an ntuple each time I run my code at the moment :confused: