From 17f89d50b7ac210542cd419a84a2920ae663ffde Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sylvester.joosten@gmail.com>
Date: Wed, 18 Dec 2019 15:45:23 -0500
Subject: [PATCH] Merged in upstream changes

---
 DBASE/HMS/standard.kinematics                 | 21 ++++++
 DBASE/SHMS/standard.kinematics                |  1 -
 PARAM/GEN/gbeam.param                         | 48 ++++++--------
 PARAM/TRIG/thms.param                         | 18 +++---
 PARAM/TRIG/tshms.param                        | 20 +++---
 .../SHMS/PRODUCTION/shms_production.cfg       | 11 ++++
 onlineGUI/UTIL/BEAMLINE/bcm_mon.C             | 64 +++++++++++++++++++
 7 files changed, 134 insertions(+), 49 deletions(-)
 create mode 100644 onlineGUI/UTIL/BEAMLINE/bcm_mon.C

diff --git a/DBASE/HMS/standard.kinematics b/DBASE/HMS/standard.kinematics
index 302f993d..b25eeca7 100644
--- a/DBASE/HMS/standard.kinematics
+++ b/DBASE/HMS/standard.kinematics
@@ -2016,3 +2016,24 @@ ppcentral = 2.1483
 ppartmass = 0.000511
 hpartmass = 0.000511
 
+2509-2524
+gpbeam = 2.174
+gtargmass_amu =  1.00794
+hpartmass = 0.00051099
+htheta_lab = -11.70
+hpcentral = 2.1483
+
+2525-2526
+gpbeam = 2.174
+gtargmass_amu =  1.00794
+hpartmass = 0.00051099
+htheta_lab = -11.70
+hpcentral = 2.0742
+
+2527-2599
+gpbeam = 2.174
+gtargmass_amu =  1.00794
+hpartmass = 0.00051099
+htheta_lab = -11.70
+hpcentral = 2.1483
+
diff --git a/DBASE/SHMS/standard.kinematics b/DBASE/SHMS/standard.kinematics
index f0a97949..89943f3a 100644
--- a/DBASE/SHMS/standard.kinematics
+++ b/DBASE/SHMS/standard.kinematics
@@ -2258,4 +2258,3 @@ hpcentral = 2.1483
 ppcentral = 2.1483
 ppartmass = 0.000511
 hpartmass = 0.000511
-
diff --git a/PARAM/GEN/gbeam.param b/PARAM/GEN/gbeam.param
index 76c3fcf6..05e2e28a 100644
--- a/PARAM/GEN/gbeam.param
+++ b/PARAM/GEN/gbeam.param
@@ -10,32 +10,21 @@
 ;  gbeam_yp = +0.00
 
 ; Add new variables for Hall C BPM A, B, and C, based on HARP calibration
-; Updated  by Dave Gaskell
+; Updated  by Mark Jones , Fit to Dec 8 2019 harp versus bpm scan
+;
+  gbpmxa_slope =  0.97
+  gbpmxa_off   = -0.07
+  gbpmxb_slope =  1.09
+  gbpmxb_off   = -0.19
+  gbpmxc_slope =  0.96
+  gbpmxc_off   =  1.1
+  gbpmya_slope = 0.95
+  gbpmya_off   = -0.9
+  gbpmyb_slope = 1.16
+  gbpmyb_off   = -0.31
+  gbpmyc_slope = 0.85
+  gbpmyc_off   =  -0.81
 ;
-  gbpmxa_slope = -0.98
-  gbpmxa_off   = +0.21
-  gbpmxa_off   = -0.05+0.32
-  gbpmxa_off   = 0.28 
-  gbpmxb_slope = -1.12
-  gbpmxb_off   = +0.08+0.12
-  gbpmxb_off   = +0.08+0.38
-  gbpmxb_off   = 0.47
-  gbpmxc_slope = -0.96
-  gbpmxc_off   = -0.89-0.29
-  gbpmxc_off   = -0.89+.09
-  gbpmxc_off   = -0.63
-  gbpmya_slope = 0.97
-  gbpmya_off   = -0.20+0.36
-  gbpmya_off   = -0.20+0.38
-  gbpmya_off   = -0.09
-  gbpmyb_slope = 1.17
-  gbpmyb_off   = 0.38+0.36
-  gbpmyb_off   = 0.38-.13
-  gbpmyb_off   = 0.02
-  gbpmyc_slope = 0.87
-  gbpmyc_off   = 0.47+0.31
-  gbpmyc_off   = 0.47-.76
-  gbpmyc_off   = -0.13
 
 ;positions of BPMs relative to target (from Fall 2018 survey)
 gbpma_zpos = 320.17 ; cm
@@ -57,10 +46,11 @@ gfrxa_adc_zero_offset = 64310
 gfrxb_adc_zero_offset = 67210
 gfrya_adc_zero_offset = 67500
 gfryb_adc_zero_offset = 61840
-gfrxa_adcpercm = 96000
-gfrxb_adcpercm = 97086
-gfrya_adcpercm = 88300
-gfryb_adcpercm = 84800
+; for 1-pass running need factor of 2 since only one coil is used
+gfrxa_adcpercm = 96000*2
+gfrxb_adcpercm = 97086*2
+gfrya_adcpercm = 88300*2
+gfryb_adcpercm = 84800*2
 
  
  
diff --git a/PARAM/TRIG/thms.param b/PARAM/TRIG/thms.param
index 3ead4460..869ad0d2 100644
--- a/PARAM/TRIG/thms.param
+++ b/PARAM/TRIG/thms.param
@@ -21,16 +21,16 @@ t_hms_adcNames = "hASUM hBSUM hCSUM hDSUM hPSHWR hSHWR hAER hCER hFADC_TREF_ROC1
 ; bar num:         1   2   3   4   5   6   7    8     9     10    11   12    13    14    15    16  17    18      19      20      21      22      23     24     25     26     27     28     29     30     31     32     33     34     35      36     37      38      39      40        41      42     43       44       45       46    47    48      49      50     51      52      53     54       55   56     57
 t_hms_tdcNames = "h1X h1Y h2X h2Y h1T h2T hT1 hASUM hBSUM hCSUM hDSUM hPRLO hPRHI hSHWR hEDTM hCER hT2 hDCREF1 hDCREF2 hDCREF3 hDCREF4 hDCREF5 hTRIG1 hTRIG2 hTRIG3 hTRIG4 hTRIG5 hTRIG6 pTRIG1 pTRIG2 pTRIG3 pTRIG4 pTRIG5 pTRIG6 pSTOF pEL_LO_LO pEL_LO pEL_HI pEL_REAL pEL_CLEAN hSTOF hEL_LO_LO hEL_LO hEL_HI hEL_REAL hEL_CLEAN  hT3 pPRE40 pPRE100 pPRE150 pPRE200 hPRE40 hPRE100 hPRE150 hPRE200 hRF hHODO_RF"
 
-t_hms_TdcTimeWindowMin =     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-			     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-			     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-			     0,	   0, 	 0,    0,    0,    0, 	 0,    0,    0,    0,
-			     0,    0, 	 0,    0,    0,    0, 	 0,    0,    0,	   0,
-			     0,    0, 	 0,    0,    0,    0, 	 0
+t_hms_TdcTimeWindowMin =     900,    900,   1000,   1000,      0,      0,      0,      0,      0,      0,
+			       0,      0,      0,      0,      0,      0,      0,  21200,  21100,  21050,
+			   21150,  21300,      0,      0,      0,      0,      0,      0,      0,      0,
+			       0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+			       0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+			       0,      0,      0,      0,      0,      0,      0
 			 
-t_hms_TdcTimeWindowMax =  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
-			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
-			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
+t_hms_TdcTimeWindowMax =    1500,   1500,   1600,   1600, 100000, 100000, 100000, 100000, 100000, 100000,
+			  100000, 100000, 100000, 100000, 100000, 100000, 100000,  21600,  21500,  21450,
+			   21550,  21700, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
 			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
 			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
 			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000
