From 99ac6219510c3dcddd41fae0af51cff03d253c12 Mon Sep 17 00:00:00 2001
From: Holly Szumila <hszumila@jlab.org>
Date: Fri, 13 Oct 2017 17:11:25 -0400
Subject: [PATCH] geometry for shms  (#217)

* added files used for shms dc alignment

* moved some dc alignment files around

* removed script in production

* updated shms geo param

* updated plots for shms dc monitoring
---
 PARAM/SHMS/DC/GEOM/pdc_geom.param      |  19 +-
 onlineGUI/Config/SHMS/DC/pdc_stand.cfg | 245 +++++++++++--------------
 onlineGUI/Macros/EXAMPLES/overlay2.C   |  92 ++++++++++
 3 files changed, 213 insertions(+), 143 deletions(-)
 create mode 100755 onlineGUI/Macros/EXAMPLES/overlay2.C

diff --git a/PARAM/SHMS/DC/GEOM/pdc_geom.param b/PARAM/SHMS/DC/GEOM/pdc_geom.param
index b76ef299..9c9467c8 100644
--- a/PARAM/SHMS/DC/GEOM/pdc_geom.param
+++ b/PARAM/SHMS/DC/GEOM/pdc_geom.param
@@ -26,22 +26,24 @@ pdc_sigma = 0.02, 0.02, 0.02, 0.02, 0.02, 0.02  ; TODO - SOS values for now
             0.02, 0.02, 0.02, 0.02, 0.02, 0.02
 
 ; Wire velocity corrections.
-pdc_wire_velocity  = 12.0;
-pdc_central_time   = 0, 0, 0, 0, 0, 0  ; TODO - no correction for now
+pdc_wire_velocity  = 12.0; -this should be checked (old HMS value for now)
+pdc_central_time   = 0, 0, 0, 0, 0, 0  ; -not used in new SHMS chambers
                      0, 0, 0, 0, 0, 0
-pdc_drifttime_sign = 0, 0, 0, 0, 0, 0  ; TODO - no correction for now
+pdc_drifttime_sign = 0, 0, 0, 0, 0, 0  ; -not used in new SHMS chambers
                      0, 0, 0, 0, 0, 0
-;pdc_readoutLR = -1.0, 1.0, -1.0, -1.0, 1.0, -1.0
-;                 1.0, -1.0, 1.0, 1.0, -1.0, 1.0
-;pdc_readoutTB = 1.0, -1.0, 1.0, -1.0, 1.0, -1.0
-;                -1.0, 1.0, -1.0, 1.0, -1.0, 1.0             
+
+pdc_readoutLR = -1.0, 1.0, -1.0, -1.0, 1.0, -1.0
+                 1.0, -1.0, 1.0, 1.0, -1.0, 1.0
+pdc_readoutTB = 1.0, -1.0, 1.0, -1.0, 1.0, -1.0
+                -1.0, 1.0, -1.0, 1.0, -1.0, 1.0             
 
 ; CHAMBER POSITION PARAMETERS
 
 ; x, y and z position of center for each wire chamber in cm.
 ; From survey C1771.
 pdc_xcenter = -0.036, 0.008 ;
-pdc_ycenter =  0.019, 0.013 ;
+pdc_ycenter = 0.019, 0.013 ;
+
 pdc_1_zpos = -40 - 0.656 ;
 pdc_2_zpos =  40 - 0.668 ;
 
@@ -99,7 +101,6 @@ pdc_ypos = pdc_ycenter[0]-0.007
            pdc_ycenter[1]+0.0035
            pdc_ycenter[1]-0.006
 
-
 ; z position in cm of each plane measured from focal plane.
 ; From technical drawings.
 pdc_zpos = pdc_1_zpos - 0.68701*cminch
diff --git a/onlineGUI/Config/SHMS/DC/pdc_stand.cfg b/onlineGUI/Config/SHMS/DC/pdc_stand.cfg
index a73bc5bd..d67ebc6f 100644
--- a/onlineGUI/Config/SHMS/DC/pdc_stand.cfg
+++ b/onlineGUI/Config/SHMS/DC/pdc_stand.cfg
@@ -1,138 +1,115 @@
-protorootfile ../ROOTfiles/pdc_replay_XXXXX.root
+protorootfile ../ROOTfiles/shms_replay_production_XXXXX_1000000.root
 guicolor orange
-canvassize 1600 800
-#canvassize 800 800
-newpage 6 2
-title SHMS DC Wire Map
-pdc1u1_wirenum -nostat
-pdc1u2_wirenum -nostat
-pdc1x1_wirenum -nostat
-pdc1x2_wirenum -nostat
-pdc1v1_wirenum -nostat
-pdc1v2_wirenum -nostat
-pdc2v2_wirenum -nostat
-pdc2v1_wirenum -nostat
-pdc2x2_wirenum -nostat
-pdc2x1_wirenum -nostat
-pdc2u2_wirenum -nostat
-pdc2u1_wirenum -nostat
-newpage 6 2 
-title SHMS DC Plane Raw TDC 
-pdc1u1_raw_tdc -nostat
-pdc1u2_raw_tdc -nostat
-pdc1x1_raw_tdc -nostat
-pdc1x2_raw_tdc -nostat
-pdc1v1_raw_tdc -nostat
-pdc1v2_raw_tdc -nostat
-pdc2v2_raw_tdc -nostat
-pdc2v1_raw_tdc -nostat
-pdc2x2_raw_tdc -nostat
-pdc2x1_raw_tdc -nostat
-pdc2u2_raw_tdc -nostat
-pdc2u1_raw_tdc -nostat
+canvassize 1200 1000
 
-newpage 6 2 logz
-title SHMS DC Raw TDC vs. Wire Number
-pdc1u1_raw_tdc_vs_wirenum -nostat
-pdc1u2_raw_tdc_vs_wirenum -nostat
-pdc1x1_raw_tdc_vs_wirenum -nostat
-pdc1x2_raw_tdc_vs_wirenum -nostat
-pdc1v1_raw_tdc_vs_wirenum -nostat
-pdc1v2_raw_tdc_vs_wirenum -nostat
-pdc2v2_raw_tdc_vs_wirenum -nostat
-pdc2v1_raw_tdc_vs_wirenum -nostat
-pdc2x2_raw_tdc_vs_wirenum -nostat
-pdc2x1_raw_tdc_vs_wirenum -nostat
-pdc2u2_raw_tdc_vs_wirenum -nostat
-pdc2u1_raw_tdc_vs_wirenum -nostat
-newpage 6 2 
-title SHMS DC Plane Drift Time 
-pdc1u1_drifttime -nostat
-pdc1u2_drifttime -nostat
-pdc1x1_drifttime -nostat
-pdc1x2_drifttime -nostat
-pdc1v1_drifttime -nostat
-pdc1v2_drifttime -nostat
-pdc2v2_drifttime -nostat
-pdc2v1_drifttime -nostat
-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
-pdc1u2_drifttime_vs_wirenum -nostat
-pdc1x1_drifttime_vs_wirenum -nostat
-pdc1x2_drifttime_vs_wirenum -nostat
-pdc1v1_drifttime_vs_wirenum -nostat
-pdc1v2_drifttime_vs_wirenum -nostat
-pdc2v2_drifttime_vs_wirenum -nostat
-pdc2v1_drifttime_vs_wirenum -nostat
-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
-pdc1u2_ddist -nostat
-pdc1x1_ddist -nostat
-pdc1x2_ddist -nostat
-pdc1v1_ddist -nostat
-pdc1v2_ddist -nostat
-pdc2v2_ddist -nostat
-pdc2v1_ddist -nostat
-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
-pdc1u2_wirenum_vs_ddist -nostat
-pdc1x1_wirenum_vs_ddist -nostat
-pdc1x2_wirenum_vs_ddist -nostat
-pdc1v1_wirenum_vs_ddist -nostat
-pdc1v2_wirenum_vs_ddist -nostat
-pdc2v2_wirenum_vs_ddist -nostat
-pdc2v1_wirenum_vs_ddist -nostat
-pdc2x2_wirenum_vs_ddist -nostat
-pdc2x1_wirenum_vs_ddist -nostat
-pdc2u2_wirenum_vs_ddist -nostat
-pdc2u1_wirenum_vs_ddist -nostat
+newpage 2 3
+title SHMS DC raw TDC
+macro    Macros/EXAMPLES/overlay2.C("pdc1u1_raw_tdc","pdc2v1_raw_tdc","1U1","2V1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1u2_raw_tdc","pdc2v2_raw_tdc","1U2","2V2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x1_raw_tdc","pdc2x1_raw_tdc","1X1","2X1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x2_raw_tdc","pdc2x2_raw_tdc","1X2","2X2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v1_raw_tdc","pdc2u1_raw_tdc","1V1","2U1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v2_raw_tdc","pdc2u2_raw_tdc","1V2","2U2")
 
-newpage 6 2 
-title SHMS DC Plane Residuals 
-pdc1u1_residuals -nostat
-pdc1u2_residuals -nostat
-pdc1x1_residuals -nostat
-pdc1x2_residuals -nostat
-pdc1v1_residuals -nostat
-pdc1v2_residuals -nostat
-pdc2v2_residuals -nostat
-pdc2v1_residuals -nostat
-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
-pdc1u2_residuals_vs_wirenum -nostat
-pdc1x1_residuals_vs_wirenum -nostat
-pdc1x2_residuals_vs_wirenum -nostat
-pdc1v1_residuals_vs_wirenum -nostat
-pdc1v2_residuals_vs_wirenum -nostat
-pdc2v2_residuals_vs_wirenum -nostat
-pdc2v1_residuals_vs_wirenum -nostat
-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 X vs. Y at F.P.
+newpage 3 4 logz
+title SHMS DC raw TDC vs wire
+pdc1u1_raw_tdc_vs_wirenum -colz
+pdc1u2_raw_tdc_vs_wirenum -colz
+pdc1x1_raw_tdc_vs_wirenum -colz
+pdc1x2_raw_tdc_vs_wirenum -colz
+pdc1v1_raw_tdc_vs_wirenum -colz
+pdc1v2_raw_tdc_vs_wirenum -colz
+pdc2v2_raw_tdc_vs_wirenum -colz
+pdc2v1_raw_tdc_vs_wirenum -colz
+pdc2x2_raw_tdc_vs_wirenum -colz
+pdc2x1_raw_tdc_vs_wirenum -colz
+pdc2u2_raw_tdc_vs_wirenum -colz
+pdc2u1_raw_tdc_vs_wirenum -colz
+
+newpage 2 3
+title SHMS DC wire hits
+macro    Macros/EXAMPLES/overlay2.C("pdc1u1_wirenum","pdc2v1_wirenum","1U1","2V1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1u2_wirenum","pdc2v2_wirenum","1U2","2V2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x1_wirenum","pdc2x1_wirenum","1X1","2X1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x2_wirenum","pdc2x2_wirenum","1X2","2X2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v1_wirenum","pdc2u1_wirenum","1V1","2U1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v2_wirenum","pdc2u2_wirenum","1V2","2U2")
+
+newpage 2 3
+title SHMS DC drift distance
+macro    Macros/EXAMPLES/overlay2.C("pdc1u1_ddist","pdc2v1_ddist","1U1","2V1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1u2_ddist","pdc2v2_ddist","1U2","2V2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x1_ddist","pdc2x1_ddist","1X1","2X1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x2_ddist","pdc2x2_ddist","1X2","2X2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v1_ddist","pdc2u1_ddist","1V1","2U1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v2_ddist","pdc2u2_ddist","1V2","2U2")
+
+newpage 3 4 logz
+title SHMS DC drift dist vs wire
+pdc1u1_wirenum_vs_ddist -colz
+pdc1u2_wirenum_vs_ddist -colz
+pdc1x1_wirenum_vs_ddist -colz
+pdc1x2_wirenum_vs_ddist -colz
+pdc1v1_wirenum_vs_ddist -colz
+pdc1v2_wirenum_vs_ddist -colz
+pdc2v2_wirenum_vs_ddist -colz
+pdc2v1_wirenum_vs_ddist -colz
+pdc2x2_wirenum_vs_ddist -colz
+pdc2x1_wirenum_vs_ddist -colz
+pdc2u2_wirenum_vs_ddist -colz
+pdc2u1_wirenum_vs_ddist -colz
+
+newpage 2 3
+title SHMS DC drift time
+macro    Macros/EXAMPLES/overlay2.C("pdc1u1_drifttime","pdc2v1_drifttime","1U1","2V1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1u2_drifttime","pdc2v1_drifttime","1U2","2V2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x1_drifttime","pdc2x1_drifttime","1X1","2X1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x2_drifttime","pdc2x2_drifttime","1X2","2X2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v1_drifttime","pdc2u1_drifttime","1V1","2U1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v2_drifttime","pdc2u2_drifttime","1V2","2U2")
+
+newpage 3 4 logz
+title SHMS DC drift time vs wire
+pdc1u1_drifttime_vs_wirenum -colz
+pdc1u2_drifttime_vs_wirenum -colz
+pdc1x1_drifttime_vs_wirenum -colz
+pdc1x2_drifttime_vs_wirenum -colz
+pdc1v1_drifttime_vs_wirenum -colz
+pdc1v2_drifttime_vs_wirenum -colz
+pdc2v2_drifttime_vs_wirenum -colz
+pdc2v1_drifttime_vs_wirenum -colz
+pdc2x2_drifttime_vs_wirenum -colz
+pdc2x1_drifttime_vs_wirenum -colz
+pdc2u2_drifttime_vs_wirenum -colz
+pdc2u1_drifttime_vs_wirenum -colz
+
+newpage 2 3
+title SHMS DC residuals
+macro    Macros/EXAMPLES/overlay2.C("pdc1u1_residuals","pdc2v1_residuals","1U1","2V1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1u2_residuals","pdc2v2_residuals","1U2","2V2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x1_residuals","pdc2x1_residuals","1X1","2X1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1x2_residuals","pdc2x2_residuals","1X2","2X2")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v1_residuals","pdc2u1_residuals","1V1","2U1")
+macro    Macros/EXAMPLES/overlay2.C("pdc1v2_residuals","pdc2u2_residuals","1V2","2U2")
+
+newpage 3 4 logz
+title SHMS DC residuals vs wire 
+pdc1u1_residuals_vs_wirenum -colz
+pdc1u2_residuals_vs_wirenum -colz
+pdc1x1_residuals_vs_wirenum -colz
+pdc1x2_residuals_vs_wirenum -colz
+pdc1v1_residuals_vs_wirenum -colz
+pdc1v2_residuals_vs_wirenum -colz
+pdc2v2_residuals_vs_wirenum -colz
+pdc2v1_residuals_vs_wirenum -colz
+pdc2x2_residuals_vs_wirenum -colz
+pdc2x1_residuals_vs_wirenum -colz
+pdc2u2_residuals_vs_wirenum -colz
+pdc2u1_residuals_vs_wirenum -colz
+
+newpage 2 2 
+title SHMS DC track at focal plane
 pdc_xfp_vs_yxp -nostat
-newpage 1 1 logz
-title Xp vs. Yp at F.P
-pdc_xfpp_vs_yfpp -nostat
+pdc_xpfp_vs_ypfp -nostat
+pdc_xfp_vs_ypfp -nostat
+pdc_xfp_vs_xpfp -nostat
\ No newline at end of file
diff --git a/onlineGUI/Macros/EXAMPLES/overlay2.C b/onlineGUI/Macros/EXAMPLES/overlay2.C
new file mode 100755
index 00000000..cd6222fc
--- /dev/null
+++ b/onlineGUI/Macros/EXAMPLES/overlay2.C
@@ -0,0 +1,92 @@
+/*******************************
+ * This macro overlays two histograms.
+ * The label1 and label2 are optional
+ * and can be used to label the
+ * different histograms as they are 
+ * drawn.
+ *
+ * hszumila@jlab.org
+ *******************************/
+
+void overlay2(TString hist1name, TString hist2name, TString label1="", TString label2="", Bool_t golden=false,TString samestr=""){
+  TH1F* H1;
+  TH1F* H2;
+  
+  H1 = (TH1F*) gDirectory->Get(hist1name);
+  H2 = (TH1F*) gDirectory->Get(hist2name);
+  if (H1 && H2) {
+  if(golden){
+    H1->SetLineColor(30);
+    H1->SetFillColor(30);
+    H1->SetFillStyle(3027);
+    H2->SetLineColor(46);
+    H2->SetFillColor(46);
+    H2->SetFillStyle(3027);
+  } else {
+    H1->SetLineColor(4);
+    H1->SetLineWidth(2);
+    H2->SetLineWidth(2);
+    H2->SetLineColor(2);
+    H1->SetStats(0);
+    H2->SetStats(0);
+    H1->SetMinimum(0);
+    H2->SetMinimum(0);
+    H1->SetTitle("");
+    H2->SetTitle("");
+    H1->GetXaxis()->SetTitleSize(0.05);
+    H1->GetYaxis()->SetTitleSize(0.045);
+    H2->GetXaxis()->SetTitleSize(0.05);
+    H2->GetYaxis()->SetTitleSize(0.045);
+    H1->GetXaxis()->SetLabelSize(0.04);
+    H1->GetYaxis()->SetLabelSize(0.04);
+    H2->GetXaxis()->SetLabelSize(0.04);
+    H2->GetYaxis()->SetLabelSize(0.04);
+
+  }
+ 
+  double xpos = H1->GetXaxis()->GetBinCenter(H1->GetXaxis()->GetFirst()+4);
+  double ypos = 0.95*H1->GetMaximum();
+
+  TText* t1 = new TText(xpos,ypos,label1);
+  t1->SetTextColor(4);
+  TText* t2 = new TText(xpos,0.9*ypos,label2);
+  t2->SetTextColor(2);
+  
+  if(golden){
+    if(!samestr.Contains("sames")) samestr += "sames";
+    H1->Draw(samestr);
+    H2->Draw(samestr);
+  } else {
+    if(!golden && !samestr.Contains("sames")){
+      // pick which hist to draw first:
+      if(H1->GetMaximum() > H2->GetMaximum()){
+	H1->Draw(samestr);
+	if(!samestr.Contains("sames")) samestr += "sames";
+	H2->Draw(samestr);
+	t1->Draw();
+	t2->Draw();
+      } else {
+	H2->Draw(samestr);
+	if(!samestr.Contains("sames")) samestr += "sames";
+	H1->Draw(samestr);
+	t1->Draw();
+	t2->Draw();
+      }
+    } else {
+      H1->Draw(samestr);
+      if(!samestr.Contains("sames")) samestr += "sames";
+      H2->Draw(samestr);
+      t1->Draw();
+      t2->Draw();
+
+    H2->GetXaxis()->SetTitleOffset(.6);
+    H2->GetXaxis()->SetTitleSize(0.08);
+    H2->GetYaxis()->SetTitleOffset(.6);
+    H2->GetYaxis()->SetTitleSize(0.08);
+    }
+  }
+  } else {
+    if (!H1) cout << " Histogram " << hist1name << " does not exist" << endl;
+    if (!H2) cout << " Histogram " << hist2name << " does not exist" << endl;
+  }
+}
-- 
GitLab