Hello co-rooters!
I would like to divide to histograms that don’t have the same binning(an experimental and an evaluated one)
To do that, I take the evaluated one, which in principle has a finer binning, in ascii format, convert it to a root file and then rebin it in a coarser binning.
My code that converts the ascii file to root file is the following
[code]{
gROOT->Reset();
TFile *f = new TFile(“refXS_tot.root”,“NEW”);
//~~~~~~~~~~~~~~~~~~~~~ 235U ~~~~~~~~~~~~~~~~~~~~~~//
TTree *TU = new TTree("U235_ENDFtot","data from ascii file");
Long64_t nlines = TU->ReadFile("U5_cross_section_eV.txt","E:XS");
printf("Found %lld points\n",nlines);
TU->Write();
int n = TU->Draw("E:XS");
TGraph *g = new TGraph(nlines,TU->GetV1(),TU->GetV2());
g->Draw("apl");
f->Close();
}[/code]
The code that reads the previously created root file and “tries” to plot a rebinned version of it is the following
[code]{
TFile *MyFile = new TFile("refXS_tot.root","READ");//Open the root file
if ( MyFile->IsOpen() ) printf("File opened successfully\n");//Check if file is opened
TTree *XSTree = (TTree*)MyFile.Get("U235_ENDFtot");//Get the XS tree
//Define the branches
Float_t E;
Float_t XS;
XSTree->SetBranchAddress("E",&E);
XSTree->SetBranchAddress("XS",&XS);
// Get number of entries
Int_t entries = XSTree->GetEntries();
printf(" Number of entries: %d\n",entries);
// Create neutron energy binning - same as the experimental yield
Int_t N_BPDEC = 2000;// bins per decade
Int_t E_MIN = -3;// lower energy limit (log10)
Int_t E_MAX = 8;// upper energy limit (log10)
Int_t ndec = E_MAX - E_MIN;//total energy range (log 10)
Int_t nbins = (Int_t) ndec*N_BPDEC;//total numer of bins
Double_t ebins[nbins+1];
Double_t step = (Double_t) ndec / nbins;
for(Int_t i=0; i <= nbins; i++) {
ebins[i] = (float) pow(10., step * (Double_t) i + E_MIN);
}
//X-Section Histogram
TH1F *hXSU5 = new TH1F("hXSU5","^{235}U Evaluated Cross Section - Rebinned; Neutron energy (eV); Cross Section (barns)",nbins,ebins);
hXSU5->Sumw2();
for (int i=0; i<=entries; i++){//Fill the histogram
hXSU5->Fill(E,XS);
}
hXSU5->Draw();
}[/code]
The problem is that although both codes run without any error whatsoever, the printed histogram that I get is empty, despite having the correct number of entries.
Any idea on why I can’t draw the histogram?
Thank you very much in advance!