Issues with RooPlot and a ttree built from a text file


I have been having some trouble using RooPlot to plot some data imported from a text file. I am using RooPlot because I need to fit the data. The code is:

RooRealVar Signal(“Signal Collection (mV)”, “Signal Collection (mV)”, -160, 40);

// Import .txt file into TTree
TCanvas* c4 = new TCanvas();
TTree *NoiseTree = new TTree("NoiseTree", "NoiseTree");
NoiseTree->ReadFile("<file path>/test33_DryIce.txt", "mV");
RooDataSet dh0("dh0","dh0",RooArgSet(Signal),Import(*NoiseTree));

RooPlot* frame0 = Signal.frame(Title("Signal and Noise"));
TH1F* NoiseHist = new TH1F("Signal And Noise", "Signal And Noise", 800, -160, 40);


When I use the “NoiseTree->Draw(“mV>>NoiseHist”)” option, I get exactly what the data should look like, as shown in ProperPlot.png; although the range is somewhat off what I would prefer. However, when I use the RooPlot function, “frame0->Draw()”, all the data is at zero except for one point at 20100 (the total number of events in the dataset) – RooPlotIssue.png.

I’ve followed along the tutorials, rf109 and rf401, and built my code based on those. The TTree used here is built from a text file, but it works fine with the “NoiseTree->Draw(“mV>>NoiseHist”)” setting. Unfortunately, since I need to make fits, I can’t use that. Can anyone tell me what I am doing wrong here?


might there be a mismatch between the name of your roorealvar and the name of the branch in the tree?
See for example Troubles with data in RooFit


The problem is, there isn’t a branch. The TTree is being constructed straight from a text file:

And NoiseTree is being used correctly, as far as I can tell. Should I shove the data into a branch first?