Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 08:21:01

0001 ///*--------------------------------------------------*/
0002 /// eic_pim.cc:
0003 /// Originally did not exist
0004 /// Date: 2015-2018
0005 ///
0006 ///*--------------------------------------------------*/
0007 /// Modifier: Wenliang (Bill) Li
0008 /// Date: Feb 24 2020
0009 /// Email: wenliang.billlee@gmail.com
0010 ///
0011 /// Comment: Feb 24, 2020: all declearation of the global variables 
0012 //            and all functions for pim class are moved there 
0013 
0014 #include "eic_pim.h"
0015 
0016 using std::vector;
0017 using namespace std;
0018 
0019 //TRandom2 *fRandom;                    
0020 TRandom3 *fRandom;                    
0021 
0022 TFile *f;                    
0023 TTree *t1;
0024 
0025 int gKinematics_type;
0026 bool gPi0_decay;
0027 bool UseSolve;
0028 bool gROOTOut; // SJDK 30/04/24 - Added boolean to enable/disable ROOTfile output
0029 string gDet_location;
0030 string gOutputType; // SJDK 12/01/22 - Added output type as a variable you can specify in the .json file
0031 string gBeamPart; // SJDK 12/01/22 - Added output type as a variable you can specify in the .json file
0032 float fProton_incidence_phi;
0033 
0034 TString gfile_name;
0035 
0036 int fSeed;
0037 
0038 bool allset, print, kCalcFermi, kCalcBremss, kCalcIon, kCalcBremssEle, kCalcIonEle, kSConserve, kFSI, kMSele, kMS;
0039 int fWLessShell, fWLess1P9, fSDiff;
0040 
0041 //long int fNEvents, fNRecorded, fNGenerated, fWSqNeg, fNSigmaNeg, fNWeightUnphys, fNWeightReject, fLundRecorded, fNFile; 
0042 
0043 unsigned long long int fNEvents, fNRecorded, fNGenerated, fWSqNeg, fNSigmaNeg, fNaN, fConserve, fNWeightUnphys, fNWeightReject, fLundRecorded, fNFile, fSolveEvents_0Sol, fSolveEvents_1Sol, fSolveEvents_2Sol, fNWeightNeg; // Love Preet - Added the fNWeightNeg to get number of negative weights
0044 
0045 // SJDK 03/04/23 - Added in Qsq Min/Max, W Min/Max and t max (06/09/23)
0046 // 13/09/23 - SJDK - New generic HBeam value (rather than proton beam)
0047 double fK, fm, fElectron_Kin_Col_GeV, fElectron_Kin_Col, fRand, fLumi, fuBcm2, fPI, fDEG2RAD, fRAD2DEG, fEBeam, fPBeam, fHBeam, fScatElec_Theta_I, fScatElec_Theta_F, fPion_Theta_I, fPion_Theta_F, fEjectileX_Theta_I, fEjectileX_Theta_F, fScatElec_E_Hi, fScatElec_E_Lo, fPSF, fQsq_Min, fQsq_Max, fW_Min, fW_Max, fT_Max; 
0048 
0049 double fOmega_Theta_I, fOmega_Theta_F, fOmega_Theta_Col, fOmega_Phi_Col;
0050 
0051 double fDiff_E, conserve, ene, mom, ene_mom, mom_px, mom_py, mom_pz, mom_pxpy, mom_pxpz, mom_pypz, mom_pxpypz; // 18/06/21 AU -> New variables to count envents passing/not passing conservation laws
0052 
0053 double fMandSConserve, fTop_Pion_Mom, fBot_Pion_Mom, fPion_Mom_Same, fEnergyConserve, fXMomConserve, fYMomConserve, fZMomConserve, fXMomConserve_RF, fYMomConserve_RF, fZMomConserve_RF, fEnergyConserve_RF; 
0054 
0055 double fDiff, fRatio, fPion_Alpha, fPion_Beta, fS_I_RF, fS_F_RF, fS_I_Col, fS_F_Col, fS_I_RF_GeV, fS_F_RF_GeV, fS_I_Col_GeV, fS_F_Col_GeV; 
0056 
0057 double fProton_Energy_Col, fProton_Mom_Col, fProton_Theta_Col, fProton_Phi_Col, fProton_MomZ_Col, fProton_MomX_Col, fProton_MomY_Col, fProton_Energy_Col_GeV, fProton_Mom_Col_GeV, fProton_MomX_Col_GeV, fProton_MomY_Col_GeV, fProton_MomZ_Col_GeV; 
0058 
0059 double fFSIProton_Energy_Col, fFSIProton_Mom_Col, fFSIProton_Theta_Col, fFSIProton_Phi_Col, fFSIProton_MomZ_Col, fFSIProton_MomX_Col, fFSIProton_MomY_Col, fFSIProton_Energy_Col_GeV, fFSIProton_Mom_Col_GeV, fFSIProton_MomX_Col_GeV, fFSIProton_MomY_Col_GeV, fFSIProton_MomZ_Col_GeV;
0060 
0061 double fTarget_Energy_Col, fTarget_Mom_Col, fTarget_Theta_Col, fTarget_Phi_Col, fTarget_MomZ_Col, fTarget_MomX_Col, fTarget_MomY_Col, fTarget_Energy_Col_GeV, fTarget_Mom_Col_GeV, fTarget_MomX_Col_GeV, fTarget_MomY_Col_GeV, fTarget_MomZ_Col_GeV;
0062 
0063 double fTarget_Pol0_Col, fTarget_PolX_Col, fTarget_PolY_Col, fTarget_PolZ_Col, fTarget_Pol0_RF, fTarget_PolX_RF, fTarget_PolY_RF, fTarget_PolZ_RF;
0064 
0065 double fBetaX_Col_RF, fBetaY_Col_RF, fBetaZ_Col_RF, fBeta_Col_RF, fGamma_Col_RF;
0066 
0067 double fProton_MomX_RF, fProton_MomY_RF, fProton_MomZ_RF, fProton_Mom_RF, fProton_Energy_RF, fProton_MomX_RF_GeV, fProton_MomY_RF_GeV, fProton_MomZ_RF_GeV, fProton_Mom_RF_GeV, fProton_Energy_RF_GeV;
0068 
0069 double fScatElec_Angle, fScatElec_Alpha_RF, fScatElec_Beta_RF;
0070 
0071 double fVertex_X, fVertex_Y, fVertex_Z, fProton_Kin_Col_GeV, fElectron_Mass, fElectron_Mass_GeV, fProton_Mass, fProton_Mass_GeV, fNeutron_Mass, fNeutron_Mass_GeV, fPion_Mass, fPion_Mass_GeV, fPiion_Phi, fAlpha, fPi, fMom_Ratio, fMom_Dif, fPionEnergyCMLess, fSNotEqual, fMode_Epsi, fRecoilProton_Mass, fRecoilProton_Mass_GeV;
0072 
0073 double fOmega_Mass, fOmega_Mass_GeV; 
0074 
0075 double f_Scat_hadron_Mass, f_Scat_hadron_Mass_GeV;
0076 
0077 double fKaon_Mass, fKaon_Mass_GeV, fLambda_Mass, fLambda_Mass_GeV, fSigma_Mass, fSigma_Mass_GeV;
0078 
0079 double fElectron_Energy_Col, fElectron_MomZ_Col, fElectron_MomX_Col, fElectron_MomY_Col, fElectron_Theta_Col, fElectron_Phi_Col, fElectron_Mom_Col;
0080 
0081 double fElectron_MS_Energy_Col, fElectron_MS_MomZ_Col, fElectron_MS_MomX_Col, fElectron_MS_MomY_Col, fElectron_MS_Theta_Col, fElectron_MS_Phi_Col, fElectron_MS_Mom_Col;
0082 
0083 double fElectron_Energy_Col_GeV, fElectron_Mom_Col_GeV, fElectron_MomX_Col_GeV, fElectron_MomY_Col_GeV, fElectron_MomZ_Col_GeV, fElectronEnergyLess, fElectronThetaLess, fRadiation_Lenght_Air;
0084 
0085 double fElectron_Targ_Thickness, fElectron_Targ_Thickness_RadLen, fElectron_Targ_BT, fElectron_Targ_Bremss_Loss, fElectron_Targ_Ion_Loss, fElectron_TargWindow_Bremss_Loss, fElectron_TargWindow_Ion_Loss;
0086 
0087 double fElectron_Air_Thickness, fElectron_Air_Thickness_RadLen, fElectron_Air_BT, fElectron_Air_Bremss_Loss, fElectron_Air_Ion_Loss, fElectron_Corrected_Energy_Col, fElectron_Corrected_Mom_Col, fElectron_Corrected_MomX_Col, fElectron_Corrected_MomY_Col, fElectron_Corrected_MomZ_Col, fElectron_Corrected_Theta_Col, fElectron_Corrected_Phi_Col, fElectron_Delta_Mom_Col, fElectron_Corrected_Energy_Col_GeV, fElectron_Corrected_Mom_Col_GeV, fElectron_Corrected_MomX_Col_GeV, fElectron_Corrected_MomY_Col_GeV, fElectron_Corrected_MomZ_Col_GeV, fElectron_Delta_Mom_Col_GeV;
0088 
0089 double fScatElec_MS_Energy_Col, fScatElec_MS_MomZ_Col, fScatElec_MS_MomX_Col, fScatElec_MS_MomY_Col, fScatElec_MS_Theta_Col, fScatElec_MS_Phi_Col, fScatElec_MS_Mom_Col;
0090 
0091 double fScatElec_Energy_Col, fScatElec_MomZ_Col, fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_Theta_Col, fScatElec_Phi_Col, fScatElec_Mom_Col, fScatElec_Energy_Col_GeV, fScatElec_Mom_Col_GeV, fScatElec_MomX_Col_GeV, fScatElec_MomY_Col_GeV, fScatElec_MomZ_Col_GeV, fScatElecEnergyLess, fScatElecThetaLess, fScatElec_Targ_Thickness, fScatElec_Targ_Thickness_RadLen, fScatElec_Targ_BT, fScatElec_Targ_Bremss_Loss, fScatElec_Targ_Ion_Loss, fScatElec_Air_Thickness, fScatElec_Air_Thickness_RadLen, fScatElec_Air_BT, fScatElec_Air_Bremss_Loss, fScatElec_Air_Ion_Loss, fScatElec_Corrected_Energy_Col, fScatElec_Corrected_Mom_Col, fScatElec_Corrected_MomX_Col, fScatElec_Corrected_MomY_Col, fScatElec_Corrected_MomZ_Col, fScatElec_Corrected_Theta_Col, fScatElec_Corrected_Phi_Col, fScatElec_Delta_Mom_Col, fScatElec_Corrected_Energy_Col_GeV, fScatElec_Corrected_Mom_Col_GeV, fScatElec_Corrected_MomX_Col_GeV, fScatElec_Corrected_MomY_Col_GeV, fScatElec_Corrected_MomZ_Col_GeV, fScatElec_Delta_Mom_Col_GeV, fScatElec_TargWindow_Bremss_Loss, fScatElec_TargWindow_Ion_Loss, fTargWindow_Thickness, fTargWindow_Thickness_RadLen, fTargWindow_BT;
0092 
0093 double fPion_TargWindow_Ion_Loss, fPion_Targ_Thickness, fPion_Targ_Thickness_RadLen, fPion_Targ_BT, fPion_Targ_Bremss_Loss, fPion_Targ_Ion_Loss, fPion_Air_Thickness, fPion_Air_Thickness_RadLen, fPion_Air_BT, fPion_Air_Bremss_Loss, fPion_Air_Ion_Loss;
0094 
0095 double fPion_MS_Energy_Col, fPion_MS_MomZ_Col, fPion_MS_MomX_Col, fPion_MS_MomY_Col, fPion_MS_Theta_Col, fPion_MS_Phi_Col, fPion_MS_Mom_Col;
0096 
0097 double fPion_Theta_Col, fPion_Phi_Col, fPion_Energy_Col, fPion_Mom_Col, fPion_MomZ_Col, fPion_MomX_Col, fPion_MomY_Col, fPion_Energy_Col_GeV, fPion_Mom_Col_GeV, fPion_MomX_Col_GeV, fPion_MomY_Col_GeV, fPion_MomZ_Col_GeV;
0098 
0099 double fKaon_Theta_Col, fKaon_Phi_Col, fKaon_Energy_Col, fKaon_Mom_Col, fKaon_MomZ_Col, fKaon_MomX_Col, fKaon_MomY_Col, fKaon_Energy_Col_GeV, fKaon_Mom_Col_GeV, fKaon_MomX_Col_GeV, fKaon_MomY_Col_GeV, fKaon_MomZ_Col_GeV;
0100 
0101 double fScathad_Theta_Col, fScathad_Phi_Col, fScathad_Energy_Col, fScathad_Mom_Col, fScathad_MomZ_Col, fScathad_MomX_Col, fScathad_MomY_Col, fScathad_Energy_Col_GeV, fScathad_Mom_Col_GeV, fScathad_MomX_Col_GeV, fScathad_MomY_Col_GeV, fScathad_MomZ_Col_GeV;
0102 
0103 double fPion_FSI_Theta_Col, fPion_FSI_Phi_Col, fPion_FSI_Energy_Col, fPion_FSI_Mom_Col, fPion_FSI_MomZ_Col, fPion_FSI_MomX_Col, fPion_FSI_MomY_Col, fPion_FSI_Energy_Col_GeV, fPion_FSI_Mom_Col_GeV, fPion_FSI_MomX_Col_GeV, fPion_FSI_MomY_Col_GeV, fPion_FSI_MomZ_Col_GeV;
0104 
0105 double fPion_Corrected_Theta_Col, fPion_Corrected_Phi_Col, fPion_Corrected_Energy_Col, fPion_Corrected_Mom_Col, fPion_Corrected_MomX_Col, fPion_Corrected_MomY_Col, fPion_Corrected_MomZ_Col, fPion_Delta_Mom_Col, fPion_Corrected_Energy_Col_GeV, fPion_Corrected_Mom_Col_GeV, fPion_Corrected_MomX_Col_GeV, fPion_Corrected_MomY_Col_GeV, fPion_Corrected_MomZ_Col_GeV, fPion_Delta_Mom_Col_GeV;
0106 
0107 double fNeutron_MS_Energy_Col, fNeutron_MS_MomZ_Col, fNeutron_MS_MomX_Col, fNeutron_MS_MomY_Col, fNeutron_MS_Theta_Col, fNeutron_MS_Phi_Col, fNeutron_MS_Mom_Col;
0108 
0109 double fNeutron_TargWindow_Ion_Loss, fNeutron_Targ_Thickness, fNeutron_Targ_Thickness_RadLen, fNeutron_Targ_BT, fNeutron_Targ_Bremss_Loss, fNeutron_Targ_Ion_Loss, fNeutron_Air_Thickness, fNeutron_Air_Thickness_RadLen, fNeutron_Air_BT, fNeutron_Air_Bremss_Loss, fNeutron_Air_Ion_Loss, fNeutron_Theta_Col, fNeutron_Phi_Col, fNeutron_Energy_Col, fNeutron_Mom_Col, fNeutron_MomZ_Col, fNeutron_MomX_Col, fNeutron_MomY_Col, fNeutron_Energy_Col_GeV, fNeutron_Mom_Col_GeV, fNeutron_MomX_Col_GeV, fNeutron_MomY_Col_GeV, fNeutron_MomZ_Col_GeV, fNeutron_Corrected_Theta_Col, fNeutron_Corrected_Phi_Col, fNeutron_Corrected_Energy_Col, fNeutron_Corrected_Mom_Col, fNeutron_Corrected_MomX_Col, fNeutron_Corrected_MomY_Col, fNeutron_Corrected_MomZ_Col, fNeutron_Delta_Mom_Col, fNeutron_Corrected_Energy_Col_GeV, fNeutron_Corrected_Mom_Col_GeV, fNeutron_Corrected_MomX_Col_GeV, fNeutron_Corrected_MomY_Col_GeV, fNeutron_Corrected_MomZ_Col_GeV, fNeutron_Delta_Mom_Col_GeV;
0110 
0111 double fRecoilProton_Energy_RF, fRecoilProton_Mom_RF, fRecoilProton_MomX_RF, fRecoilProton_MomY_RF, fRecoilProton_MomZ_RF, fRecoilProton_Energy_RF_GeV, fRecoilProton_Mom_RF_GeV, fRecoilProton_MomX_RF_GeV, fRecoilProton_MomY_RF_GeV, fRecoilProton_MomZ_RF_GeV, fRecoilProton_Theta_RF, fRecoilProton_Phi_RF;
0112 
0113 double fRecoilProton_Targ_Thickness, fRecoilProton_Targ_Thickness_RadLen, fRecoilProton_Targ_BT, fRecoilProton_Targ_Bremss_Loss, fRecoilProton_Targ_Ion_Loss, fRecoilProton_Air_Thickness, fRecoilProton_Air_Thickness_RadLen, fRecoilProton_Air_BT, fRecoilProton_Air_Bremss_Loss, fRecoilProton_Air_Ion_Loss, fRecoilProton_Theta_Col, fRecoilProton_Phi_Col, fRecoilProton_Energy_Col, fRecoilProton_Mom_Col, fRecoilProton_MomZ_Col, fRecoilProton_MomX_Col, fRecoilProton_MomY_Col, fRecoilProton_Energy_Col_GeV, fRecoilProton_Mom_Col_GeV, fRecoilProton_MomX_Col_GeV, fRecoilProton_MomY_Col_GeV, fRecoilProton_MomZ_Col_GeV, fRecoilProton_Corrected_Theta_Col, fRecoilProton_Corrected_Phi_Col, fRecoilProton_Corrected_Energy_Col, fRecoilProton_Corrected_Mom_Col, fRecoilProton_Corrected_MomX_Col, fRecoilProton_Corrected_MomY_Col, fRecoilProton_Corrected_MomZ_Col, fRecoilProton_Delta_Mom_Col, fRecoilProton_Corrected_Energy_Col_GeV, fRecoilProton_Corrected_Mom_Col_GeV, fRecoilProton_Corrected_MomX_Col_GeV, fRecoilProton_Corrected_MomY_Col_GeV, fRecoilProton_Corrected_MomZ_Col_GeV, fRecoilProton_Delta_Mom_Col_GeV;
0114 
0115 double fSSAsym, fSineAsym, fInvariantDif, fT_GeV, fProton_Kin_Col, fQsq_Value, fQsq_Dif, fQsq_GeV, fQsq, fW_GeV_Col, fW_Col, fW, fW_GeV, fW_Prime_GeV, fW_Corrected_Prime_GeV, fWSq, fWSq_GeV, fWSq_PiN, fWSq_PiN_GeV, fWSq_Top_PiN_GeV, fWSq_Bot_PiN_GeV;
0116 
0117 double fElec_ScatElec_Theta_RF, fScatElec_Cone_Phi_RF, fScatElec_Theta_RF, fScatElec_Phi_RF, fScatElec_Mom_RF, fScatElec_Energy_RF, fScatElec_MomX_RF, fScatElec_MomZ_RF, fScatElec_MomY_RF, fScatElec_Energy_RF_GeV, fScatElec_Mom_RF_GeV, fScatElec_MomX_RF_GeV, fScatElec_MomY_RF_GeV, fScatElec_MomZ_RF_GeV;
0118 
0119 double fElectron_Theta_RF, fElectron_Phi_RF, fElectron_Energy_RF, fElectron_Mom_RF, fElectron_MomX_RF, fElectron_MomZ_RF, fElectron_MomY_RF, fElectron_Energy_RF_GeV, fElectron_Mom_RF_GeV, fElectron_MomX_RF_GeV, fElectron_MomZ_RF_GeV, fElectron_MomY_RF_GeV;
0120 
0121 double fPhoton_Energy_RF_GeV, fPhoton_Mom_RF_GeV, fPhoton_Energy_RF, fPhoton_Mom_RF;
0122 
0123 double fProton_Energy_CM, fProton_Mom_CM, fProton_Energy_CM_GeV, fProton_Mom_CM_GeV, fPhoton_Energy_CM, fPhoton_Mom_CM, fPhoton_Energy_CM_GeV, fPhoton_Mom_CM_GeV, fPion_Theta_CM, fPion_Phi_CM, fPion_Energy_CM, fPion_Mom_CM, fPion_Energy_CM_GeV, fPion_Mom_CM_GeV, fNeutron_Theta_CM, fNeutron_Phi_CM, fNeutron_Energy_CM, fNeutron_Energy_CM_GeV, fNeutron_Mom_CM, fNeutron_Mom_CM_GeV;
0124 
0125 double fBeta_CM_RF, fGamma_CM_RF;
0126 
0127 double fPhoton_MomZ_RF, fPhoton_MomX_RF, fPhoton_MomY_RF, fPhoton_Theta_RF, fPhoton_Phi_RF, fPion_Energy_RF, fPion_Energy_RF_GeV, fPiqVec_Theta_RF, fPion_Mom_RF, fPion_Mom_RF_GeV, fPion_MomX_RF, fPion_MomY_RF, fPion_MomZ_RF, fPion_Theta_RF, fPion_Phi_RF, fPion_MomX_RF_GeV, fPion_MomY_RF_GeV, fPion_MomZ_RF_GeV;
0128 
0129 double fT_Para, fT_Para_GeV, fT, fEpsilon, fx, fy, fz, fNeutron_Energy_RF, fNeutron_Energy_RF_GeV, fNeutron_Mom_RF, fNeutron_Mom_RF_GeV, fNeutron_qVec_Theta_RF, fNeutron_MomX_RF, fNeutron_MomY_RF, fNeutron_MomZ_RF, fNeutron_Theta_RF, fNeutron_Phi_RF, fPhoton_MomX_RF_GeV, fPhoton_MomY_RF_GeV, fPhoton_MomZ_RF_GeV, fNeutron_MomX_RF_GeV, fNeutron_MomY_RF_GeV, fNeutron_MomZ_RF_GeV;
0130 
0131 double fPhoton_Theta_Col, fPhoton_Phi_Col, fPhoton_Energy_Col, fPhoton_Mom_Col, fPhoton_MomX_Col, fPhoton_MomZ_Col, fPhoton_MomY_Col, fPhoton_Energy_Col_GeV, fPhoton_Mom_Col_GeV, fPhoton_MomX_Col_GeV, fPhoton_MomZ_Col_GeV, fPhoton_MomY_Col_GeV;
0132 
0133 double fPhoton_Corrected_Theta_Col, fPhoton_Corrected_Phi_Col, fPhoton_Corrected_Energy_Col, fPhoton_Corrected_Mom_Col, fPhoton_Corrected_MomX_Col, fPhoton_Corrected_MomZ_Col, fPhoton_Corrected_MomY_Col, fPhoton_Corrected_Energy_Col_GeV, fPhoton_Corrected_Mom_Col_GeV, fPhoton_Corrected_MomX_Col_GeV, fPhoton_Corrected_MomZ_Col_GeV, fPhoton_Corrected_MomY_Col_GeV;
0134 
0135 double fQsq_Corrected_GeV, fQsq_Corrected, fW_Corrected, fW_Corrected_GeV, fT_Corrected, fT_Corrected_GeV, fx_Corrected, fy_Corrected, fz_Corrected;
0136 
0137 double fWFactor, fA, fFlux_Factor_Col, fFlux_Factor_RF, fJacobian_CM, fJacobian_CM_RF, fJacobian_CM_Col, fZASig_T, fZASig_L, fZASig_LT, fZASig_TT, ftestsig, fZASig_L2;
0138 
0139 double fZASigma_UU, fRorySigma_UT, fSigma_Col, fSigma_UUPara, fSig_VR, fSig_L, fSig_T;
0140 
0141 double fSig_fpi_6GeV;
0142 
0143 double fSigmaPhiS, fSigmaPhi_Minus_PhiS, fSigma2Phi_Minus_PhiS, fSigma3Phi_Minus_PhiS, fSigmaPhi_Plus_PhiS, fSigma2Phi_Plus_PhiS, fSig_Phi_Minus_PhiS, fSig_PhiS, fSig_2Phi_Minus_PhiS, fSig_Phi_Plus_PhiS, fSig_3Phi_Minus_PhiS, fSig_2Phi_Plus_PhiS, fEventWeight, fEventWeightMax, fEventWeightCeil, fEventWeightRn, fZAWFactor, fRR, fPhaseSpaceWeight, fPhaseShiftWeight, fWilliamsWeight, fDedrickWeight, fCatchenWeight, fPhi, fPhiS, fPhi_Corrected, fPhiS_Corrected;
0144 
0145 double fElectron_Mom_Sq_RF, fElectron_Mom_Sq_Col, fProton_Mom_Sq_Col, fProton_Mom_Sq_CM, fProton_Mom_Sq_RF, fPhoton_Mom_Sq_Col, fPhoton_Mom_Sq_CM, fPhoton_Mom_Sq_RF, fPion_Mom_Sq_Col, fPion_Mom_Sq_CM, fPion_Mom_Sq_RF, fNeutron_Mom_Sq_Col, fNeutron_Mom_Sq_CM, fNeutron_Mom_Sq_RF, fScatElec_Mom_Sq_Col, fScatElec_Mom_Sq_RF;
0146 
0147 double fAsymPhiMinusPhi_S, fAsymPhi_S, fAsym2PhiMinusPhi_S, fAsymPhiPlusPhi_S, fAsym3PhiMinusPhi_S, fAsym2PhiPlusPhi_S;
0148 
0149 double fTerm_PhiMinusPhi_S, fTerm_Phi_S, fTerm_2PhiMinusPhi_S, fTerm_PhiPlusPhi_S, fTerm_3PhiMinusPhi_S, fTerm_2PhiPlusPhi_S;
0150 
0151 double fAsymPhiMinusPhi_S_Col, fAsymPhi_S_Col, fAsym2PhiMinusPhi_S_Col, fAsymPhiPlusPhi_S_Col, fAsym3PhiMinusPhi_S_Col, fAsym2PhiPlusPhi_S_Col;
0152 
0153 double fTerm_PhiMinusPhi_S_Col, fTerm_Phi_S_Col, fTerm_2PhiMinusPhi_S_Col, fTerm_PhiPlusPhi_S_Col, fTerm_3PhiMinusPhi_S_Col, fTerm_2PhiPlusPhi_S_Col;
0154 
0155 double fPhi_Pion_LeptonPlane_RF, fCos_Phi_Pion_LeptonPlane_RF, fSin_Phi_Pion_LeptonPlane_RF, fPhi_TargPol_LeptonPlane_RF, fCos_Phi_TargPol_LeptonPlane_RF, fSin_Phi_TargPol_LeptonPlane_RF, fTheta_Pion_Photon_RF, fPhi_Pion_LeptonPlane_Col, fCos_Phi_Pion_LeptonPlane_Col, fSin_Phi_Pion_LeptonPlane_Col, fPhi_TargPol_LeptonPlane_Col, fCos_Phi_TargPol_LeptonPlane_Col, fSin_Phi_TargPol_LeptonPlane_Col, fTheta_Pion_Photon_Col;
0156 
0157 double fPhi_Omega_LeptonPlane_RF, fCos_Phi_Omega_LeptonPlane_RF, fSin_Phi_Omega_LeptonPlane_RF, fTheta_Omega_Photon_RF;
0158 
0159 double fZASigma_UU_Col, fRorySigma_UT_Col, fSig_Phi_Minus_PhiS_Col, fSig_PhiS_Col, fSig_2Phi_Minus_PhiS_Col, fSig_Phi_Plus_PhiS_Col, fSig_3Phi_Minus_PhiS_Col, fSig_2Phi_Plus_PhiS_Col;
0160 
0161 double fepi1, fepi2, fradical;
0162 
0163 double fOmega_Energy_CM, fOmega_Mom_CM, fOmega_Energy_CM_GeV, fOmega_Mom_CM_GeV;   
0164 
0165 double fMomentum[300];
0166 
0167 vector<vector<vector<vector<double>>>> SigPar;
0168 
0169 int psf_steps; // Love Preet - Added for phase space factor calculations
0170 
0171 double psf_ScatElec_E_Stepsize, psf_ScatElec_Theta_Stepsize, psf_ScatElec_Phi_Stepsize, psf_Ejec_Theta_Stepsize; // Love Preet - Added for phase space factor calculations
0172 
0173 double psf_ScatElec_E, psf_ScatElec_Theta, psf_ScatElec_Phi, psf_ScalElec_Mom, psf_Ejectile_Theta, psf_Ejectile_Phi, psf_Q2, psf_W, psf_W2, psf_t, psf_ScatElec_Theta_max, psf_ScatElec_Theta_min, psf_ScatElec_E_max, psf_ScatElec_E_min, psf_Ejectile_Theta_max, psf_Ejectile_Theta_min; // Love Preet - Added for phase space factor calculations
0174 
0175 double fScatElec_Energy_Col_max, fScatElec_Energy_Col_min, fScatElec_Theta_Col_max, fScatElec_Theta_Col_min,  f_Ejectile_Theta_Col_max, f_Ejectile_Theta_Col_min, fPSF_org;
0176 // Love Preet - Added for actual phase space factor calculations
0177 
0178 double scat_e_px, scat_e_py, scat_e_pz, scat_e_E, ejec_px, ejec_py, ejec_pz, ejec_E, rclH_px, rclH_py, rclH_pz, rclH_E; // Love Preet - Added to be stored in the root tree
0179 
0180 double fBeta_Col, fGamma_Col, ftheta_Col; //Love Preet - Added for jacobian calculation in collider frame
0181 
0182 double fProb[300] = {    
0183              6.03456,    6.02429,    6.01155,    5.99636,    5.97873,    5.95869,    5.93626,    5.91147,    5.88435,    5.85493,
0184              5.82325,    5.78935,    5.75326,    5.71504,    5.67472,    5.63235,    5.58799,    5.54169,     5.4935,    5.44347,          
0185              5.39167,    5.33816,    5.28299,    5.22623,    5.16794,    5.10818,    5.04703,    4.98455,    4.92081,    4.85588,
0186              4.78982,    4.71692,    4.63621,    4.55583,    4.47582,    4.39621,    4.31702,    4.23828,    4.16002,    4.08227,
0187              4.00506,     3.9284,    3.85233,    3.77686,    3.70202,    3.62783,    3.55432,    3.48149,    3.40937,    3.33798,
0188              3.26733,    3.19745,    3.12834,    3.06002,    2.99251,    2.92581,    2.85995,    2.79493,    2.73075,    2.66744,
0189              2.605,      2.54344,    2.48276,    2.41728,    2.35244,    2.28922,    2.22759,    2.16751,    2.10895,    2.05186,
0190              1.99621,    1.94198,    1.88913,    1.83762,    1.78743,    1.73851,    1.69086,    1.64442,    1.59918,    1.55511,              
0191              1.51217,    1.47035,    1.42961,    1.38993,    1.35128,    1.31364,    1.27698,    1.24129,    1.20653,    1.17269,              
0192              1.13973,    1.10765,    1.07642,    1.04601,    1.01626,   0.986934,   0.958443,   0.930759,   0.903861,   0.877727,              
0193              0.852335,   0.827665,   0.803696,   0.780409,   0.757785,   0.735806,   0.714452,   0.693708,   0.673555,   0.653978,             
0194              0.63496,   0.616485,   0.598538,   0.581105,    0.56417,   0.547721,   0.531743,   0.516223,   0.501148,   0.486506,              
0195              0.472284,    0.45847,   0.445054,   0.432024,   0.419368,   0.407077,   0.395125,   0.383513,   0.372237,   0.361289,             
0196              0.350658,   0.340336,   0.330314,   0.320583,   0.311135,   0.301962,   0.293056,   0.284409,   0.276014,   0.267863,             
0197              0.25995,   0.252268,   0.244809,   0.237569,   0.230539,   0.223715,   0.217091,    0.21066,   0.204417,   0.198357,              
0198              0.192474,   0.186763,   0.181219,   0.175838,   0.170615,   0.165545,   0.160623,   0.155843,   0.151185,   0.146666,             
0199              0.142282,   0.138028,   0.133902,   0.129898,   0.126013,   0.122245,   0.118588,   0.115041,   0.111599,   0.108261,             
0200              0.105021,   0.101879,  0.0988298,  0.0958719,  0.0930022,  0.0902182,  0.0875173,   0.084897,  0.0823549,  0.0798886,             
0201              0.0774961,  0.0751749,  0.0729231,  0.0707385,  0.0686192,  0.0665631,  0.0645685,  0.0626335,  0.0607563,  0.0589545,            
0202              0.057219,  0.0555322,   0.053893,  0.0523001,  0.0507522,  0.0492481,  0.0477867,  0.0463667,  0.0449872,  0.0436468,             
0203              0.0423448,  0.0410798,  0.0398511,  0.0386576,  0.0374982,  0.0363722,  0.0352785,  0.0342164,  0.0331849,  0.0321831,            
0204              0.0312104,  0.0302658,  0.0293486,  0.0284581,  0.0275935,   0.026754,  0.0259391,  0.0251479,  0.0243799,  0.0236344,            
0205              0.0229107,  0.0221901,  0.0214923,  0.0208167,  0.0201626,  0.0195293,  0.0189162,  0.0183226,  0.0177478,  0.0171913,            
0206              0.0166525,  0.0161308,  0.0156257,  0.0151366,  0.0146629,  0.0142044,  0.0137603,  0.0133303,  0.0129139,  0.0125107,            
0207              0.0121203,  0.0117421,   0.011376,  0.0110214,   0.010678,  0.0103455,  0.0100234, 0.00971153, 0.00940947, 0.00911693,            
0208              0.00883361,  0.0085592, 0.00829385, 0.00803735, 0.00778883, 0.00754804, 0.00731474,  0.0070887, 0.00686967, 0.00665746,               
0209              0.00645184, 0.00625261, 0.00605957, 0.00587252, 0.00569128, 0.00551567, 0.00534551, 0.00518063, 0.00502086, 0.00486605,               
0210              0.00471604, 0.00457069, 0.00442984, 0.00429336,  0.0041611, 0.00403295, 0.00390877, 0.00378843, 0.00367182, 0.00355882,               
0211              0.00344932, 0.00334321, 0.00324038, 0.00314073, 0.00304505,  0.0029524, 0.00286252, 0.00277533, 0.00269076, 0.00260872,               
0212              0.00252913, 0.00245194, 0.00237706, 0.00230444, 0.00223399, 0.00216566, 0.00209939, 0.00203512, 0.00197277, 0.00191231 };
0213 
0214 
0215 pim::pim() {
0216 }
0217 
0218 pim::pim(int aaa) {
0219 
0220   gen_seed = aaa;
0221 
0222 }
0223 
0224 /*--------------------------------------------------*/
0225 /*--------------------------------------------------*/
0226 
0227 void pim::Initilize() {
0228 
0229   //    fRandom = new TRandom2(0);
0230   //    fRandom->GetSeed();
0231   //    fRandom->SetSeed(gen_seed);
0232     
0233   fRandom = new TRandom3();
0234 
0235   fRandom->SetSeed(gen_seed);
0236     
0237   //    cout << fRandom->GetSeed() << endl;
0238   //    cout << "Seed Used: " << gen_seed << endl;
0239     
0240   //    exit(0);
0241 
0242   allset                                      = false;
0243   kCalcFermi                                  = false;
0244   kCalcBremss                                 = false;
0245   kCalcIon                                    = false;
0246   kCalcBremssEle                              = false;
0247   kCalcIonEle                                 = false;
0248   kFSI                                        = false;
0249   kMSele                                      = false;
0250   kMS                                         = false;
0251   gROOTOut                                    = false; // Set to false by default
0252   
0253   // 18/01/23 - The luminosity below is some default assumtpion, more up to date values are set in DEMP prod and depend upon beam energy combinations if they are specified
0254   // See slide 11 in https://indico.cern.ch/event/1072579/contributions/4796856/attachments/2456676/4210776/CAP-EIC-June-7-2022-Seryi-r2.pdf for more info
0255   // fLumi                                     = 0.374e33; // Jlab design
0256   fLumi                                       = 1e33; // 18/01/23, this seems a better default based upon more up to date info, see link above
0257   fuBcm2                                      = 1.0e-30;
0258   fPI                                         = 3.1415926;
0259   fDEG2RAD                                    = fPI/180.0;
0260   fRAD2DEG                                   = 180.0/fPI;
0261     
0262   // SJDK 21/12/22 - Set by .json read in
0263   //fScatElec_Theta_I                           = 60.0 * fDEG2RAD;
0264   //fScatElec_Theta_F                           = 175.0 * fDEG2RAD;
0265   // SJDK 29/11/22 - Updated comment on two variables below
0266   // Two parameters below are NOT a percentage of the beam energy as previously clamed. This parameter along with _Hi represent the RANGE of enegries over which the scattered electron is generated
0267   // The range is from 0.5*EBeam to 2.5*EBeam -> Therefore for the phase space calculation, the spread of 2* the incoming beam energy is used in the calculation
0268   // SJDK 21/12/22 - Set by .json read in
0269   //fScatElec_E_Lo                              = 0.5;  // NOT a percentage of beam energy
0270   //fScatElec_E_Hi                              = 2.5;  // NOT a percentage of beam energy
0271   // Should remove specific pion/omega values here and JUST use EjectileX, should then actually read this in as a parameter, use 0 to 50 as default
0272   fPion_Theta_I                               = 0.0 * fDEG2RAD;
0273   fPion_Theta_F                               = 50.0 * fDEG2RAD;
0274   // SJDK 21/12/22 - Set by .json read in
0275   //fEjectileX_Theta_I                          = 0.0 * fDEG2RAD;
0276   //fEjectileX_Theta_F                          = 50.0 * fDEG2RAD;
0277   fOmega_Theta_I                              = 0.0 * fDEG2RAD; 
0278   fOmega_Theta_F                              = 360.0 * fDEG2RAD; 
0279   // 02/06/21 - SJDK
0280   // Set to 0, now set in PiPlusProd.cc
0281   fPSF                                     = 0;
0282   fK                                          = 1000.0;
0283   fm                                          = 1.0/1000.0;
0284   fElectron_Mass                              = 0.51099895000;
0285   fElectron_Mass_GeV                          = fElectron_Mass/1000.0;
0286   fProton_Mass                                = 938.27208816; // Its is the mass of Proton which in SoLID DVMP is outgoing reocil Proton
0287   fProton_Mass_GeV                            = fProton_Mass/1000.0;
0288   fNeutron_Mass                               = 939.5654205; // It is the mass of Neutron. The target is Neutron in SoLID DVMP.
0289   fNeutron_Mass_GeV                           = fNeutron_Mass/1000.0;
0290   fRecoilProton_Mass                          = 938.27208816;
0291   fRecoilProton_Mass_GeV                      = fRecoilProton_Mass/1000.0;
0292   fPion_Mass                                  = 139.57039 ;
0293   fPion_Mass_GeV                              = fPion_Mass/1000.0;
0294   fKaon_Mass                                  = 493.677;
0295   fKaon_Mass_GeV                              = fKaon_Mass/1000.0;
0296   fLambda_Mass                                = 1115.683;
0297   fLambda_Mass_GeV                            = fLambda_Mass/1000.0;
0298   fSigma_Mass                                 = 1192.642;
0299   fSigma_Mass_GeV                             = fSigma_Mass/1000.0;
0300   fOmega_Mass                                 = 782.66;
0301   fOmega_Mass_GeV                             = fOmega_Mass/1000.0;
0302 
0303   fDiff                                       = 0.00001; // 10/05/23 - Love Preet - Changed from 0.5
0304     
0305   // Love Preet - Adding for phase space factor calculations
0306   psf_steps                                   = 1000.0; //1000.0;
0307   psf_ScatElec_E_max = std::numeric_limits<double>::min(); // Initialize maxValue for the scattered electron's energy
0308   psf_ScatElec_E_min = std::numeric_limits<double>::max(); // Initialize minValue for the scattered electron's energy
0309   psf_ScatElec_Theta_max = std::numeric_limits<double>::min(); // Initialize maxValue for the scattered electron's theta
0310   psf_ScatElec_Theta_min = std::numeric_limits<double>::max(); // Initialize minValue for the scattered electron's theta
0311   psf_Ejectile_Theta_max = std::numeric_limits<double>::min(); // Initialize maxValue for the ejectile's theta
0312   psf_Ejectile_Theta_min = std::numeric_limits<double>::max(); // Initialize minValue for the ejectile's theta
0313     
0314   // Love Preet - Added for actual phase space factor calculations
0315   fScatElec_Energy_Col_max = std::numeric_limits<double>::min(); // Initialize maxValue for the scattered electron's energy
0316   fScatElec_Energy_Col_min = std::numeric_limits<double>::max(); // Initialize minValue for the scattered electron's energy
0317   fScatElec_Theta_Col_max = std::numeric_limits<double>::min(); // Initialize maxValue for the scattered electron's theta
0318   fScatElec_Theta_Col_min = std::numeric_limits<double>::max(); // Initialize minValue for the scattered electron's theta
0319   f_Ejectile_Theta_Col_max = std::numeric_limits<double>::min(); // Initialize maxValue for the ejectile's theta
0320   f_Ejectile_Theta_Col_min = std::numeric_limits<double>::max(); // Initialize minValue for the ejectile's theta
0321   fPSF_org = 0;
0322     
0323   // Love Preet - Added to be stored in the root tree
0324   scat_e_px                                  = 0;
0325   scat_e_py                                  = 0;
0326   scat_e_pz                                  = 0;
0327   scat_e_E                                   = 0;
0328   ejec_px                                    = 0;
0329   ejec_py                                    = 0;
0330   ejec_pz                                    = 0;
0331   ejec_E                                     = 0;
0332   rclH_px                                    = 0;
0333   rclH_py                                    = 0;
0334   rclH_pz                                    = 0;
0335   rclH_E                                     = 0;    
0336   
0337   //Love Preet - Added for jacobian calculation in collider frame
0338   fBeta_Col                                  = 0;
0339   fGamma_Col                                 = 0;
0340   ftheta_Col                                 = 0;
0341   // 02/06/21 - SJDK
0342   // Set to 0, now set in PiPlusProd.cc
0343   fElectron_Kin_Col_GeV                       = 0;
0344   fElectron_Kin_Col                           = 0;
0345   fAlpha                                      = 1./137.036;
0346   fMom_Ratio                                  = 0.460029;
0347   fMom_Dif                                    = 0.01;
0348   fPi                                         = TMath::Pi(); 
0349   fMandSConserve                              = 0;
0350   fEnergyConserve                             = 0;
0351   fXMomConserve                               = 0;
0352   fYMomConserve                               = 0;
0353   fZMomConserve                               = 0;
0354   fXMomConserve_RF                            = 0;
0355   fYMomConserve_RF                            = 0;
0356   fZMomConserve_RF                            = 0;
0357   fEnergyConserve_RF                          = 0;
0358   fPion_Mom_Same                              = 0;
0359   fTop_Pion_Mom                               = 0;
0360   fBot_Pion_Mom                               = 0;
0361   fS_I_RF                                     = 0;
0362   fS_F_RF                                     = 0;
0363   fS_I_Col                                    = 0;
0364   fS_F_Col                                    = 0;
0365   fS_I_RF_GeV                                 = 0;
0366   fS_F_RF_GeV                                 = 0;
0367   fS_I_Col_GeV                                = 0;
0368   fS_F_Col_GeV                                = 0;
0369   fPion_Alpha                                 = 0;
0370   fPion_Beta                                  = 0;
0371   fNRecorded                                  = 0;
0372   fNGenerated                                 = 0;
0373   fRatio                                      = 0;
0374   fWLessShell                                 = 0;
0375   fWLess1P9                                   = 0;
0376   fWSqNeg                                     = 0;
0377   fNSigmaNeg                                  = 0;
0378   fNWeightNeg                                 = 0;
0379   // SJDK 15/06/21 - Integer counters to check number returning NaN and failing conservation laws added
0380   fNaN                                        = 0;
0381   fConserve                                   = 0;
0382   fNWeightUnphys                              = 0;
0383   fNWeightReject                              = 0;
0384   fSolveEvents_0Sol                           = 0;
0385   fSolveEvents_1Sol                           = 0;
0386   fSolveEvents_2Sol                           = 0;
0387   fSDiff                                      = 0;
0388   fScatElecEnergyLess                         = 0;
0389   fScatElecThetaLess                          = 0;
0390   fPionEnergyCMLess                           = 0;
0391   fSNotEqual                                  = 0;
0392   fVertex_X                                   = 0;
0393   fVertex_Y                                   = 0;
0394   fVertex_Z                                   = 0;
0395   fProton_Energy_Col                          = 0;
0396   fProton_Mom_Col                             = 0;
0397   fProton_Theta_Col                           = 0;
0398   fProton_Phi_Col                             = 0;
0399   fProton_MomZ_Col                            = 0;
0400   fProton_MomX_Col                            = 0;
0401   fProton_MomY_Col                            = 0;
0402   fProton_Energy_Col_GeV                      = 0;
0403   fProton_Mom_Col_GeV                         = 0;
0404   fProton_MomX_Col_GeV                        = 0;
0405   fProton_MomY_Col_GeV                        = 0;
0406   fProton_MomZ_Col_GeV                        = 0;
0407   fTarget_Energy_Col                          = 0;
0408   fTarget_Mom_Col                             = 0;
0409   fTarget_Theta_Col                           = 0;
0410   fTarget_Phi_Col                             = 0;
0411   fTarget_MomZ_Col                            = 0;
0412   fTarget_MomX_Col                            = 0;
0413   fTarget_MomY_Col                            = 0;
0414   fTarget_Energy_Col_GeV                      = 0;
0415   fTarget_Mom_Col_GeV                         = 0;
0416   fTarget_MomX_Col_GeV                        = 0;
0417   fTarget_MomY_Col_GeV                        = 0;
0418   fTarget_MomZ_Col_GeV                        = 0;
0419   fTarget_Pol0_Col                            = 0;
0420   fTarget_PolX_Col                            = 0;
0421   fTarget_PolY_Col                            = 0;
0422   fTarget_PolZ_Col                            = 0;
0423   fTarget_Pol0_RF                             = 0;
0424   fTarget_PolX_RF                             = 0;
0425   fTarget_PolY_RF                             = 0;
0426   fTarget_PolZ_RF                             = 0;
0427   fBetaX_Col_RF                               = 0;
0428   fBetaY_Col_RF                               = 0;
0429   fBetaZ_Col_RF                               = 0;
0430   fBeta_Col_RF                                = 0;
0431   fGamma_Col_RF                               = 0;
0432   fProton_MomX_RF                             = 0;
0433   fProton_MomY_RF                             = 0;
0434   fProton_MomZ_RF                             = 0;
0435   fProton_Mom_RF                              = 0;
0436   fProton_Energy_RF                           = 0;
0437   fProton_Energy_RF_GeV                       = 0;
0438   fProton_MomX_RF_GeV                         = 0;
0439   fProton_MomY_RF_GeV                         = 0;
0440   fProton_MomZ_RF_GeV                         = 0;
0441   fProton_Mom_RF_GeV                          = 0;
0442   fProton_Kin_Col_GeV                         = 0;
0443   fScatElec_Angle                             = 0;
0444   fScatElec_Alpha_RF                          = 0;
0445   fScatElec_Beta_RF                           = 0;
0446   fRadiation_Lenght_Air                       = 0;
0447   fElectron_Targ_Thickness                    = 0;
0448   fElectron_Targ_Thickness_RadLen             = 0;
0449   fElectron_Targ_BT                           = 0;
0450   fElectron_Targ_Bremss_Loss                  = 0;
0451   fElectron_Targ_Ion_Loss                     = 0;
0452   fElectron_TargWindow_Bremss_Loss            = 0;
0453   fElectron_TargWindow_Ion_Loss               = 0;
0454   fElectron_Air_Thickness                     = 0;
0455   fElectron_Air_Thickness_RadLen              = 0;
0456   fElectron_Air_BT                            = 0;
0457   fElectron_Air_Bremss_Loss                   = 0;
0458   fElectron_Air_Ion_Loss                      = 0;
0459   fElectron_Corrected_Theta_Col               = 0;
0460   fElectron_Corrected_Phi_Col                 = 0;
0461   fElectron_Corrected_Energy_Col              = 0;
0462   fElectron_Corrected_Mom_Col                 = 0;
0463   fElectron_Corrected_MomX_Col                = 0;
0464   fElectron_Corrected_MomY_Col                = 0;
0465   fElectron_Corrected_MomZ_Col                = 0;
0466   fElectron_Delta_Mom_Col                     = 0;
0467   fElectron_Corrected_Energy_Col_GeV          = 0;
0468   fElectron_Corrected_Mom_Col_GeV             = 0;
0469   fElectron_Corrected_MomX_Col_GeV            = 0;
0470   fElectron_Corrected_MomY_Col_GeV            = 0;
0471   fElectron_Corrected_MomZ_Col_GeV            = 0;
0472   fElectron_Delta_Mom_Col_GeV                 = 0;
0473   
0474   fElectron_Energy_Col                        = 0;
0475   fElectron_MomZ_Col                          = 0;
0476   fElectron_MomX_Col                          = 0;
0477   fElectron_MomY_Col                          = 0;
0478   fElectron_Theta_Col                         = 0;
0479   fElectron_Phi_Col                           = 0;
0480   fElectron_Mom_Col                           = 0;
0481     
0482   fElectron_MS_Energy_Col                     = 0;
0483   fElectron_MS_MomZ_Col                       = 0;
0484   fElectron_MS_MomX_Col                       = 0;
0485   fElectron_MS_MomY_Col                       = 0;
0486   fElectron_MS_Theta_Col                      = 0;
0487   fElectron_MS_Phi_Col                        = 0;
0488   fElectron_MS_Mom_Col                        = 0;
0489   
0490   fElectron_Energy_Col_GeV                    = 0;
0491   fElectron_Mom_Col_GeV                       = 0;
0492   fElectron_MomX_Col_GeV                      = 0;
0493   fElectron_MomY_Col_GeV                      = 0;
0494   fElectron_MomZ_Col_GeV                      = 0;
0495   fScatElec_Targ_Thickness                    = 0;
0496   fScatElec_Targ_Thickness_RadLen             = 0;
0497   fScatElec_Targ_BT                           = 0;
0498   fScatElec_Targ_Bremss_Loss                  = 0;
0499   fScatElec_Targ_Ion_Loss                     = 0;
0500   fScatElec_Air_Thickness                     = 0;
0501   fScatElec_Air_Thickness_RadLen              = 0;
0502   fScatElec_Air_BT                            = 0;
0503   fScatElec_Air_Bremss_Loss                   = 0;
0504   fScatElec_Air_Ion_Loss                      = 0;
0505   fScatElec_Corrected_Theta_Col               = 0;
0506   fScatElec_Corrected_Phi_Col                 = 0;
0507   fScatElec_Corrected_Energy_Col              = 0;
0508   fScatElec_Corrected_Mom_Col                 = 0;
0509   fScatElec_Corrected_MomX_Col                = 0;
0510   fScatElec_Corrected_MomY_Col                = 0;
0511   fScatElec_Corrected_MomZ_Col                = 0;
0512   fScatElec_Delta_Mom_Col                     = 0;
0513   fScatElec_Corrected_Energy_Col_GeV          = 0;
0514   fScatElec_Corrected_Mom_Col_GeV             = 0;
0515   fScatElec_Corrected_MomX_Col_GeV            = 0;
0516   fScatElec_Corrected_MomY_Col_GeV            = 0;
0517   fScatElec_Corrected_MomZ_Col_GeV            = 0;
0518   fScatElec_Delta_Mom_Col_GeV                 = 0;
0519   fScatElec_Energy_Col                        = 0;
0520   fScatElec_MomZ_Col                          = 0;
0521   fScatElec_MomX_Col                          = 0;
0522   fScatElec_MomY_Col                          = 0;
0523   fScatElec_Theta_Col                         = 0;
0524   fScatElec_Phi_Col                           = 0;
0525   fScatElec_Mom_Col                           = 0;
0526   fScatElec_Energy_Col_GeV                    = 0;
0527   fScatElec_Mom_Col_GeV                       = 0;
0528   fScatElec_MomX_Col_GeV                      = 0;
0529   fScatElec_MomY_Col_GeV                      = 0;
0530   fScatElec_MomZ_Col_GeV                      = 0;
0531   
0532   fScatElec_MS_Energy_Col                     = 0;
0533   fScatElec_MS_MomZ_Col                       = 0;
0534   fScatElec_MS_MomX_Col                       = 0;
0535   fScatElec_MS_MomY_Col                       = 0;
0536   fScatElec_MS_Theta_Col                      = 0;
0537   fScatElec_MS_Phi_Col                        = 0;
0538   fScatElec_MS_Mom_Col                        = 0;
0539     
0540   fScatElec_TargWindow_Bremss_Loss            = 0;
0541   fScatElec_TargWindow_Ion_Loss               = 0;
0542   fTargWindow_Thickness                       = 0;
0543   fTargWindow_Thickness_RadLen                = 0;
0544   fTargWindow_BT                              = 0; 
0545   fPion_TargWindow_Ion_Loss                   = 0;
0546   fNeutron_TargWindow_Ion_Loss                = 0;
0547     
0548   fPion_MS_Energy_Col                         = 0;
0549   fPion_MS_MomZ_Col                           = 0;
0550   fPion_MS_MomX_Col                           = 0;
0551   fPion_MS_MomY_Col                           = 0;
0552   fPion_MS_Theta_Col                          = 0;
0553   fPion_MS_Phi_Col                            = 0;
0554   fPion_MS_Mom_Col                            = 0;
0555   
0556   fPion_Targ_Thickness                        = 0;
0557   fPion_Targ_Thickness_RadLen                 = 0;
0558   fPion_Targ_BT                               = 0;
0559   fPion_Targ_Bremss_Loss                      = 0;
0560   fPion_Targ_Ion_Loss                         = 0;
0561   fPion_Air_Thickness                         = 0;
0562   fPion_Air_Thickness_RadLen                  = 0;
0563   fPion_Air_BT                                = 0;
0564   fPion_Air_Bremss_Loss                       = 0;
0565   fPion_Air_Ion_Loss                          = 0;
0566   fPion_Corrected_Theta_Col                   = 0;
0567   fPion_Corrected_Phi_Col                     = 0;
0568   fPion_Corrected_Energy_Col                  = 0;
0569   fPion_Corrected_Mom_Col                     = 0;
0570   fPion_Corrected_MomX_Col                    = 0;
0571   fPion_Corrected_MomY_Col                    = 0;
0572   fPion_Corrected_MomZ_Col                    = 0;
0573   fPion_Delta_Mom_Col                         = 0;
0574   fPion_Corrected_Energy_Col_GeV              = 0;
0575   fPion_Corrected_Mom_Col_GeV                 = 0;
0576   fPion_Corrected_MomX_Col_GeV                = 0;
0577   fPion_Corrected_MomY_Col_GeV                = 0;
0578   fPion_Corrected_MomZ_Col_GeV                = 0;
0579   fPion_Delta_Mom_Col_GeV                     = 0;
0580     
0581   fPion_Energy_Col                            = 0;
0582   fPion_MomZ_Col                              = 0;
0583   fPion_MomX_Col                              = 0;
0584   fPion_MomY_Col                              = 0;
0585   fPion_Theta_Col                             = 0;
0586   fPion_Phi_Col                               = 0;
0587   fPion_Mom_Col                               = 0;
0588   fPion_Energy_Col_GeV                        = 0;
0589   fPion_Mom_Col_GeV                           = 0;
0590   fPion_MomX_Col_GeV                          = 0;
0591   fPion_MomY_Col_GeV                          = 0;
0592   fPion_MomZ_Col_GeV                          = 0;
0593     
0594   fPion_FSI_Energy_Col                        = 0;
0595   fPion_FSI_MomZ_Col                          = 0;
0596   fPion_FSI_MomX_Col                          = 0;
0597   fPion_FSI_MomY_Col                          = 0;
0598   fPion_FSI_Theta_Col                         = 0;
0599   fPion_FSI_Phi_Col                           = 0;
0600   fPion_FSI_Mom_Col                           = 0;
0601   fPion_FSI_Energy_Col_GeV                    = 0;
0602   fPion_FSI_Mom_Col_GeV                       = 0;
0603   fPion_FSI_MomX_Col_GeV                      = 0;
0604   fPion_FSI_MomY_Col_GeV                      = 0;
0605   fPion_FSI_MomZ_Col_GeV                      = 0;
0606   
0607   fNeutron_MS_Energy_Col                      = 0;
0608   fNeutron_MS_MomZ_Col                        = 0;
0609   fNeutron_MS_MomX_Col                        = 0;
0610   fNeutron_MS_MomY_Col                        = 0;
0611   fNeutron_MS_Theta_Col                       = 0;
0612   fNeutron_MS_Phi_Col                         = 0;
0613   fNeutron_MS_Mom_Col                         = 0;
0614 
0615   fKaon_Energy_Col                            = 0;       
0616   fKaon_MomZ_Col                              = 0;       
0617   fKaon_MomX_Col                              = 0;       
0618   fKaon_MomY_Col                              = 0;       
0619   fKaon_Theta_Col                             = 0;       
0620   fKaon_Phi_Col                               = 0;       
0621   fKaon_Mom_Col                               = 0;       
0622   fKaon_Energy_Col_GeV                        = 0;       
0623   fKaon_Mom_Col_GeV                           = 0;       
0624   fKaon_MomX_Col_GeV                          = 0;       
0625   fKaon_MomY_Col_GeV                          = 0;       
0626   fKaon_MomZ_Col_GeV                          = 0;
0627   fScathad_Energy_Col                         = 0;    
0628   fScathad_MomZ_Col                           = 0;    
0629   fScathad_MomX_Col                           = 0;    
0630   fScathad_MomY_Col                           = 0;    
0631   fScathad_Theta_Col                          = 0;    
0632   fScathad_Phi_Col                            = 0;    
0633   fScathad_Mom_Col                            = 0;    
0634   fScathad_Energy_Col_GeV                     = 0;    
0635   fScathad_Mom_Col_GeV                        = 0;    
0636   fScathad_MomX_Col_GeV                       = 0;    
0637   fScathad_MomY_Col_GeV                       = 0;    
0638   fScathad_MomZ_Col_GeV                       = 0;
0639   
0640   fNeutron_Targ_Thickness                     = 0;
0641   fNeutron_Targ_Thickness_RadLen              = 0;
0642   fNeutron_Targ_BT                            = 0;
0643   fNeutron_Targ_Bremss_Loss                   = 0;
0644   fNeutron_Targ_Ion_Loss                      = 0;
0645   fNeutron_Air_Thickness                      = 0;
0646   fNeutron_Air_Thickness_RadLen               = 0;
0647   fNeutron_Air_BT                             = 0;
0648   fNeutron_Air_Bremss_Loss                    = 0;
0649   fNeutron_Air_Ion_Loss                       = 0;
0650   fNeutron_Corrected_Theta_Col                = 0;
0651   fNeutron_Corrected_Phi_Col                  = 0;
0652   fNeutron_Corrected_Energy_Col               = 0;
0653   fNeutron_Corrected_Mom_Col                  = 0;
0654   fNeutron_Corrected_MomX_Col                 = 0;
0655   fNeutron_Corrected_MomY_Col                 = 0;
0656   fNeutron_Corrected_MomZ_Col                 = 0;
0657   fNeutron_Delta_Mom_Col                      = 0;
0658   fNeutron_Corrected_Energy_Col_GeV           = 0;
0659   fNeutron_Corrected_Mom_Col_GeV              = 0;
0660   fNeutron_Corrected_MomX_Col_GeV             = 0;
0661   fNeutron_Corrected_MomY_Col_GeV             = 0;
0662   fNeutron_Corrected_MomZ_Col_GeV             = 0;
0663   fNeutron_Delta_Mom_Col_GeV                  = 0;
0664   fNeutron_Energy_Col                         = 0;
0665   fNeutron_MomZ_Col                           = 0;
0666   fNeutron_MomX_Col                           = 0;
0667   fNeutron_MomY_Col                           = 0;
0668   fNeutron_Theta_Col                          = 0;
0669   fNeutron_Phi_Col                            = 0;
0670   fNeutron_Mom_Col                            = 0;
0671   fNeutron_Energy_Col_GeV                     = 0;
0672   fNeutron_Mom_Col_GeV                        = 0;
0673   fNeutron_MomX_Col_GeV                       = 0;
0674   fNeutron_MomY_Col_GeV                       = 0;
0675   fNeutron_MomZ_Col_GeV                       = 0;
0676   fRecoilProton_Targ_Thickness                = 0;
0677   fRecoilProton_Targ_Thickness_RadLen         = 0;
0678   fRecoilProton_Targ_BT                       = 0;
0679   fRecoilProton_Targ_Bremss_Loss              = 0;
0680   fRecoilProton_Targ_Ion_Loss                 = 0;
0681   fRecoilProton_Air_Thickness                 = 0;
0682   fRecoilProton_Air_Thickness_RadLen          = 0;
0683   fRecoilProton_Air_BT                        = 0;
0684   fRecoilProton_Air_Bremss_Loss               = 0;
0685   fRecoilProton_Air_Ion_Loss                  = 0;
0686   fRecoilProton_Theta_Col                     = 0;
0687   fRecoilProton_Phi_Col                       = 0;
0688   fRecoilProton_Energy_Col                    = 0;
0689   fRecoilProton_Mom_Col                       = 0;
0690   fRecoilProton_MomX_Col                      = 0;
0691   fRecoilProton_MomY_Col                      = 0;
0692   fRecoilProton_MomZ_Col                      = 0;
0693   fRecoilProton_Corrected_Energy_Col          = 0;
0694   fRecoilProton_Corrected_Mom_Col             = 0;
0695   fRecoilProton_Corrected_MomX_Col            = 0;
0696   fRecoilProton_Corrected_MomY_Col            = 0;
0697   fRecoilProton_Corrected_MomZ_Col            = 0;
0698   fRecoilProton_Corrected_Theta_Col           = 0;
0699   fRecoilProton_Corrected_Phi_Col             = 0;
0700   fRecoilProton_Delta_Mom_Col                 = 0;
0701   fRecoilProton_Energy_Col_GeV                = 0;
0702   fRecoilProton_Mom_Col_GeV                   = 0;
0703   fRecoilProton_MomX_Col_GeV                  = 0;
0704   fRecoilProton_MomY_Col_GeV                  = 0;
0705   fRecoilProton_MomZ_Col_GeV                  = 0;
0706   fRecoilProton_Corrected_Energy_Col_GeV      = 0;
0707   fRecoilProton_Corrected_Mom_Col_GeV         = 0;
0708   fRecoilProton_Corrected_MomX_Col_GeV        = 0;
0709   fRecoilProton_Corrected_MomY_Col_GeV        = 0;
0710   fRecoilProton_Corrected_MomZ_Col_GeV        = 0;
0711   fRecoilProton_Delta_Mom_Col_GeV             = 0;
0712   fSSAsym                                     = 0;
0713   fSineAsym                                   = 0;
0714   fT                                          = 0;
0715   fT_GeV                                      = 0;
0716   fProton_Kin_Col                             = 0;
0717   fQsq_Value                                  = 0;
0718   fQsq_Dif                                    = 0;
0719   fQsq_GeV                                    = 0;
0720   fQsq                                        = 0;
0721   fW_GeV_Col                                  = 0;
0722   fW_Col                                      = 0;
0723   fW                                          = 0;   
0724   fW_GeV                                      = 0;
0725   fW                                          = 0;   
0726   fW_GeV                                      = 0;
0727   fW_Prime_GeV                                = 0;
0728   fW_Corrected_Prime_GeV                      = 0;
0729   fWSq                                        = 0;   
0730   fWSq_GeV                                    = 0;
0731   fWSq_PiN                                    = 0;   
0732   fWSq_PiN_GeV                                = 0;
0733   fWSq_Top_PiN_GeV                            = 0;
0734   fWSq_Bot_PiN_GeV                            = 0;
0735   fScatElec_Mom_RF                            = 0;
0736   fScatElec_Mom_RF_GeV                        = 0;
0737   fScatElec_Energy_RF                         = 0;
0738   fScatElec_Energy_RF_GeV                     = 0;
0739   fElec_ScatElec_Theta_RF                     = 0;
0740   fScatElec_Cone_Phi_RF                       = 0;
0741   fScatElec_Theta_RF                          = 0;
0742   fScatElec_Phi_RF                            = 0;
0743   fScatElec_MomX_RF                           = 0;
0744   fScatElec_MomZ_RF                           = 0;
0745   fScatElec_MomY_RF                           = 0;
0746   fElectron_Energy_RF                         = 0;
0747   fElectron_Mom_RF                            = 0;
0748   fElectron_Theta_RF                          = 0;
0749   fElectron_Phi_RF                            = 0;
0750   fElectron_MomX_RF                           = 0;
0751   fElectron_MomZ_RF                           = 0;
0752   fElectron_MomY_RF                           = 0;
0753   fPhoton_Energy_RF                           = 0;
0754   fPhoton_Mom_RF                              = 0;
0755   fPhoton_Energy_RF_GeV                       = 0;
0756   fPhoton_Mom_RF_GeV                          = 0;
0757   fProton_Energy_CM                           = 0;
0758   fProton_Energy_CM_GeV                       = 0;
0759   fProton_Mom_CM                              = 0;
0760   fProton_Mom_CM_GeV                          = 0;
0761   fPhoton_Energy_CM                           = 0;
0762   fPhoton_Mom_CM                              = 0;
0763   fPhoton_Energy_CM_GeV                       = 0;
0764   fPhoton_Mom_CM_GeV                          = 0;
0765   fPion_Theta_CM                              = 0;
0766   fPion_Phi_CM                                = 0;
0767   fPion_Energy_CM                             = 0;
0768   fPion_Mom_CM                                = 0;
0769   fPion_Energy_CM_GeV                         = 0;
0770   fPion_Mom_CM_GeV                            = 0;
0771   fBeta_CM_RF                                 = 0;
0772   fGamma_CM_RF                                = 0;
0773   fNeutron_Theta_CM                           = 0;
0774   fNeutron_Phi_CM                             = 0;
0775   fNeutron_Energy_CM                          = 0;
0776   fNeutron_Energy_CM_GeV                      = 0;
0777   fNeutron_Mom_CM                             = 0;
0778   fNeutron_Mom_CM_GeV                         = 0;
0779   fPhoton_MomZ_RF                             = 0;
0780   fPhoton_MomX_RF                             = 0;
0781   fPhoton_MomY_RF                             = 0;
0782   fPhoton_Theta_RF                            = 0;
0783   fPhoton_Phi_RF                              = 0;
0784   fPion_Energy_RF                             = 0;
0785   fPion_Mom_RF                                = 0;
0786   fPion_Energy_RF_GeV                         = 0;
0787   fPion_Mom_RF_GeV                            = 0;
0788   fPiqVec_Theta_RF                            = 0;
0789   fPion_Mom_RF                                = 0;
0790   fPion_Mom_RF_GeV                            = 0;
0791   fPion_MomX_RF                               = 0;
0792   fPion_MomY_RF                               = 0;
0793   fPion_MomZ_RF                               = 0;
0794   fPion_Theta_RF                              = 0;
0795   fPion_Phi_RF                                = 0;
0796   fPion_MomX_RF_GeV                           = 0;
0797   fPion_MomY_RF_GeV                           = 0;
0798   fPion_MomZ_RF_GeV                           = 0;
0799   fT_Para                                     = 0;
0800   fT_Para_GeV                                 = 0;
0801   fEpsilon                                    = 0;
0802   fx                                          = 0;
0803   fy                                          = 0;
0804   fz                                          = 0;
0805   fNeutron_Energy_RF                          = 0;
0806   fNeutron_Energy_RF_GeV                      = 0;
0807   fNeutron_Mom_RF                             = 0;
0808   fNeutron_Mom_RF_GeV                         = 0;
0809   fNeutron_qVec_Theta_RF                      = 0;
0810   fNeutron_MomX_RF                            = 0;
0811   fNeutron_MomY_RF                            = 0;
0812   fNeutron_MomZ_RF                            = 0;
0813   fNeutron_Theta_RF                           = 0;
0814   fNeutron_Phi_RF                             = 0;
0815   fRecoilProton_Energy_RF                     = 0;
0816   fRecoilProton_Mom_RF                        = 0;
0817   fRecoilProton_MomX_RF                       = 0;
0818   fRecoilProton_MomY_RF                       = 0;
0819   fRecoilProton_MomZ_RF                       = 0;
0820   fRecoilProton_Energy_RF_GeV                 = 0;
0821   fRecoilProton_Mom_RF_GeV                    = 0;
0822   fRecoilProton_MomX_RF_GeV                   = 0;
0823   fRecoilProton_MomY_RF_GeV                   = 0;
0824   fRecoilProton_MomZ_RF_GeV                   = 0;
0825   fRecoilProton_Theta_RF                      = 0;
0826   fRecoilProton_Phi_RF                        = 0;
0827   fElectron_MomX_RF_GeV                       = 0;
0828   fElectron_MomY_RF_GeV                       = 0;
0829   fElectron_MomZ_RF_GeV                       = 0;
0830   fPhoton_MomX_RF_GeV                         = 0;
0831   fPhoton_MomY_RF_GeV                         = 0;
0832   fPhoton_MomZ_RF_GeV                         = 0;
0833   fScatElec_MomX_RF_GeV                       = 0;
0834   fScatElec_MomY_RF_GeV                       = 0;
0835   fScatElec_MomZ_RF_GeV                       = 0;
0836   fNeutron_MomX_RF_GeV                        = 0;
0837   fNeutron_MomY_RF_GeV                        = 0;
0838   fNeutron_MomZ_RF_GeV                        = 0;
0839   fPhoton_MomX_Col_GeV                        = 0;
0840   fPhoton_MomY_Col_GeV                        = 0;
0841   fPhoton_MomZ_Col_GeV                        = 0;
0842   fPion_MomX_Col_GeV                          = 0;
0843   fPion_MomY_Col_GeV                          = 0;
0844   fPion_MomZ_Col_GeV                          = 0; 
0845   fPhoton_Theta_Col                           = 0;
0846   fPhoton_Phi_Col                             = 0;
0847   fPhoton_Energy_Col                          = 0;
0848   fPhoton_Mom_Col                             = 0;
0849   fPhoton_MomX_Col                            = 0;
0850   fPhoton_MomZ_Col                            = 0;
0851   fPhoton_MomY_Col                            = 0;
0852   fPhoton_Energy_Col_GeV                      = 0;
0853   fPhoton_Mom_Col_GeV                         = 0;
0854   fPhoton_MomX_Col_GeV                        = 0;
0855   fPhoton_MomZ_Col_GeV                        = 0;
0856   fPhoton_MomY_Col_GeV                        = 0;
0857   fWFactor                                    = 0;
0858   fA                                          = 0;
0859   fZASigma_UU                                 = 0;
0860   fRorySigma_UT                               = 0;
0861   fSigma_Col                                  = 0;
0862   fSigma_UUPara                               = 0;
0863   fSig_VR                                     = 0;
0864 
0865   fSig_fpi_6GeV                               = 0;
0866 
0867   fSig_L                                      = 0;
0868   fSig_T                                      = 0;
0869   fSigmaPhiS                                  = 0;
0870   fSigmaPhi_Minus_PhiS                        = 0;
0871   fSigma2Phi_Minus_PhiS                       = 0;
0872   fSigma3Phi_Minus_PhiS                       = 0;
0873   fSigmaPhi_Plus_PhiS                         = 0;
0874   fSigma2Phi_Plus_PhiS                        = 0;
0875   fSig_Phi_Minus_PhiS                         = 0;
0876   fSig_PhiS                                   = 0;
0877   fSig_2Phi_Minus_PhiS                        = 0;
0878   fSig_Phi_Plus_PhiS                          = 0;
0879   fSig_3Phi_Minus_PhiS                        = 0;
0880   fSig_2Phi_Plus_PhiS                         = 0;
0881   fEventWeight                                = 0;
0882   fEventWeightMax                             = 0;
0883   fEventWeightCeil                            = 0; // SJDK 11/05/21 - This is the maximum value found with the old method that is used to get the new unit weight
0884   fEventWeightRn                              = 0; // SJDK 11/05/21 -Random number to compare determined weight to
0885   fWilliamsWeight                             = 0;
0886   fDedrickWeight                              = 0;
0887   fCatchenWeight                              = 0;
0888   fFlux_Factor_Col                            = 0;
0889   fFlux_Factor_RF                             = 0;
0890   fJacobian_CM                                = 0;
0891   fJacobian_CM_RF                             = 0;
0892   fJacobian_CM_Col                            = 0;
0893   fZASig_T                                    = 0;
0894   fZASig_L                                    = 0;
0895   fZASig_L2                                   = 0;
0896   fZASig_LT                                   = 0;
0897   fZASig_TT                                   = 0;
0898   fPhi                                        = 0;
0899   fPhiS                                       = 0;
0900   fPhi_Corrected                              = 0;
0901   fPhiS_Corrected                             = 0;      
0902   
0903   fQsq_Corrected_GeV                          = 0;      
0904   fQsq_Corrected                              = 0;      
0905   fW_Corrected                                = 0;      
0906   fW_Corrected_GeV                            = 0;      
0907   fT_Corrected                                = 0;      
0908   fT_Corrected_GeV                            = 0;      
0909   fx_Corrected                                = 0;      
0910   fy_Corrected                                = 0;      
0911   fz_Corrected                                = 0;      
0912   
0913   fAsymPhiMinusPhi_S                          = 0;
0914   fAsymPhi_S                                  = 0;
0915   fAsym2PhiMinusPhi_S                         = 0;
0916   fAsymPhiPlusPhi_S                           = 0;
0917   fAsym3PhiMinusPhi_S                         = 0;
0918   fAsym2PhiPlusPhi_S                          = 0;
0919     
0920   fAsymPhiMinusPhi_S_Col                      = 0;
0921   fAsymPhi_S_Col                              = 0;
0922   fAsym2PhiMinusPhi_S_Col                     = 0;
0923   fAsymPhiPlusPhi_S_Col                       = 0;
0924   fAsym3PhiMinusPhi_S_Col                     = 0;
0925   fAsym2PhiPlusPhi_S_Col                      = 0;
0926   
0927   fTerm_PhiMinusPhi_S                         = 0;
0928   fTerm_Phi_S                                 = 0;
0929   fTerm_2PhiMinusPhi_S                        = 0;
0930   fTerm_PhiPlusPhi_S                          = 0;
0931   fTerm_3PhiMinusPhi_S                        = 0;
0932   fTerm_2PhiPlusPhi_S                         = 0;
0933     
0934   fTerm_PhiMinusPhi_S_Col                     = 0;
0935   fTerm_Phi_S_Col                             = 0;
0936   fTerm_2PhiMinusPhi_S_Col                    = 0;
0937   fTerm_PhiPlusPhi_S_Col                      = 0;
0938   fTerm_3PhiMinusPhi_S_Col                    = 0;
0939   fTerm_2PhiPlusPhi_S_Col                     = 0;
0940   
0941   fPhoton_Corrected_Theta_Col                 = 0;
0942   fPhoton_Corrected_Phi_Col                   = 0;
0943   fPhoton_Corrected_Energy_Col                = 0;
0944   fPhoton_Corrected_Mom_Col                   = 0;
0945   fPhoton_Corrected_MomX_Col                  = 0;
0946   fPhoton_Corrected_MomZ_Col                  = 0;
0947   fPhoton_Corrected_MomY_Col                  = 0;
0948   fPhoton_Corrected_Energy_Col_GeV            = 0;
0949   fPhoton_Corrected_Mom_Col_GeV               = 0;
0950   fPhoton_Corrected_MomX_Col_GeV              = 0;
0951   fPhoton_Corrected_MomZ_Col_GeV              = 0;
0952   fPhoton_Corrected_MomY_Col_GeV              = 0;
0953   fPhi_Pion_LeptonPlane_RF                    = 0;
0954   fCos_Phi_Pion_LeptonPlane_RF                = 0;
0955   fSin_Phi_Pion_LeptonPlane_RF                = 0;
0956 
0957   fPhi_Omega_LeptonPlane_RF                   = 0;
0958   fCos_Phi_Omega_LeptonPlane_RF               = 0;
0959   fSin_Phi_Omega_LeptonPlane_RF               = 0;
0960   fTheta_Omega_Photon_RF                      = 0;
0961 
0962   fOmega_Energy_CM                            = 0;
0963   fOmega_Mom_CM                               = 0;
0964   fOmega_Energy_CM_GeV                        = 0;
0965   fOmega_Mom_CM_GeV                           = 0;
0966 
0967   fPhi_TargPol_LeptonPlane_RF                 = 0;
0968   fCos_Phi_TargPol_LeptonPlane_RF             = 0;
0969   fSin_Phi_TargPol_LeptonPlane_RF             = 0;
0970   fTheta_Pion_Photon_RF                       = 0;
0971   fPhi_Pion_LeptonPlane_Col                   = 0;
0972   fCos_Phi_Pion_LeptonPlane_Col               = 0;
0973   fSin_Phi_Pion_LeptonPlane_Col               = 0;
0974   fPhi_TargPol_LeptonPlane_Col                = 0;
0975   fCos_Phi_TargPol_LeptonPlane_Col            = 0;
0976   fSin_Phi_TargPol_LeptonPlane_Col            = 0;
0977   fTheta_Pion_Photon_Col                      = 0;
0978   fZASigma_UU_Col                             = 0;
0979   fRorySigma_UT_Col                           = 0;
0980   fSig_Phi_Minus_PhiS_Col                     = 0;
0981   fSig_PhiS_Col                               = 0;
0982   fSig_2Phi_Minus_PhiS_Col                    = 0;
0983   fSig_Phi_Plus_PhiS_Col                      = 0;
0984   fSig_3Phi_Minus_PhiS_Col                    = 0;
0985   fSig_2Phi_Plus_PhiS_Col                     = 0;
0986   // SJDK 08/02/22 - New variables Ali added for conservation law checks
0987   conserve                                    = 0; // This is the number that PASS both conservation check
0988   ene                                         = 0; // The number that FAIL due to failing energy conservation check ONLY
0989   mom                                         = 0; // The number that FAIL due to failing the momentum conservation check ONLY
0990   ene_mom                                     = 0; // The number that FAIL BOTH energy and momentum check
0991   mom_px                                      = 0; // Fail due to px only
0992   mom_py                                      = 0; // Fail due to py only
0993   mom_pz                                      = 0; // Fail due to pz only
0994   mom_pxpy                                    = 0; // Fail due to px and py
0995   mom_pxpz                                    = 0; // Fail due to px and pz
0996   mom_pypz                                    = 0; // Fail due to py and pz
0997   mom_pxpypz                                  = 0; // Fail due to px, py and pz
0998 
0999 }
1000 
1001 //---------------------------------------------------------
1002 double pim::fermiMomentum() {
1003 
1004   double fMom;
1005   bool kFermi = true;
1006   while ( kFermi ) {
1007     double fProton_Rand_Mom_Col      = fRandom->Uniform( 0, 300.0);
1008     double fProton_Rand_Mom_Col_Prob = fRandom->Uniform( fProb[299], fProb[0] );
1009     int    fProton_Mom_Int           = std::ceil( fProton_Rand_Mom_Col );
1010     double f3He_Value                = fProb[ fProton_Mom_Int - 1 ];
1011   
1012     if ( fProton_Rand_Mom_Col_Prob <= f3He_Value ) {
1013       fMom = fProton_Rand_Mom_Col;  
1014       kFermi = false;
1015     }
1016   }
1017 
1018   cout << "Fermi momentum check: " << fMom << endl; 
1019   
1020   return fMom;
1021 }
1022 
1023 ///*--------------------------------------------------*/ 
1024 //-> 10/05/23 - Love added a slimmed down, simpler to read version of the CheckLaws fn
1025 // 
1026 // To check the conservation of the energy and momentum, there two methods avalaible:
1027 // Method 1: Give the four-vectors of the initial and final states partciles, 
1028 //           tolerance factor will be defaulted 1e-6 MeV
1029 // Method 2: Give the four-vectors of the initial and final states partciles, 
1030 //           and the prefered tolerance factor.
1031 //
1032 int pim::CheckLaws(TLorentzVector P_E0, TLorentzVector P_t, TLorentzVector P_e, TLorentzVector P_pim, TLorentzVector P_pro) {
1033 
1034   double energy_check = (P_t.E() + P_E0.E()) - (P_e.E()+P_pim.E()+P_pro.E());
1035   double px_check =(P_t.Px() + P_E0.Px()) - (P_e.Px()+P_pim.Px()+P_pro.Px());
1036   double py_check =(P_t.Py() + P_E0.Py()) - (P_e.Py()+P_pim.Py()+P_pro.Py());
1037   double pz_check =(P_t.Pz() + P_E0.Pz()) - (P_e.Pz()+P_pim.Pz()+P_pro.Pz());
1038   
1039   Int_t err = -1;
1040   if( fabs( energy_check ) < fDiff  && fabs( px_check ) < fDiff  &&  fabs( py_check ) < fDiff && fabs( pz_check ) < fDiff){  // if both momentum components and energy pass the conservation check (simultaneously)
1041     conserve++;
1042     err = 1;
1043   }
1044   
1045   else{
1046     if( (fabs( px_check ) > fDiff) || (fabs( py_check ) > fDiff) || (fabs( pz_check ) > fDiff) ){ // If momentum check fails, check if energy also failed, add counters accordingly     
1047 
1048       // Check components
1049       if( fabs( px_check ) > fDiff){
1050     // px failed, check py
1051     if( fabs( py_check ) > fDiff){
1052       // py failed, check pz
1053       if( fabs( pz_check ) > fDiff){
1054         // pz failed, all 3 failed
1055         mom_pxpypz++; // All failed
1056       }
1057       else mom_pxpy++; // px and py failed
1058     }
1059     else if( fabs( py_check ) < fDiff){
1060       // py passed, check pz
1061       if( fabs( pz_check ) > fDiff){
1062         mom_pxpz++; // px and pz failed
1063       }
1064       else mom_px++; // px failed, py and pz passd
1065     }
1066       }
1067      
1068       else if ( abs( px_check ) < fDiff){
1069     // px passed, check py
1070     if( fabs( py_check ) > fDiff){
1071       // py failed, check pz
1072       if( fabs( pz_check ) > fDiff){
1073         mom_pypz++; // py and pz failed
1074       }
1075       else mom_py++; // Just py failed
1076     }
1077     else mom_pz++; // Only option left (since we know one of them failed) is that pz failed
1078       }
1079       
1080       if( fabs( energy_check ) > fDiff){
1081     ene_mom++; // Both failed
1082       }
1083       else if( abs( energy_check ) < fDiff){
1084     mom++; // Only momentum failed
1085       }
1086     }    
1087     else ene++; // If check did not pass, but it wasn't momentum, must have been energy, add to counter
1088   }
1089   
1090   return err;
1091 }
1092 
1093 int pim::CheckLaws(TLorentzVector P_E0, TLorentzVector P_t, TLorentzVector P_e, TLorentzVector P_pim, TLorentzVector P_pro, double fDiff_E) {
1094 
1095   double energy_check = (P_t.E() + P_E0.E()) - (P_e.E()+P_pim.E()+P_pro.E());
1096   double px_check =(P_t.Px() + P_E0.Px()) - (P_e.Px()+P_pim.Px()+P_pro.Px());
1097   double py_check =(P_t.Py() + P_E0.Py()) - (P_e.Py()+P_pim.Py()+P_pro.Py());
1098   double pz_check =(P_t.Pz() + P_E0.Pz()) - (P_e.Pz()+P_pim.Pz()+P_pro.Pz());
1099                                                                                                  
1100   Int_t err = -1;
1101   if( fabs( energy_check ) < fDiff_E  && fabs( px_check ) < fDiff_E  &&  fabs( py_check ) < fDiff_E && fabs( pz_check ) < fDiff_E){  // if both momentum components and energy pass the conservation check (simultaneously)
1102     conserve++;
1103     err = 1;
1104   }
1105 
1106   else{
1107     if( (fabs( px_check ) > fDiff_E) || (fabs( py_check ) > fDiff_E) || (fabs( pz_check ) > fDiff_E) ){ // If momentum check fails, check if energy also failed, add counters accordingly   
1108 
1109       // Check components
1110       if( fabs( px_check ) > fDiff_E){
1111     // px failed, check py
1112     if( fabs( py_check ) > fDiff_E){
1113       // py failed, check pz
1114       if( fabs( pz_check ) > fDiff_E){
1115         // pz failed, all 3 failed
1116         mom_pxpypz++; // All failed
1117       }
1118       else mom_pxpy++; // px and py failed
1119     }
1120     else if( fabs( py_check ) < fDiff_E){
1121       // py passed, check pz
1122       if( fabs( pz_check ) > fDiff_E){
1123         mom_pxpz++; // px and pz failed
1124       }
1125       else mom_px++; // px failed, py and pz passd
1126     }
1127       }
1128      
1129       else if ( abs( px_check ) < fDiff_E){
1130     // px passed, check py
1131     if( fabs( py_check ) > fDiff_E){
1132       // py failed, check pz
1133       if( fabs( pz_check ) > fDiff_E){
1134         mom_pypz++; // py and pz failed
1135       }
1136       else mom_py++; // Just py failed
1137     }
1138     else mom_pz++; // Only option left (since we know one of them failed) is that pz failed
1139       }
1140       
1141       if( fabs( energy_check ) > fDiff_E){
1142     ene_mom++; // Both failed
1143       }
1144       else if( abs( energy_check ) < fDiff_E){
1145     mom++; // Only momentum failed
1146       }
1147     }    
1148     else ene++; // If check did not pass, but it wasn't momentum, must have been energy, add to counter
1149   }
1150   
1151   return err;
1152 }
1153 
1154 ///****************************************
1155 
1156 void pim::setrootfile( string rootFile ){ 
1157 
1158 
1159   ///****************************************
1160   /// Bill: re-delcreation of f1 is fixed,
1161   ///       all object function calls are switched pointer function calls
1162 
1163   f = new TFile(rootFile.c_str(),"recreate"); 
1164 
1165   t1 = new TTree();
1166   t1->SetName("t1");
1167 
1168   t1->Branch("ScatElec_Theta_Col",                        &fScatElec_Theta_Col,                        "fScatElec_Theta_Col/D");
1169   t1->Branch("ScatElec_Phi_Col",                          &fScatElec_Phi_Col,                          "fScatElec_Phi_Col/D");
1170   t1->Branch("ScatElec_Energy_Col_GeV",                   &fScatElec_Energy_Col_GeV,                   "fScatElec_Energy_Col_GeV/D");
1171   t1->Branch("ScatElec_Mom_Col_GeV",                      &fScatElec_Mom_Col_GeV,                      "fScatElec_Mom_Col_GeV/D");
1172   t1->Branch("ScatElec_MomX_Col_GeV",                     &fScatElec_MomX_Col_GeV,                     "fScatElec_MomX_Col_GeV/D");
1173   t1->Branch("ScatElec_MomY_Col_GeV",                     &fScatElec_MomY_Col_GeV,                     "fScatElec_MomY_Col_GeV/D");
1174   t1->Branch("ScatElec_MomZ_Col_GeV",                     &fScatElec_MomZ_Col_GeV,                     "fScatElec_MomZ_Col_GeV/D");
1175 
1176   t1->Branch("Pion_Theta_Col",                            &fPion_Theta_Col,                            "fPion_Theta_Col/D");
1177   t1->Branch("Pion_Phi_Col",                              &fPion_Phi_Col,                              "fPion_Phi_Col/D");
1178   t1->Branch("Pion_Energy_Col_GeV",                       &fPion_Energy_Col_GeV,                       "fPion_Energy_Col_GeV/D");
1179   t1->Branch("Pion_Mom_Col_GeV",                          &fPion_Mom_Col_GeV,                          "fPion_Mom_Col_GeV/D");
1180   t1->Branch("Pion_MomX_Col_GeV",                         &fPion_MomX_Col_GeV,                         "fPion_MomX_Col_GeV/D");
1181   t1->Branch("Pion_MomY_Col_GeV",                         &fPion_MomY_Col_GeV,                         "fPion_MomY_Col_GeV/D");
1182   t1->Branch("Pion_MomZ_Col_GeV",                         &fPion_MomZ_Col_GeV,                         "fPion_MomZ_Col_GeV/D");
1183 
1184   t1->Branch("Neutron_Theta_Col",                         &fNeutron_Theta_Col,                         "fNeutron_Theta_Col/D");
1185   t1->Branch("Neutron_Phi_Col",                           &fNeutron_Phi_Col,                           "fNeutron_Phi_Col/D");
1186   t1->Branch("Neutron_Energy_Col_GeV",                    &fNeutron_Energy_Col_GeV,                    "fNeutron_Energy_Col_GeV/D");
1187   t1->Branch("Neutron_Mom_Col_GeV",                       &fNeutron_Mom_Col_GeV,                       "fNeutron_Mom_Col_GeV/D");
1188   t1->Branch("Neutron_MomX_Col_GeV",                      &fNeutron_MomX_Col_GeV,                      "fNeutron_MomX_Col_GeV/D");
1189   t1->Branch("Neutron_MomY_Col_GeV",                      &fNeutron_MomY_Col_GeV,                      "fNeutron_MomY_Col_GeV/D");
1190   t1->Branch("Neutron_MomZ_Col_GeV",                      &fNeutron_MomZ_Col_GeV,                      "fNeutron_MomZ_Col_GeV/D");
1191   t1->Branch("Epsilon",                                   &fEpsilon,                                   "fEpsilon/D");
1192   t1->Branch("Phi",                                       &fPhi,                                       "fPhi/D");
1193   t1->Branch("PhiS",                                      &fPhiS,                                      "fPhiS/D");
1194   t1->Branch("W_GeV",                                     &fW_GeV,                                     "fW_GeV/D");
1195   t1->Branch("W_Prime_GeV",                               &fW_Prime_GeV,                               "fW_Prime_GeV/D");
1196 
1197   t1->Branch("Qsq_GeV",                                   &fQsq_GeV,                                   "fQsq_GeV/D");
1198   t1->Branch("T_Para_GeV",                                &fT_Para_GeV,                                "fT_Para_GeV/D");
1199   t1->Branch("T_GeV",                                     &fT_GeV,                                     "fT_GeV/D");
1200   t1->Branch("x",                                         &fx,                                         "fx/D");
1201   t1->Branch("y",                                         &fy,                                         "fy/D");
1202   t1->Branch("z",                                         &fz,                                         "fz/D");
1203 
1204   t1->Branch("Flux_Factor_RF",                            &fFlux_Factor_RF,                            "fFlux_Factor_RF/D");
1205   t1->Branch("Flux_Factor_Col",                           &fFlux_Factor_Col,                           "fFlux_Factor_Col/D");
1206   t1->Branch("Jacobian_CM",                               &fJacobian_CM,                               "fJacobian_CM/D");
1207   t1->Branch("Jacobian_CM_RF",                            &fJacobian_CM_RF,                            "fJacobian_CM_RF/D");
1208   t1->Branch("Jacobian_CM_Col",                           &fJacobian_CM_Col,                           "fJacobian_CM_Col/D");
1209   t1->Branch("EventWeight",                               &fEventWeight,                               "fEventWeight/D");
1210   t1->Branch("Sigma_Col",                                 &fSigma_Col,                                 "fSigma_Col/D");
1211   t1->Branch("Sig_VR"  ,                                  &fSig_VR,                                    "fSig_VR/D");
1212   t1->Branch("Sig_L",                                     &fSig_L,                                     "fSig_L/D");
1213   t1->Branch("Sig_T",                                     &fSig_T,                                     "fSig_T/D");
1214 
1215   t1->Branch("A",                                         &fA,                                         "fA/D");
1216   t1->Branch("Vertex_X",                                  &fVertex_X,                                  "fVertex_X/D");
1217   t1->Branch("Vertex_Y",                                  &fVertex_Y,                                  "fVertex_Y/D");
1218   t1->Branch("Vertex_Z",                                  &fVertex_Z,                                  "fVertex_Z/D");
1219   
1220 }