From 43823db72aae92a94d278aca5f72582ea3a67082 Mon Sep 17 00:00:00 2001
From: Mark Jones <jones@jlab.org>
Date: Sat, 2 Dec 2017 07:31:10 -0500
Subject: [PATCH] Modify Def-file for raster_simple and add epics bpm to
 onlinegui

Add more epics BPM quantities to raster_simple Def-files
    for HMS and SHMS

Add config and macro file for looking at epics bpm quantities
---
 DEF-files/HMS/RASTER/hms_raster_simple.def   | 26 ++++---
 DEF-files/SHMS/RASTER/shms_raster_simple.def | 12 ++++
 onlineGUI/CONFIG/BEAMLINE/epics_bpm.cfg      | 17 +++++
 onlineGUI/UTIL/BEAMLINE/epics_beam_histos.C  | 73 ++++++++++++++++++++
 4 files changed, 118 insertions(+), 10 deletions(-)
 create mode 100644 onlineGUI/CONFIG/BEAMLINE/epics_bpm.cfg
 create mode 100644 onlineGUI/UTIL/BEAMLINE/epics_beam_histos.C

diff --git a/DEF-files/HMS/RASTER/hms_raster_simple.def b/DEF-files/HMS/RASTER/hms_raster_simple.def
index 631e523b..b71cd523 100644
--- a/DEF-files/HMS/RASTER/hms_raster_simple.def
+++ b/DEF-files/HMS/RASTER/hms_raster_simple.def
@@ -10,16 +10,16 @@ formula FRXB_V H.rb.raster.frxbRawAdc*(1./4096.)/25.
 formula FRYA_V H.rb.raster.fryaRawAdc*(1./4096.)/25.
 formula FRYB_V H.rb.raster.frybRawAdc*(1./4096.)/25.
 
-TH1F hFRXA 'HMS FRXA; FRXA RAW ADC (chan); Counts' H.rb.raster.frxaRawAdc 1000 0 100000
-TH1F hFRXA_V 'HMS FRXA; FRXA RAW ADC (Volts); Counts' FRXA_V 1000 0 1.0
-TH1F hFRXB 'HMS FRXB; FRXB RAW ADC (chan); Counts' H.rb.raster.frxbRawAdc 1000 0 100000
-TH1F hFRXB_V 'HMS FRXB; FRXB RAW ADC (Volts); Counts' FRXB_V 1000 0 1.0
-TH1F hFRYA 'HMS FRYA; FRYA RAW ADC (chan); Counts' H.rb.raster.fryaRawAdc 1000 0 100000
-TH1F hFRYA_V 'HMS FRYA; FRYA RAW ADC (Volts); Counts' FRYA_V 1000 0 1.0
-TH1F hFRYB 'HMS FRYB; FRYB RAW ADC (chan); Counts' H.rb.raster.frybRawAdc 1000 0 100000
-TH1F hFRYB_V 'HMS FRYB; FRYB RAW ADC (Volts); Counts' FRYB_V 1000 0 1.0
-TH2F hFRA_XvsY 'HMS 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 hFRB_XvsY 'HMS FRB X vs Y; FRXB RAW ADC (Volts); FRYB RAW ADC (Volts)' FRXB_V FRYB_V 1000 0 1.0 1000 0 1.0
+TH1F pFRXA 'SHMS FRXA; FRXA RAW ADC (chan); Counts' H.rb.raster.frxaRawAdc 1000 0 100000
+TH1F pFRXA_V 'SHMS FRXA; FRXA RAW ADC (Volts); Counts' FRXA_V 1000 0 1.0
+TH1F pFRXB 'SHMS FRXB; FRXB RAW ADC (chan); Counts' H.rb.raster.frxbRawAdc 1000 0 100000
+TH1F pFRXB_V 'SHMS FRXB; FRXB RAW ADC (Volts); Counts' FRXB_V 1000 0 1.0
+TH1F pFRYA 'SHMS FRYA; FRYA RAW ADC (chan); Counts' H.rb.raster.fryaRawAdc 1000 0 100000
+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' H.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 '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
 #******************
 # EPICS VARIABLES *
 #******************
@@ -45,6 +45,12 @@ IPM3H07B.XRAW
 IPM3H07B.YRAW
 IPM3H07C.XRAW
 IPM3H07C.YRAW
+IPM3H07A.XSOF
+IPM3H07A.YSOF
+IPM3H07B.XSOF
+IPM3H07B.YSOF
+IPM3H07C.XSOF
+IPM3H07C.YSOF
 
 
 end epics
diff --git a/DEF-files/SHMS/RASTER/shms_raster_simple.def b/DEF-files/SHMS/RASTER/shms_raster_simple.def
index b720e8f6..99eb5eba 100644
--- a/DEF-files/SHMS/RASTER/shms_raster_simple.def
+++ b/DEF-files/SHMS/RASTER/shms_raster_simple.def
@@ -39,6 +39,18 @@ IPM3H07B.XPOS
 IPM3H07B.YPOS
 IPM3H07C.XPOS
 IPM3H07C.YPOS
