From af6ae29caf9731af6a21503ff770719d93ed1e67 Mon Sep 17 00:00:00 2001
From: Kayla CrayCraft <kayla@jlab.org>
Date: Wed, 1 Nov 2017 15:36:16 -0400
Subject: [PATCH] Update BCM scaler param and templates

---
 PARAM/GEN/gscalers.param                      | 17 ++++----
 .../COIN/PRODUCTION/coin_production.template  | 24 +++++++++--
 .../PRODUCTION/hstackana_production.template  | 41 +++++++++++++++++--
 TEMPLATES/HMS/SCALERS/hscalers.template       | 21 +++++++---
 .../PRODUCTION/pstackana_production.template  | 26 +++++++++---
 TEMPLATES/SHMS/SCALERS/pscalers.template      | 24 +++++++----
 6 files changed, 117 insertions(+), 36 deletions(-)

diff --git a/PARAM/GEN/gscalers.param b/PARAM/GEN/gscalers.param
index b0c297af..40b531b6 100644
--- a/PARAM/GEN/gscalers.param
+++ b/PARAM/GEN/gscalers.param
@@ -1,10 +1,7 @@
-gbcm1_gain = 0.000328739              ; microA/Hz (New Value)
-gbcm2_gain = 0.000381677              ; microA/Hz (New Value)
-gbcm3_gain = 0.00043343               ; microA/Hz (Old, Value)
-
-gbcm1_offset =  250842.               ; Hz (New Value)
-gbcm2_offset =  250567.               ; Hz (New Value)
-gbcm3_offset =  245437.               ; Hz (Old, Value)
-
-gunser_offset =  514529.              ; Hz (Old, Value)
-gunser_gain = 0.00025001              ; microA/Hz (New Value)
+gNumBCMs=3
+gBCM_Gain = 4673,3954,4000
+gBCM_Offset = 250000,250000,393000
+gBCM_Names="BCM1 BCM2 Unser"
+gBCM_Current_threshold=1.0
+; index = 0 to gNumBCMs-1
+gBCM_Current_threshold_index=0
diff --git a/TEMPLATES/COIN/PRODUCTION/coin_production.template b/TEMPLATES/COIN/PRODUCTION/coin_production.template
index df28a222..134bc07e 100644
--- a/TEMPLATES/COIN/PRODUCTION/coin_production.template
+++ b/TEMPLATES/COIN/PRODUCTION/coin_production.template
@@ -1,9 +1,25 @@
 Run #: {gen_run_number}
 
-Run Time  : {P.1Mhz.scaler}  {P.1Mhz.scaler/1000000.} sec
 
-BCM1  : {(P.BCM1.scalerRate-250000)/(4673):%3.3f} uA      Total charge = {(P.BCM1.scalerRate-250000) / (4673)*P.1Mhz.scaler/1000000.:%7.3f} uC
-BCM2  : {(P.BCM2.scalerRate-250000)/(3954):%3.3f} uA      Total charge = {(P.BCM2.scalerRate-250000) / (3954)*P.1Mhz.scaler/1000000.:%7.3f} uC 
-Unser : {(P.Unser.scalerRate-393000)/(4000):%3.3f} uA     Total charge = {(P.Unser.scalerRate-393000) / (4000)*P.1Mhz.scaler/1000000.:%7.3f} uC
+1 MhZ Pulses : {P.1Mhz.scaler}
+Run Length   : {P.1Mhz.scalerTime:%.3f} sec
+
+***********
+* Beamline
+***********
+  
+BCM1 Current: {P.BCM1.scalerCurrent:%.3f} uA		  
+BCM2 Current: {P.BCM2.scalerCurrent:%.3f} uA		 
+Unser Current: {P.Unser.scalerCurrent:%.3f} uA		  
+
+With no cuts on BCM{gBCM_Current_threshold_index+1}.
+BCM1 Counts: {P.BCM1.scaler}		Total Charge: {P.BCM1.scalerCharge:%.3f} uC
+BCM2 Counts: {P.BCM2.scaler} 		Total Charge: {P.BCM2.scalerCharge:%.3f} uC	
+Unser Counts: {P.Unser.scaler} 		Total Charge: {P.Unser.scalerCharge:%.3f} uC
+
+Cut on BCM{gBCM_Current_threshold_index+1} current of {gBCM_Current_threshold} uA. Beam over threshold for {P.1Mhz.scalerTimeCut:%.3f}s, or {((P.1Mhz.scalerTimeCut/P.1Mhz.scalerTime)*100.):%.3f}% of total run time.
+BCM1 Counts: {P.BCM1.scalerCut} 	Total Charge: {P.BCM1.scalerChargeCut:%.3f} uC
+BCM2 Counts: {P.BCM2.scalerCut} 	Total Charge: {P.BCM2.scalerChargeCut:%.3f} uC
+Unser Counts: {P.Unser.scalerCut} 	Total Charge: {P.Unser.scalerChargeCut:%.3f} uC
 
 All triggers  :  {all_trigs.npassed}
