Hi, I want to read an histogram inside a folder of a root file and save it in a new root file with a short name. The path of the histogram is
IDAR_3alpha.root/Analysis;1/Histograms;1/FPGA;1/FPGA Energy(hitlist) SFP: 1 FEBEX: 0 CHAN: 8;1
But the new histogram do not create, because the reading of the original histogram do not take place.
Any help please. Thanks
void New(const TString& inputfile="", const TString& outputfile="NewCal.root")
{
const TString& filename="Analysis;1/Histograms;1/FPGA;1/FPGA\ Energy(hitlist)\ SFP:\ 1\ FEBEX:\ 0\ CHAN:\ 0;1";
TFile *finput = new TFile(inputfile.Data(),"read");
TFile *output = new TFile(outputfile.Data(),"recreate");
TH1F *h = (TH1F*)finput->Get(filename.Data());
output->cd();
h->Draw();
h->Write();
finput->Close();
output->Close();
delete finput;
delete output;
}
couet
2
Do you get some messages when you execute your macro ?
pcanal
3
you might need
const TString& filename="Analysis;1/Histograms;1/FPGA;1/FPGA\ Energy(hitlist)\ SFP:\ 1\ FEBEX:\ 0\ CHAN:\ 0;1";
TFile *finput = new TFile(inputfile.Data(),"read");
TFolder *folder = finput->Get("Analysis");
TH1F *h = folder->FindObject("Histograms/FPGA/FPGA\ Energy(hitlist)\ SFP:\ 1\ FEBEX:\ 0\ CHAN:\ 0");
or
const TString& filename="Analysis;1/Histograms;1/FPGA;1/FPGA\ Energy(hitlist)\ SFP:\ 1\ FEBEX:\ 0\ CHAN:\ 0;1";
TFile *finput = new TFile(inputfile.Data(),"read");
gDirectory->cd("Analysis/Histograms/FPGA");
TH1F *h = gDirectory->Get("FPGA\ Energy(hitlist)\ SFP:\ 1\ FEBEX:\ 0\ CHAN:\ 0");
Alternatively those that provided/created this file may have a set of instructions on how to retrieve the data.
Thanks, the second option solve my problem.
Nice regards.
system
Closed
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.