diff --git a/DEF-files/SHMS/PRODUCTION/AERO/paero_histos.def b/DEF-files/SHMS/PRODUCTION/AERO/paero_histos.def
index 47e557e40fcb12eae85b309ddc26e9c9b74729ce..37f496eec9c65e5701660f149a2aa732bb29bc6c 100644
--- a/DEF-files/SHMS/PRODUCTION/AERO/paero_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/AERO/paero_histos.def
@@ -1,43 +1,3 @@
 #***************
 # SHMS AEROGEL *
 #***************
-
-#----------------------------------------------
-# SHMS AEROGEL GOOD Occupancy and Multiplicity
-#----------------------------------------------
-
-TH1F paero_good_occ_pos 'SHMS Aero+ Good Occupancy; PMT Number; Number of Good +ADC Hits' P.aero.numGoodPosAdcHits 7 0.5 7.5
-TH1F paero_good_occ_neg 'SHMS Aero- Good Occupancy; PMT Number; Number of Good -ADC Hits' P.aero.numGoodNegAdcHits 7 0.5 7.5
-TH1F paero_good_mult_pos 'SHMS Aero+ Good Multiplicity; Number of PMTs Hit; Total Number of Good +ADC Hits' P.aero.totNumGoodPosAdcHits 7 0.5 7.5
-TH1F paero_good_mult_neg 'SHMS Aero- Good Multiplicity; Number of PMTs Hit; Total Number of Good -ADC Hits' P.aero.totNumGoodNegAdcHits 7 0.5 7.5
-TH1F paero_good_mult 'SHMS Aero Good Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.aero.totnumGoodAdcHits 14 0.5 14.5
-
-#-------------------------------
-# SHMS AERO TOTAL NUMBER OF P.E.
-#-------------------------------
-
-TH1F paero_tot_npe_pos 'SHMS Aero+ Total Number of Photoelectrons; Total Number of Pos Photoelectrons; Number of Entries / 0.5 Photoelectrons' P.aero.posNpeSum 200 0 100 P.aero.posNpeSum>0.0 
-TH1F paero_tot_npe_neg 'SHMS Aero- Total Number of Photoelectrons; Total Number of Neg Photoelectrons; Number of Entries / 0.5 Photoelectrons' P.aero.negNpeSum 200 0 100 P.aero.negNpeSum>0.0 
-TH1F paero_tot_npe 'SHMS Aero Total Number of Photoelectrons; Total Number of Photoelectrons; Number of Entries / 0.5 Photoelectrons' P.aero.npeSum 200 0 100 P.aero.npeSum>0.0 
-
-#--------------------------------
-# SHMS AERO Number of P.E. / PMT
-#--------------------------------
-
-TH2F paero_npe_pos 'SHMS Aero+ Number of Photoelectrons vs. PMT Number; PMT Number; Number of Photoelectrons / PMT' [I+1] P.aero.posNpe 7 0.5 7.5 200 0 100 P.aero.posNpe>0.0 
-TH2F paero_npe_neg 'SHMS Aero- Number of Photoelectrons vs. PMT Number; PMT Number; Number of Photoelectrons / PMT' [I+1] P.aero.negNpe 7 0.5 7.5 200 0 100 P.aero.negNpe>0.0 
-
-#------------------------------------------------------------------------------
-# SHMS AERO GOOD Pulse Pedestal / Integral / Raw Integral / Amplitude / Time 
-# GOOD --> (passed errorFlag cut and pulsetime cuts oN Min/Max ADC Time Window) 
-#------------------------------------------------------------------------------
-
-TH2F paero_good_pped_vs_pmt_pos 'SHMS Aero+ Good Pulse Pedestal vs. PMT Number; PMT Number;  Pulse Pedestal / 1 ADC Units' [I+1] P.aero.goodPosAdcPed 7 0.5 7.5 400 300 700  P.aero.goodPosAdcPed>0.0
-TH2F paero_good_pi_vs_pmt_pos 'SHMS Aero+ Good Pulse Integral vs. PMT Number; PMT Number;  Pulse Integral / 50 ADC Units' [I+1] P.aero.goodPosAdcPulseInt 7 0.5 7.5 600 0 30000 P.aero.goodPosAdcPulseInt>0.0
-TH2F paero_good_pamp_vs_pmt_pos 'SHMS Aero+ Good Pulse Amplitude vs. PMT Number; PMT Number;  Pulse Amplitude / 20 ADC Units' [I+1] P.aero.goodPosAdcPulseAmp 7 0.5 7.5 200 0 4000 P.aero.goodPosAdcPulseAmp>0.0
-TH2F paero_good_ptime_vs_pmt_pos 'SHMS Aero+ Good Pulse Time vs. PMT Number; PMT Number; Pulse Time / 10 ADC Units' [I+1] P.aero.goodPosAdcPulseTime 7 0.5 7.5 350 0 3500 P.aero.goodPosAdcPulseTime>0.0
-
-TH2F paero_good_pped_vs_pmt_neg 'SHMS Aero- Good Pulse Pedestal vs. PMT Number; PMT Number;  Pulse Pedestal / 1 ADC Units' [I+1] P.aero.goodNegAdcPed 7 0.5 7.5 400 300 700 P.aero.goodNegAdcPed>0.0
-TH2F paero_good_pi_vs_pmt_neg 'SHMS Aero- Good Pulse Integral vs. PMT Number; PMT Number;  Pulse Integral / 50 ADC Units' [I+1] P.aero.goodNegAdcPulseInt 7 0.5 7.5 600 0 30000 P.aero.goodNegAdcPulseInt>0.0
-TH2F paero_good_pamp_vs_pmt_neg 'SHMS Aero- Good Pulse Amplitude vs. PMT Number; PMT Number;  Pulse Amplitude / 20 ADC Units' [I+1] P.aero.goodNegAdcPulseAmp 7 0.5 7.5 200 0 4000 P.aero.goodNegAdcPulseAmp>0.0
-TH2F paero_good_ptime_vs_pmt_neg 'SHMS Aero- Good Pulse Time vs. PMT Number; PMT Number; Pulse Time / 10 ADC Units' [I+1] P.aero.goodNegAdcPulseTime 7 0.5 7.5 350 0 3500 P.aero.goodNegAdcPulseTime>0.0
\ No newline at end of file
diff --git a/DEF-files/SHMS/PRODUCTION/BLOCK/pblock_vars.def b/DEF-files/SHMS/PRODUCTION/BLOCK/pblock_vars.def
index 809e674cc2128162ffcf450c80e885b441efba87..8122d39e5da92abe4eab651b0d6be126cd8a9a89 100644
--- a/DEF-files/SHMS/PRODUCTION/BLOCK/pblock_vars.def
+++ b/DEF-files/SHMS/PRODUCTION/BLOCK/pblock_vars.def
@@ -2,14 +2,7 @@
 # Block Definitions *
 #********************
 
-block T.shms.*
-block P.ngcer.*
-block P.dc.*
 block P.tr.*
-block P.hod.*
-block P.hgcer.*
-block P.aero.*
-block P.cal.*
 block P.gtr.*
 block P.kin.*
 block P.rb.*
diff --git a/DEF-files/SHMS/PRODUCTION/CAL/pcal_histos.def b/DEF-files/SHMS/PRODUCTION/CAL/pcal_histos.def
index 36e37b71ccb41dae5ea7e5673684566f6009a0a6..c34d7c8891d6d1fdfb3243e8df3cd550155301af 100644
--- a/DEF-files/SHMS/PRODUCTION/CAL/pcal_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/CAL/pcal_histos.def
@@ -2,83 +2,11 @@
 # SHMS CALORIMETER *
 #*******************
 
-#--------------------------------------------
-# SHMS PreSH GOOD Occupancy and Multiplicity
-#--------------------------------------------
-
-TH1F pcal_prshwr_good_occ_pos 'SHMS PreShower+ Good Occupancy; PMT Number; Number of Good +ADC Hits' P.cal.pr.numGoodPosAdcHits 14 0.5 14.5
-TH1F pcal_prshwr_good_occ_neg 'SHMS PreShower- Good Occupancy; PMT Number; Number of Good -ADC Hits' P.cal.pr.numGoodNegAdcHits 14 0.5 14.5
-TH1F pcal_prshwr_good_mult_pos 'SHMS PreShower+ Good Multiplicity; Number of PMTs Hit; Total Number of Good +ADC Hits' P.cal.pr.totNumGoodPosAdcHits 14 0.5 14.5
-TH1F pcal_prshwr_good_mult_neg 'SHMS PreShower- Good Multiplicity; Number of PMTs Hit; Total Number of Good -ADC Hits' P.cal.pr.totNumGoodNegAdcHits 14 0.5 14.5
-TH1F pcal_prshwr_good_mult 'SHMS PreShower Good Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.cal.pr.totnumGoodAdcHits 28 0.5 28.5
-
-#--------------------------------------------------------------------------------------------------
-# GOOD PULSE PEDESTALS/INTEGRALS/AMPLITUDES/TIMES 
-# GOOD --> (passed errorFlag cut, pulsetime cuts oN Min/Max ADC Time Window, and ADC threshold cut)
-#--------------------------------------------------------------------------------------------------
-
-TH2F pcal_prshwr_good_pped_vs_pmt_pos 'SHMS PreShower+ Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1] P.cal.pr.goodPosAdcPed 14 0.5 14.5 400 300 700  P.cal.pr.goodPosAdcPed>0.0
-TH2F pcal_prshwr_good_pi_vs_pmt_pos 'SHMS PreShower+ Good Pulse Integral vs. PMT Number; PMT Number; Good  Pulse Integral / 50 ADC Units' [I+1] P.cal.pr.goodPosAdcPulseInt 14 0.5 14.5 600 0 30000 P.cal.pr.goodPosAdcPulseInt>0.0
-TH2F pcal_prshwr_good_pamp_vs_pmt_pos 'SHMS PreShower+ Good Pulse Amplitude vs. PMT Number; PMT Number; Good  Pulse Amplitude / 20 ADC Units' [I+1] P.cal.pr.goodPosAdcPulseAmp 14 0.5 14.5 200 0 4000 P.cal.pr.goodPosAdcPulseAmp>0.0
-TH2F pcal_prshwr_good_ptime_vs_pmt_pos 'SHMS PreShower+ Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1] P.cal.pr.goodPosAdcPulseTime 14 0.5 14.5 350 0 3500 P.cal.pr.goodPosAdcPulseTime>0.0
-
-TH2F pcal_prshwr_good_pped_vs_pmt_neg 'SHMS PreShower- Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1] P.cal.pr.goodNegAdcPed 14 0.5 14.5 400 300 700  P.cal.pr.goodNegAdcPed>0.0
-TH2F pcal_prshwr_good_pi_vs_pmt_neg 'SHMS PreShower- Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1] P.cal.pr.goodNegAdcPulseInt 14 0.5 14.5 600 0 30000 P.cal.pr.goodNegAdcPulseInt>0.0
-TH2F pcal_prshwr_good_pamp_vs_pmt_neg 'SHMS PreShower- Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1] P.cal.pr.goodNegAdcPulseAmp 14 0.5 14.5 200 0 4000 P.cal.pr.goodNegAdcPulseAmp>0.0
-TH2F pcal_prshwr_good_ptime_vs_pmt_neg 'SHMS PreShower- Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1] P.cal.pr.goodNegAdcPulseTime 14 0.5 14.5 350 0 3500 P.cal.pr.goodNegAdcPulseTime>0.0
-
-#------------------------------------------------------
-# SHMS PRE-SHOWER ENERGY DEPOSITION vs. PMT HISTOGRAMS 
-# (calib consts (GAIN) are in GeV/ADC units )
-#------------------------------------------------------
-
-TH2F pcal_prshwr_Epos_vs_pmt 'SHMS PreShower+ Energy Deposition vs. PMT Number; PMT Number; Energy Deposition (0.01 GeV / ADC Units)' [I+1] P.cal.pr.epos 14 0.5 14.5 200 0 2 P.cal.pr.epos>0.0
-TH2F pcal_prshwr_Eneg_vs_pmt 'SHMS PreShower- Energy Deposition vs. PMT Number; PMT Number; Energy Deposition (0.01 GeV / ADC Units)' [I+1] P.cal.pr.eneg 14 0.5 14.5 200 0 2 P.cal.pr.eneg>0.0
-TH2F pcal_prshwr_Emean_vs_pmt 'SHMS PreShower Mean Energy Deposition vs. PMT Number; PMT Number; Mean Energy Deposition (0.01 GeV / ADC Units)' [I+1] P.cal.pr.emean 14 0.5 14.5 300 0 3 P.cal.pr.emean>0.0
-
-#-------------------------------------------
-# SHMS ENERGY DEPOSITION in PreShower PLANE
-#-------------------------------------------
-
-TH1F pcal_prshwr_Eplane_pos 'SHMS PreShower+ Energy Deposition; Energy Deposition (GeV); Number of Entries / 0.01 GeV' P.cal.pr.eplane_pos 200 0 2 P.cal.pr.eplane_pos>0.0
-TH1F pcal_prshwr_Eplane_neg 'SHMS PreShower- Energy Deposition; Energy Deposition (GeV); Number of Entries / 0.01 GeV' P.cal.pr.eplane_neg 200 0 2 P.cal.pr.eplane_neg>0.0
-TH1F pcal_prshwr_Eplane 'SHMS PreShower Total Energy Deposition; Total Energy Deposition (GeV); Number of Entries / 0.01 GeV' P.cal.pr.eplane 300 0 3 P.cal.pr.eplane>0.0
-
-#---------------------------------------------
-# SHMS Shower GOOD Occupancy and Multiplicity
-#---------------------------------------------
-TH1F pcal_shwr_good_occ 'SHMS Shower Good Occupancy; PMT Number; Number of Good ADC Hits' P.cal.fly.numGoodAdcHits 224 0.5 224.5
-TH1F pcal_shwr_good_mult 'SHMS Shower Good Multiplicity; PMT Number; Total Number of Good ADC Hits' P.cal.fly.totNumGoodAdcHits 224 0.5 224.5
-
-#-------------------------------------------------------------
-# SHMS Shower GOOD PULSE PEDESTALS/INTEGRALS/AMPLITUDES/TIMES
-#-------------------------------------------------------------
-
-TH2F pcal_shwr_good_pped_vs_pmt 'SHMS Shower Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1] P.cal.fly.goodAdcPed 224 0.5 224.5 700 300 1000 P.cal.fly.goodAdcPed>0.0
-TH2F pcal_shwr_good_pi_vs_pmt 'SHMS Shower Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1] P.cal.fly.goodAdcPulseInt 224 0.5 224.5 600 0 30000 P.cal.fly.goodAdcPulseInt>0.0
-TH2F pcal_shwr_good_pamp_vs_pmt 'SHMS Shower Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1] P.cal.fly.goodAdcPulseAmp 224 0.5 224.5 200 0 4000 P.cal.fly.goodAdcPulseAmp>0.0
-TH2F pcal_shwr_good_ptime_vs_pmt 'SHMS Shower Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1] P.cal.fly.goodAdcPulseTime 224 0.5 224.5 350 0 3500 P.cal.fly.goodAdcPulseTime>0.0
-
-#--------------------------------------------------
-# SHMS SHOWER ENERGY DEPOSITION vs. PMT HISTOGRAMS 
-# (calib consts (GAIN) are in GeV/ADC units )
-#--------------------------------------------------
-
-TH2F pcal_shwr_E_vs_pmt 'SHMS Shower Energy Deposition vs. PMT Number; PMT Number; Energy Deposited (0.01 GeV / ADC Units)' [I+1] P.cal.fly.e 224 0.5 224.5 300 0 3 P.cal.fly.e>0.0
-
-#--------------------------------------------------
-# TOTAL ENERGY DEPOSITION IN THE SHMS SHOWER ARRAY
-#--------------------------------------------------
-
-TH1F pcal_shwr_Earray 'SHMS Shower Total Energy Deposition in Array; Total Energy Deposited (GeV); Number of Entries / 0.01 GeV' P.cal.fly.earray 600 0 6 P.cal.fly.earray>0.0
-
 #-------------------------------------------------------------------------------------
 # SHMS PRE-SHOWER AND SHOWER (CALORIMETER) TOTAL ENERGY DEPOSITION
 # TOTAL ENERGY AND NORMALIZED ENERGY DEPOSITED IN CALORIMETER (SHOWER AND PRE-SHOWER)
 #-------------------------------------------------------------------------------------
 
-TH1F pcal_etot 'SHMS Calorimeter Total Energy Deposition; Total Energy Deposition (GeV); Number of Entries / 0.01 GeV' P.cal.etot 500 0 5 P.cal.etot>0.0
-TH1F pcal_etot_norm 'SHMS Calorimeter Total Normalized Energy Deposition; Total Energy Deposited (GeV) / P0 (GeV); Number of Entries / 0.01' P.cal.etotnorm 500 0 5 P.cal.etotnorm>0.0
 TH1F pcal_etrack 'SHMS Calorimeter Total Track Energy; Track Energy Deposited (GeV); Number of Entries / 0.1 GeV' P.cal.etrack 100 0 10 P.cal.etrack>0.0 
 TH1F pcal_etracknorm 'SHMS Calorimeter Normalized Track Energy; Trk. Energy Dep. (GeV) / Trk. P (GeV); Number of Entries / 0.1 ' P.cal.etracknorm 100 0 10 P.cal.etracknorm>0.0
 TH1F pcal_etracknorm_track 'SHMS Calorimeter Normalized Track Energy (Ntrack > 0); Trk. Energy Dep. (GeV) / Trk. P (GeV); Number of Entries / 0.1 ' P.cal.etracknorm 100 0 10 P.cal.etracknorm>0.0&&P.dc.ntrack>0
@@ -93,10 +21,10 @@ TH2F pcal_hgnpe_etrack 'SHMS HG Cer Npe v Cal energy/p' P.cal.etracknorm P.hgcer
 # SHMS PID AND ACCEPTANCE PLOTS
 #-------------------------------
 
-TH2F hgc_vs_prshw 'SHMS HGC Total N.P.E. vs. PreSh Energy; Total PreSh Energy Deposition / 0.01 GeV; HGC Total N.P.E. / 0.5' P.cal.pr.eplane P.hgcer.npeSum 300 0 3 40 0 20 P.cal.pr.eplane>0.0&&P.hgcer.npeSum>0.0 
-TH2F ngc_vs_prshw 'SHMS NGC Total N.P.E. vs. PreSh Energy; Total PreSh Energy Deposition / 0.01 GeV; NGC Total N.P.E. / 0.5' P.cal.pr.eplane P.ngcer.npeSum 300 0 3 40 0 20 P.cal.pr.eplane>0.0&&P.ngcer.npeSum>0.0 
-TH2F pcal_shw_vs_prshw 'Shower vs. PreShower Energy Deposition; PreShower Energy / 0.1 GeV; Shower Energy / 0.1 GeV' P.cal.pr.eplane P.cal.fly.earray 50 0 5 350 0 35  P.cal.pr.eplane>0.0&&P.cal.fly.earray>0.0 
-TH2F delta_vs_etracknorm 'SHMS Delta. vs. Normalized Track Energy; Calorimeter Normalized Track Energy; Momentum Acceptance (%)' P.cal.etracknorm P.gtr.dp 50 0 5 80 -15, 25 P.cal.etracknorm>0.0&&P.dc.ntrack>0 
+TH2F ngc_vs_prshw 'SHMS NGC Total N.P.E. vs. PreSh Energy; Total PreSh Energy Deposition / 0.01 GeV; NGC Total N.P.E. / 0.5' P.cal.pr.eplane P.ngcer.npeSum 400 0 4 80 0 40 P.cal.pr.eplane>0.0&&P.ngcer.npeSum>0.0 
+TH2F hgc_vs_prshw 'SHMS HGC Total N.P.E. vs. PreSh Energy; Total PreSh Energy Deposition / 0.01 GeV; HGC Total N.P.E. / 0.5' P.cal.pr.eplane P.hgcer.npeSum 400 0 4 80 0 40 P.cal.pr.eplane>0.0&&P.hgcer.npeSum>0.0 
+TH2F pcal_shw_vs_prshw 'Shower vs. PreShower Energy Deposition; PreShower Energy / 0.01 GeV; Shower Energy / 0.01 GeV' P.cal.pr.eplane P.cal.fly.earray 400 0 4 1200 0 12 P.cal.pr.eplane>0.0&&P.cal.fly.earray>0.0 
+TH2F delta_vs_etracknorm 'SHMS Delta. vs. Normalized Track Energy; Calorimeter Normalized Track Energy; Momentum Acceptance / 0.1 %' P.cal.etracknorm P.gtr.dp 200 0 2 400 -15 25 P.cal.etracknorm>0.0&&P.dc.ntrack>0 
 
 #---------------------------
 #  CLUSTERING PLOTS
@@ -107,4 +35,4 @@ TH1F pcal_xdiff 'SHMS Cal X pos - X track' P.cal.xclusttrack-P.cal.xtrack 200 -2
 TH2F pcal_xdiff_v_xtr 'SHMS Cal X pos - X track v Xtr' P.cal.xtrack P.cal.xclusttrack-P.cal.xtrack 200 -100. 100. 200 -20. 20. P.cal.nclusttrack>-1&&P.dc.ntrack>0
 TH1F pcal_xtrack 'SHMS Cal X pos of track' P.cal.xtrack 200 -100. 100. P.cal.nclusttrack>-1&&P.dc.ntrack>0
 TH1F pcal_xtrack1 'SHMS Cal X pos of track no matching clust' P.cal.xtrack 200 -100. 100. P.cal.nclusttrack==-1&&P.gtr.dp>-8.&&P.gtr.dp<8.&&P.dc.ntrack>0
-TH1F pcal_xtrack2 'SHMS Cal X pos of track no matching clust number of cluster=1' P.cal.xtrack 200 -100. 100. P.cal.nclusttrack==-1&&P.cal.nclust==0&&P.gtr.dp>-8.&&P.gtr.dp<8.&&P.dc.ntrack>0
\ No newline at end of file
+TH1F pcal_xtrack2 'SHMS Cal X pos of track no matching clust number of cluster=1' P.cal.xtrack 200 -100. 100. P.cal.nclusttrack==-1&&P.cal.nclust==0&&P.gtr.dp>-8.&&P.gtr.dp<8.&&P.dc.ntrack>0
diff --git a/DEF-files/SHMS/PRODUCTION/DC/pdc_histos.def b/DEF-files/SHMS/PRODUCTION/DC/pdc_histos.def
index beaa5c050c160a95a2aa050ddce46ad0f23ab7c3..78e6874fecf0fda875b1af6c7caee814cb6508b2 100644
--- a/DEF-files/SHMS/PRODUCTION/DC/pdc_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/DC/pdc_histos.def
@@ -2,4 +2,3 @@
 # SHMS Drift Chambers *
 #**********************
 
-#include "DEF-files/SHMS/TEST_STANDS/DC/pdcana.def"
\ No newline at end of file
diff --git a/DEF-files/SHMS/PRODUCTION/HGCER/phgcer_histos.def b/DEF-files/SHMS/PRODUCTION/HGCER/phgcer_histos.def
index 82bae8b9ef9dd724f29f47655f9fd39f9f1be302..2aa73688590148ea2aa00761036f3b4020ec72ac 100644
--- a/DEF-files/SHMS/PRODUCTION/HGCER/phgcer_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/HGCER/phgcer_histos.def
@@ -2,38 +2,9 @@
 # Heavy Gas Cherenkov *
 #**********************
 
-#-----------------------------------------
-# SHMS HGC GOOD Occupancy and Multiplicity
-#-----------------------------------------
-
-TH1F phgcer_good_occ 'SHMS Heavy Gas Cherenkov Good Occupancy; PMT Number; Number Good ADC Hits' P.hgcer.numGoodAdcHits 4 0.5 4.5
-TH1F phgcer_good_mult 'SHMS Heavy Gas Cherenkov Good Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.hgcer.totNumGoodAdcHits 4 0.5 4.5
-
-#-------------------------------------------------------------------------------
-# SHMS HGC GOOD Pulse Pedestal / Integral / Raw Integral / Amplitude / Time 
-# GOOD --> (passed errorFlag cut and pulsetime cuts oN Min/Max ADC Time Window) 
-#-------------------------------------------------------------------------------
-
-TH2F phgcer_good_pped_vs_pmt 'SHMS Heavy Gas Cherenkov Good Pulse Pedestal vs. PMT Number; PMT Number; Pulse Pedestal / 1 ADC Units' [I+1] P.hgcer.goodAdcPed 4 0.5 4.5 400 300 700
-TH2F phgcer_good_pi_vs_pmt 'SHMS Heavy Gas Cherenkov Good Pulse Integral vs. PMT Number; PMT Number; Pulse Integral / 50 ADC Units' [I+1] P.hgcer.goodAdcPulseInt 4 0.5 4.5 600 0 30000 P.hgcer.goodAdcPulseInt>0.0
-TH2F phgcer_good_pamp_vs_pmt 'SHMS Heavy Gas Cherenkov Good Pulse Amplitude vs. PMT Number; PMT Number; Pulse Amplitude / 20 ADC Units' [I+1] P.hgcer.goodAdcPulseAmp 4 0.5 4.5 200 0 4000 P.hgcer.goodAdcPulseAmp>0.0
-TH2F phgcer_good_ptime_vs_pmt 'SHMS Heavy Gas Cherenkov Good Pulse Time vs. PMT Number; PMT Number; Pulse Time / 10 ADC Units' [I+1] P.hgcer.goodAdcPulseTime 4 0.5 4.5 350 0 3500 P.hgcer.goodAdcPulseTime>0.0
-
-#-------------------------------
-# SHMS HGC Number of P.E. / PMT
-#-------------------------------
-
-TH2F phgcer_npe 'SHMS Heavy Gas Cherenkov Number of Photoelectrons vs. PMT Number; PMT Number; Number of Photoelectrons / PMT' [I+1] P.hgcer.npe 4 0.5 4.5 200 0 100 P.hgcer.npe>0.0 
-
-#-------------------------------
-# SHMS HGC TOTAL NUMBER OF P.E.
-#-------------------------------
-
-TH1F phgcer_tot_npe 'SHMS Heavy Gas Cherenkov Total Number of Photoelectrons; Total Number of Photoelectrons; Number of Entries / 0.5 Photoelectrons' P.hgcer.npeSum 200 0 100 P.hgcer.npeSum>0.0 
-
 #--------------------------
 # SHMS HGC TRACK MATCHING
 #--------------------------
 
 sTH1F phgcer_trk_match 'SHMS Noble Gas Cherenkov Track Matches; PMT Number; Number of Tracks Matched' P.hgcer.numTracksMatched 4 0.5 4.5
-sTH1F phgcer_trk_fired 'SHMS Noble Gas Cherenkov Tracks Fired; PMT Number; Number of Tracks Fired' P.hgcer.numTracksFired 4 0.5 4.5
\ No newline at end of file
+sTH1F phgcer_trk_fired 'SHMS Noble Gas Cherenkov Tracks Fired; PMT Number; Number of Tracks Fired' P.hgcer.numTracksFired 4 0.5 4.5
diff --git a/DEF-files/SHMS/PRODUCTION/HODO/phodo_histos.def b/DEF-files/SHMS/PRODUCTION/HODO/phodo_histos.def
index f74d4284869e2582076ed3521069e28dde9cd6c7..aaac30206bf3d5b24e9d9ebce779418103a98819 100644
--- a/DEF-files/SHMS/PRODUCTION/HODO/phodo_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/HODO/phodo_histos.def
@@ -2,170 +2,6 @@
 # SHMS HODOSCOPES
 #*****************
 
-#-----------------------------------
-# SHMS HODO GOOD ADC Multiplicities 
-#-----------------------------------
-
-TH1F phodo_1x_good_adc_mult_pos 'SHMS 1X+ Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good +ADC Hits' P.hod.1x.totNumGoodPosAdcHits 13 0.5 13.5
-TH1F phodo_1y_good_adc_mult_pos 'SHMS 1Y+ Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good +ADC Hits' P.hod.1y.totNumGoodPosAdcHits 13 0.5 13.5
-TH1F phodo_2x_good_adc_mult_pos 'SHMS 2X+ Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good +ADC Hits' P.hod.2x.totNumGoodPosAdcHits 14 0.5 14.5
-TH1F phodo_2y_good_adc_mult_pos 'SHMS 2Y+ Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good +ADC Hits' P.hod.2y.totNumGoodPosAdcHits 21 0.5 21.5
-
-TH1F phodo_1x_good_adc_mult_neg 'SHMS 1X- Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good -ADC Hits' P.hod.1x.totNumGoodNegAdcHits 13 0.5 13.5
-TH1F phodo_1y_good_adc_mult_neg 'SHMS 1Y- Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good -ADC Hits' P.hod.1y.totNumGoodNegAdcHits 13 0.5 13.5
-TH1F phodo_2x_good_adc_mult_neg 'SHMS 2X- Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good -ADC Hits' P.hod.2x.totNumGoodNegAdcHits 14 0.5 14.5
-TH1F phodo_2y_good_adc_mult_neg 'SHMS 2Y- Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good -ADC Hits' P.hod.2y.totNumGoodNegAdcHits 21 0.5 21.5
-
-TH1F phodo_1x_good_adc_mult 'SHMS 1X Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.hod.1x.totNumGoodAdcHits 13 0.5 13.5
-TH1F phodo_1y_good_adc_mult 'SHMS 1Y Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.hod.1y.totNumGoodAdcHits 13 0.5 13.5
-TH1F phodo_2x_good_adc_mult 'SHMS 2X Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.hod.2x.totNumGoodAdcHits 14 0.5 14.5
-TH1F phodo_2y_good_adc_mult 'SHMS 2Y Good ADC Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.hod.2y.totNumGoodAdcHits 21 0.5 21.5
-
-#-----------------------------------
-# SHMS HODO Good TDC Multiplicities
-#-----------------------------------
-
-TH1F phodo_1x_good_tdc_mult_pos 'SHMS 1X+ Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good +TDC Hits' P.hod.1x.totNumGoodPosTdcHits 13 0.5 13.5
-TH1F phodo_1y_good_tdc_mult_pos 'SHMS 1Y+ Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good +TDC Hits' P.hod.1y.totNumGoodPosTdcHits 13 0.5 13.5
-TH1F phodo_2x_good_tdc_mult_pos 'SHMS 2X+ Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good +TDC Hits' P.hod.2x.totNumGoodPosTdcHits 14 0.5 14.5
-TH1F phodo_2y_good_tdc_mult_pos 'SHMS 2Y+ Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good +TDC Hits' P.hod.2y.totNumGoodPosTdcHits 21 0.5 21.5
-
-TH1F phodo_1x_good_tdc_mult_neg 'SHMS 1X- Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good -TDC Hits' P.hod.1x.totNumGoodNegTdcHits 13 0.5 13.5
-TH1F phodo_1y_good_tdc_mult_neg 'SHMS 1Y- Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good -TDC Hits' P.hod.1y.totNumGoodNegTdcHits 13 0.5 13.5
-TH1F phodo_2x_good_tdc_mult_neg 'SHMS 2X- Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good -TDC Hits' P.hod.2x.totNumGoodNegTdcHits 14 0.5 14.5
-TH1F phodo_2y_good_tdc_mult_neg 'SHMS 2Y- Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good -TDC Hits' P.hod.2y.totNumGoodNegTdcHits 21 0.5 21.5
-
-TH1F phodo_1x_good_tdc_mult 'SHMS 1X Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good TDC Hits' P.hod.1x.totNumGoodTdcHits 13 0.5 13.5
-TH1F phodo_1y_good_tdc_mult 'SHMS 1Y Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good TDC Hits' P.hod.1y.totNumGoodTdcHits 13 0.5 13.5
-TH1F phodo_2x_good_tdc_mult 'SHMS 2X Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good TDC Hits' P.hod.2x.totNumGoodTdcHits 14 0.5 14.5
-TH1F phodo_2y_good_tdc_mult 'SHMS 2Y Good TDC Multiplicity; Number of PMTs Hit; Total Number of Good TDC Hits' P.hod.2y.totNumGoodTdcHits 21 0.5 21.5
-
-#---------------------------------
-# SHMS HODO GOOD ADC OCCUPANCIES
-#---------------------------------
-
-TH1F phodo_1x_good_adc_occ_pos 'SHMS 1X+ Good ADC Occupancy; PMT Number; Number of Good +ADC Hits' P.hod.1x.numGoodPosAdcHits 13 0.5 13.5
-TH1F phodo_1y_good_adc_occ_pos 'SHMS 1Y+ Good ADC Occupancy; PMT Number; Number of Good +ADC Hits' P.hod.1y.numGoodPosAdcHits 13 0.5 13.5 
-TH1F phodo_2x_good_adc_occ_pos 'SHMS 2X+ Good ADC Occupancy; PMT Number; Number of Good +ADC Hits' P.hod.2x.numGoodPosAdcHits 14 0.5 14.5
-TH1F phodo_2y_good_adc_occ_pos 'SHMS 2Y+ Good ADC Occupancy; PMT Number; Number of Good +ADC Hits' P.hod.2y.numGoodPosAdcHits 21 0.5 21.5
-
-TH1F phodo_1x_good_adc_occ_neg 'SHMS 1X- Good ADC Occupancy; PMT Number; Number of Good -ADC Hits' P.hod.1x.numGoodNegAdcHits 13 0.5 13.5
-TH1F phodo_1y_good_adc_occ_neg 'SHMS 1Y- Good ADC Occupancy; PMT Number; Number of Good -ADC Hits' P.hod.1y.numGoodNegAdcHits 13 0.5 13.5 
-TH1F phodo_2x_good_adc_occ_neg 'SHMS 2X- Good ADC Occupancy; PMT Number; Number of Good -ADC Hits' P.hod.2x.numGoodNegAdcHits 14 0.5 14.5
-TH1F phodo_2y_good_adc_occ_neg 'SHMS 2Y- Good ADC Occupancy; PMT Number; Number of Good -ADC Hits' P.hod.2y.numGoodNegAdcHits 21 0.5 21.5
-
-#--------------------------------
-# SHMS HODO GOOD TDC OCCUPANCIES
-#--------------------------------
-
-TH1F phodo_1x_good_tdc_occ_pos 'SHMS 1X+ Good TDC Occupancy; PMT Number; Number of Good +TDC Hits' P.hod.1x.numGoodPosTdcHits 13 0.5 13.5
-TH1F phodo_1y_good_tdc_occ_pos 'SHMS 1Y+ Good TDC Occupancy; PMT Number; Number of Good +TDC Hits' P.hod.1y.numGoodPosTdcHits 13 0.5 13.5 
-TH1F phodo_2x_good_tdc_occ_pos 'SHMS 2X+ Good TDC Occupancy; PMT Number; Number of Good +TDC Hits' P.hod.2x.numGoodPosTdcHits 14 0.5 14.5
-TH1F phodo_2y_good_tdc_occ_pos 'SHMS 2Y+ Good TDC Occupancy; PMT Number; Number of Good +TDC Hits' P.hod.2y.numGoodPosTdcHits 21 0.5 21.5
-
-TH1F phodo_1x_good_tdc_occ_neg 'SHMS 1X- Good TDC Occupancy; PMT Number; Number of Good -TDC Hits' P.hod.1x.numGoodNegTdcHits 13 0.5 13.5
-TH1F phodo_1y_good_tdc_occ_neg 'SHMS 1Y- Good TDC Occupancy; PMT Number; Number of Good -TDC Hits' P.hod.1y.numGoodNegTdcHits 13 0.5 13.5 
-TH1F phodo_2x_good_tdc_occ_neg 'SHMS 2X- Good TDC Occupancy; PMT Number; Number of Good -TDC Hits' P.hod.2x.numGoodNegTdcHits 14 0.5 14.5
-TH1F phodo_2y_good_tdc_occ_neg 'SHMS 2Y- Good TDC Occupancy; PMT Number; Number of Good -TDC Hits' P.hod.2y.numGoodNegTdcHits 21 0.5 21.5
-
-#---------------------
-# GOOD PULSE PEDESTAL
-#---------------------
-
-TH2F phodo_1x_good_pped_vs_pmt_pos 'SHMS 1X+ Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.1x.GoodPosAdcPed 13 0.5 13.5 400 300 700 P.hod.1x.GoodPosAdcPed>0.0
-TH2F phodo_1y_good_pped_vs_pmt_pos 'SHMS 1Y+ Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.1y.GoodPosAdcPed 13 0.5 13.5 400 300 700 P.hod.1y.GoodPosAdcPed>0.0
-TH2F phodo_2x_good_pped_vs_pmt_pos 'SHMS 2X+ Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.2x.GoodPosAdcPed 14 0.5 14.5 400 300 700 P.hod.2x.GoodPosAdcPed>0.0
-TH2F phodo_2y_good_pped_vs_pmt_pos 'SHMS 2Y+ Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.2y.GoodPosAdcPed 21 0.5 21.5 400 300 700 P.hod.2y.GoodPosAdcPed>0.0
-
-TH2F phodo_1x_good_pped_vs_pmt_neg 'SHMS 1X- Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.1x.GoodNegAdcPed 13 0.5 13.5 400 300 700 P.hod.1x.GoodNegAdcPed>0.0
-TH2F phodo_1y_good_pped_vs_pmt_neg 'SHMS 1Y- Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.1y.GoodNegAdcPed 13 0.5 13.5 400 300 700 P.hod.1y.GoodNegAdcPed>0.0
-TH2F phodo_2x_good_pped_vs_pmt_neg 'SHMS 2X- Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.2x.GoodNegAdcPed 14 0.5 14.5 400 300 700 P.hod.2x.GoodNegAdcPed>0.0
-TH2F phodo_2y_good_pped_vs_pmt_neg 'SHMS 2Y- Good Pulse Pedestal vs. PMT Number; PMT Number; Good Pulse Pedestal / 1 ADC Unit' [I+1]  P.hod.2y.GoodNegAdcPed 21 0.5 21.5 400 300 700 P.hod.2y.GoodNegAdcPed>0.0
-
-#---------------------
-# GOOD PULSE INTEGRAL
-#---------------------
-
-TH2F phodo_1x_good_pi_vs_pmt_pos 'SHMS 1X+ Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.1x.GoodPosAdcPulseInt 13 0.5 13.5 600 0 30000 P.hod.1x.GoodPosAdcPulseInt>0.0
-TH2F phodo_1y_good_pi_vs_pmt_pos 'SHMS 1Y+ Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.1y.GoodPosAdcPulseInt 13 0.5 13.5 600 0 30000 P.hod.1y.GoodPosAdcPulseInt>0.0
-TH2F phodo_2x_good_pi_vs_pmt_pos 'SHMS 2X+ Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.2x.GoodPosAdcPulseInt 14 0.5 14.5 600 0 30000 P.hod.2x.GoodPosAdcPulseInt>0.0
-TH2F phodo_2y_good_pi_vs_pmt_pos 'SHMS 2Y+ Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.2y.GoodPosAdcPulseInt 21 0.5 21.5 600 0 30000 P.hod.2y.GoodPosAdcPulseInt>0.0
-
-TH2F phodo_1x_good_pi_vs_pmt_neg 'SHMS 1X- Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.1x.GoodNegAdcPulseInt 13 0.5 13.5 600 0 30000 P.hod.1x.GoodNegAdcPulseInt>0.0
-TH2F phodo_1y_good_pi_vs_pmt_neg 'SHMS 1Y- Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.1y.GoodNegAdcPulseInt 13 0.5 13.5 600 0 30000 P.hod.1y.GoodNegAdcPulseInt>0.0
-TH2F phodo_2x_good_pi_vs_pmt_neg 'SHMS 2X- Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.2x.GoodNegAdcPulseInt 14 0.5 14.5 600 0 30000 P.hod.2x.GoodNegAdcPulseInt>0.0
-TH2F phodo_2y_good_pi_vs_pmt_neg 'SHMS 2Y- Good Pulse Integral vs. PMT Number; PMT Number; Good Pulse Integral / 50 ADC Units' [I+1]  P.hod.2y.GoodNegAdcPulseInt 21 0.5 21.5 600 0 30000 P.hod.2y.GoodNegAdcPulseInt>0.0
-
-#-----------------------
-# GOOD PULSE AMPLITUDE 
-#-----------------------
-
-TH2F phodo_1x_good_pamp_vs_pmt_pos 'SHMS 1X+ Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.1x.GoodPosAdcPulseAmp 13 0.5 13.5 205 0 4100 P.hod.1x.GoodPosAdcPulseAmp>0.0
-TH2F phodo_1y_good_pamp_vs_pmt_pos 'SHMS 1Y+ Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.1y.GoodPosAdcPulseAmp 13 0.5 13.5 205 0 4100 P.hod.1y.GoodPosAdcPulseAmp>0.0
-TH2F phodo_2x_good_pamp_vs_pmt_pos 'SHMS 2X+ Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.2x.GoodPosAdcPulseAmp 14 0.5 14.5 205 0 4100 P.hod.2x.GoodPosAdcPulseAmp>0.0
-TH2F phodo_2y_good_pamp_vs_pmt_pos 'SHMS 2Y+ Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.2y.GoodPosAdcPulseAmp 21 0.5 21.5 205 0 4100 P.hod.2y.GoodPosAdcPulseAmp>0.0
-
-TH2F phodo_1x_good_pamp_vs_pmt_neg 'SHMS 1X- Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.1x.GoodNegAdcPulseAmp 13 0.5 13.5 205 0 4100 P.hod.1x.GoodNegAdcPulseAmp>0.0
-TH2F phodo_1y_good_pamp_vs_pmt_neg 'SHMS 1Y- Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.1y.GoodNegAdcPulseAmp 13 0.5 13.5 205 0 4100 P.hod.1y.GoodNegAdcPulseAmp>0.0
-TH2F phodo_2x_good_pamp_vs_pmt_neg 'SHMS 2X- Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.2x.GoodNegAdcPulseAmp 14 0.5 14.5 205 0 4100 P.hod.2x.GoodNegAdcPulseAmp>0.0
-TH2F phodo_2y_good_pamp_vs_pmt_neg 'SHMS 2Y- Good Pulse Amplitude vs. PMT Number; PMT Number; Good Pulse Amplitude / 20 ADC Units' [I+1]  P.hod.2y.GoodNegAdcPulseAmp 21 0.5 21.5 205 0 4100 P.hod.2y.GoodNegAdcPulseAmp>0.0
-
-#---------------------
-# GOOD ADC PULSE TIME
-#---------------------
-
-TH2F phodo_1x_good_ptime_vs_pmt_pos 'SHMS 1X+ Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.1x.GoodPosAdcPulseTime 13 0.5 13.5 410 0 4100 P.hod.1x.GoodPosAdcPulseTime>0.0
-TH2F phodo_1y_good_ptime_vs_pmt_pos 'SHMS 1Y+ Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.1y.GoodPosAdcPulseTime 13 0.5 13.5 410 0 4100 P.hod.1y.GoodPosAdcPulseTime>0.0
-TH2F phodo_2x_good_ptime_vs_pmt_pos 'SHMS 2X+ Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.2x.GoodPosAdcPulseTime 14 0.5 14.5 410 0 4100 P.hod.2x.GoodPosAdcPulseTime>0.0
-TH2F phodo_2y_good_ptime_vs_pmt_pos 'SHMS 2Y+ Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.2y.GoodPosAdcPulseTime 21 0.5 21.5 410 0 4100 P.hod.2y.GoodPosAdcPulseTime>0.0
-
-TH2F phodo_1x_good_ptime_vs_pmt_neg 'SHMS 1X- Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.1x.GoodNegAdcPulseTime 13 0.5 13.5 410 0 4100 P.hod.1x.GoodNegAdcPulseTime>0.0
-TH2F phodo_1y_good_ptime_vs_pmt_neg 'SHMS 1Y- Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.1y.GoodNegAdcPulseTime 13 0.5 13.5 410 0 4100 P.hod.1y.GoodNegAdcPulseTime>0.0
-TH2F phodo_2x_good_ptime_vs_pmt_neg 'SHMS 2X- Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.2x.GoodNegAdcPulseTime 14 0.5 14.5 410 0 4100 P.hod.2x.GoodNegAdcPulseTime>0.0
-TH2F phodo_2y_good_ptime_vs_pmt_neg 'SHMS 2Y- Good Pulse Time vs. PMT Number; PMT Number; Good Pulse Time / 10 ADC Units' [I+1]  P.hod.2y.GoodNegAdcPulseTime 21 0.5 21.5 410 0 4100 P.hod.2y.GoodNegAdcPulseTime>0.0
-
-#---------------------------------------------------------
-# GOOD TDC TIME UNCORRECTED (uncorrected for time offsets)
-#---------------------------------------------------------
-
-TH2F phodo_1x_good_tdctime_uncorr_vs_pmt_pos 'SHMS 1X+ Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1x.GoodPosTdcTimeUnCorr 13 0.5 13.5 120 0 120 P.hod.1x.GoodPosTdcTimeUnCorr>0.0
-TH2F phodo_1y_good_tdctime_uncorr_vs_pmt_pos 'SHMS 1Y+ Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1y.GoodPosTdcTimeUnCorr 13 0.5 13.5 120 0 120 P.hod.1y.GoodPosTdcTimeUnCorr>0.0
-TH2F phodo_2x_good_tdctime_uncorr_vs_pmt_pos 'SHMS 2X+ Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2x.GoodPosTdcTimeUnCorr 14 0.5 14.5 120 0 120 P.hod.2x.GoodPosTdcTimeUnCorr>0.0
-TH2F phodo_2y_good_tdctime_uncorr_vs_pmt_pos 'SHMS 2Y+ Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2y.GoodPosTdcTimeUnCorr 21 0.5 21.5 120 0 120 P.hod.2y.GoodPosTdcTimeUnCorr>0.0
-
-TH2F phodo_1x_good_tdctime_uncorr_vs_pmt_neg 'SHMS 1X- Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1x.GoodNegTdcTimeUnCorr 13 0.5 13.5 120 0 120 P.hod.1x.GoodNegTdcTimeUnCorr>0.0
-TH2F phodo_1y_good_tdctime_uncorr_vs_pmt_neg 'SHMS 1Y- Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1y.GoodNegTdcTimeUnCorr 13 0.5 13.5 120 0 120 P.hod.1y.GoodNegTdcTimeUnCorr>0.0
-TH2F phodo_2x_good_tdctime_uncorr_vs_pmt_neg 'SHMS 2X- Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2x.GoodNegTdcTimeUnCorr 14 0.5 14.5 120 0 120 P.hod.2x.GoodNegTdcTimeUnCorr>0.0
-TH2F phodo_2y_good_tdctime_uncorr_vs_pmt_neg 'SHMS 2Y- Good Uncorrected TDC Time vs. PMT Number; PMT Number; Good Uncorrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2y.GoodNegTdcTimeUnCorr 21 0.5 21.5 120 0 120 P.hod.2y.GoodNegTdcTimeUnCorr>0.0
-
-#-----------------------------------------------------
-# GOOD TDC TIME CORRECTED (corrected for time offsets)
-#-----------------------------------------------------
-
-TH2F phodo_1x_good_tdctime_corr_vs_pmt_pos 'SHMS 1X+ Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1x.GoodPosTdcTimeCorr 13 0.5 13.5 120 0 120 P.hod.1x.GoodPosTdcTimeCorr>0.0
-TH2F phodo_1y_good_tdctime_corr_vs_pmt_pos 'SHMS 1Y+ Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1y.GoodPosTdcTimeCorr 13 0.5 13.5 120 0 120 P.hod.1y.GoodPosTdcTimeCorr>0.0
-TH2F phodo_2x_good_tdctime_corr_vs_pmt_pos 'SHMS 2X+ Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2x.GoodPosTdcTimeCorr 14 0.5 14.5 120 0 120 P.hod.2x.GoodPosTdcTimeCorr>0.0
-TH2F phodo_2y_good_tdctime_corr_vs_pmt_pos 'SHMS 2Y+ Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2y.GoodPosTdcTimeCorr 21 0.5 21.5 120 0 120 P.hod.2y.GoodPosTdcTimeCorr>0.0
-
-TH2F phodo_1x_good_tdctime_corr_vs_pmt_neg 'SHMS 1X- Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1x.GoodNegTdcTimeCorr 13 0.5 13.5 120 0 120 P.hod.1x.GoodNegTdcTimeCorr>0.0
-TH2F phodo_1y_good_tdctime_corr_vs_pmt_neg 'SHMS 1Y- Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1y.GoodNegTdcTimeCorr 13 0.5 13.5 120 0 120 P.hod.1y.GoodNegTdcTimeCorr>0.0
-TH2F phodo_2x_good_tdctime_corr_vs_pmt_neg 'SHMS 2X- Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2x.GoodNegTdcTimeCorr 14 0.5 14.5 120 0 120 P.hod.2x.GoodNegTdcTimeCorr>0.0
-TH2F phodo_2y_good_tdctime_corr_vs_pmt_neg 'SHMS 2Y- Good Corrected TDC Time vs. PMT Number; PMT Number; Good Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2y.GoodNegTdcTimeCorr 21 0.5 21.5 120 0 120 P.hod.2y.GoodNegTdcTimeCorr>0.0
-
-#-----------------------------------------------------------
-# GOOD TDC TIME TOF CORRECTED (corrected for time of flight) 
-#-----------------------------------------------------------
-
-TH2F phodo_1x_good_tdctime_tofcorr_vs_pmt_pos 'SHMS 1X+ Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1x.GoodPosTdcTimeTOFCorr 13 0.5 13.5 120 0 120 P.hod.1x.GoodPosTdcTimeTOFCorr>0.0
-TH2F phodo_1y_good_tdctime_tofcorr_vs_pmt_pos 'SHMS 1Y+ Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1y.GoodPosTdcTimeTOFCorr 13 0.5 13.5 120 0 120 P.hod.1y.GoodPosTdcTimeTOFCorr>0.0
-TH2F phodo_2x_good_tdctime_tofcorr_vs_pmt_pos 'SHMS 2X+ Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2x.GoodPosTdcTimeTOFCorr 14 0.5 14.5 120 0 120 P.hod.2x.GoodPosTdcTimeTOFCorr>0.0
-TH2F phodo_2y_good_tdctime_tofcorr_vs_pmt_pos 'SHMS 2Y+ Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2y.GoodPosTdcTimeTOFCorr 21 0.5 21.5 120 0 120 P.hod.2y.GoodPosTdcTimeTOFCorr>0.0
-
-TH2F phodo_1x_good_tdctime_tofcorr_vs_pmt_neg 'SHMS 1X- Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1x.GoodNegTdcTimeTOFCorr 13 0.5 13.5 120 0 120 P.hod.1x.GoodNegTdcTimeTOFCorr>0.0
-TH2F phodo_1y_good_tdctime_tofcorr_vs_pmt_neg 'SHMS 1Y- Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.1y.GoodNegTdcTimeTOFCorr 13 0.5 13.5 120 0 120 P.hod.1y.GoodNegTdcTimeTOFCorr>0.0
-TH2F phodo_2x_good_tdctime_tofcorr_vs_pmt_neg 'SHMS 2X- Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2x.GoodNegTdcTimeTOFCorr 14 0.5 14.5 120 0 120 P.hod.2x.GoodNegTdcTimeTOFCorr>0.0
-TH2F phodo_2y_good_tdctime_tofcorr_vs_pmt_neg 'SHMS 2Y- Good TOF Corrected TDC Time vs. PMT Number; PMT Number; Good TOF Corrected TDC Time / 1 TDC Unit' [I+1]  P.hod.2y.GoodNegTdcTimeTOFCorr 21 0.5 21.5 120 0 120 P.hod.2y.GoodNegTdcTimeTOFCorr>0.0
-
 #----------------------------------------------------------------
 # SHMS HODO TRACKING, TIMING  AND  Particle ID (PID) - BETA (v/c) 
 #----------------------------------------------------------------
@@ -174,4 +10,4 @@ TH1F phodo_beta_notrack 'SHMS Hodo Calculated Beta Without Track Info; Beta; Num
 TH1F phodo_beta 'SHMS Hodo Beta; Beta; Number of Entries / 0.02' P.hod.beta 100 0 2.0 P.hod.beta>0.0
 TH1F phodo_fpHitsTime 'SHMS Hodo Focal Plane Time; Focal Plane Time (ns); Number of Entries / 1 ns' P.hod.fpHitsTime 90 0 90 
 TH1F phodo_starttime 'SHMS Hodo Start Time; Start Time (ns); Number of Entries / 1ns' P.hod.starttime 90 0 90
-TH1F phodo_good_startime 'SHMS Hodo Good Start Time (ns); Good Start Time (ns); Number of Entries / 1ns' P.hod.goodstarttime 90 0 90
\ No newline at end of file
+TH1F phodo_good_startime 'SHMS Hodo Good Start Time (ns); Good Start Time (ns); Number of Entries / 1ns' P.hod.goodstarttime 90 0 90
diff --git a/DEF-files/SHMS/PRODUCTION/KIN/pkin_histos.def b/DEF-files/SHMS/PRODUCTION/KIN/pkin_histos.def
index 83e72e81f8620226fd273d24c02c448ecbd779f3..96f1d9e3390434194f5c9c555039cb0f454e7a83 100644
--- a/DEF-files/SHMS/PRODUCTION/KIN/pkin_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/KIN/pkin_histos.def
@@ -4,8 +4,8 @@
 # Kinematic Quantities
 #*****************************************
 
-TH1F pkin_q2 'SHMS Q2; Q2 (GeV^{2}); Number of Entries / 0.050 GeV^{2}' P.kin.Q2 100 0 5
-TH1F pkin_omega 'SHMS Omega; E_{beam} - E_{scat} (GeV); Number of Entries / 0.050 GeV' P.kin.omega 100 0 5
-TH1F pkin_w2 'SHMS W2; W2 (GeV^{2}); Number of Entries / 0.100 GeV^{2}' P.kin.W2 100 0 10
-TH1F pkin_w  'SHMS W; W  (GeV); Number of Entries / 0.050 GeV' P.kin.W 100 0 5
-TH1F pkin_theta 'SHMS Scattering Angle Theta; SHMS Scattering Angle (deg); Number of Entries / 0.06 deg' P.kin.scat_ang_deg 100 12 18
+TH1F pkin_q2 'SHMS 4-Momentum Transfer Q^{2}; Q^{2} (GeV^{2}); Number of Entries / 0.050 GeV^{2}' P.kin.Q2 200 0 10 
+TH1F pkin_omega 'SHMS Energy Transfer Omega; E_{beam} - E_{scat} (GeV); Number of Entries / 0.050 GeV' P.kin.omega 200 0 10
+TH1F pkin_w2 'SHMS Invariant Mass W^{2}; W^{2} (GeV^{2}); Number of Entries / 0.100 GeV^{2}' P.kin.W2 100 0 10
+TH1F pkin_w  'SHMS Invariant Mass W; W  (GeV); Number of Entries / 0.050 GeV' P.kin.W 200 0 10
+TH1F pkin_theta 'SHMS Scattering Angle Theta; SHMS Scattering Angle (deg); Number of Entries / 0.06 deg' P.kin.scat_ang_deg 350 5 40
diff --git a/DEF-files/SHMS/PRODUCTION/NGCER/pngcer_histos.def b/DEF-files/SHMS/PRODUCTION/NGCER/pngcer_histos.def
index 868491e774d9929cc26dfd37b96a70968ed7dca3..f5c3d7d1a4c7060cccc799ce8c9436faedf2c9e7 100644
--- a/DEF-files/SHMS/PRODUCTION/NGCER/pngcer_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/NGCER/pngcer_histos.def
@@ -2,38 +2,9 @@
 # Noble Gas Cherenkov *
 #**********************
 
-#------------------------------------------
-# SHMS NGC GOOD Occupancy and Multiplicity 
-#------------------------------------------
-
-TH1F pngcer_good_occ 'SHMS Noble Gas Cherenkov Good Occupancy; PMT Number; Number of Good ADC Hits' P.ngcer.numGoodAdcHits 4 0.5 4.5
-TH1F pngcer_good_mult 'SHMS Noble Gas Cherenkov Good Multiplicity; Number of PMTs Hit; Total Number of Good ADC Hits' P.ngcer.totNumGoodAdcHits 4 0.5 4.5
-
-#-------------------------------------------------------------------------------
-# SHMS NGC GOOD Pulse Pedestal / Integral / Raw Integral / Amplitude / Time 
-# GOOD --> (passed errorFlag cut and pulsetime cuts oN Min/Max ADC Time Window) 
-#-------------------------------------------------------------------------------
-
-TH2F pngcer_good_pped_vs_pmt 'SHMS Noble Gas Cherenkov Good Pulse Pedestal vs. PMT Number; PMT Number; Pulse Pedestal / 1 ADC Units' [I+1] P.ngcer.goodAdcPed 4 0.5 4.5 400 300 700
-TH2F pngcer_good_pi_vs_pmt 'SHMS Noble Gas Cherenkov Good Pulse Integral vs. PMT Number; PMT Number; Pulse Integral / 50 ADC Units' [I+1] P.ngcer.goodAdcPulseInt 4 0.5 4.5 600 0 30000 P.ngcer.goodAdcPulseInt>0.0
-TH2F pngcer_good_pamp_vs_pmt 'SHMS Noble Gas Cherenkov Good Pulse Amplitude vs. PMT Number; PMT Number; Pulse Amplitude / 20 ADC Units' [I+1] P.ngcer.goodAdcPulseAmp 4 0.5 4.5 200 0 4000 P.ngcer.goodAdcPulseAmp>0.0
-TH2F pngcer_good_ptime_vs_pmt 'SHMS Noble Gas Cherenkov Good Pulse Time vs. PMT Number; PMT Number; Pulse Time / 10 ADC Units' [I+1] P.ngcer.goodAdcPulseTime 4 0.5 4.5 350 0 3500 P.ngcer.goodAdcPulseTime>0.0
-
-#-------------------------------
-# SHMS NGC Number of P.E. / PMT
-#-------------------------------
-
-TH2F pngcer_npe 'SHMS Noble Gas Cherenkov Number of Photoelectrons vs. PMT Number; PMT Number; Number of Photoelectrons / PMT' [I+1] P.ngcer.npe 4 0.5 4.5 200 0 100 P.ngcer.npe>0.0 
-
-#-------------------------------
-# SHMS NGC TOTAL NUMBER OF P.E.
-#-------------------------------
-
-TH1F pngcer_tot_npe 'SHMS Noble Gas Cherenkov Total Number of Photoelectrons; Total Number of Photoelectrons; Number of Entries / 0.5 Photoelectrons' P.ngcer.npeSum 200 0 100 P.ngcer.npeSum>0.0 
-
 #--------------------------
 # SHMS NGC TRACK MATCHING
 #--------------------------
 
 sTH1F pngcer_trk_match 'SHMS Noble Gas Cherenkov Tracks Matches; PMT Number; Number of Tracks Matched' P.ngcer.numTracksMatched 4 0.5 4.5
-sTH1F pngcer_trk_fired 'SHMS Noble Gas Cherenkov Tracks Fired; PMT Number; Number of Tracks Fired' P.ngcer.numTracksFired 4 0.5 4.5
\ No newline at end of file
+sTH1F pngcer_trk_fired 'SHMS Noble Gas Cherenkov Tracks Fired; PMT Number; Number of Tracks Fired' P.ngcer.numTracksFired 4 0.5 4.5
diff --git a/DEF-files/SHMS/PRODUCTION/RASTER/praster_histos.def b/DEF-files/SHMS/PRODUCTION/RASTER/praster_histos.def
index 6edae7a1f88b023512ce4889bbaef36a87fbc328..60cf1fac485dab3c470d487efcb619ceb7d836ba 100644
--- a/DEF-files/SHMS/PRODUCTION/RASTER/praster_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/RASTER/praster_histos.def
@@ -18,5 +18,5 @@ TH1F pFRYA 'SHMS FRYA; FRYA RAW ADC (chan); Counts' P.rb.raster.fryaRawAdc 1000
 TH1F pFRYA_V 'SHMS FRYA; FRYA RAW ADC (Volts); Counts' FRYA_V 1000 0 1.0
 TH1F pFRYB 'SHMS FRYB; FRYB RAW ADC (chan); Counts' P.rb.raster.frybRawAdc 1000 0 100000
 TH1F pFRYB_V 'SHMS FRYB; FRYB RAW ADC (Volts); Counts' FRYB_V 1000 0 1.0
-TH2F pFRA_XvsY 'HMSFRA_XvsY; FRXA RAW ADC (Volts); FRYA RAW ADC (Volts)' FRXA_V FRYA_V 1000 0 1.0 1000 0 1.0
-TH2F pFRB_XvsY 'HMSFRB_XvsY; FRXB RAW ADC (Volts); FRYB RAW ADC (Volts)' FRXB_V FRYB_V 1000 0 1.0 1000 0 1.0
+TH2F pFRA_XvsY 'SHMS FRA X vs Y; FRXA RAW ADC (Volts); FRYA RAW ADC (Volts)' FRXA_V FRYA_V 1000 0 1.0 1000 0 1.0
+TH2F pFRB_XvsY 'SHMS FRB X vs Y; FRXB RAW ADC (Volts); FRYB RAW ADC (Volts)' FRXB_V FRYB_V 1000 0 1.0 1000 0 1.0
diff --git a/DEF-files/SHMS/PRODUCTION/TRIG/ptrig_histos.def b/DEF-files/SHMS/PRODUCTION/TRIG/ptrig_histos.def
index 44a67ad0f9fbb5e8c7bedf71b6f423738fef38aa..405d161ea8369dce5012ecc97084d840551f6243 100644
--- a/DEF-files/SHMS/PRODUCTION/TRIG/ptrig_histos.def
+++ b/DEF-files/SHMS/PRODUCTION/TRIG/ptrig_histos.def
@@ -2,18 +2,6 @@
 # Trigger Apparatus *
 #********************
 
-TH1F ptrig_pngc_sum_pped 'SHMS Noble Gas Sum FADC Pulse Pedestal; Pulse Pedestal; Number of Entries / 1 ADC Units' T.shms.pNGCSUM_adcPed 2000 0 2000
-TH1F ptrig_pngc_sum_pint 'SHMS Noble Gas Sum FADC Pulse Integral; Pulse Integral; Number of Entries / 10 ADC Units' T.shms.pNGCSUM_adcPulseInt 4000 0 40000
-TH1F ptrig_pngc_sum_pamp 'SHMS Noble Gas Sum FADC Pulse Amplitude; Pulse Amplitude; Number of Entries / 1 ADC Units' T.shms.pNGCSUM_adcPulseAmp 4100 0 4100
-TH1F ptrig_pngc_sum_ptime 'SHMS Noble Gas Sum FADC Pulse Time; Pulse Time; Number of Entries / 10 ADC Units' T.shms.pNGCSUM_adcPulseTimeRaw 1000 0 10000
-TH1F ptrig_pngc_sum_tdc 'SHMS Noble Gas Sum TDC Time; TDC Time; Number of Entries / 10 TDC Units' T.shms.pNGCSUM_tdcTime 700 -3500 3500
-
-TH1F ptrig_phgc_sum_pped 'SHMS Heavy Gas Sum FADC Pulse Pedestal; Pulse Pedestal; Number of Entries / 1 ADC Units' T.shms.pHGCSUM_adcPed 2000 0 2000
-TH1F ptrig_phgc_sum_pint 'SHMS Heavy Gas Sum FADC Pulse Integral; Pulse Integral; Number of Entries / 10 ADC Units' T.shms.pHGCSUM_adcPulseInt 4000 0 40000
-TH1F ptrig_phgc_sum_pamp 'SHMS Heavy Gas Sum FADC Pulse Amplitude; Pulse Amplitude; Number of Entries / 1 ADC Units' T.shms.pHGCSUM_adcPulseAmp 4100 0 4100
-TH1F ptrig_phgc_sum_ptime 'SHMS Heavy Gas Sum FADC Pulse Time; Pulse Time; Number of Entries / 10 ADC Units' T.shms.pHGCSUM_adcPulseTimeRaw 1000 0 10000
-TH1F ptrig_phgc_sum_tdc 'SHMS Heavy Gas Sum TDC Time; TDC Time; Number of Entries / 10 TDC Units' T.shms.pHGCSUM_tdcTime 700 -3500 3500
-
 TH1F ptrig_p1x_tdc_mult 'SHMS p1x TDC Multiplicity; Raw TDC Multiplicity; Counts / 10' T.shms.p1X_tdcMultiplicity 11 0 11
 TH1F ptrig_p1y_tdc_mult 'SHMS p1y TDC Multiplicity; Raw TDC Multiplicity; Counts / 10' T.shms.p1Y_tdcMultiplicity 11 0 11
 TH1F ptrig_p2x_tdc_mult 'SHMS p2x TDC Multiplicity; Raw TDC Multiplicity; Counts / 10' T.shms.p2X_tdcMultiplicity 11 0 11
@@ -26,18 +14,6 @@ TH1F ptrig_pT1_tdc_mult 'SHMS p1x/p1y/p2x/p2y Coincidence TDC Multiplicity (Slot
 TH1F ptrig_pT2_tdc_mult 'SHMS p1x/p1y/p2x/p2y Coincidence TDC Multiplicity (Slot 19, Channel 31); Raw TDC Multiplicity; Counts / 10' T.shms.pT2_tdcMultiplicity 11 0 11
 TH1F ptrig_pT3_tdc_mult 'SHMS p1x/p1y/p2x/p2y Coincidence TDC Multiplicity (Slot 19, Channel 38); Raw TDC Multiplicity; Counts / 10' T.shms.pT3_tdcMultiplicity 11 0 11
 
-TH1F ptrig_p1x_tdc 'SHMS p1x TDC Time; Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p1X_tdcTime 350 0 3500
-TH1F ptrig_p1y_tdc 'SHMS p1y TDC Time; Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p1Y_tdcTime 350 0 3500
-TH1F ptrig_p2x_tdc 'SHMS p2x TDC Time; Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p2X_tdcTime 350 0 3500
-TH1F ptrig_p2y_tdc 'SHMS p2y TDC Time; Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p2Y_tdcTime 350 0 3500
-
-TH1F ptrig_p1T_tdc 'SHMS p1x/p1y Coincidence TDC Time; Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p1T_tdcTime 350 0 3500
-TH1F ptrig_p2T_tdc 'SHMS p2x/p2y Coincidence TDC Time; Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p2T_tdcTime 350 0 3500
-
-TH1F ptrig_pT1_tdc 'SHMS p1x/p1y/p2x/p2y Coincidence TDC Time (Slot 20, Channel 15); Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.pT1_tdcTime 350 0 3500
-TH1F ptrig_pT2_tdc 'SHMS p1x/p1y/p2x/p2y Coincidence TDC Time (Slot 19, Channel 31); Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.pT2_tdcTime 350 0 3500
-TH1F ptrig_pT3_tdc 'SHMS p1x/p1y/p2x/p2y Coincidence TDC Time (Slot 19, Channel 38); Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.pT3_tdcTime 350 0 3500
-
 TH1F ptrig_p1x_good_tdc 'SHMS p1x Good TDC Time; Good Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p1X_tdcTime 350 0 3500 T.shms.p1X_tdcMultiplicity==1
 TH1F ptrig_p1y_good_tdc 'SHMS p1y Good TDC Time; Good Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p1Y_tdcTime 350 0 3500 T.shms.p1Y_tdcMultiplicity==1
 TH1F ptrig_p2x_good_tdc 'SHMS p2x Good TDC Time; Good Raw TDC Time (TDC Units); Counts / 10 TDC Units' T.shms.p2X_tdcTime 350 0 3500 T.shms.p2X_tdcMultiplicity==1
@@ -53,15 +29,4 @@ TH1F ptrig_pT3_good_tdc 'SHMS p1x/p1y/p2x/p2y Coincidence Good TDC Time (Slot 19
 TH2F ptrig_ch1xy_ch2x 'SHMS Hodo Trig; 1X1Y Trig (ns); 2X Trig (ns)' T.shms.p1T_tdcTime T.shms.p2X_tdcTime 200 100 300 200 100 300 T.shms.p2X_tdcMultiplicity==1&&T.shms.p1T_tdcMultiplicity==1
 TH2F ptrig_ch1x_ch2x 'SHMS Hodo Trig; 1X Trig (ns); 2X Trig (ns)' T.shms.p1X_tdcTime T.shms.p2X_tdcTime 200 100 300 200 100 300 T.shms.p2X_tdcMultiplicity==1&&T.shms.p1X_tdcMultiplicity==1
 TH2F ptrig_ch1y_ch2x 'SHMS Hodo Trig; 1Y Trig (ns); 2X Trig (ns)' T.shms.p1Y_tdcTime T.shms.p2X_tdcTime 200 100 300 200 100 300 T.shms.p2X_tdcMultiplicity==1&&T.shms.p1Y_tdcMultiplicity==1
-TH2F ptrig_ch1ych1x 'SHMS Hodo Trig; Trig 1X (ns); Trig 1Y (ns)' T.shms.p1X_tdcTime T.shms.p1Y_tdcTime 200 100 300 200 100 300 T.shms.p1Y_tdcMultiplicity==1&&T.shms.p1X_tdcMultiplicity==1
-
-TH1F ptrig_pdc_ref1  'SHMS DC Reference Time Slot 6 Channel 79; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF1_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref2  'SHMS DC Reference Time Slot 7 Channel 79; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF2_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref3  'SHMS DC Reference Time Slot 8 Channel 79; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF3_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref4  'SHMS DC Reference Time Slot 9 Channel 79; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF4_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref5  'SHMS DC Reference Time Slot 10 Channel 79; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF5_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref6  'SHMS DC Reference Time Slot 11 Channel 47; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF6_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref7  'SHMS DC Reference Time Slot 12 Channel 47; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF7_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref8  'SHMS DC Reference Time Slot 13 Channel 47; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF8_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref9  'SHMS DC Reference Time Slot 14 Channel 15; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF9_tdcTime  200 12000 14000
-TH1F ptrig_pdc_ref10 'SHMS DC Reference Time Slot 15 Channel 47; Raw TDC Time (TDC Clicks); Counts / 10 TDC Clicks' T.shms.pDCREF10_tdcTime 200 12000 14000
\ No newline at end of file
+TH2F ptrig_ch1y_ch1x 'SHMS Hodo Trig; 1X Trig (ns); 1Y Trig (ns)' T.shms.p1X_tdcTime T.shms.p1Y_tdcTime 200 100 300 200 100 300 T.shms.p1Y_tdcMultiplicity==1&&T.shms.p1X_tdcMultiplicity==1
diff --git a/DEF-files/SHMS/PRODUCTION/pstackana_production.def b/DEF-files/SHMS/PRODUCTION/pstackana_production.def
index f7fa43ec00d19b52f530c3edbe454589b0969dd3..45681726c41c3fe5c22b81adaf4fde18071da9b7 100644
--- a/DEF-files/SHMS/PRODUCTION/pstackana_production.def
+++ b/DEF-files/SHMS/PRODUCTION/pstackana_production.def
@@ -9,3 +9,10 @@
 #include "DEF-files/SHMS/PRODUCTION/KIN/pkin_histos.def"
 #include "DEF-files/SHMS/PRODUCTION/RASTER/praster_histos.def"
 #include "DEF-files/SHMS/PRODUCTION/EPICS/pepics_vars.def"
+#include "DEF-files/SHMS/TEST_STANDS/AERO/paeroana.def"
+#include "DEF-files/SHMS/TEST_STANDS/CAL/pcalana.def"
+#include "DEF-files/SHMS/TEST_STANDS/DC/pdcana.def"
+#include "DEF-files/SHMS/TEST_STANDS/HGCER/phgcerana.def"
+#include "DEF-files/SHMS/TEST_STANDS/HODO/phodoana.def"
+#include "DEF-files/SHMS/TEST_STANDS/NGCER/pngcerana.def"
+#include "DEF-files/SHMS/TEST_STANDS/TRIG/ptrigana.def"
diff --git a/DEF-files/SHMS/TEST_STANDS/CAL/pcalana.def b/DEF-files/SHMS/TEST_STANDS/CAL/pcalana.def
index 4ce039b0764f48a97403be549718468e5e439a46..0241630986fcfcf1d3cfdc3dab2af6dc52459940 100644
--- a/DEF-files/SHMS/TEST_STANDS/CAL/pcalana.def
+++ b/DEF-files/SHMS/TEST_STANDS/CAL/pcalana.def
@@ -47,7 +47,7 @@ TH2F pcal_prshwr_pamp_vs_pmt_pos 'SHMS PreShower+ Pulse Amplitude vs. PMT Number
 
 TH2F pcal_prshwr_pped_vs_pmt_neg 'SHMS PreShower- Pulse Pedestal vs. PMT Number; PMT Number; Pulse Pedestal / 2 mV' P.cal.pr.negAdcCounter P.cal.pr.negAdcPed 14 0.5 14.5 500 0 1000
 TH2F pcal_prshwr_pi_vs_pmt_neg 'SHMS PreShower- Pulse Integral vs. PMT Number; PMT Number; Pulse Integral / 0.25 pC' P.cal.pr.negAdcCounter P.cal.pr.negAdcPulseInt 14 0.5 14.5 320 0 80
-TH2F pcal_prshwr_pamp_vs_pmt_neg 'SHMS PreShower- Pulse Amplitude vs. PMT Number; PMT Number; Pulse Amplitude / 2 mV' P.cal.pr.negAdcCounter P.cal.pr.negAdcPulseAmp 14 0.5 14.5 500 1000
+TH2F pcal_prshwr_pamp_vs_pmt_neg 'SHMS PreShower- Pulse Amplitude vs. PMT Number; PMT Number; Pulse Amplitude / 2 mV' P.cal.pr.negAdcCounter P.cal.pr.negAdcPulseAmp 14 0.5 14.5 500 0 1000
 
 
 #GOOD PULSE PEDESTALS/INTEGRALS/AMPLITUDES/TIMES :: GOOD --> (passed errorFlag cut, pulsetime cuts oN Min/Max ADC Time Window, and ADC threshold cut)
@@ -88,7 +88,7 @@ TH1F pcal_shwr_raw_mult 'SHMS Shower Raw Multiplicity; Number of PMTs Hit; Total
 
 #SHMS Shower GOOD Occupancy and Multiplicity
 TH1F pcal_shwr_good_occ 'SHMS Shower Good Occupancy; PMT Number; Number of Good ADC Hits' P.cal.fly.numGoodAdcHits 224 0.5 224.5
-TH1F pcal_shwr_good_mult 'SHMS Shower Good Multiplicity; PMT Number; Total Number of Good ADC Hits' P.cal.fly.totNumGoodAdcHits 224 0.5 224.5
+TH1F pcal_shwr_good_mult 'SHMS Shower Good Multiplicity; Numer of PMTs Hit; Total Number of Good ADC Hits' P.cal.fly.totNumGoodAdcHits 224 0.5 224.5
 
 #SHMS Shower RAW PULSE PEDESTALS/INTEGRALS/AMPLITUDES/TIMES
 TH2F pcal_shwr_raw_pped_vs_pmt 'SHMS Shower Raw Pulse Pedestal vs. PMT Number; PMT Number; Raw Pulse Pedestal / 10 ADC Unit' P.cal.fly.adcCounter P.cal.fly.adcPedRaw 224 0.5 224.5 410 0 4100
diff --git a/onlineGUI/CONFIG/SHMS/GEN/shms_production.cfg b/onlineGUI/CONFIG/SHMS/GEN/shms_production.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..8c506f369f585266cd4a8139a3af3c928127c68d
--- /dev/null
+++ b/onlineGUI/CONFIG/SHMS/GEN/shms_production.cfg
@@ -0,0 +1,174 @@
+protorootfile ../ROOTfiles/shms_replay_production_XXXXX_50000.root
+guicolor orange
+canvassize 1000 800
+
+newpage 4 2
+title SHMS Hodoscope ADC Occ/Mult
+macro 'UTIL/GEN/overlay2.C("phodo_1x_good_adc_occ_pos","phodo_1x_good_adc_occ_neg","S1x+","S1x-","SHMS Hodo 1x Good ADC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_1y_good_adc_occ_pos","phodo_1y_good_adc_occ_neg","S1y+","S1y-","SHMS Hodo 1y Good ADC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2x_good_adc_occ_pos","phodo_2x_good_adc_occ_neg","S2x+","S2x-","SHMS Hodo 2x Good ADC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2y_good_adc_occ_pos","phodo_2y_good_adc_occ_neg","S2y+","S2y-","SHMS Hodo 2y Good ADC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_1x_good_adc_mult_pos","phodo_1x_good_adc_mult_neg","S1x+","S1x-","SHMS Hodo 1x Good ADC Multiplicity")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_1y_good_adc_mult_pos","phodo_1y_good_adc_mult_neg","S1y+","S1y-","SHMS Hodo 1y Good ADC Multiplicity")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2x_good_adc_mult_pos","phodo_2x_good_adc_mult_neg","S2x+","S2x-","SHMS Hodo 2x Good ADC Multiplicity")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2y_good_adc_mult_pos","phodo_2y_good_adc_mult_neg","S2y+","S2y-","SHMS Hodo 2y Good ADC Multiplicity")' -nostat
+
+newpage 4 2
+title SHMS Hodoscope TDC Occ/Mult
+macro 'UTIL/GEN/overlay2.C("phodo_1x_good_tdc_occ_pos","phodo_1x_good_tdc_occ_neg","S1x+","S1x-","SHMS Hodo 1x Good TDC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_1y_good_tdc_occ_pos","phodo_1y_good_tdc_occ_neg","S1y+","S1y-","SHMS Hodo 1y Good TDC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2x_good_tdc_occ_pos","phodo_2x_good_tdc_occ_neg","S2x+","S2x-","SHMS Hodo 2x Good TDC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2y_good_tdc_occ_pos","phodo_2y_good_tdc_occ_neg","S2y+","S2y-","SHMS Hodo 2y Good TDC Occupancy")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_1x_good_tdc_mult_pos","phodo_1x_good_tdc_mult_neg","S1x+","S1x-","SHMS Hodo 1x Good TDC Multiplicity")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_1y_good_tdc_mult_pos","phodo_1y_good_tdc_mult_neg","S1y+","S1y-","SHMS Hodo 1y Good TDC Multiplicity")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2x_good_tdc_mult_pos","phodo_2x_good_tdc_mult_neg","S2x+","S2x-","SHMS Hodo 2x Good TDC Multiplicity")' -nostat
+macro 'UTIL/GEN/overlay2.C("phodo_2y_good_tdc_mult_pos","phodo_2y_good_tdc_mult_neg","S2y+","S2y-","SHMS Hodo 2y Good TDC Multiplicity")' -nostat
+
+newpage 4 2
+title SHMS Hodoscope Pedestals
+phodo_1x_good_pped_vs_pmt_pos -nostat
+phodo_1y_good_pped_vs_pmt_pos -nostat
+phodo_2x_good_pped_vs_pmt_pos -nostat
+phodo_2y_good_pped_vs_pmt_pos -nostat
+phodo_1x_good_pped_vs_pmt_neg -nostat
+phodo_1y_good_pped_vs_pmt_neg -nostat
+phodo_2x_good_pped_vs_pmt_neg -nostat
+phodo_2y_good_pped_vs_pmt_neg -nostat
+
+newpage 4 3
+title SHMS DC Wiremaps
+pdc1u1_wirenum -nostat
+pdc1u2_wirenum -nostat
+pdc2u1_wirenum -nostat
+pdc2u2_wirenum -nostat
+pdc1x1_wirenum -nostat
+pdc1x2_wirenum -nostat
+pdc2x1_wirenum -nostat
+pdc2x2_wirenum -nostat
+pdc1v1_wirenum -nostat
+pdc1v2_wirenum -nostat
+pdc2v1_wirenum -nostat
+pdc2v2_wirenum -nostat
+
+newpage 4 3
+title SHMS DC Drift Distance
+pdc1u1_ddist -nostat
+pdc1u2_ddist -nostat
+pdc2u1_ddist -nostat
+pdc2u2_ddist -nostat
+pdc1x1_ddist -nostat
+pdc1x2_ddist -nostat
+pdc2x1_ddist -nostat
+pdc2x2_ddist -nostat
+pdc1v1_ddist -nostat
+pdc1v2_ddist -nostat
+pdc2v1_ddist -nostat
+pdc2v2_ddist -nostat
+
+newpage 4 3
+title SHMS DC Drift Time
+pdc1u1_drifttime -nostat
+pdc1u2_drifttime -nostat
+pdc2u1_drifttime -nostat
+pdc2u2_drifttime -nostat
+pdc1x1_drifttime -nostat
+pdc1x2_drifttime -nostat
+pdc2x1_drifttime -nostat
+pdc2x2_drifttime -nostat
+pdc1v1_drifttime -nostat
+pdc1v2_drifttime -nostat
+pdc2v1_drifttime -nostat
+pdc2v2_drifttime -nostat
+
+newpage 2 2
+title SHMS DC Focal Plane
+pdc_xfp_vs_yfp -nostat
+pdc_xpfp_vs_ypfp -nostat
+pdc_xfp_vs_xpfp -nostat
+pdc_xfp_vs_ypfp -nostat
+
+newpage 3 2
+title SHMS Cherenkov Occ/Mult
+macro 'UTIL/GEN/overlay2.C("paero_good_occ_pos","paero_good_occ_neg","Aero+","Aero-","SHMS Aerogel Cherenkov Good Occupancy")' -nostat
+pngcer_good_occ -nostat
+phgcer_good_occ -nostat
+macro 'UTIL/GEN/overlay2.C("paero_good_mult_pos","paero_good_mult_neg","Aero+","Aero-","SHMS Aerogel Cherenkov Good Multiplicity")' -nostat
+pngcer_good_mult -nostat
+phgcer_good_mult -nostat
+
+newpage 3 2
+title SHMS Cherenkov Pedestals
+paero_good_pped_vs_pmt_pos -nostat
+pngcer_good_pped_vs_pmt -nostat
+phgcer_good_pped_vs_pmt -nostat
+paero_good_pped_vs_pmt_neg -nostat
+
+newpage 4 2
+title SHMS Cherenkov NPE
+paero_npe_pos -nostat
+paero_npe_neg -nostat
+pngcer_npe -nostat
+phgcer_npe -nostat
+paero_tot_npe_pos -nostat
+paero_tot_npe_neg -nostat
+pngcer_tot_npe -nostat
+phgcer_tot_npe -nostat
+
+newpage 2 2
+title SHMS Calorimeter Occ/Mult
+macro 'UTIL/GEN/overlay2.C("pcal_prshwr_good_occ_pos","pcal_prshwr_good_occ_neg","PrSh+","PrSh-","SHMS PreShower Good Occupancy")' -nostat
+pcal_shwr_good_occ -nostat
+macro 'UTIL/GEN/overlay2.C("pcal_prshwr_good_mult_pos","pcal_prshwr_good_mult_neg","PrSh+","PrSh-","SHMS PreShower Good Multiplicity")' -nostat
+pcal_shwr_good_mult -nostat
+
+newpage 2 2
+title SHMS Calorimeter Pedestals
+pcal_prshwr_good_pped_vs_pmt_pos -nostat
+pcal_shwr_good_pped_vs_pmt -nostat
+pcal_prshwr_good_pped_vs_pmt_neg -nostat
+
+newpage 4 3
+title SHMS DC Reference Times
+ptrig_pdc_ref1
+ptrig_pdc_ref2
+ptrig_pdc_ref3
+ptrig_pdc_ref4
+ptrig_pdc_ref5
+ptrig_pdc_ref6
+ptrig_pdc_ref7
+ptrig_pdc_ref8
+ptrig_pdc_ref9
+ptrig_pdc_ref10
+
+newpage 4 3
+title SHMS Trigger Reference Times
+ptrig_p1x_tdc -nostat
+ptrig_p1y_tdc -nostat
+ptrig_p2x_tdc -nostat
+ptrig_p2y_tdc -nostat
+ptrig_p1T_tdc -nostat
+ptrig_p2T_tdc -nostat
+ptrig_pT1_tdc -nostat
+ptrig_pT2_tdc -nostat
+ptrig_pT3_tdc -nostat
+
+newpage 2 2
+title SHMS Fast Raster
+pFRA_XvsY -nostat
+pFRB_XvsY -nostat
+
+newpage 2 2
+title SHMS Kinematics
+pkin_q2 -nostat
+pkin_w -nostat
+pkin_omega -nostat
+pkin_theta -nostat
+
+newpage 2 3 logz
+title SHMS PID
+hgc_vs_prshw -nostat
+ngc_vs_prshw -nostat
+pcal_shw_vs_prshw -nostat
+delta_vs_etracknorm -nostat
+pdc_trk_mom -nostat
+pdc_trk_beta -nostat
diff --git a/onlineGUI/CONFIG/SHMS/GEN/shms_stack.cfg b/onlineGUI/CONFIG/SHMS/GEN/shms_stack.cfg
index d8613e5bab36077e16431e6aa38a39f484b65a60..36f252a667f7e9938fc6d3527db388622ae46d62 100644
--- a/onlineGUI/CONFIG/SHMS/GEN/shms_stack.cfg
+++ b/onlineGUI/CONFIG/SHMS/GEN/shms_stack.cfg
@@ -3,20 +3,24 @@ protorootfile ../ROOTfiles/shms_replay_XXXXX_50000.root
 guicolor orange
 canvassize 1600 800
 #canvassize 800 800
+
 newpage 2 1
 title SHMS NGC Good Occ./Mult.
 pngcer_good_occ -nostat
 pngcer_good_mult -nostat
+
 newpage 2 2 logz
 title SHMS NGC Good Pulse Profile
 pngcer_good_pped_vs_pmt -nostat
 pngcer_good_pamp_vs_pmt -nostat
 pngcer_good_pi_vs_pmt -nostat
 pngcer_good_ptime_vs_pmt -nostat
+
 newpage 2 1 logz
 title SHMS NGC N.P.E. (PID)
 pngcer_npe -nostat
 pngcer_tot_npe -nostat
+
 newpage 6 2
 title SHMS DC Wire Map
 pdc1u1_wirenum -nostat
@@ -31,6 +35,7 @@ pdc2x2_wirenum -nostat
 pdc2x1_wirenum -nostat
 pdc2u2_wirenum -nostat
 pdc2u1_wirenum -nostat
+
 newpage 6 2 
 title SHMS DC Drift Plane Times
 pdc1u1_drifttime -nostat
@@ -45,6 +50,7 @@ pdc2x2_drifttime -nostat
 pdc2x1_drifttime -nostat
 pdc2u2_drifttime -nostat
 pdc2u1_drifttime -nostat
+
 newpage 6 2 logz
 title SHMS DC Drift Time vs. Wire Number
 pdc1u1_drifttime_vs_wirenum -nostat
@@ -59,6 +65,7 @@ pdc2x2_drifttime_vs_wirenum -nostat
 pdc2x1_drifttime_vs_wirenum -nostat
 pdc2u2_drifttime_vs_wirenum -nostat
 pdc2u1_drifttime_vs_wirenum -nostat
+
 newpage 6 2 
 title SHMS DC Plane Drift Distance
 pdc1u1_ddist -nostat
@@ -73,6 +80,7 @@ pdc2x2_ddist -nostat
 pdc2x1_ddist -nostat
 pdc2u2_ddist -nostat
 pdc2u1_ddist -nostat
+
 newpage 6 2 logz
 title SHMS DC Drift Distance vs. Wire Number
 pdc1u1_wirenum_vs_ddist -nostat
@@ -102,6 +110,7 @@ pdc2x2_residuals -nostat
 pdc2x1_residuals -nostat
 pdc2u2_residuals -nostat
 pdc2u1_residuals -nostat
+
 newpage 6 2 logz
 title SHMS DC Residuals vs. Wire Number
 pdc1u1_residuals_vs_wirenum -nostat
@@ -116,9 +125,11 @@ pdc2x2_residuals_vs_wirenum -nostat
 pdc2x1_residuals_vs_wirenum -nostat
 pdc2u2_residuals_vs_wirenum -nostat
 pdc2u1_residuals_vs_wirenum -nostat
+
 newpage 1 1 logz
 title SHMS DC X vs. Y at F.P.
 pdc_xfp_vs_yxp -nostat
+
 newpage 1 1 logz
 title SHMS DC Xp vs. Yp at F.P.
 pdc_xfpp_vs_yfpp -nostat
@@ -127,12 +138,14 @@ newpage 2 1
 title SHMS HGC Good Occ./Mult.
 phgcer_good_occ -nostat
 phgcer_good_mult -nostat
+
 newpage 2 2 logz
 title SHMS HGC Good Pulse Profile
 phgcer_good_pped_vs_pmt -nostat
 phgcer_good_pamp_vs_pmt -nostat
 phgcer_good_pi_vs_pmt -nostat
 phgcer_good_ptime_vs_pmt -nostat
+
 newpage 2 1 logz
 title SHMS HGC N.P.E. (PID)
 phgcer_npe -nostat
@@ -149,6 +162,7 @@ phodo_2x_good_adc_occ_pos -nostat
 phodo_2x_good_adc_occ_neg -nostat
 phodo_2y_good_adc_occ_pos -nostat
 phodo_2y_good_adc_occ_neg -nostat
+
 newpage 3 4 
 title SHMS Hodo Good ADC Mult.
 phodo_1x_good_adc_mult_pos -nostat
@@ -174,6 +188,7 @@ phodo_2x_good_tdc_occ_pos -nostat
 phodo_2x_good_tdc_occ_neg -nostat
 phodo_2y_good_tdc_occ_pos -nostat
 phodo_2y_good_tdc_occ_neg -nostat
+
 newpage 3 4
 title SHMS Hodo Good TDC Mult.
 phodo_1x_good_tdc_mult_pos -nostat
@@ -271,11 +286,13 @@ newpage 2 1
 title SHMS Aero Good Occ. 
 paero_good_occ_pos -nostat 
 paero_good_occ_neg -nostat
+
 newpage 3 1
 title SHMS Aero Good Mult.
 paero_good_mult_pos -nostat 
 paero_good_mult_neg -nostat
 paero_good_mult -nostat
+
 newpage 3 2 logz
 title SHMS Aero N.P.E (PID)
 paero_tot_npe_pos -nostat
@@ -283,6 +300,7 @@ paero_tot_npe_neg -nostat
 paero_tot_npe -nostat
 paero_npe_pos -nostat
 paero_npe_neg -nostat
+
 newpage 4 2 logz
 title SHMS Aero Good Pulse Profile
 paero_good_pped_vs_pmt_pos -nostat
@@ -299,11 +317,13 @@ newpage 2 1
 title SHMS PreSH Good Occ.
 pcal_prshwr_good_occ_pos -nostat
 pcal_prshwr_good_occ_neg -nostat
+
 newpage 3 1
 title SHMS PreSH Good Mult.
 pcal_prshwr_good_mult_pos -nostat
 pcal_prshwr_good_mult_neg -nostat
 pcal_prshwr_good_mult -nostat
+
 newpage 4 2 logz
 title SHMS PreSH Good Pulse Profile
 pcal_prshwr_good_pped_vs_pmt_pos -nostat
@@ -314,11 +334,13 @@ pcal_prshwr_good_pi_vs_pmt_pos -nostat
 pcal_prshwr_good_pi_vs_pmt_neg -nostat
 pcal_prshwr_good_ptime_vs_pmt_pos -nostat
 pcal_prshwr_good_ptime_vs_pmt_neg -nostat
+
 newpage 3 1 logz
 title SHMS PreSH Energy Dep./PMT
 pcal_prshwr_Epos_vs_pmt -nostat
 pcal_prshwr_Eneg_vs_pmt -nostat
 pcal_prshwr_Emean_vs_pmt -nostat
+
 newpage 3 1
 title SHMS PreSH Tot. Energy Dep. 
 pcal_prshwr_Eplane_pos -nostat