\ No newline at end of file
diff --git a/TEMPLATES/HMS/PRODUCTION/hstackana_production.template b/TEMPLATES/HMS/PRODUCTION/hstackana_production.template
index b1514669..34455556 100644
--- a/TEMPLATES/HMS/PRODUCTION/hstackana_production.template
+++ b/TEMPLATES/HMS/PRODUCTION/hstackana_production.template
@@ -1,10 +1,29 @@
 Run #{gen_run_number}
 
-Run Time  : {H.1Mhz.scaler}  {H.1Mhz.scaler/1000000.} sec 
+**************************
+* General Run Information
+**************************
 
-BCM1  : {(H.BCM1.scalerRate-250000)/(4673):%3.3f} uA      Total charge = {(H.BCM1.scalerRate-250000) / (4673)*H.1Mhz.scaler/1000000.:%7.3f} uC
-BCM2  : {(H.BCM2.scalerRate-250000)/(3954):%3.3f} uA      Total charge = {(H.BCM2.scalerRate-250000) / (3954)*H.1Mhz.scaler/1000000.:%7.3f} uC 
-Unser : {(H.Unser.scalerRate-393000)/(4000):%3.3f} uA     Total charge = {(H.Unser.scalerRate-393000) / (4000)*H.1Mhz.scaler/1000000.:%7.3f} uC 
+1 MhZ Pulses : {H.1Mhz.scaler}
+Run Length   : {H.1Mhz.scalerTime:%.3f} sec
+
+***********
+* Beamline
+***********
+  
+BCM1 Current: {H.BCM1.scalerCurrent:%.3f} uA		  
+BCM2 Current: {H.BCM2.scalerCurrent:%.3f} uA		 
+Unser Current: {H.Unser.scalerCurrent:%.3f} uA		  
+
+With no cuts on BCM{gBCM_Current_threshold_index+1}.
+BCM1 Counts: {H.BCM1.scaler}		Total Charge: {H.BCM1.scalerCharge:%.3f} uC
+BCM2 Counts: {H.BCM2.scaler} 		Total Charge: {H.BCM2.scalerCharge:%.3f} uC	
+Unser Counts: {H.Unser.scaler} 		Total Charge: {H.Unser.scalerCharge:%.3f} uC
+
+Cut on BCM{gBCM_Current_threshold_index+1} current of {gBCM_Current_threshold} uA. Beam over threshold for {H.1Mhz.scalerTimeCut:%.3f}s, or {((H.1Mhz.scalerTimeCut/H.1Mhz.scalerTime)*100.):%.3f}% of total run time.
+BCM1 Counts: {H.BCM1.scalerCut} 	Total Charge: {H.BCM1.scalerChargeCut:%.3f} uC
+BCM2 Counts: {H.BCM2.scalerCut} 	Total Charge: {H.BCM2.scalerChargeCut:%.3f} uC
+Unser Counts: {H.Unser.scalerCut} 	Total Charge: {H.Unser.scalerChargeCut:%.3f} uC
 
 {hdc_plane_names}
 Horizontal drift chamber z positions:
@@ -15,6 +34,20 @@ Chamber 2: {hdc_zpos[6]:%6.2f} {hdc_zpos[7]:%6.2f} {hdc_zpos[8]:%6.2f}
 
 HMS triggers:  {hms_trigs.npassed}
 
+Hodo efficiency:
+Plane 1: {hhodo_plane_AND_eff[0]}
+Plane 2: {hhodo_plane_AND_eff[1]}
+Plane 3: {hhodo_plane_AND_eff[2]}
+Plane 4: {hhodo_plane_AND_eff[3]}
+
+S1XY : {hhodo_s1XY_eff}
+S2XY : {hhodo_s2XY_eff}
+
+STOF: {hhodo_stof_eff}
+
+3_of_4 EFF : {hhodo_3_of_4_eff}
+4_of_4 EFF : {hhodo_4_of_4_eff}
+
 Rate  :  {H.Trig.scalerRate/1000.:%7.3f} kHz
 
 Live Time : {(hms_trigs.npassed / H.Trig.scaler)*100.0:%3.2f} %
diff --git a/TEMPLATES/HMS/SCALERS/hscalers.template b/TEMPLATES/HMS/SCALERS/hscalers.template
index b8ffe2f1..426eaf7e 100644
--- a/TEMPLATES/HMS/SCALERS/hscalers.template
+++ b/TEMPLATES/HMS/SCALERS/hscalers.template
@@ -1,19 +1,28 @@
 Run #: {gen_run_number}