diff --git a/PARAM/TRIG/tshms.param b/PARAM/TRIG/tshms.param
index 50911dbc..3c72afc1 100644
--- a/PARAM/TRIG/tshms.param
+++ b/PARAM/TRIG/tshms.param
@@ -23,16 +23,16 @@ t_shms_adcNames = "pAER pHGCER pNGCER pPSHWR pFADC_TREF_ROC2 pHGCER_MOD pNGCER_M
 ; BAR NUM:          1   2   3   4   5   6   7   8   9   10    11     12     13      14      15      16      17      18      19      20      21       22     23    24     25      26     27      28     29     30    31     32     33     34     35     36     37    38       39      40     41      42        43     44       45      46     47     48        49       50     51      52      53      54     55      56      57    58
 t_shms_tdcNames = "pT1 pT2 p1X p1Y p2X p2Y p1T p2T pT3 pAER pHGCER pNGCER pDCREF1 pDCREF2 pDCREF3 pDCREF4 pDCREF5 pDCREF6 pDCREF7 pDCREF8 pDCREF9 pDCREF10 pEDTM pPRLO  pPRHI  pTRIG1 pTRIG2 pTRIG3 pTRIG4 pTRIG5 pTRIG6 hTRIG1 hTRIG2 hTRIG3 hTRIG4 hTRIG5 hTRIG6 pSTOF pEL_LO_LO pEL_LO pEL_HI pEL_REAL pEL_CLEAN hSTOF hEL_LO_LO hEL_LO hEL_HI hEL_REAL hEL_CLEAN pPRE40 pPRE100 pPRE150 pPRE200 hPRE40 hPRE100 hPRE150 hPRE200 pRF" 
 
-t_shms_TdcTimeWindowMin =    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-			     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-			     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-			     0,	   0, 	 0,    0,    0,    0, 	 0,    0,    0,    0,
-			     0,    0, 	 0,    0,    0,    0, 	 0,    0,    0,	   0,
-			     0,    0, 	 0,    0,    0,    0, 	 0,    0,    0
+t_shms_TdcTimeWindowMin =      0,      0,  3000,    3000,   3100,   3100,      0,      0,      0,      0,
+			       0,      0, 15250,   15275,  15300,  15325,  15375,  15400,  15425,  15400,
+			   15350,  15450,     0,       0,      0,      0,      0,      0,      0,      0,
+			       0,      0,     0,       0,      0,      0,      0,      0,      0,      0,
+			       0,      0,     0,       0,      0,      0,      0,      0,      0,      0,
+			       0,      0,     0,       0,      0,      0,      0,      0
 			 
-t_shms_TdcTimeWindowMax = 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
+t_shms_TdcTimeWindowMax = 100000, 100000,   4000,   4000,   4100,   4100, 100000, 100000, 100000, 100000,
+			  100000, 100000,  15650,  15675,  15700,  15725,  15775,  15800,  15825,  15800,
+			   15750,  15850, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
 			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
 			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
-			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
-			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000,
-			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000
+			  100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000
diff --git a/onlineGUI/CONFIG/SHMS/PRODUCTION/shms_production.cfg b/onlineGUI/CONFIG/SHMS/PRODUCTION/shms_production.cfg
index bd83a9af..36a7f085 100644
--- a/onlineGUI/CONFIG/SHMS/PRODUCTION/shms_production.cfg
+++ b/onlineGUI/CONFIG/SHMS/PRODUCTION/shms_production.cfg
@@ -340,3 +340,14 @@ title SHMS Helicity
 ptrig_heli -nostat
 ptrig_heli_rep -nostat
 ptrig_heli_pred -nostat