diff --git a/onlineGUI/onlineGUI_v1.2.1/online.C b/onlineGUI/onlineGUI_v1.2.1/online.C
index 21a382ba764e469f78ddfa462a8b453a93341da0..99341a0a0776865af7aa0a849e99fb23222141b7 100755
--- a/onlineGUI/onlineGUI_v1.2.1/online.C
+++ b/onlineGUI/onlineGUI_v1.2.1/online.C
@@ -1,2090 +1,2090 @@
-///////////////////////////////////////////////////////////////////
-//  Macro to help with online analysis
-//    B. Moffit (moffit@jlab.org)
-//    - Originally written in Oct. 2003
-//  Documentation and updates available at:
-//    http://www.jlab.org/~moffit/onlineGUI/
-//
-
-#include "online.h"
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <list>
-#include <TMath.h>
-#include <TBranch.h>
-#include <TGClient.h>
-#include <TCanvas.h>
-#include <TStyle.h>
-#include <TROOT.h>
-#include <TGImageMap.h>
-#include <TGFileDialog.h>
-#include <TKey.h>
-#include <TObjString.h>
-#include <TSystem.h>
-#include <TLatex.h>
-#include <TText.h>
-#include <TGraph.h>
-#include "GetRootFileName.C"
-#include "GetRunNumber.C"
-#include "TPaveText.h"
-#ifdef STANDALONE
-#include <TApplication.h>
-#endif
-// #define DEBUGGETFILEOBJECTS
-// #define DEBUGPARSE
-// #define DEBUG
-//#define DEBUG2
-//#define NOISY
-//#define INTERNALSTYLE
-
-//TString guiDirectory = "onlineGUI_v1.2.1/";
-TString guiDirectory = "./";
-
-///////////////////////////////////////////////////////////////////
-//  Class: OnlineConfig
-//
-//     Utility class that reads in a text file (.cfg) and
-//     stores it's contents.
-//
-//
-
-OnlineConfig::OnlineConfig()
-{
-    // Constructor.  Without an argument, will use default "standard" config
-    fMonitor = kFALSE;
-    OnlineConfig("standard");
-}
-
-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"))
-        confFileName += ".cfg";
-    fMonitor = kFALSE;
-    fFoundCfg = kFALSE;
-
-    // Attempt to find the config file in specified (first argument,
-    // relative or absolute) location, then in guiDirectory
-    fConfFile = new ifstream(confFileName.Data());
-    if ( ! (*fConfFile) ) {
-        cerr << "OnlineConfig() WARNING: config file " << confFileName.Data()
-            << " does not exist" << endl;
-        cerr << " Checking the " << guiDirectory << " directory" << endl;
-        confFileName.Prepend(guiDirectory+"/");
-        fConfFile = new ifstream(confFileName.Data());
-        if ( ! (*fConfFile) ) {
-            // Didn't find it... load up the default config
-            confFileName = guiDirectory+"/default.cfg";
-            cout << "OnlineConfig()  Trying " << confFileName.Data()
-                << " as default configuration." << endl
-                << " (May be ok.)" << endl;
-            fConfFile = new ifstream(confFileName.Data());
-            if ( ! (*fConfFile) ) {
-                cerr << "OnlineConfig() WARNING: no file "
-                    << confFileName.Data() <<endl;
-                cerr << "You need a configuration to run.  Ask an expert."<<endl;
-                fFoundCfg = kFALSE;
-                //      return;
-            } else {
-                fFoundCfg = kTRUE;
-            }
-        } else {
-            fFoundCfg = kTRUE;
-        }
-    } else {
-        fFoundCfg = kTRUE;
-    }
-
-    if(fFoundCfg) {
-        clog << "GUI Configuration loading from "
-            << confFileName.Data() << endl;
-    }
-
-    ParseFile();
-
-    // Load up a user configurable style (if it exists)
-    TString styleFile = guiDirectory+"onlineGUI_Style.C";
-    if(!gSystem->AccessPathName(styleFile))
-        gROOT->Macro(styleFile);
-
-    fConfFile->close();
-    delete fConfFile;
-
-}
-
-void OnlineConfig::ParseFile()
-{
-    // Reads in the Config File, and makes the proper calls to put
-    //  the information contained into memory.
-
-    if(!fFoundCfg) {
-        return;
-    }
-
-    TString comment = "#";
-    vector<TString> strvect;
-    TString sinput, sline;
-    while (sline.ReadLine(*fConfFile)) {
-        strvect.clear();
-        // Strip away leading and trailing spaces.
-        sline = sline.Strip(TString::kBoth,' ');
-        // If the line starts with a comment, skip it.
-        if(sline.BeginsWith(comment)) continue;
-        // If the line contains a comment, split it up into two and keep
-        // the uncommented (first) part
-        if(sline.Contains(comment)) {
-            TObjArray *tmpoarr = sline.Tokenize(comment);
-            TObjString *tmpostr = (TObjString*)tmpoarr->First();
-            sline = tmpostr->GetString().Strip(TString::kTrailing,' ');
-            delete tmpoarr;
-        }
-        // Now split up the line according to 's and spaces.  This is for
-        // looking for the histogram using it's title (which may contain
-        // spaces) instead of its name.
-        if(sline.Contains("'")) {
-            TObjArray *tmpoarr = sline.Tokenize("'");
-            Bool_t quote_on_odd = kTRUE;
-            if(!(sline.BeginsWith("'"))) quote_on_odd=kFALSE;
-            TIterator *next = tmpoarr->MakeIterator();
-            TObjString *tmpostr; Bool_t odd=kTRUE;
-            while((tmpostr=(TObjString*)next->Next())!=NULL) {
-                if((quote_on_odd&&odd) || (!quote_on_odd&&!odd)) {
-                    strvect.push_back(tmpostr->GetString());
-                    odd = !odd;
-                } else {
-                    TObjArray *tmpoarr2 = tmpostr->GetString().Tokenize(" ");
-                    TIterator *next2 = tmpoarr2->MakeIterator();
-                    TObjString *tmpostr2;
-                    while((tmpostr2=(TObjString*)next2->Next())!=NULL) {
-                        strvect.push_back(tmpostr2->GetString());
-                    }
-                    delete tmpoarr2;
-                    odd = !odd;
-                }
-            }
-            delete tmpoarr;
-        } else { // No 's.. just split according to spaces
-            TObjArray *tmpoarr2 = sline.Tokenize(" ");
-            TIterator *next2 = tmpoarr2->MakeIterator();
-            TObjString *tmpostr2;
-            while((tmpostr2=(TObjString*)next2->Next())!=NULL) {
-                strvect.push_back(tmpostr2->GetString());
-            }
-            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++)
-            cout << sConfFile[ii][jj] << " ";
-        cout << endl;
-    }
-#endif
-
-    cout << "     " << sConfFile.size() << " lines read from "
-        << confFileName << endl;
-
-}
-
-Bool_t OnlineConfig::ParseConfig()
-{
-    //  Goes through each line of the config [must have been ParseFile()'d]
-    //   and interprets.
-
-    if(!fFoundCfg) {
-        return kFALSE;
-    }
-
-    UInt_t command_cnt=0;
-    UInt_t j=0;
-    Bool_t hasMultiPlots=kFALSE;
-    canvaswidth = 800;		// Default canvas size
-    canvasheight = 600;
-    // If statement for each high level command (cut, newpage, etc)
-    for(UInt_t i=0;i<sConfFile.size();i++) {
-        // "newpage" command
-        if(sConfFile[i][0] == "newpage") {
-            // sConfFile[i] is first of pair
-            for(j=i+1;j<sConfFile.size();j++) {
-                if(sConfFile[j][0] != "newpage") {
-                    // Count how many commands within the page
-                    command_cnt++;
-                } else break;
-            }
-            pageInfo.push_back(make_pair(i,command_cnt));
-            i += command_cnt;
-            command_cnt=0;
-        }
-        if(sConfFile[i][0] == "watchfile") {
-            fMonitor = kTRUE;
-        }
-        if(sConfFile[i][0] == "definecut") {
-            if(sConfFile[i].size()>3) {
-                cerr << "cut command has too many arguments" << endl;
-                continue;
-            }
-            TCut tempCut(sConfFile[i][1],sConfFile[i][2]);
-            cutList.push_back(tempCut);
-        }
-        if(sConfFile[i][0] == "rootfile") {
-            if(sConfFile[i].size() != 2) {
-                cerr << "WARNING: rootfile command does not have the "
-                    << "correct number of arguments"
-                    << endl;
-                continue;
-            }
-            if(!rootfilename.IsNull()) {
-                cerr << "WARNING: too many rootfile's defined. "
-                    << " Will only use the first one."
-                    << endl;
-                continue;
-            }
-            rootfilename = sConfFile[i][1];
-        }
-        if(sConfFile[i][0] == "goldenrootfile") {
-            if(sConfFile[i].size() != 2) {
-                cerr << "WARNING: goldenfile command does not have the "
-                    << "correct number of arguments"
-                    << endl;
-                continue;
-            }
-            if(!goldenrootfilename.IsNull()) {
-                cerr << "WARNING: too many goldenrootfile's defined. "
-                    << " Will only use the first one."
-                    << endl;
-                continue;
-            }
-            goldenrootfilename = sConfFile[i][1];
-        }
-        if(sConfFile[i][0] == "protorootfile") {
-            if(sConfFile[i].size() != 2) {
-                cerr << "WARNING: protorootfile command does not have the "
-                    << "correct number of arguments"
-                    << endl;
-                continue;
-            }
-            if(!protorootfile.IsNull()) {
-                cerr << "WARNING: too many protorootfile's defined. "
-                    << " Will only use the first one."
-                    << endl;
-                continue;
-            }
-            protorootfile = sConfFile[i][1];
-        }
-        if(sConfFile[i][0] == "guicolor") {
-            if(sConfFile[i].size() != 2) {
-                cerr << "WARNING: guicolor command does not have the "
-                    << "correct number of arguments (needs 1)"
-                    << endl;
-                continue;
-            }
-            if(!guicolor.IsNull()) {
-                cerr << "WARNING: too many guicolor's defined. "
-                    << " Will only use the first one."
-                    << endl;
-                continue;
-            }
-            guicolor = sConfFile[i][1];
-        }
-        if(sConfFile[i][0] == "canvassize") {
-            if(sConfFile[i].size() != 3) {
-                cerr << "WARNING: canvassize command does not have the "
-                    << "correct number of arguments (needs 2)"
-                    << endl;
-                continue;
-            }
-            canvaswidth = UInt_t(atoi(sConfFile[i][1]));
-            canvasheight = UInt_t(atoi(sConfFile[i][2]));
-        }
-        if(sConfFile[i][0] == "plotsdir") {
-            if(sConfFile[i].size() != 2) {
-                cerr << "WARNING: plotsdir command does not have the "
-                    << "correct number of arguments (needs 1)"
-                    << endl;
-                continue;
-            }
-            if(!plotsdir.IsNull()) {
-                cerr << "WARNING: too many plotdir's defined. "
-                    << " Will only use the first one."
-                    << endl;
-                continue;
-            }
-            plotsdir = sConfFile[i][1];
-        }
-        if(sConfFile[i][0] == "multiplot") {
-            hasMultiPlots = kTRUE;
-        }
-
-    }
-
-    if(hasMultiPlots) {
-        if(!ParseForMultiPlots()) {
-            cerr << "ParseForMultiPlots() Failed" << endl;
-        }
-    }
-
-#ifdef NOISY
-    for(UInt_t i=0; i<GetPageCount(); i++) {
-        cout << "Page " << i << " (" << GetPageTitle(i) << ")"
-            << " will draw " << GetDrawCount(i)
-            << " histograms." << endl;
-    }
-#endif
-
-    cout << "Number of pages defined = " << GetPageCount() << endl;
-    cout << "Number of cuts defined = " << cutList.size() << endl;
-
-    if (fMonitor)
-        cout << "Will periodically update plots" << endl;
-    if(!goldenrootfilename.IsNull()) {
-        cout << "Will compare chosen histrograms with the golden rootfile: "
-            << endl
-            << goldenrootfilename << endl;
-    }
-
-    return kTRUE;
-
-}
-
-Bool_t OnlineConfig::ParseForMultiPlots() {
-    // Parse through each line of sConfFile,
-    // and replace each "multiplot" command with a real draw entry
-
-    vector < vector <TString> > newConfFile;
-    for(UInt_t iter=0;iter<sConfFile.size();iter++) {
-        if(sConfFile[iter][0]=="multiplot") {
-            // 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++) {
-                vector <TString> newline;
-                for(UInt_t ielem=3; ielem<sConfFile[iter].size();ielem++) {
-                    TString origString = sConfFile[iter][ielem];
-                    TString newString = origString;
-                    newString.ReplaceAll("XXXXX",Form("%d",imult));
-                    newline.push_back(newString);
-                }
-                newConfFile.push_back(newline);
-            }
-        } else {
-            newConfFile.push_back(sConfFile[iter]);
-        }
-    }
-
-#ifdef DEBUG
-    for(UInt_t iter=0;iter<newConfFile.size();iter++) {
-        for(UInt_t iline=0;iline<newConfFile[iter].size();iline++) {
-            cout << newConfFile[iter][iline] << " ";
-        }
-        cout << endl;
-    }
-#endif
-
-    // Out with the old, in with the new.
-    sConfFile.clear();
-    sConfFile = newConfFile;
-
-    // Now need to recalculate pageInfo.
-    UInt_t command_cnt=0;
-    UInt_t j=0;
-
-    pageInfo.clear();
-    // If statement for each high level command (cut, newpage, etc)
-    for(UInt_t i=0;i<sConfFile.size();i++) {
-        // "newpage" command
-        if(sConfFile[i][0] == "newpage") {
-            // sConfFile[i] is first of pair
-            for(j=i+1;j<sConfFile.size();j++) {
-                if(sConfFile[j][0] != "newpage") {
-                    // Count how many commands within the page
-                    command_cnt++;
-                } else break;
-            }
-            pageInfo.push_back(make_pair(i,command_cnt));
-            i += command_cnt;
-            command_cnt=0;
-        }
-    }
-
-    return kTRUE;
-
-}
-
-TCut OnlineConfig::GetDefinedCut(TString ident) {
-    // Returns the defined cut, according to the identifier
-
-    for(UInt_t i=0; i<cutList.size(); i++) {
-        if((TString)cutList[i].GetName() == ident.Data()) {
-            TCut tempCut = cutList[i].GetTitle();
-            return tempCut;
-        }
-    }
-    return "";
-}
-
-vector <TString> OnlineConfig::GetCutIdent() {
-    // Returns a vector of the cut identifiers, specified in config
-    vector <TString> out;
-
-    for(UInt_t i=0; i<cutList.size(); i++) {
-        out.push_back(cutList[i].GetName());
-    }
-
-    return out;
-}
-
-Bool_t OnlineConfig::IsLogx(UInt_t page) {
-    // Check if last word on line is "logx"
-
-    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];
-    if(option == "logx") return kTRUE;
-    return kFALSE;
-
-}
-
-Bool_t OnlineConfig::IsLogy(UInt_t page) {
-    // Check if last word on line is "logy"
-
-    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];
-    if(option == "logy") return kTRUE;
-    return kFALSE;
-
-}
-
-Bool_t OnlineConfig::IsLogz(UInt_t page) {
-    // Check if last word on line is "logz"
-
-    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];
-    if(option == "logz") return kTRUE;
-    return kFALSE;
-
-}
-
-
-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
-    //  calculated dimensions required to fit all histograms.
-
-    pair <UInt_t, UInt_t> outDim;
-
-    // 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) {
-            outDim = make_pair(UInt_t(atoi(sConfFile[page_index][1])),
-                    UInt_t(atoi(sConfFile[page_index][1])));
-            return outDim;
-        } else if (sConfFile[page_index].size() == size1+1) {
-            outDim = make_pair(UInt_t(atoi(sConfFile[page_index][1])),
-                    UInt_t(atoi(sConfFile[page_index][2])));
-            return outDim;
-        } else {
-            cout << "Warning: newpage command has too many arguments. "
-                << "Will automatically determine dimensions of 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))));
-    outDim = make_pair(dim,dim);
-
-    return outDim;
-}
-
-TString OnlineConfig::GetPageTitle(UInt_t page)
-{
-    // Returns the title of the page.
-    //  if it is not defined in the config, then return "Page #"
-
-    TString title;
-
-    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") {
-            // Combine the strings, and return it
-            for (UInt_t j=1; j<sConfFile[iter_command+i].size(); j++) {
-                title += sConfFile[iter_command+i][j];
-                title += " ";
-            }
-            title.Chop();
-            return title;
-        }
-    }
-    title = "Page "; title += page;
-    return title;
-}
-
-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
-
-    vector <UInt_t> index;
-    UInt_t iter_command = pageInfo[page].first+1;
-
-    for(UInt_t i=0; i<pageInfo[page].second; i++) {
-        if(sConfFile[iter_command+i][0] != "title") {
-            index.push_back(iter_command+i);
-        }
-    }
-
-    return index;
-}
-
-UInt_t OnlineConfig::GetDrawCount(UInt_t page)
-{
-    // Returns the number of histograms that have been request for this page
-    UInt_t draw_count=0;
-
-    for(UInt_t i=0; i<pageInfo[page].second; i++) {
-        if(sConfFile[pageInfo[page].first+i+1][0] != "title") draw_count++;
-    }
-
-    return draw_count;
-
-}
-
-drawcommand OnlineConfig::GetDrawCommand(UInt_t page, UInt_t nCommand)
-{
-    // 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
-    //  4: treename - only for Tree variables
-    //  5: nostat
-    //  6: noshowgolden  - only for Histograms
-    //  This should probably be replaced with an actual structure
-
-    drawcommand out_command;
-    vector <UInt_t> command_vector = GetDrawIndex(page);
-    UInt_t index = command_vector[nCommand];
-
-#ifdef DEBUG
-    cout << "OnlineConfig::GetDrawCommand(" << page << ","
-        << nCommand << ")" << endl;
-#endif
-
-    // First line is the variable
-    if(sConfFile[index].size()>=1) {
-        out_command.variable = sConfFile[index][0];
-    }
-    if(sConfFile[index].size()>=2) {
-        if((sConfFile[index][1] != "-type") &&
-                (sConfFile[index][1] != "-title") &&
-                (sConfFile[index][1] != "-tree") &&
-                (sConfFile[index][1] != "-noshowgolden") &&
-                (sConfFile[index][1] != "-nostat")) {
-            if(out_command.variable=="macro") {
-                out_command.macro = sConfFile[index][1];
-            } else {
-                out_command.cut = sConfFile[index][1];
-            }
-        }
-    }
-
-    // Now go through the rest of that line..
-    for (UInt_t i=1; i<sConfFile[index].size(); i++) {
-        if(sConfFile[index][i]=="-type") {
-            out_command.type = sConfFile[index][i+1];
-            i = i+1;
-        } else if(sConfFile[index][i]=="-title") {
-            // Put the entire title, surrounded by quotes, as one TString
-            TString title;
-            UInt_t j=0;
-            for(j=i+1; j<sConfFile[index].size(); j++) {
-                TString word = sConfFile[index][j];
-                if( (word.BeginsWith("\"")) && (word.EndsWith("\"")) ) {
-                    title = word.ReplaceAll("\"","");
-                    out_command.title = title;
-                    i = j;
-                    break;
-                } else if(word.BeginsWith("\"")) {
-                    title = word.ReplaceAll("\"","");
-                } else if(word.EndsWith("\"")) {
-                    title += " " + word.ReplaceAll("\"","");
-                    out_command.title = title;
-                    i = j;
-                    break;
-                } else {
-                    title += " " + word;
-                }
-            }
-            // If we got here, and out_command.title is null... then just copy the contents
-            // of "title" to out_command.title (taking out any "'s along the way)
-            if(out_command.title.IsNull())
-                out_command.title = title.ReplaceAll("\"","");
-        } else if(sConfFile[index][i]=="-tree") {
-            out_command.treename = sConfFile[index][i+1];
-            i = i+1;
-        } else if(sConfFile[index][i]=="-nostat") {
-            out_command.nostat = "nostat";
-        } else if(sConfFile[index][i]=="-noshowgolden") {
-            out_command.noshowgolden = "noshowgolden";
-        }
-
-
-#ifdef DEBUG
-        cout << endl;
-#endif
-    }
-#ifdef DEBUG
-    cout << sConfFile[index].size() << ": ";
-    for(UInt_t i=0; i<sConfFile[index].size(); i++) {
-        cout << sConfFile[index][i] << " ";
-    }
-    cout << endl;
-#endif
-    return out_command;
-}
-
-vector <TString> OnlineConfig::SplitString(TString instring,TString delim)
-{
-    // Utility to split up a string on the deliminator.
-    //  returns a vector of strings.
-
-    vector <TString> v;
-
-    TString remainingString = instring;
-    TString tempstring = instring;
-    int i;
-
-    while (remainingString.Index(delim) != -1) {
-        i = remainingString.Index(delim);
-        tempstring.Remove(i);
-        v.push_back(tempstring);
-        remainingString.Remove(0,i+1);
-        while(remainingString.Index(delim) == 0) {
-            remainingString.Remove(0,1);
-        }
-        tempstring = remainingString;
-        // Cut out the rest, if it's a comment (starts with #)
-        if(TString(remainingString.Strip(TString::kLeading,' ')).BeginsWith("#")) {
-            tempstring = "";
-            break;
-        }
-    }
-
-    while(tempstring.EndsWith(delim)) {
-        tempstring.Chop();
-    }
-
-    if(!tempstring.IsNull()) v.push_back(tempstring);
-
-    return v;
-}
-
-void OnlineConfig::OverrideRootFile(UInt_t runnumber)
-{
-    // Override the ROOT file defined in the cfg file If
-    // protorootfile is used, construct filename using it, otherwise
-    // uses a helper macro "GetRootFileName.C(UInt_t runnumber)
-
-    if(!protorootfile.IsNull()) {
-        TString rn = "";
-        rn += runnumber;
-        protorootfile.ReplaceAll("XXXXX",rn.Data());
-        rootfilename = protorootfile;
-    } else {
-        rootfilename = GetRootFileName(runnumber);
-    }
-
-    cout << "Overridden File name: " << rootfilename << endl;
-}
-
-///////////////////////////////////////////////////////////////////
-//  Class: OnlineGUI
-//
-//    Creates a GUI to display the commands used in OnlineConfig
-//
-//
-
-OnlineGUI::OnlineGUI(OnlineConfig& config, Bool_t printonly, Bool_t rootonly,UInt_t RunNum):
-    runNumber(RunNum),
-    timer(0),
-    fFileAlive(kFALSE)
-{
-    // Constructor.  Get the config pointer, and make the GUI.
-
-    fConfig = &config;
-
-    if(printonly || rootonly) {
-        fPrintOnly=kTRUE;
-        PrintPages();
-    } else {
-        fPrintOnly=kFALSE;
-        CreateGUI(gClient->GetRoot(),200,200);
-    }
-}
-
-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");
-    if(!fRootFile.RootFile->IsOpen()) {
-        cout << "ERROR:  rootfile: " << fConfig->GetRootFile()
-            << " does not exist"
-            << endl;
-        if(fConfig->IsMonitor()) {
-            cout << "Will wait... hopefully.." << endl;
-        } else {
-#ifdef STANDALONE
-            gApplication->Terminate();
-#else
-            return;
-#endif
-        }
-    } else {
-        fFileAlive = kTRUE;
-        ObtainRunNumber();
-        // Open the Root Trees.  Give a warning if it's not there..
-        GetFileObjects(&fRootFile);
-        GetRootTree(&fRootFile);
-        GetTreeVars(&fRootFile);
-        for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
-            if(fRootFile.RootTree[i]==0) {
-                fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i);
-            }
-        }
-
-    }
-    TString goldenfilename=fConfig->GetGoldenFile();
-    if(!goldenfilename.IsNull()) {
-        fGoldenFile.RootFile = new TFile(goldenfilename,"READ");
-        if(!fGoldenFile.RootFile->IsOpen()) {
-            cout << "ERROR: goldenrootfile: " << goldenfilename
-                << " does not exist.  Oh well, no comparison plots."
-                << endl;
-            doGolden = kFALSE;
-            fGoldenFile.RootFile=NULL;
-        } else {
-            // Open the Root Trees.  Give a warning if it's not there..
-            GetFileObjects(&fGoldenFile);
-            GetRootTree(&fGoldenFile);
-            GetTreeVars(&fGoldenFile);
-            for(UInt_t i=0; i<fGoldenFile.RootTree.size(); i++) {
-                if(fGoldenFile.RootTree[i]==0) {
-                    fGoldenFile.RootTree.erase(fGoldenFile.RootTree.begin() + i);
-                }
-            }
-            doGolden = kTRUE;
-        }
-    } else {
-        doGolden=kFALSE;
-        fGoldenFile.RootFile=NULL;
-    }
-
-
-    // Create the main frame
-    fMain = new TGMainFrame(p,w,h);
-    fMain->Connect("CloseWindow()", "OnlineGUI", this, "MyCloseWindow()");
-    ULong_t lightgreen, lightblue, red, mainguicolor;
-    gClient->GetColorByName("lightgreen",lightgreen);
-    gClient->GetColorByName("lightblue",lightblue);
-    gClient->GetColorByName("red",red);
-
-    UInt_t canvas_width = fConfig->GetCanvasWidth();
-    UInt_t canvas_height = fConfig->GetCanvasHeight();
-
-    Bool_t good_color=kFALSE;
-    TString usercolor = fConfig->GetGuiColor();
-    if(!usercolor.IsNull()) {
-        good_color = gClient->GetColorByName(usercolor,mainguicolor);
-    }
-
-    if(!good_color) {
-        if(!usercolor.IsNull()) {
-            cout << "Bad guicolor (" << usercolor << ").. using default." << endl;
-        }
-        if(fConfig->IsMonitor()) {
-            // Default background color for Online Monitor
-            mainguicolor = lightgreen;
-        } else {
-            // Default background color for Normal Online Display
-            mainguicolor = lightblue;
-        }
-    }
-
-    fMain->SetBackgroundColor(mainguicolor);
-
-    // Top frame, to hold page buttons and canvas
-    fTopframe = new TGHorizontalFrame(fMain,200,200);
-    fTopframe->SetBackgroundColor(mainguicolor);
-    fMain->AddFrame(fTopframe, new TGLayoutHints(kLHintsExpandX
-                | kLHintsExpandY,10,10,10,1));
-
-    // Create a verticle frame widget with radio buttons
-    //  This will hold the page buttons
-    vframe = new TGVerticalFrame(fTopframe,40,200);
-    vframe->SetBackgroundColor(mainguicolor);
-    TString buff;
-    for(UInt_t i=0; i<fConfig->GetPageCount(); i++) {
-        buff = fConfig->GetPageTitle(i);
-        fRadioPage[i] = new TGRadioButton(vframe,buff,i);
-        fRadioPage[i]->SetBackgroundColor(mainguicolor);
-    }
-
-    fRadioPage[0]->SetState(kButtonDown);
-    current_page = 0;
-
-    for (UInt_t i=0; i<fConfig->GetPageCount(); i++) {
-        vframe->AddFrame(fRadioPage[i],
-                new TGLayoutHints(kLHintsLeft |
-                    kLHintsCenterY,5,5,3,4));
-        fRadioPage[i]->Connect("Pressed()", "OnlineGUI", this, "DoRadio()");
-    }
-    if(!fConfig->IsMonitor()) {
-        wile =
-            new TGPictureButton(vframe,
-                    gClient->GetPicture(guiDirectory+"/hcsmall.png"));
-        wile->Connect("Pressed()","OnlineGUI", this,"DoDraw()");
-    } else {
-        wile =
-            new TGPictureButton(vframe,
-                    gClient->GetPicture(guiDirectory+"/panguin.xpm"));
-        wile->Connect("Pressed()","OnlineGUI", this,"DoDrawClear(&fRootFile)");
-    }
-    wile->SetBackgroundColor(mainguicolor);
-
-    vframe->AddFrame(wile,
-            new TGLayoutHints(kLHintsBottom|kLHintsLeft,5,10,4,2));
-
-
-    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);
-    fTopframe->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandY,10,10,10,1));
-    fCanvas = fEcanvas->GetCanvas();
-
-    // Create the bottom frame.  Contains control buttons
-    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);
-    fBottomFrame->AddFrame(hframe,new TGLayoutHints(kLHintsExpandX,200,20,2,2));
-
-    fPrev = new TGTextButton(hframe,"Prev");
-    fPrev->SetBackgroundColor(mainguicolor);
-    fPrev->Connect("Clicked()","OnlineGUI",this,"DrawPrev()");
-    hframe->AddFrame(fPrev, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
-
-    fNext = new TGTextButton(hframe,"Next");
-    fNext->SetBackgroundColor(mainguicolor);
-    fNext->Connect("Clicked()","OnlineGUI",this,"DrawNext()");
-    hframe->AddFrame(fNext, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
-
-    fExit = new TGTextButton(hframe,"Exit GUI");
-    fExit->SetBackgroundColor(red);
-    fExit->Connect("Clicked()","OnlineGUI",this,"CloseGUI()");
-
-    hframe->AddFrame(fExit, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
-
-    TString Buff;
-    if(runNumber==0) {
-        Buff = "";
-    } else {
-        Buff = "Run #";
-        Buff += runNumber;
-    }
-    TGString labelBuff(Buff);
-
-    fRunNumber = new TGLabel(hframe,Buff);
-    fRunNumber->SetBackgroundColor(mainguicolor);
-    hframe->AddFrame(fRunNumber,new TGLayoutHints(kLHintsCenterX,5,5,1,1));
-
-    fPrint = new TGTextButton(hframe,"Print To &File");
-    fPrint->SetBackgroundColor(mainguicolor);
-    fPrint->Connect("Clicked()","OnlineGUI",this,"PrintToFile()");
-    hframe->AddFrame(fPrint, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
-
-
-    // Set a name to the main frame
-    if(fConfig->IsMonitor()) {
-        fMain->SetWindowName("Parity ANalysis GUI moNitor");
-    } else {
-        fMain->SetWindowName("Online Analysis GUI");
-    }
-
-    // Map all sub windows to main frame
-    fMain->MapSubwindows();
-
-    // Initialize the layout algorithm
-    fMain->Resize(fMain->GetDefaultSize());
-
-    // Map main frame
-    fMain->MapWindow();
-
-#ifdef DEBUG
-    fMain->Print();
-#endif
-
-    if(fFileAlive) DoDraw();
-
-    if(fConfig->IsMonitor()) {
-        timer = new TTimer();
-        if(fFileAlive) {
-            timer->Connect(timer,"Timeout()","OnlineGUI",this,"TimerUpdate()");
-        } else {
-            timer->Connect(timer,"Timeout()","OnlineGUI",this,"CheckRootFile()");
-        }
-        timer->Start(UPDATETIME);
-    }
-
-}
-
-void OnlineGUI::DoDraw()
-{
+///////////////////////////////////////////////////////////////////
+//  Macro to help with online analysis
+//    B. Moffit (moffit@jlab.org)
+//    - Originally written in Oct. 2003
+//  Documentation and updates available at:
+//    http://www.jlab.org/~moffit/onlineGUI/
+//
+
+#include "online.h"
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <list>
+#include <TMath.h>
+#include <TBranch.h>
+#include <TGClient.h>
+#include <TCanvas.h>
+#include <TStyle.h>
+#include <TROOT.h>
+#include <TGImageMap.h>
+#include <TGFileDialog.h>
+#include <TKey.h>
+#include <TObjString.h>
+#include <TSystem.h>
+#include <TLatex.h>
+#include <TText.h>
+#include <TGraph.h>
+#include "GetRootFileName.C"
+#include "GetRunNumber.C"
+#include "TPaveText.h"
+#ifdef STANDALONE
+#include <TApplication.h>
+#endif
+// #define DEBUGGETFILEOBJECTS
+// #define DEBUGPARSE
+// #define DEBUG
+//#define DEBUG2
+//#define NOISY
+//#define INTERNALSTYLE
+
+//TString guiDirectory = "onlineGUI_v1.2.1/";
+TString guiDirectory = "./";
+
+///////////////////////////////////////////////////////////////////
+//  Class: OnlineConfig
+//
+//     Utility class that reads in a text file (.cfg) and
+//     stores it's contents.
+//
+//
+
+OnlineConfig::OnlineConfig()
+{
+    // Constructor.  Without an argument, will use default "standard" config
+    fMonitor = kFALSE;
+    OnlineConfig("standard");
+}
+
+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"))
+        confFileName += ".cfg";
+    fMonitor = kFALSE;
+    fFoundCfg = kFALSE;
+
+    // Attempt to find the config file in specified (first argument,
+    // relative or absolute) location, then in guiDirectory
+    fConfFile = new ifstream(confFileName.Data());
+    if ( ! (*fConfFile) ) {
+        cerr << "OnlineConfig() WARNING: config file " << confFileName.Data()
+            << " does not exist" << endl;
+        cerr << " Checking the " << guiDirectory << " directory" << endl;
+        confFileName.Prepend(guiDirectory+"/");
+        fConfFile = new ifstream(confFileName.Data());
+        if ( ! (*fConfFile) ) {
+            // Didn't find it... load up the default config
+            confFileName = guiDirectory+"/default.cfg";
+            cout << "OnlineConfig()  Trying " << confFileName.Data()
+                << " as default configuration." << endl
+                << " (May be ok.)" << endl;
+            fConfFile = new ifstream(confFileName.Data());
+            if ( ! (*fConfFile) ) {
+                cerr << "OnlineConfig() WARNING: no file "
+                    << confFileName.Data() <<endl;
+                cerr << "You need a configuration to run.  Ask an expert."<<endl;
+                fFoundCfg = kFALSE;
+                //      return;
+            } else {
+                fFoundCfg = kTRUE;
+            }
+        } else {
+            fFoundCfg = kTRUE;
+        }
+    } else {
+        fFoundCfg = kTRUE;
+    }
+
+    if(fFoundCfg) {
+        clog << "GUI Configuration loading from "
+            << confFileName.Data() << endl;
+    }
+
+    ParseFile();
+
+    // Load up a user configurable style (if it exists)
+    TString styleFile = guiDirectory+"onlineGUI_Style.C";
+    if(!gSystem->AccessPathName(styleFile))
+        gROOT->Macro(styleFile);
+
+    fConfFile->close();
+    delete fConfFile;
+
+}
+
+void OnlineConfig::ParseFile()
+{
+    // Reads in the Config File, and makes the proper calls to put
+    //  the information contained into memory.
+
+    if(!fFoundCfg) {
+        return;
+    }
+
+    TString comment = "#";
+    vector<TString> strvect;
+    TString sinput, sline;
+    while (sline.ReadLine(*fConfFile)) {
+        strvect.clear();
+        // Strip away leading and trailing spaces.
+        sline = sline.Strip(TString::kBoth,' ');
+        // If the line starts with a comment, skip it.
+        if(sline.BeginsWith(comment)) continue;
+        // If the line contains a comment, split it up into two and keep
+        // the uncommented (first) part
+        if(sline.Contains(comment)) {
+            TObjArray *tmpoarr = sline.Tokenize(comment);
+            TObjString *tmpostr = (TObjString*)tmpoarr->First();
+            sline = tmpostr->GetString().Strip(TString::kTrailing,' ');
+            delete tmpoarr;
+        }
+        // Now split up the line according to 's and spaces.  This is for
+        // looking for the histogram using it's title (which may contain
+        // spaces) instead of its name.
+        if(sline.Contains("'")) {
+            TObjArray *tmpoarr = sline.Tokenize("'");
+            Bool_t quote_on_odd = kTRUE;
+            if(!(sline.BeginsWith("'"))) quote_on_odd=kFALSE;
+            TIterator *next = tmpoarr->MakeIterator();
+            TObjString *tmpostr; Bool_t odd=kTRUE;
+            while((tmpostr=(TObjString*)next->Next())!=NULL) {
+                if((quote_on_odd&&odd) || (!quote_on_odd&&!odd)) {
+                    strvect.push_back(tmpostr->GetString());
+                    odd = !odd;
+                } else {
+                    TObjArray *tmpoarr2 = tmpostr->GetString().Tokenize(" ");
+                    TIterator *next2 = tmpoarr2->MakeIterator();
+                    TObjString *tmpostr2;
+                    while((tmpostr2=(TObjString*)next2->Next())!=NULL) {
+                        strvect.push_back(tmpostr2->GetString());
+                    }
+                    delete tmpoarr2;
+                    odd = !odd;
+                }
+            }
+            delete tmpoarr;
+        } else { // No 's.. just split according to spaces
+            TObjArray *tmpoarr2 = sline.Tokenize(" ");
+            TIterator *next2 = tmpoarr2->MakeIterator();
+            TObjString *tmpostr2;
+            while((tmpostr2=(TObjString*)next2->Next())!=NULL) {
+                strvect.push_back(tmpostr2->GetString());
+            }
+            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++)
+            cout << sConfFile[ii][jj] << " ";
+        cout << endl;
+    }
+#endif
+
+    cout << "     " << sConfFile.size() << " lines read from "
+        << confFileName << endl;
+
+}
+
+Bool_t OnlineConfig::ParseConfig()
+{
+    //  Goes through each line of the config [must have been ParseFile()'d]
+    //   and interprets.
+
+    if(!fFoundCfg) {
+        return kFALSE;
+    }
+
+    UInt_t command_cnt=0;
+    UInt_t j=0;
+    Bool_t hasMultiPlots=kFALSE;
+    canvaswidth = 800;		// Default canvas size
+    canvasheight = 600;
+    // If statement for each high level command (cut, newpage, etc)
+    for(UInt_t i=0;i<sConfFile.size();i++) {
+        // "newpage" command
+        if(sConfFile[i][0] == "newpage") {
+            // sConfFile[i] is first of pair
+            for(j=i+1;j<sConfFile.size();j++) {
+                if(sConfFile[j][0] != "newpage") {
+                    // Count how many commands within the page
+                    command_cnt++;
+                } else break;
+            }
+            pageInfo.push_back(make_pair(i,command_cnt));
+            i += command_cnt;
+            command_cnt=0;
+        }
+        if(sConfFile[i][0] == "watchfile") {
+            fMonitor = kTRUE;
+        }
+        if(sConfFile[i][0] == "definecut") {
+            if(sConfFile[i].size()>3) {
+                cerr << "cut command has too many arguments" << endl;
+                continue;
+            }
+            TCut tempCut(sConfFile[i][1],sConfFile[i][2]);
+            cutList.push_back(tempCut);
+        }
+        if(sConfFile[i][0] == "rootfile") {
+            if(sConfFile[i].size() != 2) {
+                cerr << "WARNING: rootfile command does not have the "
+                    << "correct number of arguments"
+                    << endl;
+                continue;
+            }
+            if(!rootfilename.IsNull()) {
+                cerr << "WARNING: too many rootfile's defined. "
+                    << " Will only use the first one."
+                    << endl;
+                continue;
+            }
+            rootfilename = sConfFile[i][1];
+        }
+        if(sConfFile[i][0] == "goldenrootfile") {
+            if(sConfFile[i].size() != 2) {
+                cerr << "WARNING: goldenfile command does not have the "
+                    << "correct number of arguments"
+                    << endl;
+                continue;
+            }
+            if(!goldenrootfilename.IsNull()) {
+                cerr << "WARNING: too many goldenrootfile's defined. "
+                    << " Will only use the first one."
+                    << endl;
+                continue;
+            }
+            goldenrootfilename = sConfFile[i][1];
+        }
+        if(sConfFile[i][0] == "protorootfile") {
+            if(sConfFile[i].size() != 2) {
+                cerr << "WARNING: protorootfile command does not have the "
+                    << "correct number of arguments"
+                    << endl;
+                continue;
+            }
+            if(!protorootfile.IsNull()) {
+                cerr << "WARNING: too many protorootfile's defined. "
+                    << " Will only use the first one."
+                    << endl;
+                continue;
+            }
+            protorootfile = sConfFile[i][1];
+        }
+        if(sConfFile[i][0] == "guicolor") {
+            if(sConfFile[i].size() != 2) {
+                cerr << "WARNING: guicolor command does not have the "
+                    << "correct number of arguments (needs 1)"
+                    << endl;
+                continue;
+            }
+            if(!guicolor.IsNull()) {
+                cerr << "WARNING: too many guicolor's defined. "
+                    << " Will only use the first one."
+                    << endl;
+                continue;
+            }
+            guicolor = sConfFile[i][1];
+        }
+        if(sConfFile[i][0] == "canvassize") {
+            if(sConfFile[i].size() != 3) {
+                cerr << "WARNING: canvassize command does not have the "
+                    << "correct number of arguments (needs 2)"
+                    << endl;
+                continue;
+            }
+            canvaswidth = UInt_t(atoi(sConfFile[i][1]));
+            canvasheight = UInt_t(atoi(sConfFile[i][2]));
+        }
+        if(sConfFile[i][0] == "plotsdir") {
+            if(sConfFile[i].size() != 2) {
+                cerr << "WARNING: plotsdir command does not have the "
+                    << "correct number of arguments (needs 1)"
+                    << endl;
+                continue;
+            }
+            if(!plotsdir.IsNull()) {
+                cerr << "WARNING: too many plotdir's defined. "
+                    << " Will only use the first one."
+                    << endl;
+                continue;
+            }
+            plotsdir = sConfFile[i][1];
+        }
+        if(sConfFile[i][0] == "multiplot") {
+            hasMultiPlots = kTRUE;
+        }
+
+    }
+
+    if(hasMultiPlots) {
+        if(!ParseForMultiPlots()) {
+            cerr << "ParseForMultiPlots() Failed" << endl;
+        }
+    }
+
+#ifdef NOISY
+    for(UInt_t i=0; i<GetPageCount(); i++) {
+        cout << "Page " << i << " (" << GetPageTitle(i) << ")"
+            << " will draw " << GetDrawCount(i)
+            << " histograms." << endl;
+    }
+#endif
+
+    cout << "Number of pages defined = " << GetPageCount() << endl;
+    cout << "Number of cuts defined = " << cutList.size() << endl;
+
+    if (fMonitor)
+        cout << "Will periodically update plots" << endl;
+    if(!goldenrootfilename.IsNull()) {
+        cout << "Will compare chosen histrograms with the golden rootfile: "
+            << endl
+            << goldenrootfilename << endl;
+    }
+
+    return kTRUE;
+
+}
+
+Bool_t OnlineConfig::ParseForMultiPlots() {
+    // Parse through each line of sConfFile,
+    // and replace each "multiplot" command with a real draw entry
+
+    vector < vector <TString> > newConfFile;
+    for(UInt_t iter=0;iter<sConfFile.size();iter++) {
+        if(sConfFile[iter][0]=="multiplot") {
+            // 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++) {
+                vector <TString> newline;
+                for(UInt_t ielem=3; ielem<sConfFile[iter].size();ielem++) {
+                    TString origString = sConfFile[iter][ielem];
+                    TString newString = origString;
+                    newString.ReplaceAll("XXXXX",Form("%d",imult));
+                    newline.push_back(newString);
+                }
+                newConfFile.push_back(newline);
+            }
+        } else {
+            newConfFile.push_back(sConfFile[iter]);
+        }
+    }
+
+#ifdef DEBUG
+    for(UInt_t iter=0;iter<newConfFile.size();iter++) {
+        for(UInt_t iline=0;iline<newConfFile[iter].size();iline++) {
+            cout << newConfFile[iter][iline] << " ";
+        }
+        cout << endl;
+    }
+#endif
+
+    // Out with the old, in with the new.
+    sConfFile.clear();
+    sConfFile = newConfFile;
+
+    // Now need to recalculate pageInfo.
+    UInt_t command_cnt=0;
+    UInt_t j=0;
+
+    pageInfo.clear();
+    // If statement for each high level command (cut, newpage, etc)
+    for(UInt_t i=0;i<sConfFile.size();i++) {
+        // "newpage" command
+        if(sConfFile[i][0] == "newpage") {
+            // sConfFile[i] is first of pair
+            for(j=i+1;j<sConfFile.size();j++) {
+                if(sConfFile[j][0] != "newpage") {
+                    // Count how many commands within the page
+                    command_cnt++;
+                } else break;
+            }
+            pageInfo.push_back(make_pair(i,command_cnt));
+            i += command_cnt;
+            command_cnt=0;
+        }
+    }
+
+    return kTRUE;
+
+}
+
+TCut OnlineConfig::GetDefinedCut(TString ident) {
+    // Returns the defined cut, according to the identifier
+
+    for(UInt_t i=0; i<cutList.size(); i++) {
+        if((TString)cutList[i].GetName() == ident.Data()) {
+            TCut tempCut = cutList[i].GetTitle();
+            return tempCut;
+        }
+    }
+    return "";
+}
+
+vector <TString> OnlineConfig::GetCutIdent() {
+    // Returns a vector of the cut identifiers, specified in config
+    vector <TString> out;
+
+    for(UInt_t i=0; i<cutList.size(); i++) {
+        out.push_back(cutList[i].GetName());
+    }
+
+    return out;
+}
+
+Bool_t OnlineConfig::IsLogx(UInt_t page) {
+    // Check if last word on line is "logx"
+
+    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];
+    if(option == "logx") return kTRUE;
+    return kFALSE;
+
+}
+
+Bool_t OnlineConfig::IsLogy(UInt_t page) {
+    // Check if last word on line is "logy"
+
+    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];
+    if(option == "logy") return kTRUE;
+    return kFALSE;
+
+}
+
+Bool_t OnlineConfig::IsLogz(UInt_t page) {
+    // Check if last word on line is "logz"
+
+    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];
+    if(option == "logz") return kTRUE;
+    return kFALSE;
+
+}
+
+
+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
+    //  calculated dimensions required to fit all histograms.
+
+    pair <UInt_t, UInt_t> outDim;
+
+    // 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) {
+            outDim = make_pair(UInt_t(atoi(sConfFile[page_index][1])),
+                    UInt_t(atoi(sConfFile[page_index][1])));
+            return outDim;
+        } else if (sConfFile[page_index].size() == size1+1) {
+            outDim = make_pair(UInt_t(atoi(sConfFile[page_index][1])),
+                    UInt_t(atoi(sConfFile[page_index][2])));
+            return outDim;
+        } else {
+            cout << "Warning: newpage command has too many arguments. "
+                << "Will automatically determine dimensions of 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))));
+    outDim = make_pair(dim,dim);
+
+    return outDim;
+}
+
+TString OnlineConfig::GetPageTitle(UInt_t page)
+{
+    // Returns the title of the page.
+    //  if it is not defined in the config, then return "Page #"
+
+    TString title;
+
+    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") {
+            // Combine the strings, and return it
+            for (UInt_t j=1; j<sConfFile[iter_command+i].size(); j++) {
+                title += sConfFile[iter_command+i][j];
+                title += " ";
+            }
+            title.Chop();
+            return title;
+        }
+    }
+    title = "Page "; title += page;
+    return title;
+}
+
+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
+
+    vector <UInt_t> index;
+    UInt_t iter_command = pageInfo[page].first+1;
+
+    for(UInt_t i=0; i<pageInfo[page].second; i++) {
+        if(sConfFile[iter_command+i][0] != "title") {
+            index.push_back(iter_command+i);
+        }
+    }
+
+    return index;
+}
+
+UInt_t OnlineConfig::GetDrawCount(UInt_t page)
+{
+    // Returns the number of histograms that have been request for this page
+    UInt_t draw_count=0;
+
+    for(UInt_t i=0; i<pageInfo[page].second; i++) {
+        if(sConfFile[pageInfo[page].first+i+1][0] != "title") draw_count++;
+    }
+
+    return draw_count;
+
+}
+
+drawcommand OnlineConfig::GetDrawCommand(UInt_t page, UInt_t nCommand)
+{
+    // 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
+    //  4: treename - only for Tree variables
+    //  5: nostat
+    //  6: noshowgolden  - only for Histograms
+    //  This should probably be replaced with an actual structure
+
+    drawcommand out_command;
+    vector <UInt_t> command_vector = GetDrawIndex(page);
+    UInt_t index = command_vector[nCommand];
+
+#ifdef DEBUG
+    cout << "OnlineConfig::GetDrawCommand(" << page << ","
+        << nCommand << ")" << endl;
+#endif
+
+    // First line is the variable
+    if(sConfFile[index].size()>=1) {
+        out_command.variable = sConfFile[index][0];
+    }
+    if(sConfFile[index].size()>=2) {
+        if((sConfFile[index][1] != "-type") &&
+                (sConfFile[index][1] != "-title") &&
+                (sConfFile[index][1] != "-tree") &&
+                (sConfFile[index][1] != "-noshowgolden") &&
+                (sConfFile[index][1] != "-nostat")) {
+            if(out_command.variable=="macro") {
+                out_command.macro = sConfFile[index][1];
+            } else {
+                out_command.cut = sConfFile[index][1];
+            }
+        }
+    }
+
+    // Now go through the rest of that line..
+    for (UInt_t i=1; i<sConfFile[index].size(); i++) {
+        if(sConfFile[index][i]=="-type") {
+            out_command.type = sConfFile[index][i+1];
+            i = i+1;
+        } else if(sConfFile[index][i]=="-title") {
+            // Put the entire title, surrounded by quotes, as one TString
+            TString title;
+            UInt_t j=0;
+            for(j=i+1; j<sConfFile[index].size(); j++) {
+                TString word = sConfFile[index][j];
+                if( (word.BeginsWith("\"")) && (word.EndsWith("\"")) ) {
+                    title = word.ReplaceAll("\"","");
+                    out_command.title = title;
+                    i = j;
+                    break;
+                } else if(word.BeginsWith("\"")) {
+                    title = word.ReplaceAll("\"","");
+                } else if(word.EndsWith("\"")) {
+                    title += " " + word.ReplaceAll("\"","");
+                    out_command.title = title;
+                    i = j;
+                    break;
+                } else {
+                    title += " " + word;
+                }
+            }
+            // If we got here, and out_command.title is null... then just copy the contents
+            // of "title" to out_command.title (taking out any "'s along the way)
+            if(out_command.title.IsNull())
+                out_command.title = title.ReplaceAll("\"","");
+        } else if(sConfFile[index][i]=="-tree") {
+            out_command.treename = sConfFile[index][i+1];
+            i = i+1;
+        } else if(sConfFile[index][i]=="-nostat") {
+            out_command.nostat = "nostat";
+        } else if(sConfFile[index][i]=="-noshowgolden") {
+            out_command.noshowgolden = "noshowgolden";
+        }
+
+
+#ifdef DEBUG
+        cout << endl;
+#endif
+    }
+#ifdef DEBUG
+    cout << sConfFile[index].size() << ": ";
+    for(UInt_t i=0; i<sConfFile[index].size(); i++) {
+        cout << sConfFile[index][i] << " ";
+    }
+    cout << endl;
+#endif
+    return out_command;
+}
+
+vector <TString> OnlineConfig::SplitString(TString instring,TString delim)
+{
+    // Utility to split up a string on the deliminator.
+    //  returns a vector of strings.
+
+    vector <TString> v;
+
+    TString remainingString = instring;
+    TString tempstring = instring;
+    int i;
+
+    while (remainingString.Index(delim) != -1) {
+        i = remainingString.Index(delim);
+        tempstring.Remove(i);
+        v.push_back(tempstring);
+        remainingString.Remove(0,i+1);
+        while(remainingString.Index(delim) == 0) {
+            remainingString.Remove(0,1);
+        }
+        tempstring = remainingString;
+        // Cut out the rest, if it's a comment (starts with #)
+        if(TString(remainingString.Strip(TString::kLeading,' ')).BeginsWith("#")) {
+            tempstring = "";
+            break;
+        }
+    }
+
+    while(tempstring.EndsWith(delim)) {
+        tempstring.Chop();
+    }
+
+    if(!tempstring.IsNull()) v.push_back(tempstring);
+
+    return v;
+}
+
+void OnlineConfig::OverrideRootFile(UInt_t runnumber)
+{
+    // Override the ROOT file defined in the cfg file If
+    // protorootfile is used, construct filename using it, otherwise
+    // uses a helper macro "GetRootFileName.C(UInt_t runnumber)
+
+    if(!protorootfile.IsNull()) {
+        TString rn = "";
+        rn += runnumber;
+        protorootfile.ReplaceAll("XXXXX",rn.Data());
+        rootfilename = protorootfile;
+    } else {
+        rootfilename = GetRootFileName(runnumber);
+    }
+
+    cout << "Overridden File name: " << rootfilename << endl;
+}
+
+///////////////////////////////////////////////////////////////////
+//  Class: OnlineGUI
+//
+//    Creates a GUI to display the commands used in OnlineConfig
+//
+//
+
+OnlineGUI::OnlineGUI(OnlineConfig& config, Bool_t printonly, Bool_t rootonly,UInt_t RunNum):
+    runNumber(RunNum),
+    timer(0),
+    fFileAlive(kFALSE)
+{
+    // Constructor.  Get the config pointer, and make the GUI.
+
+    fConfig = &config;
+
+    if(printonly || rootonly) {
+        fPrintOnly=kTRUE;
+        PrintPages();
+    } else {
+        fPrintOnly=kFALSE;
+        CreateGUI(gClient->GetRoot(),200,200);
+    }
+}
+
+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");
+    if(!fRootFile.RootFile->IsOpen()) {
+        cout << "ERROR:  rootfile: " << fConfig->GetRootFile()
+            << " does not exist"
+            << endl;
+        if(fConfig->IsMonitor()) {
+            cout << "Will wait... hopefully.." << endl;
+        } else {
+#ifdef STANDALONE
+            gApplication->Terminate();
+#else
+            return;
+#endif
+        }
+    } else {
+        fFileAlive = kTRUE;
+        ObtainRunNumber();
+        // Open the Root Trees.  Give a warning if it's not there..
+        GetFileObjects(&fRootFile);
+        GetRootTree(&fRootFile);
+        GetTreeVars(&fRootFile);
+        for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
+            if(fRootFile.RootTree[i]==0) {
+                fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i);
+            }
+        }
+
+    }
+    TString goldenfilename=fConfig->GetGoldenFile();
+    if(!goldenfilename.IsNull()) {
+        fGoldenFile.RootFile = new TFile(goldenfilename,"READ");
+        if(!fGoldenFile.RootFile->IsOpen()) {
+            cout << "ERROR: goldenrootfile: " << goldenfilename
+                << " does not exist.  Oh well, no comparison plots."
+                << endl;
+            doGolden = kFALSE;
+            fGoldenFile.RootFile=NULL;
+        } else {
+            // Open the Root Trees.  Give a warning if it's not there..
+            GetFileObjects(&fGoldenFile);
+            GetRootTree(&fGoldenFile);
+            GetTreeVars(&fGoldenFile);
+            for(UInt_t i=0; i<fGoldenFile.RootTree.size(); i++) {
+                if(fGoldenFile.RootTree[i]==0) {
+                    fGoldenFile.RootTree.erase(fGoldenFile.RootTree.begin() + i);
+                }
+            }
+            doGolden = kTRUE;
+        }
+    } else {
+        doGolden=kFALSE;
+        fGoldenFile.RootFile=NULL;
+    }
+
+
+    // Create the main frame
+    fMain = new TGMainFrame(p,w,h);
+    fMain->Connect("CloseWindow()", "OnlineGUI", this, "MyCloseWindow()");
+    ULong_t lightgreen, lightblue, red, mainguicolor;
+    gClient->GetColorByName("lightgreen",lightgreen);
+    gClient->GetColorByName("lightblue",lightblue);
+    gClient->GetColorByName("red",red);
+
+    UInt_t canvas_width = fConfig->GetCanvasWidth();
+    UInt_t canvas_height = fConfig->GetCanvasHeight();
+
+    Bool_t good_color=kFALSE;
+    TString usercolor = fConfig->GetGuiColor();
+    if(!usercolor.IsNull()) {
+        good_color = gClient->GetColorByName(usercolor,mainguicolor);
+    }
+
+    if(!good_color) {
+        if(!usercolor.IsNull()) {
+            cout << "Bad guicolor (" << usercolor << ").. using default." << endl;
+        }
+        if(fConfig->IsMonitor()) {
+            // Default background color for Online Monitor
+            mainguicolor = lightgreen;
+        } else {
+            // Default background color for Normal Online Display
+            mainguicolor = lightblue;
+        }
+    }
+
+    fMain->SetBackgroundColor(mainguicolor);
+
+    // Top frame, to hold page buttons and canvas
+    fTopframe = new TGHorizontalFrame(fMain,200,200);
+    fTopframe->SetBackgroundColor(mainguicolor);
+    fMain->AddFrame(fTopframe, new TGLayoutHints(kLHintsExpandX
+                | kLHintsExpandY,10,10,10,1));
+
+    // Create a verticle frame widget with radio buttons
+    //  This will hold the page buttons
+    vframe = new TGVerticalFrame(fTopframe,40,200);
+    vframe->SetBackgroundColor(mainguicolor);
+    TString buff;
+    for(UInt_t i=0; i<fConfig->GetPageCount(); i++) {
+        buff = fConfig->GetPageTitle(i);
+        fRadioPage[i] = new TGRadioButton(vframe,buff,i);
+        fRadioPage[i]->SetBackgroundColor(mainguicolor);
+    }
+
+    fRadioPage[0]->SetState(kButtonDown);
+    current_page = 0;
+
+    for (UInt_t i=0; i<fConfig->GetPageCount(); i++) {
+        vframe->AddFrame(fRadioPage[i],
+                new TGLayoutHints(kLHintsLeft |
+                    kLHintsCenterY,5,5,3,4));
+        fRadioPage[i]->Connect("Pressed()", "OnlineGUI", this, "DoRadio()");
+    }
+    if(!fConfig->IsMonitor()) {
+        wile =
+            new TGPictureButton(vframe,
+                    gClient->GetPicture(guiDirectory+"/hcsmall.png"));
+        wile->Connect("Pressed()","OnlineGUI", this,"DoDraw()");
+    } else {
+        wile =
+            new TGPictureButton(vframe,
+                    gClient->GetPicture(guiDirectory+"/panguin.xpm"));
+        wile->Connect("Pressed()","OnlineGUI", this,"DoDrawClear(&fRootFile)");
+    }
+    wile->SetBackgroundColor(mainguicolor);
+
+    vframe->AddFrame(wile,
+            new TGLayoutHints(kLHintsBottom|kLHintsLeft,5,10,4,2));
+
+
+    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);
+    fTopframe->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandY,10,10,10,1));
+    fCanvas = fEcanvas->GetCanvas();
+
+    // Create the bottom frame.  Contains control buttons
+    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);
+    fBottomFrame->AddFrame(hframe,new TGLayoutHints(kLHintsExpandX,200,20,2,2));
+
+    fPrev = new TGTextButton(hframe,"Prev");
+    fPrev->SetBackgroundColor(mainguicolor);
+    fPrev->Connect("Clicked()","OnlineGUI",this,"DrawPrev()");
+    hframe->AddFrame(fPrev, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
+
+    fNext = new TGTextButton(hframe,"Next");
+    fNext->SetBackgroundColor(mainguicolor);
+    fNext->Connect("Clicked()","OnlineGUI",this,"DrawNext()");
+    hframe->AddFrame(fNext, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
+
+    fExit = new TGTextButton(hframe,"Exit GUI");
+    fExit->SetBackgroundColor(red);
+    fExit->Connect("Clicked()","OnlineGUI",this,"CloseGUI()");
+
+    hframe->AddFrame(fExit, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
+
+    TString Buff;
+    if(runNumber==0) {
+        Buff = "";
+    } else {
+        Buff = "Run #";
+        Buff += runNumber;
+    }
+    TGString labelBuff(Buff);
+
+    fRunNumber = new TGLabel(hframe,Buff);
+    fRunNumber->SetBackgroundColor(mainguicolor);
+    hframe->AddFrame(fRunNumber,new TGLayoutHints(kLHintsCenterX,5,5,1,1));
+
+    fPrint = new TGTextButton(hframe,"Print To &File");
+    fPrint->SetBackgroundColor(mainguicolor);
+    fPrint->Connect("Clicked()","OnlineGUI",this,"PrintToFile()");
+    hframe->AddFrame(fPrint, new TGLayoutHints(kLHintsCenterX,5,5,1,1));
+
+
+    // Set a name to the main frame
+    if(fConfig->IsMonitor()) {
+        fMain->SetWindowName("Parity ANalysis GUI moNitor");
+    } else {
+        fMain->SetWindowName("Online Analysis GUI");
+    }
+
+    // Map all sub windows to main frame
+    fMain->MapSubwindows();
+
+    // Initialize the layout algorithm
+    fMain->Resize(fMain->GetDefaultSize());
+
+    // Map main frame
+    fMain->MapWindow();
+
+#ifdef DEBUG
+    fMain->Print();
+#endif
+
+    if(fFileAlive) DoDraw();
+
+    if(fConfig->IsMonitor()) {
+        timer = new TTimer();
+        if(fFileAlive) {
+            timer->Connect(timer,"Timeout()","OnlineGUI",this,"TimerUpdate()");
+        } else {
+            timer->Connect(timer,"Timeout()","OnlineGUI",this,"CheckRootFile()");
+        }
+        timer->Start(UPDATETIME);
+    }
+
+}
+
+void OnlineGUI::DoDraw()
+{
  
-  // The main Drawing Routine.
- 
-#ifdef INTERNALSTYLE
-    gStyle->SetOptStat(1110);
-    gStyle->SetStatFontSize(0.1);
-#endif
-    if (fConfig->IsLogx(current_page)) {
-        gStyle->SetOptLogx(1);
-    } else {
-        gStyle->SetOptLogx(0);
-    }
-    if (fConfig->IsLogy(current_page)) {
-        gStyle->SetOptLogy(1);
-    } else {
-        gStyle->SetOptLogy(0);
-    }
-    if (fConfig->IsLogz(current_page)) {
-        gStyle->SetOptLogz(1);
-    } else {
-        gStyle->SetOptLogz(0);
-    }
-#ifdef INTERNALSTYLE
-  gStyle->SetTitleH(0.10);
-  gStyle->SetTitleW(0.40);
-  //gStyle->SetLabelSize(0.10,"X");
-  //gStyle->SetLabelSize(0.10,"Y");
-  gStyle->SetLabelSize(0.05,"X");
-  gStyle->SetLabelSize(0.05,"Y");
-  gStyle->SetTitleSize(0.045,"X");
-  gStyle->SetTitleSize(0.045,"Y");
-  gStyle->SetPadLeftMargin(0.14);
-  gStyle->SetNdivisions(505,"X");
-  gStyle->SetNdivisions(404,"Y");
-  gStyle->SetPalette(1);
-  gROOT->ForceStyle();
-#endif
-
-    // Determine the dimensions of the canvas..
-    UInt_t draw_count = fConfig->GetDrawCount(current_page);
-#ifdef INTERNALSTYLE
-    if(draw_count>=8) {
-        gStyle->SetLabelSize(0.08,"X");
-        gStyle->SetLabelSize(0.08,"Y");
-    }
-#endif
-    //   Int_t dim = Int_t(round(sqrt(double(draw_count))));
-    pair <UInt_t,UInt_t> dim = fConfig->GetPageDim(current_page);
-
-#ifdef DEBUG
-    cout << "Dimensions: " << dim.first << "X"
-        << dim.second << endl;
-#endif
-
-    // Create a nice clean canvas.
-    fCanvas->Clear();
-    fCanvas->Divide(dim.first,dim.second);
-
-    drawcommand thiscommand;
-    // Draw the histograms.
-    for(UInt_t i=0; i<draw_count; i++) {
-        thiscommand = fConfig->GetDrawCommand(current_page,i);
-        thiscommand = fileObject2command(thiscommand,&fRootFile);
-        fCanvas->cd(i+1);
-        if (thiscommand.variable == "macro") {
-            MacroDraw(thiscommand);
-        } else if (thiscommand.objtype.Contains("TH")) {
-            HistDraw(thiscommand);
-        } else if (thiscommand.objtype.Contains("TCanvas")) {
-            CanvasDraw(thiscommand,i+1);
-        } else if (thiscommand.objtype.Contains("TGraph")) {
-            GraphDraw(thiscommand);
-        } else { // otherwise... assume that the objtype is a branch from a tree
-            TreeDraw(thiscommand);
-        }
-    }
-
-    fCanvas->cd();
-    fCanvas->Update();
-
-    if(!fPrintOnly) {
-        CheckPageButtons();
-    }
-
-}
-
-void OnlineGUI::DrawNext()
-{
-    // Handler for the "Next" button.
-    fRadioPage[current_page]->SetState(kButtonUp);
-    // The following line triggers DoRadio()
-    fRadioPage[current_page+1]->SetState(kButtonDown,true);
-
-}
-
-void OnlineGUI::DrawPrev()
-{
-    // Handler for the "Prev" button.
-    fRadioPage[current_page]->SetState(kButtonUp);
-    // The following line triggers DoRadio()
-    fRadioPage[current_page-1]->SetState(kButtonDown,true);
-
-}
-
-void OnlineGUI::DoRadio()
-{
-    // Handle the radio buttons
-    //  Find out which button has been pressed..
-    //   turn off the previous button...
-    //   then draw the appropriate page.
-    // This routine also handles the Draw from the Prev/Next buttons
-    //   - makes a call to DoDraw()
-
-    UInt_t pagecount = fConfig->GetPageCount();
-    TGButton *btn = (TGButton *) gTQSender;
-    UInt_t id = btn->WidgetId();
-
-    if (id <= pagecount) {
-        fRadioPage[current_page]->SetState(kButtonUp);
-    }
-
-    current_page = id;
-    if(!fConfig->IsMonitor()) DoDraw();
-
-}
-
-void OnlineGUI::CheckPageButtons()
-{
-    // Checks the current page to see if it's the first or last page.
-    //  If so... turn off the appropriate button.
-    //  If not.. turn on both buttons.
-
-    if(current_page==0) {
-        fPrev->SetState(kButtonDisabled);
-        if(fConfig->GetPageCount()!=1)
-            fNext->SetState(kButtonUp);
-    } else if(current_page==fConfig->GetPageCount()-1) {
-        fNext->SetState(kButtonDisabled);
-        if(fConfig->GetPageCount()!=1)
-            fPrev->SetState(kButtonUp);
-    } else {
-        fPrev->SetState(kButtonUp);
-        fNext->SetState(kButtonUp);
-    }
-}
-
-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
-    //    (in case the the name is not very descriptive... like when
-    //    using h2root)
-    //  If there's no good keys.. do nothing.
-#ifdef DEBUGGETFILEOBJECTS
-    cout << "Keys = " << fLocalRootFileObj->RootFile->ReadKeys() << endl;
-#endif
-    if(fLocalRootFileObj->RootFile->ReadKeys()==0) {
-        fLocalRootFileObj->fUpdate = kFALSE;
-        //     delete fLocalRootFileObj->RootFile;
-        //     fLocalRootFileObj->RootFile = 0;
-        //     CheckRootFile();
-        return;
-    }
-    fLocalRootFileObj->vfileObjects.clear();
-
-    TIter next( (fLocalRootFileObj->RootFile)->GetListOfKeys() );
-    TKey *key = new TKey();
-
-    // Do the search
-    while((key=(TKey*)next())!=0) {
-#ifdef DEBUGGETFILEOBJECTS
-        cout << "Key = " << key << endl;
-#endif
-        TString objname = key->GetName();
-        TString objtype = key->GetClassName();
-        TString objtitle = key->GetTitle();
-#ifdef DEBUGGETFILEOBJECTS
-        cout << objname << " " << objtype << endl;
-#endif
-
-        if(objtype.Contains("TDirectory")) {
-            TDirectory *thisdir = (TDirectory*)fLocalRootFileObj->RootFile->Get(objname);
-            TIter nextInDir(thisdir->GetListOfKeys());
-            TKey *innerkey = new TKey();
-            while((innerkey=(TKey*)nextInDir())!=0) {
-                TString iobjname = innerkey->GetName();
-                TString iobjtype = innerkey->GetClassName();
-                TString iobjtitle = innerkey->GetTitle();
-                TString iobjdir = objname;
-#ifdef DEBUGGETFILEOBJECTS
-                cout << iobjname << " " << iobjtype << endl;
-#endif
-                fileObject thisObject;
-                thisObject.name = iobjname;
-                thisObject.type = iobjtype;
-                thisObject.title = iobjtitle;
-                thisObject.directory = objname;
-                fLocalRootFileObj->vfileObjects.push_back(thisObject);
-            }
-        } else {
-            fileObject thisObject;
-            thisObject.name = objname;
-            thisObject.type = objtype;
-            thisObject.title = objtitle;
-            thisObject.directory = "";
-            fLocalRootFileObj->vfileObjects.push_back(thisObject);
-        }
-
-    }
-    fLocalRootFileObj->fUpdate = kTRUE;
-    delete key;
-}
-
-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.
-    fLocalRootFileObj->TreeVars.clear();
-    TObjArray *branchList;
-    vector <TString> currentTree;
-
-    for(UInt_t i=0; i<fLocalRootFileObj->RootTree.size(); i++) {
-        currentTree.clear();
-        branchList = fLocalRootFileObj->RootTree[i]->GetListOfBranches();
-        TIter next(branchList);
-        TBranch *brc;
-
-        while((brc=(TBranch*)next())!=0) {
-            TString found = brc->GetName();
-            // Not sure if the line below is so smart...
-            currentTree.push_back(found);
-        }
-        fLocalRootFileObj->TreeVars.push_back(currentTree);
-    }
-#ifdef DEBUG2
-    for(UInt_t iTree=0; iTree<fLocalRootFileObj->TreeVars.size(); iTree++) {
-        cout << "In Tree " << iTree << ": " << endl;
-        for(UInt_t i=0; i<fLocalRootFileObj->TreeVars[iTree].size(); i++) {
-            cout << fLocalRootFileObj->TreeVars[iTree][i] << endl;
-        }
-    }
-#endif
-}
-
-
-void OnlineGUI::GetRootTree(RootFileObject* fLocalRootFileObj ) {
-    // Utility to search a ROOT File for ROOT Trees
-    // Fills the RootTree vector
-    fLocalRootFileObj->RootTree.clear();
-
-    list <TString> found;
-    for(UInt_t i=0; i<fLocalRootFileObj->vfileObjects.size(); i++) {
-#ifdef DEBUGGETROOTTREE
-        cout << "Object = " << fLocalRootFileObj->vfileObjects[i].type <<
-            "     Name = " << fLocalRootFileObj->vfileObjects[i].name << endl;
-#endif
-        if(fLocalRootFileObj->vfileObjects[i].type.Contains("TTree"))
-            found.push_back(fLocalRootFileObj->vfileObjects[i].name);
-    }
-
-    // Remove duplicates, then insert into fLocalRootFileObj->RootTree
-    found.unique();
-    UInt_t nTrees = found.size();
-
-    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).
-    // Returns the correct index.  if not found returns an index 1
-    // larger than fRootFile.RootTree.size()
-
-    //  This is for 2d draws... look for the first only
-    if(var.Contains(":")) {
-        TString first_var = fConfig->SplitString(var,":")[0];
-        var = first_var;
-    }
-
-    //  This is for variables with multiple dimensions.
-    if(var.Contains("[")) {
-        TString first_var = fConfig->SplitString(var,"[")[0];
-        var = first_var;
-    }
-
-    for(UInt_t iTree=0; iTree<fLocalRootFileObj->TreeVars.size(); iTree++) {
-        for(UInt_t ivar=0; ivar<fLocalRootFileObj->TreeVars[iTree].size(); ivar++) {
-            if(var == fLocalRootFileObj->TreeVars[iTree][ivar]) return iTree;
-        }
-    }
-
-    return fLocalRootFileObj->RootTree.size()+1;
-}
-
-UInt_t OnlineGUI::GetTreeIndexFromName(TString name, RootFileObject* fLocalRootFileObj) {
-    // Called by TreeDraw().  Tries to find the Tree index provided the
-    //  name.  If it doesn't match up, return a number that's one larger
-    //  than the number of found trees.
-    for(UInt_t iTree=0; iTree<fLocalRootFileObj->RootTree.size(); iTree++) {
-        TString treename = fLocalRootFileObj->RootTree[iTree]->GetName();
-        if(name == treename) {
-            return iTree;
-        }
-    }
-
-    return fLocalRootFileObj->RootTree.size()+1;
-}
-
-void OnlineGUI::MacroDraw(drawcommand command) {
-    // Called by DoDraw(), this will make a call to the defined macro, and
-    //  plot it in it's own pad.  One plot per macro, please.
-
-    if(command.macro.IsNull()) {
-        cout << "macro command doesn't contain a macro to execute" << endl;
-        return;
-    }
-
-    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];
-    Double_t ver_num = rootversion_cut.Atof();
-    if(ver_num<5.16) {
-        TString badstring = "TCanvas Drawing Unsupported in ROOT v"+rootversion;
-        BadDraw(badstring);
-        return;
-    }
-
-    TDirectory *fDir;
-    if(command.directory.IsNull()) {
-        fDir = 0;
-    } 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;
-    if(command.directory.IsNull()) {
-        fDir = 0;
-    } 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);
-
-}
-
-
-void OnlineGUI::DoDrawClear(RootFileObject* fLocalRootFileObj) {
-    // Utility to grab the number of entries in each tree.  This info is
-    // then used, if watching a file, to "clear" the TreeDraw
-    // histograms, and begin looking at new data.
-    for(UInt_t i=0; i<fLocalRootFileObj->TreeEntries.size(); i++) {
-        fLocalRootFileObj->TreeEntries[i] = (Int_t) fLocalRootFileObj->RootTree[i]->GetEntries();
-    }
-
-
-}
-
-void OnlineGUI::TimerUpdate() {
-    // Called periodically by the timer, if "watchfile" is indicated
-    // in the config.  Reloads the ROOT file, and updates the current page.
-#ifdef DEBUG
-    cout << "Update Now" << endl;
-#endif
-
-    if(fRootFile.RootFile->IsZombie() || (fRootFile.RootFile->GetSize() == -1)
-            || (fRootFile.RootFile->ReadKeys()==0)) {
-        cout << "New run not yet available.  Waiting..." << endl;
-        fRootFile.RootFile->Close();
-        delete fRootFile.RootFile;
-        fRootFile.RootFile = 0;
-        timer->Reset();
-        timer->Disconnect();
-        timer->Connect(timer,"Timeout()","OnlineGUI",this,"CheckRootFile()");
-        return;
-    }
-    for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
-        fRootFile.RootTree[i]->Refresh();
-    }
-    DoDraw();
-    timer->Reset();
-
-}
-
-void OnlineGUI::BadDraw(TString errMessage) {
-    // Routine to display (in Pad) why a particular draw method has
-    // failed.
-    TPaveText *pt = new TPaveText(0.1,0.1,0.9,0.9,"brNDC");
-    pt->SetBorderSize(3);
-    pt->SetFillColor(10);
-    pt->SetTextAlign(22);
-    pt->SetTextFont(72);
-    pt->SetTextColor(2);
-    pt->AddText(errMessage.Data());
-    pt->Draw();
-    //   cout << errMessage << endl;
-
-}
-
-
-void OnlineGUI::CheckRootFile() {
-    // Check the path to the rootfile (should follow symbolic links)
-    // ... If found:
-    //   Reopen new root file,
-    //   Reconnect the timer to TimerUpdate()
-
-    if(gSystem->AccessPathName(fConfig->GetRootFile())==0) {
-        cout << "Found the new run" << endl;
-        if(OpenRootFile()==0) {
-            timer->Reset();
-            timer->Disconnect();
-            timer->Connect(timer,"Timeout()","OnlineGUI",this,"TimerUpdate()");
-        }
-    } else {
-        TString rnBuff = "Waiting for run";
-        fRunNumber->SetText(rnBuff.Data());
-        hframe->Layout();
-    }
-
-}
-
-Int_t OnlineGUI::OpenRootFile() {
-
-
-    fRootFile.RootFile = new TFile(fConfig->GetRootFile(),"READ");
-    if(fRootFile.RootFile->IsZombie() || (fRootFile.RootFile->GetSize() == -1)
-            || (fRootFile.RootFile->ReadKeys()==0)) {
-        cout << "New run not yet available.  Waiting..." << endl;
-        fRootFile.RootFile->Close();
-        delete fRootFile.RootFile;
-        fRootFile.RootFile = 0;
-        timer->Reset();
-        timer->Disconnect();
-        timer->Connect(timer,"Timeout()","OnlineGUI",this,"CheckRootFile()");
-        return -1;
-    }
-
-    // Update the runnumber
-    ObtainRunNumber();
-    if(runNumber != 0) {
-        TString rnBuff = "Run #";
-        rnBuff += runNumber;
-        fRunNumber->SetText(rnBuff.Data());
-        hframe->Layout();
-    }
-
-    // Open the Root Trees.  Give a warning if it's not there..
-    GetFileObjects(&fRootFile);
-    if (fRootFile.fUpdate) { // Only do this stuff if there are valid keys
-        GetRootTree(&fRootFile);
-        GetTreeVars(&fRootFile);
-        for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
-            if(fRootFile.RootTree[i]==0) {
-                fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i);
-            }
-        }
-        DoDraw();
-    } else {
-        return -1;
-    }
-    return 0;
-
-}
-
-void OnlineGUI::HistDraw(drawcommand command) {
-    // Called by DoDraw(), this will plot a histogram.
-
-    Bool_t showGolden=kFALSE;
-    if(doGolden) showGolden=kTRUE;
-    Bool_t showStat=kTRUE;
-    TString htitle;
-
-    if(command.noshowgolden=="noshowgolden")
-        showGolden = kFALSE;
-    if(command.nostat=="nostat")
-        showStat=kFALSE;
-    htitle = command.title;
-
-    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
-        fRootFile.RootFile->cd();
-        if(fDir) fDir->cd();
-        fRootFile.mytemp1d = (TH1D*)gDirectory->Get(command.objname);
-        if(!fRootFile.mytemp1d) BadDraw(command.variable+" not found");
-        if(fRootFile.mytemp1d->GetEntries()==0) {
-            BadDraw("Empty Histogram");
-        } else {
-            if(showGolden) {
-                fGoldenFile.RootFile->cd();
-                if(fDir) fDir->cd();
-                fGoldenFile.mytemp1d = (TH1D*)gDirectory->Get(command.objname);
-                fGoldenFile.mytemp1d->SetLineColor(30);
-                fGoldenFile.mytemp1d->SetFillColor(30);
-                Int_t fillstyle=3027;
-                if(fPrintOnly) fillstyle=3010;
-                fGoldenFile.mytemp1d->SetFillStyle(fillstyle);
-                fRootFile.mytemp1d->SetStats(showStat);
-                fGoldenFile.mytemp1d->SetStats(kFALSE);
-                fGoldenFile.mytemp1d->Draw();
-                if(!htitle.IsNull()) fGoldenFile.mytemp1d->SetTitle(htitle);
-                fRootFile.mytemp1d->Draw("sames"+type);
-            } else {
-                fRootFile.mytemp1d->SetStats(showStat);
-                if(!htitle.IsNull()) fRootFile.mytemp1d->SetTitle(htitle);
-                fRootFile.mytemp1d->Draw(type);
-
-                // Force TH1s' y-axis to start at 0 if not a logy plot
-                if(gStyle->GetOptLogy() == 0)
-                    fRootFile.mytemp1d->SetMinimum(0);
-            }
-        }
-        return;
-    }
-
-    if(command.objtype.Contains("TH2")) {
-        // Operation for TH2
-        if(!showGolden) fRootFile.RootFile->cd();
-        if(fDir) fDir->cd();
-        fRootFile.mytemp2d = (TH2D*)gDirectory->Get(command.objname);
-        if(fRootFile.mytemp2d->GetEntries()==0) {
-            BadDraw("Empty Histogram");
-        } else {
-            if(showGolden) {
-                fGoldenFile.RootFile->cd();
-                if(fDir) fDir->cd();
-                fGoldenFile.mytemp2d = (TH2D*)gDirectory->Get(command.objname);
-                fGoldenFile.mytemp2d->SetMarkerColor(2);
-                fRootFile.mytemp2d->SetStats(showStat);
-                fGoldenFile.mytemp2d->SetStats(kFALSE);
-                fGoldenFile.mytemp2d->Draw(type);
-                if(!htitle.IsNull()) fGoldenFile.mytemp2d->SetTitle(htitle);
-                fRootFile.mytemp2d->Draw("sames"+type);
-            } else {
-                fRootFile.mytemp2d->SetStats(showStat);
-                if(!htitle.IsNull()) fGoldenFile.mytemp2d->SetTitle(htitle);
-                fRootFile.mytemp2d->Draw(type);
-                fRootFile.mytemp2d->Draw("colz");
-            }
-        }
-        return;
-    }
-
-    if(command.objtype.Contains("TH3")) {
-        // Operation for TH3
-        if(!showGolden) fRootFile.RootFile->cd();
-        if(fDir) fDir->cd();
-        fRootFile.mytemp3d = (TH3D*)gDirectory->Get(command.objname);
-        if(fRootFile.mytemp3d->GetEntries()==0) {
-            BadDraw("Empty Histogram");
-        } else {
-            fRootFile.mytemp3d->Draw();
-            if(showGolden) {
-                fGoldenFile.RootFile->cd();
-                if(fDir) fDir->cd();
-                fGoldenFile.mytemp3d = (TH3D*)gDirectory->Get(command.objname);
-                fGoldenFile.mytemp3d->SetMarkerColor(2);
-                fRootFile.mytemp3d->SetStats(showStat);
-                fGoldenFile.mytemp3d->SetStats(kFALSE);
-                fGoldenFile.mytemp3d->Draw(type);
-                if(!htitle.IsNull()) fGoldenFile.mytemp3d->SetTitle(htitle);
-                fRootFile.mytemp3d->Draw("sames"+type);
-            } else {
-                fRootFile.mytemp3d->SetStats(showStat);
-                if(!htitle.IsNull()) fGoldenFile.mytemp3d->SetTitle(htitle);
-                fRootFile.mytemp3d->Draw(type);
-            }
-        }
-        return;
-    }
-
-}
-
-drawcommand OnlineGUI::fileObject2command(drawcommand command, RootFileObject* fLocalRootFileObj) {
-    // Fill in gaps in the drawcommand with items from the
-    // vfileObject.  This elimates the need for duplicate code in
-    // the different *Draw routines.
-    for(UInt_t i=0; i<fLocalRootFileObj->vfileObjects.size(); i++) {
-        if(fLocalRootFileObj->vfileObjects[i].name==command.variable ||
-                fLocalRootFileObj->vfileObjects[i].title==command.variable ) {
-            command.objname = fLocalRootFileObj->vfileObjects[i].name;
-            command.objtitle = fLocalRootFileObj->vfileObjects[i].title;
-            command.objtype = fLocalRootFileObj->vfileObjects[i].type;
-            command.directory = fLocalRootFileObj->vfileObjects[i].directory;
-#ifdef DEBUGf2command
-            cout << command.directory << " "
-                << command.objtype  << " "
-                << command.objname
-                << endl;
-#endif
-            return command;
-        }
-    }
-    return command;
-
-
-}
-
-void OnlineGUI::TreeDraw(drawcommand command) {
-    // Called by DoDraw(), this will plot a Tree Variable
-
-    TString var = command.variable;
-    Bool_t showGolden=kFALSE;
-    if(doGolden) showGolden=kTRUE;
-
-    Bool_t showStat=kTRUE;
-    if(command.nostat=="nostat") showStat=kFALSE;
-
-    //TObject *hobj;
-
-    // Combine the cuts (definecuts and specific cuts)
-    TCut cut = "";
-    TString tempCut;
-    if(!command.cut.IsNull()) {
-        tempCut = command.cut;
-        vector <TString> cutIdents = fConfig->GetCutIdent();
-        for(UInt_t i=0; i<cutIdents.size(); i++) {
-            if(tempCut.Contains(cutIdents[i])) {
-                TString cut_found = (TString)fConfig->GetDefinedCut(cutIdents[i]);
-                tempCut.ReplaceAll(cutIdents[i],cut_found);
-            }
-        }
-        cut = (TCut)tempCut;
-    }
-
-    // Determine which Tree the variable comes from, then draw it.
-    UInt_t iTree;
-    if(command.treename.IsNull()) {
-        iTree = GetTreeIndex(var,&fRootFile);
-    } else {
-        iTree = GetTreeIndexFromName(command.treename,&fRootFile);
-    }
-    TString drawopt = command.type;
-    Int_t errcode=0;
-    if(drawopt.IsNull() && var.Contains(":")) drawopt = "cont";
-    if(drawopt=="scat") drawopt = "";
-
-    fRootFile.RootFile->cd();
-    if (iTree <= fRootFile.RootTree.size() ) {
-        TObjArray* tok = var.Tokenize(">()");
-        TString myvar   = ((TObjString*)tok->First())->GetString();
-        TString hname   = "h";
-        TString histdef = ((TObjString*)tok->Last())->GetString();
-        if(tok->GetEntries() == 1) histdef = "";        // ie "var[0]"
-        if(tok->GetEntries() == 2) {
-            if(! histdef.Contains(",") ) {             // ie "var[0]>>h1"
-                hname = histdef;
-                histdef = "";
-            }
-        }
-        if(tok->GetEntries() == 3) hname = ((TObjString*)tok->At(1))->GetString();  // ie "var[0]>>h1(100,0,100)"
-        delete tok;
-        TString tmp = var + tempCut;
-        hname = Form("%s_%u",hname.Data(),tmp.Hash());      // unique id so caching histos works
-
-        errcode=1;
-        TObject *hobj  = gDirectory->Get(hname);
-        if(hobj == NULL) {
-            errcode = fRootFile.RootTree[iTree]->Draw(myvar+">>"+hname+"("+histdef+")",cut,drawopt,
-                    1000000000,fRootFile.TreeEntries[iTree]);
-            hobj = gDirectory->Get(hname);
-        }
-        TH1F *mainhist = (TH1F*)hobj;
-        mainhist->Draw(drawopt);
-        //tmp = myvar+">>"+hname+"("+histdef+")";
-        //printf("hist: '%s',  opt: '%s',  \"%s\"\n", hname.Data(), drawopt.Data(),tmp.Data());
-
-        if(errcode==-1) {
-            BadDraw(var+" not found");
-        } else if (errcode!=0) {
-            TString htype = hobj->ClassName();
-            if(! htype.Contains("TH1F") ) {
-                //printf("skipping.\n");
-                showGolden=kFALSE;
-            }
-            if(showGolden) {
-                errcode=1;
-                TString goldname = "gold"+hname;
-                TH1F *goldhist = (TH1F*)gDirectory->Get(goldname);
-                if(goldhist == NULL) {
-                    goldhist = (TH1F*)mainhist->Clone(hname);
-                    goldhist->SetName(goldname);
-                    errcode = fGoldenFile.RootTree[iTree]->Project(goldname,myvar,cut);
-                }
-                if(errcode>0) {
-                    goldhist->SetFillColor(30);
-                    Int_t fillstyle=3027;
-                    if(fPrintOnly) fillstyle=3010;
-                    goldhist->SetFillStyle(fillstyle);
-                    goldhist->Draw(drawopt);
-                    mainhist->SetFillColor(0);
-                    mainhist->SetFillStyle(1001);
-                    mainhist->Draw("same");
-                    if(!command.title.IsNull()) goldhist->SetTitle(command.title);
-                    if(!showStat)               goldhist->SetStats(kFALSE);
-                }
-            } else {
-                if(!command.title.IsNull()) mainhist->SetTitle(command.title);
-                if(!showStat)               mainhist->SetStats(kFALSE);
-            }
-        } else {
-            BadDraw("Empty Histogram");
-        }
-    } else {
-        BadDraw(var+" not found");
-        if (fConfig->IsMonitor()){
-            // Maybe we missed it... look again.  I dont like the code
-            // below... maybe I can come up with something better
-            GetFileObjects(&fRootFile);
-            GetRootTree(&fRootFile);
-            GetTreeVars(&fRootFile);
-        }
-    }
-
-}
-
-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;
-#endif
-}
-
-void OnlineGUI::PrintToFile()
-{
-    // Routine to print the current page to a File.
-    //  A file dialog pop's up to request the file name.
-    fCanvas = fEcanvas->GetCanvas();
-    gStyle->SetPaperSize(20,24);
-    static TString dir(".");
-    TGFileInfo fi;
-    const char *myfiletypes[] =
-    { "All files","*",
-        "PDF files","*.pdf",
-        "PNG files","*.png",
-        "GIF files","*.gif",
-        "JPG files","*.jpg",
-        0,               0 };
-    fi.fFileTypes = myfiletypes;
-    fi.fIniDir    = StrDup(dir.Data());
-    cout << " INitiail = " << fi.fIniDir << endl;
-    new TGFileDialog(gClient->GetRoot(), fMain, kFDSave, &fi);
-    if(fi.fFilename!=NULL) {
-        fCanvas->Print(fi.fFilename);
-    }
-}
-
-void OnlineGUI::PrintPages() {
-    // 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");
-    if(!fRootFile.RootFile->IsOpen()) {
-        cout << "ERROR:  rootfile: " << fConfig->GetRootFile()
-            << " does not exist"
-            << endl;
-#ifdef STANDALONE
-        gApplication->Terminate();
-#else
-        return;
-#endif
-    } else {
-        fFileAlive = kTRUE;
-        ObtainRunNumber();
-        // Open the Root Trees.  Give a warning if it's not there..
-        GetFileObjects(&fRootFile);
-        GetRootTree(&fRootFile);
-        GetTreeVars(&fRootFile);
-        for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
-            if(fRootFile.RootTree[i]==0) {
-                fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i);
-            }
-        }
-
-    }
-    TString goldenfilename=fConfig->GetGoldenFile();
-    if(!goldenfilename.IsNull()) {
-        fGoldenFile.RootFile = new TFile(goldenfilename,"READ");
-        if(!fGoldenFile.RootFile->IsOpen()) {
-            cout << "ERROR: goldenrootfile: " << goldenfilename
-                << " does not exist.  Oh well, no comparison plots."
-                << endl;
-            doGolden = kFALSE;
-            fGoldenFile.RootFile=NULL;
-        } else {
-            // Open the Root Trees.  Give a warning if it's not there..
-            GetFileObjects(&fGoldenFile);
-            GetRootTree(&fGoldenFile);
-            GetTreeVars(&fGoldenFile);
-            for(UInt_t i=0; i<fGoldenFile.RootTree.size(); i++) {
-                if(fGoldenFile.RootTree[i]==0) {
-                    fGoldenFile.RootTree.erase(fGoldenFile.RootTree.begin() + i);
-                }
-            }
-            doGolden = kTRUE;
-        }
-    } else {
-        doGolden=kFALSE;
-        fGoldenFile.RootFile=NULL;
-    }
-
-    // I'm not sure exactly how this works.  But it does.
-    fCanvas = new TCanvas("fCanvas","trythis",850,1100);
-    //   TCanvas *maincanvas = new TCanvas("maincanvas","whatever",850,1100);
-    //   maincanvas->SetCanvas(fCanvas);
-    TLatex *lt = new TLatex();
-
-    TString plotsdir = fConfig->GetPlotsDir();
-    Bool_t useJPG = kFALSE;
-    if(!plotsdir.IsNull()) useJPG = kTRUE;
-
-    //  TString filename = "summaryplots";
-    TString ConfigStartAll=fConfig->GetConfigStart();
-    TObjArray *tx= ConfigStartAll.Tokenize("/");
-    TString temp=((TObjString *)(tx->At(tx->GetEntries()-1)))->String();
-    Ssiz_t pos=temp.Index(".cfg");
-    TString filename=temp(0,pos);
-    if(runNumber!=0) {
-        filename += "_";
-        filename += runNumber;
-    }
-    if(useJPG) {
-        filename.Prepend(plotsdir+"/");
-        filename += "_pageXXXX.jpg";
-    }
-    else filename += ".pdf";
-
-    TString pagehead = "Summary Plots";
-    if(runNumber!=0) {
-        pagehead += "(Run #";
-        pagehead += runNumber;
-        pagehead += ")";
-    }
-    pagehead += ": ";
-
-    gStyle->SetPalette(1);
-    gStyle->SetTitleX(0.5);
-    gStyle->SetTitleY(0.95);
-    gStyle->SetPadBorderMode(0);
-    gStyle->SetHistLineColor(1);
-    gStyle->SetHistFillColor(1);
-    cout << filename << endl;
-    if(!useJPG) fCanvas->Print(filename+"[");
-    TString origFilename = filename;
-    for(UInt_t i=0; i<fConfig->GetPageCount(); i++) {
-        current_page=i;
-        DoDraw();
-        TString pagename = pagehead + fConfig->GetPageTitle(current_page);
-        lt->SetTextSize(0.025);
-        lt->DrawLatex(0.05,0.98,pagename);
-        if(useJPG) {
-            filename = origFilename;
-            filename.ReplaceAll("XXXX",Form("%d",current_page));
-            cout << "Printing page " << current_page
-                << " to file = " << filename << endl;
-        }
-        fCanvas->Print(filename);
-    }
-    if(!useJPG) fCanvas->Print(filename+"]");
-    //
-
-    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();
-#endif
-}
-
-void OnlineGUI::MyCloseWindow()
-{
-    fMain->SendCloseMessage();
-    cout << "OnlineGUI Closed." << endl;
-    if(timer!=NULL) {
-        timer->Stop();
-        delete timer;
-    }
-    delete fPrint;
-    delete fExit;
-    delete fRunNumber;
-    delete fPrev;
-    delete fNext;
-    delete wile;
-    for(UInt_t i=0; i<fConfig->GetPageCount(); i++)
-        delete fRadioPage[i];
-    delete hframe;
-    delete fEcanvas;
-    delete fBottomFrame;
-    delete vframe;
-    delete fTopframe;
-    delete fMain;
-    if(fGoldenFile.RootFile!=NULL) delete fGoldenFile.RootFile;
-    if(fRootFile.RootFile!=NULL) delete fRootFile.RootFile;
-    delete fConfig;
-
-#ifdef STANDALONE
-    gApplication->Terminate();
-#endif
-}
-
-void OnlineGUI::CloseGUI()
-{
-    // Routine to take care of the Exit GUI button
-    fMain->SendCloseMessage();
-}
-
-OnlineGUI::~OnlineGUI()
-{
-    //  fMain->SendCloseMessage();
-    if(timer!=NULL) {
-        timer->Stop();
-        delete timer;
-    }
-    delete fPrint;
-    delete fExit;
-    delete fRunNumber;
-    delete fPrev;
-    delete fNext;
-    delete wile;
-    for(UInt_t i=0; i<fConfig->GetPageCount(); i++)
-        delete fRadioPage[i];
-    delete hframe;
-    delete fEcanvas;
-    delete vframe;
-    delete fBottomFrame;
-    delete fTopframe;
-    delete fMain;
-    if(fGoldenFile.RootFile!=NULL) delete fGoldenFile.RootFile;
-    if(fRootFile.RootFile!=NULL) delete fRootFile.RootFile;
-    delete fConfig;
-}
-
-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.
-
-    if(printonly || rootonly) {
-        if(!gROOT->IsBatch()) {
-#ifdef STANDALONE
-            gROOT->SetBatch();
-#else
-            cout << "Sorry... the print summary plots option only works "
-                << "in BATCH mode." << endl;
-            return;
-#endif
-        }
-    }
-
-    OnlineConfig *fconfig = new OnlineConfig(type);
-    //    OnlineConfig *fconfig = new OnlineConfig("halla");
-
-    if(!fconfig->ParseConfig()) {
-#ifdef STANDALONE
-        gApplication->Terminate();
-#else
-        return;
-#endif
-    }
-
-    if(run!=0) fconfig->OverrideRootFile(run);
-
-    new OnlineGUI(*fconfig,printonly,rootonly,run);
-
-}
-
-#ifdef STANDALONE
-void Usage()
-{
-    cerr << "Usage: online [-r] [-f] [-P]"
-        << endl;
-    cerr << "Options:" << endl;
-    cerr << "  -r : runnumber" << endl;
-    cerr << "  -f : configuration file" << endl;
-    cerr << "  -P : Only Print Summary Plots" << endl;
-    cerr << "  -R : Only Rootfile " << endl;
-    cerr << endl;
-
-}
-
-int main(int argc, char **argv)
-{
-    TString type="default";
-    UInt_t run=0;
-    Bool_t printonly=kFALSE;
-    Bool_t rootonly=kFALSE;
-    Bool_t showedUsage=kFALSE;
-
-    TApplication theApp("App",&argc,argv,NULL,-1);
-
-    for(Int_t i=1;i<theApp.Argc();i++)
-    {
-        TString sArg = theApp.Argv(i);
-        if(sArg=="-f") {
-            type = theApp.Argv(++i);
-            cout << " File specifier: "
-                <<  type << endl;
-        } else if (sArg=="-r") {
-            run = atoi(theApp.Argv(++i));
-            cout << " Runnumber: "
-                << run << endl;
-        } else if (sArg=="-P") {
-            printonly = kTRUE;
-            cout <<  " PrintOnly" << endl;
-        } else if (sArg=="-R") {
-            rootonly = kTRUE;
-            cout <<  " RootOnly" << endl;
-        } else if (sArg=="-h") {
-            if(!showedUsage) Usage();
-            showedUsage=kTRUE;
-            return 0;
-        } else {
-            cerr << "\"" << sArg << "\"" << " not recognized.  Ignored." << endl;
-            if(!showedUsage) Usage();
-            showedUsage=kTRUE;
-        }
-    }
-
-    online(type,run,printonly,rootonly);
-    theApp.Run();
-
-    return 0;
-}
-
-#endif
+  // The main Drawing Routine.
+ 
+#ifdef INTERNALSTYLE
+    gStyle->SetOptStat(1110);
+    gStyle->SetStatFontSize(0.1);
+#endif
+    if (fConfig->IsLogx(current_page)) {
+        gStyle->SetOptLogx(1);
+    } else {
+        gStyle->SetOptLogx(0);
+    }
+    if (fConfig->IsLogy(current_page)) {
+        gStyle->SetOptLogy(1);
+    } else {
+        gStyle->SetOptLogy(0);
+    }
+    if (fConfig->IsLogz(current_page)) {
+        gStyle->SetOptLogz(1);
+    } else {
+        gStyle->SetOptLogz(0);
+    }
+#ifdef INTERNALSTYLE
+  gStyle->SetTitleH(0.10);
+  gStyle->SetTitleW(0.40);
+  //gStyle->SetLabelSize(0.10,"X");
+  //gStyle->SetLabelSize(0.10,"Y");
+  gStyle->SetLabelSize(0.05,"X");
+  gStyle->SetLabelSize(0.05,"Y");
+  gStyle->SetTitleSize(0.045,"X");
+  gStyle->SetTitleSize(0.045,"Y");
+  gStyle->SetPadLeftMargin(0.14);
+  gStyle->SetNdivisions(505,"X");
+  gStyle->SetNdivisions(404,"Y");
+  gStyle->SetPalette(1);
+  gROOT->ForceStyle();
+#endif
+
+    // Determine the dimensions of the canvas..
+    UInt_t draw_count = fConfig->GetDrawCount(current_page);
+#ifdef INTERNALSTYLE
+    if(draw_count>=8) {
+        gStyle->SetLabelSize(0.08,"X");
+        gStyle->SetLabelSize(0.08,"Y");
+    }
+#endif
+    //   Int_t dim = Int_t(round(sqrt(double(draw_count))));
+    pair <UInt_t,UInt_t> dim = fConfig->GetPageDim(current_page);
+
+#ifdef DEBUG
+    cout << "Dimensions: " << dim.first << "X"
+        << dim.second << endl;
+#endif
+
+    // Create a nice clean canvas.
+    fCanvas->Clear();
+    fCanvas->Divide(dim.first,dim.second);
+
+    drawcommand thiscommand;
+    // Draw the histograms.
+    for(UInt_t i=0; i<draw_count; i++) {
+        thiscommand = fConfig->GetDrawCommand(current_page,i);
+        thiscommand = fileObject2command(thiscommand,&fRootFile);
+        fCanvas->cd(i+1);
+        if (thiscommand.variable == "macro") {
+            MacroDraw(thiscommand);
+        } else if (thiscommand.objtype.Contains("TH")) {
+            HistDraw(thiscommand);
+        } else if (thiscommand.objtype.Contains("TCanvas")) {
+            CanvasDraw(thiscommand,i+1);
+        } else if (thiscommand.objtype.Contains("TGraph")) {
+            GraphDraw(thiscommand);
+        } else { // otherwise... assume that the objtype is a branch from a tree
+            TreeDraw(thiscommand);
+        }
+    }
+
+    fCanvas->cd();
+    fCanvas->Update();
+
+    if(!fPrintOnly) {
+        CheckPageButtons();
+    }
+
+}
+
+void OnlineGUI::DrawNext()
+{
+    // Handler for the "Next" button.
+    fRadioPage[current_page]->SetState(kButtonUp);
+    // The following line triggers DoRadio()
+    fRadioPage[current_page+1]->SetState(kButtonDown,true);
+
+}
+
+void OnlineGUI::DrawPrev()
+{
+    // Handler for the "Prev" button.
+    fRadioPage[current_page]->SetState(kButtonUp);
+    // The following line triggers DoRadio()
+    fRadioPage[current_page-1]->SetState(kButtonDown,true);
+
+}
+
+void OnlineGUI::DoRadio()
+{
+    // Handle the radio buttons
+    //  Find out which button has been pressed..
+    //   turn off the previous button...
+    //   then draw the appropriate page.
+    // This routine also handles the Draw from the Prev/Next buttons
+    //   - makes a call to DoDraw()
+
+    UInt_t pagecount = fConfig->GetPageCount();
+    TGButton *btn = (TGButton *) gTQSender;
+    UInt_t id = btn->WidgetId();
+
+    if (id <= pagecount) {
+        fRadioPage[current_page]->SetState(kButtonUp);
+    }
+
+    current_page = id;
+    if(!fConfig->IsMonitor()) DoDraw();
+
+}
+
+void OnlineGUI::CheckPageButtons()
+{
+    // Checks the current page to see if it's the first or last page.
+    //  If so... turn off the appropriate button.
+    //  If not.. turn on both buttons.
+
+    if(current_page==0) {
+        fPrev->SetState(kButtonDisabled);
+        if(fConfig->GetPageCount()!=1)
+            fNext->SetState(kButtonUp);
+    } else if(current_page==fConfig->GetPageCount()-1) {
+        fNext->SetState(kButtonDisabled);
+        if(fConfig->GetPageCount()!=1)
+            fPrev->SetState(kButtonUp);
+    } else {
+        fPrev->SetState(kButtonUp);
+        fNext->SetState(kButtonUp);
+    }
+}
+
+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
+    //    (in case the the name is not very descriptive... like when
+    //    using h2root)
+    //  If there's no good keys.. do nothing.
+#ifdef DEBUGGETFILEOBJECTS
+    cout << "Keys = " << fLocalRootFileObj->RootFile->ReadKeys() << endl;
+#endif
+    if(fLocalRootFileObj->RootFile->ReadKeys()==0) {
+        fLocalRootFileObj->fUpdate = kFALSE;
+        //     delete fLocalRootFileObj->RootFile;
+        //     fLocalRootFileObj->RootFile = 0;
+        //     CheckRootFile();
+        return;
+    }
+    fLocalRootFileObj->vfileObjects.clear();
+
+    TIter next( (fLocalRootFileObj->RootFile)->GetListOfKeys() );
+    TKey *key = new TKey();
+
+    // Do the search
+    while((key=(TKey*)next())!=0) {
+#ifdef DEBUGGETFILEOBJECTS
+        cout << "Key = " << key << endl;
+#endif
+        TString objname = key->GetName();
+        TString objtype = key->GetClassName();
+        TString objtitle = key->GetTitle();
+#ifdef DEBUGGETFILEOBJECTS
+        cout << objname << " " << objtype << endl;
+#endif
+
+        if(objtype.Contains("TDirectory")) {
+            TDirectory *thisdir = (TDirectory*)fLocalRootFileObj->RootFile->Get(objname);
+            TIter nextInDir(thisdir->GetListOfKeys());
+            TKey *innerkey = new TKey();
+            while((innerkey=(TKey*)nextInDir())!=0) {
+                TString iobjname = innerkey->GetName();
+                TString iobjtype = innerkey->GetClassName();
+                TString iobjtitle = innerkey->GetTitle();
+                TString iobjdir = objname;
+#ifdef DEBUGGETFILEOBJECTS
+                cout << iobjname << " " << iobjtype << endl;
+#endif
+                fileObject thisObject;
+                thisObject.name = iobjname;
+                thisObject.type = iobjtype;
+                thisObject.title = iobjtitle;
+                thisObject.directory = objname;
+                fLocalRootFileObj->vfileObjects.push_back(thisObject);
+            }
+        } else {
+            fileObject thisObject;
+            thisObject.name = objname;
+            thisObject.type = objtype;
+            thisObject.title = objtitle;
+            thisObject.directory = "";
+            fLocalRootFileObj->vfileObjects.push_back(thisObject);
+        }
+
+    }
+    fLocalRootFileObj->fUpdate = kTRUE;
+    delete key;
+}
+
+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.
+    fLocalRootFileObj->TreeVars.clear();
+    TObjArray *branchList;
+    vector <TString> currentTree;
+
+    for(UInt_t i=0; i<fLocalRootFileObj->RootTree.size(); i++) {
+        currentTree.clear();
+        branchList = fLocalRootFileObj->RootTree[i]->GetListOfBranches();
+        TIter next(branchList);
+        TBranch *brc;
+
+        while((brc=(TBranch*)next())!=0) {
+            TString found = brc->GetName();
+            // Not sure if the line below is so smart...
+            currentTree.push_back(found);
+        }
+        fLocalRootFileObj->TreeVars.push_back(currentTree);
+    }
+#ifdef DEBUG2
+    for(UInt_t iTree=0; iTree<fLocalRootFileObj->TreeVars.size(); iTree++) {
+        cout << "In Tree " << iTree << ": " << endl;
+        for(UInt_t i=0; i<fLocalRootFileObj->TreeVars[iTree].size(); i++) {
+            cout << fLocalRootFileObj->TreeVars[iTree][i] << endl;
+        }
+    }
+#endif
+}
+
+
+void OnlineGUI::GetRootTree(RootFileObject* fLocalRootFileObj ) {
+    // Utility to search a ROOT File for ROOT Trees
+    // Fills the RootTree vector
+    fLocalRootFileObj->RootTree.clear();
+
+    list <TString> found;
+    for(UInt_t i=0; i<fLocalRootFileObj->vfileObjects.size(); i++) {
+#ifdef DEBUGGETROOTTREE
+        cout << "Object = " << fLocalRootFileObj->vfileObjects[i].type <<
+            "     Name = " << fLocalRootFileObj->vfileObjects[i].name << endl;
+#endif
+        if(fLocalRootFileObj->vfileObjects[i].type.Contains("TTree"))
+            found.push_back(fLocalRootFileObj->vfileObjects[i].name);
+    }
+
+    // Remove duplicates, then insert into fLocalRootFileObj->RootTree
+    found.unique();
+    UInt_t nTrees = found.size();
+
+    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).
+    // Returns the correct index.  if not found returns an index 1
+    // larger than fRootFile.RootTree.size()
+
+    //  This is for 2d draws... look for the first only
+    if(var.Contains(":")) {
+        TString first_var = fConfig->SplitString(var,":")[0];
+        var = first_var;
+    }
+
+    //  This is for variables with multiple dimensions.
+    if(var.Contains("[")) {
+        TString first_var = fConfig->SplitString(var,"[")[0];
+        var = first_var;
+    }
+
+    for(UInt_t iTree=0; iTree<fLocalRootFileObj->TreeVars.size(); iTree++) {
+        for(UInt_t ivar=0; ivar<fLocalRootFileObj->TreeVars[iTree].size(); ivar++) {
+            if(var == fLocalRootFileObj->TreeVars[iTree][ivar]) return iTree;
+        }
+    }
+
+    return fLocalRootFileObj->RootTree.size()+1;
+}
+
+UInt_t OnlineGUI::GetTreeIndexFromName(TString name, RootFileObject* fLocalRootFileObj) {
+    // Called by TreeDraw().  Tries to find the Tree index provided the
+    //  name.  If it doesn't match up, return a number that's one larger
+    //  than the number of found trees.
+    for(UInt_t iTree=0; iTree<fLocalRootFileObj->RootTree.size(); iTree++) {
+        TString treename = fLocalRootFileObj->RootTree[iTree]->GetName();
+        if(name == treename) {
+            return iTree;
+        }
+    }
+
+    return fLocalRootFileObj->RootTree.size()+1;
+}
+
+void OnlineGUI::MacroDraw(drawcommand command) {
+    // Called by DoDraw(), this will make a call to the defined macro, and
+    //  plot it in it's own pad.  One plot per macro, please.
+
+    if(command.macro.IsNull()) {
+        cout << "macro command doesn't contain a macro to execute" << endl;
+        return;
+    }
+
+    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];
+    Double_t ver_num = rootversion_cut.Atof();
+    if(ver_num<5.16) {
+        TString badstring = "TCanvas Drawing Unsupported in ROOT v"+rootversion;
+        BadDraw(badstring);
+        return;
+    }
+
+    TDirectory *fDir;
+    if(command.directory.IsNull()) {
+        fDir = 0;
+    } 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;
+    if(command.directory.IsNull()) {
+        fDir = 0;
+    } 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);
+
+}
+
+
+void OnlineGUI::DoDrawClear(RootFileObject* fLocalRootFileObj) {
+    // Utility to grab the number of entries in each tree.  This info is
+    // then used, if watching a file, to "clear" the TreeDraw
+    // histograms, and begin looking at new data.
+    for(UInt_t i=0; i<fLocalRootFileObj->TreeEntries.size(); i++) {
+        fLocalRootFileObj->TreeEntries[i] = (Int_t) fLocalRootFileObj->RootTree[i]->GetEntries();
+    }
+
+
+}
+
+void OnlineGUI::TimerUpdate() {
+    // Called periodically by the timer, if "watchfile" is indicated
+    // in the config.  Reloads the ROOT file, and updates the current page.
+#ifdef DEBUG
+    cout << "Update Now" << endl;
+#endif
+
+    if(fRootFile.RootFile->IsZombie() || (fRootFile.RootFile->GetSize() == -1)
+            || (fRootFile.RootFile->ReadKeys()==0)) {
+        cout << "New run not yet available.  Waiting..." << endl;
+        fRootFile.RootFile->Close();
+        delete fRootFile.RootFile;
+        fRootFile.RootFile = 0;
+        timer->Reset();
+        timer->Disconnect();
+        timer->Connect(timer,"Timeout()","OnlineGUI",this,"CheckRootFile()");
+        return;
+    }
+    for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
+        fRootFile.RootTree[i]->Refresh();
+    }
+    DoDraw();
+    timer->Reset();
+
+}
+
+void OnlineGUI::BadDraw(TString errMessage) {
+    // Routine to display (in Pad) why a particular draw method has
+    // failed.
+    TPaveText *pt = new TPaveText(0.1,0.1,0.9,0.9,"brNDC");
+    pt->SetBorderSize(3);
+    pt->SetFillColor(10);
+    pt->SetTextAlign(22);
+    pt->SetTextFont(72);
+    pt->SetTextColor(2);
+    pt->AddText(errMessage.Data());
+    pt->Draw();
+    //   cout << errMessage << endl;
+
+}
+
+
+void OnlineGUI::CheckRootFile() {
+    // Check the path to the rootfile (should follow symbolic links)
+    // ... If found:
+    //   Reopen new root file,
+    //   Reconnect the timer to TimerUpdate()
+
+    if(gSystem->AccessPathName(fConfig->GetRootFile())==0) {
+        cout << "Found the new run" << endl;
+        if(OpenRootFile()==0) {
+            timer->Reset();
+            timer->Disconnect();
+            timer->Connect(timer,"Timeout()","OnlineGUI",this,"TimerUpdate()");
+        }
+    } else {
+        TString rnBuff = "Waiting for run";
+        fRunNumber->SetText(rnBuff.Data());
+        hframe->Layout();
+    }
+
+}
+
+Int_t OnlineGUI::OpenRootFile() {
+
+
+    fRootFile.RootFile = new TFile(fConfig->GetRootFile(),"READ");
+    if(fRootFile.RootFile->IsZombie() || (fRootFile.RootFile->GetSize() == -1)
+            || (fRootFile.RootFile->ReadKeys()==0)) {
+        cout << "New run not yet available.  Waiting..." << endl;
+        fRootFile.RootFile->Close();
+        delete fRootFile.RootFile;
+        fRootFile.RootFile = 0;
+        timer->Reset();
+        timer->Disconnect();
+        timer->Connect(timer,"Timeout()","OnlineGUI",this,"CheckRootFile()");
+        return -1;
+    }
+
+    // Update the runnumber
+    ObtainRunNumber();
+    if(runNumber != 0) {
+        TString rnBuff = "Run #";
+        rnBuff += runNumber;
+        fRunNumber->SetText(rnBuff.Data());
+        hframe->Layout();
+    }
+
+    // Open the Root Trees.  Give a warning if it's not there..
+    GetFileObjects(&fRootFile);
+    if (fRootFile.fUpdate) { // Only do this stuff if there are valid keys
+        GetRootTree(&fRootFile);
+        GetTreeVars(&fRootFile);
+        for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
+            if(fRootFile.RootTree[i]==0) {
+                fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i);
+            }
+        }
+        DoDraw();
+    } else {
+        return -1;
+    }
+    return 0;
+
+}
+
+void OnlineGUI::HistDraw(drawcommand command) {
+    // Called by DoDraw(), this will plot a histogram.
+
+    Bool_t showGolden=kFALSE;
+    if(doGolden) showGolden=kTRUE;
+    Bool_t showStat=kTRUE;
+    TString htitle;
+
+    if(command.noshowgolden=="noshowgolden")
+        showGolden = kFALSE;
+    if(command.nostat=="nostat")
+        showStat=kFALSE;
+    htitle = command.title;
+
+    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
+        fRootFile.RootFile->cd();
+        if(fDir) fDir->cd();
+        fRootFile.mytemp1d = (TH1D*)gDirectory->Get(command.objname);
+        if(!fRootFile.mytemp1d) BadDraw(command.variable+" not found");
+        if(fRootFile.mytemp1d->GetEntries()==0) {
+            BadDraw("Empty Histogram");
+        } else {
+            if(showGolden) {
+                fGoldenFile.RootFile->cd();
+                if(fDir) fDir->cd();
+                fGoldenFile.mytemp1d = (TH1D*)gDirectory->Get(command.objname);
+                fGoldenFile.mytemp1d->SetLineColor(30);
+                fGoldenFile.mytemp1d->SetFillColor(30);
+                Int_t fillstyle=3027;
+                if(fPrintOnly) fillstyle=3010;
+                fGoldenFile.mytemp1d->SetFillStyle(fillstyle);
+                fRootFile.mytemp1d->SetStats(showStat);
+                fGoldenFile.mytemp1d->SetStats(kFALSE);
+                fGoldenFile.mytemp1d->Draw();
+                if(!htitle.IsNull()) fGoldenFile.mytemp1d->SetTitle(htitle);
+                fRootFile.mytemp1d->Draw("sames"+type);
+            } else {
+                fRootFile.mytemp1d->SetStats(showStat);
+                if(!htitle.IsNull()) fRootFile.mytemp1d->SetTitle(htitle);
+                fRootFile.mytemp1d->Draw(type);
+
+                // Force TH1s' y-axis to start at 1 if not a logy plot
+                if(gStyle->GetOptLogy() == 0)
+                    fRootFile.mytemp1d->SetMinimum(1);
+            }
+        }
+        return;
+    }
+
+    if(command.objtype.Contains("TH2")) {
+        // Operation for TH2
+        if(!showGolden) fRootFile.RootFile->cd();
+        if(fDir) fDir->cd();
+        fRootFile.mytemp2d = (TH2D*)gDirectory->Get(command.objname);
+        if(fRootFile.mytemp2d->GetEntries()==0) {
+            BadDraw("Empty Histogram");
+        } else {
+            if(showGolden) {
+                fGoldenFile.RootFile->cd();
+                if(fDir) fDir->cd();
+                fGoldenFile.mytemp2d = (TH2D*)gDirectory->Get(command.objname);
+                fGoldenFile.mytemp2d->SetMarkerColor(2);
+                fRootFile.mytemp2d->SetStats(showStat);
+                fGoldenFile.mytemp2d->SetStats(kFALSE);
+                fGoldenFile.mytemp2d->Draw(type);
+                if(!htitle.IsNull()) fGoldenFile.mytemp2d->SetTitle(htitle);
+                fRootFile.mytemp2d->Draw("sames"+type);
+            } else {
+                fRootFile.mytemp2d->SetStats(showStat);
+                if(!htitle.IsNull()) fGoldenFile.mytemp2d->SetTitle(htitle);
+                fRootFile.mytemp2d->Draw(type);
+                fRootFile.mytemp2d->Draw("colz");
+            }
+        }
+        return;
+    }
+
+    if(command.objtype.Contains("TH3")) {
+        // Operation for TH3
+        if(!showGolden) fRootFile.RootFile->cd();
+        if(fDir) fDir->cd();
+        fRootFile.mytemp3d = (TH3D*)gDirectory->Get(command.objname);
+        if(fRootFile.mytemp3d->GetEntries()==0) {
+            BadDraw("Empty Histogram");
+        } else {
+            fRootFile.mytemp3d->Draw();
+            if(showGolden) {
+                fGoldenFile.RootFile->cd();
+                if(fDir) fDir->cd();
+                fGoldenFile.mytemp3d = (TH3D*)gDirectory->Get(command.objname);
+                fGoldenFile.mytemp3d->SetMarkerColor(2);
+                fRootFile.mytemp3d->SetStats(showStat);
+                fGoldenFile.mytemp3d->SetStats(kFALSE);
+                fGoldenFile.mytemp3d->Draw(type);
+                if(!htitle.IsNull()) fGoldenFile.mytemp3d->SetTitle(htitle);
+                fRootFile.mytemp3d->Draw("sames"+type);
+            } else {
+                fRootFile.mytemp3d->SetStats(showStat);
+                if(!htitle.IsNull()) fGoldenFile.mytemp3d->SetTitle(htitle);
+                fRootFile.mytemp3d->Draw(type);
+            }
+        }
+        return;
+    }
+
+}
+
+drawcommand OnlineGUI::fileObject2command(drawcommand command, RootFileObject* fLocalRootFileObj) {
+    // Fill in gaps in the drawcommand with items from the
+    // vfileObject.  This elimates the need for duplicate code in
+    // the different *Draw routines.
+    for(UInt_t i=0; i<fLocalRootFileObj->vfileObjects.size(); i++) {
+        if(fLocalRootFileObj->vfileObjects[i].name==command.variable ||
+                fLocalRootFileObj->vfileObjects[i].title==command.variable ) {
+            command.objname = fLocalRootFileObj->vfileObjects[i].name;
+            command.objtitle = fLocalRootFileObj->vfileObjects[i].title;
+            command.objtype = fLocalRootFileObj->vfileObjects[i].type;
+            command.directory = fLocalRootFileObj->vfileObjects[i].directory;
+#ifdef DEBUGf2command
+            cout << command.directory << " "
+                << command.objtype  << " "
+                << command.objname
+                << endl;
+#endif
+            return command;
+        }
+    }
+    return command;
+
+
+}
+
+void OnlineGUI::TreeDraw(drawcommand command) {
+    // Called by DoDraw(), this will plot a Tree Variable
+
+    TString var = command.variable;
+    Bool_t showGolden=kFALSE;
+    if(doGolden) showGolden=kTRUE;
+
+    Bool_t showStat=kTRUE;
+    if(command.nostat=="nostat") showStat=kFALSE;
+
+    //TObject *hobj;
+
+    // Combine the cuts (definecuts and specific cuts)
+    TCut cut = "";
+    TString tempCut;
+    if(!command.cut.IsNull()) {
+        tempCut = command.cut;
+        vector <TString> cutIdents = fConfig->GetCutIdent();
+        for(UInt_t i=0; i<cutIdents.size(); i++) {
+            if(tempCut.Contains(cutIdents[i])) {
+                TString cut_found = (TString)fConfig->GetDefinedCut(cutIdents[i]);
+                tempCut.ReplaceAll(cutIdents[i],cut_found);
+            }
+        }
+        cut = (TCut)tempCut;
+    }
+
+    // Determine which Tree the variable comes from, then draw it.
+    UInt_t iTree;
+    if(command.treename.IsNull()) {
+        iTree = GetTreeIndex(var,&fRootFile);
+    } else {
+        iTree = GetTreeIndexFromName(command.treename,&fRootFile);
+    }
+    TString drawopt = command.type;
+    Int_t errcode=0;
+    if(drawopt.IsNull() && var.Contains(":")) drawopt = "cont";
+    if(drawopt=="scat") drawopt = "";
+
+    fRootFile.RootFile->cd();
+    if (iTree <= fRootFile.RootTree.size() ) {
+        TObjArray* tok = var.Tokenize(">()");
+        TString myvar   = ((TObjString*)tok->First())->GetString();
+        TString hname   = "h";
+        TString histdef = ((TObjString*)tok->Last())->GetString();
+        if(tok->GetEntries() == 1) histdef = "";        // ie "var[0]"
+        if(tok->GetEntries() == 2) {
+            if(! histdef.Contains(",") ) {             // ie "var[0]>>h1"
+                hname = histdef;
+                histdef = "";
+            }
+        }
+        if(tok->GetEntries() == 3) hname = ((TObjString*)tok->At(1))->GetString();  // ie "var[0]>>h1(100,0,100)"
+        delete tok;
+        TString tmp = var + tempCut;
+        hname = Form("%s_%u",hname.Data(),tmp.Hash());      // unique id so caching histos works
+
+        errcode=1;
+        TObject *hobj  = gDirectory->Get(hname);
+        if(hobj == NULL) {
+            errcode = fRootFile.RootTree[iTree]->Draw(myvar+">>"+hname+"("+histdef+")",cut,drawopt,
+                    1000000000,fRootFile.TreeEntries[iTree]);
+            hobj = gDirectory->Get(hname);
+        }
+        TH1F *mainhist = (TH1F*)hobj;
+        mainhist->Draw(drawopt);
+        //tmp = myvar+">>"+hname+"("+histdef+")";
+        //printf("hist: '%s',  opt: '%s',  \"%s\"\n", hname.Data(), drawopt.Data(),tmp.Data());
+
+        if(errcode==-1) {
+            BadDraw(var+" not found");
+        } else if (errcode!=0) {
+            TString htype = hobj->ClassName();
+            if(! htype.Contains("TH1F") ) {
+                //printf("skipping.\n");
+                showGolden=kFALSE;
+            }
+            if(showGolden) {
+                errcode=1;
+                TString goldname = "gold"+hname;
+                TH1F *goldhist = (TH1F*)gDirectory->Get(goldname);
+                if(goldhist == NULL) {
+                    goldhist = (TH1F*)mainhist->Clone(hname);
+                    goldhist->SetName(goldname);
+                    errcode = fGoldenFile.RootTree[iTree]->Project(goldname,myvar,cut);
+                }
+                if(errcode>0) {
+                    goldhist->SetFillColor(30);
+                    Int_t fillstyle=3027;
+                    if(fPrintOnly) fillstyle=3010;
+                    goldhist->SetFillStyle(fillstyle);
+                    goldhist->Draw(drawopt);
+                    mainhist->SetFillColor(0);
+                    mainhist->SetFillStyle(1001);
+                    mainhist->Draw("same");
+                    if(!command.title.IsNull()) goldhist->SetTitle(command.title);
+                    if(!showStat)               goldhist->SetStats(kFALSE);
+                }
+            } else {
+                if(!command.title.IsNull()) mainhist->SetTitle(command.title);
+                if(!showStat)               mainhist->SetStats(kFALSE);
+            }
+        } else {
+            BadDraw("Empty Histogram");
+        }
+    } else {
+        BadDraw(var+" not found");
+        if (fConfig->IsMonitor()){
+            // Maybe we missed it... look again.  I dont like the code
+            // below... maybe I can come up with something better
+            GetFileObjects(&fRootFile);
+            GetRootTree(&fRootFile);
+            GetTreeVars(&fRootFile);
+        }
+    }
+
+}
+
+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;
+#endif
+}
+
+void OnlineGUI::PrintToFile()
+{
+    // Routine to print the current page to a File.
+    //  A file dialog pop's up to request the file name.
+    fCanvas = fEcanvas->GetCanvas();
+    gStyle->SetPaperSize(20,24);
+    static TString dir(".");
+    TGFileInfo fi;
+    const char *myfiletypes[] =
+    { "All files","*",
+        "PDF files","*.pdf",
+        "PNG files","*.png",
+        "GIF files","*.gif",
+        "JPG files","*.jpg",
+        0,               0 };
+    fi.fFileTypes = myfiletypes;
+    fi.fIniDir    = StrDup(dir.Data());
+    cout << " INitiail = " << fi.fIniDir << endl;
+    new TGFileDialog(gClient->GetRoot(), fMain, kFDSave, &fi);
+    if(fi.fFilename!=NULL) {
+        fCanvas->Print(fi.fFilename);
+    }
+}
+
+void OnlineGUI::PrintPages() {
+    // 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");
+    if(!fRootFile.RootFile->IsOpen()) {
+        cout << "ERROR:  rootfile: " << fConfig->GetRootFile()
+            << " does not exist"
+            << endl;
+#ifdef STANDALONE
+        gApplication->Terminate();
+#else
+        return;
+#endif
+    } else {
+        fFileAlive = kTRUE;
+        ObtainRunNumber();
+        // Open the Root Trees.  Give a warning if it's not there..
+        GetFileObjects(&fRootFile);
+        GetRootTree(&fRootFile);
+        GetTreeVars(&fRootFile);
+        for(UInt_t i=0; i<fRootFile.RootTree.size(); i++) {
+            if(fRootFile.RootTree[i]==0) {
+                fRootFile.RootTree.erase(fRootFile.RootTree.begin() + i);
+            }
+        }
+
+    }
+    TString goldenfilename=fConfig->GetGoldenFile();
+    if(!goldenfilename.IsNull()) {
+        fGoldenFile.RootFile = new TFile(goldenfilename,"READ");
+        if(!fGoldenFile.RootFile->IsOpen()) {
+            cout << "ERROR: goldenrootfile: " << goldenfilename
+                << " does not exist.  Oh well, no comparison plots."
+                << endl;
+            doGolden = kFALSE;
+            fGoldenFile.RootFile=NULL;
+        } else {
+            // Open the Root Trees.  Give a warning if it's not there..
+            GetFileObjects(&fGoldenFile);
+            GetRootTree(&fGoldenFile);
+            GetTreeVars(&fGoldenFile);
+            for(UInt_t i=0; i<fGoldenFile.RootTree.size(); i++) {
+                if(fGoldenFile.RootTree[i]==0) {
+                    fGoldenFile.RootTree.erase(fGoldenFile.RootTree.begin() + i);
+                }
+            }
+            doGolden = kTRUE;
+        }
+    } else {
+        doGolden=kFALSE;
+        fGoldenFile.RootFile=NULL;
+    }
+
+    // I'm not sure exactly how this works.  But it does.
+    fCanvas = new TCanvas("fCanvas","trythis",850,1100);
+    //   TCanvas *maincanvas = new TCanvas("maincanvas","whatever",850,1100);
+    //   maincanvas->SetCanvas(fCanvas);
+    TLatex *lt = new TLatex();
+
+    TString plotsdir = fConfig->GetPlotsDir();
+    Bool_t useJPG = kFALSE;
+    if(!plotsdir.IsNull()) useJPG = kTRUE;
+
+    //  TString filename = "summaryplots";
+    TString ConfigStartAll=fConfig->GetConfigStart();
+    TObjArray *tx= ConfigStartAll.Tokenize("/");
+    TString temp=((TObjString *)(tx->At(tx->GetEntries()-1)))->String();
+    Ssiz_t pos=temp.Index(".cfg");
+    TString filename=temp(0,pos);
+    if(runNumber!=0) {
+        filename += "_";
+        filename += runNumber;
+    }
+    if(useJPG) {
+        filename.Prepend(plotsdir+"/");
+        filename += "_pageXXXX.jpg";
+    }
+    else filename += ".pdf";
+
+    TString pagehead = "Summary Plots";
+    if(runNumber!=0) {
+        pagehead += "(Run #";
+        pagehead += runNumber;
+        pagehead += ")";
+    }
+    pagehead += ": ";
+
+    gStyle->SetPalette(1);
+    gStyle->SetTitleX(0.5);
+    gStyle->SetTitleY(0.95);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetHistLineColor(1);
+    gStyle->SetHistFillColor(1);
+    cout << filename << endl;
+    if(!useJPG) fCanvas->Print(filename+"[");
+    TString origFilename = filename;
+    for(UInt_t i=0; i<fConfig->GetPageCount(); i++) {
+        current_page=i;
+        DoDraw();
+        TString pagename = pagehead + fConfig->GetPageTitle(current_page);
+        lt->SetTextSize(0.025);
+        lt->DrawLatex(0.05,0.98,pagename);
+        if(useJPG) {
+            filename = origFilename;
+            filename.ReplaceAll("XXXX",Form("%d",current_page));
+            cout << "Printing page " << current_page
+                << " to file = " << filename << endl;
+        }
+        fCanvas->Print(filename);
+    }
+    if(!useJPG) fCanvas->Print(filename+"]");
+    //
+
+    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();
+#endif
+}
+
+void OnlineGUI::MyCloseWindow()
+{
+    fMain->SendCloseMessage();
+    cout << "OnlineGUI Closed." << endl;
+    if(timer!=NULL) {
+        timer->Stop();
+        delete timer;
+    }
+    delete fPrint;
+    delete fExit;
+    delete fRunNumber;
+    delete fPrev;
+    delete fNext;
+    delete wile;
+    for(UInt_t i=0; i<fConfig->GetPageCount(); i++)
+        delete fRadioPage[i];
+    delete hframe;
+    delete fEcanvas;
+    delete fBottomFrame;
+    delete vframe;
+    delete fTopframe;
+    delete fMain;
+    if(fGoldenFile.RootFile!=NULL) delete fGoldenFile.RootFile;
+    if(fRootFile.RootFile!=NULL) delete fRootFile.RootFile;
+    delete fConfig;
+
+#ifdef STANDALONE
+    gApplication->Terminate();
+#endif
+}
+
+void OnlineGUI::CloseGUI()
+{
+    // Routine to take care of the Exit GUI button
+    fMain->SendCloseMessage();
+}
+
+OnlineGUI::~OnlineGUI()
+{
+    //  fMain->SendCloseMessage();
+    if(timer!=NULL) {
+        timer->Stop();
+        delete timer;
+    }
+    delete fPrint;
+    delete fExit;
+    delete fRunNumber;
+    delete fPrev;
+    delete fNext;
+    delete wile;
+    for(UInt_t i=0; i<fConfig->GetPageCount(); i++)
+        delete fRadioPage[i];
+    delete hframe;
+    delete fEcanvas;
+    delete vframe;
+    delete fBottomFrame;
+    delete fTopframe;
+    delete fMain;
+    if(fGoldenFile.RootFile!=NULL) delete fGoldenFile.RootFile;
+    if(fRootFile.RootFile!=NULL) delete fRootFile.RootFile;
+    delete fConfig;
+}
+
+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.
+
+    if(printonly || rootonly) {
+        if(!gROOT->IsBatch()) {
+#ifdef STANDALONE
+            gROOT->SetBatch();
+#else
+            cout << "Sorry... the print summary plots option only works "
+                << "in BATCH mode." << endl;
+            return;
+#endif
+        }
+    }
+
+    OnlineConfig *fconfig = new OnlineConfig(type);
+    //    OnlineConfig *fconfig = new OnlineConfig("halla");
+
+    if(!fconfig->ParseConfig()) {
+#ifdef STANDALONE
+        gApplication->Terminate();
+#else
+        return;
+#endif
+    }
+
+    if(run!=0) fconfig->OverrideRootFile(run);
+
+    new OnlineGUI(*fconfig,printonly,rootonly,run);
+
+}
+
+#ifdef STANDALONE
+void Usage()
+{
+    cerr << "Usage: online [-r] [-f] [-P]"
+        << endl;
+    cerr << "Options:" << endl;
+    cerr << "  -r : runnumber" << endl;
+    cerr << "  -f : configuration file" << endl;
+    cerr << "  -P : Only Print Summary Plots" << endl;
+    cerr << "  -R : Only Rootfile " << endl;
+    cerr << endl;
+
+}
+
+int main(int argc, char **argv)
+{
+    TString type="default";
+    UInt_t run=0;
+    Bool_t printonly=kFALSE;
+    Bool_t rootonly=kFALSE;
+    Bool_t showedUsage=kFALSE;
+
+    TApplication theApp("App",&argc,argv,NULL,-1);
+
+    for(Int_t i=1;i<theApp.Argc();i++)
+    {
+        TString sArg = theApp.Argv(i);
+        if(sArg=="-f") {
+            type = theApp.Argv(++i);
+            cout << " File specifier: "
+                <<  type << endl;
+        } else if (sArg=="-r") {
+            run = atoi(theApp.Argv(++i));
+            cout << " Runnumber: "
+                << run << endl;
+        } else if (sArg=="-P") {
+            printonly = kTRUE;
+            cout <<  " PrintOnly" << endl;
+        } else if (sArg=="-R") {
+            rootonly = kTRUE;
+            cout <<  " RootOnly" << endl;
+        } else if (sArg=="-h") {
+            if(!showedUsage) Usage();
+            showedUsage=kTRUE;
+            return 0;
+        } else {
+            cerr << "\"" << sArg << "\"" << " not recognized.  Ignored." << endl;
+            if(!showedUsage) Usage();
+            showedUsage=kTRUE;
+        }
+    }
+
+    online(type,run,printonly,rootonly);
+    theApp.Run();
+
+    return 0;
+}
+
+#endif