_ERICA
April 11, 2020, 8:17am
1
I got root file from geant4 so I could see histograms but I want to see the data about the histogram.
Could you please help me to export the data as a .txt or something to be able to analyse it in other programs?
TFile file = new TFile(“whitebeam.root”, “read”); TH1D h1 = (TH1D*) file -> Get(“1”); h1 -> Print(“all”); > aaa.txt
I’ve tried and tried to follow so many similar things like that, but couldn’t get any.
Please help me to get it.
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
What you try to use works with ROOT 5 only.
With ROOT 6, you need to replace “> aaa.txt” with:
root [...] .> aaa.txt
root [...] h1->Print("all");
root [...] .>
_ERICA
April 13, 2020, 12:56am
3
I tried it but It said “error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.”.
Could you tell me what I should do to solve this problem?
Are you sure the histogram name in the file is “1”? Check with
.ls
or
f->ls()
after opening the file.
_ERICA
April 13, 2020, 10:14am
5
[class] [name];[cycle number]
so it name is histo??
_ERICA
April 13, 2020, 10:16am
6
it’s also the same root file. but the name looks different.
try
TH1D *h1 = (TH1D*) file -> Get("histo/h1");
_ERICA
April 13, 2020, 10:26am
9
But the .txt file looks like this…
_ERICA
April 13, 2020, 10:44am
11
I did it, but I got an error message… Did I something wrong??
TH1D *h1; file->GetObject("histo/h1.1", h1);
system
Closed
April 27, 2020, 12:02pm
14
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.