Skip to content
Snippets Groups Projects
Commit 2aca96d0 authored by Jure Bericic's avatar Jure Bericic
Browse files

Added a root file output when pdf is produced.

Fixed kpp online script to work with root6.
parent a7180abb
No related branches found
No related tags found
No related merge requests found
......@@ -649,19 +649,19 @@ void UserScript() {
} // UserScript function
void kpp_analysis(TString histname) {
cout << histname << endl;
// Grab the histo
TH1F *h1d;
TH2F *h2d;
h1d = dynamic_cast <TH1F*> gDirectory->Get(histname);
h2d = dynamic_cast <TH2F*> gDirectory->Get(histname);
h1d = dynamic_cast <TH1F*> (gDirectory->Get(histname));
h2d = dynamic_cast <TH2F*> (gDirectory->Get(histname));
// Grab histo directly if it does not already exist
if(!h1d && !h2d) {
UserScript();
h1d = (TH1F*) gDirectory->Get(histname);
h2d = (TH2F*) gDirectory->Get(histname);
h1d = (TH1F*) (gDirectory->Get(histname));
h2d = (TH2F*) (gDirectory->Get(histname));
// Throw error
if(!h1d || !h2d) {
cout << "User histogram " << histname << " not found" << endl;
......
......@@ -1886,7 +1886,40 @@ void OnlineGUI::PrintPages() {
}
if(!useJPG) fCanvas->Print(filename+"]");
//
TFile *hroot = new TFile(filename+"_hist.root","recreate");
cout << "Writing histograms to root file '" << filename << "'." << endl;
filename.Resize(filename.Last('.'));
filename += ".root";
TFile* hroot = new TFile(filename,"recreate");
UInt_t pageCount = fConfig->GetPageCount();
for (UInt_t iPage=0; iPage<pageCount; ++iPage) {
UInt_t drawCount = fConfig->GetDrawCount(iPage);
for (UInt_t iDraw=0; iDraw<drawCount; ++iDraw) {
TString macro = fConfig->GetDrawCommand(iPage, iDraw).macro;
if (macro != "") {
TString histName = macro.Remove(0, macro.First('\"')+1);
histName.Resize(macro.First('\"'));
fRootFile.RootFile->cd();
TH1F* h1f = dynamic_cast<TH1F*>(gDirectory->Get(histName));
TH2F* h2f = dynamic_cast<TH2F*>(gDirectory->Get(histName));
hroot->cd();
if (h1f) h1f->Write();
else if (h2f) h2f->Write();
else cout << histName << " not found!" << endl;
}
}
}
hroot->Write();
hroot->Close();
delete hroot;
cout << "Root file '" << filename << "' done." << endl;
//
#ifdef STANDALONE
gApplication->Terminate();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment