Please read tips for efficient and successful posting and posting code
ROOT Version: 6.18
Platform: Not Provided
I am trying to convert my root file to ascii but when I do that I get a straight line i.e. my program produces an ascii file that is a straight line, however, my root file is an exponential decay. Please let me how I can fix this to get an ascii with an exponential decayascii1.C (559 Bytes) decay_600ns.root (12.0 KB)
Your file contains a TCanvas:
root  f1->ls()
KEY: TCanvas Time_distr;1
and you try to it it in a TH1S …
TH1S *hGam = (TH1S*) f1->Get(name);
The TCanvas is the output. So I was trying to ocnvert a root file to ascii that way, I don’t know if there’s a better way.
A TCanvas is not a TH1S. Have a look in the list of primitives of the canvas if you have a TH1S. You can do
I had a look and its not on the list of primitives. The list is attached. I suppose then that the way I am converting is not right?
As you can see you have an histogram in that canvas. It is called
cube2_zx_py. You can do:
TCanvas *C = (TCanvas*) f1->Get(name);
TH1D h = (TH1D*)C->GetListOfPrimitives()->FindObject("cube2_zx_py");
I have just tried doing this several times and it does not work. Also Iam just a beginner in root and some things are not so trivial to me.
To help you further we will need your root file.
Ok it is attached.
decay_600ns.root (12.0 KB)
root  auto f = new TFile("decay_600ns.root");
root  auto C = (TCanvas*) f->Get("Time_distr");
root  auto h = (TH1D*)C->GetListOfPrimitives()->FindObject("cube_2_zx_py");
root  h->Print()
TH1.Print Name = cube_2_zx_py, Entries= 3353172, Total sum= 3.27269e+06
Ok thanks. Where is the ascii generated here?
root  .> ascii.dat
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.