Yes, unfortunately, I don’t have the errors. I am really interested in the widths of the histogram. I have tried different methods, but somehow it’s not working correctly I would say :
METHOD I
{
TTree *tree = new TTree(“tree”,“tree”);
tree->ReadFile(“yield176_40.txt”,“bin:value”);
float bin, value;
tree->SetBranchAddress(“bin”, &bin);
tree->SetBranchAddress(“value”, &value);
//Get the bin edges and values out of the tree
std::vector binEdges, values;
for (int i = 0; i < tree->GetEntries(); i++) {
tree->GetEntry(i);
binEdges.push_back(bin);
values.push_back(value);
}
tree->ResetBranchAddresses();
auto hist = new TH1F(“hist”, “”, binEdges.size() - 1, binEdges.data());
//Fill the histogram
for (int i = 0; i < values.size(); i++) {
hist->SetBinContent(binEdges.at(i), values.at(i));
hist->GetXaxis()->SetRangeUser(0,200);
}
hist->Draw("");
}
Here somehow the plot is truncated :
METHOD II
TTree *MyTree = new TTree(“MyTree”, “MyTree”);
MyTree->ReadFile(“yield176_40.txt”, “Mass/D:Yield/D”);
MyTree->SetEstimate(-1);
MyTree->Draw(“Mass”, “Yield”, “C”);
//gStyle->SetOptStat(111111);
}
And I get the output which is very weird.
METHOD III
Also tried plotting 2D histogram
{
TTree *MyTree = new TTree(“MyTree”, “MyTree”);
MyTree->ReadFile(“yield176_40.txt”, “MD:Counts”);
MyTree->SetEstimate(MyTree->GetEntries()); // not strictly necessary
TH2F *MyHisto = new TH2F(“MyHisto”, “;MD;Counts”, 100, MyTree->GetMinimum(“MD”) - 1, MyTree->GetMaximum(“MD”) + 1, 100, MyTree->GetMinimum(“Counts”) - 1, MyTree->GetMaximum(“Counts”) + 1);
MyTree->Project(“MyHisto”, “Counts:MD”);
MyHisto->Draw("*");
}
and I get the following output where the widths of the mass distribution shown is not correct
What I want to do is plot a 1D histogram and get the standard deviation of my mass distribution. But different methods give different widths. So what is the correct and reliable way to do this