Hi Experts,
i am trying to create histograms using below files but i am unable to do that.
can anyone please point me out that where i am doing wrong and also i am unable to open that root file why ?
LoadPlotNtuple.C (1.8 KB)
radioprotection.root (32.9 KB)
any type of help will be appreciated
Thanks in advance!
Regards
Priyanshu
For starters, your code tries to open “radioprotection_NEW.root” but the file is named “radioprotection.root”. Correcting that, I get one plot, of ntuple1, which seems correct. The other 2 ntuples are empty in the file, so maybe the problems start from the creation of that file.
but when i do same change and run those files it gives me so many errors, can you please share how you compile this file ?
I don’t compile it, I just do .x yourmacrofile.C
try:
{
auto f = new TFile("radioprotection.root");
TNtuple * ntuple1 = (TNtuple*)f->Get("radioprotection_ntuple/101");
TNtuple * ntuple2 = (TNtuple*)f->Get("radioprotection_ntuple/102");
TNtuple * ntuple3 = (TNtuple*)f->Get("radioprotection_ntuple/103");
int numberOfBinsX = 500;
int numberOfBinsY = 500;
int numberOfBinsZ = 500;
int Xmin = 0;
int Xmax = 1000;
int Ymin = 0;
int Ymax = 1000;
int Zmin = 0;
int Zmax = 1000;
//the type of histogram, how many variable, min and max values plus size of bins
auto h0 = new TH1F("h0", "Primary Particle Energy Spectrum; Energy (Mev);Frequency",
numberOfBinsX, Xmin, Xmax); //Edep // binning, xmin, xmax, along x direction
//the type of histogram, how many variable, min and max values plus size of bins
auto h1 = new TH1F("h1", "Energy deposition; Edep (kev);Frequency",
numberOfBinsX, Xmin, Xmax); //Edep // binning, xmin, xmax, along x direction
auto c = new TCanvas();
c->Divide(2,1);
c->cd(1); ntuple1->Draw("Ek>>h0","","");
c->cd(2); ntuple2->Draw("edep>>h1", "", "");
}
it gives:
Note that h2 is empty … you need to check why.
okay. thank you, i will check it.
BTW when i open this .root file in text editor it looks something weird. i can’t see the values. why it is so ?
It is a binary file. No way you can see anything in a text editor. It is not a text file as Wikipedia says.
okay. Thank you for the reply.
Hi @priyanshu-gif ,
you can use rootbrowse
to check out the contents of a ROOT file, it’s a program that should be included in your ROOT installation. You can just call rootbrowse yourfile.root
and it should open a “TBrowser” window, ROOT’s graphical file browser.
Cheers,
Enrico
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.