Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:06:53

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