-
 **************************
 * General Run Information
 **************************
 
 1 MhZ Pulses : {H.1Mhz.scaler}
-Run Length   : {H.1Mhz.scaler/1000000.:%.3f} sec
+Run Length   : {H.1Mhz.scalerTime:%.3f} sec
 
 ***********
 * Beamline
 ***********
-
-BCM1  Current : {(H.BCM1.scalerRate-250000)/(4673):%.3f} uA      Total charge = {(H.BCM1.scalerRate-250000) / (4673)*H.1Mhz.scaler/1000000.:%.3f} uC
-BCM2  Current : {(H.BCM2.scalerRate-250000)/(3954):%.3f} uA      Total charge = {(H.BCM2.scalerRate-250000) / (3954)*H.1Mhz.scaler/1000000.:%.3f} uC 
-Unser Current : {(H.Unser.scalerRate-393000)/(4000):%.3f} uA     Total charge = {(H.Unser.scalerRate-393000) / (4000)*H.1Mhz.scaler/1000000.:%.3f} uC
+  
+BCM1 Current: {H.BCM1.scalerCurrent:%.3f} uA		  
+BCM2 Current: {H.BCM2.scalerCurrent:%.3f} uA		 
+Unser Current: {H.Unser.scalerCurrent:%.3f} uA		  
+
+With no cuts on BCM{gBCM_Current_threshold_index+1}.
+BCM1 Counts: {H.BCM1.scaler}		Total Charge: {H.BCM1.scalerCharge:%.3f} uC
+BCM2 Counts: {H.BCM2.scaler} 		Total Charge: {H.BCM2.scalerCharge:%.3f} uC	
+Unser Counts: {H.Unser.scaler} 		Total Charge: {H.Unser.scalerCharge:%.3f} uC
+
+Cut on BCM{gBCM_Current_threshold_index+1} current of {gBCM_Current_threshold} uA. Beam over threshold for {H.1Mhz.scalerTimeCut:%.3f}s, or {((H.1Mhz.scalerTimeCut/H.1Mhz.scalerTime)*100.):%.3f}% of total run time.
+BCM1 Counts: {H.BCM1.scalerCut} 	Total Charge: {H.BCM1.scalerChargeCut:%.3f} uC
+BCM2 Counts: {H.BCM2.scalerCut} 	Total Charge: {H.BCM2.scalerChargeCut:%.3f} uC
+Unser Counts: {H.Unser.scalerCut} 	Total Charge: {H.Unser.scalerChargeCut:%.3f} uC
 
 ***********
 * Triggers
diff --git a/TEMPLATES/SHMS/PRODUCTION/pstackana_production.template b/TEMPLATES/SHMS/PRODUCTION/pstackana_production.template
index 84b9f3f4..b28ac12e 100644
--- a/TEMPLATES/SHMS/PRODUCTION/pstackana_production.template
+++ b/TEMPLATES/SHMS/PRODUCTION/pstackana_production.template
@@ -1,10 +1,25 @@
 Run #: {gen_run_number}
 
-Run Time  : {P.1Mhz.scaler}  {P.1Mhz.scaler/1000000.} sec
-
-BCM1  : {(P.BCM1.scalerRate-250000)/(4673):%3.3f} uA      Total charge = {(P.BCM1.scalerRate-250000) / (4673)*P.1Mhz.scaler/1000000.:%7.3f} uC
-BCM2  : {(P.BCM2.scalerRate-250000)/(3954):%3.3f} uA      Total charge = {(P.BCM2.scalerRate-250000) / (3954)*P.1Mhz.scaler/1000000.:%7.3f} uC 
-Unser : {(P.Unser.scalerRate-393000)/(4000):%3.3f} uA     Total charge = {(P.Unser.scalerRate-393000) / (4000)*P.1Mhz.scaler/1000000.:%7.3f} uC
+1 MhZ Pulses : {P.1Mhz.scaler}
+Run Length   : {P.1Mhz.scalerTime:%.3f} sec
+
+***********
+* Beamline
+***********
+  
+BCM1 Current: {P.BCM1.scalerCurrent:%.3f} uA		  
+BCM2 Current: {P.BCM2.scalerCurrent:%.3f} uA		 
+Unser Current: {P.Unser.scalerCurrent:%.3f} uA		  
+
+With no cuts on BCM{gBCM_Current_threshold_index+1}.
+BCM1 Counts: {P.BCM1.scaler}		Total Charge: {P.BCM1.scalerCharge:%.3f} uC
+BCM2 Counts: {P.BCM2.scaler} 		Total Charge: {P.BCM2.scalerCharge:%.3f} uC	
+Unser Counts: {P.Unser.scaler} 		Total Charge: {P.Unser.scalerCharge:%.3f} uC
+
+Cut on BCM{gBCM_Current_threshold_index+1} current of {gBCM_Current_threshold} uA. Beam over threshold for {P.1Mhz.scalerTimeCut:%.3f}s, or {((P.1Mhz.scalerTimeCut/P.1Mhz.scalerTime)*100.):%.3f}% of total run time.
+BCM1 Counts: {P.BCM1.scalerCut} 	Total Charge: {P.BCM1.scalerChargeCut:%.3f} uC
+BCM2 Counts: {P.BCM2.scalerCut} 	Total Charge: {P.BCM2.scalerChargeCut:%.3f} uC
+Unser Counts: {P.Unser.scalerCut} 	Total Charge: {P.Unser.scalerChargeCut:%.3f} uC
 
 SHMS triggers  :  {shms_trigs.npassed}
 