+IPM3H07A.XRAW
+IPM3H07A.YRAW
+IPM3H07B.XRAW
+IPM3H07B.YRAW
+IPM3H07C.XRAW
+IPM3H07C.YRAW
+IPM3H07A.XSOF
+IPM3H07A.YSOF
+IPM3H07B.XSOF
+IPM3H07B.YSOF
+IPM3H07C.XSOF
+IPM3H07C.YSOF
 
 
 end epics
\ No newline at end of file
diff --git a/onlineGUI/CONFIG/BEAMLINE/epics_bpm.cfg b/onlineGUI/CONFIG/BEAMLINE/epics_bpm.cfg
new file mode 100644
index 00000000..1faaa041
--- /dev/null
+++ b/onlineGUI/CONFIG/BEAMLINE/epics_bpm.cfg
@@ -0,0 +1,17 @@
+protorootfile ../ROOTfiles/hms_raster_simple_XXXXX_10000.root
+guicolor orange
+canvassize 700 700
+newpage 4 3
+title EPICS BPM 
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07AXRAW")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07AYRAW")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07BXRAW")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07BYRAW")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07AXSOF")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07AYSOF")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07BXSOF")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07BYSOF")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07AXPOS")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07AYPOS")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07BXPOS")
+macro UTIL/BEAMLINE/epics_beam_histos.C("uhIPM3H07BYPOS")
diff --git a/onlineGUI/UTIL/BEAMLINE/epics_beam_histos.C b/onlineGUI/UTIL/BEAMLINE/epics_beam_histos.C
new file mode 100644
index 00000000..c33a2216
--- /dev/null
+++ b/onlineGUI/UTIL/BEAMLINE/epics_beam_histos.C
@@ -0,0 +1,73 @@
+void UserScript()
+{
+  const UInt_t NBPMS  = 3;
+  const TString bpm_names[NBPMS]={"IPM3H07A","IPM3H07B","IPM3H07C"};
+  const UInt_t NBPMS_POS  = 2;
+  const TString bpm_pos[NBPMS_POS]={"X","Y"};
+  const UInt_t NBPMS_TYPES  = 3;
+  const TString bpm_type[NBPMS_TYPES]={"RAW","SOF","POS"};
+  TH1F* hbpm[NBPMS*NBPMS_POS*NBPMS_TYPES];
+  Double_t bpm[NBPMS*NBPMS_POS*NBPMS_TYPES];
+  
+  //
+  TTree *T=(TTree*)gDirectory->Get("E");
+  Int_t totev=T->GetEntries();
+  //
+  TString h2dttitle;TString h2dtname;TString list_name;
+  Int_t icnt=0;
+  for(UInt_t ip = 0; ip < NBPMS; ip++) {
+  for(UInt_t is = 0; is < NBPMS_POS; is++) {
+  for(UInt_t it = 0; it < NBPMS_TYPES; it++) {
+     h2dttitle= ";"+bpm_names[ip]+bpm_pos[is]+" "+bpm_type[it]+" (mm)  ;  Events ";
+    h2dtname="uh"+bpm_names[ip]+bpm_pos[is]+bpm_type[it];
+    hbpm[icnt]= new TH1F(h2dtname,h2dttitle,100,-10,10);
+    list_name =bpm_names[ip]+"."+bpm_pos[is]+bpm_type[it];
+    T->SetBranchAddress(list_name,&bpm[icnt]);
+    icnt++;
+  }
+  }
+  }
+  // Loop over the events, filling the histograms
+  //  cout << " looping over data " << endl;
+  for(UInt_t iev = 0; iev < totev; iev++) {
+    //    cout << " iev = " << iev << endl;
+    //       cout << " get entry = " << iev << endl;
+    T->GetEntry(iev);
+     for(UInt_t ip = 0; ip < NBPMS*NBPMS_POS*NBPMS_TYPES; ip++) {
+       hbpm[ip]->Fill(bpm[ip]);
+     }
+    //
+  }
+}
+void epics_beam_histos(TString histname) {
+  TH1F* h1d;
+  TH2F* h2d;
+  h1d = (TH1F*) gDirectory->Get(histname);
+  h2d = (TH2F*) gDirectory->Get(histname);
+ if(!h1d && !h2d) {
+    UserScript();
+    h1d = (TH1F*) gDirectory->Get(histname);
+    h2d = (TH2F*) gDirectory->Get(histname);
+    if(!h1d || !h2d) {
+      cout << "User histogram " << histname << " not found" << endl;
+      exit(1);
+    }
+  }
+  if (h2d) {
+  h2d->SetStats(0);
+  h2d->Draw("colz");
+    h2d->GetXaxis()->SetTitleOffset(.6);
+    h2d->GetXaxis()->SetTitleSize(0.08);
+    h2d->GetYaxis()->SetTitleOffset(.6);
+    h2d->GetYaxis()->SetTitleSize(0.08);
+      }
+  else {
+    cout << "1d  drawing   " << histname << endl;
+  h1d->SetStats(0);
+  h1d->Draw();
+    h1d->GetXaxis()->SetTitleOffset(.6);
+    h1d->GetXaxis()->SetTitleSize(0.08);
+    h1d->GetYaxis()->SetTitleOffset(.6);
+    h1d->GetYaxis()->SetTitleSize(0.08);
+  }
+}
-- 
GitLab