+
+newpage 4 2
+title BCM Monitoring
+macro 'UTIL/BEAMLINE/bcm_mon.C("hrbcm12")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hrbcm4a4b")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hrbcm4a4c")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hrbcm4b4c")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hdbcm12")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hdbcm4a4b")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hdbcm4a4c")'
+macro 'UTIL/BEAMLINE/bcm_mon.C("hdbcm4b4c")'
diff --git a/onlineGUI/UTIL/BEAMLINE/bcm_mon.C b/onlineGUI/UTIL/BEAMLINE/bcm_mon.C
new file mode 100644
index 00000000..5bacf8ca
--- /dev/null
+++ b/onlineGUI/UTIL/BEAMLINE/bcm_mon.C
@@ -0,0 +1,64 @@
+
+void UserScript()
+{
+
+  TTree *TSP = (TTree*) gDirectory->Get("TSP");
+  UInt_t ne = TSP->GetEntries();
+
+  Double_t ibcm1, ibcm2, ibcm4a, ibcm4b, ibcm4c;
+  TSP->SetBranchAddress("P.BCM1.scalerCurrent",  &ibcm1);
+  TSP->SetBranchAddress("P.BCM2.scalerCurrent",  &ibcm2);
+  TSP->SetBranchAddress("P.BCM4A.scalerCurrent", &ibcm4a);
+  TSP->SetBranchAddress("P.BCM4B.scalerCurrent", &ibcm4b);
+  TSP->SetBranchAddress("P.BCM4C.scalerCurrent", &ibcm4c);
+
+  TH1F *hrbcm12   = new TH1F("hrbcm12",   "BCM 1 & 2 Ratio;   BCM1 / BCM2;   Number of Entries", 100, 0.5, 1.5);
+  TH1F *hrbcm4a4b = new TH1F("hrbcm4a4b", "BCM 4A & 4B Ratio; BCM4A / BCM4B; Number of Entries", 100, 0.5, 1.5);
+  TH1F *hrbcm4a4c = new TH1F("hrbcm4a4c", "BCM 4A & 4C Ratio; BCM4A / BCM4C; Number of Entries", 500, 0.0, 5.0);
+  TH1F *hrbcm4b4c = new TH1F("hrbcm4b4c", "BCM 4B & 4C Ratio; BCM4B / BCM4C; Number of Entries", 500, 0.0, 5.0);
+
+  TH1F *hdbcm12   = new TH1F("hdbcm12",   "BCM 1 & 2 Difference;   BCM1 - BCM2 (uA);   Number of Entries", 100, -0.5, 0.5);
+  TH1F *hdbcm4a4b = new TH1F("hdbcm4a4b", "BCM 4A & 4B Difference; BCM4A - BCM4B (uA); Number of Entries", 100, -0.5, 0.5);
+  TH1F *hdbcm4a4c = new TH1F("hdbcm4a4c", "BCM 4A & 4C Difference; BCM4A - BCM4C (uA); Number of Entries", 500, -25.0, 25.0);
+  TH1F *hdbcm4b4c = new TH1F("hdbcm4b4c", "BCM 4B & 4C Difference; BCM4B - BCM4C (uA); Number of Entries", 500, -25.0, 25.0);
+
+  for (UInt_t iev = 0; iev < ne; iev++) {
+    TSP->GetEntry(iev);
+    if (ibcm1 > 0.0 && ibcm2 > 0.0) {
+      hrbcm12->Fill(ibcm1/ibcm2);
+      hdbcm12->Fill(abs(ibcm1-ibcm2));
+    }
+    if (ibcm4a > 0.0 && ibcm4b > 0.0) {
+      hrbcm4a4b->Fill(ibcm4a/ibcm4b);
+      hdbcm4a4b->Fill(abs(ibcm4a-ibcm4b));
+    }
+    if (ibcm4a > 0.0 && ibcm4c > 0.0) {
+      hrbcm4a4c->Fill(ibcm4a/ibcm4c);
+      hdbcm4a4c->Fill(abs(ibcm4a-ibcm4c));
+    }
+    if (ibcm4b > 0.0 && ibcm4c > 0.0) {
+      hrbcm4b4c->Fill(ibcm4b/ibcm4c);
+      hdbcm4b4c->Fill(abs(ibcm4b-ibcm4c));
+    }
+  }
+
+}
+
+void bcm_mon(TString histname) {
+
+  TH1F* h1d;
+  h1d = (TH1F*) gDirectory->Get(histname);
+  if (!h1d) {
+    UserScript();
+    h1d = (TH1F*) gDirectory->Get(histname);
+    if (!h1d) {
+      cout << "User histogram " << histname << " not found" << endl;
+      exit(1);
+    }
+  }
+  if (h1d) {
+    h1d->SetStats(0);
+    h1d->Draw();
+  }
+
+}
-- 
GitLab