@@ -12,6 +27,7 @@ Rate  :  {P.Trig.scalerRate/1000.:%7.3f} kHz
 Live Time : {(shms_trigs.npassed / P.Trig.scaler)*100.0:%3.2f} %
 Dead Time : {100.0 - (shms_trigs.npassed / P.Trig.scaler)*100.0:%3.2f} %
 
+
 **DRIFT CHAMBER** 
 good_S1_time         Counts: {good_S1_time.npassed}     / all_trigs : {good_S1_time.npassed / all_trigs.npassed}       
 good_S2X_time        Counts: {good_S2X_time.npassed}    / all_trigs : {good_S2X_time.npassed / all_trigs.npassed}    
diff --git a/TEMPLATES/SHMS/SCALERS/pscalers.template b/TEMPLATES/SHMS/SCALERS/pscalers.template
index c328cd75..8a7b723d 100644
--- a/TEMPLATES/SHMS/SCALERS/pscalers.template
+++ b/TEMPLATES/SHMS/SCALERS/pscalers.template
@@ -5,17 +5,27 @@ Run #: {gen_run_number}
 **************************
 
 1 MhZ Pulses : {P.1Mhz.scaler}
-Run Length   : {P.1Mhz.scaler/1000000.:%.3f} sec
+Run Length   : {P.1Mhz.scalerTime:%.3f} sec
 
 ***********
 * Beamline
 ***********
-
-BCM1  Current : {(P.BCM1.scalerRate-250000)/(4673):%.3f} uA      Total charge = {(P.BCM1.scalerRate-250000) / (4673)*P.1Mhz.scaler/1000000.:%.3f} uC
-BCM2  Current : {(P.BCM2.scalerRate-250000)/(3954):%.3f} uA      Total charge = {(P.BCM2.scalerRate-250000) / (3954)*P.1Mhz.scaler/1000000.:%.3f} uC 
-Unser Current : {(P.Unser.scalerRate-393000)/(4000):%.3f} uA     Total charge = {(P.Unser.scalerRate-393000) / (4000)*P.1Mhz.scaler/1000000.:%.3f} uC
-
-***********
+  
+BCM1 Current: {P.BCM1.scalerCurrent:%.3f} uA		  
+BCM2 Current: {P.BCM2.scalerCurrent:%.3f} uA		 
+Unser Current: {P.Unser.scalerCurrent:%.3f} uA		  
+
+With no cuts on BCM{gBCM_Current_threshold_index+1}.
+BCM1 Counts: {P.BCM1.scaler}		Total Charge: {P.BCM1.scalerCharge:%.3f} uC
+BCM2 Counts: {P.BCM2.scaler} 		Total Charge: {P.BCM2.scalerCharge:%.3f} uC	
+Unser Counts: {P.Unser.scaler} 		Total Charge: {P.Unser.scalerCharge:%.3f} uC
+
+Cut on BCM{gBCM_Current_threshold_index+1} current of {gBCM_Current_threshold} uA. Beam over threshold for {P.1Mhz.scalerTimeCut:%.3f}s, or {((P.1Mhz.scalerTimeCut/P.1Mhz.scalerTime)*100.):%.3f}% of total run time.
+BCM1 Counts: {P.BCM1.scalerCut} 	Total Charge: {P.BCM1.scalerChargeCut:%.3f} uC
+BCM2 Counts: {P.BCM2.scalerCut} 	Total Charge: {P.BCM2.scalerChargeCut:%.3f} uC
+Unser Counts: {P.Unser.scalerCut} 	Total Charge: {P.Unser.scalerChargeCut:%.3f} uC
+
+***********	
 * Triggers
 ***********
 
-- 
GitLab