From 2aca96d0e44baff62d691e2e8cb7cb52b13213ce Mon Sep 17 00:00:00 2001 From: Jure Bericic <jure.bericic@gmail.com> Date: Mon, 6 Mar 2017 09:44:10 -0500 Subject: [PATCH] Added a root file output when pdf is produced. Fixed kpp online script to work with root6. --- onlineGUI/Macros/kpp_analysis.C | 78 ++++----- onlineGUI/onlineGUI_v1.2.1/online.C | 239 ++++++++++++++++------------ 2 files changed, 175 insertions(+), 142 deletions(-) diff --git a/onlineGUI/Macros/kpp_analysis.C b/onlineGUI/Macros/kpp_analysis.C index ed68b4ee..0312458d 100644 --- a/onlineGUI/Macros/kpp_analysis.C +++ b/onlineGUI/Macros/kpp_analysis.C @@ -19,7 +19,7 @@ void UserScript() { static const UInt_t nngc_pmts = 4; static const UInt_t npos_aero_pmts = 7; - static const UInt_t nneg_aero_pmts = 7; + static const UInt_t nneg_aero_pmts = 7; static const UInt_t maxTdcHits = 128; static const UInt_t maxAdcHits = 4; @@ -70,7 +70,7 @@ void UserScript() { Double_t p2X_goodNegTdcTimeCorr[maxTdcHits*nbars_2x], p2Y_goodNegTdcTimeCorr[maxTdcHits*nbars_2y]; Double_t p1X_goodPosTdcTimeCorr[maxTdcHits*nbars_1x], p1Y_goodPosTdcTimeCorr[maxTdcHits*nbars_1y]; Double_t p2X_goodPosTdcTimeCorr[maxTdcHits*nbars_2x], p2Y_goodPosTdcTimeCorr[maxTdcHits*nbars_2y]; - + // Hodoscope focal plane times Double_t p1X_fpTime, p1Y_fpTime, p2X_fpTime, p2Y_fpTime; Double_t p1X_plTime, p1Y_plTime, p2X_plTime, p2Y_plTime; @@ -96,7 +96,7 @@ void UserScript() { Int_t phgc_hits; Double_t phgc_pmt[maxAdcHits*nhgc_pmts], phgc_pulseTime[maxAdcHits*nhgc_pmts]; Double_t phgc_pulseInt[maxAdcHits*nhgc_pmts]; - + // Noble gas Cherenkov ADC Int_t pngc_hits; Double_t pngc_pmt[maxAdcHits*nngc_pmts], pngc_pulseTime[maxAdcHits*nngc_pmts]; @@ -104,7 +104,7 @@ void UserScript() { // Tracking information Double_t trk_pmag; - + Long64_t nentries; // =:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: @@ -143,7 +143,7 @@ void UserScript() { TH2F *h2_phgc_pulseTime_pT1_diff; TH2F *h2_phgc_pulseTime_pT2_diff; TH2F *h2_phgc_pulseTime_pT3_diff; - + TH2F *h2_pngc_pulseTime_pT1_diff; TH2F *h2_pngc_pulseTime_pT2_diff; TH2F *h2_pngc_pulseTime_pT3_diff; @@ -154,7 +154,7 @@ void UserScript() { TH2F *h2_EdivP_vs_P; // =:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: - + // Declare trees TTree *T = (TTree*) gDirectory->Get("T"); @@ -255,11 +255,11 @@ void UserScript() { T->SetBranchAddress("P.hod.1x.GoodNegTdcTimeCorr", p1X_goodNegTdcTimeCorr); T->SetBranchAddress("P.hod.1y.GoodNegTdcTimeCorr", p1Y_goodNegTdcTimeCorr); T->SetBranchAddress("P.hod.2x.GoodNegTdcTimeCorr", p2X_goodNegTdcTimeCorr); - T->SetBranchAddress("P.hod.2y.GoodNegTdcTimeCorr", p2Y_goodNegTdcTimeCorr); + T->SetBranchAddress("P.hod.2y.GoodNegTdcTimeCorr", p2Y_goodNegTdcTimeCorr); T->SetBranchAddress("P.hod.1x.GoodPosTdcTimeCorr", p1X_goodPosTdcTimeCorr); T->SetBranchAddress("P.hod.1y.GoodPosTdcTimeCorr", p1Y_goodPosTdcTimeCorr); T->SetBranchAddress("P.hod.2x.GoodPosTdcTimeCorr", p2X_goodPosTdcTimeCorr); - T->SetBranchAddress("P.hod.2y.GoodPosTdcTimeCorr", p2Y_goodPosTdcTimeCorr); + T->SetBranchAddress("P.hod.2y.GoodPosTdcTimeCorr", p2Y_goodPosTdcTimeCorr); // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// @@ -307,9 +307,9 @@ void UserScript() { // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// T->SetBranchAddress("P.tr.p", &trk_pmag); - + // =:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: - + // Create histos // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// @@ -405,13 +405,13 @@ void UserScript() { h2_phgc_pulseTime_pT1_diff = new TH2F("h2_phgc_pulseTime_pT1_diff", "SHMS Heavy Gas Cherenkov ADC Pulse Time - T1; PMT Number; ADC Pulse Time - Trigger 1 Time (ns)", nhgc_pmts, 0.5, nhgc_pmts + 0.5, 300, -300, 0); h2_phgc_pulseTime_pT2_diff = new TH2F("h2_phgc_pulseTime_pT2_diff", "SHMS Heavy Gas Cherenkov ADC Pulse Time - T2; PMT Number; ADC Pulse Time - Trigger 2 Time (ns)", nhgc_pmts, 0.5, nhgc_pmts + 0.5, 300, -300, 0); h2_phgc_pulseTime_pT3_diff = new TH2F("h2_phgc_pulseTime_pT3_diff", "SHMS Heavy Gas Cherenkov ADC Pulse Time - T3; PMT Number; ADC Pulse Time - Trigger 3 Time (ns)", nhgc_pmts, 0.5, nhgc_pmts + 0.5, 300, -300, 0); - + // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// h2_pngc_pulseTime_pT1_diff = new TH2F("h2_pngc_pulseTime_pT1_diff", "SHMS Noble Gas Cherenkov ADC Pulse Time - T1; PMT Number; ADC Pulse Time - Trigger 1 Time (ns)", nngc_pmts, 0.5, nngc_pmts + 0.5, 300, -300, 0); h2_pngc_pulseTime_pT2_diff = new TH2F("h2_pngc_pulseTime_pT2_diff", "SHMS Noble Gas Cherenkov ADC Pulse Time - T2; PMT Number; ADC Pulse Time - Trigger 2 Time (ns)", nngc_pmts, 0.5, nngc_pmts + 0.5, 300, -300, 0); h2_pngc_pulseTime_pT3_diff = new TH2F("h2_pngc_pulseTime_pT3_diff", "SHMS Noble Gas Cherenkov ADC Pulse Time - T3; PMT Number; ADC Pulse Time - Trigger 3 Time (ns)", nngc_pmts, 0.5, nngc_pmts + 0.5, 300, -300, 0); - + // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// h2_pshwr_vs_phgcer = new TH2F ("h2_pshwr_vs_phgcer", "SHMS Shower vs. Heavy Gas Cherenkov; Number of HGC Photoelectrons / 1 Photoelectron; Shower Energy / 1 MeV", 500, 0, 500, 4000, 0, 4); @@ -427,17 +427,17 @@ void UserScript() { // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// h2_EdivP_vs_P = new TH2F ("h2_EdivP_vs_P", "SHMS E/p vs. p; p (geV); E/p", 600, 0, 6, 100, 0, 1); - + // =:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: // Loop of entries in tree for(UInt_t ievent = 0; ievent < nentries; ievent++) { - + T->GetEntry(ievent); // cout << "========================" << endl; // cout << "Event Number = " << ievent << endl; - // cout << "========================" << endl; + // cout << "========================" << endl; // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//== @@ -528,36 +528,36 @@ void UserScript() { h2_p2Ypos_pt_tt_diff->Fill(p2Y_posAdcPaddle[iadchit], p2Y_posAdcPulseTime[iadchit]*clk2adc - p2Y_posTdcTime[itdchit]*clk2tdc); } } - + // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//== // Fill trigger time histos if (p1X_tdcTime != 0.0) h_p1X_tdc->Fill(p1X_tdcTime*clk2tdc); if (p1Y_tdcTime != 0.0) h_p1Y_tdc->Fill(p1Y_tdcTime*clk2tdc); - if (p2X_tdcTime != 0.0) h_p2X_tdc->Fill(p2X_tdcTime*clk2tdc); + if (p2X_tdcTime != 0.0) h_p2X_tdc->Fill(p2X_tdcTime*clk2tdc); if (p2Y_tdcTime != 0.0) h_p2Y_tdc->Fill(p2Y_tdcTime*clk2tdc); - if (p1T_tdcTime != 0.0) h_p1T_tdc->Fill(p1T_tdcTime*clk2tdc); + if (p1T_tdcTime != 0.0) h_p1T_tdc->Fill(p1T_tdcTime*clk2tdc); if (p2T_tdcTime != 0.0) h_p2T_tdc->Fill(p2T_tdcTime*clk2tdc); - h_pT1_tdc->Fill(pT1_tdcTime*clk2tdc); - h_pT2_tdc->Fill(pT2_tdcTime*clk2tdc); + h_pT1_tdc->Fill(pT1_tdcTime*clk2tdc); + h_pT2_tdc->Fill(pT2_tdcTime*clk2tdc); h_pT3_tdc->Fill(pT3_tdcTime*clk2tdc); for (UInt_t iref = 0; iref < ndcRefTimes; iref++) h_pDCREF_tdc[iref]->Fill(pDCREF_tdcTime[iref]*clk2tdc); - if (p1X_tdcTime != 0.0) h_p1XmpT2_tdc->Fill((pT2_tdcTime - p1X_tdcTime)*clk2tdc); + if (p1X_tdcTime != 0.0) h_p1XmpT2_tdc->Fill((pT2_tdcTime - p1X_tdcTime)*clk2tdc); if (p1Y_tdcTime != 0.0) h_p1YmpT2_tdc->Fill((pT2_tdcTime - p1Y_tdcTime)*clk2tdc); - if (p2X_tdcTime != 0.0) h_p2XmpT2_tdc->Fill((pT2_tdcTime - p2X_tdcTime)*clk2tdc); + if (p2X_tdcTime != 0.0) h_p2XmpT2_tdc->Fill((pT2_tdcTime - p2X_tdcTime)*clk2tdc); if (p2Y_tdcTime != 0.0) h_p2YmpT2_tdc->Fill((pT2_tdcTime - p2Y_tdcTime)*clk2tdc); - if (p1T_tdcTime != 0.0) h_p1TmpT2_tdc->Fill((pT2_tdcTime - p1T_tdcTime)*clk2tdc); + if (p1T_tdcTime != 0.0) h_p1TmpT2_tdc->Fill((pT2_tdcTime - p1T_tdcTime)*clk2tdc); if (p2T_tdcTime != 0.0) h_p2TmpT2_tdc->Fill((pT2_tdcTime - p2T_tdcTime)*clk2tdc); - if (p1X_tdcTime != 0.0) h_p1XmpT3_tdc->Fill((pT3_tdcTime - p1X_tdcTime)*clk2tdc); + if (p1X_tdcTime != 0.0) h_p1XmpT3_tdc->Fill((pT3_tdcTime - p1X_tdcTime)*clk2tdc); if (p1Y_tdcTime != 0.0) h_p1YmpT3_tdc->Fill((pT3_tdcTime - p1Y_tdcTime)*clk2tdc); - if (p2X_tdcTime != 0.0) h_p2XmpT3_tdc->Fill((pT3_tdcTime - p2X_tdcTime)*clk2tdc); + if (p2X_tdcTime != 0.0) h_p2XmpT3_tdc->Fill((pT3_tdcTime - p2X_tdcTime)*clk2tdc); if (p2Y_tdcTime != 0.0) h_p2YmpT3_tdc->Fill((pT3_tdcTime - p2Y_tdcTime)*clk2tdc); - if (p1T_tdcTime != 0.0) h_p1TmpT3_tdc->Fill((pT3_tdcTime - p1T_tdcTime)*clk2tdc); + if (p1T_tdcTime != 0.0) h_p1TmpT3_tdc->Fill((pT3_tdcTime - p1T_tdcTime)*clk2tdc); if (p2T_tdcTime != 0.0) h_p2TmpT3_tdc->Fill((pT3_tdcTime - p2T_tdcTime)*clk2tdc); // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//== @@ -583,7 +583,7 @@ void UserScript() { if (paero_sum != 0.0) h_paero_sum->Fill(paero_sum); // ==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//== - + Double_t ppshwr_sum = 0.0; for (UInt_t ipshwrhit = 0; ipshwrhit < ppshwr_negHits; ipshwrhit++) { h2_ppshwr_negPulseTime_pT1_diff->Fill(ppshwr_negPmt[ipshwrhit], ppshwr_negPulseTime[ipshwrhit]*clk2adc - pT1_tdcTime*clk2tdc); @@ -644,31 +644,31 @@ void UserScript() { if ((ievent)%1000 == 0) cout << "ievent = " << ievent << endl; - + } // Entries loop } // 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); - + TH2F *h2d; + + 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; + cout << "User histogram " << histname << " not found" << endl; exit(1); } - } - //else + } + //else if (h2d) { h2d->SetStats(0); h2d->Draw("colz"); diff --git a/onlineGUI/onlineGUI_v1.2.1/online.C b/onlineGUI/onlineGUI_v1.2.1/online.C index c983c6d5..ad2a619c 100755 --- a/onlineGUI/onlineGUI_v1.2.1/online.C +++ b/onlineGUI/onlineGUI_v1.2.1/online.C @@ -49,18 +49,18 @@ TString guiDirectory = "./"; // // -OnlineConfig::OnlineConfig() +OnlineConfig::OnlineConfig() { // Constructor. Without an argument, will use default "standard" config fMonitor = kFALSE; OnlineConfig("standard"); } -OnlineConfig::OnlineConfig(TString anatype) +OnlineConfig::OnlineConfig(TString anatype) { // Constructor. Takes the config anatype as the only argument. // Loads up the configuration file, and stores it's contents for access. - + confFileName = anatype; configfilestart=anatype; if(!confFileName.Contains(".cfg")) @@ -80,7 +80,7 @@ OnlineConfig::OnlineConfig(TString anatype) if ( ! (*fConfFile) ) { // Didn't find it... load up the default config confFileName = guiDirectory+"/default.cfg"; - cout << "OnlineConfig() Trying " << confFileName.Data() + cout << "OnlineConfig() Trying " << confFileName.Data() << " as default configuration." << endl << " (May be ok.)" << endl; fConfFile = new ifstream(confFileName.Data()); @@ -101,7 +101,7 @@ OnlineConfig::OnlineConfig(TString anatype) } if(fFoundCfg) { - clog << "GUI Configuration loading from " + clog << "GUI Configuration loading from " << confFileName.Data() << endl; } @@ -117,7 +117,7 @@ OnlineConfig::OnlineConfig(TString anatype) } -void OnlineConfig::ParseFile() +void OnlineConfig::ParseFile() { // Reads in the Config File, and makes the proper calls to put // the information contained into memory. @@ -178,24 +178,24 @@ void OnlineConfig::ParseFile() delete tmpoarr2; } sConfFile.push_back(strvect); - + } #ifdef DEBUGPARSE for(UInt_t ii=0; ii<sConfFile.size(); ii++) { cout << "Line " << ii << endl << " "; - for(UInt_t jj=0; jj<sConfFile[ii].size(); jj++) + for(UInt_t jj=0; jj<sConfFile[ii].size(); jj++) cout << sConfFile[ii][jj] << " "; cout << endl; } #endif - cout << " " << sConfFile.size() << " lines read from " + cout << " " << sConfFile.size() << " lines read from " << confFileName << endl; - + } -Bool_t OnlineConfig::ParseConfig() +Bool_t OnlineConfig::ParseConfig() { // Goes through each line of the config [must have been ParseFile()'d] // and interprets. @@ -243,8 +243,8 @@ Bool_t OnlineConfig::ParseConfig() continue; } if(!rootfilename.IsNull()) { - cerr << "WARNING: too many rootfile's defined. " - << " Will only use the first one." + cerr << "WARNING: too many rootfile's defined. " + << " Will only use the first one." << endl; continue; } @@ -258,8 +258,8 @@ Bool_t OnlineConfig::ParseConfig() continue; } if(!goldenrootfilename.IsNull()) { - cerr << "WARNING: too many goldenrootfile's defined. " - << " Will only use the first one." + cerr << "WARNING: too many goldenrootfile's defined. " + << " Will only use the first one." << endl; continue; } @@ -273,8 +273,8 @@ Bool_t OnlineConfig::ParseConfig() continue; } if(!protorootfile.IsNull()) { - cerr << "WARNING: too many protorootfile's defined. " - << " Will only use the first one." + cerr << "WARNING: too many protorootfile's defined. " + << " Will only use the first one." << endl; continue; } @@ -288,8 +288,8 @@ Bool_t OnlineConfig::ParseConfig() continue; } if(!guicolor.IsNull()) { - cerr << "WARNING: too many guicolor's defined. " - << " Will only use the first one." + cerr << "WARNING: too many guicolor's defined. " + << " Will only use the first one." << endl; continue; } @@ -313,8 +313,8 @@ Bool_t OnlineConfig::ParseConfig() continue; } if(!plotsdir.IsNull()) { - cerr << "WARNING: too many plotdir's defined. " - << " Will only use the first one." + cerr << "WARNING: too many plotdir's defined. " + << " Will only use the first one." << endl; continue; } @@ -335,7 +335,7 @@ Bool_t OnlineConfig::ParseConfig() #ifdef NOISY for(UInt_t i=0; i<GetPageCount(); i++) { cout << "Page " << i << " (" << GetPageTitle(i) << ")" - << " will draw " << GetDrawCount(i) + << " will draw " << GetDrawCount(i) << " histograms." << endl; } #endif @@ -343,11 +343,11 @@ Bool_t OnlineConfig::ParseConfig() cout << "Number of pages defined = " << GetPageCount() << endl; cout << "Number of cuts defined = " << cutList.size() << endl; - if (fMonitor) + if (fMonitor) cout << "Will periodically update plots" << endl; if(!goldenrootfilename.IsNull()) { - cout << "Will compare chosen histrograms with the golden rootfile: " - << endl + cout << "Will compare chosen histrograms with the golden rootfile: " + << endl << goldenrootfilename << endl; } @@ -362,11 +362,11 @@ Bool_t OnlineConfig::ParseForMultiPlots() { vector < vector <TString> > newConfFile; for(UInt_t iter=0;iter<sConfFile.size();iter++) { if(sConfFile[iter][0]=="multiplot") { - // First argument is the low limit, + // First argument is the low limit, // second argument is the high limit UInt_t lolimit = (UInt_t)sConfFile[iter][1].Atoi(); UInt_t hilimit = (UInt_t)sConfFile[iter][2].Atoi(); - + // For the rest of the line, replace all of the XXXXX's // with an iteration from lolimit to hilimit. for(UInt_t imult=lolimit;imult<=hilimit;imult++) { @@ -452,7 +452,7 @@ Bool_t OnlineConfig::IsLogx(UInt_t page) { UInt_t page_index = pageInfo[page].first; Int_t word_index = sConfFile[page_index].size()-1; if (word_index <= 0) return kFALSE; - TString option = sConfFile[page_index][word_index]; + TString option = sConfFile[page_index][word_index]; if(option == "logx") return kTRUE; return kFALSE; @@ -464,7 +464,7 @@ Bool_t OnlineConfig::IsLogy(UInt_t page) { UInt_t page_index = pageInfo[page].first; Int_t word_index = sConfFile[page_index].size()-1; if (word_index <= 0) return kFALSE; - TString option = sConfFile[page_index][word_index]; + TString option = sConfFile[page_index][word_index]; if(option == "logy") return kTRUE; return kFALSE; @@ -476,14 +476,14 @@ Bool_t OnlineConfig::IsLogz(UInt_t page) { UInt_t page_index = pageInfo[page].first; Int_t word_index = sConfFile[page_index].size()-1; if (word_index <= 0) return kFALSE; - TString option = sConfFile[page_index][word_index]; + TString option = sConfFile[page_index][word_index]; if(option == "logz") return kTRUE; return kFALSE; } -pair <UInt_t, UInt_t> OnlineConfig::GetPageDim(UInt_t page) +pair <UInt_t, UInt_t> OnlineConfig::GetPageDim(UInt_t page) { // If defined in the config, will return those dimensions // for the indicated page. Otherwise, will return the @@ -493,13 +493,13 @@ pair <UInt_t, UInt_t> OnlineConfig::GetPageDim(UInt_t page) // This is the page index in sConfFile. UInt_t page_index = pageInfo[page].first; - + UInt_t size1 = 2; if (IsLogx(page)) size1 = 3; // last word is "logy" if (IsLogy(page)) size1 = 3; // last word is "logy" if (IsLogz(page)) size1 = 3; // last word is "logy" - + // If the dimensions are defined, return them. if(sConfFile[page_index].size()>size1-1) { if(sConfFile[page_index].size() == size1) { @@ -516,7 +516,7 @@ pair <UInt_t, UInt_t> OnlineConfig::GetPageDim(UInt_t page) << endl; } } - + // If not defined, return the "default." UInt_t draw_count = GetDrawCount(page); UInt_t dim = UInt_t(TMath::Nint(sqrt(double(draw_count+1)))); @@ -525,7 +525,7 @@ pair <UInt_t, UInt_t> OnlineConfig::GetPageDim(UInt_t page) return outDim; } -TString OnlineConfig::GetPageTitle(UInt_t page) +TString OnlineConfig::GetPageTitle(UInt_t page) { // Returns the title of the page. // if it is not defined in the config, then return "Page #" @@ -535,7 +535,7 @@ TString OnlineConfig::GetPageTitle(UInt_t page) UInt_t iter_command = pageInfo[page].first+1; for(UInt_t i=0; i<pageInfo[page].second; i++) { // go through each command - if(sConfFile[iter_command+i][0] == "title") { + if(sConfFile[iter_command+i][0] == "title") { // Combine the strings, and return it for (UInt_t j=1; j<sConfFile[iter_command+i].size(); j++) { title += sConfFile[iter_command+i][j]; @@ -549,7 +549,7 @@ TString OnlineConfig::GetPageTitle(UInt_t page) return title; } -vector <UInt_t> OnlineConfig::GetDrawIndex(UInt_t page) +vector <UInt_t> OnlineConfig::GetDrawIndex(UInt_t page) { // Returns an index of where to find the draw commands within a page // within the sConfFile vector @@ -566,7 +566,7 @@ vector <UInt_t> OnlineConfig::GetDrawIndex(UInt_t page) return index; } -UInt_t OnlineConfig::GetDrawCount(UInt_t page) +UInt_t OnlineConfig::GetDrawCount(UInt_t page) { // Returns the number of histograms that have been request for this page UInt_t draw_count=0; @@ -581,13 +581,13 @@ UInt_t OnlineConfig::GetDrawCount(UInt_t page) drawcommand OnlineConfig::GetDrawCommand(UInt_t page, UInt_t nCommand) { - // Returns the vector of strings pertaining to a specific page, and + // Returns the vector of strings pertaining to a specific page, and // draw command from the config. // Return vector of TStrings: // 0: variable // 1: cut - only for Tree variables // 2: type - // 3: title + // 3: title // 4: treename - only for Tree variables // 5: nostat // 6: noshowgolden - only for Histograms @@ -598,7 +598,7 @@ drawcommand OnlineConfig::GetDrawCommand(UInt_t page, UInt_t nCommand) UInt_t index = command_vector[nCommand]; #ifdef DEBUG - cout << "OnlineConfig::GetDrawCommand(" << page << "," + cout << "OnlineConfig::GetDrawCommand(" << page << "," << nCommand << ")" << endl; #endif @@ -659,7 +659,7 @@ drawcommand OnlineConfig::GetDrawCommand(UInt_t page, UInt_t nCommand) } else if(sConfFile[index][i]=="-noshowgolden") { out_command.noshowgolden = "noshowgolden"; } - + #ifdef DEBUG cout << endl; @@ -675,7 +675,7 @@ drawcommand OnlineConfig::GetDrawCommand(UInt_t page, UInt_t nCommand) return out_command; } -vector <TString> OnlineConfig::SplitString(TString instring,TString delim) +vector <TString> OnlineConfig::SplitString(TString instring,TString delim) { // Utility to split up a string on the deliminator. // returns a vector of strings. @@ -705,13 +705,13 @@ vector <TString> OnlineConfig::SplitString(TString instring,TString delim) while(tempstring.EndsWith(delim)) { tempstring.Chop(); } - + if(!tempstring.IsNull()) v.push_back(tempstring); return v; } -void OnlineConfig::OverrideRootFile(UInt_t runnumber) +void OnlineConfig::OverrideRootFile(UInt_t runnumber) { // Override the ROOT file defined in the cfg file If // protorootfile is used, construct filename using it, otherwise @@ -754,9 +754,9 @@ OnlineGUI::OnlineGUI(OnlineConfig& config, Bool_t printonly, Bool_t rootonly,UIn } } -void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) +void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) { - + // Open the RootFile. Die if it doesn't exist. // unless we're watching a file. fRootFile.RootFile = new TFile(fConfig->GetRootFile(),"READ"); @@ -825,7 +825,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) UInt_t canvas_width = fConfig->GetCanvasWidth(); UInt_t canvas_height = fConfig->GetCanvasHeight(); - Bool_t good_color=kFALSE; + Bool_t good_color=kFALSE; TString usercolor = fConfig->GetGuiColor(); if(!usercolor.IsNull()) { good_color = gClient->GetColorByName(usercolor,mainguicolor); @@ -849,7 +849,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) // Top frame, to hold page buttons and canvas fTopframe = new TGHorizontalFrame(fMain,200,200); fTopframe->SetBackgroundColor(mainguicolor); - fMain->AddFrame(fTopframe, new TGLayoutHints(kLHintsExpandX + fMain->AddFrame(fTopframe, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,10,10,10,1)); // Create a verticle frame widget with radio buttons @@ -867,18 +867,18 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) current_page = 0; for (UInt_t i=0; i<fConfig->GetPageCount(); i++) { - vframe->AddFrame(fRadioPage[i], + vframe->AddFrame(fRadioPage[i], new TGLayoutHints(kLHintsLeft | kLHintsCenterY,5,5,3,4)); fRadioPage[i]->Connect("Pressed()", "OnlineGUI", this, "DoRadio()"); } if(!fConfig->IsMonitor()) { - wile = + wile = new TGPictureButton(vframe, gClient->GetPicture(guiDirectory+"/hcsmall.png")); wile->Connect("Pressed()","OnlineGUI", this,"DoDraw()"); } else { - wile = + wile = new TGPictureButton(vframe, gClient->GetPicture(guiDirectory+"/panguin.xpm")); wile->Connect("Pressed()","OnlineGUI", this,"DoDrawClear(&fRootFile)"); @@ -892,7 +892,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) fTopframe->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX| kLHintsCenterY,2,2,2,2)); - + // Create canvas widget fEcanvas = new TRootEmbeddedCanvas("Ecanvas", fTopframe, canvas_width, canvas_height); fEcanvas->SetBackgroundColor(mainguicolor); @@ -903,7 +903,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) fBottomFrame = new TGHorizontalFrame(fMain,canvas_width+400,200); fBottomFrame->SetBackgroundColor(mainguicolor); fMain->AddFrame(fBottomFrame, new TGLayoutHints(kLHintsExpandX,10,10,10,10)); - + // Create a horizontal frame widget with buttons hframe = new TGHorizontalFrame(fBottomFrame,canvas_width+400,40); hframe->SetBackgroundColor(mainguicolor); @@ -924,7 +924,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) fExit->Connect("Clicked()","OnlineGUI",this,"CloseGUI()"); hframe->AddFrame(fExit, new TGLayoutHints(kLHintsCenterX,5,5,1,1)); - + TString Buff; if(runNumber==0) { Buff = ""; @@ -933,7 +933,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) Buff += runNumber; } TGString labelBuff(Buff); - + fRunNumber = new TGLabel(hframe,Buff); fRunNumber->SetBackgroundColor(mainguicolor); hframe->AddFrame(fRunNumber,new TGLayoutHints(kLHintsCenterX,5,5,1,1)); @@ -953,10 +953,10 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) // Map all sub windows to main frame fMain->MapSubwindows(); - + // Initialize the layout algorithm fMain->Resize(fMain->GetDefaultSize()); - + // Map main frame fMain->MapWindow(); @@ -978,7 +978,7 @@ void OnlineGUI::CreateGUI(const TGWindow *p, UInt_t w, UInt_t h) } -void OnlineGUI::DoDraw() +void OnlineGUI::DoDraw() { // The main Drawing Routine. @@ -1027,9 +1027,9 @@ void OnlineGUI::DoDraw() pair <UInt_t,UInt_t> dim = fConfig->GetPageDim(current_page); #ifdef DEBUG - cout << "Dimensions: " << dim.first << "X" + cout << "Dimensions: " << dim.first << "X" << dim.second << endl; -#endif +#endif // Create a nice clean canvas. fCanvas->Clear(); @@ -1037,7 +1037,7 @@ void OnlineGUI::DoDraw() drawcommand thiscommand; // Draw the histograms. - for(UInt_t i=0; i<draw_count; i++) { + for(UInt_t i=0; i<draw_count; i++) { thiscommand = fConfig->GetDrawCommand(current_page,i); thiscommand = fileObject2command(thiscommand,&fRootFile); fCanvas->cd(i+1); @@ -1053,7 +1053,7 @@ void OnlineGUI::DoDraw() TreeDraw(thiscommand); } } - + fCanvas->cd(); fCanvas->Update(); @@ -1069,7 +1069,7 @@ void OnlineGUI::DrawNext() fRadioPage[current_page]->SetState(kButtonUp); // The following line triggers DoRadio() fRadioPage[current_page+1]->SetState(kButtonDown,true); - + } void OnlineGUI::DrawPrev() @@ -1078,7 +1078,7 @@ void OnlineGUI::DrawPrev() fRadioPage[current_page]->SetState(kButtonUp); // The following line triggers DoRadio() fRadioPage[current_page-1]->SetState(kButtonDown,true); - + } void OnlineGUI::DoRadio() @@ -1093,8 +1093,8 @@ void OnlineGUI::DoRadio() UInt_t pagecount = fConfig->GetPageCount(); TGButton *btn = (TGButton *) gTQSender; UInt_t id = btn->WidgetId(); - - if (id <= pagecount) { + + if (id <= pagecount) { fRadioPage[current_page]->SetState(kButtonUp); } @@ -1103,7 +1103,7 @@ void OnlineGUI::DoRadio() } -void OnlineGUI::CheckPageButtons() +void OnlineGUI::CheckPageButtons() { // Checks the current page to see if it's the first or last page. // If so... turn off the appropriate button. @@ -1127,7 +1127,7 @@ void OnlineGUI::GetFileObjects(RootFileObject* fLocalRootFileObj) { // Utility to find all of the objects within a File (TTree, TH1F, etc). // The pair stored in the vector is <ObjName, ObjType> - // For histograms, the title is also stored + // For histograms, the title is also stored // (in case the the name is not very descriptive... like when // using h2root) // If there's no good keys.. do nothing. @@ -1149,7 +1149,7 @@ void OnlineGUI::GetFileObjects(RootFileObject* fLocalRootFileObj) // Do the search while((key=(TKey*)next())!=0) { #ifdef DEBUGGETFILEOBJECTS - cout << "Key = " << key << endl; + cout << "Key = " << key << endl; #endif TString objname = key->GetName(); TString objtype = key->GetClassName(); @@ -1185,13 +1185,13 @@ void OnlineGUI::GetFileObjects(RootFileObject* fLocalRootFileObj) thisObject.directory = ""; fLocalRootFileObj->vfileObjects.push_back(thisObject); } - + } fLocalRootFileObj->fUpdate = kTRUE; delete key; } -void OnlineGUI::GetTreeVars(RootFileObject* fLocalRootFileObj) +void OnlineGUI::GetTreeVars(RootFileObject* fLocalRootFileObj) { // Utility to find all of the variables (leaf's/branches) within a // Specified TTree and put them within the TreeVars vector. @@ -1245,20 +1245,20 @@ void OnlineGUI::GetRootTree(RootFileObject* fLocalRootFileObj ) { for(UInt_t i=0; i<nTrees; i++) { fLocalRootFileObj->RootTree.push_back( (TTree*) fLocalRootFileObj->RootFile->Get(found.front()) ); found.pop_front(); - } + } // Initialize the TreeEntries vector fLocalRootFileObj->TreeEntries.clear(); for(UInt_t i=0;i<fLocalRootFileObj->RootTree.size();i++) { fLocalRootFileObj->TreeEntries.push_back(0); } - + } UInt_t OnlineGUI::GetTreeIndex(TString var, RootFileObject* fLocalRootFileObj ) { // Utility to find out which Tree (in fRootFile.RootTree) has the specified // variable "var". If the variable is a collection of Tree // variables (e.g. bcm1:lumi1), will only check the first - // (e.g. bcm1). + // (e.g. bcm1). // Returns the correct index. if not found returns an index 1 // larger than fRootFile.RootTree.size() @@ -1308,12 +1308,12 @@ void OnlineGUI::MacroDraw(drawcommand command) { if(doGolden) fRootFile.RootFile->cd(); gROOT->Macro(command.macro); - + } void OnlineGUI::CanvasDraw(drawcommand command,UInt_t padnum) { // Called by DoDraw(), this will draw the TCanvas in the current Canvas - + TString rootversion = gROOT->GetVersion(); TString slash = "/"; TString rootversion_cut = (fConfig->SplitString(rootversion,slash))[0]; @@ -1330,19 +1330,19 @@ void OnlineGUI::CanvasDraw(drawcommand command,UInt_t padnum) { } else { fDir = (TDirectory*)fRootFile.RootFile->Get(command.directory); } - + if(fDir) fDir->cd(); fRootFile.RootFile->cd(); TCanvas *tcanv = (TCanvas*)fRootFile.RootFile->Get(command.objname); fCanvas->cd(padnum); tcanv->DrawClonePad(); delete tcanv; - + } void OnlineGUI::GraphDraw(drawcommand command) { // Called by DoDraw(), this will draw the TCanvas in the current Canvas - + TString rootversion = gROOT->GetVersion(); fRootFile.RootFile->cd(); TDirectory *fDir; @@ -1351,14 +1351,14 @@ void OnlineGUI::GraphDraw(drawcommand command) { } else { fDir = (TDirectory*)fRootFile.RootFile->Get(command.directory); } - + if(fDir) fDir->cd(); TGraph *thisgraph = (TGraph*)fRootFile.RootFile->Get(command.objname); TString drawopt = command.type; if(drawopt.IsNull()) drawopt = "AP"; if(!command.title.IsNull()) thisgraph->SetTitle(command.title); thisgraph->Draw(drawopt); - + } @@ -1369,7 +1369,7 @@ void OnlineGUI::DoDrawClear(RootFileObject* fLocalRootFileObj) { for(UInt_t i=0; i<fLocalRootFileObj->TreeEntries.size(); i++) { fLocalRootFileObj->TreeEntries[i] = (Int_t) fLocalRootFileObj->RootTree[i]->GetEntries(); } - + } @@ -1418,7 +1418,7 @@ void OnlineGUI::BadDraw(TString errMessage) { void OnlineGUI::CheckRootFile() { // Check the path to the rootfile (should follow symbolic links) // ... If found: - // Reopen new root file, + // Reopen new root file, // Reconnect the timer to TimerUpdate() if(gSystem->AccessPathName(fConfig->GetRootFile())==0) { @@ -1487,7 +1487,7 @@ void OnlineGUI::HistDraw(drawcommand command) { Bool_t showStat=kTRUE; TString htitle; - if(command.noshowgolden=="noshowgolden") + if(command.noshowgolden=="noshowgolden") showGolden = kFALSE; if(command.nostat=="nostat") showStat=kFALSE; @@ -1495,13 +1495,13 @@ void OnlineGUI::HistDraw(drawcommand command) { TString type=command.type; TDirectory *fDir; - + if(command.directory.IsNull()) { fDir = 0; } else { fDir = (TDirectory*)fRootFile.RootFile->Get(command.directory); } - + // Determine dimensionality of histogram, then draw it if(command.objtype.Contains("TH1")) { // Operation for TH1 @@ -1590,7 +1590,7 @@ void OnlineGUI::HistDraw(drawcommand command) { } return; } - + } drawcommand OnlineGUI::fileObject2command(drawcommand command, RootFileObject* fLocalRootFileObj) { @@ -1605,16 +1605,16 @@ drawcommand OnlineGUI::fileObject2command(drawcommand command, RootFileObject* f command.objtype = fLocalRootFileObj->vfileObjects[i].type; command.directory = fLocalRootFileObj->vfileObjects[i].directory; #ifdef DEBUGf2command - cout << command.directory << " " - << command.objtype << " " - << command.objname + cout << command.directory << " " + << command.objtype << " " + << command.objname << endl; #endif return command; } } return command; - + } @@ -1740,7 +1740,7 @@ void OnlineGUI::ObtainRunNumber() { // Utility to obtain the runnumber through a helper macro // "GetRunNumber.C" - + if (runNumber==0) runNumber = GetRunNumber(); #ifdef DEBUG cout << "Runnumber from file: " << runNumber << endl; @@ -1755,7 +1755,7 @@ void OnlineGUI::PrintToFile() gStyle->SetPaperSize(20,24); static TString dir("."); TGFileInfo fi; - const char *myfiletypes[] = + const char *myfiletypes[] = { "All files","*", "PDF files","*.pdf", "PNG files","*.png", @@ -1772,9 +1772,9 @@ void OnlineGUI::PrintToFile() } void OnlineGUI::PrintPages() { - // Routine to go through each defined page, and print the output to + // Routine to go through each defined page, and print the output to // a postscript file. (good for making sample histograms). - + // Open the RootFile // unless we're watching a file. fRootFile.RootFile = new TFile(fConfig->GetRootFile(),"READ"); @@ -1799,7 +1799,7 @@ void OnlineGUI::PrintPages() { fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i); } } - + } TString goldenfilename=fConfig->GetGoldenFile(); if(!goldenfilename.IsNull()) { @@ -1879,14 +1879,47 @@ void OnlineGUI::PrintPages() { if(useJPG) { filename = origFilename; filename.ReplaceAll("XXXX",Form("%d",current_page)); - cout << "Printing page " << current_page + cout << "Printing page " << current_page << " to file = " << filename << endl; } fCanvas->Print(filename); } 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(); @@ -1907,7 +1940,7 @@ void OnlineGUI::MyCloseWindow() delete fPrev; delete fNext; delete wile; - for(UInt_t i=0; i<fConfig->GetPageCount(); i++) + for(UInt_t i=0; i<fConfig->GetPageCount(); i++) delete fRadioPage[i]; delete hframe; delete fEcanvas; @@ -1924,7 +1957,7 @@ void OnlineGUI::MyCloseWindow() #endif } -void OnlineGUI::CloseGUI() +void OnlineGUI::CloseGUI() { // Routine to take care of the Exit GUI button fMain->SendCloseMessage(); @@ -1943,7 +1976,7 @@ OnlineGUI::~OnlineGUI() delete fPrev; delete fNext; delete wile; - for(UInt_t i=0; i<fConfig->GetPageCount(); i++) + for(UInt_t i=0; i<fConfig->GetPageCount(); i++) delete fRadioPage[i]; delete hframe; delete fEcanvas; @@ -1956,7 +1989,7 @@ OnlineGUI::~OnlineGUI() delete fConfig; } -void online(TString type="standard",UInt_t run=0,Bool_t printonly=kFALSE,Bool_t rootonly=kFALSE) +void online(TString type="standard",UInt_t run=0,Bool_t printonly=kFALSE,Bool_t rootonly=kFALSE) { // "main" routine. Run this at the ROOT commandline. -- GitLab