# Plot on Y, projecting on Z, and on a subset of X ! How to

Dear Experts,
I have the piece of code:
.
.
.
x->setRange(“lowSideband”,5.0,514);
myString.clear(); myString.str("");
myString << “B0MassArb < 5.14 && B0MassArb > 5.0”;
cout << "Cut for B0 low sideband: " << myString.str().c_str() << endl;
lowSidebandDataSet = (RooDataSet*)dataSet->reduce(myString.str().c_str());

``````  // #####################################################
// # Define whole-range in the full-projected variable #
// #####################################################
y->setRange("wholeRangeY",y->getMin(),y->getMax());
z->setRange("wholeRangeZ",z->getMin(),z->getMax());

// ##############
// # Y-variable #
// ##############

// ###########################
// # Background plot results #
// ###########################
Canv->cd(4);
RooPlot* myFrameLowSideBY = y->frame(NBINS);
lowSidebandDataSet->plotOn(myFrameLowSideBY,Name(MakeName(dataSet,ID).c_str()));
(*TotalPDF)->plotOn(myFrameLowSideBY,Name((*TotalPDF)->getPlotLabel()),LineColor(kBlack),ProjWData(*lowSidebandDataSet));
``````

.
.
.
Basically I would like to plot versus Y, integrating on a sub range of X, and on a full range of Z
I would like to plot both the datapoint and the pdf
I found the afore mentioned code, which seems to be working ok, but the ProjWData is pretty slow.
Is there another way to do the same thing ?
For example with ProjectRange ? and CutRange ?
I’ve tried those but they do not seem to work as expected
If you an alternative code with respect to what I posted here,
can you please try to modify this code in order to show me how you would have done it ?

Many thanks.

• Mauro.