Dear all,
I want to create a histogram from a txt.file. The first 6 columns are the bin boundaries for the 3 parameter m, pt and y. The 7th column is the yield and the 8th one is the uncertainty. I have created a function to read the lines of this textfile.
void DecodeLine(std::string line, double &m_low, double &m_high, double &y_low, double &y_high, double pt_low, double pt_high, double yield, double uncert){
TString rs(line.c_str());
printf("rs: %s\n", rs.Data());
TObjArray *toks = rs.Tokenize(" ");
if(toks->GetEntries()!=9) return;
m_low = ((TObjString *)toks->At(0))->String().Atof();
m_high = ((TObjString *)toks->At(1))->String().Atof();
y_low = ((TObjString *)toks->At(2))->String().Atof();
y_high = ((TObjString *)toks->At(3))->String().Atof();
pt_low = ((TObjString *)toks->At(4))->String().Atof();
pt_high = ((TObjString *)toks->At(5))->String().Atof();
yield = ((TObjString *)toks->At(6))->String().Atof();
uncert = ((TObjString *)toks->At(7))->String().Atof();
printf("m_low %f, m_low %f, y_low %f, y_high %f, pt_low %f, pt_high %f, yield %f, uncert %f", m_low, m_high, y_low, y_high, pt_low, pt_high, yield, uncert);
}
In my main function , I did this
ifstream in("results_DYPbPb_eppspdf_noresumbutkt_ptbins_mu1.txt");
std::string str;
double m_low, m_high, pt_low, pt_high, y_low, y_high, yield, uncert;
while(getline(in,str)){
if(str.find("#") < str.length()) continue; // Line commented out
if(str.length() == 0) continue;
DecodeLine(str, m_low, m_high, pt_low, pt_high, y_low, y_high, yield, uncert);
if(y_low > 6) continue;
Im not sure how to create a histogram with these bin boundaries. At the end I want a TH2D histogram with m as X, pt as Y, the yield as dN/dm and the uncertainty.
I have attached the textfile.
Thanks
results_DYPbPb_eppspdf_noresumbutkt_ptbins_mu1.txt (607.7 KB)