I am new using ROOT and we are trying to create a histogram but the output file I want to create (“gaus.root”) is not being created and I can’t figure out why. Help me please.
Here it is the core we are using:
#include<TH1.h>
#include<TFile.h>
#include<TRandom.h>
int main(){
TH1F *h = new TH1F(“hgaus”, “A Gauss Function”, 100,-5.0,5.0);
TRandom rnd;
for (int i=0; i<10000; ++i){
double x= rnd.Gaus(1.5,1.0);
h->Fill(x);
}
TFile *myfile= new TFile(“gaus.root”,“new”);
myfile->Write();
myfile->Close();
return 0;
}
Hi!
Thank you for your quick answer.
We changed the code as you suggested to us, but I still does not create the gaus.root file. Is there any other thing we could do to fix it? any package that we could try? thanks in advance. Here it is the updated code:
This is how I run it in the terminal and the not found error that appears. Is it possible that the error is due to we are not specifying in the script where we want to save the file?