Hi,

I have two different datasets in two root files. I want to plot one variable mass for both the data sets in one frame in roofit . Like drawing two histograms in one canvas from two different rootfiles by normalizing them.

But When I am plotting in one frame its giving segmentation violation.

The trial code is here , Any suggestion is most welcome.

regards,

debashis

```
void normalized_roofit() {
using namespace RooFit;
RooRealVar x("x", "x",3,3.2);
RooDataSet* data = new RooDataSet("data", "data",RooArgSet(x));
// fit variable
Float_t jpsimass,jpsif;
// Read data file
TFile* input=new TFile("charm_stream0.root");
TTree* t1 = (TTree*) input->Get("h1");
// no of entries in the datafile
Int_t n_tot = (int)t1->GetEntries();
cout << " n_tot = " << n_tot << endl;
t1->SetBranchAddress("jpsimass",&jpsimass);
t1->SetBranchAddress("jpsif",&jpsif);
// Import the data points
for(int i=0; i<n_tot; i++) {
t1->GetEntry(i);
if(jpsif ==1){
if(jpsimass >=2.9 && jpsimass <=3.3) {
x.setVal(jpsimass);
data->add(RooArgSet(x));
// if its double than I can fill in histogram
}
}
}
RooPlot *myframe =x.frame(100);//100 is number of bins.
RooRealVar x2("x2", "x2",3,3.2);
RooDataSet* data2 = new RooDataSet("data2", "data2",RooArgSet(x2));
// fit variable
Float_t jpsimass2,jpsif2;
// Read data file
TFile* input2=new TFile("charged_stream0.root");
TTree* t2 = (TTree*) input2->Get("h1");
// no of entries in the datafile
Int_t n_tot2 = (int)t2->GetEntries();
cout << " n_tot2 = " << n_tot2 << endl;
t2->SetBranchAddress("jpsimass",&jpsimass2);
t2->SetBranchAddress("jpsif",&jpsif2);
// Import the data points
for(int i=0; i<n_tot2; i++) {
t2->GetEntry(i);
if(jpsif2 ==1){
if(jpsimass2 >=2.9 && jpsimass2 <=3.3) {
x2.setVal(jpsimass2);
data2->add(RooArgSet(x2));
}
}
}
RooPlot *myframe2 =x2.frame(100);
//data->plotOn(myframe2);
data2->plotOn(myframe2);
myframe2->Draw();
}
```