From 5a5586739214b1918a36cdae0bf4eaa3b83b38c6 Mon Sep 17 00:00:00 2001
From: hallc-online <hallconline@gmail.com>
Date: Sun, 19 Aug 2018 19:32:44 -0400
Subject: [PATCH] Update THcHallCSpectrometer.cxx

Added setting of spectrometer mispointing according the the input
spectrometer angle if the mispointing is not set by a parameter.

The formulas for deteriming the mispointing comes from fits to sureys.

If one wants to use different spectrometer mispointings then
it is best to set hmispointing_x,hmispointing_y for HMS
and pmispointing_x,pmispointing_y for SHMS in the kinematics setting file
such as standard.kinematics .
---
 src/THcHallCSpectrometer.cxx | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/THcHallCSpectrometer.cxx b/src/THcHallCSpectrometer.cxx
index 48541e6..b499688 100644
--- a/src/THcHallCSpectrometer.cxx
+++ b/src/THcHallCSpectrometer.cxx
@@ -282,9 +282,31 @@ Int_t THcHallCSpectrometer::ReadDatabase( const TDatime& date )
   fSelUsingPrune = 0;
   fPhi_lab = 0.;
   fSatCorr=0.;
-  fMispointing_x=0.;
-  fMispointing_y=0.;
+  fMispointing_x=999.;
+  fMispointing_y=999.;
   gHcParms->LoadParmValues((DBRequest*)&list,prefix);
+  //  mispointing in transport system y is horizontal and +x is vertical down
+  if (fMispointing_y == 999.) {
+    if (prefix[0]=='h') {
+       fMispointing_y = 0.1*(0.52-0.012*40.+0.002*40.*40.);
+       if (fTheta_lab < 40) fMispointing_y = 0.1*(0.52-0.012*TMath::Abs(fTheta_lab)+0.002*fTheta_lab*fTheta_lab);
+    }
+    if (prefix[0]=='p') fMispointing_y = 0.1*(-0.6);
+	cout << prefix[0] << " From Formula Mispointing_y = " << fMispointing_y << endl;
+  } else {
+	cout << prefix[0] << " From Parameter Set Mispointing_y = " << fMispointing_y << endl;
+  }
+  if (fMispointing_x == 999.) {
+    if (prefix[0]=='h')  {
+         fMispointing_x = 0.1*(2.37-0.086*50+0.0012*50.*50.);
+         if (fTheta_lab < 50)fMispointing_x = 0.1*(2.37-0.086*TMath::Abs(fTheta_lab)+0.0012*fTheta_lab*fTheta_lab);
+    }
+    if (prefix[0]=='p') fMispointing_x = 0.1*(-1.26);
+	cout << prefix[0] << " From Formula Mispointing_x = " << fMispointing_x << endl;
+  } else {
+	cout << prefix[0] << " From Parameter Set Mispointing_x = " << fMispointing_x << endl;
+  }
+  //
 
   EnforcePruneLimits();
 
-- 
GitLab