diff --git a/config/AR23_20i/CommonParam.xml b/config/AR23_20i/CommonParam.xml index ad5f46618..a1d7851aa 100644 --- a/config/AR23_20i/CommonParam.xml +++ b/config/AR23_20i/CommonParam.xml @@ -291,6 +291,7 @@ Or changing the name of this parameter set P31(1910),P33(1920),F35(1905),F37(1950),P11(1710) + 0.0924 diff --git a/config/AR23_20i/ModelConfiguration.xml b/config/AR23_20i/ModelConfiguration.xml index 69e2930a1..06f819393 100644 --- a/config/AR23_20i/ModelConfiguration.xml +++ b/config/AR23_20i/ModelConfiguration.xml @@ -120,6 +120,9 @@ STFC, Rutherford Appleton Laboratory genie::AlvarezRusoCOHPiPXSec/Fast --> + + genie::AlvarezRusoSalaCOHGammaPXSec/Default + genie::BardinIMDRadCorPXSec/Default genie::IMDAnnihilationPXSec/Default genie::NuElectronPXSec/Default diff --git a/config/AR23_20i/TuneGeneratorList.xml b/config/AR23_20i/TuneGeneratorList.xml index 938e22406..4a65ae8e4 100644 --- a/config/AR23_20i/TuneGeneratorList.xml +++ b/config/AR23_20i/TuneGeneratorList.xml @@ -47,7 +47,7 @@ Generator-%d alg No --> - 18 + 19 genie::EventGenerator/QEL-CC genie::EventGenerator/QEL-NC genie::EventGenerator/RES-CC @@ -66,6 +66,7 @@ Generator-%d alg No genie::EventGenerator/QEL-CC-LAMBDA genie::EventGenerator/MEC-CC genie::EventGenerator/MEC-NC + genie::EventGenerator/COH-NC-GAMMA diff --git a/config/AlvarezRusoCOHPiPXSec.xml b/config/AlvarezRusoCOHPiPXSec.xml index 3efd34a18..ae043ae74 100644 --- a/config/AlvarezRusoCOHPiPXSec.xml +++ b/config/AlvarezRusoCOHPiPXSec.xml @@ -39,13 +39,13 @@ CoHAR_mA double yes Coherent axial mass 1.28 - genie::COHXSecAR/Default + genie::COHXSecAR/Pion false - genie::COHXSecAR/Fast + genie::COHXSecAR/Fast_Pion false diff --git a/config/AlvarezRusoSalaCOHGammaPXSec.xml b/config/AlvarezRusoSalaCOHGammaPXSec.xml new file mode 100644 index 000000000..0c2234579 --- /dev/null +++ b/config/AlvarezRusoSalaCOHGammaPXSec.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + genie::COHDeltaCurrent/Default + + + genie::COHXSecAR/Gamma + + + + + + + genie::COHDeltaCurrent/FermiMomentumTable + + + + + + + diff --git a/config/COHDeltaCurrent.xml b/config/COHDeltaCurrent.xml new file mode 100644 index 000000000..569e0d914 --- /dev/null +++ b/config/COHDeltaCurrent.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + genie::DeltaTransitionFormFactor/Default + genie::DeltaInMediumCorrections/Default + + + + + + genie::DeltaInMediumCorrections/FermiMomentumTable + + + + + diff --git a/config/COHGammaIntegrationLimits.xml b/config/COHGammaIntegrationLimits.xml new file mode 100644 index 000000000..e7451cb58 --- /dev/null +++ b/config/COHGammaIntegrationLimits.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + 0.9 + 150. + + genie::COHProtonFormFactorInterpolation/Default + + + + diff --git a/config/COHGammaKinematicsGenerator.xml b/config/COHGammaKinematicsGenerator.xml new file mode 100644 index 000000000..7e1ee6689 --- /dev/null +++ b/config/COHGammaKinematicsGenerator.xml @@ -0,0 +1,54 @@ + + + + + + + + + 1.5 + + 1. + + 100000 + + 11 ; 175 ; 11 ; 3 + + 0.4 ; 0.8 ; 0.4 ; 0.01 + + genie::COHGammaIntegrationLimits/Default + + + + + + diff --git a/config/COHKinematicsGenerator.xml b/config/COHKinematicsGenerator.xml deleted file mode 100644 index 0a01bf804..000000000 --- a/config/COHKinematicsGenerator.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - Coherent - - - - - diff --git a/config/COHPionKinematicsGenerator.xml b/config/COHPionKinematicsGenerator.xml new file mode 100644 index 000000000..165417589 --- /dev/null +++ b/config/COHPionKinematicsGenerator.xml @@ -0,0 +1,38 @@ + + + + + + + + + Coherent + + + + + diff --git a/config/COHProtonFormFactorInterpolation.xml b/config/COHProtonFormFactorInterpolation.xml new file mode 100644 index 000000000..9bbe1098c --- /dev/null +++ b/config/COHProtonFormFactorInterpolation.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + genie::DeVriesFormFactorMap/Default + + + false + + + diff --git a/config/COHXSecAR.xml b/config/COHXSecAR.xml index 5efacb297..2a12668ff 100644 --- a/config/COHXSecAR.xml +++ b/config/COHXSecAR.xml @@ -12,6 +12,17 @@ split-integral bool yes If true, breaks 4d integral into 3d+ gsl-integration-type string yes Algorithm to use for multidimensional integral vegas gsl-relative-tolerance double yes Desired numerical accuracy for each integral 0.01 gsl-max-eval int yes Max limit of evaluations for multidimensional integral 20000 + +IsCOHPion bool yes This integrator can be used for both COH Pion and Gamma false +ISCOHGamma bool yes false +OmegaPhaseSpace bool Yes Only used for the COH Gamma case false + It perform the integration in the dOmega_g dOmega_l +tPhaseSpace bool Yes Only used for the COH Gamma case false + It perform the integration in the t phase space + instead of theta_l +IntegrationLimits algo Maybe Specificies integration limit algorithm + It is required for COH gamma configurations + .................................................................................................... --> @@ -23,17 +34,57 @@ gsl-max-eval int yes Max limit of evaluations for multidi 40000 0.01 true - + - + + + true + + + + miser 10000 0.05 + true + + + + true + + false + + false + vegas + + 400000 + 0.005 + + genie::COHGammaIntegrationLimits/Default + + + + + + true + true + false + vegas + + 400000 + 0.005 + + + + + + + diff --git a/config/DeVriesFormFactor.xml b/config/DeVriesFormFactor.xml new file mode 100644 index 000000000..1002ce45a --- /dev/null +++ b/config/DeVriesFormFactor.xml @@ -0,0 +1,980 @@ + + + + + + + + + + + + 1000010030 + + 3.5 + 2.83 + + + 0.25182e-1 ; 0.34215e-1 ; 0.15257e-1 + + + + + + 1000020030 + + 5.0 + + + 10.10 + + + + 0.20020e-1 ; 0.41934e-1 ; 0.36254e-1 ; 0.17941e-1 ; 0.46608e-2 ; + 0.46834e-2 ; 0.52042e-2 ; 0.38280e-2 ; 0.25661e-2 ; 0.14182e-2 ; + 0.61390e-3 ; 0.22929e-3 + + + + + + 1000060120 + + 8.0 + 2.75 + + + 0.15737e-1 ; 0.38897e-1 ; 0.37085e-1 ; 0.14795e-1 ; -0.44831e-2 ; + -0.10057e-1 ; -0.68696e-2 ; -0.28813e-2 ; -0.77229e-3 ; 0.66908e-4 ; + 0.10636e-3 ; -0.36864e-4 ; -0.50135e-5 ; 0.94550e-5 ; -0.47687e-5 + + + + + 1000070150 + + 7.0 + + 3.17 + + + + 0.25491e-1 ; 0.50618e-1 ; 0.29822e-1 ; -0.55196e-2 ; -0.15913e-1 ; + -0.76184e-2 ; -0.23992e-2 ; -0.47940e-3 + + + + + 1000080160 + + 8.0 + 2.77 + + + 0.20238e-1 ; 0.44793e-1 ; 0.33533e-1 ; 0.35030e-2 ; -0.12293e-1 ; + -0.10329e-1 ; 0.34036e-2 ; 0.41627e-3 ; -0.94435e-3 ; 0.25771e-3 ; + 0.23759e-3 ; -0.10603e-3 ; 0.41480e-4 + + + + + 1000130270 + + 7.0 + 2.70 + + + 0.43418e-1 ; 0.60298e-1 ; 0.28950e-2 ; -0.23522e-1 ; -0.79791e-2 ; + 0.23010e-2 ; 0.10794e-2 ; 0.12574e-3 ; -0.13021e-3 ; 0.56563e-4 ; + -0.18011e-4 ; 0.42869e-5 + + + + + 1000140280 + + 8.0 + 2.64 + + + 0.33495e-1 ; 0.59533e-1 ; 0.20979e-1 ; -0.16900e-1 ; -0.14998e-1 ; + 4.93248e-3 ; 0.33266e-2 ; 0.59244e-3 ; 4.40013e-3 ; 0.12242e-3 ; + -0.12994e-4 ; -0.92784e-5 ; 0.72595e-5 ; -0.42096e-5 + + + + + 1000140290 + + 8.0 + 2.64 + + + 0.33521e-1 ; 0.59679e-1 ; 0.20593e-1 ; -0.18646e-1 ; -0.16550e-1 ; + -0.11922e-2 ; 0.28025e-2 ; -0.67353e-4 ; -0.34619e-3 ; 0.17611e-3 ; + -0.57173e-5 ; 0.12371e-4 + + + + + 1000140300 + + 8.5 + 2.64 + + + 0.28397e-1 ; 0.54163e-1 ; 0.25167e-1 ; -0.12858e-1 ; -0.17592e-1 ; + -0.46722e-2 ; 0.24804e-2 ; 0.14760e-2 ; -0.30168e-3 ; 0.48346e-4 ; + 0.0 ; -0.51570e-5 ; 0.30261e-5 + + + + + 1000150310 + + 8.0 + 2.64 + + + 0.35305e-1 ; 0.59642e-1 ; 0.17274e-1 ; -0.19303e-1 ; 0.13545e-1 ; + 0.63209e-3 ; 0.35462e-2 ; 0.83653e-3 ; -0.47904e-3 ; 0.19099e-3 ; + -0.69611e-4 ; 0.23196e-4 ; -0.77780e-5 + + + + + 1000160320 + + 8.0 + 2.56 + + + 0.37251e-1 ; 0.60248e-1 ; 0.14748e-1 ; -0.18352e-1 ; -0.10347e-1 ; + 0.30461e-2 ; 0.35277e-2 ; -0.39834e-4 ; -0.97177e-4 ; 0.92279e-4 ; + -0.51931e-4 ; 0.22958e-4 ; -0.86609e-5 ; 0.28879e-5 ; -0.86632e-6 + + + + + 1000160340 + + 8.0 + 2.56 + + + 0.37036e-1 ; 0.58506e-1 ; 0.12082e-1 ; -0.19022e-1 ; 0.83421e-2 ; + 0.45434e-2 ; 0.28346e-2 ; -0.52304e-3 ; 0.27754e-4 ; 0.59403e-4 ; + -0.42794e-4 ; 0.20407e-4 ; -0.79934e-5 ; 0.27354e-5 ; -0.83914e-6 + + + + + 1000160360 + + 8.0 + 2.56 + + + 0.37032e-1 ; 0.57939e-1 ; 0.10049e-1 ; -0.19852e-1 ; -0.67176e-2 ; + 0.61882e-2 ; 0.37795e-2 ; -0.55272e-3 ; -0.12904e-3 ; 0.15845e-3 ; + -0.84063e-4 ; 0.34010e-4 ; -0.11663e-4 ; 0.35204e-5 ; -0.95135e-6 + + + + + 1000180400 + + 9.0 + 1.81 + + + 0.30451e-1 ; 0.55337e-1 ; 0.20203e-1 ; -0.16765e-1 ; -0.13578e-1 ; + -0.43204e-4 ; 0.91988e-3 ; -0.41205e-3 ; 0.11971e-3 ; -0.19801e-4 ; + -0.43204e-5 ; 0.61205e-5 ; -0.37803e-5 ; 0.18001e-5 ; -0.77407e-6 + + + + + 1000200400 + + 8.0 + 3.55 + + + 0.44846e-1 ; 0.61326e-1 ; -0.16818e-2 ; -0.26217e-1 ; 0.29725e-2 ; + 0.85534e-2 ; 0.35322e-2 ; -0.48258e-3 ; -0.39346e-3 ; 0.20338e-3 ; + 0.25461e-4 ; -0.17794e-4 ; 0.67394e-5 ; -0.21033e-5 + + + + + 1000200480 + + 8.0 + 3.55 + + + 0.44782e-1 ; 0.59523e-1 ; -0.74148e-2 ; -0.29466e-1 ; -0.28350e-3 ; + 0.10829e-1 ; 0.30465e-2 ; -0.10237e-2 ; -0.17830e-3 ; 0.55391e-4 ; + -0.22644e-4 ; 0.82671e-5 ; -0.27343e-5 ; 0.82461e-6 ; -0.22780e-6 + + + + + 1000220480 + + 10.0 + 2.20 + + + 0.27850e-1 ; 0.55432e-1 ; 0.26369e-1 ; -0.17091e-1 ; -0.21798e-1 ; + -0.24889e-2 ; 0.76631e-2 ; 0.34554e-2 ; -0.67471e-3 ; 0.10764e-3 ; + -0.16564e-5 ; -0.55566e-5 + + + + + 1000220500 + + 9.5 + 2.20 + + + 0.31818e-1 ; 0.58556e-1 ; 0.19637e-1 ; -0.24309e-1 ; -0.18748e-1 ; + 0.33741e-2 ; 0.89961e-2 ; 0.37954e-2 ; 0.41238e-3 ; 0.12540e-3 + + + + + 1000240500 + + 9.0 + 2.59 + + + 0.39174e-1 ; 0.61822e-1 ; 0.68550e-2 ; -0.30170e-1 ; -0.98745e-2 ; + 0.87944e-2 ; 0.68502e-2 ; -0.93609e-3 ; -0.24962e-2 ; -0.15361e-2 ; + -0.73687e-3 + + + + + 1000240520 + + 9.0 + 2.59 + + + 0.39287e-1 ; 0.62477e-1 ; 0.62482e-2 ; -0.32885e-1 ; -0.10648e-1 ; + 0.10520e-1 ; 0.85478e-2 ; -0.24003e-3 ; -0.20499e-2 ; -0.12001e-2 ; + -0.56649e-3 + + + + + 1000240540 + + 9.0 + 2.59 + + + 0.39002e-1 ; 0.60305e-1 ; 0.45845e-2 ; -0.30723e-1 ; -0.91355e-2 ; + 0.93251e-2 ; 0.60583e-2 ; -0.15602e-2 ; -0.76809e-3 ; 0.76809e-3 ; + -0.34804e-3 + + + + + 1000260540 + + 9.0 + 2.22 + + + 0.42339e-1 ; 0.64428e-1 ; 0.15840e-2 ; -0.35171e-1 ; -0.10116e-1 ; + 0.12069e-1 ; 0.62230e-2 ; -0.12045e-2 ; 0.13561e-3 ; 0.10428e-4 ; + -0.16980e-4 ; 0.91817e-5 ; 0.39988e-5 ; 0.15731e-5 ; -0.57862e-6 ; + 0.20186e-6 ; -0.67892e-7 + + + + + 1000260560 + + 9.0 + 2.22 + + + 0.42018e-1 ; 0.62337e-1 ; 0.23995e-3 ; -0.32776e-1 ; -0.79941e-2 ; + 0.10844e-1 ; 0.49123e-2 ; -0.22144e-2 ; -0.18146e-3 ; 0.37261e-3 ; + -0.23296e-3 ; 0.11494e-3 ; -0.50596e-4 ; 0.20652e-4 ; -0.79428e-5 ; + 0.28986e-5 ; -0.10075e-5 + + + + + 1000260580 + + 9.0 + 2.22 + + + 0.41791e-1 ; 0.60524e-1 ; -0.14978e-2 ; -0.31183e-1 ; -0.58013e-2 ; + 0.10611e-1 ; 0.41629e-2 ; -0.29045e-5 ; 0.54106e-3 ; 0.38689e-3 ; + 0.20514e-3 ; -0.95237e-4 ; 0.40707e-4 ; -0.16346e-1 ; 0.62233e-5 ; + 0.22568e-5 ; 0.78077e-6 + + + + + 1000270590 + + 9.0 + 2.22 + + + 0.43133e-1 ; 0.61249e-1 ; -0.32523e-2 ; -0.32681e-1 ; -0.49583e-2 ; + 0.11494e-1 ; 0.55428e-2 ; 0.31398e-3 ; 0.70578e-4 ; 0.53725e-5 ; + -0.74650e-6 ; 0.19793e-5 ; -0.28059e-5 ; 0.27183e-5 ; -0.19454e-5 ; + 0.10963e-5 ; 0.51114e-6 + + + + + 1000280580 + + 9.0 + 2.22 + + + 0.45030e-1 ; 0.65044e-1 ; -0.32843e-2 ; -0.36241e-1 ; -0.67442e-2 ; + 0.13146e-1 ; 0.50903e-2 ; -0.20787e-2 ; 0.12901e-3 ; 0.14828e-3 ; + -0.11530e-3 ; 0.60881e-4 ; -0.27676e-4 ; 0.11506e-4 ; 0.44764e-5 ; + 0.16468e-5 ; -0.57496e-6 + + + + + 1000280600 + + 9.0 + 2.22 + + + 0.44855e-1 ; 0.63476e-1 ; -0.51001e-2 ; -0.34496e-1 ; -0.43132e-2 ; + 0.12767e-1 ; 0.49935e-2 ; -0.92940e-3 ; 0.28281e-3 ; -0.76557e-4 ; + 0.18677e-4 ; 0.36855e-5 ; -0.32276e-6 ; 0.19843e-6 ; 0.16275e-6 ; + -0.82891e-7 ; -0.34896e-7 + + + + + 1000280620 + + 9.0 + 2.22 + + + 0.44581e-1 ; 0.61478e-1 ; -0.69425e-2 ; -0.33126e-1 ; -0.24964e-2 ; + 0.12674e-1 ; 0.37148e-2 ; -0.20881e-2 ; 0.30193e-3 ; 0.57573e-4 ; + -0.77965e-4 ; 0.46906e-4 ; -0.22724e-4 ; 0.98243e-5 ; -0.39250e-5 ; + 0.14732e-5 ; 0.52344e-6 + + + + + 1000280640 + + 9.0 + 2.22 + + + 0.44429e-1 ; 0.60116e-1 ; -0.92003e-2 ; -0.33452e-1 ; -0.52856e-3 ; + 0.13156e-1 ; 0.35152e-2 ; -0.21671e-2 ; 0.46497e-4 ; 0.25366e-3 ; + -0.18438e-2 ; 0.96874e-4 ; -0.44224e-4 ; 0.18493e-4 ; -0.72361e-5 ; + 0.26740e-5 ; -0.93929e-6 + + + + + 1000290630 + + 9.0 + 2.22 + + + 0.45598e-1 ; 0.60706e-1 ; -0.78616e-2 ; -0.31638e-1 ; -0.14447e-2 ; + 0.10953e-1 ; 0.42578e-2 ; -0.24224e-3 ; -0.30067e-3 ; 0.23903e-3 ; + -0.12910e-3 ; 0.60195e-4 ; -0.25755e-4 ; 0.10332e-4 ; -0.39330e-5 ; + 0.14254e-5 ; -0.49221e-6 + + + + + 1000290650 + + 9.0 + 2.22 + + + 0.45444e-1 ; 0.59544e-1 ; -0.94968e-2 ; -0.31561e-1 ; 0.22898e-3 ; + 0.11189e-1 ; 0.37360e-2 ; -0.64873e-3 ; -0.51133e-3 ; 0.43765e-3 ; + -0.24276e-3 ; 0.11507e-3 ; -0.49761e-4 ; 0.20140e-4 ; -0.76945e-5 ; + 0.28055e-5 ; -0.97411e-6 + + + + + 1000300640 + + 9.0 + 2.22 + + + 0.47038e-1 ; 0.61536e-1 ; -0.90045e-2 ; -0.30669e-1 ; -0.78705e-3 ; + 0.10034e-1 ; 0.14053e-2 ; -0.20640e-2 ; 0.35105e-3 ; 0.27303e-4 ; + -0.63811e-4 ; 0.40893e-4 ; -0.20311e-4 ; 0.88986e-5 ; -0.35849e-5 ; + 0.13522e-5 ; -0.38635e-6 + + + + + 1000300660 + + 9.0 + 2.22 + + + 0.46991e-1 ; 0.60995e-1 ; -0.96693e-2 ; -0.30457e-1 ; -0.53435e-3 ; + 0.97083e-2 ; 0.14091e-2 ; -0.70813e-3 ; 0.20809e-3 ; -0.48275e-4 ; + 0.72680e-5 ; 0.91369e-6 ; -0.14874e-5 ; 0.88831e-6 ; -0.41689e-6 ; + 0.17283e-6 ; -0.65968e-7 + + + + + 1000300680 + + 9.0 + 2.22 + + + 0.46654e-1 ; 0.58827e-1 ; -0.12283e-1 ; -0.29865e-1 ; 0.25669e-2 ; + 0.10235e-1 ; 0.31861e-2 ; -0.17351e-3 ; -0.42979e-3 ; 0.33700e-3 ; + -0.18435e-3 ; 0.87043e-4 ; -0.37612e-4 ; 0.15220e-4 ; -0.58282e-5 ; + 0.21230e-5 ; -0.73709e-6 + + + + + 1000300700 + + 9.0 + 2.22 + + + 0.46362e-1 ; 0.57130e-1 ; -0.13877e-1 ; -0.30030e-1 ; 0.35341e-2 ; + 0.10113e-1 ; 0.41029e-2 ; 0.76469e-3 ; -0.10138e-2 ; 0.60837e-3 ; + -0.29929e-3 ; 0.13329e-3 ; -0.55502e-4 ; 0.21893e-4 ; -0.82286e-5 ; + 0.29559e-5 ; -0.10148e-5 + + + + + 1000320700 + + 10.0 + 2.90 + + + 0.38182e-1 ; 0.60306e-1 ; 0.64346e-2 ; -0.29427e-1 ; -0.95888e-2 ; + 0.87849e-2 ; 0.49187e-2 ; -0.15189e-2 ; -0.17385e-2 ; -0.16794e-3 ; + -0.11746e-3 ; 0.65768e-4 ; -0.30691e-4 ; 0.13051e-5 ; -0.52251e-5 + + + + + 1000320720 + + 10.0 + 2.90 + + + 0.38083e-1 ; 0.59342e-1 ; 0.47718e-2 ; -0.29953e-1 ; -0.88476e-2 ; + 0.96205e-2 ; 0.47901e-2 ; -0.16869e-2 ; -0.15406e-2 ; -0.97230e-4 ; + -0.47640e-4 ; -0.15669e-5 ; 0.67076e-5 ; -0.44500e-5 ; 0.22158e-5 + + + + + 1000320740 + + 10.0 + 2.90 + + + 0.37989e-1 ; 0.58298e-1 ; 0.27406e-2 ; -0.30666e-1 ; -0.81505e-2 ; + 0.10231e-1 ; 0.49382e-2 ; -0.16270e-2 ; -0.13937e-2 ; 0.15476e-3 ; + 0.14396e-3 ; -0.73075e-4 ; 0.31998e-4 ; -0.12822e-4 ; 0.48406e-5 + + + + + 1000320760 + + 10.0 + 2.90 + + + 0.37951e-1 ; 0.57876e-1 ; 0.15303e-2 ; -0.31822e-1 ; -0.76875e-2 ; + 0.11237e-1 ; 0.50780e-2 ; -0.17293e-2 ; -0.15523e-2 ; 0.72439e-4 ; + 0.16560e-3 ; -0.86631e-4 ; 0.39159e-4 ; -0.16259e-4 ; 0.63681e-5 + + + + + 1000380880 + + 9.0 + 2.50 + + + 0.56435e-1 ; 0.55072e-1 ; -0.33363e-1 ; -0.26061e-1 ; 0.15749e-1 ; + 0.75233e-2 ; -0.55044e-2 ; -0.23643e-2 ; 0.39362e-3 ; -0.22733e-3 ; + 0.12519e-3 ; -0.61176e-4 ; 0.27243e-4 ; -0.11285e-4 ; 0.43997e-5 ; + -0.16248e-5 ; 0.57053e-6 + + + + + 1000400900 + + 10.0 + 2.50 + + + 0.46188e-1 ; 0.61795e-1 ; -0.12315e-1 ; -0.36915e-1 ; 0.25175e-2 ; + 0.15234e-1 ; -0.55146e-3 ; -0.60631e-2 ; -0.12198e-2 ; 0.36200e-3 ; + -0.16466e-3 ; 0.53305e-4 ; -0.50873e-5 ; -0.85658e-5 ; 0.86095e-5 + + + + + 1000400920 + + 10.0 + 2.50 + + + 0.45939e-1 ; 0.60104e-1 ; -0.13341e-1 ; -0.35106e-1 ; 0.31760e-2 ; + 0.13753e-1 ; -0.82682e-3 ; -0.53001e-2 ; -0.97579e-3 ; 0.26489e-3 ; + -0.15873e-3 ; 0.69301e-4 ; -0.22278e-4 ; 0.39533e-5 ; 0.10609e-5 + + + + + 1000400940 + + 10.0 + 2.50 + + + 0.45798e-1 ; 0.59245e-1 ; -0.13389e-1 ; -0.33252e-1 ; 0.39888e-2 ; + 0.12750e-1 ; -0.15793e-2 ; -0.56692e-2 ; -0.15698e-2 ; 0.54394e-4 ; + -0.24032e-4 ; 0.38401e-4 ; -0.31690e-4 ; 0.18481e-4 ; -0.85367e-5 + + + + + 1000420920 + + 12.0 + 1.96 + + + 0.30782e-1 ; 0.59896e-1 ; 0.22016e-1 ; -0.28945e-1 ; -0.26707e-1 ; + 0.40426e-2 ; 0.14429e-1 ; 0.31696e-2 ; -0.63061e-2 ; -0.45119e-2 ; + 0.46236e-3 ; 0.94909e-3 ; -0.38930e-3 ; -0.14808e-3 ; 0.19622e-3 ; + -0.40197e-4 ; -0.71949e-4 + + + + + 1000420940 + + 12.0 + 1.96 + + + 0.30661e-1 ; 0.58828e-1 ; 0.20396e-1 ; -0.28830e-1 ; -0.25077e-1 ; + 0.44768e-2 ; 0.13127e-1 ; 0.19548e-2 ; -0.61403e-2 ; -0.35825e-2 ; + 0.73790e-3 ; 0.61882e-3 ; -0.40556e-3 ; -0.55748e-5 ; -0.12453e-3 ; + -0.57812e-4 ; -0.21657e-4 + + + + + 1000420960 + + 12.0 + 1.96 + + + 0.30564e-1 ; 0.58013e-1 ; 0.19255e-1 ; -0.28372e-1 ; -0.23304e-1 ; + 0.49894e-2 ; 0.12126e-1 ; 0.10496e-2 ; -0.62592e-2 ; -0.32814e-2 ; + 0.89668e-3 ; 0.50636e-3 ; -0.43412e-3 ; 0.71531e-4 ; 0.76745e-4 ; + -0.54316e-4 ; 0.23386e-6 + + + + + 1000420980 + + 12.0 + 1.96 + + + 0.30483e-1 ; 0.57207e-1 ; 0.17888e-1 ; -0.28388e-1 ; -0.21778e-1 ; + 0.56780e-2 ; 0.11236e-1 ; 0.82176e-3 ; -0.50390e-2 ; -0.23877e-2 ; + 0.71492e-3 ; 0.29839e-3 ; -0.31408e-3 ; 0.80177e-3 ; 0.43682e-4 ; + -0.51394e-4 ; 0.22293e-4 + + + + + 1000421000 + + 12.0 + 1.96 + + + 0.30353e-1 ; 0.56087e-1 ; 0.16057e-1 ; -0.28767e-1 ; -0.20683e-1 ; + 0.62429e-2 ; 0.11058e-1 ; 0.11502e-2 ; -0.39395e-2 ; -0.14978e-2 ; + 0.76350e-3 ; 0.10554e-3 ; -0.25658e-3 ; 0.10964e-3 ; 0.10015e-4 ; + -0.40341e-4 ; 0.25744e-4 + + + + + 1000461040 + + 11.0 + 2.38 + + + 0.41210e-1 ; 0.62846e-1 ; -0.21202e-2 ; -0.38359e-1 ; -0.44693e-2 ; + 0.16656e-1 ; 0.36873e-2 ; -0.57534e-2 ; -0.32499e-2 ; 0.69844e-3 ; + 0.16304e-2 ; 0.59882e-3 + + + + + 1000461060 + + 11.0 + 2.38 + + + 0.41056e-1 ; 0.61757e-1 ; -0.29891e-2 ; -0.37356e-1 ; -0.35348e-2 ; + 0.16085e-1 ; 0.28502e-2 ; -0.55764e-2 ; -0.15433e-2 ; 0.22281e-2 ; + 0.13160e-2 ; 0.16508e-4 + + + + + 1000461080 + + 11.0 + 2.38 + + + 0.40754e-1 ; 0.59460e-1 ; -0.54077e-2 ; -0.36305e-1 ; -0.21987e-2 ; + 0.15418e-1 ; 0.25927e-2 ; -0.52781e-2 ; -0.19757e-2 ; 0.10339e-2 ; + 0.22891e-3 ; -0.33464e-3 + + + + + 1000461100 + + 11.0 + 2.40 + + + 0.40668e-1 ; 0.58793e-1 ; -0.61375e-2 ; -0.35983e-1 ; -0.17447e-2 ; + 0.14998e-1 ; 0.19994e-2 ; -0.53170e-2 ; -0.14289e-2 ; 0.16033e-2 ; + 0.31574e-3 ; -0.42195e-3 + + + + + 1000621440 + + 9.25 + 2.50 + + + 0.74734e-1 ; 0.26145e-1 ; -0.63832e-1 ; 0.10432e-1 ; 0.19183e-1 ; + -0.12572e-1 ; -0.39707e-2 ; -0.18703e-2 ; 0.12602e-2 ; -0.11902e-2 ; + -0.15703e-2 + + + + + 1000621480 + + 9.25 + 2.50 + + + 0.73859e-1 ; 0.24023e-1 ; -0.59437e-1 ; 0.10761e-1 ; 0.17022e-1 ; + -0.11401e-1 ; -0.18102e-2 ; 0.93011e-3 ; 0.98012e-3 ; -0.12601e-2 ; + -0.17402e-2 + + + + + 1000621500 + + 9.25 + 2.50 + + + 0.73338e-1 ; 0.24626e-1 ; -0.52773e-1 ; 0.10582e-1 ; 0.15353e-1 ; + -0.95624e-2 ; -0.18804e-2 ; -0.79019e-3 ; 0.10102e-2 ; -0.26606e-2 ; + -0.18304e-2 + + + + + 1000621520 + + 9.25 + 2.50 + + + 0.72646e-1 ; 0.21824e-1 ; -0.54112e-1 ; 0.98321e-2 ; 0.16213e-1 ; + -0.65614e-2 ; 0.53611e-2 ; -0.14103e-2 ; -0.99022e-3 ; -0.23005e-2 + + + + + 1000621540 + + 10.5 + 2.18 + + + 0.55859e-1 ; 0.44002e-1 ; -0.40342e-1 ; -0.17989e-1 ; 0.19817e-1 ; + 0.51643e-2 ; -0.60212e-2 ; -0.23127e-2 ; 0.47024e-3 + + + + + + 1000641540 + + 10.0 + 2.17 + + + 0.63832e-1 ; 0.36983e-1 ; -0.48193e-1 ; -0.51046e-2 ; 0.19805e-1 ; + -0.82574e-3 ; -0.46942e-2 + + + + + 1000641580 + + 10.5 + 2.17 + + + 0.57217e-1 ; 0.43061e-1 ; -0.41996e-1 ; -0.17203e-1 ; 0.19933e-1 ; + 0.51060e-2 ; -0.73665e-2 ; -0.20926e-2 ; 0.21883e-2 + + + + + 1000681660 + + 11.0 + 2.28 + + + 0.54426e-1 ; 0.47165e-1 ; -0.38654e-1 ; -0.19672e-1 ; 0.22092e-1 ; + 0.78708e-2 ; -0.53005e-2 ; 0.50005e-3 ; 0.52005e-3 ; -0.35003e-3 ; + 0.12001e-3 + + + + + 1000701740 + + 11.0 + 2.33 + + + 0.54440e-1 ; 0.40034e-1 ; -0.45606e-1 ; -0.20932e-1 ; 0.20455e-1 ; + 0.27061e-2 ; -0.60489e-2 ; -0.15918e-3 ; 0.11938e-2 + + + + + 1000711750 + + 11.0 + 2.33 + + + 0.55609e-1 ; 0.42243e-1 ; -0.45028e-1 ; -0.19491e-1 ; 0.22514e-1 ; + 0.38982e-2 ; -0.72395e-2 ; 0.31822e-3 ; -0.23866e-3 + + + + + 1000761920 + + 11.0 + 2.90 + + + 0.59041e-1 ; 0.41498e-1 ; -0.49900e-1 ; -0.10183e-1 ; 0.29067e-1 ; + -0.57382e-2 ; -0.92348e-2 ; 0.36170e-2 ; 0.28736e-2 ; 0.24194e-3 ; + -0.16766e-2 ; 0.73610e-3 + + + + + 1000781960 + + 12.0 + 2.28 + + + 0.50218e-1 ; 0.53722e-1 ; -0.35015e-1 ; -0.34588e-1 ; 0.23564e-1 ; + 0.14340e-1 ; -0.13270e-1 ; -0.51212e-2 ; 0.56088e-2 ; 0.14890e-2 ; + -0.10928e-2 ; 0.55662e-3 ; -0.50557e-4 ; -0.19708e-3 ; 0.24016e-3 + + + + + 1000812030 + + 12.0 + 2.24 + + + 0.51568e-1 ; 0.51562e-1 ; -0.39299e-1 ; -0.30826e-1 ; 0.27491e-1 ; + 0.10795e-1 ; -0.15922e-1 ; -0.25527e-2 ; 0.58548e-2 ; 0.19324e-3 ; + -0.17925e-3 ; 0.14307e-3 ; -0.91669e-4 ; 0.53497e-4 ; -0.29492e-4 ; + 0.15625e-4 ; -0.80141e-5 + + + + + 1000812050 + + 12.0 + 2.24 + + + 0.51518e-1 ; 0.51165e-1 ; -0.39559e-1 ; -0.30118e-1 ; 0.27600e-1 ; + 0.10412e-1 ; -0.15725e-1 ; -0.26546e-2 ; 0.70184e-2 ; 0.82116e-3 ; + -0.51805e-3 ; 0.32560e-3 ; -0.18670e-3 ; 0.10202e-3 ; -0.53857e-4 ; + 0.27672e-4 ; -0.13873e-4 + + + + + 1000822040 + + 12.0 + 2.24 + + + 0.52102e-1 ; 0.51786e-1 ; -0.39188e-1 ; -0.29242e-1 ; 0.28992e-1 ; + 0.11040e-1 ; -0.14591e-1 ; -0.94917e-3 ; 0.71349e-2 ; 0.24780e-3 ; + -0.61656e-3 ; 0.42335e-3 ; -0.25250e-3 ; 0.14106e-3 ; -0.75446e-4 ; + 0.39143e-4 ; -0.19760e-4 + + + + + 1000822060 + + 12.0 + 2.24 + + + 0.52019e-1 ; 0.51190e-1 ; -0.39459e-1 ; -0.28405e-1 ; 0.28862e-1 ; + 0.10685e-1 ; -0.14550e-1 ; -0.13519e-2 ; 0.77624e-2 ; -0.41882e-4 ; + -0.97010e-3 ; 0.69611e-3 ; -0.42410e-3 ; 0.23857e-3 ; -0.12828e-3 ; + 0.66663e-4 ; -0.33718e-4 + + + + + 1000822070 + + 12.0 + 2.24 + + + 0.51981e-1 ; 0.51059e-1 ; -0.39447e-1 ; -0.28428e-1 ; 0.28988e-1 ; + 0.10329e-1 ; -0.14029e-1 ; -0.46728e-3 ; 0.67984e-2 ; 0.56905e-3 ; + -0.50430e-3 ; 0.32796e-3 ; -0.19157e-3 ; 0.10565e-3 ; -0.56200e-4 ; + 0.29020e-4 ; -0.14621e-4 + + + + + 1000822080 + + 11.0 + 2.24 + + + 0.62732e-1 ; 0.38542e-1 ; -0.55105e-1 ; -0.26990e-2 ; 0.31016e-1 ; + -0.99486e-2 ; -0.93012e-2 ; 0.76653e-2 ; 0.20885e-2 ; -0.17840e-2 ; + 0.74876e-4 ; 0.32278e-3 ; -0.11353e-3 + + + + + 1000832090 + + 12.0 + 2.24 + + + 0.52448e-1 ; 0.50400e-1 ; -0.41014e-1 ; -0.27927e-2 ; 0.29587e-1 ; + 0.98017e-2 ; -0.14930e-1 ; -0.31967e-3 ; 0.77252e-2 ; 0.57533e-3 ; + -0.82529e-3 ; 0.25728e-3 ; -0.11043e-3 ; 0.51930e-4 ; -0.24767e-4 ; + 0.11863e-4 ; -0.56554e-5 + + + + diff --git a/config/DeVriesFormFactorMap.xml b/config/DeVriesFormFactorMap.xml new file mode 100644 index 000000000..d853c0b9f --- /dev/null +++ b/config/DeVriesFormFactorMap.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + genie::DeVriesFormFactor/12C ; + genie::DeVriesFormFactor/15N ; + genie::DeVriesFormFactor/16O ; + genie::DeVriesFormFactor/27Al ; + genie::DeVriesFormFactor/28Si ; + genie::DeVriesFormFactor/29Si ; + genie::DeVriesFormFactor/30Si ; + genie::DeVriesFormFactor/31P ; + genie::DeVriesFormFactor/32S ; + genie::DeVriesFormFactor/34S ; + genie::DeVriesFormFactor/36S ; + genie::DeVriesFormFactor/40Ar ; + genie::DeVriesFormFactor/40Ca ; + genie::DeVriesFormFactor/48Ca ; + genie::DeVriesFormFactor/48Ti ; + genie::DeVriesFormFactor/50Ti ; + genie::DeVriesFormFactor/50Cr ; + genie::DeVriesFormFactor/52Cr ; + genie::DeVriesFormFactor/54Cr ; + genie::DeVriesFormFactor/54Fe ; + genie::DeVriesFormFactor/56Fe ; + genie::DeVriesFormFactor/58Fe ; + genie::DeVriesFormFactor/59Co ; + genie::DeVriesFormFactor/58Ni ; + genie::DeVriesFormFactor/60Ni ; + genie::DeVriesFormFactor/62Ni ; + genie::DeVriesFormFactor/64Ni ; + genie::DeVriesFormFactor/63Cu ; + genie::DeVriesFormFactor/65Cu ; + genie::DeVriesFormFactor/64Zn ; + genie::DeVriesFormFactor/66Zn ; + genie::DeVriesFormFactor/68Zn ; + genie::DeVriesFormFactor/70Zn ; + genie::DeVriesFormFactor/70Ge ; + genie::DeVriesFormFactor/72Ge ; + genie::DeVriesFormFactor/74Ge ; + genie::DeVriesFormFactor/76Ge ; + genie::DeVriesFormFactor/88Sr ; + genie::DeVriesFormFactor/90Zr ; + genie::DeVriesFormFactor/92Zr ; + genie::DeVriesFormFactor/94Zr ; + genie::DeVriesFormFactor/92Mo ; + genie::DeVriesFormFactor/94Mo ; + genie::DeVriesFormFactor/96Mo ; + genie::DeVriesFormFactor/98Mo ; + genie::DeVriesFormFactor/100Mo ; + genie::DeVriesFormFactor/104Pd ; + genie::DeVriesFormFactor/106Pd ; + genie::DeVriesFormFactor/108Pd ; + genie::DeVriesFormFactor/110Pd ; + genie::DeVriesFormFactor/144Sm ; + genie::DeVriesFormFactor/148Sm ; + genie::DeVriesFormFactor/150Sm ; + genie::DeVriesFormFactor/152Sm ; + genie::DeVriesFormFactor/154Sm ; + genie::DeVriesFormFactor/154Gd ; + genie::DeVriesFormFactor/158Gd ; + genie::DeVriesFormFactor/166Er ; + genie::DeVriesFormFactor/174Yb ; + genie::DeVriesFormFactor/175Lu ; + genie::DeVriesFormFactor/192Os ; + genie::DeVriesFormFactor/196Pt ; + genie::DeVriesFormFactor/203Tl ; + genie::DeVriesFormFactor/205Tl ; + genie::DeVriesFormFactor/204Pb ; + genie::DeVriesFormFactor/206Pb ; + genie::DeVriesFormFactor/207Pb ; + genie::DeVriesFormFactor/208Pb ; + genie::DeVriesFormFactor/209Bi + + + + + diff --git a/config/DeltaInMediumCorrections.xml b/config/DeltaInMediumCorrections.xml new file mode 100644 index 000000000..77d5d7708 --- /dev/null +++ b/config/DeltaInMediumCorrections.xml @@ -0,0 +1,42 @@ + + + + + + + + + NUCL + + 0.08 + 0.17 + 2.14 + + + + + + + FermiGas,NUCL + + + + + + diff --git a/config/DeltaTransitionFormFactor.xml b/config/DeltaTransitionFormFactor.xml new file mode 100644 index 000000000..e99479729 --- /dev/null +++ b/config/DeltaTransitionFormFactor.xml @@ -0,0 +1,37 @@ + + + + + + + + + WeakInt,Resonances + + 0.93 + 0.3 + 0.01 + 0.23 + 0.71 + + + + + + diff --git a/config/EventGenerator.xml b/config/EventGenerator.xml index d1a418a16..e63a6d78b 100644 --- a/config/EventGenerator.xml +++ b/config/EventGenerator.xml @@ -555,19 +555,30 @@ XSecModel alg Yes Cross section model used at the thread 6 genie::InitialStateAppender/Default genie::VertexGenerator/Default - genie::COHKinematicsGenerator/Default + genie::COHPionKinematicsGenerator/Default genie::COHPrimaryLeptonGenerator/Default genie::COHHadronicSystemGenerator/Default genie::UnstableParticleDecayer/AfterHadronTransport genie::COHInteractionListGenerator/NC-PION + + + 5 + genie::InitialStateAppender/Default + genie::VertexGenerator/Default + genie::COHGammaKinematicsGenerator/Default + genie::COHPrimaryLeptonGenerator/Default + genie::COHHadronicSystemGenerator/Default + genie::COHInteractionListGenerator/NC-GAMMA + + 6 genie::InitialStateAppender/Default genie::VertexGenerator/Default - genie::COHKinematicsGenerator/Default + genie::COHPionKinematicsGenerator/Default genie::COHPrimaryLeptonGenerator/Default genie::COHHadronicSystemGenerator/Default genie::UnstableParticleDecayer/AfterHadronTransport diff --git a/config/EventGeneratorListAssembler.xml b/config/EventGeneratorListAssembler.xml index 30a19530f..cb219cc34 100644 --- a/config/EventGeneratorListAssembler.xml +++ b/config/EventGeneratorListAssembler.xml @@ -185,14 +185,35 @@ Generator-%d alg No genie::EventGenerator/RES-NC + + + + + 3 + genie::EventGenerator/COH-CC-PION + genie::EventGenerator/COH-NC-PION + genie::EventGenerator/COH-NC-GAMMA + + + + 1 + genie::EventGenerator/COH-CC-PION + + + + 2 + genie::EventGenerator/COH-NC-PION + genie::EventGenerator/COH-NC-GAMMA + + - 2 + 2 genie::EventGenerator/COH-CC-PION genie::EventGenerator/COH-NC-PION - 1 + 1 genie::EventGenerator/COH-CC-PION @@ -201,6 +222,12 @@ Generator-%d alg No genie::EventGenerator/COH-NC-PION + + 1 + genie::EventGenerator/COH-NC-GAMMA + + + 2 genie::EventGenerator/DIS-CC @@ -218,13 +245,14 @@ Generator-%d alg No - 6 + 7 genie::EventGenerator/QEL-NC genie::EventGenerator/RES-NC genie::EventGenerator/DIS-NC - genie::EventGenerator/COH-NC-PION - genie::EventGenerator/MEC-NC - genie::EventGenerator/DFR-NC + genie::EventGenerator/COH-NC-PION + genie::EventGenerator/COH-NC-GAMMA + genie::EventGenerator/MEC-NC + genie::EventGenerator/DFR-NC diff --git a/config/G18_02a/ModelConfiguration.xml b/config/G18_02a/ModelConfiguration.xml index c77a4c844..d0ba19232 100644 --- a/config/G18_02a/ModelConfiguration.xml +++ b/config/G18_02a/ModelConfiguration.xml @@ -111,13 +111,13 @@ STFC, Rutherford Appleton Laboratory genie::BergerSehgalCOHPiPXSec2015/Default genie::BergerSehgalCOHPiPXSec2015/Default + - - - + + genie::BardinIMDRadCorPXSec/Default genie::IMDAnnihilationPXSec/Default genie::NuElectronPXSec/Default diff --git a/config/G18_02a/TuneGeneratorList.xml b/config/G18_02a/TuneGeneratorList.xml index 938e22406..57b3599fa 100644 --- a/config/G18_02a/TuneGeneratorList.xml +++ b/config/G18_02a/TuneGeneratorList.xml @@ -54,8 +54,8 @@ Generator-%d alg No genie::EventGenerator/RES-NC genie::EventGenerator/DIS-CC genie::EventGenerator/DIS-NC - genie::EventGenerator/COH-CC-PION - genie::EventGenerator/COH-NC-PION + genie::EventGenerator/COH-CC-PION + genie::EventGenerator/COH-NC-PION genie::EventGenerator/DIS-CC-CHARM genie::EventGenerator/QEL-CC-CHARM genie::EventGenerator/NUE-EL diff --git a/config/Messenger.xml b/config/Messenger.xml index 52b6ff705..9a5d31caf 100644 --- a/config/Messenger.xml +++ b/config/Messenger.xml @@ -59,7 +59,7 @@ NOTICE NOTICE NOTICE - NOTICE + INFO NOTICE WARN WARN @@ -204,7 +204,7 @@ WARN NOTICE NOTICE - WARN + NOTICE NOTICE WARN WARN diff --git a/config/master_config.xml b/config/master_config.xml index 4ff4ad940..2263ca3fa 100644 --- a/config/master_config.xml +++ b/config/master_config.xml @@ -2,6 +2,105 @@ + + EventGenerator.xml + FermiMover.xml + HadronTransporter.xml + HAIntranuke.xml + HAIntranuke2018.xml + HNIntranuke2018.xml + HINCLCascadeIntranuke.xml + HG4BertCascIntranuke.xml + CascadeReweight.xml + UnstableParticleDecayer.xml + PauliBlocker.xml + NucDeExcitationSim.xml + NucBindEnergyAggregator.xml + InitialStateAppender.xml + VertexGenerator.xml + QELEventGenerator.xml + QELEventGeneratorSM.xml + DMELEventGenerator.xml + IBDPrimaryLeptonGenerator.xml + QELPrimaryLeptonGenerator.xml + DISPrimaryLeptonGenerator.xml + RESPrimaryLeptonGenerator.xml + NuEPrimaryLeptonGenerator.xml + DMEOutgoingDarkGenerator.xml + COHPrimaryLeptonGenerator.xml + DFRPrimaryLeptonGenerator.xml + SKPrimaryLeptonGenerator.xml + DMELOutgoingDarkGenerator.xml + DMDISOutgoingDarkGenerator.xml + IBDKinematicsGenerator.xml + QELKinematicsGenerator.xml + DISKinematicsGenerator.xml + RESKinematicsGenerator.xml + NuEKinematicsGenerator.xml + DMEKinematicsGenerator.xml + COHPionKinematicsGenerator.xml + COHGammaKinematicsGenerator.xml + DFRKinematicsGenerator.xml + SKKinematicsGenerator.xml + DMELKinematicsGenerator.xml + DMDISKinematicsGenerator.xml + HELeptonKinematicsGenerator.xml + HEDISKinematicsGenerator.xml + IBDHadronicSystemGenerator.xml + QELHadronicSystemGenerator.xml + COHHadronicSystemGenerator.xml + DFRHadronicSystemGenerator.xml + DISHadronicSystemGenerator.xml + RESHadronicSystemGenerator.xml + RSPPHadronicSystemGenerator.xml + SKHadronicSystemGenerator.xml + NuETargetRemnantGenerator.xml + DMETargetRemnantGenerator.xml + RSPPResonanceSelector.xml + AMNuGammaGenerator.xml + MECGenerator.xml + GLRESGenerator.xml + HEDISGenerator.xml + HENuElGenerator.xml + PhotonCOHGenerator.xml + PhotonRESGenerator.xml + CEvNSEventGenerator.xml + COHDNuEventGenerator.xml + QELEventGeneratorSuSA.xml + NucleonDecayPrimaryVtxGenerator.xml + NNBarOscPrimaryVtxGenerator.xml + SpectralFunction2p2h.xml + SRCNuclearRecoil.xml + BeamHNLGenerator.xml + BeamHNLGenerator.xml + BeamHNLGenerator.xml + BeamHNLGenerator.xml + + + QELInteractionListGenerator.xml + RSPPInteractionListGenerator.xml + RESInteractionListGenerator.xml + DISInteractionListGenerator.xml + NuEInteractionListGenerator.xml + DMEInteractionListGenerator.xml + COHInteractionListGenerator.xml + AMNuGammaInteractionListGenerator.xml + MECInteractionListGenerator.xml + HELeptonInteractionListGenerator.xml + DFRInteractionListGenerator.xml + SKInteractionListGenerator.xml + DMELInteractionListGenerator.xml + DMDISInteractionListGenerator.xml + IBDInteractionListGenerator.xml + CEvNSInteractionListGenerator.xml + COHDNuInteractionListGenerator.xml + HEDISInteractionListGenerator.xml + Default.xml + Default.xml + Default.xml + InteractionListAssembler.xml + EventGeneratorListAssembler.xml +======= EventGenerator.xml FermiMover.xml @@ -100,168 +199,176 @@ InteractionListAssembler.xml EventGeneratorListAssembler.xml - - PhysInteractionSelector.xml - ToyInteractionSelector.xml + + PhysInteractionSelector.xml + ToyInteractionSelector.xml - - PetersonFragm.xml - CollinsSpillerFragm.xml + + PetersonFragm.xml + CollinsSpillerFragm.xml - - AGKYLowW2019.xml - AGKY2019.xml - Pythia6Hadro2019.xml - Pythia8Hadro2019.xml - AGCharm2019.xml - LeptoHadronization.xml + + AGKYLowW2019.xml + AGKY2019.xml + Pythia6Hadro2019.xml + Pythia8Hadro2019.xml + AGCharm2019.xml + LeptoHadronization.xml - - GRV98LO.xml - LHAPDF6.xml - LHAPDF5.xml - BYPDF.xml + + GRV98LO.xml + LHAPDF6.xml + LHAPDF5.xml + BYPDF.xml - - PythiaDecayer.xml - BaryonResonanceDecayer.xml - DarkSectorDecayer.xml + + PythiaDecayer.xml + BaryonResonanceDecayer.xml + DarkSectorDecayer.xml - - DipoleELFormFactorsModel.xml - BBA03ELFormFactorsModel.xml - BBA05ELFormFactorsModel.xml - BBA07ELFormFactorsModel.xml - DipoleAxialFormFactorModel.xml - ZExpAxialFormFactorModel.xml - KuzminNaumov2016AxialFormFactorModel.xml - LwlynSmithFFCC.xml - LwlynSmithFFDeltaS.xml - TransverseEnhancementFFModel.xml - LwlynSmithFFNC.xml - QPMDISStrucFunc.xml - BYStrucFunc.xml - RSHelicityAmplModelCC.xml - RSHelicityAmplModelNCp.xml - RSHelicityAmplModelNCn.xml - RSHelicityAmplModelEMp.xml - RSHelicityAmplModelEMn.xml - EngelFormFactor.xml + + DipoleELFormFactorsModel.xml + BBA03ELFormFactorsModel.xml + BBA05ELFormFactorsModel.xml + BBA07ELFormFactorsModel.xml + DipoleAxialFormFactorModel.xml + ZExpAxialFormFactorModel.xml + KuzminNaumov2016AxialFormFactorModel.xml + LwlynSmithFFCC.xml + LwlynSmithFFDeltaS.xml + TransverseEnhancementFFModel.xml + LwlynSmithFFNC.xml + QPMDISStrucFunc.xml + BYStrucFunc.xml + RSHelicityAmplModelCC.xml + RSHelicityAmplModelNCp.xml + RSHelicityAmplModelNCn.xml + RSHelicityAmplModelEMp.xml + RSHelicityAmplModelEMn.xml + DeVriesFormFactor.xml + DeVriesFormFactorMap.xml + COHProtonFormFactorInterpolation.xml + COHDeltaCurrent.xml + DeltaInMediumCorrections.xml + DeltaTransitionFormFactor.xml + DeltaInMediumCorrections.xml + EngelFormFactor.xml + + QELXSec.xml + NewQELXSec.xml + SmithMonizQELCCXSec.xml + DISXSec.xml + COHDNuXSec.xml + COHXSec.xml + COHXSecAR.xml + CEvNSXSec.xml + DFRXSec.xml + AlamSimoAtharVacasSKXSec.xml + IMDXSec.xml + RESXSec.xml + MECXSec.xml + NuElectronXSec.xml + DMElectronXSec.xml + DMELXSec.xml + DMDISXSec.xml + HELeptonXSec.xml + HEDISXSec.xml + COHGammaIntegrationLimits.xml + BostedChristyEMPXSec.xml - - QELXSec.xml - NewQELXSec.xml - SmithMonizQELCCXSec.xml - DISXSec.xml - COHDNuXSec.xml - COHXSec.xml - COHXSecAR.xml - CEvNSXSec.xml - DFRXSec.xml - AlamSimoAtharVacasSKXSec.xml - IMDXSec.xml - RESXSec.xml - MECXSec.xml - NuElectronXSec.xml - DMElectronXSec.xml - DMELXSec.xml - DMDISXSec.xml - HELeptonXSec.xml - HEDISXSec.xml - BostedChristyEMPXSec.xml + + AhrensNCELPXSec.xml + AhrensDMELPXSec.xml + AlvarezRusoCOHPiPXSec.xml + AlvarezRusoSalaCOHGammaPXSec.xml + BergerSehgalCOHPiPXSec2015.xml + BergerSehgalFMCOHPiPXSec2015.xml + BertuzzoDNuCOHPXSec.xml + LwlynSmithQELCCPXSec.xml + NievesQELCCPXSec.xml + SuSAv2QELPXSec.xml + SmithMonizQELCCPXSec.xml + QPMDMDISPXSec.xml + QPMDISPXSec.xml + KNOTunedQPMDISPXSec.xml + AivazisCharmPXSecLO.xml + SlowRsclCharmDISPXSecLO.xml + KovalenkoQELCharmPXSec.xml + PaisQELLambdaPXSec.xml + AlamSimoAtharVacasSKPXSec2014.xml + P33PaschosLalakulichPXSec.xml + BardinIMDRadCorPXSec.xml + IMDAnnihilationPXSec.xml + IBDXSecMap.xml + StrumiaVissaniIBDPXSec.xml + KLVOxygenIBDPXSec.xml + PattonCEvNSPXSec.xml + NuElectronPXSec.xml + DMElectronPXSec.xml + GLRESPXSec.xml + HENuElPXSec.xml + PhotonCOHPXSec.xml + PhotonRESPXSec.xml + BergerSehgalRESPXSec2014.xml + KuzminLyubushkinNaumovRESPXSec2014.xml + ReinDFRPXSec.xml + ReinSehgalCOHPiPXSec.xml + ReinSehgalRESPXSec.xml + ReinSehgalSPPPXSec.xml + ReinSehgalRESXSec.xml + ReinSehgalSPPXSec.xml + H3AMNuGammaPXSec.xml + EmpiricalMECPXSec2015.xml + NievesSimoVacasMECPXSec2016.xml + SuSAv2MECPXSec.xml + RosenbluthPXSec.xml + Default.xml + Default.xml + Default.xml + ReinSehgalRESXSecFast.xml + BertuzzoDNuCOHPXSec.xml + HybridXSecAlgorithm.xml + HEDISPXSec.xml + XSecScaleMap.xml + MECScaleVsW.xml + XSecLinearCombinations.xml + QvalueShifter.xml - - AhrensNCELPXSec.xml - AhrensDMELPXSec.xml - AlvarezRusoCOHPiPXSec.xml - BergerSehgalCOHPiPXSec2015.xml - BergerSehgalFMCOHPiPXSec2015.xml - BertuzzoDNuCOHPXSec.xml - LwlynSmithQELCCPXSec.xml - NievesQELCCPXSec.xml - SuSAv2QELPXSec.xml - SmithMonizQELCCPXSec.xml - QPMDMDISPXSec.xml - QPMDISPXSec.xml - KNOTunedQPMDISPXSec.xml - AivazisCharmPXSecLO.xml - SlowRsclCharmDISPXSecLO.xml - KovalenkoQELCharmPXSec.xml - PaisQELLambdaPXSec.xml - AlamSimoAtharVacasSKPXSec2014.xml - P33PaschosLalakulichPXSec.xml - BardinIMDRadCorPXSec.xml - IMDAnnihilationPXSec.xml - IBDXSecMap.xml - StrumiaVissaniIBDPXSec.xml - KLVOxygenIBDPXSec.xml - PattonCEvNSPXSec.xml - NuElectronPXSec.xml - DMElectronPXSec.xml - GLRESPXSec.xml - HENuElPXSec.xml - PhotonCOHPXSec.xml - PhotonRESPXSec.xml - BergerSehgalRESPXSec2014.xml - KuzminLyubushkinNaumovRESPXSec2014.xml - ReinDFRPXSec.xml - ReinSehgalCOHPiPXSec.xml - ReinSehgalRESPXSec.xml - ReinSehgalSPPPXSec.xml - ReinSehgalRESXSec.xml - ReinSehgalSPPXSec.xml - H3AMNuGammaPXSec.xml - EmpiricalMECPXSec2015.xml - NievesSimoVacasMECPXSec2016.xml - SuSAv2MECPXSec.xml - RosenbluthPXSec.xml - Default.xml - Default.xml - Default.xml - ReinSehgalRESXSecFast.xml - BertuzzoDNuCOHPXSec.xml - HybridXSecAlgorithm.xml - HEDISPXSec.xml - XSecScaleMap.xml - MECScaleVsW.xml - XSecLinearCombinations.xml - QvalueShifter.xml + + NuclearModelMap.xml + FGMBodekRitchie.xml + LocalFGM.xml + EffectiveSF.xml + SpectralFunc1d.xml + SpectralFunc.xml + SmithMonizUtils.xml - - NuclearModelMap.xml - FGMBodekRitchie.xml - LocalFGM.xml - EffectiveSF.xml - SpectralFunc1d.xml - SpectralFunc.xml - SmithMonizUtils.xml + + BetheBlochModel.xml + BezrukovBugaevModel.xml + KokoulinPetrukhinModel.xml + PetrukhinShestakovModel.xml - - BetheBlochModel.xml - BezrukovBugaevModel.xml - KokoulinPetrukhinModel.xml - PetrukhinShestakovModel.xml - - - IBDHadronicSystemGenerator.xml - IBDKinematicsGenerator.xml - IBDPrimaryLeptonGenerator.xml - IBDXSecMap.xml - IBDInteractionListGenerator.xml - StrumiaVissaniIBDPXSec.xml - KLVOxygenIBDPXSec.xml + + IBDHadronicSystemGenerator.xml + IBDKinematicsGenerator.xml + IBDPrimaryLeptonGenerator.xml + IBDXSecMap.xml + IBDInteractionListGenerator.xml + StrumiaVissaniIBDPXSec.xml + KLVOxygenIBDPXSec.xml - - NievesMECHadronTensorModel.xml - SuSAv2QELHadronTensorModel.xml - SuSAv2MECHadronTensorModel.xml + + NievesMECHadronTensorModel.xml + SuSAv2QELHadronTensorModel.xml + SuSAv2MECHadronTensorModel.xml - - GSystUncertaintyTable.xml + + GSystUncertaintyTable.xml - - EventLibraryInterface.xml - EvtLibInteractionListGenerator.xml - EvtLibPXSec.xml + + EventLibraryInterface.xml + EvtLibInteractionListGenerator.xml + EvtLibPXSec.xml diff --git a/src/Apps/gSplineXml2Root.cxx b/src/Apps/gSplineXml2Root.cxx index 29249200c..cd84b088a 100644 --- a/src/Apps/gSplineXml2Root.cxx +++ b/src/Apps/gSplineXml2Root.cxx @@ -22,11 +22,8 @@ -t the target pdg code (format: 10LZZZAAAI) -e - the minimum and maximum energy (in generated plots -- use it to zoom at low E) - -o - output ROOT file name - -w - write out plots in a postscipt file + the minimum and maximum energy (in generated plots -- use it to +zoom at low E) -o output ROOT file name -w write out plots in a postscipt file -l energy bins in log10 scale -k @@ -54,12 +51,11 @@ Important Note: The stored graphs can be used for cross section interpolation. - Essentially, this _single_ ROOT file can contain _all_ the GENIE cross - section `functions' you may need. - For instance, the `xsec.root' file generated in the above example will - contain a `nu_mu_O16' directory (generated by the last command) - which will include cross section graphs for all numu + O16 processes. - To extract the numu+O16 DIS CC cross section graph for hit u valence + Essentially, this _single_ ROOT file can contain _all_ the GENIE +cross section `functions' you may need. For instance, the `xsec.root' file +generated in the above example will contain a `nu_mu_O16' directory (generated +by the last command) which will include cross section graphs for all numu + O16 +processes. To extract the numu+O16 DIS CC cross section graph for hit u valence quarks in a bound proton and evaluate the cross section at energy E, then type: @@ -80,86 +76,85 @@ //____________________________________________________________________________ #include -#include #include +#include #include -#include -#include -#include -#include -#include #include -#include +#include +#include #include +#include +#include #include +#include #include -#include +#include +#include -#include "Framework/ParticleData/BaryonResonance.h" -#include "Framework/ParticleData/BaryonResUtils.h" -#include "Framework/Conventions/XmlParserStatus.h" -#include "Framework/Conventions/Units.h" +#include "Framework/Algorithm/AlgConfigPool.h" #include "Framework/Conventions/Controls.h" -#include "Framework/EventGen/InteractionList.h" +#include "Framework/Conventions/Units.h" +#include "Framework/Conventions/XmlParserStatus.h" #include "Framework/EventGen/GEVGDriver.h" +#include "Framework/EventGen/InteractionList.h" #include "Framework/Interaction/Interaction.h" #include "Framework/Messenger/Messenger.h" #include "Framework/Numerical/Spline.h" -#include "Framework/ParticleData/PDGCodes.h" +#include "Framework/ParticleData/BaryonResUtils.h" +#include "Framework/ParticleData/BaryonResonance.h" #include "Framework/ParticleData/PDGCodeList.h" -#include "Framework/ParticleData/PDGUtils.h" +#include "Framework/ParticleData/PDGCodes.h" #include "Framework/ParticleData/PDGLibrary.h" +#include "Framework/ParticleData/PDGUtils.h" +#include "Framework/Registry/Registry.h" #include "Framework/Utils/AppInit.h" +#include "Framework/Utils/CmdLnArgParser.h" #include "Framework/Utils/RunOpt.h" -#include "Framework/Utils/XSecSplineList.h" #include "Framework/Utils/StringUtils.h" -#include "Framework/Utils/CmdLnArgParser.h" -#include "Framework/Registry/Registry.h" -#include "Framework/Algorithm/AlgConfigPool.h" - +#include "Framework/Utils/XSecSplineList.h" +using std::ostringstream; using std::string; using std::vector; -using std::ostringstream; using namespace genie; using namespace genie::utils; -//Prototypes: -void LoadSplines (void); -GEVGDriver GetEventGenDriver (void); -void SaveToPsFile (void); -void SaveGraphsToRootFile (void); -void SaveNtupleToRootFile (void); -void GetCommandLineArgs (int argc, char ** argv); -void PrintSyntax (void); +// Prototypes: +void LoadSplines(void); +GEVGDriver GetEventGenDriver(void); +void SaveToPsFile(void); +void SaveGraphsToRootFile(void); +void SaveNtupleToRootFile(void); +void GetCommandLineArgs(int argc, char **argv); +void PrintSyntax(void); PDGCodeList GetPDGCodeListFromString(std::string s); -//User-specified options: -string gOptXMLFilename; // input XML filename -string gOptROOTFilename; // output ROOT filename -PDGCodeList gOptProbePdgList; // list of probe PDG codes -PDGCodeList gOptTgtPdgList; // list of target PDG codes -int gOptProbePdgCode; // probe PDG code (currently being processed) -int gOptTgtPdgCode; // target PDG code -bool gWriteOutPlots; // write out a postscript file with plots -//bool gKeepSplineKnots; // use spline abscissa points rather than equi-spaced - -//Globals & constants +// User-specified options: +string gOptXMLFilename; // input XML filename +string gOptROOTFilename; // output ROOT filename +PDGCodeList gOptProbePdgList; // list of probe PDG codes +PDGCodeList gOptTgtPdgList; // list of target PDG codes +int gOptProbePdgCode; // probe PDG code (currently being processed) +int gOptTgtPdgCode; // target PDG code +bool gWriteOutPlots; // write out a postscript file with plots +// bool gKeepSplineKnots; // use spline abscissa points rather than +// equi-spaced + +// Globals & constants double gEmin; double gEmax; bool gInlogE; -int kNP = 300; -int kNSplineP = 1000; -const int kPsType = 111; // ps type: portrait +int kNP = 300; +int kNSplineP = 1000; +const int kPsType = 111; // ps type: portrait //____________________________________________________________________________ -int main(int argc, char ** argv) -{ - GetCommandLineArgs(argc,argv); +int main(int argc, char **argv) { + GetCommandLineArgs(argc, argv); - if ( ! RunOpt::Instance()->Tune() ) { + if (!RunOpt::Instance()->Tune()) { LOG("gslp2root", pFATAL) << " No TuneId in RunOption"; exit(-1); } @@ -170,14 +165,16 @@ int main(int argc, char ** argv) // load the x-section splines xml file specified by the user LoadSplines(); - if ( ! XSecSplineList::Instance() -> HasSplineFromTune(RunOpt::Instance() -> Tune() -> Name() ) ) { - LOG("gspl2root", pWARN) << "No splines loaded for tune " << RunOpt::Instance() -> Tune() -> Name() ; + if (!XSecSplineList::Instance()->HasSplineFromTune( + RunOpt::Instance()->Tune()->Name())) { + LOG("gspl2root", pWARN) + << "No splines loaded for tune " << RunOpt::Instance()->Tune()->Name(); } - for (unsigned int indx_p = 0; indx_p < gOptProbePdgList.size(); ++indx_p ) { - for (unsigned int indx_t = 0; indx_t < gOptTgtPdgList.size(); ++indx_t ) { + for (unsigned int indx_p = 0; indx_p < gOptProbePdgList.size(); ++indx_p) { + for (unsigned int indx_t = 0; indx_t < gOptTgtPdgList.size(); ++indx_t) { gOptProbePdgCode = gOptProbePdgList[indx_p]; - gOptTgtPdgCode = gOptTgtPdgList[indx_t]; + gOptTgtPdgCode = gOptTgtPdgList[indx_t]; // save the cross section plots in a postscript file SaveToPsFile(); // save the cross section graphs at a root file @@ -188,20 +185,18 @@ int main(int argc, char ** argv) return 0; } //____________________________________________________________________________ -void LoadSplines(void) -{ -// load the cross section splines specified at the cmd line +void LoadSplines(void) { + // load the cross section splines specified at the cmd line - XSecSplineList * splist = XSecSplineList::Instance(); + XSecSplineList *splist = XSecSplineList::Instance(); XmlParserStatus_t ist = splist->LoadFromXml(gOptXMLFilename); assert(ist == kXmlOK); } //____________________________________________________________________________ -GEVGDriver GetEventGenDriver(void) -{ -// create an event genartion driver configured for the specified initial state -// (so that cross section splines will be accessed through that driver as in -// event generation mode) +GEVGDriver GetEventGenDriver(void) { + // create an event genartion driver configured for the specified initial state + // (so that cross section splines will be accessed through that driver as in + // event generation mode) InitialState init_state(gOptTgtPdgCode, gOptProbePdgCode); @@ -209,77 +204,75 @@ GEVGDriver GetEventGenDriver(void) evg_driver.SetEventGeneratorList(RunOpt::Instance()->EventGeneratorList()); evg_driver.Configure(init_state); evg_driver.CreateSplines(); - evg_driver.CreateXSecSumSpline (100, gEmin, gEmax); + evg_driver.CreateXSecSumSpline(100, gEmin, gEmax); return evg_driver; } //____________________________________________________________________________ -void SaveToPsFile(void) -{ - if(!gWriteOutPlots) return; +void SaveToPsFile(void) { + if (!gWriteOutPlots) + return; //-- get the event generation driver GEVGDriver evg_driver = GetEventGenDriver(); //-- define some marker styles / colors const unsigned int kNMarkers = 5; - const unsigned int kNColors = 6; + const unsigned int kNColors = 6; unsigned int markers[kNMarkers] = {20, 28, 29, 27, 3}; - unsigned int colors [kNColors] = {1, 2, 4, 6, 8, 28}; + unsigned int colors[kNColors] = {1, 2, 4, 6, 8, 28}; //-- create a postscript document for saving cross section plpots - TCanvas * c = new TCanvas("c","",20,20,500,850); + TCanvas *c = new TCanvas("c", "", 20, 20, 500, 850); c->SetBorderMode(0); c->SetFillColor(0); - TLegend * legend = new TLegend(0.01,0.01,0.99,0.99); + TLegend *legend = new TLegend(0.01, 0.01, 0.99, 0.99); legend->SetFillColor(0); legend->SetBorderSize(0); //-- get pdglibrary for mapping pdg codes to names - PDGLibrary * pdglib = PDGLibrary::Instance(); + PDGLibrary *pdglib = PDGLibrary::Instance(); ostringstream filename; - filename << "xsec-splines-" - << pdglib->Find(gOptProbePdgCode)->GetName() << "-" - << pdglib->Find(gOptTgtPdgCode)->GetName() << ".ps"; - TPostScript * ps = new TPostScript(filename.str().c_str(), kPsType); + filename << "xsec-splines-" << pdglib->Find(gOptProbePdgCode)->GetName() + << "-" << pdglib->Find(gOptTgtPdgCode)->GetName() << ".ps"; + TPostScript *ps = new TPostScript(filename.str().c_str(), kPsType); //-- get the list of interactions that can be simulated by the driver - const InteractionList * ilist = evg_driver.Interactions(); + const InteractionList *ilist = evg_driver.Interactions(); unsigned int nspl = ilist->size(); //-- book enough space for xsec plots (last one is the sum) - TGraph * gr[nspl+1]; + TGraph *gr[nspl + 1]; - //-- loop over all the simulated interactions & create the cross section graphs + //-- loop over all the simulated interactions & create the cross section + //graphs InteractionList::const_iterator ilistiter = ilist->begin(); - unsigned int i=0; - for(; ilistiter != ilist->end(); ++ilistiter) { + unsigned int i = 0; + for (; ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; + const Interaction *interaction = *ilistiter; LOG("gspl2root", pINFO) - << "Current interaction: " << interaction->AsString(); - + << "Current interaction: " << interaction->AsString(); //-- access the cross section spline - const Spline * spl = evg_driver.XSecSpline(interaction); - if(!spl) { + const Spline *spl = evg_driver.XSecSpline(interaction); + if (!spl) { LOG("gspl2root", pWARN) - << "Can't get spline for: " << interaction->AsString(); + << "Can't get spline for: " << interaction->AsString(); exit(2); } //-- set graph color/style - int icol = TMath::Min( i % kNColors, kNColors-1 ); - int isty = TMath::Min( i / kNMarkers, kNMarkers-1 ); + int icol = TMath::Min(i % kNColors, kNColors - 1); + int isty = TMath::Min(i / kNMarkers, kNMarkers - 1); int col = colors[icol]; int sty = markers[isty]; - LOG("gspl2root", pINFO) - << "color = " << col << ", marker = " << sty; + LOG("gspl2root", pINFO) << "color = " << col << ", marker = " << sty; //-- export Spline as TGraph / set color & stype - gr[i] = spl->GetAsTGraph(kNP,true,true,1.,1./units::cm2); + gr[i] = spl->GetAsTGraph(kNP, true, true, 1., 1. / units::cm2); gr[i]->SetLineColor(col); gr[i]->SetMarkerColor(col); gr[i]->SetMarkerStyle(sty); @@ -289,33 +282,37 @@ void SaveToPsFile(void) } //-- now, get the sum... - const Spline * splsum = evg_driver.XSecSumSpline(); - if(!splsum) { - LOG("gspl2root", pWARN) - << "Can't get the cross section sum spline"; - exit(2); + const Spline *splsum = evg_driver.XSecSumSpline(); + if (!splsum) { + LOG("gspl2root", pWARN) << "Can't get the cross section sum spline"; + exit(2); } - gr[nspl] = splsum->GetAsTGraph(kNP,true,true,1.,1./units::cm2); + gr[nspl] = splsum->GetAsTGraph(kNP, true, true, 1., 1. / units::cm2); //-- figure out the minimum / maximum xsec in plotted range double XSmax = -9999; - double XSmin = 9999; - double x=0, y=0; - for(int j=0; jGetPoint(j,x,y); - XSmax = TMath::Max(XSmax,y); + double XSmin = 9999; + double x = 0, y = 0; + for (int j = 0; j < kNP; j++) { + gr[nspl]->GetPoint(j, x, y); + XSmax = TMath::Max(XSmax, y); } - XSmin = XSmax/100000.; - XSmax = XSmax*1.2; + XSmin = XSmax / 100000.; + XSmax = XSmax * 1.2; - LOG("gspl2root", pINFO) << "Drawing frame: E = (" << gEmin << ", " << gEmax << ")"; - LOG("gspl2root", pINFO) << "Drawing frame: XSec = (" << XSmin << ", " << XSmax << ")"; + LOG("gspl2root", pINFO) << "Drawing frame: E = (" << gEmin << ", " << gEmax + << ")"; + LOG("gspl2root", pINFO) << "Drawing frame: XSec = (" << XSmin << ", " << XSmax + << ")"; //-- ps output: add the 1st page with _all_ xsec spline plots // - //c->Draw(); - TH1F * h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); - for(unsigned int ispl = 0; ispl <= nspl; ispl++) if(gr[ispl]) { gr[ispl]->Draw("LP"); } + // c->Draw(); + TH1F *h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + for (unsigned int ispl = 0; ispl <= nspl; ispl++) + if (gr[ispl]) { + gr[ispl]->Draw("LP"); + } h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -326,21 +323,22 @@ void SaveToPsFile(void) //-- plot QEL xsecs only // - h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); - i=0; - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - if(interaction->ProcInfo().IsQuasiElastic() && ! interaction->ExclTag().IsCharmEvent()) { - gr[i]->Draw("LP"); - TString spltitle(interaction->AsString()); - spltitle = spltitle.ReplaceAll(";",1," ",1); - legend->AddEntry(gr[i], spltitle.Data(),"LP"); + h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + i = 0; + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + if (interaction->ProcInfo().IsQuasiElastic() && + !interaction->ExclTag().IsCharmEvent()) { + gr[i]->Draw("LP"); + TString spltitle(interaction->AsString()); + spltitle = spltitle.ReplaceAll(";", 1, " ", 1); + legend->AddEntry(gr[i], spltitle.Data(), "LP"); } i++; } legend->SetHeader("QEL Cross Sections"); gr[nspl]->Draw("LP"); - legend->AddEntry(gr[nspl], "sum","LP"); + legend->AddEntry(gr[nspl], "sum", "LP"); h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -349,28 +347,28 @@ void SaveToPsFile(void) c->SetGridy(); c->Update(); c->Clear(); - c->Range(0,0,1,1); + c->Range(0, 0, 1, 1); legend->Draw(); c->Update(); //-- plot RES xsecs only // - h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); legend->Clear(); - i=0; - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - if(interaction->ProcInfo().IsResonant()) { - gr[i]->Draw("LP"); - TString spltitle(interaction->AsString()); - spltitle = spltitle.ReplaceAll(";",1," ",1); - legend->AddEntry(gr[i], spltitle.Data(),"LP"); + i = 0; + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + if (interaction->ProcInfo().IsResonant()) { + gr[i]->Draw("LP"); + TString spltitle(interaction->AsString()); + spltitle = spltitle.ReplaceAll(";", 1, " ", 1); + legend->AddEntry(gr[i], spltitle.Data(), "LP"); } i++; } legend->SetHeader("RES Cross Sections"); gr[nspl]->Draw("LP"); - legend->AddEntry(gr[nspl], "sum","LP"); + legend->AddEntry(gr[nspl], "sum", "LP"); h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -379,28 +377,28 @@ void SaveToPsFile(void) c->SetGridy(); c->Update(); c->Clear(); - c->Range(0,0,1,1); + c->Range(0, 0, 1, 1); legend->Draw(); c->Update(); //-- plot DIS xsecs only // - h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); legend->Clear(); - i=0; - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - if(interaction->ProcInfo().IsDeepInelastic()) { - gr[i]->Draw("LP"); - TString spltitle(interaction->AsString()); - spltitle = spltitle.ReplaceAll(";",1," ",1); - legend->AddEntry(gr[i], spltitle.Data(),"LP"); + i = 0; + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + if (interaction->ProcInfo().IsDeepInelastic()) { + gr[i]->Draw("LP"); + TString spltitle(interaction->AsString()); + spltitle = spltitle.ReplaceAll(";", 1, " ", 1); + legend->AddEntry(gr[i], spltitle.Data(), "LP"); } i++; } legend->SetHeader("DIS Cross Sections"); gr[nspl]->Draw("LP"); - legend->AddEntry(gr[nspl], "sum","LP"); + legend->AddEntry(gr[nspl], "sum", "LP"); h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -409,28 +407,28 @@ void SaveToPsFile(void) c->SetGridy(); c->Update(); c->Clear(); - c->Range(0,0,1,1); + c->Range(0, 0, 1, 1); legend->Draw(); c->Update(); //-- plot COH xsecs only // - h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); legend->Clear(); - i=0; - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - if(interaction->ProcInfo().IsCoherentProduction()) { - gr[i]->Draw("LP"); - TString spltitle(interaction->AsString()); - spltitle = spltitle.ReplaceAll(";",1," ",1); - legend->AddEntry(gr[i], spltitle.Data(),"LP"); + i = 0; + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + if (interaction->ProcInfo().IsCoherentProduction()) { + gr[i]->Draw("LP"); + TString spltitle(interaction->AsString()); + spltitle = spltitle.ReplaceAll(";", 1, " ", 1); + legend->AddEntry(gr[i], spltitle.Data(), "LP"); } i++; } legend->SetHeader("COH Cross Sections"); gr[nspl]->Draw("LP"); - legend->AddEntry(gr[nspl], "sum","LP"); + legend->AddEntry(gr[nspl], "sum", "LP"); h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -439,27 +437,27 @@ void SaveToPsFile(void) c->SetGridy(); c->Update(); c->Clear(); - c->Range(0,0,1,1); + c->Range(0, 0, 1, 1); legend->Draw(); c->Update(); //-- plot charm xsecs only // - h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); - i=0; - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - if(interaction->ExclTag().IsCharmEvent()) { - gr[i]->Draw("LP"); - TString spltitle(interaction->AsString()); - spltitle = spltitle.ReplaceAll(";",1," ",1); - legend->AddEntry(gr[i], spltitle.Data(),"LP"); + h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + i = 0; + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + if (interaction->ExclTag().IsCharmEvent()) { + gr[i]->Draw("LP"); + TString spltitle(interaction->AsString()); + spltitle = spltitle.ReplaceAll(";", 1, " ", 1); + legend->AddEntry(gr[i], spltitle.Data(), "LP"); } i++; } legend->SetHeader("Charm Prod. Cross Sections"); - //gr[nspl]->Draw("LP"); - legend->AddEntry(gr[nspl], "sum","LP"); + // gr[nspl]->Draw("LP"); + legend->AddEntry(gr[nspl], "sum", "LP"); h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -468,30 +466,30 @@ void SaveToPsFile(void) c->SetGridy(); c->Update(); c->Clear(); - c->Range(0,0,1,1); + c->Range(0, 0, 1, 1); legend->Draw(); c->Update(); //-- plot ve xsecs only // - h = (TH1F*) c->DrawFrame(gEmin, XSmin, gEmax, XSmax); + h = (TH1F *)c->DrawFrame(gEmin, XSmin, gEmax, XSmax); legend->Clear(); - i=0; - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - if(interaction->ProcInfo().IsInverseMuDecay() || - interaction->ProcInfo().IsIMDAnnihilation() || - interaction->ProcInfo().IsNuElectronElastic()) { - gr[i]->Draw("LP"); - TString spltitle(interaction->AsString()); - spltitle = spltitle.ReplaceAll(";",1," ",1); - legend->AddEntry(gr[i], spltitle.Data(),"LP"); + i = 0; + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + if (interaction->ProcInfo().IsInverseMuDecay() || + interaction->ProcInfo().IsIMDAnnihilation() || + interaction->ProcInfo().IsNuElectronElastic()) { + gr[i]->Draw("LP"); + TString spltitle(interaction->AsString()); + spltitle = spltitle.ReplaceAll(";", 1, " ", 1); + legend->AddEntry(gr[i], spltitle.Data(), "LP"); } i++; } legend->SetHeader("IMD and ve Elastic Cross Sections"); gr[nspl]->Draw("LP"); - legend->AddEntry(gr[nspl], "sum","LP"); + legend->AddEntry(gr[nspl], "sum", "LP"); h->GetXaxis()->SetTitle("Ev (GeV)"); h->GetYaxis()->SetTitle("#sigma_{nuclear}/Ev (cm^{2}/GeV)"); c->SetLogx(); @@ -500,7 +498,7 @@ void SaveToPsFile(void) c->SetGridy(); c->Update(); c->Clear(); - c->Range(0,0,1,1); + c->Range(0, 0, 1, 1); legend->Draw(); c->Update(); @@ -508,106 +506,132 @@ void SaveToPsFile(void) ps->Close(); //-- clean-up - for(unsigned int j=0; j<=nspl; j++) { if(gr[j]) delete gr[j]; } + for (unsigned int j = 0; j <= nspl; j++) { + if (gr[j]) + delete gr[j]; + } delete c; delete ps; } //____________________________________________________________________________ -void FormatXSecGraph(TGraph * g) -{ +void FormatXSecGraph(TGraph *g) { g->SetTitle("GENIE cross section graph"); g->GetXaxis()->SetTitle("Ev (GeV)"); g->GetYaxis()->SetTitle("#sigma_{nuclear} (10^{-38} cm^{2})"); } //____________________________________________________________________________ -void SaveGraphsToRootFile(void) -{ +void SaveGraphsToRootFile(void) { //-- get the event generation driver GEVGDriver evg_driver = GetEventGenDriver(); //-- get the list of interactions that can be simulated by the driver - const InteractionList * ilist = evg_driver.Interactions(); + const InteractionList *ilist = evg_driver.Interactions(); //-- check whether the splines will be saved in a ROOT file - if not, exit now - bool save_in_root = gOptROOTFilename.size()>0; - if(!save_in_root) { + bool save_in_root = gOptROOTFilename.size() > 0; + if (!save_in_root) { - LOG("gspl2root", pWARN) << "No Interaction List available" ; + LOG("gspl2root", pWARN) << "No Interaction List available"; return; } //-- get pdglibrary for mapping pdg codes to names - PDGLibrary * pdglib = PDGLibrary::Instance(); + PDGLibrary *pdglib = PDGLibrary::Instance(); //-- check whether the requested filename exists // if yes, then open the file in 'update' mode bool exists = !(gSystem->AccessPathName(gOptROOTFilename.c_str())); - TFile * froot = 0; - if(exists) froot = new TFile(gOptROOTFilename.c_str(), "UPDATE"); - else froot = new TFile(gOptROOTFilename.c_str(), "RECREATE"); + TFile *froot = 0; + if (exists) + froot = new TFile(gOptROOTFilename.c_str(), "UPDATE"); + else + froot = new TFile(gOptROOTFilename.c_str(), "RECREATE"); assert(froot); //-- create directory ostringstream dptr; string probe_name = pdglib->Find(gOptProbePdgCode)->GetName(); - string tgt_name = (gOptTgtPdgCode==1000000010) ? - "n" : pdglib->Find(gOptTgtPdgCode)->GetName(); + string tgt_name = (gOptTgtPdgCode == 1000000010) + ? "n" + : pdglib->Find(gOptTgtPdgCode)->GetName(); dptr << probe_name << "_" << tgt_name; ostringstream dtitle; - dtitle << "Cross sections for: " - << pdglib->Find(gOptProbePdgCode)->GetName() << "+" - << pdglib->Find(gOptTgtPdgCode)->GetName(); - - LOG("gspl2root", pINFO) - << "Will store graphs in root directory = " << dptr.str(); - TDirectory * topdir = - dynamic_cast (froot->Get(dptr.str().c_str())); - if(topdir) { - LOG("gspl2root", pINFO) - << "Directory: " << dptr.str() << " already exists!! Exiting"; - froot->Close(); - delete froot; - return; + dtitle << "Cross sections for: " << pdglib->Find(gOptProbePdgCode)->GetName() + << "+" << pdglib->Find(gOptTgtPdgCode)->GetName(); + + LOG("gspl2root", pINFO) << "Will store graphs in root directory = " + << dptr.str(); + TDirectory *topdir = + dynamic_cast(froot->Get(dptr.str().c_str())); + if (topdir) { + LOG("gspl2root", pINFO) + << "Directory: " << dptr.str() << " already exists!! Exiting"; + froot->Close(); + delete froot; + return; } - topdir = froot->mkdir(dptr.str().c_str(),dtitle.str().c_str()); + topdir = froot->mkdir(dptr.str().c_str(), dtitle.str().c_str()); topdir->cd(); - double de = (gInlogE) ? (TMath::Log(gEmax)-TMath::Log(gEmin))/(kNSplineP-1) : (gEmax-gEmin)/(kNSplineP-1); - double * e = new double[kNSplineP]; - for(int i=0; ibegin(); - for(; ilistiter != ilist->end(); ++ilistiter) { + for (; ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; + const Interaction *interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const XclsTag & xcls = interaction->ExclTag(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); + const ProcessInfo &proc = interaction->ProcInfo(); + const XclsTag &xcls = interaction->ExclTag(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); // graph title ostringstream title; - if (proc.IsQuasiElastic() ) { title << "qel"; } - else if (proc.IsMEC() ) { title << "mec"; } - else if (proc.IsResonant() ) { title << "res"; } - else if (proc.IsDeepInelastic() ) { title << "dis"; } - else if (proc.IsDiffractive() ) { title << "dfr"; } - else if (proc.IsCoherentProduction() ) { + if (proc.IsQuasiElastic()) { + title << "qel"; + } else if (proc.IsMEC()) { + title << "mec"; + } else if (proc.IsResonant()) { + title << "res"; + } else if (proc.IsDeepInelastic()) { + title << "dis"; + } else if (proc.IsDiffractive()) { + title << "dfr"; + } else if (proc.IsCoherentProduction()) { title << "coh"; - if ( xcls.NSingleGammas() > 0 ) title << "_gamma" ; - else if ( xcls.NPions() > 0 ) title << "_pion" ; - else if ( xcls.NRhos() > 0 ) title << "_rho" ; - else title << "_other" ; - } + if (xcls.NSingleGammas() > 0) + title << "_gamma"; + else if (xcls.NPions() > 0) + title << "_pion"; + else if (xcls.NRhos() > 0) + title << "_rho"; + else + title << "_other"; + } else if (proc.IsCoherentElastic()) { + title << "cevns"; + } else if (proc.IsInverseMuDecay()) { + title << "imd"; + } else if (proc.IsIMDAnnihilation()) { + title << "imdanh"; + } else if (proc.IsNuElectronElastic()) { + title << "ve"; + } else if (proc.IsGlashowResonance()) { + title << "glres"; + } else if (proc.IsCoherentElastic() ) { title << "cevns"; } else if (proc.IsInverseMuDecay() ) { title << "imd"; } else if (proc.IsIMDAnnihilation() ) { title << "imdanh";} @@ -630,74 +654,126 @@ void SaveGraphsToRootFile(void) << " interaction type has not recongnised: spline not added " ; continue; } - if(tgt.HitNucIsSet()) { + if (proc.IsWeakCC()) { + title << "_cc"; + } else if (proc.IsWeakNC()) { + title << "_nc"; + } else if (proc.IsWeakMix()) { + title << "_ccncmix"; + } else if (proc.IsEM()) { + title << "_em"; + } else if (proc.IsDarkNeutralCurrent()) { + title << "_dark"; + } else { + LOG("gspl2root", pWARN) + << "Process " << proc + << " interaction type has not recongnised: spline not added "; + continue; + } + + if (tgt.HitNucIsSet()) { int hitnuc = tgt.HitNucPdg(); - if ( pdg::IsProton (hitnuc) ) { title << "_p"; } - else if ( pdg::IsNeutron(hitnuc) ) { title << "_n"; } - else if ( pdg::Is2NucleonCluster(hitnuc) ) - { - if (hitnuc == kPdgClusterNN) { title << "_nn"; } - else if (hitnuc == kPdgClusterNP) { title << "_np"; } - else if (hitnuc == kPdgClusterPP) { title << "_pp"; } - else { - LOG("gspl2root", pWARN) << "Can't handle hit 2-nucleon cluster PDG = " << hitnuc; + if (pdg::IsProton(hitnuc)) { + title << "_p"; + } else if (pdg::IsNeutron(hitnuc)) { + title << "_n"; + } else if (pdg::Is2NucleonCluster(hitnuc)) { + if (hitnuc == kPdgClusterNN) { + title << "_nn"; + } else if (hitnuc == kPdgClusterNP) { + title << "_np"; + } else if (hitnuc == kPdgClusterPP) { + title << "_pp"; + } else { + LOG("gspl2root", pWARN) + << "Can't handle hit 2-nucleon cluster PDG = " << hitnuc; } - } - else { + } else { LOG("gspl2root", pWARN) << "Can't handle hit nucleon PDG = " << hitnuc; } - if(tgt.HitQrkIsSet()) { - int qrkpdg = tgt.HitQrkPdg(); - bool insea = tgt.HitSeaQrk(); - - if ( pdg::IsUQuark(qrkpdg) ) { title << "_u"; } - else if ( pdg::IsDQuark(qrkpdg) ) { title << "_d"; } - else if ( pdg::IsSQuark(qrkpdg) ) { title << "_s"; } - else if ( pdg::IsCQuark(qrkpdg) ) { title << "_c"; } - else if ( pdg::IsBQuark(qrkpdg) ) { title << "_b"; } - else if ( pdg::IsAntiUQuark(qrkpdg) ) { title << "_ubar"; } - else if ( pdg::IsAntiDQuark(qrkpdg) ) { title << "_dbar"; } - else if ( pdg::IsAntiSQuark(qrkpdg) ) { title << "_sbar"; } - else if ( pdg::IsAntiCQuark(qrkpdg) ) { title << "_cbar"; } - else if ( pdg::IsAntiBQuark(qrkpdg) ) { title << "_bbar"; } - - if(insea) { title << "sea"; } - else { title << "val"; } + if (tgt.HitQrkIsSet()) { + int qrkpdg = tgt.HitQrkPdg(); + bool insea = tgt.HitSeaQrk(); + + if (pdg::IsUQuark(qrkpdg)) { + title << "_u"; + } else if (pdg::IsDQuark(qrkpdg)) { + title << "_d"; + } else if (pdg::IsSQuark(qrkpdg)) { + title << "_s"; + } else if (pdg::IsCQuark(qrkpdg)) { + title << "_c"; + } else if (pdg::IsBQuark(qrkpdg)) { + title << "_b"; + } else if (pdg::IsAntiUQuark(qrkpdg)) { + title << "_ubar"; + } else if (pdg::IsAntiDQuark(qrkpdg)) { + title << "_dbar"; + } else if (pdg::IsAntiSQuark(qrkpdg)) { + title << "_sbar"; + } else if (pdg::IsAntiCQuark(qrkpdg)) { + title << "_cbar"; + } else if (pdg::IsAntiBQuark(qrkpdg)) { + title << "_bbar"; + } + + if (insea) { + title << "sea"; + } else { + title << "val"; + } } } - if(proc.IsResonant()) { - Resonance_t res = xcls.Resonance(); - string resname = res::AsString(res); - resname = str::FilterString(")", resname); - resname = str::FilterString("(", resname); - title << "_" << resname.substr(3,4) << resname.substr(0,3); + if (proc.IsResonant()) { + Resonance_t res = xcls.Resonance(); + string resname = res::AsString(res); + resname = str::FilterString(")", resname); + resname = str::FilterString("(", resname); + title << "_" << resname.substr(3, 4) << resname.substr(0, 3); } - if(xcls.IsStrangeEvent()) { - title << "_strange"; - if(!xcls.IsInclusiveStrange()) { title << xcls.StrangeHadronPdg(); } + if (xcls.IsStrangeEvent()) { + title << "_strange"; + if (!xcls.IsInclusiveStrange()) { + title << xcls.StrangeHadronPdg(); + } } - if(xcls.IsCharmEvent()) { - title << "_charm"; - if(!xcls.IsInclusiveCharm()) { title << xcls.CharmHadronPdg(); } + if (xcls.IsCharmEvent()) { + title << "_charm"; + if (!xcls.IsInclusiveCharm()) { + title << xcls.CharmHadronPdg(); + } } - if(xcls.IsFinalQuarkEvent()) { - int qrkpdg = xcls.FinalQuarkPdg(); - if ( pdg::IsUQuark(qrkpdg) ) { title << "_u"; } - else if ( pdg::IsDQuark(qrkpdg) ) { title << "_d"; } - else if ( pdg::IsSQuark(qrkpdg) ) { title << "_s"; } - else if ( pdg::IsCQuark(qrkpdg) ) { title << "_c"; } - else if ( pdg::IsBQuark(qrkpdg) ) { title << "_b"; } - else if ( pdg::IsTQuark(qrkpdg) ) { title << "_t"; } - else if ( pdg::IsAntiUQuark(qrkpdg) ) { title << "_ubar"; } - else if ( pdg::IsAntiDQuark(qrkpdg) ) { title << "_dbar"; } - else if ( pdg::IsAntiSQuark(qrkpdg) ) { title << "_sbar"; } - else if ( pdg::IsAntiCQuark(qrkpdg) ) { title << "_cbar"; } - else if ( pdg::IsAntiBQuark(qrkpdg) ) { title << "_bbar"; } - else if ( pdg::IsAntiTQuark(qrkpdg) ) { title << "_tbar"; } + if (xcls.IsFinalQuarkEvent()) { + int qrkpdg = xcls.FinalQuarkPdg(); + if (pdg::IsUQuark(qrkpdg)) { + title << "_u"; + } else if (pdg::IsDQuark(qrkpdg)) { + title << "_d"; + } else if (pdg::IsSQuark(qrkpdg)) { + title << "_s"; + } else if (pdg::IsCQuark(qrkpdg)) { + title << "_c"; + } else if (pdg::IsBQuark(qrkpdg)) { + title << "_b"; + } else if (pdg::IsTQuark(qrkpdg)) { + title << "_t"; + } else if (pdg::IsAntiUQuark(qrkpdg)) { + title << "_ubar"; + } else if (pdg::IsAntiDQuark(qrkpdg)) { + title << "_dbar"; + } else if (pdg::IsAntiSQuark(qrkpdg)) { + title << "_sbar"; + } else if (pdg::IsAntiCQuark(qrkpdg)) { + title << "_cbar"; + } else if (pdg::IsAntiBQuark(qrkpdg)) { + title << "_bbar"; + } else if (pdg::IsAntiTQuark(qrkpdg)) { + title << "_tbar"; + } } if(xcls.IsFinalLeptonEvent()) { int leppdg = TMath::Abs(xcls.FinalLeptonPdg()); @@ -707,12 +783,12 @@ void SaveGraphsToRootFile(void) else if ( pdg::IsPion(leppdg) ) { title << "_had"; } } - const Spline * spl = evg_driver.XSecSpline(interaction); - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2); + const Spline *spl = evg_driver.XSecSpline(interaction); + for (int i = 0; i < kNSplineP; i++) { + xs[i] = spl->Evaluate(e[i]) * (1E+38 / units::cm2); } - TGraph * gr = new TGraph(kNSplineP, e, xs); + TGraph *gr = new TGraph(kNSplineP, e, xs); gr->SetName(title.str().c_str()); FormatXSecGraph(gr); gr->SetTitle(spl->GetName()); @@ -720,73 +796,76 @@ void SaveGraphsToRootFile(void) topdir->Add(gr); } - // // totals for (anti-)neutrino scattering // bool is_neutrino = pdg::IsNeutralLepton(gOptProbePdgCode); - if(is_neutrino) { + if (is_neutrino) { // // add-up all res channels // - double * xsresccp = new double[kNSplineP]; - double * xsresccn = new double[kNSplineP]; - double * xsresncp = new double[kNSplineP]; - double * xsresncn = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); - const Spline * spl = evg_driver.XSecSpline(interaction); + const Spline *spl = evg_driver.XSecSpline(interaction); - if (proc.IsResonant() && proc.IsWeakCC() && pdg::IsProton(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if (proc.IsResonant() && proc.IsWeakCC() && pdg::IsNeutron(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if (proc.IsResonant() && proc.IsWeakNC() && pdg::IsProton(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if (proc.IsResonant() && proc.IsWeakNC() && pdg::IsNeutron(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } + if (proc.IsResonant() && proc.IsWeakCC() && + pdg::IsProton(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsresccp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } + if (proc.IsResonant() && proc.IsWeakCC() && + pdg::IsNeutron(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsresccn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } + if (proc.IsResonant() && proc.IsWeakNC() && + pdg::IsProton(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsresncp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } + if (proc.IsResonant() && proc.IsWeakNC() && + pdg::IsNeutron(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsresncn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } } - TGraph * gr_resccp = new TGraph(kNSplineP, e, xsresccp); + TGraph *gr_resccp = new TGraph(kNSplineP, e, xsresccp); gr_resccp->SetName("res_cc_p"); FormatXSecGraph(gr_resccp); topdir->Add(gr_resccp); - TGraph * gr_resccn = new TGraph(kNSplineP, e, xsresccn); + TGraph *gr_resccn = new TGraph(kNSplineP, e, xsresccn); gr_resccn->SetName("res_cc_n"); FormatXSecGraph(gr_resccn); topdir->Add(gr_resccn); - TGraph * gr_resncp = new TGraph(kNSplineP, e, xsresncp); + TGraph *gr_resncp = new TGraph(kNSplineP, e, xsresncp); gr_resncp->SetName("res_nc_p"); FormatXSecGraph(gr_resncp); topdir->Add(gr_resncp); - TGraph * gr_resncn = new TGraph(kNSplineP, e, xsresncn); + TGraph *gr_resncn = new TGraph(kNSplineP, e, xsresncn); gr_resncn->SetName("res_nc_n"); FormatXSecGraph(gr_resncn); topdir->Add(gr_resncn); @@ -809,16 +888,17 @@ void SaveGraphsToRootFile(void) xsdisncp[i] = 0; xsdisncn[i] = 0; } - for(ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const XclsTag & xcls = interaction->ExclTag(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const XclsTag &xcls = interaction->ExclTag(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); - const Spline * spl = evg_driver.XSecSpline(interaction); + const Spline *spl = evg_driver.XSecSpline(interaction); - if(xcls.IsCharmEvent()) continue; + if (xcls.IsCharmEvent()) + continue; if (proc.IsDeepInelastic() && proc.IsWeakCC() && pdg::IsProton(tgt.HitNucPdg())) { for(int i=0; iSetName("dis_cc_p"); FormatXSecGraph(gr_disccp); topdir->Add(gr_disccp); - TGraph * gr_disccn = new TGraph(kNSplineP, e, xsdisccn); + TGraph *gr_disccn = new TGraph(kNSplineP, e, xsdisccn); gr_disccn->SetName("dis_cc_n"); FormatXSecGraph(gr_disccn); topdir->Add(gr_disccn); - TGraph * gr_disncp = new TGraph(kNSplineP, e, xsdisncp); + TGraph *gr_disncp = new TGraph(kNSplineP, e, xsdisncp); gr_disncp->SetName("dis_nc_p"); FormatXSecGraph(gr_disncp); topdir->Add(gr_disncp); - TGraph * gr_disncn = new TGraph(kNSplineP, e, xsdisncn); + TGraph *gr_disncn = new TGraph(kNSplineP, e, xsdisncn); gr_disncn->SetName("dis_nc_n"); FormatXSecGraph(gr_disncn); topdir->Add(gr_disncn); @@ -930,15 +1010,15 @@ void SaveGraphsToRootFile(void) gr_disccp_charm->SetName("dis_cc_p_charm"); FormatXSecGraph(gr_disccp_charm); topdir->Add(gr_disccp_charm); - TGraph * gr_disccn_charm = new TGraph(kNSplineP, e, xsdisccn); + TGraph *gr_disccn_charm = new TGraph(kNSplineP, e, xsdisccn); gr_disccn_charm->SetName("dis_cc_n_charm"); FormatXSecGraph(gr_disccn_charm); topdir->Add(gr_disccn_charm); - TGraph * gr_disncp_charm = new TGraph(kNSplineP, e, xsdisncp); + TGraph *gr_disncp_charm = new TGraph(kNSplineP, e, xsdisncp); gr_disncp_charm->SetName("dis_nc_p_charm"); FormatXSecGraph(gr_disncp_charm); topdir->Add(gr_disncp_charm); - TGraph * gr_disncn_charm = new TGraph(kNSplineP, e, xsdisncn); + TGraph *gr_disncn_charm = new TGraph(kNSplineP, e, xsdisncn); gr_disncn_charm->SetName("dis_nc_n_charm"); FormatXSecGraph(gr_disncn_charm); topdir->Add(gr_disncn_charm); @@ -947,36 +1027,36 @@ void SaveGraphsToRootFile(void) // add-up all mec channels // - double * xsmeccc = new double[kNSplineP]; - double * xsmecnc = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); - const Spline * spl = evg_driver.XSecSpline(interaction); + const Spline *spl = evg_driver.XSecSpline(interaction); - if (proc.IsMEC() && proc.IsWeakCC()) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if (proc.IsMEC() && proc.IsWeakNC()) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } + if (proc.IsMEC() && proc.IsWeakCC()) { + for (int i = 0; i < kNSplineP; i++) { + xsmeccc[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } + if (proc.IsMEC() && proc.IsWeakNC()) { + for (int i = 0; i < kNSplineP; i++) { + xsmecnc[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } } - TGraph * gr_meccc = new TGraph(kNSplineP, e, xsmeccc); + TGraph *gr_meccc = new TGraph(kNSplineP, e, xsmeccc); gr_meccc->SetName("mec_cc"); FormatXSecGraph(gr_meccc); topdir->Add(gr_meccc); - TGraph * gr_mecnc = new TGraph(kNSplineP, e, xsmecnc); + TGraph *gr_mecnc = new TGraph(kNSplineP, e, xsmecnc); gr_mecnc->SetName("mec_nc"); FormatXSecGraph(gr_mecnc); topdir->Add(gr_mecnc); @@ -985,51 +1065,52 @@ void SaveGraphsToRootFile(void) // add-up all COH channels // - double * xscohcc = new double[kNSplineP]; - double * xscohnc = new double[kNSplineP]; - double * xscohtot = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + + const Spline *spl = evg_driver.XSecSpline(interaction); - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - - const Spline * spl = evg_driver.XSecSpline(interaction); - if (proc.IsCoherentProduction() && proc.IsWeakCC()) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } + for (int i = 0; i < kNSplineP; i++) { + xscohcc[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } } + if (proc.IsCoherentProduction() && proc.IsWeakNC()) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if ( proc.IsCoherentProduction() ) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } + for (int i = 0; i < kNSplineP; i++) { + xscohnc[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } } + if (proc.IsCoherentProduction()) { + for (int i = 0; i < kNSplineP; i++) { + xscohtot[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } } - TGraph * gr_cohcc = new TGraph(kNSplineP, e, xscohcc); + TGraph *gr_cohcc = new TGraph(kNSplineP, e, xscohcc); gr_cohcc->SetName("coh_cc"); FormatXSecGraph(gr_cohcc); topdir->Add(gr_cohcc); - TGraph * gr_cohnc = new TGraph(kNSplineP, e, xscohnc); + TGraph *gr_cohnc = new TGraph(kNSplineP, e, xscohnc); gr_cohnc->SetName("coh_nc"); FormatXSecGraph(gr_cohnc); topdir->Add(gr_cohnc); - TGraph * gr_cohtot = new TGraph(kNSplineP, e, xscohtot); + TGraph *gr_cohtot = new TGraph(kNSplineP, e, xscohtot); gr_cohtot->SetName("coh"); FormatXSecGraph(gr_cohtot); topdir->Add(gr_cohtot); @@ -1086,87 +1167,87 @@ void SaveGraphsToRootFile(void) // // total cross sections // - double * xstotcc = new double[kNSplineP]; - double * xstotccp = new double[kNSplineP]; - double * xstotccn = new double[kNSplineP]; - double * xstotnc = new double[kNSplineP]; - double * xstotncp = new double[kNSplineP]; - double * xstotncn = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); - const Spline * spl = evg_driver.XSecSpline(interaction); + const Spline *spl = evg_driver.XSecSpline(interaction); bool iscc = proc.IsWeakCC(); bool isnc = proc.IsWeakNC(); - bool offp = pdg::IsProton (tgt.HitNucPdg()); + bool offp = pdg::IsProton(tgt.HitNucPdg()); bool offn = pdg::IsNeutron(tgt.HitNucPdg()); if (iscc && offp) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotccp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (iscc && offn) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotccn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (isnc && offp) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotncp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (isnc && offn) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotncn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (iscc) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotcc[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (isnc) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotnc[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } } - TGraph * gr_totcc = new TGraph(kNSplineP, e, xstotcc); + TGraph *gr_totcc = new TGraph(kNSplineP, e, xstotcc); gr_totcc->SetName("tot_cc"); FormatXSecGraph(gr_totcc); topdir->Add(gr_totcc); - TGraph * gr_totccp = new TGraph(kNSplineP, e, xstotccp); + TGraph *gr_totccp = new TGraph(kNSplineP, e, xstotccp); gr_totccp->SetName("tot_cc_p"); FormatXSecGraph(gr_totccp); topdir->Add(gr_totccp); - TGraph * gr_totccn = new TGraph(kNSplineP, e, xstotccn); + TGraph *gr_totccn = new TGraph(kNSplineP, e, xstotccn); gr_totccn->SetName("tot_cc_n"); FormatXSecGraph(gr_totccn); topdir->Add(gr_totccn); - TGraph * gr_totnc = new TGraph(kNSplineP, e, xstotnc); + TGraph *gr_totnc = new TGraph(kNSplineP, e, xstotnc); gr_totnc->SetName("tot_nc"); FormatXSecGraph(gr_totnc); topdir->Add(gr_totnc); - TGraph * gr_totncp = new TGraph(kNSplineP, e, xstotncp); + TGraph *gr_totncp = new TGraph(kNSplineP, e, xstotncp); gr_totncp->SetName("tot_nc_p"); FormatXSecGraph(gr_totncp); topdir->Add(gr_totncp); - TGraph * gr_totncn = new TGraph(kNSplineP, e, xstotncn); + TGraph *gr_totncn = new TGraph(kNSplineP, e, xstotncn); gr_totncn->SetName("tot_nc_n"); FormatXSecGraph(gr_totncn); topdir->Add(gr_totncn); @@ -1198,51 +1279,50 @@ void SaveGraphsToRootFile(void) }// neutrinos - // // totals for charged lepton scattering // bool is_charged_lepton = pdg::IsChargedLepton(gOptProbePdgCode); - - if(is_charged_lepton) { - + + if (is_charged_lepton) { + // // add-up all res channels // - double * xsresemp = new double[kNSplineP]; - double * xsresemn = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); - const Spline * spl = evg_driver.XSecSpline(interaction); + const Spline *spl = evg_driver.XSecSpline(interaction); - if (proc.IsResonant() && proc.IsEM() && pdg::IsProton(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if (proc.IsResonant() && proc.IsEM() && pdg::IsNeutron(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } + if (proc.IsResonant() && proc.IsEM() && pdg::IsProton(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsresemp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } + if (proc.IsResonant() && proc.IsEM() && pdg::IsNeutron(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsresemn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } } - TGraph * gr_resemp = new TGraph(kNSplineP, e, xsresemp); + TGraph *gr_resemp = new TGraph(kNSplineP, e, xsresemp); gr_resemp->SetName("res_em_p"); FormatXSecGraph(gr_resemp); topdir->Add(gr_resemp); - TGraph * gr_resemn = new TGraph(kNSplineP, e, xsresemn); + TGraph *gr_resemn = new TGraph(kNSplineP, e, xsresemn); gr_resemn->SetName("res_em_n"); FormatXSecGraph(gr_resemn); topdir->Add(gr_resemn); @@ -1251,39 +1331,42 @@ void SaveGraphsToRootFile(void) // add-up all dis channels // - double * xsdisemp = new double[kNSplineP]; - double * xsdisemn = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const XclsTag & xcls = interaction->ExclTag(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); - - const Spline * spl = evg_driver.XSecSpline(interaction); - - if(xcls.IsCharmEvent()) continue; - - if (proc.IsDeepInelastic() && proc.IsEM() && pdg::IsProton(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } - if (proc.IsDeepInelastic() && proc.IsEM() && pdg::IsNeutron(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); - } - } + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const XclsTag &xcls = interaction->ExclTag(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); + + const Spline *spl = evg_driver.XSecSpline(interaction); + + if (xcls.IsCharmEvent()) + continue; + + if (proc.IsDeepInelastic() && proc.IsEM() && + pdg::IsProton(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsdisemp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } + if (proc.IsDeepInelastic() && proc.IsEM() && + pdg::IsNeutron(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsdisemn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); + } + } } - TGraph * gr_disemp = new TGraph(kNSplineP, e, xsdisemp); + TGraph *gr_disemp = new TGraph(kNSplineP, e, xsdisemp); gr_disemp->SetName("dis_em_p"); FormatXSecGraph(gr_disemp); topdir->Add(gr_disemp); - TGraph * gr_disemn = new TGraph(kNSplineP, e, xsdisemn); + TGraph *gr_disemn = new TGraph(kNSplineP, e, xsdisemn); gr_disemn->SetName("dis_em_n"); FormatXSecGraph(gr_disemn); topdir->Add(gr_disemn); @@ -1292,37 +1375,40 @@ void SaveGraphsToRootFile(void) // add-up all charm dis channels // - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const XclsTag & xcls = interaction->ExclTag(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); - - const Spline * spl = evg_driver.XSecSpline(interaction); - - if(!xcls.IsCharmEvent()) continue; - - if (proc.IsDeepInelastic() && proc.IsEM() && pdg::IsProton(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const XclsTag &xcls = interaction->ExclTag(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); + + const Spline *spl = evg_driver.XSecSpline(interaction); + + if (!xcls.IsCharmEvent()) + continue; + + if (proc.IsDeepInelastic() && proc.IsEM() && + pdg::IsProton(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsdisemp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } - if (proc.IsDeepInelastic() && proc.IsEM() && pdg::IsNeutron(tgt.HitNucPdg())) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + if (proc.IsDeepInelastic() && proc.IsEM() && + pdg::IsNeutron(tgt.HitNucPdg())) { + for (int i = 0; i < kNSplineP; i++) { + xsdisemn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } } - TGraph * gr_disemp_charm = new TGraph(kNSplineP, e, xsdisemp); + TGraph *gr_disemp_charm = new TGraph(kNSplineP, e, xsdisemp); gr_disemp_charm->SetName("dis_em_p_charm"); FormatXSecGraph(gr_disemp_charm); topdir->Add(gr_disemp_charm); - TGraph * gr_disemn_charm = new TGraph(kNSplineP, e, xsdisemn); + TGraph *gr_disemn_charm = new TGraph(kNSplineP, e, xsdisemn); gr_disemn_charm->SetName("dis_em_n_charm"); FormatXSecGraph(gr_disemn_charm); topdir->Add(gr_disemn_charm); @@ -1330,128 +1416,126 @@ void SaveGraphsToRootFile(void) // // total cross sections // - double * xstotem = new double[kNSplineP]; - double * xstotemp = new double[kNSplineP]; - double * xstotemn = new double[kNSplineP]; - for(int i=0; ibegin(); ilistiter != ilist->end(); ++ilistiter) { - const Interaction * interaction = *ilistiter; - const ProcessInfo & proc = interaction->ProcInfo(); - const InitialState & init = interaction->InitState(); - const Target & tgt = init.Tgt(); + for (ilistiter = ilist->begin(); ilistiter != ilist->end(); ++ilistiter) { + const Interaction *interaction = *ilistiter; + const ProcessInfo &proc = interaction->ProcInfo(); + const InitialState &init = interaction->InitState(); + const Target &tgt = init.Tgt(); - const Spline * spl = evg_driver.XSecSpline(interaction); + const Spline *spl = evg_driver.XSecSpline(interaction); bool isem = proc.IsEM(); - bool offp = pdg::IsProton (tgt.HitNucPdg()); + bool offp = pdg::IsProton(tgt.HitNucPdg()); bool offn = pdg::IsNeutron(tgt.HitNucPdg()); if (isem && offp) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotemp[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (isem && offn) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotemn[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } if (isem) { - for(int i=0; iEvaluate(e[i]) * (1E+38/units::cm2)); + for (int i = 0; i < kNSplineP; i++) { + xstotem[i] += (spl->Evaluate(e[i]) * (1E+38 / units::cm2)); } } } - TGraph * gr_totem = new TGraph(kNSplineP, e, xstotem); + TGraph *gr_totem = new TGraph(kNSplineP, e, xstotem); gr_totem->SetName("tot_em"); FormatXSecGraph(gr_totem); topdir->Add(gr_totem); - TGraph * gr_totemp = new TGraph(kNSplineP, e, xstotemp); + TGraph *gr_totemp = new TGraph(kNSplineP, e, xstotemp); gr_totemp->SetName("tot_em_p"); FormatXSecGraph(gr_totemp); topdir->Add(gr_totemp); - TGraph * gr_totemn = new TGraph(kNSplineP, e, xstotemn); + TGraph *gr_totemn = new TGraph(kNSplineP, e, xstotemn); gr_totemn->SetName("tot_em_n"); FormatXSecGraph(gr_totemn); topdir->Add(gr_totemn); - delete [] e; - delete [] xs; - delete [] xsresemp; - delete [] xsresemn; - delete [] xsdisemp; - delete [] xsdisemn; - delete [] xstotem; - delete [] xstotemp; - delete [] xstotemn; + delete[] e; + delete[] xs; + delete[] xsresemp; + delete[] xsresemn; + delete[] xsdisemp; + delete[] xsdisemn; + delete[] xstotem; + delete[] xstotemp; + delete[] xstotemn; - }// charged leptons + } // charged leptons topdir->Write(); - if(froot) { + if (froot) { froot->Close(); delete froot; } } //____________________________________________________________________________ -void SaveNtupleToRootFile(void) -{ -/* - //-- create cross section ntuple - // - double brXSec; - double brEv; - bool brIsQel; - bool brIsRes; - bool brIsDis; - bool brIsCoh; - bool brIsImd; - bool brIsNuEEl; - bool brIsCC; - bool brIsNC; - int brNucleon; - int brQrk; - bool brIsSeaQrk; - int brRes; - bool brCharm; - TTree * xsecnt = new TTree("xsecnt",dtitle.str().c_str()); - xsecnt->Branch("xsec", &brXSec, "xsec/D"); - xsecnt->Branch("e", &brEv, "e/D"); - xsecnt->Branch("qel", &brIsQel, "qel/O"); - xsecnt->Branch("res", &brIsRes, "res/O"); - xsecnt->Branch("dis", &brIsDis, "dis/O"); - xsecnt->Branch("coh", &brIsCoh, "coh/O"); - xsecnt->Branch("imd", &brIsImd, "imd/O"); - xsecnt->Branch("veel", &brIsNuEEl, "veel/O"); - xsecnt->Branch("cc", &brIsCC, "cc/O"); - xsecnt->Branch("nc", &brIsNC, "nc/O"); - xsecnt->Branch("nuc", &brNucleon, "nuc/I"); - xsecnt->Branch("qrk", &brQrk, "qrk/I"); - xsecnt->Branch("sea", &brIsSeaQrk, "sea/O"); - xsecnt->Branch("res", &brRes, "res/I"); - xsecnt->Branch("charm", &brCharm, "charm/O"); -*/ +void SaveNtupleToRootFile(void) { + /* + //-- create cross section ntuple + // + double brXSec; + double brEv; + bool brIsQel; + bool brIsRes; + bool brIsDis; + bool brIsCoh; + bool brIsImd; + bool brIsNuEEl; + bool brIsCC; + bool brIsNC; + int brNucleon; + int brQrk; + bool brIsSeaQrk; + int brRes; + bool brCharm; + TTree * xsecnt = new TTree("xsecnt",dtitle.str().c_str()); + xsecnt->Branch("xsec", &brXSec, "xsec/D"); + xsecnt->Branch("e", &brEv, "e/D"); + xsecnt->Branch("qel", &brIsQel, "qel/O"); + xsecnt->Branch("res", &brIsRes, "res/O"); + xsecnt->Branch("dis", &brIsDis, "dis/O"); + xsecnt->Branch("coh", &brIsCoh, "coh/O"); + xsecnt->Branch("imd", &brIsImd, "imd/O"); + xsecnt->Branch("veel", &brIsNuEEl, "veel/O"); + xsecnt->Branch("cc", &brIsCC, "cc/O"); + xsecnt->Branch("nc", &brIsNC, "nc/O"); + xsecnt->Branch("nuc", &brNucleon, "nuc/I"); + xsecnt->Branch("qrk", &brQrk, "qrk/I"); + xsecnt->Branch("sea", &brIsSeaQrk, "sea/O"); + xsecnt->Branch("res", &brRes, "res/I"); + xsecnt->Branch("charm", &brCharm, "charm/O"); + */ } //____________________________________________________________________________ -void GetCommandLineArgs(int argc, char ** argv) -{ +void GetCommandLineArgs(int argc, char **argv) { LOG("gspl2root", pINFO) << "Parsing command line arguments"; // Common run options. Set defaults and read. - RunOpt::Instance()->ReadFromCommandLine(argc,argv); + RunOpt::Instance()->ReadFromCommandLine(argc, argv); // Parse run options for this app - CmdLnArgParser parser(argc,argv); + CmdLnArgParser parser(argc, argv); // input XML file name: - if( parser.OptionExists('f') ) { + if (parser.OptionExists('f')) { LOG("gspl2root", pINFO) << "Reading input XML filename"; gOptXMLFilename = parser.ArgAsString('f'); } else { @@ -1461,62 +1545,61 @@ void GetCommandLineArgs(int argc, char ** argv) } // probe PDG code: - if( parser.OptionExists('p') ) { + if (parser.OptionExists('p')) { LOG("gspl2root", pINFO) << "Reading probe PDG code"; gOptProbePdgList = GetPDGCodeListFromString(parser.ArgAsString('p')); } else { - LOG("gspl2root", pFATAL) - << "Unspecified probe PDG code - Exiting"; + LOG("gspl2root", pFATAL) << "Unspecified probe PDG code - Exiting"; PrintSyntax(); exit(1); } // target PDG code: - if( parser.OptionExists('t') ) { + if (parser.OptionExists('t')) { LOG("gspl2root", pINFO) << "Reading target PDG code"; gOptTgtPdgList = GetPDGCodeListFromString(parser.ArgAsString('t')); } else { - LOG("gspl2root", pFATAL) - << "Unspecified target PDG code - Exiting"; + LOG("gspl2root", pFATAL) << "Unspecified target PDG code - Exiting"; PrintSyntax(); exit(1); } // min,max neutrino energy - if( parser.OptionExists('e') ) { + if (parser.OptionExists('e')) { LOG("gspl2root", pINFO) << "Reading neutrino energy"; string nue = parser.ArgAsString('e'); // is it just a value or a range (comma separated set of values) - if(nue.find(",") != string::npos) { - // split the comma separated list - vector nurange = utils::str::Split(nue, ","); - assert(nurange.size() == 2); - gEmin = atof(nurange[0].c_str()); - gEmax = atof(nurange[1].c_str()); + if (nue.find(",") != string::npos) { + // split the comma separated list + vector nurange = utils::str::Split(nue, ","); + assert(nurange.size() == 2); + gEmin = atof(nurange[0].c_str()); + gEmax = atof(nurange[1].c_str()); } else { - const Registry * val_reg = AlgConfigPool::Instance() -> CommonList( "Param", "Validation" ) ; - gEmin = val_reg -> GetDouble( "GVLD-Emin" ) ; + const Registry *val_reg = + AlgConfigPool::Instance()->CommonList("Param", "Validation"); + gEmin = val_reg->GetDouble("GVLD-Emin"); gEmax = atof(nue.c_str()); - LOG("gspl2root", pDEBUG) - << "Unspecified Emin - Setting to " << gEmin << " GeV as per configuration"; + LOG("gspl2root", pDEBUG) << "Unspecified Emin - Setting to " << gEmin + << " GeV as per configuration"; } } else { - const Registry * val_reg = AlgConfigPool::Instance() -> CommonList("Param", "Validation" ) ; - gEmin = val_reg -> GetDouble( "GVLD-Emin" ) ; + const Registry *val_reg = + AlgConfigPool::Instance()->CommonList("Param", "Validation"); + gEmin = val_reg->GetDouble("GVLD-Emin"); gEmax = 100; LOG("gspl2root", pDEBUG) - << "Unspecified Emin,Emax - Setting to " << gEmin << ",100 GeV "; - + << "Unspecified Emin,Emax - Setting to " << gEmin << ",100 GeV "; } - assert(gEmin isvec = utils::str::Split(s,","); +PDGCodeList GetPDGCodeListFromString(std::string s) { + vector isvec = utils::str::Split(s, ","); // fill in the PDG code list PDGCodeList list; vector::const_iterator iter; - for(iter = isvec.begin(); iter != isvec.end(); ++iter) { - list.push_back( atoi(iter->c_str()) ); + for (iter = isvec.begin(); iter != isvec.end(); ++iter) { + list.push_back(atoi(iter->c_str())); } return list; - } //____________________________________________________________________________ diff --git a/src/Framework/Conventions/KinePhaseSpace.h b/src/Framework/Conventions/KinePhaseSpace.h index 59ad95638..aacf1b80c 100644 --- a/src/Framework/Conventions/KinePhaseSpace.h +++ b/src/Framework/Conventions/KinePhaseSpace.h @@ -72,7 +72,10 @@ typedef enum EKinePhaseSpace { kPSlog10xlog10Q2fE, kPSEDNufE, // Used for Dark Neutrinos, two body final state kPSn1n2fE, - kPSn1n2n3fE + kPSn1n2n3fE, + kPSEgTlTgPgfE, + kPSEgOlOgfE, + kPSEgtTgPgfE } KinePhaseSpace_t; class KinePhaseSpace @@ -95,8 +98,8 @@ class KinePhaseSpace case(kPSlogyfE) : return "<{logy}|E>"; break; case(kPSyfEx) : return "<{y}|E,x>"; break; case(kPSlogyfEx) : return "<{logy}|E,x>"; break; - case(kPSlogxlogyfE) : return "<{logx,logy}|E>"; break; case(kPSxyfE) : return "<{x,y}|E>"; break; + case(kPSlogxlogyfE) : return "<{logx,logy}|E>"; break; case(kPSxQ2fE) : return "<{x,Q2}|E>"; break; case(kPSQ2fE) : return "<{Q2}|E>"; break; case(kPSQD2fE) : return "<{QD2}|E>"; break; @@ -120,18 +123,20 @@ class KinePhaseSpace case(kPSlogQ2logyfE): return "<{Q2,y}|E>"; break; case(kPSTlctl) : return "<{Tl,cos(theta_l)}|E>"; break; case(kPSElOlOpifE) : return "<{El,Omega_l,Omega_pi}|E>"; break; - case(kPSEgTlOgfE) : return "<{Egamma,Theta_l,Omega_gamma}|E>"; break; case(kPSElOlTpifE) : return "<{El,Omega_l,Theta_pi}|E>"; break; case(kPSTkTlctl) : return "<{Tk,Tl,cos(theta_l)}|E>"; break; case(kPSQ2vfE) : return "<{Q2,v}|E>"; break; - // TODO: update this string when the appropriate kinematic variables are known case(kPSQELEvGen) : return ""; break; - case(kPSDMELEvGen) : return ""; break; case(kPSTAfE) : return "<{TA}|E>"; break; + case(kPSEgTlOgfE) : return "<{Egamma,Theta_l,Omega_gamma}|E>"; break; + case(kPSDMELEvGen) : return ""; break; case(kPSlog10xlog10Q2fE) : return "<{log10x,log10Q2}|E>"; break; case(kPSEDNufE) : return "<{EDNu}|E>"; break; case(kPSn1n2fE) : return "<{n1,n2}|E>"; break; case(kPSn1n2n3fE) : return "<{n1,n2,n3}|E>"; break; + case(kPSEgTlTgPgfE) : return "<{Egamma,Theta_l,Theta_gamma,Phi_gamma}|E>"; break; + case(kPSEgOlOgfE) : return "<{Egamma,Omega_l,Omega_gamma}|E>"; break; + case(kPSEgtTgPgfE) : return "<{Egamma,t,Theta_gamma,Phi_gamma}|E>"; break; } return "** Undefined kinematic phase space **"; } diff --git a/src/Framework/Numerical/ComplexMatrix.h b/src/Framework/Numerical/ComplexMatrix.h new file mode 100644 index 000000000..c27394c2e --- /dev/null +++ b/src/Framework/Numerical/ComplexMatrix.h @@ -0,0 +1,136 @@ +//____________________________________________________________________________ +/*! + + \namespace genie::utils::math + + \brief Utilities for ComplexMatrix definitions + + \author Costas Andreopoulos + University of Liverpool & STFC Rutherford Appleton Lab + + \created July, 2020 + + \cpright Copyright (c) 2003-2020, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COMPLEX_MATRIX_H_ +#define _COMPLEX_MATRIX_H_ + +#include +#include +#include + +namespace genie { + namespace utils { + + namespace math { + + template< size_t N > + class ComplexArray : public std::array< std::complex, N > { + + public: + const ComplexArray & operator += ( const ComplexArray & ) ; + const ComplexArray & operator *= ( const std::complex & ) ; + + ComplexArray Conj() const ; + } ; + + template< size_t N > + class ComplexMatrix : public std::array< ComplexArray, N > { + + public: + const ComplexMatrix & operator += ( const ComplexMatrix & ) ; + const ComplexMatrix & operator *= ( const std::complex & ) ; + + ComplexMatrix Conj() const ; + + }; + + // all these classes are templated, so they need the implementation locally + + + template + const ComplexArray & ComplexArray::operator += ( const ComplexArray & v ) { + + for ( unsigned int i = 0 ; i < this->size(); ++i ) { + this->at(i) += v[i] ; + } + + return *this ; + } + + //____________________________________________________________________________ + + template + const ComplexArray & ComplexArray::operator *= ( const std::complex & c ) { + + for ( unsigned int i = 0 ; i < this->size(); ++i ) { + this -> at(i) *= c ; + } + + return *this ; + + } + + //____________________________________________________________________________ + template + ComplexArray ComplexArray::Conj() const { + + ComplexArray a; + for ( unsigned int i = 0 ; i < this->size(); ++i ) { + a[i] = std::conj( this->at(i) ) ; + } + + return a ; + } + + //____________________________________________________________________________ + + template + const ComplexMatrix & ComplexMatrix::operator += ( const ComplexMatrix & m ) { + + for ( unsigned int i = 0 ; i < this->size(); ++i ) { + this->at(i) += m[i] ; + } + + return *this ; + } + + //____________________________________________________________________________ + + template + const ComplexMatrix & ComplexMatrix::operator *= ( const std::complex & c ) { + + for ( unsigned int i = 0 ; i < this->size(); ++i ) { + this->at(i) *= c ; + } + + return *this ; + } + + //____________________________________________________________________________ + template + ComplexMatrix ComplexMatrix::Conj() const { + + ComplexMatrix a; + for ( unsigned int i = 0 ; i < this->size(); ++i ) { + a[i] = this->at(i).Conj() ; + } + + return a ; + } + + //____________________________________________________________________________ + + + + + + } // math namespace + } // utils namespace +} // genie namespace + +#endif // _COMPLEX_MATRIX_H_ diff --git a/src/Framework/Numerical/GTrace.cxx b/src/Framework/Numerical/GTrace.cxx new file mode 100644 index 000000000..24aedd413 --- /dev/null +++ b/src/Framework/Numerical/GTrace.cxx @@ -0,0 +1,19 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + For documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include "Framework/Numerical/GTrace.h" + +using namespace genie::utils::math; + + diff --git a/src/Framework/Numerical/GTrace.h b/src/Framework/Numerical/GTrace.h new file mode 100644 index 000000000..97db9bcc2 --- /dev/null +++ b/src/Framework/Numerical/GTrace.h @@ -0,0 +1,52 @@ +//____________________________________________________________________________ +/*! + + \class genie::utils::math::GTrace + + \brief Simple math container for 4 x 4 complex objects + + \author Costas Andreopoulos + University of Liverpool & STFC Rutherford Appleton Lab + + Marco Roda + University of Liverpool + + \created May 15, 2020 + + \cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _MATH_UTILS_GTRACE_H_ +#define _MATH_UTILS_GTRACE_H_ + +#include "Framework/Numerical/ComplexMatrix.h" + +namespace genie { + namespace utils { + + namespace math { + + using GTrace = ComplexMatrix<4> ; + + class GTraceContraction : public std::pair { + public: + + GTraceContraction( const GTrace & t ) : + std::pair(t.Conj(), t) { ; } + + GTraceContraction( const GTrace & a, const GTrace & b ) : + std::pair(a, b) { ; } + + std::complex operator()( uint8_t i, uint8_t j, + uint8_t m, uint8_t n) const { + return first[i][j] * second[m][n] ; } + }; + + } // math namespace + } // utils namespace +} // genie namespace + +#endif // _MATH_UTILS_GTRACE_H_ diff --git a/src/Framework/Numerical/MathUtils.h b/src/Framework/Numerical/MathUtils.h index 805a90b75..dab68a976 100644 --- a/src/Framework/Numerical/MathUtils.h +++ b/src/Framework/Numerical/MathUtils.h @@ -1,14 +1,14 @@ //____________________________________________________________________________ /*! -\namespace genie::utils::math + \namespace genie::utils::math -\brief Simple mathematical utilities not found in ROOT's TMath + \brief Simple mathematical utilities not found in ROOT's TMath -\author Costas Andreopoulos - University of Liverpool & STFC Rutherford Appleton Laboratory + \author Costas Andreopoulos + University of Liverpool & STFC Rutherford Appleton Laboratory -\created May 06, 2004 + \created May 06, 2004 \cpright Copyright (c) 2003-2023, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org @@ -19,6 +19,8 @@ #define _MATH_UTILS_H_ #include +#include +#include #include #include #include diff --git a/src/Framework/Utils/XSecSplineList.cxx b/src/Framework/Utils/XSecSplineList.cxx index dbfba9f50..2313e91de 100644 --- a/src/Framework/Utils/XSecSplineList.cxx +++ b/src/Framework/Utils/XSecSplineList.cxx @@ -11,6 +11,8 @@ #include //provides: int feenableexcept(int excepts); #include //provides: std::isnan() +#include + #include #include @@ -36,6 +38,8 @@ using std::endl; namespace genie { + using namespace std::chrono ; + //____________________________________________________________________________ ostream & operator << (ostream & stream, const XSecSplineList & list) { @@ -239,10 +243,18 @@ void XSecSplineList::CreateSpline(const XSecAlgorithmI * alg, p4.SetPz(pz); } interaction->InitStatePtr()->SetProbeP4(p4); + + steady_clock::time_point start = steady_clock::now(); + xsec[i] = alg->Integral(interaction); + + steady_clock::time_point end = steady_clock::now(); + + duration time_span = duration_cast>(end - start); + SLOG("XSecSplLst", pNOTICE) << "xsec(E = " << E[i] << ") = " - << (1E+38/units::cm2)*xsec[i] << " x 1E-38 cm^2"; + << (1E+38/units::cm2)*xsec[i] << " x 1E-38 cm^2, evaluated in " << time_span.count() << " s"; if ( std::isnan(xsec[i]) ) { // this sometimes happens near threshold, warn and move on SLOG("XSecSplLst", pWARN) diff --git a/src/Physics/Coherent/EventGen/COHGammaKinematicsGenerator.cxx b/src/Physics/Coherent/EventGen/COHGammaKinematicsGenerator.cxx new file mode 100644 index 000000000..795a378e6 --- /dev/null +++ b/src/Physics/Coherent/EventGen/COHGammaKinematicsGenerator.cxx @@ -0,0 +1,466 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda < mroda \at liverpool.ac.uk> + University of Liverpool + + For the class documentation see the corresponding header file. + + Important revisions after version 2.0.0 : + @ Feb 09, 2009 - CA + Moved into the new Coherent package from its previous location (EVGModules + package) + @ Mar 03, 2009 - CA + Renamed COHPiKinematicsGenerator -> COHKinematicsGenerator in + anticipation of reusing the code for simulating coherent production of + vector mesons. + @ May 06, 2009 - CA + Fix a problem with the search for the max cross section over the allowed + phase space which prevented kinematics to be generated for events near the + energy threshold. + @ Feb 06, 2013 - CA + When the value of the differential cross-section for the selected kinematics + is set to the event, set the corresponding KinePhaseSpace_t value too. + +*/ +//____________________________________________________________________________ + +#include +#include +#include +#include +#include // std::accumulate +#include +#include + +#include +#include +#include "Math/Minimizer.h" +#include "Math/Factory.h" +#include + +#include "Framework/Algorithm/AlgConfigPool.h" +#include "Framework/Conventions/Constants.h" +#include "Framework/Conventions/Controls.h" +#include "Framework/Conventions/GBuild.h" +#include "Framework/Conventions/KinePhaseSpace.h" +#include "Framework/Conventions/Units.h" +#include "Framework/EventGen/EVGThreadException.h" +#include "Framework/EventGen/EventGeneratorI.h" +#include "Framework/EventGen/RunningThreadInfo.h" +#include "Framework/GHEP/GHepFlags.h" +#include "Framework/GHEP/GHepRecord.h" +#include "Framework/Messenger/Messenger.h" +#include "Framework/Numerical/RandomGen.h" +#include "Framework/Utils/KineUtils.h" +#include "Physics/Coherent/EventGen/COHGammaKinematicsGenerator.h" +#include "Physics/XSectionIntegration/GSLXSecFunc.h" + +using namespace genie; +using namespace genie::constants; +using namespace genie::controls; +using namespace genie::utils; + +//___________________________________________________________________________ +COHGammaKinematicsGenerator::COHGammaKinematicsGenerator() + : KineGeneratorWithCache("genie::COHGammaKinematicsGenerator"), + fGammaLimits(nullptr), ftPhaseSpace(true) {} +//___________________________________________________________________________ +COHGammaKinematicsGenerator::COHGammaKinematicsGenerator(string config) + : KineGeneratorWithCache("genie::COHGammaKinematicsGenerator", config), + fGammaLimits(nullptr), ftPhaseSpace(true) {} +//___________________________________________________________________________ +COHGammaKinematicsGenerator::~COHGammaKinematicsGenerator() {} +//___________________________________________________________________________ +void COHGammaKinematicsGenerator::ProcessEventRecord(GHepRecord *evrec) const { + if (fGenerateUniformly) { + LOG("COHGammaKinematicsGenerator", pNOTICE) + << "Generating kinematics uniformly over the allowed phase space"; + } + + Interaction *in = evrec->Summary(); + + RunningThreadInfo *rtinfo = RunningThreadInfo::Instance(); + const EventGeneratorI *evg = rtinfo->RunningThread(); + fXSecModel = evg->CrossSectionAlg(); + + if (!fXSecModel->ValidProcess(in)) { + std::stringstream message; + message << "Cannot calculate kinematics for " << fXSecModel->Id().Name(); + + LOG("COHGammaKinematicsGenerator", pFATAL) << message.str(); + + exceptions::EVGThreadException ex; + ex.SetReason(message.str()); + ex.SwitchOnFastForward(); + throw ex; + } + + in->SetBit(kISkipProcessChk); + + double xsec_max = (fGenerateUniformly) ? -1 : this->ComputeMaxXSec(in); + + // Initialise a random number generator + RandomGen *rnd = RandomGen::Instance(); + + //-- For the subsequent kinematic selection with the rejection method: + // Calculate the max differential cross section or retrieve it from the + // cache. Throw an exception and quit the evg thread if a non-positive + // value is found. + // If the kinematics are generated uniformly over the allowed phase + // space the max xsec is irrelevant + + std::array ranges = { + fGammaLimits->EGamma(*in), + ftPhaseSpace ? fGammaLimits->t(*in) : fGammaLimits->ThetaLepton(*in), + fGammaLimits->ThetaGamma(*in), fGammaLimits->PhiGamma(*in)}; + + std::array widths; + for (unsigned int i = 0; i < ranges.size(); ++i) { + widths[i] = ranges[i].max - ranges[i].min; + } + + //------ Try to select a valid set of kinematics + unsigned int iter = 0; + bool accept=false; + + double xsec=-1 ; + std::array point ; + + Interaction local_interaction( * in ) ; + + std::unique_ptr func = nullptr ; + if ( ftPhaseSpace ) func.reset( new utils::gsl::d4Xsec_dEgdtdThetagdPhig( fXSecModel, & local_interaction ) ); + else func.reset( new utils::gsl::d4Xsec_dEgdThetaldThetagdPhig( fXSecModel, & local_interaction ) ) ; + + while(1) { + iter++; + + if (iter > fMaxIterations) + this->throwOnTooManyIterations(iter, evrec); + + // generate the kinematic point + for (unsigned int i = 0; i < ranges.size(); ++i) { + point[i] = ranges[i].min + widths[i] * rnd->RndKine().Rndm(); + } + + // LOG("COHKinematics", pINFO) << "Trying: Gamma(" << g_E_g << ", " + // << g_theta_g << ", " << g_phi_g << "), Lep(" + // << g_theta_l << ")"; + + xsec = (*func)(point.data()); + + // realized this method assumes E_l + + if (!fGenerateUniformly) { + //-- decide whether to accept the current kinematics + double t = xsec_max * rnd->RndKine().Rndm(); + + LOG("COHKinematics", pINFO) << "Got: xsec = " << xsec << ", t = " << t + << " (max_xsec = " << xsec_max << ")"; + + double f = 200*(xsec-xsec_max)/(xsec_max+xsec); + if ( f>fMaxXSecDiffTolerance ) { + xsec_max = xsec * fSafetyFactor; + LOG("COHKinematics", pWARN) << "Cross section maximum has been overridden to " << xsec_max ; + continue; + } + + + // this->AssertXSecLimits(in, xsec, xsec_max); + +#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ + LOG("COHKinematics", pDEBUG) << "xsec= " << xsec << ", J= 1, Rnd= " << t; +#endif + accept = (t < xsec); + } else { + accept = (xsec > 0); + } + + //-- If the generated kinematics are accepted, finish-up module's job + + if (accept) { + + // update kinematic variables + Kinematics *kine = in->KinePtr(); + const Kinematics &local_kine = local_interaction.Kine(); + + kine->Setx(local_kine.x(), true); + kine->Sety(local_kine.y(), true); + kine->SetQ2(local_kine.Q2(), true); + kine->SetW(local_kine.W(), true); + kine->Sett(local_kine.t(), true); + + // generate the phase for the lepton + double phi_l = 2 * constants::kPi * + rnd->RndKine().Rndm(); // final overall roation added + + // add the phase to both lepton and gamma so that the relative is the same + TLorentzVector lep(local_kine.FSLeptonP4()); + lep.SetPhi(phi_l); + kine->SetFSLeptonP4(lep); + + TLorentzVector gamma(local_kine.HadSystP4()); + double phi_g = gamma.Phi(); + phi_g += phi_l; + gamma.SetPhi(phi_g); + kine->SetHadSystP4(gamma); + + // for uniform kinematics, compute an event weight as + // wght = (phase space volume)*(differential xsec)/(event total xsec) + if (fGenerateUniformly) { + // Phase space volume needs checking + double vol = std::accumulate(widths.begin(), widths.end(), 1., + std::multiplies()); + double totxsec = evrec->XSec(); + double wght = (vol / totxsec) * xsec; + LOG("COHKinematics", pNOTICE) << "Kinematics wght = " << wght; + + // apply computed weight to the current event weight + wght *= evrec->Weight(); + LOG("COHKinematics", pNOTICE) << "Current event wght = " << wght; + evrec->SetWeight(wght); + } + + evrec->SetDiffXSec(xsec, kPSEgTlTgPgfE); + + // reset bits + in -> ResetBit(kISkipProcessChk); + in -> ResetBit(kISkipKinematicChk); + + break ; + }//if accept + + }//while still throwing events + + return; +} +//___________________________________________________________________________ +double +COHGammaKinematicsGenerator::ComputeMaxXSec(const Interaction *in) const { + // Computes the maximum differential cross section in the requested phase + // space. This method overloads KineGeneratorWithCache::ComputeMaxXSec + // method and the value is cached at a circular cache branch for retrieval + // during subsequent event generation. + +#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ + SLOG("COHKinematics", pDEBUG) + << "Scanning the allowed phase space {K} for the max(dxsec/d{K})"; +#endif + + std::cout << "Looking for the minimum \n" ; + + std::unique_ptr min( ROOT::Math::Factory::CreateMinimizer("Minuit2" ) ); + + // min -> SetPrintLevel(3) ; + + gsl::d4Xsec_dEgdThetaldThetagdPhig f(fXSecModel, in); + f.SetFactor( + -1.); // Make it return negative of cross-section so we can minimize + + min->SetFunction(f); + min->SetMaxFunctionCalls(10000); + min->SetTolerance(0.05); // not sure what this does.... + + // need min, max, n, and d for all the xsec varables + // for COH gamma they are Eg, theta_l theta_gamma, phi_gamma + // then set variables and get min + + std::array names = {"E_g", ftPhaseSpace ? "t" : "theta_l", + "theta_g", "phi_g"}; + + std::array ranges = { + fGammaLimits->EGamma(*in), + ftPhaseSpace ? fGammaLimits->t(*in) : fGammaLimits->ThetaLepton(*in), + fGammaLimits->ThetaGamma(*in), fGammaLimits->PhiGamma(*in)}; + + std::array start, steps, temp_point; + // Please note that if Minuit2 minimizer is used, the steps are not used + // but for consistency we are evaluating it + + double max_xsec = -1. ; + + double e_nu = in->InitState().ProbeE( kRfLab ) ; + + auto scan_points = fMinimScanPoints ; + for ( int i = 0; i < scan_points.size() ; ++i ) { + scan_points[i] += ceil( e_nu * fScaleScanPoints[i] ); + } + + unsigned int max_xsec_iteractions = 0 ; + + while ( max_xsec <= 0. ) { + + for( auto & p : scan_points ) { + p *= (max_xsec_iteractions+1) ; + std::cout << p << std::endl ; + } + + for (unsigned int i = 0; i < ranges.size(); ++i) { + double width = ranges[i].max - ranges[i].min; + steps[i] = width / (scan_points[i] + 1); + } + + + + + double xsec = 0; + + // preliimnary scan + for (unsigned int i = 1; i <= scan_points[0]; ++i) { + temp_point[0] = ranges[0].min + steps[0] * i; + + for (unsigned int j = 1; j <= scan_points[1]; ++j) { + temp_point[1] = ranges[1].min + steps[1] * j; + + for (unsigned int k = 1; k <= scan_points[2]; ++k) { + temp_point[2] = ranges[2].min + steps[2] * k; + + for (unsigned int l = 1; l <= scan_points[3]; ++l) { + temp_point[3] = ranges[3].min + steps[3] * l; + + double temp_xsec = -f(temp_point.data()); + //std::cout << temp_xsec << std::endl; + if (temp_xsec > xsec) { + start = temp_point; + xsec = temp_xsec; + } + } + } + } + } + + std::cout << "Minimising using minuit \n"; + std::cout << xsec << std::endl; + + for (unsigned int i = 0; i < ranges.size(); ++i) { + min->SetLimitedVariable(i, names[i], + start[i], + 1E-6*steps[i], + ranges[i].min, ranges[i].max); + } + + min->Minimize(); + + max_xsec = -min->MinValue(); // back to positive xsec + std::cout << max_xsec << std::endl; + + ++ max_xsec_iteractions ; + } // while max_xsec <= 0. + + // Apply safety factor, since value retrieved from the cache might + // correspond to a slightly different energy. + max_xsec *= fSafetyFactor; + +#ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ + SLOG("COHKinematics", pDEBUG) << in->AsString(); + SLOG("COHKinematics", pDEBUG) << "Max xsec in phase space = " << max_xsec; + SLOG("COHKinematics", pDEBUG) << "Computed using alg = " << fXSecModel->Id(); +#endif + + return max_xsec; +} +//___________________________________________________________________________ +double +COHGammaKinematicsGenerator::Energy(const Interaction *interaction) const { + // Override the base class Energy() method to cache the max xsec for the + // neutrino energy in the LAB rather than in the hit nucleon rest frame. + + const InitialState &init_state = interaction->InitState(); + double E = init_state.ProbeE(kRfLab); + return E; +} +//___________________________________________________________________________ +void COHGammaKinematicsGenerator::throwOnTooManyIterations(unsigned int iters, + GHepRecord* evrec) const +{ + LOG("COHKinematics", pWARN) + << "*** Could not select valid kinematics after " + << iters << " iterations"; + evrec->EventFlags()->SetBitNumber(kKineGenErr, true); + genie::exceptions::EVGThreadException exception; + exception.SetReason("Couldn't select kinematics"); + exception.SwitchOnStepBack() ; + exception.SetReturnStep(0) ; // this is the kinematic generator + throw exception; +} +//___________________________________________________________________________ +void COHGammaKinematicsGenerator::Configure(const Registry &config) { + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void COHGammaKinematicsGenerator::Configure(string config) { + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void COHGammaKinematicsGenerator::LoadConfig(void) { + + bool error = false; + + GetParamDef("tPhaseSpace", ftPhaseSpace, false); + + //-- max xsec safety factor (for rejection method) and min cached energy + GetParamDef("MaxXSec-SafetyFactor", fSafetyFactor, 1.6); + GetParamDef("Cache-MinEnergy", fEMin, -1.0); + + //-- Generate kinematics uniformly over allowed phase space and compute + // an event weight? + GetParamDef("UniformOverPhaseSpace", fGenerateUniformly, false); + + //-- Maximum allowed fractional cross section deviation from maxim cross + // section used in rejection method + GetParamDef("MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 999999.); + assert(fMaxXSecDiffTolerance >= 0); + + int max_iter; + GetParamDef("MaxIterations", max_iter, (int)kRjMaxIterations); + if (max_iter > 0) { + fMaxIterations = max_iter; + } + + const Algorithm *temp = SubAlg("IntegrationLimits"); + fGammaLimits = dynamic_cast(temp); + if (!fGammaLimits) { + LOG("COHGammaKinematicsGenerator", pERROR) + << "Gamma integration limits subalgo failed to load"; + error = true; + } + + std::vector scan_points; + GetParamVect("MinimScanPoint", scan_points); + if (scan_points.size() < fMinimScanPoints.size()) { + LOG("COHGammaKinematicsGenerator", pERROR) + << "Not enough information for phase space scan"; + error = true; + } + + for (unsigned int i = 0; i < fMinimScanPoints.size(); ++i) { + fMinimScanPoints[i] = std::max(1, scan_points[i]); + } + + std::vector scale_scan_points; + GetParamVect("ScaleScanPoint", scale_scan_points); + if (scale_scan_points.size() < fScaleScanPoints.size()) { + LOG("COHGammaKinematicsGenerator", pERROR) + << "Not enough information for phase space scan"; + error = true; + } + + for (unsigned int i = 0; i < fScaleScanPoints.size(); ++i) { + fScaleScanPoints[i] = std::max(0., scale_scan_points[i]); + } + + + + if (error) { + LOG("COHGammaKinematicsGenerator", pFATAL) + << "Invalid configuration. Exiting"; + exit(78); + } +} +//____________________________________________________________________________ diff --git a/src/Physics/Coherent/EventGen/COHGammaKinematicsGenerator.h b/src/Physics/Coherent/EventGen/COHGammaKinematicsGenerator.h new file mode 100644 index 000000000..c0264e2a1 --- /dev/null +++ b/src/Physics/Coherent/EventGen/COHGammaKinematicsGenerator.h @@ -0,0 +1,71 @@ +//____________________________________________________________________________ +/*! + +\class genie::COHGammaKinematicsGenerator + +\brief Generates values for the kinematic variables describing coherent + neutrino-nucleus pion production events. + Is a concrete implementation of the EventRecordVisitorI interface. + +\author Costas Andreopoulos + University of Liverpool & STFC Rutherford Appleton Lab + +\created October 03, 2004 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COH_GAMMA_KINEMATICS_GENERATOR_H_ +#define _COH_GAMMA_KINEMATICS_GENERATOR_H_ + +#include "Physics/Common/KineGeneratorWithCache.h" +#include "Framework/Utils/Range1.h" + +#include "Physics/Coherent/XSection/COHGammaIntegrationLimits.h" + +namespace genie { + + class COHGammaKinematicsGenerator : public KineGeneratorWithCache { + + public : + COHGammaKinematicsGenerator(); + COHGammaKinematicsGenerator(string config); + ~COHGammaKinematicsGenerator(); + + // implement the EventRecordVisitorI interface + void ProcessEventRecord(GHepRecord * event_rec) const override ; + + // overload the Algorithm::Configure() methods to load private data + // members from configuration options + void Configure(const Registry & config) override ; + void Configure(string config) override ; + + // methods to load sub-algorithms and config data from the Registry + void LoadConfig (void); + + // overload KineGeneratorWithCache method to compute max xsec + double ComputeMaxXSec (const Interaction * in) const override ; + + // overload KineGeneratorWithCache method to get energy + // This can probably go + double Energy (const Interaction * in) const override ; + + + protected: + void throwOnTooManyIterations(unsigned int iters, GHepRecord* evrec) const; + + private: + + const COHGammaIntegrationLimits * fGammaLimits ; + std::array fMinimScanPoints ; + std::array fScaleScanPoints ; + bool ftPhaseSpace ; + + unsigned int fMaxIterations ; + }; + +} // genie namespace +#endif // _COH_GAMMA_KINEMATICS_GENERATOR_H_ diff --git a/src/Physics/Coherent/EventGen/COHHadronicSystemGenerator.cxx b/src/Physics/Coherent/EventGen/COHHadronicSystemGenerator.cxx index 147a80395..fecc63833 100644 --- a/src/Physics/Coherent/EventGen/COHHadronicSystemGenerator.cxx +++ b/src/Physics/Coherent/EventGen/COHHadronicSystemGenerator.cxx @@ -51,24 +51,35 @@ COHHadronicSystemGenerator::~COHHadronicSystemGenerator() //___________________________________________________________________________ void COHHadronicSystemGenerator::ProcessEventRecord(GHepRecord * evrec) const { - // Access cross section algorithm for running thread - RunningThreadInfo * rtinfo = RunningThreadInfo::Instance(); - const EventGeneratorI * evg = rtinfo->RunningThread(); - const XSecAlgorithmI *fXSecModel = evg->CrossSectionAlg(); - if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { - CalculateHadronicSystem_ReinSehgal(evrec); - } else if ((fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015")) { - CalculateHadronicSystem_BergerSehgal(evrec); - } else if ((fXSecModel->Id().Name() == "genie::BergerSehgalFMCOHPiPXSec2015")) { - CalculateHadronicSystem_BergerSehgalFM(evrec); - } else if ((fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec")) { - CalculateHadronicSystem_AlvarezRuso(evrec); + + const Interaction * interaction = evrec -> Summary() ; + const XclsTag & xcls = interaction -> ExclTag() ; + + if ( xcls.NPions() ==1 ) { + + // Access cross section algorithm for running thread + RunningThreadInfo * rtinfo = RunningThreadInfo::Instance(); + const EventGeneratorI * evg = rtinfo->RunningThread(); + const XSecAlgorithmI *fXSecModel = evg->CrossSectionAlg(); + if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { + CalculateHadronicSystem_ReinSehgal(evrec); + } else if ((fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015")) { + CalculateHadronicSystem_BergerSehgal(evrec); + } else if ((fXSecModel->Id().Name() == "genie::BergerSehgalFMCOHPiPXSec2015")) { + CalculateHadronicSystem_BergerSehgalFM(evrec); + } else if (fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec") { + CalculateHadronicSystem_AlvarezRuso(evrec); + } + else { + LOG("COHHadronicSystemGenerator",pFATAL) << + "ProcessEventRecord >> Cannot calculate hadronic system for " << + fXSecModel->Id().Name(); + } } - else { - LOG("COHHadronicSystemGenerator",pFATAL) << - "ProcessEventRecord >> Cannot calculate hadronic system for " << - fXSecModel->Id().Name(); + else if ( xcls.NSingleGammas() == 1 ) { + CalculateHadronicSystem_AlvarezRuso(evrec); } + } //___________________________________________________________________________ int COHHadronicSystemGenerator::getPionPDGCodeFromXclTag(const XclsTag& xcls_tag) const @@ -321,51 +332,63 @@ void COHHadronicSystemGenerator::CalculateHadronicSystem_ReinSehgal(GHepRecord * //___________________________________________________________________________ void COHHadronicSystemGenerator::CalculateHadronicSystem_AlvarezRuso(GHepRecord * evrec) const { - Interaction * interaction = evrec->Summary(); + const Interaction * interaction = evrec->Summary(); const Kinematics & kinematics = interaction -> Kine(); - GHepParticle * nu = evrec->Probe(); - GHepParticle * Ni = evrec->TargetNucleus(); - GHepParticle * fsl = evrec->FinalStatePrimaryLepton(); - - // Pion - const TLorentzVector ppi = kinematics.HadSystP4(); - const TVector3 ppi3 = ppi.Vect(); - const double Epi = ppi.E(); - int pion_pdgc=0; - if ( interaction->ProcInfo().IsWeakCC() ) { - if( nu->Pdg() > 0 ){ // neutrino - pion_pdgc = kPdgPiP; + const GHepParticle * nu = evrec->Probe(); + const GHepParticle * Ni = evrec->TargetNucleus(); + const GHepParticle * fsl = evrec->FinalStatePrimaryLepton(); + + const XclsTag & xcls = interaction->ExclTag(); + + int other_pdgc = 0 ; + + // Produced Particle + if ( xcls.NPions() > 0 ) { + if ( interaction->ProcInfo().IsWeakCC() ) { + if( nu->Pdg() > 0 ){ // neutrino + other_pdgc = kPdgPiP; + } + else{ // anti-neutrino + other_pdgc = kPdgPiM; + } } - else{ // anti-neutrino - pion_pdgc = kPdgPiM; + else if ( interaction->ProcInfo().IsWeakNC() ) { + other_pdgc = kPdgPi0; + } + else{ + LOG("COHHadronicSystemGeneratorAR", pFATAL) + << "Could not determine pion involved in interaction"; + exit(1); } } - else if ( interaction->ProcInfo().IsWeakNC() ) { - pion_pdgc = kPdgPi0; - } - else{ - LOG("COHHadronicSystemGeneratorAR", pFATAL) - << "Could not determine pion involved in interaction"; - exit(1); + else if ( xcls.NSingleGammas() > 0 ) { + other_pdgc = kPdgGamma ; } - // - // Nucleus - int nucl_pdgc = Ni->Pdg(); // pdg of final nucleus same as the initial nucleus - double pxNf = nu->Px() + Ni->Px() - fsl->Px() - ppi3.Px(); - double pyNf = nu->Py() + Ni->Py() - fsl->Py() - ppi3.Py(); - double pzNf = nu->Pz() + Ni->Pz() - fsl->Pz() - ppi3.Pz(); - double ENf = nu->E() + Ni->E() - fsl->E() - Epi; - // - // Both + // determin the momemntum of the other + // including rotations due to incoming particle + const TLorentzVector * nu_p4 = evrec->Probe() -> P4() ; + TVector3 nu_dir = nu_p4 -> Vect().Unit() ; + + TVector3 other_p3 = kinematics.HadSystP4().Vect(); + other_p3.RotateUz( nu_dir ) ; + TLorentzVector other_p4( other_p3, kinematics.HadSystP4().E() ) ; + + // Both produced particle and recoil nucleus need to know where they are produced + // and their mother const TLorentzVector & vtx = *(nu->X4()); int mom = evrec->TargetNucleusPosition(); - - // + + evrec->AddParticle( other_pdgc,kIStStableFinalState, + mom,-1,-1,-1, + other_p4, vtx ) ; + + // evaluate Recoil mmomentum + TLorentzVector nucl_p4 = *(nu->P4()) + *(Ni->P4()) - *(fsl->P4()) - other_p4 ; + // Fill the records - evrec->AddParticle(nucl_pdgc,kIStStableFinalState, mom,-1,-1,-1, - pxNf, pyNf, pzNf, ENf, 0, 0, 0, 0); + evrec->AddParticle( Ni->Pdg(),kIStStableFinalState, + mom,-1,-1,-1, + nucl_p4, vtx ) ; - evrec->AddParticle(pion_pdgc,kIStStableFinalState, mom,-1,-1,-1, - ppi3.Px(), ppi3.Py(),ppi3.Pz(),Epi, vtx.X(), vtx.Y(), vtx.Z(), vtx.T()); } diff --git a/src/Physics/Coherent/EventGen/COHKinematicsGenerator.cxx b/src/Physics/Coherent/EventGen/COHPionKinematicsGenerator.cxx similarity index 53% rename from src/Physics/Coherent/EventGen/COHKinematicsGenerator.cxx rename to src/Physics/Coherent/EventGen/COHPionKinematicsGenerator.cxx index a30ce32de..38c697fa9 100644 --- a/src/Physics/Coherent/EventGen/COHKinematicsGenerator.cxx +++ b/src/Physics/Coherent/EventGen/COHPionKinematicsGenerator.cxx @@ -1,36 +1,40 @@ //____________________________________________________________________________ /* + Copyright (c) 2003-2023, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org + + Costas Andreopoulos + University of Liverpool & STFC Rutherford Appleton Laboratory - Costas Andreopoulos - University of Liverpool & STFC Rutherford Appleton Laboratory + */ //____________________________________________________________________________ #include +#include -#include -#include -#include -#include "Math/Minimizer.h" #include "Math/Factory.h" +#include "Math/Minimizer.h" +#include +#include +#include #include "Framework/Algorithm/AlgConfigPool.h" -#include "Framework/Conventions/GBuild.h" #include "Framework/Conventions/Constants.h" #include "Framework/Conventions/Controls.h" -#include "Framework/Conventions/Units.h" -#include "Physics/Coherent/EventGen/COHKinematicsGenerator.h" +#include "Framework/Conventions/GBuild.h" #include "Framework/Conventions/KinePhaseSpace.h" +#include "Framework/Conventions/Units.h" #include "Framework/EventGen/EVGThreadException.h" #include "Framework/EventGen/EventGeneratorI.h" #include "Framework/EventGen/RunningThreadInfo.h" -#include "Framework/GHEP/GHepRecord.h" #include "Framework/GHEP/GHepFlags.h" +#include "Framework/GHEP/GHepRecord.h" #include "Framework/Messenger/Messenger.h" #include "Framework/Numerical/RandomGen.h" #include "Framework/Utils/KineUtils.h" +#include "Physics/Coherent/EventGen/COHPionKinematicsGenerator.h" #include "Physics/XSectionIntegration/GSLXSecFunc.h" using namespace genie; @@ -39,59 +43,63 @@ using namespace genie::controls; using namespace genie::utils; //___________________________________________________________________________ -COHKinematicsGenerator::COHKinematicsGenerator() : - KineGeneratorWithCache("genie::COHKinematicsGenerator") -{ +COHPionKinematicsGenerator::COHPionKinematicsGenerator() + : KineGeneratorWithCache("genie::COHPionKinematicsGenerator") { fEnvelope = 0; } //___________________________________________________________________________ -COHKinematicsGenerator::COHKinematicsGenerator(string config) : - KineGeneratorWithCache("genie::COHKinematicsGenerator", config) -{ +COHPionKinematicsGenerator::COHPionKinematicsGenerator(string config) + : KineGeneratorWithCache("genie::COHPionKinematicsGenerator", config) { fEnvelope = 0; } //___________________________________________________________________________ -COHKinematicsGenerator::~COHKinematicsGenerator() -{ - if(fEnvelope) delete fEnvelope; +COHPionKinematicsGenerator::~COHPionKinematicsGenerator() { + if (fEnvelope) + delete fEnvelope; } //___________________________________________________________________________ -void COHKinematicsGenerator::ProcessEventRecord(GHepRecord * evrec) const -{ - if(fGenerateUniformly) { +void COHPionKinematicsGenerator::ProcessEventRecord(GHepRecord *evrec) const { + if (fGenerateUniformly) { LOG("COHKinematics", pNOTICE) - << "Generating kinematics uniformly over the allowed phase space"; + << "Generating kinematics uniformly over the allowed phase space"; } - //-- Access cross section algorithm for running thread - RunningThreadInfo * rtinfo = RunningThreadInfo::Instance(); - const EventGeneratorI * evg = rtinfo->RunningThread(); + const Interaction *interaction = evrec->Summary(); + const XclsTag &xcls = interaction->ExclTag(); + + RunningThreadInfo *rtinfo = RunningThreadInfo::Instance(); + const EventGeneratorI *evg = rtinfo->RunningThread(); fXSecModel = evg->CrossSectionAlg(); - if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { - CalculateKin_ReinSehgal(evrec); - } else if (fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015") { - CalculateKin_BergerSehgal(evrec); - } else if (fXSecModel->Id().Name() == "genie::BergerSehgalFMCOHPiPXSec2015") { - CalculateKin_BergerSehgalFM(evrec); - } else if ((fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec")) { - CalculateKin_AlvarezRuso(evrec); - } - else { - LOG("COHKinematicsGenerator",pFATAL) << - "ProcessEventRecord >> Cannot calculate kinematics for " << - fXSecModel->Id().Name(); + + if (xcls.NPions() == 1) { + + //-- Access cross section algorithm for running thread + if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { + CalculateKin_ReinSehgal(evrec); + } else if (fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015") { + CalculateKin_BergerSehgal(evrec); + } else if (fXSecModel->Id().Name() == + "genie::BergerSehgalFMCOHPiPXSec2015") { + CalculateKin_BergerSehgalFM(evrec); + } else if ((fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec")) { + CalculateKin_AlvarezRuso(evrec); + } else { + LOG("COHPionKinematicsGenerator", pFATAL) + << "ProcessEventRecord >> Cannot calculate kinematics for " + << fXSecModel->Id().Name(); + } } } //___________________________________________________________________________ -void COHKinematicsGenerator::CalculateKin_BergerSehgal(GHepRecord * evrec) const -{ +void COHPionKinematicsGenerator::CalculateKin_BergerSehgal( + GHepRecord *evrec) const { // Get the Primary Interacton object - Interaction * interaction = evrec->Summary(); + Interaction *interaction = evrec->Summary(); interaction->SetBit(kISkipProcessChk); - interaction->SetBit(kISkipKinematicChk); // TODO: Why turn this off? + interaction->SetBit(kISkipKinematicChk); // TODO: Why turn this off? // Initialise a random number generator - RandomGen * rnd = RandomGen::Instance(); + RandomGen *rnd = RandomGen::Instance(); //-- For the subsequent kinematic selection with the rejection method: // Calculate the max differential cross section or retrieve it from the @@ -102,35 +110,36 @@ void COHKinematicsGenerator::CalculateKin_BergerSehgal(GHepRecord * evrec) const double xsec_max = this->MaxXSec(evrec); //-- Get the kinematical limits for the generated x,y - const KPhaseSpace & kps = interaction->PhaseSpace(); - Range1D_t y = kps.YLim(); - Range1D_t Q2(fQ2Min,fQ2Max); - assert(y.min>0. && y.max>0. && y.min<1. && y.max<1. && y.minPhaseSpace(); + Range1D_t y = kps.YLim(); + Range1D_t Q2(fQ2Min, fQ2Max); + assert(y.min > 0. && y.max > 0. && y.min < 1. && y.max < 1. && y.min < y.max); + + const double ymin = y.min + kASmallNum; + const double ymax = y.max - kASmallNum; + const double dy = ymax - ymin; const double Q2min = Q2.min + kASmallNum; const double Q2max = Q2.max - kASmallNum; - const double dQ2 = Q2max - Q2min; + const double dQ2 = Q2max - Q2min; unsigned int iter = 0; - bool accept=false; - double xsec=-1, gy=-1, gQ2=-1; + bool accept = false; + double xsec = -1, gy = -1, gQ2 = -1; - while(1) { + while (1) { iter++; - if(iter > kRjMaxIterations) this->throwOnTooManyIterations(iter,evrec); + if (iter > kRjMaxIterations) + this->throwOnTooManyIterations(iter, evrec); //-- Select unweighted kinematics using importance sampling method. // TODO: The importance sampling envelope is not used. Currently, // we just employ a standard rejection-method approach. - gy = ymin + dy * rnd->RndKine().Rndm(); + gy = ymin + dy * rnd->RndKine().Rndm(); gQ2 = Q2min + dQ2 * rnd->RndKine().Rndm(); - LOG("COHKinematics", pINFO) << - "Trying: Q^2 = " << gQ2 << ", y = " << gy; /* << ", t = " << gt; */ + LOG("COHKinematics", pINFO) + << "Trying: Q^2 = " << gQ2 << ", y = " << gy; /* << ", t = " << gt; */ interaction->KinePtr()->Sety(gy); interaction->KinePtr()->SetQ2(gQ2); @@ -143,36 +152,39 @@ void COHKinematicsGenerator::CalculateKin_BergerSehgal(GHepRecord * evrec) const accept = (xsec_max * rnd->RndKine().Rndm() < xsec); //-- If the generated kinematics are accepted, finish-up module's job - if(accept) { - LOG("COHKinematics", pNOTICE) - << "Selected: Q^2 = " << gQ2 << ", y = " << gy; /* << ", t = " << gt; */ - - // the Berger-Sehgal COH cross section should be a triple differential cross section - // d^2xsec/dQ2dydt where t is the the square of the 4p transfer to the - // nucleus. The cross section used for kinematical selection should have - // the t-dependence integrated out. The t-dependence is of the form - // ~exp(-bt). Now that the x,y kinematical variables have been selected - // we can generate a t using the t-dependence as a PDF. - const InitialState & init_state = interaction->InitState(); - double Ev = init_state.ProbeE(kRfLab); - double Epi = gy*Ev; // pion energy - double Epi2 = TMath::Power(Epi,2); - double pme2 = kPionMass2/Epi2; - double gx = interaction->KinePtr()->x(); // utils::kinematics::Q2YtoX(Ev,kNucleonMass,gQ2,gy); // gQ2 / ( 2. * gy * kNucleonMass * Ev); - double xME = kNucleonMass*gx/Epi; - double tA = 1. + xME - 0.5*pme2; + if (accept) { + LOG("COHKinematics", pNOTICE) << "Selected: Q^2 = " << gQ2 + << ", y = " << gy; /* << ", t = " << gt; */ + + // the Berger-Sehgal COH cross section should be a triple differential + // cross section d^2xsec/dQ2dydt where t is the the square of the 4p + // transfer to the nucleus. The cross section used for kinematical + // selection should have the t-dependence integrated out. The t-dependence + // is of the form ~exp(-bt). Now that the x,y kinematical variables have + // been selected we can generate a t using the t-dependence as a PDF. + const InitialState &init_state = interaction->InitState(); + double Ev = init_state.ProbeE(kRfLab); + double Epi = gy * Ev; // pion energy + double Epi2 = TMath::Power(Epi, 2); + double pme2 = kPionMass2 / Epi2; + double gx = interaction->KinePtr() + ->x(); // utils::kinematics::Q2YtoX(Ev,kNucleonMass,gQ2,gy); + // // gQ2 / ( 2. * gy * kNucleonMass * Ev); + double xME = kNucleonMass * gx / Epi; + double tA = 1. + xME - 0.5 * pme2; /* Range1D_t tl = kps.TLim(); // this becomes the bounds for t */ - double tB = TMath::Sqrt(1.+ 2*xME) * TMath::Sqrt(1.-pme2); - double tmin = 2*Epi2 * (tA-tB); - double tmax = 2*Epi2 * (tA+tB); - double A = (double) init_state.Tgt().A(); - double A13 = TMath::Power(A,1./3.); - double R = fRo * A13 * units::fermi; // nuclear radius - double R2 = TMath::Power(R,2.); - double b = 0.33333 * R2; - double tsum = (TMath::Exp(-b*tmin) - TMath::Exp(-b*tmax))/b; - double rt = tsum * rnd->RndKine().Rndm(); - double gt = -1.*TMath::Log(-1.*b*rt + TMath::Exp(-1.*b*tmin))/b; + double tB = TMath::Sqrt(1. + 2 * xME) * TMath::Sqrt(1. - pme2); + double tmin = 2 * Epi2 * (tA - tB); + double tmax = 2 * Epi2 * (tA + tB); + double A = (double)init_state.Tgt().A(); + double A13 = TMath::Power(A, 1. / 3.); + double R = fRo * A13 * units::fermi; // nuclear radius + double R2 = TMath::Power(R, 2.); + double b = 0.33333 * R2; + double tsum = (TMath::Exp(-b * tmin) - TMath::Exp(-b * tmax)) / b; + double rt = tsum * rnd->RndKine().Rndm(); + double gt = + -1. * TMath::Log(-1. * b * rt + TMath::Exp(-1. * b * tmin)) / b; // TODO: If we re-install the fGenerateUniformly option, we // would compute the event weight here. @@ -194,18 +206,18 @@ void COHKinematicsGenerator::CalculateKin_BergerSehgal(GHepRecord * evrec) const return; } - }// iterations + } // iterations } //___________________________________________________________________________ -void COHKinematicsGenerator::CalculateKin_BergerSehgalFM(GHepRecord * evrec) const -{ +void COHPionKinematicsGenerator::CalculateKin_BergerSehgalFM( + GHepRecord *evrec) const { // Get the Primary Interacton object - Interaction * interaction = evrec->Summary(); + Interaction *interaction = evrec->Summary(); interaction->SetBit(kISkipProcessChk); interaction->SetBit(kISkipKinematicChk); // Initialise a random number generator - RandomGen * rnd = RandomGen::Instance(); + RandomGen *rnd = RandomGen::Instance(); //-- For the subsequent kinematic selection with the rejection method: // Calculate the max differential cross section or retrieve it from the @@ -216,41 +228,42 @@ void COHKinematicsGenerator::CalculateKin_BergerSehgalFM(GHepRecord * evrec) con double xsec_max = this->MaxXSec(evrec); //-- Get the kinematical limits for the generated x,y - const KPhaseSpace & kps = interaction->PhaseSpace(); - Range1D_t y = kps.YLim(); - Range1D_t Q2(fQ2Min,fQ2Max); - assert(y.min>0. && y.max>0. && y.min<1. && y.max<1. && y.minPhaseSpace(); + Range1D_t y = kps.YLim(); + Range1D_t Q2(fQ2Min, fQ2Max); + assert(y.min > 0. && y.max > 0. && y.min < 1. && y.max < 1. && y.min < y.max); + + const double ymin = y.min + kASmallNum; + const double ymax = y.max - kASmallNum; + const double dy = ymax - ymin; const double Q2min = Q2.min + kASmallNum; const double Q2max = Q2.max - kASmallNum; - const double dQ2 = Q2max - Q2min; - const double tmin = kASmallNum; - const double tmax = fTMax - kASmallNum; // TODO: Choose realistic t bounds - const double dt = tmax - tmin; + const double dQ2 = Q2max - Q2min; + const double tmin = kASmallNum; + const double tmax = fTMax - kASmallNum; // TODO: Choose realistic t bounds + const double dt = tmax - tmin; //-- Try to select a valid (Q^2,y,t) triple. unsigned int iter = 0; - bool accept=false; - double xsec=-1, gy=-1, gt=-1, gQ2=-1; + bool accept = false; + double xsec = -1, gy = -1, gt = -1, gQ2 = -1; - while(1) { + while (1) { iter++; - if(iter > kRjMaxIterations) this->throwOnTooManyIterations(iter,evrec); + if (iter > kRjMaxIterations) + this->throwOnTooManyIterations(iter, evrec); //-- Select unweighted kinematics using importance sampling method. // TODO: The importance sampling envelope is not used. Currently, // we just employ a standard rejection-method approach. - gy = ymin + dy * rnd->RndKine().Rndm(); - gt = tmin + dt * rnd->RndKine().Rndm(); + gy = ymin + dy * rnd->RndKine().Rndm(); + gt = tmin + dt * rnd->RndKine().Rndm(); gQ2 = Q2min + dQ2 * rnd->RndKine().Rndm(); - LOG("COHKinematics", pINFO) << - "Trying: Q^2 = " << gQ2 << ", y = " << gy << ", t = " << gt; + LOG("COHKinematics", pINFO) + << "Trying: Q^2 = " << gQ2 << ", y = " << gy << ", t = " << gt; interaction->KinePtr()->Sety(gy); interaction->KinePtr()->Sett(gt); @@ -263,9 +276,9 @@ void COHKinematicsGenerator::CalculateKin_BergerSehgalFM(GHepRecord * evrec) con accept = (xsec_max * rnd->RndKine().Rndm() < xsec); //-- If the generated kinematics are accepted, finish-up module's job - if(accept) { + if (accept) { LOG("COHKinematics", pNOTICE) - << "Selected: Q^2 = " << gQ2 << ", y = " << gy << ", t = " << gt; + << "Selected: Q^2 = " << gQ2 << ", y = " << gy << ", t = " << gt; // TODO: If we re-install the fGenerateUniformly option, we // would compute the event weight here. @@ -286,18 +299,18 @@ void COHKinematicsGenerator::CalculateKin_BergerSehgalFM(GHepRecord * evrec) con return; } - }// iterations + } // iterations } //___________________________________________________________________________ -void COHKinematicsGenerator::CalculateKin_ReinSehgal(GHepRecord * evrec) const -{ +void COHPionKinematicsGenerator::CalculateKin_ReinSehgal( + GHepRecord *evrec) const { // Get the Primary Interacton object - Interaction * interaction = evrec->Summary(); + Interaction *interaction = evrec->Summary(); interaction->SetBit(kISkipProcessChk); interaction->SetBit(kISkipKinematicChk); //-- Get the random number generators - RandomGen * rnd = RandomGen::Instance(); + RandomGen *rnd = RandomGen::Instance(); //-- For the subsequent kinematic selection with the rejection method: // Calculate the max differential cross section or retrieve it from the @@ -308,28 +321,29 @@ void COHKinematicsGenerator::CalculateKin_ReinSehgal(GHepRecord * evrec) const double xsec_max = (fGenerateUniformly) ? -1 : this->MaxXSec(evrec); //-- Get the kinematical limits for the generated x,y - const KPhaseSpace & kps = interaction->PhaseSpace(); + const KPhaseSpace &kps = interaction->PhaseSpace(); Range1D_t y = kps.YLim(); - assert(y.min>0. && y.max>0. && y.min<1. && y.max<1. && y.min 0. && y.max > 0. && y.min < 1. && y.max < 1. && y.min < y.max); const double xmin = kASmallNum; - const double xmax = 1.- kASmallNum; + const double xmax = 1. - kASmallNum; const double ymin = y.min + kASmallNum; const double ymax = y.max - kASmallNum; - const double dx = xmax - xmin; - const double dy = ymax - ymin; + const double dx = xmax - xmin; + const double dy = ymax - ymin; //------ Try to select a valid x,y pair unsigned int iter = 0; - bool accept=false; - double xsec=-1, gx=-1, gy=-1; + bool accept = false; + double xsec = -1, gx = -1, gy = -1; - while(1) { + while (1) { iter++; - if(iter > kRjMaxIterations) this->throwOnTooManyIterations(iter,evrec); + if (iter > kRjMaxIterations) + this->throwOnTooManyIterations(iter, evrec); - if(fGenerateUniformly) { + if (fGenerateUniformly) { //-- Generate a x,y pair uniformly in the kinematically allowed range. gx = xmin + dx * rnd->RndKine().Rndm(); gy = ymin + dy * rnd->RndKine().Rndm(); @@ -337,16 +351,16 @@ void COHKinematicsGenerator::CalculateKin_ReinSehgal(GHepRecord * evrec) const } else { //-- Select unweighted kinematics using importance sampling method. - if(iter==1) { + if (iter == 1) { LOG("COHKinematics", pNOTICE) << "Initializing the sampling envelope"; double Ev = interaction->InitState().ProbeE(kRfLab); - fEnvelope->SetRange(xmin,ymin,xmax,ymax); + fEnvelope->SetRange(xmin, ymin, xmax, ymax); fEnvelope->SetParameter(0, xsec_max); fEnvelope->SetParameter(1, Ev); } // Generate W,QD2 using the 2-D envelope as PDF - fEnvelope->GetRandom2(gx,gy); + fEnvelope->GetRandom2(gx, gy); } LOG("COHKinematics", pINFO) << "Trying: x = " << gx << ", y = " << gy; @@ -358,60 +372,59 @@ void COHKinematicsGenerator::CalculateKin_ReinSehgal(GHepRecord * evrec) const xsec = fXSecModel->XSec(interaction, kPSxyfE); //-- decide whether to accept the current kinematics - if(!fGenerateUniformly) { + if (!fGenerateUniformly) { double max = fEnvelope->Eval(gx, gy); - double t = max * rnd->RndKine().Rndm(); + double t = max * rnd->RndKine().Rndm(); this->AssertXSecLimits(interaction, xsec, max); #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ - LOG("COHKinematics", pDEBUG) - << "xsec= " << xsec << ", J= 1, Rnd= " << t; + LOG("COHKinematics", pDEBUG) << "xsec= " << xsec << ", J= 1, Rnd= " << t; #endif - accept = (t0); + accept = (t < xsec); + } else { + accept = (xsec > 0); } //-- If the generated kinematics are accepted, finish-up module's job - if(accept) { - LOG("COHKinematics", pNOTICE) << "Selected: x = "<< gx << ", y = "<< gy; + if (accept) { + LOG("COHKinematics", pNOTICE) << "Selected: x = " << gx << ", y = " << gy; - // the Rein-Sehgal COH cross section should be a triple differential cross section - // d^2xsec/dxdydt where t is the the square of the 4p transfer to the - // nucleus. The cross section used for kinematical selection should have - // the t-dependence integrated out. The t-dependence is of the form + // the Rein-Sehgal COH cross section should be a triple differential cross + // section d^2xsec/dxdydt where t is the the square of the 4p transfer to + // the nucleus. The cross section used for kinematical selection should + // have the t-dependence integrated out. The t-dependence is of the form // ~exp(-bt). Now that the x,y kinematical variables have been selected // we can generate a t using the t-dependence as a PDF. - const InitialState & init_state = interaction->InitState(); - double Ev = init_state.ProbeE(kRfLab); - double Epi = gy*Ev; // pion energy - double Epi2 = TMath::Power(Epi,2); - double pme2 = kPionMass2/Epi2; - double xME = kNucleonMass*gx/Epi; - double tA = 1. + xME - 0.5*pme2; - double tB = TMath::Sqrt(1.+ 2*xME) * TMath::Sqrt(1.-pme2); - double tmin = 2*Epi2 * (tA-tB); - double tmax = 2*Epi2 * (tA+tB); - double A = (double) init_state.Tgt().A(); - double A13 = TMath::Power(A,1./3.); - double R = fRo * A13 * units::fermi; // nuclear radius - double R2 = TMath::Power(R,2.); - double b = 0.33333 * R2; - double tsum = (TMath::Exp(-b*tmin) - TMath::Exp(-b*tmax))/b; - double rt = tsum * rnd->RndKine().Rndm(); - double gt = -1.*TMath::Log(-1.*b*rt + TMath::Exp(-1.*b*tmin))/b; - - LOG("COHKinematics", pNOTICE) - << "Selected: t = "<< gt << ", from ["<< tmin << ", "<< tmax << "]"; + const InitialState &init_state = interaction->InitState(); + double Ev = init_state.ProbeE(kRfLab); + double Epi = gy * Ev; // pion energy + double Epi2 = TMath::Power(Epi, 2); + double pme2 = kPionMass2 / Epi2; + double xME = kNucleonMass * gx / Epi; + double tA = 1. + xME - 0.5 * pme2; + double tB = TMath::Sqrt(1. + 2 * xME) * TMath::Sqrt(1. - pme2); + double tmin = 2 * Epi2 * (tA - tB); + double tmax = 2 * Epi2 * (tA + tB); + double A = (double)init_state.Tgt().A(); + double A13 = TMath::Power(A, 1. / 3.); + double R = fRo * A13 * units::fermi; // nuclear radius + double R2 = TMath::Power(R, 2.); + double b = 0.33333 * R2; + double tsum = (TMath::Exp(-b * tmin) - TMath::Exp(-b * tmax)) / b; + double rt = tsum * rnd->RndKine().Rndm(); + double gt = + -1. * TMath::Log(-1. * b * rt + TMath::Exp(-1. * b * tmin)) / b; + + LOG("COHKinematics", pNOTICE) << "Selected: t = " << gt << ", from [" + << tmin << ", " << tmax << "]"; // for uniform kinematics, compute an event weight as // wght = (phase space volume)*(differential xsec)/(event total xsec) - if(fGenerateUniformly) { - double vol = y.max-y.min; // dx=1, dt: irrelevant + if (fGenerateUniformly) { + double vol = y.max - y.min; // dx=1, dt: irrelevant double totxsec = evrec->XSec(); - double wght = (vol/totxsec)*xsec; - LOG("COHKinematics", pNOTICE) << "Kinematics wght = "<< wght; + double wght = (vol / totxsec) * xsec; + LOG("COHKinematics", pNOTICE) << "Kinematics wght = " << wght; // apply computed weight to the current event weight wght *= evrec->Weight(); @@ -428,7 +441,7 @@ void COHKinematicsGenerator::CalculateKin_ReinSehgal(GHepRecord * evrec) const interaction->KinePtr()->Sety(gy, true); interaction->KinePtr()->Sett(gt, true); interaction->KinePtr()->SetW(kPionMass, true); - interaction->KinePtr()->SetQ2(2*kNucleonMass*gx*gy*Ev, true); + interaction->KinePtr()->SetQ2(2 * kNucleonMass * gx * gy * Ev, true); interaction->KinePtr()->ClearRunningValues(); // set the cross section for the selected kinematics @@ -436,20 +449,20 @@ void COHKinematicsGenerator::CalculateKin_ReinSehgal(GHepRecord * evrec) const return; } - }// iterations + } // iterations } //___________________________________________________________________________ -void COHKinematicsGenerator::CalculateKin_AlvarezRuso(GHepRecord * evrec) const -{ +void COHPionKinematicsGenerator::CalculateKin_AlvarezRuso( + GHepRecord *evrec) const { LOG("COHKinematics", pNOTICE) << "Using AlvarezRuso Model"; // Get the Primary Interacton object - Interaction * interaction = evrec->Summary(); + Interaction *interaction = evrec->Summary(); interaction->SetBit(kISkipProcessChk); interaction->SetBit(kISkipKinematicChk); // Initialise a random number generator - RandomGen * rnd = RandomGen::Instance(); + RandomGen *rnd = RandomGen::Instance(); //-- For the subsequent kinematic selection with the rejection method: // Calculate the max differential cross section or retrieve it from the @@ -459,10 +472,14 @@ void COHKinematicsGenerator::CalculateKin_AlvarezRuso(GHepRecord * evrec) const // space the max xsec is irrelevant double xsec_max = (fGenerateUniformly) ? -1 : this->MaxXSec(evrec); - //Set up limits of integration variables + // Set up limits of integration variables // Primary lepton energy const double E_l_min = interaction->FSPrimLepton()->Mass(); - const double E_l_max = interaction->InitStatePtr()->GetProbeP4(kRfLab)->E() - kPionMass; + const TLorentzVector *P4_nu = interaction->InitStatePtr()->GetProbeP4(kRfLab); + const double E_l_max = P4_nu->E() - kPionMass; + delete P4_nu; + P4_nu = nullptr; + // Primary lepton angle with respect to the beam axis const double ctheta_l_min = 0.4; const double ctheta_l_max = 1.0 - kASmallNum; @@ -474,23 +491,25 @@ void COHKinematicsGenerator::CalculateKin_AlvarezRuso(GHepRecord * evrec) const const double phi_max = (2.0 * kPi) - kASmallNum; // const double d_E_l = E_l_max - E_l_min; - const double d_ctheta_l = ctheta_l_max - ctheta_l_min; + const double d_ctheta_l = ctheta_l_max - ctheta_l_min; const double d_ctheta_pi = ctheta_pi_max - ctheta_pi_min; const double d_phi = phi_max - phi_min; //------ Try to select a valid set of kinematics unsigned int iter = 0; - bool accept=false; - double xsec=-1, g_E_l=-1, g_theta_l=-1, g_phi_l=-1, g_theta_pi=-1, g_phi_pi=-1; + bool accept = false; + double xsec = -1, g_E_l = -1, g_theta_l = -1, g_phi_l = -1, g_theta_pi = -1, + g_phi_pi = -1; double g_ctheta_l, g_ctheta_pi; - while(1) { + while (1) { iter++; - if(iter > kRjMaxIterations) this->throwOnTooManyIterations(iter,evrec); + if (iter > kRjMaxIterations) + this->throwOnTooManyIterations(iter, evrec); - //Select kinematic point + // Select kinematic point g_E_l = E_l_min + d_E_l * rnd->RndKine().Rndm(); - g_ctheta_l = ctheta_l_min + d_ctheta_l * rnd->RndKine().Rndm(); + g_ctheta_l = ctheta_l_min + d_ctheta_l * rnd->RndKine().Rndm(); g_ctheta_pi = ctheta_pi_min + d_ctheta_pi * rnd->RndKine().Rndm(); g_phi_l = phi_min + d_phi * rnd->RndKine().Rndm(); // random phi is relative to phi_l @@ -498,76 +517,77 @@ void COHKinematicsGenerator::CalculateKin_AlvarezRuso(GHepRecord * evrec) const g_theta_l = TMath::ACos(g_ctheta_l); g_theta_pi = TMath::ACos(g_ctheta_pi); - LOG("COHKinematics", pINFO) << "Trying: Lep(" <SetKinematics(g_E_l, g_theta_l, g_phi_l, g_theta_pi, g_phi_pi, interaction, interaction->KinePtr()); // computing cross section for the current kinematics - xsec = fXSecModel->XSec(interaction,kPSElOlOpifE) / (1E-38 * units::cm2); + xsec = fXSecModel->XSec(interaction, kPSElOlOpifE) / (1E-38 * units::cm2); if (!fGenerateUniformly) { //-- decide whether to accept the current kinematics - double t = xsec_max * rnd->RndKine().Rndm(); + double t = xsec_max * rnd->RndKine().Rndm(); - LOG("COHKinematics", pINFO) << "Got: xsec = " << xsec << ", t = " << - t << " (max_xsec = " << xsec_max << ")"; + LOG("COHKinematics", pINFO) << "Got: xsec = " << xsec << ", t = " << t + << " (max_xsec = " << xsec_max << ")"; this->AssertXSecLimits(interaction, xsec, xsec_max); #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ - LOG("COHKinematics", pDEBUG) - << "xsec= " << xsec << ", J= 1, Rnd= " << t; + LOG("COHKinematics", pDEBUG) << "xsec= " << xsec << ", J= 1, Rnd= " << t; #endif - accept = (t0); + accept = (t < xsec); + } else { + accept = (xsec > 0); } //-- If the generated kinematics are accepted, finish-up module's job - if(accept) { - LOG("COHKinematics", pNOTICE) << "Selected: Lepton(" << - g_E_l << ", " << g_theta_l << ", " << - g_phi_l << ") Pion(" << g_theta_pi << ", " << g_phi_pi << ")"; + if (accept) { + LOG("COHKinematics", pNOTICE) + << "Selected: Lepton(" << g_E_l << ", " << g_theta_l << ", " + << g_phi_l << ") Pion(" << g_theta_pi << ", " << g_phi_pi << ")"; double E_l = g_E_l; double theta_l = g_theta_l; double theta_pi = g_theta_pi; double phi_l = g_phi_l; double phi_pi = g_phi_pi; - const TLorentzVector P4_nu = *(interaction->InitStatePtr()->GetProbeP4(kRfLab)); - double E_nu = P4_nu.E(); - double E_pi= E_nu-E_l; + P4_nu = interaction->InitStatePtr()->GetProbeP4(kRfLab); + double E_nu = P4_nu->E(); + double E_pi = E_nu - E_l; double m_l = interaction->FSPrimLepton()->Mass(); double m_pi = this->pionMass(interaction); - double p_l = TMath::Sqrt(E_l*E_l - m_l*m_l); - TVector3 lepton_3vector = TVector3(0,0,0); - lepton_3vector.SetMagThetaPhi(p_l,theta_l,phi_l); - TLorentzVector P4_lep = TLorentzVector(lepton_3vector , E_l ); + double p_l = TMath::Sqrt(E_l * E_l - m_l * m_l); + TVector3 lepton_3vector = TVector3(0, 0, 0); + lepton_3vector.SetMagThetaPhi(p_l, theta_l, phi_l); + TLorentzVector P4_lep = TLorentzVector(lepton_3vector, E_l); - double p_pi = TMath::Sqrt(E_pi*E_pi - m_pi*m_pi); - TVector3 pion_3vector = TVector3(0,0,0); - pion_3vector.SetMagThetaPhi(p_pi,theta_pi,phi_pi); - TLorentzVector P4_pion = TLorentzVector(pion_3vector , E_pi); + double p_pi = TMath::Sqrt(E_pi * E_pi - m_pi * m_pi); + TVector3 pion_3vector = TVector3(0, 0, 0); + pion_3vector.SetMagThetaPhi(p_pi, theta_pi, phi_pi); + TLorentzVector P4_pion = TLorentzVector(pion_3vector, E_pi); - TLorentzVector q = P4_nu - P4_lep; + TLorentzVector q = *P4_nu - P4_lep; double Q2 = -q.Mag2(); - double x = Q2/(2*E_pi*constants::kNucleonMass); - double y = E_pi/E_nu; + double x = Q2 / (2 * E_pi * constants::kNucleonMass); + double y = E_pi / E_nu; - double t = TMath::Abs( (q - P4_pion).Mag2() ); + delete P4_nu; + P4_nu = nullptr; + + double t = TMath::Abs((q - P4_pion).Mag2()); // for uniform kinematics, compute an event weight as // wght = (phase space volume)*(differential xsec)/(event total xsec) - if(fGenerateUniformly) { + if (fGenerateUniformly) { // Phase space volume needs checking - double vol = d_E_l*d_ctheta_l*d_phi*d_ctheta_pi*d_phi; + double vol = d_E_l * d_ctheta_l * d_phi * d_ctheta_pi * d_phi; double totxsec = evrec->XSec(); - double wght = (vol/totxsec)*xsec; - LOG("COHKinematics", pNOTICE) << "Kinematics wght = "<< wght; + double wght = (vol / totxsec) * xsec; + LOG("COHKinematics", pNOTICE) << "Kinematics wght = " << wght; // apply computed weight to the current event weight wght *= evrec->Weight(); @@ -583,79 +603,81 @@ void COHKinematicsGenerator::CalculateKin_AlvarezRuso(GHepRecord * evrec) const interaction->KinePtr()->Sety(y, true); interaction->KinePtr()->Sett(t, true); interaction->KinePtr()->SetW(kPionMass, true); - interaction->KinePtr()->SetQ2(2*kNucleonMass*x*y*E_nu, true); + interaction->KinePtr()->SetQ2(2 * kNucleonMass * x * y * E_nu, true); interaction->KinePtr()->ClearRunningValues(); // set the cross section for the selected kinematics - evrec->SetDiffXSec(xsec,kPSElOlOpifE); + evrec->SetDiffXSec(xsec, kPSElOlOpifE); return; } - }//while + } // while } //___________________________________________________________________________ -void COHKinematicsGenerator::SetKinematics(const double E_l, - const double theta_l, - const double phi_l, - const double theta_pi, - const double phi_pi, - const Interaction* interaction, - Kinematics* kinematics) const -{ - const TLorentzVector P4_nu = *(interaction->InitStatePtr()->GetProbeP4(kRfLab)); - double E_nu = P4_nu.E(); - double E_pi= E_nu-E_l; +void COHPionKinematicsGenerator::SetKinematics( + const double E_l, const double theta_l, const double phi_l, + const double theta_prod, const double phi_prod, + const Interaction *interaction, Kinematics *kinematics) const { + + double E_nu = interaction->InitStatePtr()->ProbeE(kRfLab); + const TLorentzVector P4_nu(0., 0., E_nu, E_nu); + double m_l = interaction->FSPrimLepton()->Mass(); - double m_pi; - if ( interaction->ProcInfo().IsWeakCC() ) { - m_pi = constants::kPionMass; - } else { - m_pi = constants::kPi0Mass; - } - double p_l=0.0; - if (E_l > m_l) { - p_l = TMath::Sqrt(E_l*E_l - m_l*m_l); - } - TVector3 lepton_3vector = TVector3(0,0,0); - lepton_3vector.SetMagThetaPhi(p_l,theta_l,phi_l); - TLorentzVector P4_lep = TLorentzVector(lepton_3vector , E_l ); + double p_l = TMath::Sqrt(E_l * E_l - m_l * m_l); + + TVector3 lepton_3vector = TVector3(0, 0, 0); + lepton_3vector.SetMagThetaPhi(p_l, theta_l, phi_l); + TLorentzVector P4_lep = TLorentzVector(lepton_3vector, E_l); + + double E_prod = E_nu - E_l; + double m_prod = -1.; + // need to check if photon or pion + // if pion, charged or neutral + if (interaction->ExclTagPtr()->NSingleGammas() > 0) { + m_prod = 0.0; + } else if (interaction->ExclTagPtr()->NPions() > 0) { + if (interaction->ProcInfo().IsWeakCC()) { + m_prod = constants::kPionMass; + } else { + m_prod = constants::kPi0Mass; + } + } // else if Pion production - double p_pi=0.0; - if (E_pi > m_pi) { - p_pi = TMath::Sqrt(E_pi*E_pi - m_pi*m_pi); - } - TVector3 pion_3vector = TVector3(0,0,0); - pion_3vector.SetMagThetaPhi(p_pi,theta_pi,phi_pi); - TLorentzVector P4_pion = TLorentzVector(pion_3vector , E_pi); + double p_prod = TMath::Sqrt(E_prod * E_prod - m_prod * m_prod); + TVector3 prod_3vector = TVector3(0, 0, 0); + prod_3vector.SetMagThetaPhi(p_prod, theta_prod, phi_prod); + TLorentzVector P4_prod = TLorentzVector(prod_3vector, E_prod); - double Q2 = -(P4_nu-P4_lep).Mag2(); - double x = Q2/(2*E_pi*constants::kNucleonMass); - double y = E_pi/E_nu; + double Q2 = -(P4_nu - P4_lep).Mag2(); + double x = Q2 / (2 * E_prod * constants::kNucleonMass); + double y = E_prod / E_nu; kinematics->Setx(x); kinematics->Sety(y); kinematics::UpdateWQ2FromXY(interaction); - kinematics->SetFSLeptonP4(P4_lep ); - kinematics->SetHadSystP4 (P4_pion); // use Hadronic System variable to store pion momentum + kinematics->SetFSLeptonP4(P4_lep); + kinematics->SetHadSystP4(P4_prod); // use Hadronic System variable to store + // producted particle momentum } //___________________________________________________________________________ -bool COHKinematicsGenerator::CheckKinematics(const double E_l, - const double /* theta_l */ , - const double /* phi_l */ , - const double /* theta_pi */ , - const double /* phi_pi */ , - const Interaction* interaction) const -{ - const TLorentzVector P4_nu = *(interaction->InitStatePtr()->GetProbeP4(kRfLab)); - double E_nu = P4_nu.E(); - double E_pi= E_nu-E_l; +bool COHPionKinematicsGenerator::CheckKinematics( + const double E_l, const double /* theta_l */, + const double /* phi_l */, const double /* theta_pi */, + const double /* phi_pi */, const Interaction *interaction) const { + const TLorentzVector *P4_nu = interaction->InitStatePtr()->GetProbeP4(kRfLab); + double E_nu = P4_nu->E(); + double E_pi = E_nu - E_l; double m_l = interaction->FSPrimLepton()->Mass(); double m_pi; - if ( interaction->ProcInfo().IsWeakCC() ) { + + delete P4_nu; + P4_nu = nullptr; + + if (interaction->ProcInfo().IsWeakCC()) { m_pi = constants::kPionMass; - } - else { + } else { m_pi = constants::kPi0Mass; } + if (E_l <= m_l) { return false; } @@ -665,8 +687,7 @@ bool COHKinematicsGenerator::CheckKinematics(const double E_l, return true; } //___________________________________________________________________________ -double COHKinematicsGenerator::ComputeMaxXSec(const Interaction * in) const -{ +double COHPionKinematicsGenerator::ComputeMaxXSec(const Interaction *in) const { // Computes the maximum differential cross section in the requested phase // space. This method overloads KineGeneratorWithCache::ComputeMaxXSec // method and the value is cached at a circular cache branch for retrieval @@ -674,22 +695,30 @@ double COHKinematicsGenerator::ComputeMaxXSec(const Interaction * in) const #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ SLOG("COHKinematics", pDEBUG) - << "Scanning the allowed phase space {K} for the max(dxsec/d{K})"; + << "Scanning the allowed phase space {K} for the max(dxsec/d{K})"; #endif + double max_xsec = 0.; - if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { - max_xsec = MaxXSec_ReinSehgal(in); - } else if ((fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015")) { - max_xsec = MaxXSec_BergerSehgal(in); - } else if ((fXSecModel->Id().Name() == "genie::BergerSehgalFMCOHPiPXSec2015")) { - max_xsec = MaxXSec_BergerSehgalFM(in); - } else if ((fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec")) { - max_xsec = MaxXSec_AlvarezRuso(in); - } - else { - LOG("COHKinematicsGenerator",pFATAL) << - "ComputeMaxXSec >> Cannot calculate max cross-section for " << - fXSecModel->Id().Name(); + + const XclsTag &xcls = in->ExclTag(); + + if (xcls.NPions() == 1) { + + if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { + max_xsec = MaxXSec_ReinSehgal(in); + } else if ((fXSecModel->Id().Name() == + "genie::BergerSehgalCOHPiPXSec2015")) { + max_xsec = MaxXSec_BergerSehgal(in); + } else if ((fXSecModel->Id().Name() == + "genie::BergerSehgalFMCOHPiPXSec2015")) { + max_xsec = MaxXSec_BergerSehgalFM(in); + } else if ((fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec")) { + max_xsec = MaxXSec_AlvarezRuso(in); + } else { + LOG("COHPionKinematicsGenerator", pFATAL) + << "ComputeMaxXSec >> Cannot calculate max cross-section for " + << fXSecModel->Id().Name(); + } } // Apply safety factor, since value retrieved from the cache might @@ -705,89 +734,90 @@ double COHKinematicsGenerator::ComputeMaxXSec(const Interaction * in) const return max_xsec; } //___________________________________________________________________________ -double COHKinematicsGenerator::MaxXSec_BergerSehgal(const Interaction * in) const -{ +double +COHPionKinematicsGenerator::MaxXSec_BergerSehgal(const Interaction *in) const { double max_xsec = 0; - const int NQ2 = 50; - const int Ny = 50; + const int NQ2 = 50; + const int Ny = 50; - const KPhaseSpace & kps = in->PhaseSpace(); + const KPhaseSpace &kps = in->PhaseSpace(); Range1D_t Q2r = kps.Q2Lim(); Q2r.max = fQ2Max; const double logQ2min = TMath::Log10(Q2r.min + kASmallNum); const double logQ2max = TMath::Log10(Q2r.max); - const double dlogQ2 = (logQ2max - logQ2min) /(NQ2-1); + const double dlogQ2 = (logQ2max - logQ2min) / (NQ2 - 1); - for(int i=0; iKinePtr()->SetQ2(Q2); Range1D_t yr = kps.YLim(); - if ((yr.max < 0) || (yr.max < yr.min) || - (yr.max > 1) || (yr.min < 0)) { // forbidden kinematics + if ((yr.max < 0) || (yr.max < yr.min) || (yr.max > 1) || + (yr.min < 0)) { // forbidden kinematics continue; } - const double logymin = TMath::Log10(yr.min); - const double logymax = TMath::Log10(yr.max); - const double dlogy = (logymax - logymin) /(Ny-1); + const double logymin = TMath::Log10(yr.min); + const double logymax = TMath::Log10(yr.max); + const double dlogy = (logymax - logymin) / (Ny - 1); - for(int j=0; jKinePtr()->Sety(gy); - /* Range1D_t tl = kps.TLim(); // TESTING! - this becomes a loop over t */ + /* Range1D_t tl = kps.TLim(); // TESTING! - this becomes a loop over t + */ kinematics::UpdateXFromQ2Y(in); // Note: We're not stepping through log Q^2, log y - we "unpacked" double xsec = fXSecModel->XSec(in, kPSQ2yfE); #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ - LOG("COHKinematics", pDEBUG) - << "xsec(Q2= " << Q2 << ", y= " << gy << ", t = " << gt << ") = " << xsec; + LOG("COHKinematics", pDEBUG) << "xsec(Q2= " << Q2 << ", y= " << gy + << ", t = " << gt << ") = " << xsec; #endif max_xsec = TMath::Max(max_xsec, xsec); } // y - } // Q2 + } // Q2 return max_xsec; } //___________________________________________________________________________ -double COHKinematicsGenerator::MaxXSec_BergerSehgalFM(const Interaction * in) const -{ +double COHPionKinematicsGenerator::MaxXSec_BergerSehgalFM( + const Interaction *in) const { double max_xsec = 0; // How many sampling bins in each variable for max xsec calculation? - const int NQ2 = 50; - const int Ny = 50; - const int Nt = 50; + const int NQ2 = 50; + const int Ny = 50; + const int Nt = 50; - const KPhaseSpace & kps = in->PhaseSpace(); + const KPhaseSpace &kps = in->PhaseSpace(); Range1D_t Q2r = kps.Q2Lim(); Q2r.max = fQ2Max; const double logQ2min = TMath::Log10(Q2r.min + kASmallNum); const double logQ2max = TMath::Log10(Q2r.max); - const double logtmin = TMath::Log10(kASmallNum); - const double logtmax = TMath::Log10(fTMax - kASmallNum); - const double dlogQ2 = (logQ2max - logQ2min) /(NQ2-1); - const double dlogt = (logtmax - logtmin) /(Nt-1); + const double logtmin = TMath::Log10(kASmallNum); + const double logtmax = TMath::Log10(fTMax - kASmallNum); + const double dlogQ2 = (logQ2max - logQ2min) / (NQ2 - 1); + const double dlogt = (logtmax - logtmin) / (Nt - 1); - for(int i=0; iKinePtr()->SetQ2(Q2); Range1D_t yr = kps.YLim(); - if ((yr.max < 0) || (yr.max < yr.min) || - (yr.max > 1) || (yr.min < 0)) { // forbidden kinematics + if ((yr.max < 0) || (yr.max < yr.min) || (yr.max > 1) || + (yr.min < 0)) { // forbidden kinematics continue; } - const double logymin = TMath::Log10(yr.min); - const double logymax = TMath::Log10(yr.max); - const double dlogy = (logymax - logymin) /(Ny-1); + const double logymin = TMath::Log10(yr.min); + const double logymax = TMath::Log10(yr.max); + const double dlogy = (logymax - logymin) / (Ny - 1); - for(int j=0; jKinePtr()->Sety(gy); @@ -795,26 +825,26 @@ double COHKinematicsGenerator::MaxXSec_BergerSehgalFM(const Interaction * in) co double xsec = fXSecModel->XSec(in, kPSxyfE); #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ - LOG("COHKinematics", pDEBUG) - << "xsec(Q2= " << Q2 << ", y= " << gy << ", t = " << gt << ") = " << xsec; + LOG("COHKinematics", pDEBUG) << "xsec(Q2= " << Q2 << ", y= " << gy + << ", t = " << gt << ") = " << xsec; #endif max_xsec = TMath::Max(max_xsec, xsec); } // t - } // y - } // Q2 + } // y + } // Q2 return max_xsec; } //___________________________________________________________________________ -double COHKinematicsGenerator::MaxXSec_ReinSehgal(const Interaction * in) const -{ +double +COHPionKinematicsGenerator::MaxXSec_ReinSehgal(const Interaction *in) const { double max_xsec = 0; double Ev = in->InitState().ProbeE(kRfLab); const int Nx = 50; const int Ny = 50; - const KPhaseSpace & kps = in->PhaseSpace(); + const KPhaseSpace &kps = in->PhaseSpace(); Range1D_t y = kps.YLim(); const double logxmin = TMath::Log10(1E-5); @@ -822,16 +852,17 @@ double COHKinematicsGenerator::MaxXSec_ReinSehgal(const Interaction * in) const const double logymin = TMath::Log10(y.min); const double logymax = TMath::Log10(y.max); - const double dlogx = (logxmax - logxmin) /(Nx-1); - const double dlogy = (logymax - logymin) /(Ny-1); + const double dlogx = (logxmax - logxmin) / (Nx - 1); + const double dlogy = (logymax - logymin) / (Ny - 1); - for(int i=0; i1.0 && Q2>0.01) continue; + double Q2 = 2 * kNucleonMass * gx * gy * Ev; + if (Ev > 1.0 && Q2 > 0.01) + continue; in->KinePtr()->Setx(gx); in->KinePtr()->Sety(gy); @@ -839,17 +870,17 @@ double COHKinematicsGenerator::MaxXSec_ReinSehgal(const Interaction * in) const double xsec = fXSecModel->XSec(in, kPSxyfE); #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ LOG("COHKinematics", pDEBUG) - << "xsec(x= " << gx << ", y= " << gy << ") = " << xsec; + << "xsec(x= " << gx << ", y= " << gy << ") = " << xsec; #endif max_xsec = TMath::Max(max_xsec, xsec); - }//y - }//x + } // y + } // x return max_xsec; } //___________________________________________________________________________ -double COHKinematicsGenerator::MaxXSec_AlvarezRuso(const Interaction * in) const -{ +double +COHPionKinematicsGenerator::MaxXSec_AlvarezRuso(const Interaction *in) const { // Computes the maximum differential cross section in the requested phase // space. This method overloads KineGeneratorWithCache::ComputeMaxXSec // method and the value is cached at a circular cache branch for retrieval @@ -857,19 +888,20 @@ double COHKinematicsGenerator::MaxXSec_AlvarezRuso(const Interaction * in) const #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ SLOG("COHKinematics", pDEBUG) - << "Scanning the allowed phase space {K} for the max(dxsec/d{K})"; + << "Scanning the allowed phase space {K} for the max(dxsec/d{K})"; #endif double max_xsec = 0.; double Ev = in->InitState().ProbeE(kRfLab); - const KPhaseSpace & kps = in->PhaseSpace(); + const KPhaseSpace &kps = in->PhaseSpace(); Range1D_t y = kps.YLim(); - ROOT::Math::Minimizer * min = ROOT::Math::Factory::CreateMinimizer("Minuit2"); - gsl::d4Xsec_dEldThetaldOmegapi f(fXSecModel,in); - f.SetFactor(-1.); // Make it return negative of cross-section so we can minimize + ROOT::Math::Minimizer *min = ROOT::Math::Factory::CreateMinimizer("Minuit2"); + gsl::d4Xsec_dEldThetaldOmegapi f(fXSecModel, in); + f.SetFactor( + -1.); // Make it return negative of cross-section so we can minimize - min->SetFunction( f ); + min->SetFunction(f); min->SetMaxFunctionCalls(10000); min->SetTolerance(0.05); @@ -891,17 +923,21 @@ double COHKinematicsGenerator::MaxXSec_AlvarezRuso(const Interaction * in) const //~ const double min_phipi = kPi; //~ const double max_phipi = 0.5 * kPi; const double min_phipi = kASmallNum; - const double max_phipi = 2*kPi-kASmallNum; + const double max_phipi = 2 * kPi - kASmallNum; const unsigned int n_phipi = 10; const double d_phipi = (max_phipi - min_phipi) / double(n_phipi - 1); - min->SetLimitedVariable ( 0 ,"E_lep" , max_el -kASmallNum , d_el , min_el , max_el ); - min->SetLimitedVariable ( 1 ,"theta_l" , min_thetal +kASmallNum , d_thetal , min_thetal , max_thetal ); - min->SetLimitedVariable ( 2 ,"theta_pi" , min_thetapi+kASmallNum , d_thetapi , min_thetapi, max_thetapi ); - min->SetLimitedVariable ( 3 ,"phi_pi" , min_phipi +kASmallNum , d_phipi , min_phipi , max_phipi ); + min->SetLimitedVariable(0, "E_lep", max_el - kASmallNum, d_el, min_el, + max_el); + min->SetLimitedVariable(1, "theta_l", min_thetal + kASmallNum, d_thetal, + min_thetal, max_thetal); + min->SetLimitedVariable(2, "theta_pi", min_thetapi + kASmallNum, d_thetapi, + min_thetapi, max_thetapi); + min->SetLimitedVariable(3, "phi_pi", min_phipi + kASmallNum, d_phipi, + min_phipi, max_phipi); min->Minimize(); - max_xsec = -min->MinValue(); //back to positive xsec + max_xsec = -min->MinValue(); // back to positive xsec // Apply safety factor, since value retrieved from the cache might // correspond to a slightly different energy. @@ -918,20 +954,19 @@ double COHKinematicsGenerator::MaxXSec_AlvarezRuso(const Interaction * in) const return max_xsec; } //___________________________________________________________________________ -double COHKinematicsGenerator::Energy(const Interaction * interaction) const -{ +double +COHPionKinematicsGenerator::Energy(const Interaction *interaction) const { // Override the base class Energy() method to cache the max xsec for the // neutrino energy in the LAB rather than in the hit nucleon rest frame. - const InitialState & init_state = interaction->InitState(); + const InitialState &init_state = interaction->InitState(); double E = init_state.ProbeE(kRfLab); return E; } //___________________________________________________________________________ -double COHKinematicsGenerator::pionMass(const Interaction* in) const -{ +double COHPionKinematicsGenerator::pionMass(const Interaction *in) const { double m_pi = 0.0; - if ( in->ProcInfo().IsWeakCC() ) { + if (in->ProcInfo().IsWeakCC()) { m_pi = constants::kPionMass; } else { m_pi = constants::kPi0Mass; @@ -939,12 +974,10 @@ double COHKinematicsGenerator::pionMass(const Interaction* in) const return m_pi; } //___________________________________________________________________________ -void COHKinematicsGenerator::throwOnTooManyIterations(unsigned int iters, - GHepRecord* evrec) const -{ - LOG("COHKinematics", pWARN) - << "*** Could not select valid kinematics after " - << iters << " iterations"; +void COHPionKinematicsGenerator::throwOnTooManyIterations( + unsigned int iters, GHepRecord *evrec) const { + LOG("COHKinematics", pWARN) << "*** Could not select valid kinematics after " + << iters << " iterations"; evrec->EventFlags()->SetBitNumber(kKineGenErr, true); genie::exceptions::EVGThreadException exception; exception.SetReason("Couldn't select kinematics"); @@ -952,47 +985,54 @@ void COHKinematicsGenerator::throwOnTooManyIterations(unsigned int iters, throw exception; } //___________________________________________________________________________ -void COHKinematicsGenerator::Configure(const Registry & config) -{ +void COHPionKinematicsGenerator::Configure(const Registry &config) { Algorithm::Configure(config); this->LoadConfig(); } //____________________________________________________________________________ -void COHKinematicsGenerator::Configure(string config) -{ +void COHPionKinematicsGenerator::Configure(string config) { Algorithm::Configure(config); this->LoadConfig(); } //____________________________________________________________________________ -void COHKinematicsGenerator::LoadConfig(void) -{ +void COHPionKinematicsGenerator::LoadConfig(void) { + + bool error = false; + //-- COH model parameter Ro - GetParam( "COH-Ro", fRo ); + GetParam("COH-Ro", fRo); //-- COH model parameter t_max for t = (q - p_pi)^2 - GetParam( "COH-t-max", fTMax ) ; + GetParam("COH-t-max", fTMax); //-- COH model bounds of integration for Q^2 - GetParam( "COH-Q2-min", fQ2Min ) ; - GetParam( "COH-Q2-max", fQ2Max ) ; + GetParam("COH-Q2-min", fQ2Min); + GetParam("COH-Q2-max", fQ2Max); //-- max xsec safety factor (for rejection method) and min cached energy - GetParamDef( "MaxXSec-SafetyFactor", fSafetyFactor, 1.6 ) ; - GetParamDef( "Cache-MinEnergy", fEMin, -1.0 ) ; + GetParamDef("MaxXSec-SafetyFactor", fSafetyFactor, 1.6); + GetParamDef("Cache-MinEnergy", fEMin, -1.0); //-- Generate kinematics uniformly over allowed phase space and compute // an event weight? - GetParamDef( "UniformOverPhaseSpace", fGenerateUniformly, false ) ; + GetParamDef("UniformOverPhaseSpace", fGenerateUniformly, false); //-- Maximum allowed fractional cross section deviation from maxim cross // section used in rejection method - GetParamDef( "MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 999999. ) ; - assert(fMaxXSecDiffTolerance>=0); + GetParamDef("MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 999999.); + assert(fMaxXSecDiffTolerance >= 0); //-- Envelope employed when importance sampling is used // (initialize with dummy range) - if(fEnvelope) delete fEnvelope; - fEnvelope = new TF2("CohKinEnvelope", - kinematics::COHImportanceSamplingEnvelope,0.,1,0.,1,2); + if (fEnvelope) + delete fEnvelope; + fEnvelope = + new TF2("CohKinEnvelope", kinematics::COHImportanceSamplingEnvelope, 0., + 1, 0., 1, 2); // stop ROOT from deleting this object of its own volition gROOT->GetListOfFunctions()->Remove(fEnvelope); + + if (error) { + LOG("COHKinematicsGenerator", pFATAL) << "Invalid configuration. Exiting"; + exit(78); + } } //____________________________________________________________________________ diff --git a/src/Physics/Coherent/EventGen/COHKinematicsGenerator.h b/src/Physics/Coherent/EventGen/COHPionKinematicsGenerator.h similarity index 89% rename from src/Physics/Coherent/EventGen/COHKinematicsGenerator.h rename to src/Physics/Coherent/EventGen/COHPionKinematicsGenerator.h index 0e79657ed..aa3df89ff 100644 --- a/src/Physics/Coherent/EventGen/COHKinematicsGenerator.h +++ b/src/Physics/Coherent/EventGen/COHPionKinematicsGenerator.h @@ -1,7 +1,7 @@ //____________________________________________________________________________ /*! -\class genie::COHKinematicsGenerator +\class genie::COHPionKinematicsGenerator \brief Generates values for the kinematic variables describing coherent neutrino-nucleus pion production events. @@ -17,22 +17,23 @@ */ //____________________________________________________________________________ -#ifndef _COH_KINEMATICS_GENERATOR_H_ -#define _COH_KINEMATICS_GENERATOR_H_ +#ifndef _COH_PION_KINEMATICS_GENERATOR_H_ +#define _COH_PION_KINEMATICS_GENERATOR_H_ #include "Physics/Common/KineGeneratorWithCache.h" #include "Framework/Utils/Range1.h" + class TF2; namespace genie { - class COHKinematicsGenerator : public KineGeneratorWithCache { + class COHPionKinematicsGenerator : public KineGeneratorWithCache { public : - COHKinematicsGenerator(); - COHKinematicsGenerator(string config); - ~COHKinematicsGenerator(); + COHPionKinematicsGenerator(); + COHPionKinematicsGenerator(string config); + ~COHPionKinematicsGenerator(); // implement the EventRecordVisitorI interface void ProcessEventRecord(GHepRecord * event_rec) const; @@ -78,7 +79,9 @@ namespace genie { double fQ2Min; ///< lower bound of integration for Q^2 in Berger-Sehgal Model double fQ2Max; ///< upper bound of integration for Q^2 in Berger-Sehgal Model double fTMax; ///< upper bound for t = (q - p_pi)^2 + + }; } // genie namespace -#endif // _COH_KINEMATICS_GENERATOR_H_ +#endif // _COH_PION_KINEMATICS_GENERATOR_H_ diff --git a/src/Physics/Coherent/EventGen/COHPrimaryLeptonGenerator.cxx b/src/Physics/Coherent/EventGen/COHPrimaryLeptonGenerator.cxx index dec269278..be2f15793 100644 --- a/src/Physics/Coherent/EventGen/COHPrimaryLeptonGenerator.cxx +++ b/src/Physics/Coherent/EventGen/COHPrimaryLeptonGenerator.cxx @@ -46,29 +46,56 @@ COHPrimaryLeptonGenerator::~COHPrimaryLeptonGenerator() //___________________________________________________________________________ void COHPrimaryLeptonGenerator::ProcessEventRecord(GHepRecord * evrec) const { - //-- Access cross section algorithm for running thread - RunningThreadInfo * rtinfo = RunningThreadInfo::Instance(); - const EventGeneratorI * evg = rtinfo->RunningThread(); - const XSecAlgorithmI *fXSecModel = evg->CrossSectionAlg(); + + const Interaction * interaction = evrec -> Summary() ; + const XclsTag & xcls = interaction -> ExclTag() ; - // In Rein and Berger-Sehgal, no modification is required to the standard impl. - if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { - PrimaryLeptonGenerator::ProcessEventRecord(evrec); - } - else if ((fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015")) { - PrimaryLeptonGenerator::ProcessEventRecord(evrec); - } - else if ((fXSecModel->Id().Name() == "genie::BergerSehgalFMCOHPiPXSec2015")) { - PrimaryLeptonGenerator::ProcessEventRecord(evrec); - } - else if ((fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec")) { - CalculatePrimaryLepton_AlvarezRuso(evrec); + if ( xcls.NPions() ==1 ) { + + //-- Access cross section algorithm for running thread + RunningThreadInfo * rtinfo = RunningThreadInfo::Instance(); + const EventGeneratorI * evg = rtinfo->RunningThread(); + const XSecAlgorithmI *fXSecModel = evg->CrossSectionAlg(); + + // In Rein and Berger-Sehgal, no modification is required to the standard impl. + if (fXSecModel->Id().Name() == "genie::ReinSehgalCOHPiPXSec") { + PrimaryLeptonGenerator::ProcessEventRecord(evrec); + } + else if ((fXSecModel->Id().Name() == "genie::BergerSehgalCOHPiPXSec2015")) { + PrimaryLeptonGenerator::ProcessEventRecord(evrec); + } + else if ((fXSecModel->Id().Name() == "genie::BergerSehgalFMCOHPiPXSec2015")) { + PrimaryLeptonGenerator::ProcessEventRecord(evrec); + } + else if ( fXSecModel->Id().Name() == "genie::AlvarezRusoCOHPiPXSec" ) { + CalculatePrimaryLepton_AlvarezRuso(evrec); + } + else { + LOG("COHPrimaryLeptonGenerator",pFATAL) << + "ProcessEventRecord >> Cannot calculate primary lepton for " << + fXSecModel->Id().Name(); + } } - else { - LOG("COHPrimaryLeptonGenerator",pFATAL) << - "ProcessEventRecord >> Cannot calculate primary lepton for " << - fXSecModel->Id().Name(); + else if ( xcls.NSingleGammas() == 1 ) { + + const Kinematics & kinematics = interaction->Kine(); + + const TLorentzVector * nu_p4 = evrec->Probe() -> P4() ; + TVector3 nu_dir = nu_p4 -> Vect().Unit() ; + + TVector3 lep_p3 = kinematics.FSLeptonP4().Vect(); + lep_p3.RotateUz( nu_dir ) ; + + TLorentzVector lep_p4( lep_p3, kinematics.FSLeptonP4().E() ) ; + + int pdgc = interaction->FSPrimLepton()->PdgCode(); + + evrec -> AddParticle( pdgc, kIStStableFinalState, + evrec->ProbePosition(), -1, // mothers + -1, -1, // daughters + lep_p4, * evrec->Probe() -> X4() ) ; } + } //___________________________________________________________________________ void COHPrimaryLeptonGenerator::CalculatePrimaryLepton_AlvarezRuso(GHepRecord * evrec) const diff --git a/src/Physics/Coherent/EventGen/LinkDef.h b/src/Physics/Coherent/EventGen/LinkDef.h index a90535d2a..7a9dfba07 100644 --- a/src/Physics/Coherent/EventGen/LinkDef.h +++ b/src/Physics/Coherent/EventGen/LinkDef.h @@ -7,7 +7,8 @@ #pragma link C++ namespace genie; #pragma link C++ class genie::COHInteractionListGenerator; -#pragma link C++ class genie::COHKinematicsGenerator; +#pragma link C++ class genie::COHPionKinematicsGenerator; +#pragma link C++ class genie::COHGammaKinematicsGenerator; #pragma link C++ class genie::COHPrimaryLeptonGenerator; #pragma link C++ class genie::COHHadronicSystemGenerator; diff --git a/src/Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.cxx b/src/Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.cxx new file mode 100644 index 000000000..a2054982a --- /dev/null +++ b/src/Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.cxx @@ -0,0 +1,331 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + Jon Sensenig + University of Pennsylvania + July 2020 + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include + +#include + +#include "Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.h" +#include "Framework/Algorithm/AlgConfigPool.h" +#include "Physics/XSectionIntegration/XSecIntegratorI.h" +#include "Framework/Conventions/GBuild.h" +#include "Framework/Conventions/Constants.h" +#include "Framework/Conventions/Units.h" +#include "Framework/Conventions/RefFrame.h" +#include "Framework/Messenger/Messenger.h" +#include "Framework/ParticleData/PDGCodes.h" +#include "Framework/ParticleData/PDGUtils.h" +#include "Framework/Utils/HadXSUtils.h" +#include "Framework/Utils/KineUtils.h" + + + +using namespace genie; +using namespace genie::constants; +using namespace genie::utils; + +//____________________________________________________________________________ +AlvarezRusoSalaCOHGammaPXSec::AlvarezRusoSalaCOHGammaPXSec() : + XSecAlgorithmI("genie::AlvarezRusoSalaCOHGammaPXSec"), + fFormFactors( nullptr ), + fXSecIntegrator( nullptr ) +{ ; } + +//____________________________________________________________________________ +AlvarezRusoSalaCOHGammaPXSec::AlvarezRusoSalaCOHGammaPXSec(string config) : + XSecAlgorithmI("genie::AlvarezRusoSalaCOHGammaPXSec", config), + fFormFactors( nullptr ), + fXSecIntegrator( nullptr ) +{ ; } +//____________________________________________________________________________ +AlvarezRusoSalaCOHGammaPXSec::~AlvarezRusoSalaCOHGammaPXSec() +{ ; } +//____________________________________________________________________________ +double AlvarezRusoSalaCOHGammaPXSec::XSec( const Interaction * interaction, + KinePhaseSpace_t kps ) const { + + if(! this -> ValidProcess (interaction) ) return 0.; + if(! this -> ValidKinematics (interaction) ) return 0.; + + if ( kps != kPSEgTlOgfE && + kps != kPSEgTlTgPgfE && + kps != kPSEgtTgPgfE && + kps != kPSEgOlOgfE ) { + + LOG("AlvarezRusoSalaCOHGammaPXSec", pERROR ) + << "Requested cross section with invalid phase space: " << KinePhaseSpace::AsString( kps ) ; + return 0. ; + } ; + + // the form factor in this interaction is limited to a very narrow region + // the most efficient way to evaluate the cross section is to first evaluate + // the form factor(s) and only then, if they are not zero, proceed to the evaluation + // of the hadronic currents + + const Kinematics & kinematics = interaction -> Kine(); + double transferred_Q = sqrt( kinematics.t() ) ; + int pdg = interaction -> InitState().Tgt().Pdg() ; + double proton_ff = fFormFactors -> ProtonFF( transferred_Q, pdg ) ; + double neutron_ff = fFormFactors -> NeutronFF( transferred_Q, pdg ) ; + + if ( proton_ff == 0. && neutron_ff == 0. ) return 0. ; + + utils::math::GTraceContraction H( TotalHadronicCurrent( *interaction, proton_ff, neutron_ff ) ) ; + + const InitialState & init_state = interaction -> InitState(); + + int nu = init_state.ProbePdg(); + double contraction = pdg::IsNeutrino(nu) ? + NeutrinoHadronContraction( *interaction, H ) : + AntiNeutrinoHadronContraction( *interaction, H ) ; + + double pre_factor = ( 4.*constants::kPi*constants::kAem * constants::kGF2 ) / ( 16*pow(2.*constants::kPi, 5) ); + + TLorentzVector gamma_p4 = kinematics.HadSystP4() ; // FS gamma momentum + TLorentzVector out_lep = kinematics.FSLeptonP4() ; + + double diff_cross_section = pre_factor*contraction*( gamma_p4.E() * out_lep.E() / init_state.ProbeE(kRfLab) ); + + if ( kps == kPSEgOlOgfE ) return diff_cross_section ; + + // the system is clearly invariant under z rotations -> phi_lepton translation. + // so that integral can be performed simply multiplying by 2 pi + diff_cross_section *= 2.*constants::kPi ; + + // Jacobian for dsigma wrt to t + if ( kps == kPSEgtTgPgfE ) { + double dt_dcos = init_state.ProbeE(kRfLab)-gamma_p4.E()*( cos( gamma_p4.Theta() )-sin( gamma_p4.Theta() )*cos( gamma_p4.Phi()*( out_lep.Z()/out_lep.X() ) ) ) ; + diff_cross_section /= ( 2. * out_lep.E() * abs( dt_dcos ) ) ; + return diff_cross_section ; + } + // the remaining possible phase spaces are all functions of Theta_l instead of Cos Theta_l + // so the first jacobian correction can be applied here + // teh Jacobian simply being sin_Theta_l + + + diff_cross_section *= sin( out_lep.Theta() ) ; + + if ( kps == kPSEgTlOgfE ) + return diff_cross_section ; + + + // if kps == kPSEgTlTgPgfE + diff_cross_section *= sin( gamma_p4.Theta() ) ; + return diff_cross_section ; + +} +//____________________________________________________________________________ +utils::math::GTrace +AlvarezRusoSalaCOHGammaPXSec::TotalHadronicCurrent( const Interaction & interaction, + double proton_ff, double neutron_ff ) const { + + // sum R's from all currents here + utils::math::GTrace R_total; + for ( unsigned int i = 0; i < fCurrents.size(); i++ ) { + R_total += fCurrents[i] -> R(interaction, proton_ff, neutron_ff ); + } + + return R_total; +} +//____________________________________________________________________________ +double AlvarezRusoSalaCOHGammaPXSec::Integral( const Interaction * interaction) const +{ + double xsec = fXSecIntegrator->Integrate(this,interaction); + return xsec; +} +//____________________________________________________________________________ +bool AlvarezRusoSalaCOHGammaPXSec::ValidProcess(const Interaction * interaction) const +{ + if(interaction->TestBit(kISkipProcessChk)) return true; + + const InitialState & init_state = interaction->InitState(); + int nu = init_state.ProbePdg(); + if (!pdg::IsNeutrino(nu) && !pdg::IsAntiNeutrino(nu)) return false; + + const ProcessInfo & proc_info = interaction->ProcInfo(); + + if ( ! proc_info.IsCoherentProduction() ) return false; + if ( ! proc_info.IsWeakNC() ) return false; + + const Target & target = init_state.Tgt(); + if ( target.A() <= 1 ) return false; + if ( ! fFormFactors -> HasNucleus( target.Pdg() ) ) return false ; + + const XclsTag & xcls = interaction -> ExclTag() ; + if ( xcls.NSingleGammas() != 1 ) return false ; + + return true; +} +//____________________________________________________________________________ +bool AlvarezRusoSalaCOHGammaPXSec::ValidKinematics(const Interaction * interaction) const +{ + if(interaction->TestBit(kISkipKinematicChk)) return true; + + const KPhaseSpace& kps = interaction->PhaseSpace(); + + if ( ! kps.IsAllowed() ) { + LOG("AlvarezRusoSalaCOHGammaPXSec", pDEBUG) << "*** Not in allowed kinematical space"; + return false; + } + + // The cross section is only valid in a small range of W + // From the target mass + // if we are outside of this range, the cross section is cut + + if ( interaction -> Kine().W() > interaction -> InitState().Tgt().Mass() + fDeltaW ) + return false ; + + return true; +} +//____________________________________________________________________________ +double +AlvarezRusoSalaCOHGammaPXSec::NeutrinoHadronContraction( const Interaction & i, + const utils::math::GTraceContraction & H ) const { + + double k0 = i.InitState().ProbeE(kRfLab); // incident neutrino E + TLorentzVector probe( 0., 0., k0, k0 ) ; + TLorentzVector out_nu = i.Kine().FSLeptonP4(); + TLorentzVector t_q = probe - out_nu; // in/out neutrino E difference + // FIXME not sure if q is exactly right + std::array q = { t_q.E(), t_q.X(), t_q.Y(), t_q.Z() }; // Z boson momentum?? + + std::complex lh = -8*k0*((2*k0 - q[0] - q[3])*H(0,0,0,0) + q[1]*H(0,0,0,1) - std::complex(0,1)*q[1]*H(0,0,0,2) + + (-2*k0 + q[0] + q[3])*H(0,0,0,3) + q[1]*H(0,1,0,0) + (-q[0] + q[3])*H(0,1,0,1) + + std::complex(0,1)*(q[0] - q[3])*H(0,1,0,2) - q[1]*H(0,1,0,3) + std::complex(0,1)*q[1]*H(0,2,0,0) - + std::complex(0,1)*(q[0] - q[3])*H(0,2,0,1) + (-q[0] + q[3])*H(0,2,0,2) - std::complex(0,1)*q[1]*H(0,2,0,3) + + (-2*k0 + q[0] + q[3])*H(0,3,0,0) - q[1]*H(0,3,0,1) + std::complex(0,1)*q[1]*H(0,3,0,2) + + (2*k0 - q[0] - q[3])*H(0,3,0,3) + (-2*k0 + q[0] + q[3])*H(1,0,1,0) - q[1]*H(1,0,1,1) + + std::complex(0,1)*q[1]*H(1,0,1,2) + (2*k0 - q[0] - q[3])*H(1,0,1,3) - q[1]*H(1,1,1,0) + + (q[0] - q[3])*H(1,1,1,1) - std::complex(0,1)*(q[0] - q[3])*H(1,1,1,2) + q[1]*H(1,1,1,3) - + std::complex(0,1)*q[1]*H(1,2,1,0) + std::complex(0,1)*(q[0] - q[3])*H(1,2,1,1) + (q[0] - q[3])*H(1,2,1,2) + + std::complex(0,1)*q[1]*H(1,2,1,3) + (2*k0 - q[0] - q[3])*H(1,3,1,0) + q[1]*H(1,3,1,1) - + std::complex(0,1)*q[1]*H(1,3,1,2) + (-2*k0 + q[0] + q[3])*H(1,3,1,3) + (-2*k0 + q[0] + q[3])*H(2,0,2,0) - + q[1]*H(2,0,2,1) + std::complex(0,1)*q[1]*H(2,0,2,2) + (2*k0 - q[0] - q[3])*H(2,0,2,3) - q[1]*H(2,1,2,0) + + (q[0] - q[3])*H(2,1,2,1) - std::complex(0,1)*(q[0] - q[3])*H(2,1,2,2) + q[1]*H(2,1,2,3) - + std::complex(0,1)*q[1]*H(2,2,2,0) + std::complex(0,1)*(q[0] - q[3])*H(2,2,2,1) + (q[0] - q[3])*H(2,2,2,2) + + std::complex(0,1)*q[1]*H(2,2,2,3) + (2*k0 - q[0] - q[3])*H(2,3,2,0) + q[1]*H(2,3,2,1) - + std::complex(0,1)*q[1]*H(2,3,2,2) + (-2*k0 + q[0] + q[3])*H(2,3,2,3) + (-2*k0 + q[0] + q[3])*H(3,0,3,0) - + q[1]*H(3,0,3,1) + std::complex(0,1)*q[1]*H(3,0,3,2) + (2*k0 - q[0] - q[3])*H(3,0,3,3) - q[1]*H(3,1,3,0) + + (q[0] - q[3])*H(3,1,3,1) - std::complex(0,1)*(q[0] - q[3])*H(3,1,3,2) + q[1]*H(3,1,3,3) - + std::complex(0,1)*q[1]*H(3,2,3,0) + std::complex(0,1)*(q[0] - q[3])*H(3,2,3,1) + (q[0] - q[3])*H(3,2,3,2) + + std::complex(0,1)*q[1]*H(3,2,3,3) + (2*k0 - q[0] - q[3])*H(3,3,3,0) + q[1]*H(3,3,3,1) - + std::complex(0,1)*q[1]*H(3,3,3,2) + (-2*k0 + q[0] + q[3])*H(3,3,3,3)); + return lh.real(); +} +//____________________________________________________________________________ +double +AlvarezRusoSalaCOHGammaPXSec::AntiNeutrinoHadronContraction( const Interaction & i, + const utils::math::GTraceContraction & H ) const { + + double k0 = i.InitState().ProbeE(kRfLab); // incident neutrino E + TLorentzVector probe( 0., 0., k0, k0 ) ; + TLorentzVector out_nu = i.Kine().FSLeptonP4(); + TLorentzVector t_q = probe - out_nu; // in/out neutrino E difference + // FIXME not sure if q is exactly right + std::array q = { t_q.E(), t_q.X(), t_q.Y(), t_q.Z() }; // Z boson momentum?? + + std::complex lh = -8*k0*((2*k0 - q[0] - q[3])*H(0,0,0,0) + q[1]*H(0,0,0,1) + std::complex(0,1)*q[1]*H(0,0,0,2) + + (-2*k0 + q[0] + q[3])*H(0,0,0,3) + q[1]*H(0,1,0,0) + (-q[0] + q[3])*H(0,1,0,1) - + std::complex(0,1)*(q[0] - q[3])*H(0,1,0,2) - q[1]*H(0,1,0,3) - std::complex(0,1)*q[1]*H(0,2,0,0) + + std::complex(0,1)*(q[0] - q[3])*H(0,2,0,1) + (-q[0] + q[3])*H(0,2,0,2) + std::complex(0,1)*q[1]*H(0,2,0,3) + + (-2*k0 + q[0] + q[3])*H(0,3,0,0) - q[1]*H(0,3,0,1) - std::complex(0,1)*q[1]*H(0,3,0,2) + + (2*k0 - q[0] - q[3])*H(0,3,0,3) + (-2*k0 + q[0] + q[3])*H(1,0,1,0) - q[1]*H(1,0,1,1) - + std::complex(0,1)*q[1]*H(1,0,1,2) + (2*k0 - q[0] - q[3])*H(1,0,1,3) - q[1]*H(1,1,1,0) + + (q[0] - q[3])*H(1,1,1,1) + std::complex(0,1)*(q[0] - q[3])*H(1,1,1,2) + q[1]*H(1,1,1,3) + + std::complex(0,1)*q[1]*H(1,2,1,0) - std::complex(0,1)*(q[0] - q[3])*H(1,2,1,1) + (q[0] - q[3])*H(1,2,1,2) - + std::complex(0,1)*q[1]*H(1,2,1,3) + (2*k0 - q[0] - q[3])*H(1,3,1,0) + q[1]*H(1,3,1,1) + + std::complex(0,1)*q[1]*H(1,3,1,2) + (-2*k0 + q[0] + q[3])*H(1,3,1,3) + (-2*k0 + q[0] + q[3])*H(2,0,2,0) - + q[1]*H(2,0,2,1) - std::complex(0,1)*q[1]*H(2,0,2,2) + (2*k0 - q[0] - q[3])*H(2,0,2,3) - q[1]*H(2,1,2,0) + + (q[0] - q[3])*H(2,1,2,1) + std::complex(0,1)*(q[0] - q[3])*H(2,1,2,2) + q[1]*H(2,1,2,3) + + std::complex(0,1)*q[1]*H(2,2,2,0) - std::complex(0,1)*(q[0] - q[3])*H(2,2,2,1) + (q[0] - q[3])*H(2,2,2,2) - + std::complex(0,1)*q[1]*H(2,2,2,3) + (2*k0 - q[0] - q[3])*H(2,3,2,0) + q[1]*H(2,3,2,1) + + std::complex(0,1)*q[1]*H(2,3,2,2) + (-2*k0 + q[0] + q[3])*H(2,3,2,3) + (-2*k0 + q[0] + q[3])*H(3,0,3,0) - + q[1]*H(3,0,3,1) - std::complex(0,1)*q[1]*H(3,0,3,2) + (2*k0 - q[0] - q[3])*H(3,0,3,3) - q[1]*H(3,1,3,0) + + (q[0] - q[3])*H(3,1,3,1) + std::complex(0,1)*(q[0] - q[3])*H(3,1,3,2) + q[1]*H(3,1,3,3) + + std::complex(0,1)*q[1]*H(3,2,3,0) - std::complex(0,1)*(q[0] - q[3])*H(3,2,3,1) + (q[0] - q[3])*H(3,2,3,2) - + std::complex(0,1)*q[1]*H(3,2,3,3) + (2*k0 - q[0] - q[3])*H(3,3,3,0) + q[1]*H(3,3,3,1) + + std::complex(0,1)*q[1]*H(3,3,3,2) + (-2*k0 + q[0] + q[3])*H(3,3,3,3)); + return lh.real(); +} +//____________________________________________________________________________ +void AlvarezRusoSalaCOHGammaPXSec::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void AlvarezRusoSalaCOHGammaPXSec::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void AlvarezRusoSalaCOHGammaPXSec::LoadConfig(void) +{ + + fCurrents.clear() ; + bool good_configuration = true ; + + // load all the resonance specific currents + std::vector current_keys ; + GetParamVectKeys( "COH-HadronicCurrents", current_keys ) ; + + for ( unsigned int i = 0 ; i < current_keys.size() ; ++i ) { + + const Algorithm * algo = SubAlg( current_keys[i] ) ; + + const COHHadronicCurrentI * current = dynamic_cast< const COHHadronicCurrentI * >( algo ) ; + + if ( ! current ) { + good_configuration = false ; + LOG("AlvarezRusoSalaCOHGammaPXSec", pERROR ) << "SubAlgo with key " << current_keys[i] << " not retrieved" ; + } + else { + fCurrents.push_back( current ) ; + } + + } + + + //-- load the form factor + fFormFactors = + dynamic_cast (this->SubAlg("COH-FormFactor")); + if (! fFormFactors ) { + good_configuration = false ; + LOG("AlvarezRusoSalaCOHGammaPXSec", pERROR ) << "Form factor not retrieved" ; + } + + + //-- load the differential cross section integrator + fXSecIntegrator = + dynamic_cast (this->SubAlg("XSec-Integrator")); + if ( ! fXSecIntegrator ) { + good_configuration = false ; + LOG("AlvarezRusoSalaCOHGammaPXSec", pERROR ) << "Integrator not retrieved" ; + } + + + GetParam( "AsymptoticMaxGammaEnergy", fDeltaW ); + if ( fDeltaW <= 0. ) { + good_configuration = false ; + LOG("AlvarezRusoSalaCOHGammaPXSec", pERROR ) << "Delta W is negative" ; + } + + if ( ! good_configuration ) { + LOG("AlvarezRusoSalaCOHGammaPXSec", pFATAL ) << "Bad configuration: exiting" ; + exit( 78 ) ; + } +} diff --git a/src/Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.h b/src/Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.h new file mode 100644 index 000000000..2d3c8ba9f --- /dev/null +++ b/src/Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.h @@ -0,0 +1,80 @@ +//____________________________________________________________________________ +/*! + \class genie::AlvarezRusoSalaCOHGammaPXSec + + \brief Implementation of the Alvarez-Ruso Sala coherent gamma production model + Is a concrete implementation of the XSecAlgorithmI interface. + +\ref https://link.aps.org/doi/10.1103/PhysRevC.89.015503 + +\author Marco Roda + University of Liverpool + + Jon Sensenig + University of Pennsylvania + +\created July, 2020 + +\cpright Copyright (c) 2003-2020, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _ALVAREZ_RUSO_SALA_COH_GAMMA_XSEC_H_ +#define _ALVAREZ_RUSO_SALA_COH_GAMMA_XSEC_H_ + +#include + +#include "Framework/EventGen/XSecAlgorithmI.h" +#include "Physics/XSectionIntegration/XSecIntegratorI.h" + +#include "Physics/Coherent/XSection/COHHadronicCurrentI.h" +#include "Physics/Coherent/XSection/COHFormFactorI.h" + +namespace genie { + +class AlvarezRusoSalaCOHGammaPXSec : public XSecAlgorithmI { + +public: + AlvarezRusoSalaCOHGammaPXSec(); + AlvarezRusoSalaCOHGammaPXSec( string config ); + virtual ~AlvarezRusoSalaCOHGammaPXSec(); + + //-- XSecAlgorithmI interface implementation + + double XSec ( const Interaction * i, KinePhaseSpace_t k) const override ; + double Integral ( const Interaction * i) const override ; + bool ValidProcess ( const Interaction * i) const override ; + bool ValidKinematics ( const Interaction * i) const override ; + + + + //-- overload the Algorithm::Configure() methods to load private data + // members from configuration options + void Configure(const Registry & config) override ; + void Configure(string config) override ; + +protected: + void LoadConfig(void); + + utils::math::GTrace TotalHadronicCurrent ( const Interaction & interaction, + double proton_ff, double neutron_ff ) const; + + double NeutrinoHadronContraction ( const Interaction & i, const utils::math::GTraceContraction & ) const ; + double AntiNeutrinoHadronContraction ( const Interaction & i, const utils::math::GTraceContraction & ) const ; + +private: + + std::vector fCurrents ; + const COHFormFactorI * fFormFactors ; + + const XSecIntegratorI * fXSecIntegrator; + + double fDeltaW; + +}; + +} // genie namespace + +#endif // _ALVAREZ_RUSO_SALA_COH_GAMMA_XSEC_H_ diff --git a/src/Physics/Coherent/XSection/COHDeltaCurrent.cxx b/src/Physics/Coherent/XSection/COHDeltaCurrent.cxx new file mode 100644 index 000000000..1e9993723 --- /dev/null +++ b/src/Physics/Coherent/XSection/COHDeltaCurrent.cxx @@ -0,0 +1,812 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include "Framework/Messenger/Messenger.h" + +#include "Physics/Coherent/XSection/COHDeltaCurrent.h" + +using namespace genie; +using namespace genie::utils::math; + + +COHDeltaCurrent::COHDeltaCurrent() : + COHHadronicCurrentI("genie::COHDeltaCurrent") +{ + +} + +//____________________________________________________________________________ +COHDeltaCurrent::COHDeltaCurrent(string config) : + COHHadronicCurrentI("genie::COHDeltaCurrent", config) +{ + +} + +//____________________________________________________________________________ +COHDeltaCurrent::~COHDeltaCurrent() +{ + +} + +//____________________________________________________________________________ +void COHDeltaCurrent::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} + +//____________________________________________________________________________ +void COHDeltaCurrent::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} + +//____________________________________________________________________________ +void COHDeltaCurrent::LoadConfig(void) +{ + + bool good_config = true ; + + const Algorithm * delta_trans_algo = SubAlg( "COH-Delta-FormFactor" ) ; + + if ( ! delta_trans_algo ) { + good_config = false ; + LOG("COHDeltaCurrent", pERROR ) << "Configuration does not know COH-Delta-FormFactor field" ; + } + + delta_ff = dynamic_cast( delta_trans_algo ) ; + + if ( ! delta_ff ) { + good_config = false ; + LOG("COHDeltaCurrent", pERROR ) << "Algo " << delta_trans_algo -> Id().Name() << " is not a DeltaTransitionFormFactor" ; + } + + const Algorithm * delta_med_algo = SubAlg( "COH-Delta-Corrections" ) ; + + if ( ! delta_med_algo ) { + good_config = false ; + LOG("COHDeltaCurrent", pERROR ) << "Configuration does not know COH-Delta-Corrections field" ; + } + + Delta_med = dynamic_cast( delta_med_algo ) ; + + if ( ! Delta_med ) { + good_config = false ; + LOG("COHDeltaCurrent", pERROR ) << "Algo " << delta_med_algo -> Id().Name() << " is not a DeltaInMediumCorrections" ; + } + + if ( ! good_config ) { + LOG("COHDeltaCurrent", pFATAL ) << "Bad configuration, exit" ; + exit( 78 ) ; + } + +} + +//____________________________________________________________________________ +GTrace COHDeltaCurrent::R( const Interaction & i, + double proton_ff, double neutron_ff ) const { + + const InitialState & init_state = i.InitState(); + + double k0 = init_state.ProbeE( kRfLab ) ; + TLorentzVector probe( 0., 0., k0, k0 ) ; + + const Kinematics & kine = i.Kine() ; + TLorentzVector out_neutrino = kine.FSLeptonP4() ; + TLorentzVector q = probe - out_neutrino ; + + + // evaluation of the momenta to be used for the propagators + TLorentzVector temp = 0.5*( i.Kine().HadSystP4() - q ); + + TLorentzVector p_dir( temp.Vect(), + sqrt(pow(constants::kNucleonMass,2) + temp.Vect().Mag2() ) ); + + TLorentzVector p_crs( -temp.Vect(), p_dir.E() ); // same temporal. opposite sign for the spatial + + double p0 = p_dir.E() ; + p_dir += q ; + p_crs -= q ; + + int pdg = init_state.Tgt().Pdg() ; + + std::complex D_prop_dir = Delta_med -> AverageDirectPropagator( p_dir.Mag2(), pdg ) ; + std::complex D_prop_cross = Delta_med -> AverageCrossPropagator( p_crs.Mag2() ) ; + + GTrace R = DirTrace(i) ; + R *= D_prop_dir ; + + GTrace tr_cross = CrsTrace(i) ; + tr_cross *= D_prop_cross ; + + // Add trace * propagator from direct and crossed diagrams + R += tr_cross ; + + R *= ( proton_ff * constants::kProtonMass + neutron_ff * constants::kNeutronMass ) / ( 2*p0 ) ; + + return R; +} + +//____________________________________________________________________________ +GTrace COHDeltaCurrent::DirTrace( const Interaction & i ) const { + + // these calculations expects the interaction to be in the lab frame with the incoming neutrino parallel to z + double k0 = i.InitState().ProbeE( kRfLab ) ; + TLorentzVector probe( 0., 0., k0, k0 ) ; + TLorentzVector out_neutrino = i.Kine().FSLeptonP4() ; + TLorentzVector t_photon = i.Kine().HadSystP4() ; + + TLorentzVector t_q = probe - out_neutrino ; + double Q2 = std::abs(t_q.Mag2()) ; // Must be >0 + + // this requires Q2 + double C3v = delta_ff -> C3V( Q2 ) ; + double C3vNC = delta_ff -> C3VNC( Q2 ) ; + double C5aNC = delta_ff -> C5ANC( Q2 ) ; + + double mDelta = utils::res::Mass( Resonance() ) ; + double mDelta2 = pow( mDelta, 2 ); + + TVector3 temp = 0.5*( i.Kine().HadSystP4() - t_q ).Vect(); + double p0 = sqrt(pow(constants::kNucleonMass,2) + temp.Mag2() ) ; + + // the following contractions requires a vector with time coordinate in the 0-th position + // that is not the case for TLorentzVector so we need to rearrange it + std::array q = { t_q.E(), t_q.X(), t_q.Y(), t_q.Z() } ; + std::array kg = { t_photon.E(), t_photon.X(), t_photon.Y(), t_photon.Z() } ; + double mn = constants::kNucleonMass ; + double mn2 = pow( mn, 2 ) ; + + GTrace tr; + + tr[0][0] = -( C3v*C3vNC*( mDelta*p0 + mn*(p0 + q[0]) )*( 4*mDelta2*q[1]*kg[1] - 4*pow(p0,2)*q[1]*kg[1] + + pow(q[1],3)*kg[1] + q[1]*q[3]*q[3]*kg[1] + + q[1]*q[1]*kg[1]*kg[1] - q[3]*q[3]*kg[1]*kg[1] + - q[3]*q[3]*kg[2]*kg[2] + + q[0]*q[0]*( q[1]*q[1] - 3*q[1]*kg[1] + q[3]*( 2*q[3] - 3*kg[3] ) ) + + q[3]*( 4*mDelta2 - 4*pow(p0,2) + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] )*kg[3] + - 8*p0*q[0]*( q[1]*kg[1] + q[3]*kg[3] ) ) + ) / ( 3.*mDelta2*pow(mn,3) ); + + tr[0][1] = ( std::complex(0.,1.)*C3v*C5aNC*mDelta*( mDelta*p0 + mn*( p0 + q[0] ) )*q[3]*kg[2]*( 8*mn2 + - 2*q[0]*( p0 + q[0] ) + q[1]*( q[1] + kg[1] ) + q[3]*( q[3] + kg[3]) ) + - C3v*C3vNC*mn*( 16*mDelta2 * mn * q[0] * ( p0 + q[0] ) * kg[1] + 4*pow(mDelta,3)*( 4*p0*q[0]*kg[1] + + q[3]*( -( q[3]*kg[1]) + q[1]*kg[3]) ) - 4*mn*(p0 + q[0])*( 4*pow(p0,2)*q[0]*kg[1] + 8*p0*q[0] * q[0]*kg[1] + + 4*pow( q[0], 3)*kg[1] - q[0]*q[1] * q[1]*kg[1] + 2*p0*q[3]*(-(q[3]*kg[1]) + q[1]*kg[3]) + - q[0]*q[1]*( 2*kg[1]*kg[1] + kg[2]*kg[2] + kg[3]*(- q[3] + kg[3]) ) + - q[0]*kg[1]*( q[0]*q[0] + q[3]*(2*q[3] + kg[3] ) ) ) + + mDelta*( -16*pow(p0,3)*q[0]*kg[1] - q[3]*(q[3]*kg[1] - q[1]*kg[3])*( -3*q[0]*q[0] + q[1]*q[1] + + 2*q[1]*kg[1] + q[3]*( q[3] + 2*kg[3] ) ) - 4*pow(p0,2)*(8*q[0]*q[0]*kg[1] + 3*q[3]*( -( q[3]*kg[1] ) + + q[1]*kg[3] ) ) + 4*p0*q[0]*( q[0]*q[0]*( q[1] - 3*kg[1] ) + q[1]*q[1]*kg[1] + q[3]*kg[1]*( 4*q[3] + kg[3] ) + + q[1]*( kg[1]*kg[1] - 3*q[3]*kg[3] ) ) ) ) + ) / (12.*mDelta2*pow(mn,4)); + + tr[0][2] = ( C3v*( std::complex(0.,-1.)*C5aNC*mDelta*( mDelta*p0 + mn*( p0 + q[0] ) )*( q[3]*kg[1] + - q[1]*kg[3] )*( 8*mn2 - 2*q[0]*( p0 + q[0] ) + q[1]*( q[1] + kg[1] ) + q[3]*( q[3] + kg[3] ) ) + + C3vNC*mn*kg[2]*( -16*mDelta2*mn*q[0]*( p0 + q[0] ) + 4*pow(mDelta,3)*( -4*p0*q[0] + q[1]*q[1] + q[3]*q[3]) + + 4*mn*( p0 + q[0] )*( 4*pow(p0,2)*q[0] + 8*p0*q[0]*q[0] + 3*pow(q[0],3) - 2*p0*(q[1]*q[1] + q[3]*q[3] ) + - q[0]*q[1]*( 2*q[1] + kg[1] ) - q[0]*q[3]*( 2*q[3] + kg[3] ) ) + + mDelta*( 16*pow(p0,3)*q[0] + 4*pow(p0,2)*( 8*q[0]*q[0] - 3*( q[1]*q[1] + q[3]*q[3] ) ) + + (q[1]*q[1] + q[3]*q[3])*( -3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + 4*p0*q[0]*( 3*q[0]*q[0] - q[1]*( 4*q[1] + kg[1] ) - q[3]*( 4*q[3] + kg[3]) ) ) ) ) + ) / ( 12.*mDelta2*pow(mn,4) ); + + tr[0][3] = ( C3v*( std::complex(0.,-1.)*C5aNC*mDelta*( mDelta*p0 + mn*( p0 + q[0] ) )*q[1]*kg[2]*( 8*mn2 - 2*q[0]*( p0 + q[0] ) + + q[1]*( q[1] + kg[1] ) + q[3]*( q[3] + kg[3] ) ) + + C3vNC*mn*( -16*mDelta2*mn*q[0]*( p0 + q[0] )*kg[3] + 4*pow(mDelta,3)*( -(q[1]*q[3]*kg[1]) + - 4*p0*q[0]*kg[3] + q[1]*q[1]*kg[3] ) + 4*mn*( p0 + q[0] )*( q[0]*q[3]*( kg[1]*( q[1] + kg[1] ) + kg[2]*kg[2] ) + + 8*p0*q[0]*q[0]*kg[3] - q[0]*( -4*pow(p0,2) + q[3]*q[3] + q[1]*( 2*q[1] + kg[1] ) )*kg[3] + + pow(q[0],3)*( -2*q[3] + 3*kg[3] ) + 2*p0*q[1]*( q[3]*kg[1] - q[1]*kg[3] ) ) + + mDelta*( 16*pow(p0,3)*q[0]*kg[3] + 4*pow(p0,2)*( 3*q[1]*q[3]*kg[1] + 8*q[0]*q[0]*kg[3] - 3*q[1]*q[1]*kg[3] ) + + q[1]*( -( q[3]*kg[1] ) + q[1]*kg[3] )*( -3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + - 4*p0*q[0]*( -( q[3]*(3*q[1]*kg[1] + kg[1]*kg[1] + kg[2]*kg[2] ) ) + q[0]*q[0]*( 2*q[3] - 3*kg[3] ) + + ( q[3]*q[3] + q[1]*( 4*q[1] + kg[1] ) )*kg[3] ) ) ) ) + ) / ( 12.*mDelta2*pow(mn,4) ); + + tr[1][0] = (C3v*( std::complex(0.,1.)*C5aNC*q[3]*kg[2]*( 8*pow(mDelta,3)*mn*( p0 + q[0] ) + - 4*mn2*( p0 + q[0] )*( 2*p0*q[0] + q[0]*q[0] - q[1]*kg[1] - q[3]*kg[3] ) + - 2*mDelta*mn*( p0 + q[0] )*( 8*mn2 + 2*p0*q[0] + q[0]*q[0] - q[1]*kg[1] - q[3]*kg[3] ) + + mDelta2*( 8*pow(p0,3) + 12*pow(p0,2)*q[0] + 4*p0*q[0]*q[0] + 8*mn2*( -2*p0 + q[0] ) + + q[0]*( q[1]*q[1] - q[1]*kg[1] + q[3]*( q[3] - kg[3] ) ) + - 2*p0*( q[1]*q[1] + 2*q[1]*kg[1] + q[3]*( q[3] + 2*kg[3] ) ) ) ) + - 2*C3vNC*mn*( 16*mDelta2*mn*q[0]*( p0 + q[0] )*q[1] + 4*pow(mDelta,3)*( q[1]*( 4*p0*q[0] + - q[0]*q[0] + kg[1]*kg[1] ) + q[3]*kg[1]*kg[3] ) + + mDelta*( -16*pow(p0,3)*q[0]*q[1] + 4*p0*q[0]*( pow(q[1],3) + 2*q[1]*q[1]*kg[1] - 3*q[1]*kg[1]*kg[1] + + q[3]*kg[1]*( q[3] - 3*kg[3] ) + q[1]*q[3]*( q[3] + kg[3] ) ) + + ( 3*q[0]*q[0] - q[1]*( q[1] + 2*kg[1] ) - q[3]*( q[3] + 2*kg[3] ) )*( q[0]*q[0]*q[1] + - kg[1]*( q[1]*kg[1] + q[3]*kg[3] ) ) - 4*pow(p0,2)*( 5*q[0]*q[0]*q[1] + 3*kg[1]*( q[1]*kg[1] + q[3]*kg[3] ) ) ) + - 4*mn*( p0 + q[0] )*( 4*pow(p0,2)*q[0]*q[1] + 6*p0*q[0]*q[0]*q[1] + 2*p0*kg[1]*( q[1]*kg[1] + q[3]*kg[3] ) + + q[0]*( 2*q[0]*q[0]*q[1] - pow(q[1],3) - 2*q[1]*q[1]*kg[1] + q[3]*kg[1]*(-q[3] + kg[3] ) + + q[1]*( kg[1]*kg[1] - q[3]*(q[3] + kg[3] ) ) ) ) ) ) + ) / ( 24.*mDelta2*pow(mn,4) ); + + tr[1][1] = (C3v*( std::complex(0.,1.)*C5aNC*q[3]*kg[2]*( 4*pow(mDelta,3)*mn*( q[1] + kg[1] ) + + 2*mn2*( q[1] + kg[1] )*( -( q[0]*( 2*p0 + q[0] ) ) + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*( q[1] + kg[1] )*( -4*p0*q[0] - 3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + mDelta2*( q[0]*q[0]*( q[1] - kg[1] ) + 8*mn2*kg[1] - 2*p0*q[0]*kg[1] + q[3]*q[3]*kg[1] + + 4*pow(p0,2)*( q[1] + kg[1] ) - q[1]*q[3]*kg[3] ) ) + - 2*C3vNC*mn*( 16*mDelta2*mn*( p0 + q[0] )*( q[0]*q[0] - q[3]*kg[3] ) + + 4*pow(mDelta,3)*( -( q[0]*( -4*p0*q[0] + q[0]*q[0] + q[3]*q[3] - kg[1]*kg[1] ) ) + + 2*( -2*p0 + q[0] )*q[3]*kg[3] ) + - 4*mn*( p0 + q[0] )*( 4*pow(p0,2)*q[0]*q[0] + 2*pow(q[0],4) + - q[0]*q[0]*( q[1]*q[1] + 2*q[1]*kg[1] - kg[1]*kg[1] + 3*q[3]*kg[3] ) + + q[3]*( -( q[3]*( 2*kg[1]*kg[1] + kg[2]*kg[2] ) ) + +( q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] )*kg[3] ) + + 2*p0*q[0]*( 3*q[0]*q[0] + kg[1]*kg[1] - q[3]*( q[3] + 2*kg[3] ) ) ) + - mDelta*( 16*pow(p0,3)*q[0]*q[0] + 4*pow(p0,2)*q[0]*( 5*q[0]*q[0] - 3*q[3]*q[3] + 3*kg[1]*kg[1] - 2*q[3]*kg[3] ) + + 4*p0*( -2*q[3]*q[3]*kg[1]*kg[1] - q[0]*q[0]*( 2*q[3]*q[3] +( q[1] - kg[1] )*( q[1] + 3*kg[1] ) ) + + q[3]*( q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] )*kg[3] ) + - q[0]*( q[0]*q[0] + q[3]*q[3] - kg[1]*kg[1] - 2*q[3]*kg[3] )*( 3*q[0]*q[0] - q[1]*( q[1] + 2*kg[1] ) + - q[3]*( q[3] + 2*kg[3] ) ) ) ) ) + ) / ( 24.*mDelta2*pow(mn,4) ); + + tr[1][2] = ( C3v*( -2*C3vNC*mn*kg[2]*( 16*mDelta2*mn*( p0 + q[0] )*q[1] + 4*pow(mDelta,3)*( 4*p0*q[1] + q[0]*( -2*q[1] + kg[1] ) ) + + 4*mn*( p0 + q[0] )*( pow(q[1],3) + q[1]*q[3]*q[3] + 2*q[1]*q[1]*kg[1] + q[3]*q[3]*kg[1] + - 2*p0*q[0]*( 2*q[1] + kg[1] ) -q[0]*q[0]*( 2*q[1] + kg[1] ) + q[1]*q[3]*kg[3] ) + + mDelta*(-4*pow(p0,2)*q[0]*( 2*q[1] + 3*kg[1] ) + 4*p0*( q[0]*q[0]*( 2*q[1] - 3*kg[1] ) + + ( q[1]*q[1] + q[3]*q[3] )*( q[1] + 2*kg[1] ) ) + - q[0]*( 2*q[1] - kg[1] )*( -3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + + std::complex(0.,1.)*C5aNC*( 2*mn2*q[3]*kg[2]*kg[2]*( -( q[0]*( 2*p0 + q[0] ) ) + q[1]*kg[1] + q[3]*kg[3] ) + + 4*pow(mDelta,3)*mn*( -( q[3]*kg[1]*kg[1] ) + q[0]*q[0]*( q[3] - 2*kg[3] ) - 2*p0*q[0]*kg[3] + + ( 8*mn2 + q[3]*q[3] + q[1]*( q[1] + kg[1] ) )*kg[3] ) + + mDelta2*( -2*p0*q[3]*( 2*p0*( -2*q[0]*q[0] + kg[1]*kg[1] ) + + q[0]*( -3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + q[1]*kg[1] + kg[1]*kg[1] ) ) + + q[3]*( -( q[0]*( 4*p0 + q[0] ) ) + q[1]*q[1] + q[3]*q[3])*kg[2]*kg[2] + + 2*p0*( -4*pow(p0,2)*q[0] - 2*pow(q[0],3) + q[0]*q[1]*( q[1] + kg[1] ) + + 2*p0*( -3*q[0]*q[0] + q[3]*q[3] + q[1]*( q[1] + kg[1] ) ) )*kg[3] + + 8*mn2*( q[3]*( -2*p0*q[0] + kg[2]*kg[2] ) + 2*p0*( 2*p0 + q[0] )*kg[3] ) ) + + mDelta*mn*( q[3]*( -pow(q[0],4) - kg[1]*kg[1]*( 3*( q[1]*q[1] + q[3]*q[3] ) + 4*q[1]*kg[1] ) + - 2*(q[3]*q[3] + q[1]*(q[1] + kg[1] ) )*kg[2]*kg[2] + + q[0]*q[0]*( q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 5*kg[1]*kg[1] + 2*kg[2]*kg[2] ) ) + + ( 2*pow(q[0],4) + pow((q[1]*q[1] + q[3]*q[3]),2) + 3*q[1]*( q[1]*q[1] + q[3] * q[3])*kg[1] + + 2*( q[1] - q[3] )*( q[1] + q[3] )*kg[1]*kg[1] + - q[0]*q[0]*( 3*( q[1]*q[1] + q[3]*q[3] ) + 5*q[1]*kg[1] ) )*kg[3] + 4*pow(p0,2)*q[0]*q[0]*( q[3] + kg[3] ) + - 8*mn2*( 2*p0*q[0]*( q[3] + kg[3] ) + q[0]*q[0]*( 2*q[3] + kg[3] ) + - kg[3]*( q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + 2*p0*q[0]*( -( q[1]*q[1]*( q[3] + 2*kg[3] ) ) + q[0]*q[0]*( q[3] + 3*kg[3] ) + - q[1]*kg[1]*( q[3] + 3*kg[3] ) + q[3]*( 3*kg[1]*kg[1] + kg[2]*kg[2] - q[3]*( q[3] + 3*kg[3] ) ) ) ) ) ) + ) / ( 24.*mDelta2*pow(mn,4) ); + + tr[1][3] = -( C3v*( std::complex(0.,1.)*C5aNC*kg[2]*( 4*pow(mDelta,3)*mn*( 8*mn2 - 2*q[0]*(p0 + q[0]) + q[1]*(q[1] + kg[1]) ) + - 2*mn2*q[3]*(q[3] + kg[3])*( -(q[0]*(2*p0 + q[0])) + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*( 4*pow(p0,2)*q[0]*q[0] + 6*p0*pow(q[0],3) + 2*pow(q[0],4) + - 4*p0*q[0]*q[1]*q[1] - 3*q[0]*q[0]*q[1]*q[1] + pow(q[1],4) + + q[1]*q[1]*q[3]*q[3] - 6*p0*q[0]*q[1]*kg[1] - 5*q[0]*q[0]*q[1]*kg[1] + + 3*pow(q[1],3)*kg[1] + q[1]*q[3] * q[3]*kg[1] + 2*q[1]*q[1]*kg[1]*kg[1] + + 2*q[3]*( -(q[0]*(p0 + q[0])) + q[1]*(q[1] + kg[1]))*kg[3] + + 8*mn2*( -( q[0]*(2*p0 + q[0]) ) + q[1]*q[1] + 2*q[1]*kg[1] + q[3]*( q[3] + 2*kg[3] ) ) ) + + mDelta2*( -8*pow(p0,3)*q[0] + 4*pow(p0,2)*( -3*q[0]*q[0] + q[1]*(q[1] + kg[1]) ) + + 8*mn2*( 2*p0*(2*p0 + q[0]) - q[3]*kg[3] ) + + 2*p0*q[0]*( -2*q[0] * q[0] + q[1]*(q[1] + kg[1]) + q[3]*(q[3] + 2*kg[3]) ) + + q[3]*( q[0]*q[0]*(-q[3] + kg[3]) + q[1]*(q[3]*kg[1] - q[1]*kg[3]) ) ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*(p0 + q[0])*q[1]*kg[3] + + 4*pow(mDelta,3)*( q[0]*q[1]*(q[3] - 2*kg[3]) + 4*p0*q[1]*kg[3] + q[0]*kg[1]*kg[3] ) + - 4*mn*(p0 + q[0])*( q[1]*q[3]*( 2*kg[1]*kg[1] + kg[2]*kg[2] ) + - q[1]*( q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] )*kg[3] + + q[0]*q[0]*( -(q[3]*(q[1] + kg[1])) + (2*q[1] + kg[1])*kg[3] ) + + 2*p0*q[0]*( kg[1]*kg[3] + q[1]*(q[3] + 2*kg[3]) ) ) + + mDelta*( -4*pow(p0,2)*q[0]*( 3*q[1]*q[3] + 2*q[1]*kg[3] + 3*kg[1]*kg[3] ) + - q[0]*( q[1]*(q[3] - 2*kg[3]) + kg[1]*kg[3] )*( 3*q[0]*q[0] - q[1]*(q[1] + + 2*kg[1]) - q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*( -2*q[1]*q[3]*kg[1] * kg[1] + + q[1]*( q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] )*kg[3] + + q[0]*q[0]*( -(q[1]*q[3]) + q[3]*kg[1] + 2*q[1]*kg[3] - 3*kg[1]*kg[3] ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][0] = ( C3v*( -2*C3vNC*mn*kg[2]*( 4*pow(mDelta,3)*(q[1]*kg[1] + q[3]*kg[3]) + - 4*mn*(p0 + q[0])*( -( q[0]*(q[1]*q[1] + q[3]*q[3] - q[1]*kg[1] - q[3]*kg[3]) ) + + 2*p0*(q[1]*kg[1] + q[3]*kg[3]) ) + + mDelta*( 4*p0*q[0]*( q[1]*q[1] + q[3]*q[3] - 3*q[1]*kg[1] - 3*q[3]*kg[3] ) + - 12*pow(p0,2)*(q[1]*kg[1] + q[3]*kg[3]) + + (q[1]*kg[1] + q[3]*kg[3])*( -3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + - std::complex(0.,1.)*C5aNC*(q[3]*kg[1] - q[1]*kg[3])*( 8*pow(mDelta,3)*mn*(p0 + q[0]) + - 4*mn2*(p0 + q[0])*( 2*p0*q[0] + q[0]*q[0] - q[1]*kg[1] - q[3]*kg[3] ) + - 2*mDelta*mn*(p0 + q[0])*( 8*mn2 + 2*p0*q[0] + q[0]*q[0] - q[1]*kg[1] - q[3]*kg[3] ) + + mDelta2*( 8*pow(p0,3) + 12*pow(p0,2)*q[0] + 4*p0*q[0]*q[0] + 8*mn2*(-2*p0 + q[0]) + + q[0]*( q[1]*q[1] - q[1]*kg[1] + q[3]*(q[3] - kg[3]) ) + - 2*p0*( q[1]*q[1] + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][1] = ( C3v*( -2*C3vNC*mn*kg[2]*( 4*pow(mDelta,3)*q[0]*kg[1] - 4*mn*(p0 + q[0])*( 2*p0*q[0]*kg[1] + + q[0] * q[0]*(-q[1] + kg[1]) + q[3]*(-(q[3]*kg[1]) + q[1]*kg[3]) ) + + mDelta*( 4*p0*q[0] * q[0]*(q[1] - 3*kg[1]) - 12*pow(p0,2)*q[0]*kg[1] + + 8*p0*q[3]*(q[3]*kg[1] - q[1]*kg[3]) + + q[0]*kg[1]*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + - std::complex(0.,1.)*C5aNC*( 2*mn2*(q[1] + kg[1])*(-(q[3]*kg[1]) + + q[1]*kg[3])*( 2*p0*q[0] + q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + + 4*pow(mDelta,3)*mn*( q[3]*( q[0] * q[0] + q[1]*kg[1] - kg[2] * kg[2] ) + + ( 8*mn2 - 2*q[0]*(p0 + q[0]) + q[3] * q[3] )*kg[3] ) + + mDelta2*( -8*pow(p0,3)*q[0]*kg[3] + 2*p0*q[0]*( -( q[3]*(q[1] * q[1] + q[3] * q[3] + q[1]*kg[1] + + 2*kg[1] * kg[1] + kg[2] * kg[2] ) ) + q[0] * q[0]*(3*q[3] - 2*kg[3]) + q[1]*(q[1] + 2*kg[1])*kg[3] ) + + 4*pow(p0,2)*( q[3]*kg[1]*(q[1] + kg[1]) + q[0] * q[0]*(q[3] - 3*kg[3]) + q[3]*kg[3]*(q[3] + kg[3]) ) + + (q[3]*kg[1] - q[1]*kg[3])*( q[0] * q[0]*(q[1] - kg[1]) + q[3]*(q[3]*kg[1] - q[1]*kg[3]) ) + + 8*mn2*( 4*pow(p0,2)*kg[3] + 2*p0*q[0]*(-q[3] + kg[3]) + kg[1]*(q[3]*kg[1] - q[1]*kg[3]) ) ) + + mDelta*mn*( q[3]*( -pow(q[0],4) + kg[1]*( pow(q[1],3) + q[1]*q[3] * q[3] + + 2*q[1] * q[1]*kg[1] - 2*q[3] * q[3]*kg[1] ) + - ( q[1] * q[1] + 3*q[3] * q[3] + 2*q[1]*kg[1] )*kg[2] * kg[2] + + q[0] * q[0]*( -q[1] * q[1] + q[3] * q[3] - 3*q[1]*kg[1] + 2*kg[1] * kg[1] + 5*kg[2] * kg[2] ) ) + + ( 2*pow(q[0],4) - q[0] * q[0]*( 3*q[3] * q[3] + 2*q[1]*kg[1] ) + + q[3] * q[3]*( q[1] * q[1] + q[3] * q[3] + 4*q[1]*kg[1] - 2*kg[2] * kg[2] ) )*kg[3] + + 4*pow(p0,2)*q[0] * q[0]*(q[3] + kg[3]) + - 8*mn2*( 2*p0*q[0]*(q[3] + kg[3]) + q[0] * q[0]*(2*q[3] + kg[3]) + - kg[3]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + 2*p0*q[0]*( -(q[1] * q[1]*q[3]) - q[1]*kg[1]*(3*q[3] + kg[3]) + q[0] * q[0]*(q[3] + 3*kg[3]) + + q[3]*( kg[1] * kg[1] + 3*kg[2] * kg[2] - q[3]*(q[3] + 3*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][2] = ( C3v*( std::complex(0.,-1.)*C5aNC*kg[2]*(q[3]*kg[1] - q[1]*kg[3])*( 4*pow(mDelta,3)*mn + + mDelta2*( 8*mn2 + 4*pow(p0,2) - 2*p0*q[0] - q[0]*q[0] + q[1]*q[1] + q[3]*q[3] ) + + 2*mn2*( -(q[0]*(2*p0 + q[0])) + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*( -4*p0*q[0] - 3*q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + 2*C3vNC*mn*( -16*mDelta2*mn*(p0 + q[0])*(q[0]*q[0] - q[1]*kg[1] - q[3]*kg[3]) + + 4*pow(mDelta,3)*( q[0]*( q[0]*q[0] + q[1]*q[1] + q[3]*q[3] - 2*q[1]*kg[1] - kg[2]*kg[2] - 2*q[3]*kg[3] ) + + 4*p0*( -q[0]*q[0] + q[1]*kg[1] + q[3]*kg[3] ) ) + + 4*mn*(p0 + q[0])*( 4*pow(p0,2)*q[0]*q[0] + 2*pow(q[0],4) + pow(q[1],3)*kg[1] + q[1]*q[3]*q[3]*kg[1] + + q[1]*q[1]*kg[1]*kg[1] - q[3]*q[3]*kg[1]*kg[1] - q[1]*q[1]*kg[2]*kg[2] - 2*q[3]*q[3]*kg[2]*kg[2] + + q[3]*( q[1]*q[1] + q[3]*q[3] + 2*q[1]*kg[1] )*kg[3] + - q[0]*q[0]*( q[1]*q[1] + 3*q[1]*kg[1] - kg[2]*kg[2] + 3*q[3]*kg[3] ) + + 2*p0*q[0]*( 3*q[0]*q[0] - q[1]*(q[1] + 2*kg[1]) + kg[2]*kg[2] - q[3]*(q[3] + 2*kg[3]) ) ) + + mDelta*( 16*pow(p0,3)*q[0]*q[0] + 4*pow(p0,2)*q[0]*( 5*q[0]*q[0] - 3*q[1]*q[1] - 3*q[3]*q[3] + - 2*q[1]*kg[1] + 3*kg[2]*kg[2] - 2*q[3]*kg[3] ) + - q[0]*( q[0]*q[0] + q[1]*q[1] + q[3]*q[3] + - 2*q[1]*kg[1] - kg[2]*kg[2] - 2*q[3]*kg[3] )*( 3*q[0]*q[0] - q[1]*(q[1] + + 2*kg[1]) - q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*( pow(q[1],3)*kg[1] + q[1]*q[3]*q[3]*kg[1] + q[3]*q[3]*( -2*kg[2]*kg[2] + q[3]*kg[3] ) + + q[0]*q[0]*( q[1]*(-4*q[1] + kg[1]) + 3*kg[2]*kg[2] + q[3]*(-2*q[3] + kg[3]) ) + + q[1]*q[1]*( 2*kg[1]*kg[1] + kg[3]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][3] = ( C3v*( -2*C3vNC*mn*kg[2]*( 4*pow(mDelta,3)*q[0]*kg[3] - 4*mn*(p0 + q[0])*( 2*p0*q[0]*kg[3] + + q[0] * q[0]*(-q[3] + kg[3]) + q[1]*(q[3]*kg[1] - q[1]*kg[3]) ) + + mDelta*( 4*p0*q[0] * q[0]*(q[3] - 3*kg[3]) - 12*pow(p0,2)*q[0]*kg[3] + 8*p0*q[1]*( -(q[3]*kg[1]) + q[1]*kg[3] ) + + q[0]*kg[3]*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + + std::complex(0.,1.)*C5aNC*( -2*mn2*(q[3] + kg[3])*( q[3]*kg[1] + - q[1]*kg[3] )*( -( q[0]*(2*p0 + q[0]) ) + q[1]*kg[1] + q[3]*kg[3] ) + + 4*pow(mDelta,3)*mn*( q[0] * q[0]*(q[1] - 2*kg[1]) + 8*mn2*kg[1] + - 2*p0*q[0]*kg[1] + q[1]*( q[1]*kg[1] - kg[2] * kg[2] + q[3]*kg[3] ) ) + + mDelta2*( -8*pow(p0,3)*q[0]*kg[1] + 4*pow(p0,2)*( q[0] * q[0]*(q[1] - 3*kg[1]) + + q[1]*kg[1]*(q[1] + kg[1]) + q[1]*kg[3]*(q[3] + kg[3]) ) + + (q[3]*kg[1] - q[1]*kg[3])*( q[0] * q[0]*(-q[3] + kg[3]) + q[1]*(q[3]*kg[1] - q[1]*kg[3]) ) + + 8*mn2*( 4*pow(p0,2)*kg[1] + 2*p0*q[0]*(-q[1] + kg[1]) + kg[3]*( -(q[3]*kg[1]) + q[1]*kg[3] ) ) + + 2*p0*q[0]*( -pow(q[1],3) + q[0] * q[0]*(q[1] - 2*kg[1]) + q[3]*kg[1]*(q[3] + 2*kg[3]) + + q[1]*( 2*kg[1] * kg[1] + kg[2] * kg[2] - q[3]*(q[3] + kg[3]) ) ) ) + + mDelta*mn*( pow(q[0],4)*q[1] - q[0] * q[0]*pow(q[1],3) + q[0] * q[0]*q[1]*q[3] * q[3] + 2*pow(q[0],4)*kg[1] + - 3*q[0] * q[0]*q[1] * q[1]*kg[1] + pow(q[1],4)*kg[1] + q[1] * q[1]*q[3] * q[3]*kg[1] + - 2*q[0] * q[0]*q[1]*kg[1] * kg[1] + 2*pow(q[1],3)*kg[1] * kg[1] - 2*q[1]*q[3] * q[3]*kg[1] * kg[1] + + 4*pow(p0,2)*q[0] * q[0]*(q[1] + kg[1]) + 3*q[0] * q[0]*q[1]*kg[2] * kg[2] - pow(q[1],3)*kg[2] * kg[2] + - 3*q[1]*q[3] * q[3]*kg[2] * kg[2] - 2*q[1] * q[1]*kg[1]*kg[2] * kg[2] + - 3*q[0] * q[0]*q[1]*q[3]*kg[3] + pow(q[1],3)*q[3]*kg[3] + q[1]*pow(q[3],3)*kg[3] + - 2*q[0] * q[0]*q[3]*kg[1]*kg[3] + 4*q[1] * q[1]*q[3]*kg[1]*kg[3] - 2*q[1]*q[3]*kg[2] * kg[2]*kg[3] + - 8*mn2*( 2*p0*q[0]*(q[1] + kg[1]) + q[0] * q[0]*(2*q[1] + kg[1]) + - kg[1]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + 2*p0*q[0]*( -pow(q[1],3) - 3*q[1] * q[1]*kg[1] + 2*q[0] * q[0]*(q[1] + 2*kg[1]) + - q[1]*( q[3] * q[3] + kg[1] * kg[1] - 2*kg[2] * kg[2] + 3*q[3]*kg[3] ) + - kg[1]*( kg[1] * kg[1] + kg[2] * kg[2] + kg[3]*(q[3] + kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][0] = -( C3v*( std::complex(0.,1.)*C5aNC*q[1]*kg[2]*( 8*pow(mDelta,3)*mn*(p0 + q[0]) + - 4*mn2*(p0 + q[0])*( 2*p0*q[0] + q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + - 2*mDelta*mn*(p0 + q[0])*( 8*mn2 + 2*p0*q[0] + q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + + mDelta2*( 8*pow(p0,3) + 12*pow(p0,2)*q[0] + 4*p0*q[0] * q[0] + 8*mn2*(-2*p0 + q[0]) + + q[0]*( q[1] * q[1] - q[1]*kg[1] + q[3]*(q[3] - kg[3]) ) + - 2*p0*( q[1] * q[1] + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*q[0]*(p0 + q[0])*q[3] + + 4*pow(mDelta,3)*( 4*p0*q[0]*q[3] - q[3]*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[1]*kg[1]*kg[3] ) + + 4*mn*(p0 + q[0])*( -4*pow(p0,2)*q[0]*q[3] - 8*p0*q[0] * q[0]*q[3] - 3*pow(q[0],3)*q[3] + + 2*p0*q[3]*( kg[1] * kg[1] + kg[2] * kg[2] ) + + q[0]*q[3]*( q[1] * q[1] + q[3] * q[3] + q[1]*kg[1] + kg[1] * kg[1] + kg[2] * kg[2] ) + - 2*p0*q[1]*kg[1]*kg[3] + q[0]*( q[1] * q[1] + 2*q[3] * q[3] - q[1]*kg[1] )*kg[3] ) + + mDelta*( -16*pow(p0,3)*q[0]*q[3] - 4*pow(p0,2)*( 8*q[0] * q[0]*q[3] + - 3*q[3]*( kg[1] * kg[1] + kg[2] * kg[2] ) + 3*q[1]*kg[1]*kg[3] ) + - ( q[3]*(kg[1] * kg[1] + kg[2] * kg[2]) - q[1]*kg[1]*kg[3] )*( -3*q[0] * q[0] + q[1] * q[1] + + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*q[0]*( -3*q[0] * q[0]*q[3] + q[1]*kg[1]*(q[3] - 3*kg[3]) + q[1] * q[1]*(q[3] + kg[3]) + + q[3]*( 3*(kg[1] * kg[1] + kg[2] * kg[2]) + q[3]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][1] = ( std::complex(0.,1.)*C3v*C5aNC*kg[2]*( -2*mn2*q[1]*(q[1] + kg[1])*( -(q[0]*(2*p0 + q[0])) + + q[1]*kg[1] + q[3]*kg[3] ) + 4*pow(mDelta,3)*mn*( 8*mn2 - 2*q[0]*(p0 + q[0]) + q[3]*(q[3] + kg[3]) ) + - mDelta*mn*( -4*pow(p0,2)*q[0] * q[0] - 2*pow(q[0],4) + q[0] * q[0]*q[3] * q[3] + - q[1] * q[1]*q[3] * q[3] - pow(q[3],4) + + 2*q[0] * q[0]*q[1]*kg[1] - 2*q[1]*q[3] * q[3]*kg[1] + + 2*q[3] * q[3]*kg[1] * kg[1] + 2*q[3] * q[3]*kg[2] * kg[2] + - q[3]*( -5*q[0] * q[0] + q[1] * q[1] + 3*q[3] * q[3] + 2*q[1]*kg[1] )*kg[3] + + 2*p0*q[0]*( -3*q[0] * q[0] + 2*q[3] * q[3] + q[1]*kg[1] + 3*q[3]*kg[3] ) + + 8*mn2*( 2*p0*q[0] + q[0] * q[0] - q[1]*(q[1] + 2*kg[1]) - q[3]*(q[3] + 2*kg[3]) ) ) + + mDelta2*( -8*pow(p0,3)*q[0] + 8*mn2*( 2*p0*(2*p0 + q[0]) - q[1]*kg[1] ) + + 4*pow(p0,2)*( -3*q[0] * q[0] + q[3]*(q[3] + kg[3]) ) + + 2*p0*q[0]*( -2*q[0] * q[0] + q[1]*(q[1] + 2*kg[1]) + q[3]*(q[3] + kg[3]) ) + + q[1]*( q[0] * q[0]*(-q[1] + kg[1]) + q[3]*( -(q[3]*kg[1]) + q[1]*kg[3] ) ) ) ) + - 2*C3v*C3vNC*mn*( 16*mDelta2*mn*(p0 + q[0])*q[3]*kg[1] + + 4*pow(mDelta,3)*( q[0]*q[1]*q[3] + 4*p0*q[3]*kg[1] + q[0]*kg[1]*(-2*q[3] + kg[3]) ) + - 4*mn*(p0 + q[0])*( 2*p0*q[0]*( q[1]*q[3] + kg[1]*(2*q[3] + kg[3]) ) + + q[0] * q[0]*( q[1]*(q[3] - kg[3]) + kg[1]*(2*q[3] + kg[3]) ) + - q[3]*( q[1] * q[1]*kg[1] + q[1]*( 2*kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) + + mDelta*( -4*pow(p0,2)*q[0]*( 3*q[1]*q[3] + 2*q[3]*kg[1] + 3*kg[1]*kg[3] ) + + q[0]*( q[1]*q[3] + kg[1]*(-2*q[3] + kg[3]) )*( -3*q[0] * q[0] + q[1] * q[1] + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*( q[0] * q[0]*( -3*q[1]*q[3] + 2*q[3]*kg[1] + q[1]*kg[3] - 3*kg[1]*kg[3] ) + + q[3]*( q[1] * q[1]*kg[1] + 2*q[1]*(kg[1] * kg[1] + kg[2] * kg[2]) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][2] = ( C3v*( -2*C3vNC*mn*kg[2]*( 16*mDelta2*mn*(p0 + q[0])*q[3] + - 4*mn*(p0 + q[0])*( -( q[3]*( -2*q[0]*(2*p0 + q[0]) + q[3] * q[3] + q[1]*(q[1] + kg[1]) ) ) + + ( 2*p0*q[0] + q[0] * q[0] - q[1] * q[1] - 2*q[3] * q[3])*kg[3] ) + + 4*pow(mDelta,3)*( 4*p0*q[3] + q[0]*(-2*q[3] + kg[3]) ) + + mDelta*( -4*pow(p0,2)*q[0]*(2*q[3] + 3*kg[3]) + - q[0]*(2*q[3] - kg[3])*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + 4*p0*( q[0] * q[0]*(2*q[3] - 3*kg[3]) + ( q[1] * q[1] + q[3] * q[3] )*(q[3] + 2*kg[3]) ) ) ) + - std::complex(0.,1.)*C5aNC*( 2*mn2*q[1]*kg[2] * kg[2]*( -(q[0]*(2*p0 + q[0])) + + q[1]*kg[1] + q[3]*kg[3]) + 4*pow(mDelta,3)*mn*( 8*mn2*kg[1] - 2*p0*q[0]*kg[1] - 2*q[0] * q[0]*kg[1] + + q[1] * q[1]*kg[1] + q[3] * q[3]*kg[1] + q[1]*kg[1] * kg[1] + q[1]*kg[2] * kg[2] + q[3]*kg[1]*kg[3]) + + mDelta2*( -8*pow(p0,3)*q[0]*kg[1] + q[1]*( -q[0] * q[0] + q[1] * q[1] + q[3] * q[3] )*kg[2] * kg[2] + + 8*mn2*( 4*pow(p0,2)*kg[1] + 2*p0*q[0]*(-q[1] + kg[1]) + q[1]*kg[2] * kg[2] ) + + 4*pow(p0,2)*( q[0] * q[0]*(q[1] - 3*kg[1]) + q[1] * q[1]*kg[1] + q[1]*( kg[1] * kg[1] + kg[2] * kg[2] ) + + q[3]*kg[1]*(q[3] + kg[3])) + 2*p0*q[0]*( -pow(q[1],3) + 2*q[0] * q[0]*(q[1] - kg[1]) + + q[3]*kg[1]*(q[3] + kg[3]) - q[1]*( -kg[1] * kg[1] + kg[2] * kg[2] + q[3]*(q[3] + kg[3]) ) ) ) + + mDelta*mn*( 4*pow(q[0],4)*q[1] - 2*q[0] * q[0]*pow(q[1],3) - 2*q[0] * q[0]*q[1]*q[3] * q[3] + 2*pow(q[0],4)*kg[1] + - 5*q[0] * q[0]*q[1] * q[1]*kg[1] + pow(q[1],4)*kg[1] - q[0] * q[0]*q[3] * q[3]*kg[1] + + 2*q[1] * q[1]*q[3] * q[3]*kg[1] + pow(q[3],4)*kg[1] - 5*q[0] * q[0]*q[1]*kg[1] * kg[1] + + 3*pow(q[1],3)*kg[1] * kg[1] + 3*q[1]*q[3] * q[3]*kg[1] * kg[1] + + 2*q[1] * q[1]*pow(kg[1],3) - 2*q[3] * q[3]*pow(kg[1],3) + 4*pow(p0,2)*q[0] * q[0]*(q[1] + kg[1]) + - 3*q[0] * q[0]*q[1]*kg[2] * kg[2] + pow(q[1],3)*kg[2] * kg[2] + q[1]*q[3] * q[3]*kg[2] * kg[2] + + 2*q[1] * q[1]*kg[1]*kg[2] * kg[2] - 2*q[3] * q[3]*kg[1]*kg[2] * kg[2] - 2*q[0] * q[0]*q[1]*q[3]*kg[3] + - 5*q[0] * q[0]*q[3]*kg[1]*kg[3] + 3*q[1] * q[1]*q[3]*kg[1]*kg[3] + 3*pow(q[3],3)*kg[1]*kg[3] + + 4*q[1]*q[3]*kg[1] * kg[1]*kg[3] + 2*q[1]*q[3]*kg[2] * kg[2]*kg[3] + - 8*mn2*( 2*p0*q[0]*(q[1] + kg[1]) + q[0] * q[0]*(2*q[1] + kg[1]) + - kg[1]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + 2*p0*q[0]*( -pow(q[1],3) - 3*q[1] * q[1]*kg[1] + q[0] * q[0]*(4*q[1] + 3*kg[1]) - q[3]*kg[1]*(2*q[3] + 3*kg[3]) + - q[1]*( 3*kg[1] * kg[1] + 2*kg[2] * kg[2] + q[3]*(q[3] + kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][3] = -( C3v*( std::complex(0.,1.)*C5aNC*q[1]*kg[2]*( 4*pow(mDelta,3)*mn*(q[3] + kg[3]) + + 2*mn2*(q[3] + kg[3])*( -( q[0]*(2*p0 + q[0]) ) + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*(q[3] + kg[3])*( -4*p0*q[0] - 3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + mDelta2*( -(q[1]*q[3]*kg[1]) + q[0] * q[0]*(q[3] - kg[3]) + 8*mn2*kg[3] - 2*p0*q[0]*kg[3] + q[1] * q[1]*kg[3] + + 4*pow(p0,2)*(q[3] + kg[3]) ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*(p0 + q[0])*( q[0] * q[0] - q[1]*kg[1] ) + + 4*pow(mDelta,3)*( 4*p0*(q[0] * q[0] - q[1]*kg[1]) - q[0]*( pow(q[1] - kg[1],2) + kg[2] * kg[2] ) ) + - 4*mn*(p0 + q[0])*( 4*pow(p0,2)*q[0] * q[0] + 3*pow(q[0],4) + + 2*p0*q[0]*( 4*q[0] * q[0] - pow(q[1] + kg[1],2) - kg[2] * kg[2] ) + - q[0] * q[0]*( q[3] * q[3] + (q[1] + kg[1])*(2*q[1] + kg[1]) + kg[2] * kg[2] + 2*q[3]*kg[3] ) + + q[1]*( q[1] * q[1]*kg[1] + q[1]*( 2*kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) + - mDelta*( 16*pow(p0,3)*q[0] * q[0] + 4*pow(p0,2)*q[0]*( 8*q[0] * q[0] - 3*q[1] * q[1] + - 2*q[1]*kg[1] - 3*( kg[1] * kg[1] + kg[2] * kg[2] ) ) + + q[0]*( pow(q[1] - kg[1],2) + kg[2] * kg[2] )*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + 4*p0*( 3*pow(q[0],4) - q[0] * q[0]*( 4*q[1] * q[1] + - q[1]*kg[1] + 3*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*(q[3] + 2*kg[3]) ) + + q[1]*( q[1] * q[1]*kg[1] + 2*q[1]*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + return tr; + +} + +//____________________________________________________________________________ +GTrace COHDeltaCurrent::CrsTrace( const Interaction & i ) const { + + + // these calculations expects the interaction to be in the lab frame with the incoming neutrino parallel to z + double k0 = i.InitState().ProbeE( kRfLab ) ; + TLorentzVector probe( 0., 0., k0, k0 ) ; + TLorentzVector out_neutrino = i.Kine().FSLeptonP4() ; + TLorentzVector t_photon = i.Kine().HadSystP4() ; + + TLorentzVector t_q = probe - out_neutrino ; + double Q2 = std::abs(t_q.Mag2()) ; // Must be >0 + + // this requires Q2 + double C3v = delta_ff -> C3V( Q2 ) ; + double C3vNC = delta_ff -> C3VNC( Q2 ) ; + double C5aNC = delta_ff -> C5ANC( Q2 ) ; + + double mDelta = utils::res::Mass( Resonance() ) ; + double mDelta2 = pow( mDelta, 2 ); + + TVector3 temp = 0.5*( i.Kine().HadSystP4() - t_q ).Vect(); + double p0 = sqrt(pow(constants::kNucleonMass,2) + temp.Mag2() ) ; + + // the following contractions requires a vector with time coordinate in the 0-th position + // that is not the case for TLorentzVector so we need to rearrange it + std::array q = { t_q.E(), t_q.X(), t_q.Y(), t_q.Z() } ; + std::array kg = { t_photon.E(), t_photon.X(), t_photon.Y(), t_photon.Z() } ; + + double mn = constants::kNucleonMass ; + double mn2 = pow( mn, 2 ) ; + + GTrace tr; + + tr[0][0] = -( C3v*C3vNC*( (mDelta + mn)*p0 - mn*q[0] )*( 4*mDelta2*q[1]*kg[1] - 4*pow(p0,2)*q[1]*kg[1] + pow(q[1],3)*kg[1] + + q[1]*q[3] * q[3]*kg[1] + q[1] * q[1]*kg[1] * kg[1] - q[3] * q[3]*kg[1] * kg[1] - q[3] * q[3]*kg[2] * kg[2] + + q[0] * q[0]*( q[1] * q[1] - 3*q[1]*kg[1] + q[3]*(2*q[3] - 3*kg[3]) ) + q[3]*( 4*mDelta2 - 4*pow(p0,2) + + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] )*kg[3] + 8*p0*q[0]*(q[1]*kg[1] + q[3]*kg[3]) ) + ) / (3.*mDelta2*pow(mn,3)); + + tr[0][1] = -( C3v*( std::complex(0.,1.)*C5aNC*mDelta*( (mDelta + mn)*p0 - mn*q[0] )*q[3]*kg[2]*( 8*mn2 + + 2*(p0 - q[0])*q[0] + q[1]*(q[1] + kg[1]) + q[3]*(q[3] + kg[3]) ) + + C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*q[0]*kg[1] + 4*pow(mDelta,3)*( 4*p0*q[0]*kg[1] + q[3]*(q[3]*kg[1] + - q[1]*kg[3]) ) + 4*mn*(p0 - q[0])*( pow(q[0],3)*(q[1] - 3*kg[1]) + 8*p0*q[0] * q[0]*kg[1] + + 2*p0*q[3]*(-(q[3]*kg[1]) + q[1]*kg[3]) + q[0]*( -4*pow(p0,2)*kg[1] + 2*q[3] * q[3]*kg[1] + + q[1]*kg[1]*(q[1] + kg[1]) + q[3]*(-q[1] + kg[1])*kg[3] ) ) + + mDelta*( -16*pow(p0,3)*q[0]*kg[1] + q[3]*(q[3]*kg[1] - q[1]*kg[3])*( -3*q[0] * q[0] + q[1] * q[1] + + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) + 4*pow(p0,2)*( 8*q[0] * q[0]*kg[1] + + 3*q[3]*( -(q[3]*kg[1]) + q[1]*kg[3] ) ) + + 4*p0*q[0]*( q[0] * q[0]*(q[1] - 3*kg[1]) + q[1] * q[1]*kg[1] + q[3]*kg[1]*(4*q[3] + kg[3]) + q[1]*(kg[1] * kg[1] - 3*q[3]*kg[3]) ) ) ) ) + ) / (12.*mDelta2*pow(mn,4)); + + tr[0][2] = ( std::complex(0.,1.)*C3v*C5aNC*mDelta*( (mDelta + mn)*p0 - mn*q[0] )*( q[3]*kg[1] + - q[1]*kg[3] )*( 8*mn2 + 2*(p0 - q[0])*q[0] + q[1]*(q[1] + kg[1]) + q[3]*(q[3] + kg[3]) ) + - C3v*C3vNC*mn*kg[2]*( 16*mDelta2*mn*(p0 - q[0])*q[0] + 4*pow(mDelta,3)*( 4*p0*q[0] + q[1] * q[1] + q[3] * q[3] ) + + 4*mn*(p0 - q[0])*( -4*pow(p0,2)*q[0] + 8*p0*q[0] * q[0] - 3*pow(q[0],3) - 2*p0*( q[1] * q[1] + q[3] * q[3] ) + + q[0]*q[1]*(2*q[1] + kg[1]) + q[0]*q[3]*(2*q[3] + kg[3]) ) + + mDelta*( -16*pow(p0,3)*q[0] + 4*pow(p0,2)*( 8*q[0] * q[0] - 3*( q[1] * q[1] + q[3] * q[3] ) ) + + ( q[1] * q[1] + q[3] * q[3] )*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + 4*p0*q[0]*( -3*q[0] * q[0] + q[1]*(4*q[1] + kg[1]) + q[3]*(4*q[3] + kg[3]) ) ) ) + ) / (12.*mDelta2*pow(mn,4)); + + tr[0][3] = ( std::complex(0.,1.)*C3v*C5aNC*mDelta*( (mDelta + mn)*p0 - mn*q[0] )*q[1]*kg[2]*( 8*mn2 + + 2*(p0 - q[0])*q[0] + q[1]*(q[1] + kg[1]) + q[3]*(q[3] + kg[3]) ) + - C3v*C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*q[0]*kg[3] + 4*pow(mDelta,3)*( -(q[1]*q[3]*kg[1]) + + 4*p0*q[0]*kg[3] + q[1] * q[1]*kg[3] ) +4*mn*(p0 - q[0])*( -( q[0]*q[3]*(kg[1]*(q[1] + kg[1]) + kg[2] * kg[2] ) ) + + pow(q[0],3)*(2*q[3] - 3*kg[3]) + 8*p0*q[0] * q[0]*kg[3] + q[0]*( -4*pow(p0,2) + q[3] * q[3] + + q[1]*(2*q[1] + kg[1]) )*kg[3] + 2*p0*q[1]*( q[3]*kg[1] - q[1]*kg[3]) ) + + mDelta*( -16*pow(p0,3)*q[0]*kg[3] + 4*pow(p0,2)*( 3*q[1]*q[3]*kg[1] + 8*q[0] * q[0]*kg[3] - 3*q[1] * q[1]*kg[3] ) + + q[1]*( -(q[3]*kg[1]) + q[1]*kg[3] )*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + 4*p0*q[0]*( -( q[3]*(3*q[1]*kg[1] + kg[1] * kg[1] + kg[2] * kg[2] ) ) + q[0] * q[0]*(2*q[3] - 3*kg[3]) + + ( q[3] * q[3] + q[1]*(4*q[1] + kg[1]) )*kg[3] ) ) ) + ) / (12.*mDelta2*pow(mn,4)); + + tr[1][0] = ( std::complex(0.,1.)*C3v*C5aNC*q[3]*kg[2]*( 8*pow(mDelta,3)*mn*(-p0 + q[0]) + + 2*mDelta*mn*(p0 - q[0])*( 8*mn2 - 2*p0*q[0] + q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + - 4*mn2*(p0 - q[0])*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta2*( -8*pow(p0,3) + 12*pow(p0,2)*q[0] + 8*mn2*(2*p0 + q[0]) + + q[0]*( q[1] * q[1] + q[3] * q[3] - q[1]*kg[1] - q[3]*kg[3] ) + + 2*p0*( -2*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + - 2*C3v*C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*q[0]*q[1] + + 4*pow(mDelta,3)*( 4*p0*q[0]*q[1] + q[0] * q[0]*q[1] - kg[1]*(q[1]*kg[1] + q[3]*kg[3]) ) + + mDelta*( -16*pow(p0,3)*q[0]*q[1] + 4*p0*q[0]*( pow(q[1],3) + 2*q[1] * q[1]*kg[1] + - 3*q[1]*kg[1] * kg[1] + q[3]*kg[1]*(q[3] - 3*kg[3]) + q[1]*q[3]*(q[3] + kg[3]) ) + - ( 3*q[0] * q[0] - q[1]*(q[1] + 2*kg[1]) - q[3]*(q[3] + 2*kg[3]) )*( q[0] * q[0]*q[1] + - kg[1]*(q[1]*kg[1] + q[3]*kg[3]) ) + 4*pow(p0,2)*( 5*q[0] * q[0]*q[1] + 3*kg[1]*(q[1]*kg[1] + q[3]*kg[3]) ) ) + - 4*mn*(p0 - q[0])*( 4*pow(p0,2)*q[0]*q[1] - 2*p0*( 3*q[0] * q[0]*q[1] + kg[1]*(q[1]*kg[1] + q[3]*kg[3]) ) + + q[0]*( 2*q[0] * q[0]*q[1] - pow(q[1],3) - 2*q[1] * q[1]*kg[1] + q[3]*kg[1]*(-q[3] + kg[3]) + + q[1]*( kg[1] * kg[1] - q[3]*(q[3] + kg[3]) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[1][1] = ( std::complex(0.,1.)*C3v*C5aNC*q[3]*kg[2]*( 4*pow(mDelta,3)*mn*(q[1] + kg[1]) + + 2*mn2*(q[1] + kg[1])*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*(q[1] + kg[1])*( 4*p0*q[0] - 3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + mDelta2*( q[0] * q[0]*(q[1] - kg[1]) + 8*mn2*kg[1] + 2*p0*q[0]*kg[1] + q[3] * q[3]*kg[1] + + 4*pow(p0,2)*(q[1] + kg[1]) - q[1]*q[3]*kg[3] ) ) + - 2*C3v*C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*(q[0] * q[0] - q[3]*kg[3]) + 4*pow(mDelta,3)*( q[0]*( 4*p0*q[0] + + q[0] * q[0] + q[3] * q[3] - kg[1] * kg[1] ) - 2*(2*p0 + q[0])*q[3]*kg[3] ) + - 4*mn*(p0 - q[0])*( 4*pow(p0,2)*q[0] * q[0] + 2*pow(q[0],4) + 2*p0*q[0]*( -3*q[0] * q[0] + + q[3] * q[3] - kg[1] * kg[1] + 2*q[3]*kg[3] ) - q[0] * q[0]*( q[1] * q[1] + 2*q[1]*kg[1] + - kg[1] * kg[1] + 3*q[3]*kg[3] ) + q[3]*( -( q[3]*(2*kg[1] * kg[1] + kg[2] * kg[2] ) ) + + ( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1])*kg[3] ) ) + + mDelta*( -16*pow(p0,3)*q[0] * q[0] + 4*pow(p0,2)*q[0]*( 5*q[0] * q[0] - 3*q[3] * q[3] + + 3*kg[1] * kg[1] - 2*q[3]*kg[3] ) - q[0]*( q[0] * q[0] + q[3] * q[3] - kg[1] * kg[1] + - 2*q[3]*kg[3] )*( 3*q[0] * q[0] - q[1]*(q[1] + 2*kg[1]) - q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*( q[0] * q[0]*( (q[1] - kg[1])*(q[1] + 3*kg[1]) + q[3]*(2*q[3] - kg[3]) ) + + q[3]*( 2*q[3]*kg[1] * kg[1] - ( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1])*kg[3] ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[1][2] = ( C3v*( -2*C3vNC*mn*kg[2]*( 16*mDelta2*mn*(p0 - q[0])*q[1] + 4*pow(mDelta,3)*( 4*p0*q[1] + 2*q[0]*q[1] + - q[0]*kg[1] ) + 4*mn*(p0 - q[0])*( pow(q[1],3) + q[1]*q[3] * q[3] + 2*q[1] * q[1]*kg[1] + + q[3] * q[3]*kg[1] + 2*p0*q[0]*(2*q[1] + kg[1]) - q[0] * q[0]*(2*q[1] + kg[1]) + q[1]*q[3]*kg[3] ) + + mDelta*( 4*pow(p0,2)*q[0]*(2*q[1] + 3*kg[1]) + 4*p0*( q[0] * q[0]*(2*q[1] - 3*kg[1]) + + ( q[1] * q[1] + q[3] * q[3] )*(q[1] + 2*kg[1]) ) + q[0]*(2*q[1] - kg[1])*( -3*q[0] * q[0] + + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + + std::complex(0.,1.)*C5aNC*( 2*mn2*q[3]*kg[2] * kg[2]*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + + q[3]*kg[3] ) + 4*pow(mDelta,3)*mn*( -(q[3]*kg[1] * kg[1]) + q[0] * q[0]*(q[3] - 2*kg[3]) + 2*p0*q[0]*kg[3] + + ( 8*mn2 + q[3] * q[3] + q[1]*(q[1] + kg[1]) )*kg[3] ) + + mDelta2*( 2*p0*q[3]*( q[0]*( 4*p0*q[0] - 3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] ) + q[0]*q[1]*kg[1] + + (-2*p0 + q[0])*kg[1] * kg[1] ) + q[3]*( 4*p0*q[0] - q[0] * q[0] + q[1] * q[1] + + q[3] * q[3] )*kg[2] * kg[2] + 2*p0*( 4*pow(p0,2)*q[0] + 2*pow(q[0],3) - q[0]*q[1]*(q[1] + kg[1]) + + 2*p0*( -3*q[0] * q[0] + q[3] * q[3] + q[1]*(q[1] + kg[1]) ) )*kg[3] + 8*mn2*( q[3]*kg[2] * kg[2] + + 2*p0*q[0]*(q[3] - kg[3]) + 4*pow(p0,2)*kg[3] ) ) + + mDelta*mn*( q[3]*( 4*pow(p0,2)*q[0] * q[0] - pow(q[0],4) - kg[1] * kg[1]*( 3*( q[1] * q[1] + + q[3] * q[3] ) + 4*q[1]*kg[1] ) - 2*( q[3] * q[3] + q[1]*(q[1] + kg[1]) )*kg[2] * kg[2] + + 2*p0*q[0]*( -q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + q[1]*kg[1] - 3*kg[1] * kg[1] - kg[2] * kg[2] ) + + q[0] * q[0]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 5*kg[1] * kg[1] + 2*kg[2] * kg[2] ) ) + + ( 4*pow(p0,2)*q[0] * q[0] + 2*pow(q[0],4) + pow(q[1] * q[1] + q[3] * q[3],2) + + 3*q[1]*( q[1] * q[1] + q[3] * q[3] )*kg[1] + 2*(q[1] - q[3])*(q[1] + q[3])*kg[1] * kg[1] + + 2*p0*q[0]*( -3*q[0] * q[0] + 2*q[1] * q[1] + 3*q[3] * q[3] + 3*q[1]*kg[1] ) + - q[0] * q[0]*( 3*( q[1] * q[1] + q[3] * q[3] ) + 5*q[1]*kg[1] ) )*kg[3] + + 8*mn2*( 2*p0*q[0]*(q[3] + kg[3]) - q[0] * q[0]*(2*q[3] + kg[3]) + kg[3]*( q[1] * q[1] + + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[1][3] = ( C3v*( 2*C3vNC*mn*( 16*mDelta2*mn*(-p0 + q[0])*q[1]*kg[3] + 4*pow(mDelta,3)*( q[0]*q[1]*(q[3] - 2*kg[3]) + - 4*p0*q[1]*kg[3] + q[0]*kg[1]*kg[3] ) - 4*mn*(p0 - q[0])*( -( q[1]*q[3]*(2*kg[1] * kg[1] + + kg[2] * kg[2] ) ) + q[1]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] )*kg[3] + q[0] * q[0]*( q[3]*(q[1] + + kg[1]) - (2*q[1] + kg[1])*kg[3] ) + 2*p0*q[0]*( kg[1]*kg[3] + q[1]*(q[3] + 2*kg[3]) ) ) + + mDelta*( 4*p0*q[3]*( q[0] * q[0]*(q[1] - kg[1]) + 2*q[1]*kg[1] * kg[1] ) - 4*p0*( q[0] * q[0]*(2*q[1] + - 3*kg[1]) + q[1]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] ) )*kg[3] - 4*pow(p0,2)*q[0]*( 3*q[1]*q[3] + + 2*q[1]*kg[3] + 3*kg[1]*kg[3] ) + q[0]*( q[1]*(q[3] - 2*kg[3]) + + kg[1]*kg[3] )*( -3*q[0] * q[0] + q[1] * q[1] + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) ) ) + - std::complex(0.,1.)*C5aNC*kg[2]*( 4*pow(mDelta,3)*mn*( 8*mn2 + 2*(p0 - q[0])*q[0] + q[1]*(q[1] + kg[1]) ) + - 2*mn2*q[3]*(q[3] + kg[3])*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*( 4*pow(p0,2)*q[0] * q[0] - 6*p0*pow(q[0],3) + 2*pow(q[0],4) + 4*p0*q[0]*q[1] * q[1] + - 3*q[0] * q[0]*q[1] * q[1] + pow(q[1],4) + q[1] * q[1]*q[3] * q[3] + 6*p0*q[0]*q[1]*kg[1] + - 5*q[0] * q[0]*q[1]*kg[1] + 3*pow(q[1],3)*kg[1] + q[1]*q[3] * q[3]*kg[1] + 2*q[1] * q[1]*kg[1] * kg[1] + + 2*q[3]*( (p0 - q[0])*q[0] + q[1]*(q[1] + kg[1]) )*kg[3] + 8*mn2*( 2*p0*q[0] - q[0] * q[0] + + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + mDelta2*( 8*pow(p0,3)*q[0] + 4*pow(p0,2)*( -3*q[0] * q[0] + q[1]*(q[1] + kg[1]) ) + + 8*mn2*( 4*pow(p0,2) - 2*p0*q[0] - q[3]*kg[3] ) + 2*p0*q[0]*( 2*q[0] * q[0] - q[1]*(q[1] + kg[1]) + - q[3]*(q[3] + 2*kg[3]) ) + q[3]*( q[0] * q[0]*(-q[3] + kg[3]) + q[1]*(q[3]*kg[1] - q[1]*kg[3]) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][0] = ( C3v*( 2*C3vNC*mn*kg[2]*( 4*pow(mDelta,3)*(q[1]*kg[1] + q[3]*kg[3]) - 4*mn*(p0 - q[0])*( q[0]*( q[1] * q[1] + + q[3] * q[3] - q[1]*kg[1] - q[3]*kg[3] ) + 2*p0*(q[1]*kg[1] + q[3]*kg[3]) ) + + mDelta*( -4*p0*q[0]*( q[1] * q[1] + q[3] * q[3] - 3*q[1]*kg[1] - 3*q[3]*kg[3] ) - 12*pow(p0,2)*(q[1]*kg[1] + + q[3]*kg[3]) + (q[1]*kg[1] + q[3]*kg[3])*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + - std::complex(0.,1.)*C5aNC*(q[3]*kg[1] - q[1]*kg[3])*( 8*pow(mDelta,3)*mn*(-p0 + q[0]) + + 2*mDelta*mn*(p0 - q[0])*( 8*mn2 - 2*p0*q[0] + q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + - 4*mn2*(p0 - q[0])*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta2*( -8*pow(p0,3) + 12*pow(p0,2)*q[0] + 8*mn2*(2*p0 + q[0]) + q[0]*( q[1] * q[1] + q[3] * q[3] + - q[1]*kg[1] - q[3]*kg[3] ) + 2*p0*( -2*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][1] = ( C3v*( 2*C3vNC*mn*kg[2]*( 4*pow(mDelta,3)*q[0]*kg[1] - 4*mn*(p0 - q[0])*( q[0] * q[0]*(q[1] + - kg[1]) + 2*p0*q[0]*kg[1] + q[3]*(q[3]*kg[1] - q[1]*kg[3]) ) + + mDelta*( -12*pow(p0,2)*q[0]*kg[1] + q[0]*kg[1]*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) - 4*p0*( q[0] * q[0]*(q[1] - 3*kg[1]) + 2*q[3]*(q[3]*kg[1] - q[1]*kg[3]) ) ) ) + - std::complex(0.,1.)*C5aNC*( -2*mn2*(q[1] + kg[1])*(-(q[3]*kg[1]) + q[1]*kg[3])*( 2*p0*q[0] + - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + 4*pow(mDelta,3)*mn*( q[3]*( q[0] * q[0] + q[1]*kg[1] + - kg[2] * kg[2] ) + ( 8*mn2 + 2*(p0 - q[0])*q[0] + q[3] * q[3] )*kg[3]) + + mDelta2*( 8*pow(p0,3)*q[0]*kg[3] + 4*pow(p0,2)*( q[3]*kg[1]*(q[1] + kg[1]) + q[0] * q[0]*(q[3] + - 3*kg[3]) + q[3]*kg[3]*(q[3] + kg[3]) ) + 2*p0*q[0]*( q[3]*( q[1] * q[1] + q[3] * q[3] + q[1]*kg[1] + + 2*kg[1] * kg[1] + kg[2] * kg[2] ) - q[1]*(q[1] + 2*kg[1])*kg[3] + q[0] * q[0]*(-3*q[3] + 2*kg[3]) ) + + (q[3]*kg[1] - q[1]*kg[3])*( q[0] * q[0]*(q[1] - kg[1]) + q[3]*(q[3]*kg[1] - q[1]*kg[3]) ) + + 8*mn2*( 2*p0*q[0]*(q[3] - kg[3]) + 4*pow(p0,2)*kg[3] + kg[1]*(q[3]*kg[1] - q[1]*kg[3]) ) ) + + mDelta*mn*( q[3]*( -pow(q[0],4) + kg[1]*( pow(q[1],3) + q[1]*q[3] * q[3] + 2*q[1] * q[1]*kg[1] + - 2*q[3] * q[3]*kg[1] ) - ( q[1] * q[1] + 3*q[3] * q[3] + 2*q[1]*kg[1] )*kg[2] * kg[2] + + q[0] * q[0]*( -q[1] * q[1] + q[3] * q[3] - 3*q[1]*kg[1] + 2*kg[1] * kg[1] + 5*kg[2] * kg[2] ) ) + + ( 2*pow(q[0],4) - q[0] * q[0]*( 3*q[3] * q[3] + 2*q[1]*kg[1] ) + q[3] * q[3]*( q[1] * q[1] + + q[3] * q[3] + 4*q[1]*kg[1] - 2*kg[2] * kg[2] ) )*kg[3] + 4*pow(p0,2)*q[0] * q[0]*(q[3] + kg[3]) + + 8*mn2*( 2*p0*q[0]*(q[3] + kg[3]) - q[0] * q[0]*(2*q[3] + kg[3]) + kg[3]*( q[1] * q[1] + q[3] * q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + 2*p0*q[0]*( q[1] * q[1]*q[3] + q[1]*kg[1]*(3*q[3] + kg[3]) + - q[0] * q[0]*(q[3] + 3*kg[3]) + q[3]*( q[3] * q[3] - kg[1] * kg[1] - 3*kg[2] * kg[2] + 3*q[3]*kg[3] ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][2] = -( C3v*( std::complex(0.,1.)*C5aNC*kg[2]*(q[3]*kg[1] - q[1]*kg[3])*( 4*pow(mDelta,3)*mn + + mDelta2*( 8*mn2 + 4*pow(p0,2) + 2*p0*q[0] - q[0] * q[0] + q[1] * q[1] + q[3] * q[3] ) + + 2*mn2*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*( 4*p0*q[0] - 3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*( q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + + 4*pow(mDelta,3)*( q[0]*( q[0] * q[0] + q[1] * q[1] + q[3] * q[3] - 2*q[1]*kg[1] - kg[2] * kg[2] + - 2*q[3]*kg[3] ) + 4*p0*( q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) ) - 4*mn*(p0 - q[0])*( 4*pow(p0,2)*q[0] * q[0] + + 2*pow(q[0],4) + pow(q[1],3)*kg[1] + q[1]*q[3] * q[3]*kg[1] + q[1] * q[1]*kg[1] * kg[1] + - q[3] * q[3]*kg[1] * kg[1] - q[1] * q[1]*kg[2] * kg[2] - 2*q[3] * q[3]*kg[2] * kg[2] + + q[3]*( q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] )*kg[3] + 2*p0*q[0]*( -3*q[0] * q[0] + q[1] * q[1] + + q[3] * q[3] + 2*q[1]*kg[1] - kg[2] * kg[2] + 2*q[3]*kg[3] ) - q[0] * q[0]*( q[1] * q[1] + + 3*q[1]*kg[1] - kg[2] * kg[2] + 3*q[3]*kg[3] ) ) + - mDelta*( 16*pow(p0,3)*q[0] * q[0] + 4*pow(p0,2)*q[0]*( -5*q[0] * q[0] + 3*q[1] * q[1] + 3*q[3] * q[3] + + 2*q[1]*kg[1] - 3*kg[2] * kg[2] + 2*q[3]*kg[3] ) + q[0]*( q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + - 2*q[1]*kg[1] - kg[2] * kg[2] - 2*q[3]*kg[3] )*( 3*q[0] * q[0] - q[1]*(q[1] + 2*kg[1]) - q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*( pow(q[1],3)*kg[1] + q[1]*q[3] * q[3]*kg[1] + q[3] * q[3]*( -2*kg[2] * kg[2] + q[3]*kg[3] ) + + q[0] * q[0]*( q[1]*(-4*q[1] + kg[1]) + 3*kg[2] * kg[2] + q[3]*(-2*q[3] + kg[3]) ) + + q[1] * q[1]*( 2*kg[1] * kg[1] + kg[3]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[2][3] = ( C3v*( 2*C3vNC*mn*kg[2]*( 4*pow(mDelta,3)*q[0]*kg[3] - 4*mn*(p0 - q[0])*( q[0] * q[0]*(q[3] - kg[3]) + + 2*p0*q[0]*kg[3] + q[1]*(-(q[3]*kg[1]) + q[1]*kg[3]) ) + + mDelta*( -12*pow(p0,2)*q[0]*kg[3] + q[0]*kg[3]*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) - 4*p0*( q[0] * q[0]*(q[3] - 3*kg[3]) + 2*q[1]*( -(q[3]*kg[1]) + q[1]*kg[3] ) ) ) ) + + std::complex(0.,1.)*C5aNC*( -2*mn2*(q[3] + kg[3])*(q[3]*kg[1] - q[1]*kg[3])*( 2*p0*q[0] + - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + 4*pow(mDelta,3)*mn*( q[0] * q[0]*(q[1] - 2*kg[1]) + + 8*mn2*kg[1] + 2*p0*q[0]*kg[1] + q[1]*( q[1]*kg[1] - kg[2] * kg[2] + q[3]*kg[3] ) ) + + mDelta2*( 8*pow(p0,3)*q[0]*kg[1] + 4*pow(p0,2)*( q[0] * q[0]*(q[1] - 3*kg[1]) + q[1]*kg[1]*(q[1] + kg[1]) + + q[1]*kg[3]*(q[3] + kg[3]) ) + (q[3]*kg[1] - q[1]*kg[3])*( q[0] * q[0]*(-q[3] + kg[3]) + + q[1]*(q[3]*kg[1] - q[1]*kg[3]) ) + 8*mn2*( 2*p0*q[0]*(q[1] - kg[1]) + 4*pow(p0,2)*kg[1] + + kg[3]*( -(q[3]*kg[1]) + q[1]*kg[3]) ) - 2*p0*q[0]*( -pow(q[1],3) + q[0] * q[0]*(q[1] - 2*kg[1]) + + q[3]*kg[1]*(q[3] + 2*kg[3]) + q[1]*( 2*kg[1] * kg[1] + kg[2] * kg[2] - q[3]*(q[3] + kg[3]) ) ) ) + + mDelta*mn*( pow(q[0],4)*q[1] - q[0] * q[0]*pow(q[1],3) + q[0] * q[0]*q[1]*q[3] * q[3] + 2*pow(q[0],4)*kg[1] + - 3*q[0] * q[0]*q[1] * q[1]*kg[1] + pow(q[1],4)*kg[1] + q[1] * q[1]*q[3] * q[3]*kg[1] - 2*q[0] * q[0]*q[1]*kg[1] * kg[1] + + 2*pow(q[1],3)*kg[1] * kg[1] - 2*q[1]*q[3] * q[3]*kg[1] * kg[1] + 4*pow(p0,2)*q[0] * q[0]*(q[1] + kg[1]) + + 3*q[0] * q[0]*q[1]*kg[2] * kg[2] - pow(q[1],3)*kg[2] * kg[2] - 3*q[1]*q[3] * q[3]*kg[2] * kg[2] + - 2*q[1] * q[1]*kg[1]*kg[2] * kg[2] - 3*q[0] * q[0]*q[1]*q[3]*kg[3] + pow(q[1],3)*q[3]*kg[3] + q[1]*pow(q[3],3)*kg[3] + - 2*q[0] * q[0]*q[3]*kg[1]*kg[3] + 4*q[1] * q[1]*q[3]*kg[1]*kg[3] - 2*q[1]*q[3]*kg[2] * kg[2]*kg[3] + + 8*mn2*( 2*p0*q[0]*(q[1] + kg[1]) - q[0] * q[0]*(2*q[1] + kg[1]) + kg[1]*( q[1] * q[1] + q[3] * q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + 2*p0*q[0]*( pow(q[1],3) + 3*q[1] * q[1]*kg[1] + - 2*q[0] * q[0]*(q[1] + 2*kg[1]) + q[1]*( q[3] * q[3] + kg[1] * kg[1] - 2*kg[2] * kg[2] + + 3*q[3]*kg[3] ) + kg[1]*( kg[1] * kg[1] + kg[2] * kg[2] + kg[3]*(q[3] + kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][0] = -( C3v*( std::complex(0.,1.)*C5aNC*q[1]*kg[2]*( 8*pow(mDelta,3)*mn*(-p0 + q[0]) + + 2*mDelta*mn*(p0 - q[0])*( 8*mn2 - 2*p0*q[0] + q[0] * q[0] - q[1]*kg[1] - q[3]*kg[3] ) + - 4*mn2*(p0 - q[0])*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta2*( -8*pow(p0,3) + 12*pow(p0,2)*q[0] + 8*mn2*(2*p0 + q[0]) + q[0]*( q[1] * q[1] + q[3] * q[3] + - q[1]*kg[1] - q[3]*kg[3] ) + 2*p0*( -2*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*q[0]*q[3] + 4*pow(mDelta,3)*( q[3]*( 4*p0*q[0] + kg[1] * kg[1] + + kg[2] * kg[2] ) - q[1]*kg[1]*kg[3] ) + 4*mn*(p0 - q[0])*( -4*pow(p0,2)*q[0]*q[3] + 8*p0*q[0] * q[0]*q[3] + - 3*pow(q[0],3)*q[3] - 2*p0*q[3]*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[0]*q[3]*( q[1] * q[1] + + q[3] * q[3] + q[1]*kg[1] + kg[1] * kg[1] + kg[2] * kg[2] ) + 2*p0*q[1]*kg[1]*kg[3] + q[0]*(q[1] * q[1] + + 2*q[3] * q[3] - q[1]*kg[1])*kg[3] ) + + mDelta*( -16*pow(p0,3)*q[0]*q[3] + 4*pow(p0,2)*( 8*q[0] * q[0]*q[3] - 3*q[3]*(kg[1] * kg[1] + + kg[2] * kg[2]) + 3*q[1]*kg[1]*kg[3] ) + ( q[3]*( kg[1] * kg[1] + kg[2] * kg[2] ) + - q[1]*kg[1]*kg[3] )*( -3*q[0] * q[0] + q[1] * q[1] + 2*q[1]*kg[1] + q[3]*(q[3] + 2*kg[3]) ) + + 4*p0*q[0]*( -3*q[0] * q[0]*q[3] + q[1]*kg[1]*(q[3] - 3*kg[3]) + q[1] * q[1]*(q[3] + kg[3]) + + q[3]*( 3*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][1] = ( C3v*( std::complex(0.,1.)*C5aNC*kg[2]*( -2*mn2*q[1]*(q[1] + kg[1])*( 2*p0*q[0] - q[0] * q[0] + + q[1]*kg[1] + q[3]*kg[3] ) + 4*pow(mDelta,3)*mn*( 8*mn2 + 2*(p0 - q[0])*q[0] + q[3]*(q[3] + kg[3]) ) + + mDelta*mn*( 4*pow(p0,2)*q[0] * q[0] - 6*p0*pow(q[0],3) + 2*pow(q[0],4) + 4*p0*q[0]*q[3] * q[3] + - q[0] * q[0]*q[3] * q[3] + q[1] * q[1]*q[3] * q[3] + pow(q[3],4) + 2*p0*q[0]*q[1]*kg[1] - 2*q[0] * q[0]*q[1]*kg[1] + + 2*q[1]*q[3] * q[3]*kg[1] - 2*q[3] * q[3]*kg[1] * kg[1] - 2*q[3] * q[3]*kg[2] * kg[2] + + q[3]*( 6*p0*q[0] - 5*q[0] * q[0] + q[1] * q[1] + 3*q[3] * q[3] + 2*q[1]*kg[1] )*kg[3] + + 8*mn2*( 2*p0*q[0] - q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + + mDelta2*( 8*pow(p0,3)*q[0] + 8*mn2*( 4*pow(p0,2) - 2*p0*q[0] - q[1]*kg[1] ) + + 2*p0*q[0]*( 2*q[0] * q[0] - q[1]*(q[1] + 2*kg[1]) - q[3]*(q[3] + kg[3]) ) + 4*pow(p0,2)*( -3*q[0] * q[0] + + q[3]*(q[3] + kg[3]) ) + q[1]*( q[0] * q[0]*(-q[1] + kg[1]) + q[3]*( -(q[3]*kg[1]) + q[1]*kg[3] ) ) ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*(-p0 + q[0])*q[3]*kg[1] + 4*pow(mDelta,3)*( q[0]*q[1]*q[3] - 4*p0*q[3]*kg[1] + + q[0]*kg[1]*(-2*q[3] + kg[3]) ) - 4*mn*(p0 - q[0])*( 2*p0*q[0]*( q[1]*q[3] + kg[1]*(2*q[3] + kg[3]) ) + - q[0] * q[0]*( q[1]*(q[3] - kg[3]) + kg[1]*(2*q[3] + kg[3]) ) + q[3]*( q[1] * q[1]*kg[1] + + q[1]*( 2*kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) + + mDelta*( -4*pow(p0,2)*q[0]*( 3*q[1]*q[3] + 2*q[3]*kg[1] + 3*kg[1]*kg[3] ) + + q[0]*( -3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3])*( q[1]*q[3] + kg[1]*(-2*q[3] + kg[3]) ) + - 4*p0*( q[0] * q[0]*( -3*q[1]*q[3] + 2*q[3]*kg[1] + q[1]*kg[3] - 3*kg[1]*kg[3] ) + + q[3]*( q[1] * q[1]*kg[1] + 2*q[1]*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][2] = ( C3v*( -2*C3vNC*mn*kg[2]*( 16*mDelta2*mn*(p0 - q[0])*q[3] + 4*pow(mDelta,3)*( 4*p0*q[3] + 2*q[0]*q[3] - q[0]*kg[3] ) + + 4*mn*(p0 - q[0])*( q[3]*( 4*p0*q[0] - 2*q[0] * q[0] + q[3] * q[3] + q[1]*(q[1] + kg[1]) ) + + ( 2*p0*q[0] - q[0] * q[0] + q[1] * q[1] + 2*q[3] * q[3])*kg[3] ) + + mDelta*( 4*pow(p0,2)*q[0]*(2*q[3] + 3*kg[3]) + q[0]*(2*q[3] - kg[3])*( -3*q[0] * q[0] + q[1] * q[1] + + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + 4*p0*( q[0] * q[0]*(2*q[3] - 3*kg[3]) + ( q[1] * q[1] + + q[3] * q[3] )*(q[3] + 2*kg[3]) ) ) ) + - std::complex(0.,1.)*C5aNC*( 2*mn2*q[1]*kg[2] * kg[2]*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + 4*pow(mDelta,3)*mn*( 8*mn2*kg[1] + 2*p0*q[0]*kg[1] - 2*q[0] * q[0]*kg[1] + q[1] * q[1]*kg[1] + q[3] * q[3]*kg[1] + + q[1]*kg[1] * kg[1] + q[1]*kg[2] * kg[2] + q[3]*kg[1]*kg[3]) + + mDelta2*( 8*pow(p0,3)*q[0]*kg[1] + q[1]*( -q[0] * q[0] + q[1] * q[1] + q[3] * q[3] )*kg[2] * kg[2] + + 8*mn2*( 2*p0*q[0]*(q[1] - kg[1]) + 4*pow(p0,2)*kg[1] + q[1]*kg[2] * kg[2] ) + 4*pow(p0,2)*( q[0] * q[0]*(q[1] + - 3*kg[1]) + q[1] * q[1]*kg[1] + q[1]*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + kg[3]) ) + - 2*p0*q[0]*( -pow(q[1],3) + 2*q[0] * q[0]*(q[1] - kg[1]) + q[3]*kg[1]*(q[3] + kg[3]) + - q[1]*( -kg[1] * kg[1] + kg[2] * kg[2] + q[3]*(q[3] + kg[3]) ) ) ) + + mDelta*mn*( 4*pow(q[0],4)*q[1] - 2*q[0] * q[0]*pow(q[1],3) - 2*q[0] * q[0]*q[1]*q[3] * q[3] + 2*pow(q[0],4)*kg[1] + - 5*q[0] * q[0]*q[1] * q[1]*kg[1] + pow(q[1],4)*kg[1] - q[0] * q[0]*q[3] * q[3]*kg[1] + 2*q[1] * q[1]*q[3] * q[3]*kg[1] + + pow(q[3],4)*kg[1] - 5*q[0] * q[0]*q[1]*kg[1] * kg[1] + 3*pow(q[1],3)*kg[1] * kg[1] + 3*q[1]*q[3] * q[3]*kg[1] * kg[1] + + 2*q[1] * q[1]*pow(kg[1],3) - 2*q[3] * q[3]*pow(kg[1],3) + 4*pow(p0,2)*q[0] * q[0]*(q[1] + kg[1]) + - 3*q[0] * q[0]*q[1]*kg[2] * kg[2] + pow(q[1],3)*kg[2] * kg[2] + q[1]*q[3] * q[3]*kg[2] * kg[2] + + 2*q[1] * q[1]*kg[1]*kg[2] * kg[2] - 2*q[3] * q[3]*kg[1]*kg[2] * kg[2] + q[3]*( -( q[0] * q[0]*(2*q[1] + + 5*kg[1]) ) + kg[1]*( 3*( q[1] * q[1] + q[3] * q[3] ) + 4*q[1]*kg[1] ) + 2*q[1]*kg[2] * kg[2] )*kg[3] + + 8*mn2*( 2*p0*q[0]*(q[1] + kg[1]) - q[0] * q[0]*(2*q[1] + kg[1]) + kg[1]*( q[1] * q[1] + q[3] * q[3] + + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) ) + 2*p0*q[0]*( pow(q[1],3) + 3*q[1] * q[1]*kg[1] - q[0] * q[0]*(4*q[1] + + 3*kg[1]) + q[3]*kg[1]*(2*q[3] + 3*kg[3]) + q[1]*( 3*kg[1] * kg[1] + 2*kg[2] * kg[2] + q[3]*(q[3] + kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + tr[3][3] = -( C3v*( std::complex(0.,1.)*C5aNC*q[1]*kg[2]*( 4*pow(mDelta,3)*mn*(q[3] + kg[3]) + + 2*mn2*(q[3] + kg[3])*( 2*p0*q[0] - q[0] * q[0] + q[1]*kg[1] + q[3]*kg[3] ) + + mDelta*mn*(q[3] + kg[3])*( 4*p0*q[0] - 3*q[0] * q[0] + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) + + mDelta2*( -(q[1]*q[3]*kg[1]) + q[0] * q[0]*(q[3] - kg[3]) + 8*mn2*kg[3] + 2*p0*q[0]*kg[3] + q[1] * q[1]*kg[3] + + 4*pow(p0,2)*(q[3] + kg[3]) ) ) + + 2*C3vNC*mn*( 16*mDelta2*mn*(p0 - q[0])*(q[0] * q[0] - q[1]*kg[1]) + 4*pow(mDelta,3)*( 4*p0*(q[0] * q[0] + - q[1]*kg[1]) + q[0]*(pow(q[1] - kg[1],2) + kg[2] * kg[2]) ) - 4*mn*(p0 - q[0])*( 4*pow(p0,2)*q[0] * q[0] + + 3*pow(q[0],4) + 2*p0*q[0]*( -4*q[0] * q[0] + pow(q[1] + kg[1],2) + kg[2] * kg[2]) + - q[0] * q[0]*( q[3] * q[3] + (q[1] + kg[1])*(2*q[1] + kg[1]) + kg[2] * kg[2] + 2*q[3]*kg[3] ) + + q[1]*( q[1] * q[1]*kg[1] + q[1]*( 2*kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) + + mDelta*( -16*pow(p0,3)*q[0] * q[0] + 4*pow(p0,2)*q[0]*( 8*q[0] * q[0] - 3*q[1] * q[1] - 2*q[1]*kg[1] + - 3*(kg[1] * kg[1] + kg[2] * kg[2])) + q[0]*( pow(q[1] - kg[1],2) + kg[2] * kg[2] )*( -3*q[0] * q[0] + + q[1] * q[1] + q[3] * q[3] + 2*q[1]*kg[1] + 2*q[3]*kg[3] ) - 4*p0*( 3*pow(q[0],4) + - q[0] * q[0]*( 4*q[1] * q[1] - q[1]*kg[1] + 3*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*(q[3] + 2*kg[3]) ) + + q[1]*( q[1] * q[1]*kg[1] + 2*q[1]*( kg[1] * kg[1] + kg[2] * kg[2] ) + q[3]*kg[1]*(q[3] + 2*kg[3]) ) ) ) ) ) + ) / (24.*mDelta2*pow(mn,4)); + + return tr; + +} diff --git a/src/Physics/Coherent/XSection/COHDeltaCurrent.h b/src/Physics/Coherent/XSection/COHDeltaCurrent.h new file mode 100644 index 000000000..8c146be3a --- /dev/null +++ b/src/Physics/Coherent/XSection/COHDeltaCurrent.h @@ -0,0 +1,65 @@ +//____________________________________________________________________________ +/*! + +\class genie::COHDeltaCurrent + +\brief Class for COH Hadronic Current specification for Delta Resonance + +\author Marco Roda + University of Liverpool + +\created November 2019 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COH_DELTA_CURRENT_H_ +#define _COH_DELTA_CURRENT_H_ + +#include "Physics/Coherent/XSection/COHHadronicCurrentI.h" +#include "Physics/Coherent/XSection/DeltaTransitionFormFactor.h" +#include "Physics/Coherent/XSection/DeltaInMediumCorrections.h" + +namespace genie { + +class COHDeltaCurrent : public COHHadronicCurrentI { + +public: + + COHDeltaCurrent() ; + COHDeltaCurrent( string config ); + + virtual ~COHDeltaCurrent(); + + virtual utils::math::GTrace R( const Interaction & i, + double proton_ff, double neutron_ff ) const override ; + + virtual Resonance_t Resonance() const override { return kP33_1232 ; } + + // methods to implemented from Algorithm + void Configure (const Registry & config) override ; + void Configure (string param_set) override ; + + protected: + + void LoadConfig(void); + + + utils::math::GTrace DirTrace( const Interaction & i ) const ; + // The form factor might not be necessary in this case + + utils::math::GTrace CrsTrace( const Interaction & i ) const ; + + private: + + const DeltaTransitionFormFactor * delta_ff ; + const DeltaInMediumCorrections * Delta_med ; + +}; + +} // genie namespace +#endif // #ifndef _COH_DELTA_CURRENT_H_ + diff --git a/src/Physics/Coherent/XSection/COHFormFactorI.cxx b/src/Physics/Coherent/XSection/COHFormFactorI.cxx new file mode 100644 index 000000000..477d23dd0 --- /dev/null +++ b/src/Physics/Coherent/XSection/COHFormFactorI.cxx @@ -0,0 +1,53 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + + +#include + +#include "Physics/Coherent/XSection/COHFormFactorI.h" +#include "Framework/Messenger/Messenger.h" + +using namespace genie; + +COHFormFactorI::COHFormFactorI( string name ) : + Algorithm( name ) { + +} + +//____________________________________________________________________________ + +COHFormFactorI::COHFormFactorI( string name, string config ) : + Algorithm( name, config ) { + +} + +//____________________________________________________________________________ +genie::Range1D_t COHFormFactorI::QRange( int /* pdg */ ) const { + + return genie::Range1D_t( 0., std::numeric_limits::infinity() ) ; +} +//____________________________________________________________________________ +void COHFormFactorI::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void COHFormFactorI::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} diff --git a/src/Physics/Coherent/XSection/COHFormFactorI.h b/src/Physics/Coherent/XSection/COHFormFactorI.h new file mode 100644 index 000000000..dc62ee3fd --- /dev/null +++ b/src/Physics/Coherent/XSection/COHFormFactorI.h @@ -0,0 +1,58 @@ +//____________________________________________________________________________ +/*! + +\class genie::COHFormFactorI + +\brief Interface for COH Production model form factor + +\author Marco Roda + University of Liverpool + +\created November 2019 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COH_FORM_FACTOR_I_H_ +#define _COH_FORM_FACTOR_I_H_ + +#include "Framework/Algorithm/Algorithm.h" +#include "Framework/Utils/Range1.h" + +namespace genie { + +class COHFormFactorI : public Algorithm { + +public: + + virtual ~COHFormFactorI() { ; } + + virtual double ProtonFF ( double Q, int pdg ) const = 0 ; + virtual double NeutronFF( double Q, int pdg ) const = 0 ; + + virtual bool HasNucleus( int pdg ) const = 0 ; + + virtual genie::Range1D_t QRange( int pdg ) const ; + + void Configure (const Registry & config) override ; + void Configure (string param_set) override; + + protected: + + COHFormFactorI( string name ); + COHFormFactorI( string name, string config ); + + virtual void LoadConfig() = 0 ; + +private: + + COHFormFactorI() {;} + +}; + +} // genie namespace +#endif // #ifndef _COH_FORM_FACTOR_I_H_ + diff --git a/src/Physics/Coherent/XSection/COHGammaIntegrationLimits.cxx b/src/Physics/Coherent/XSection/COHGammaIntegrationLimits.cxx new file mode 100644 index 000000000..041f91607 --- /dev/null +++ b/src/Physics/Coherent/XSection/COHGammaIntegrationLimits.cxx @@ -0,0 +1,149 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include +#include +#include + + +#include "Physics/Coherent/XSection/COHGammaIntegrationLimits.h" +#include "Framework/Messenger/Messenger.h" + +#include "Framework/Conventions/Controls.h" +#include "Framework/Conventions/Constants.h" + + +using namespace genie; + + +//____________________________________________________________________________ +COHGammaIntegrationLimits::COHGammaIntegrationLimits() : + Algorithm("genie::COHGammaIntegrationLimits"), + fFF( nullptr ), + fDeltaW( std::numeric_limits::infinity() ) +{ ; } +//____________________________________________________________________________ +COHGammaIntegrationLimits::COHGammaIntegrationLimits(string config) : + Algorithm("genie::COHGammaIntegrationLimits", config), + fFF( nullptr ), + fDeltaW( std::numeric_limits::infinity() ) + { ; } +//____________________________________________________________________________ +COHGammaIntegrationLimits::~COHGammaIntegrationLimits() +{ + +} +//____________________________________________________________________________ +Range1D_t COHGammaIntegrationLimits::EGamma( const Interaction & in ) const { + + + double max_t = t( in ).max ; + double target_mass = in.InitState().Tgt().Mass() ; + + double mt2 = target_mass * target_mass ; + double twice_mt2 = 2 * mt2 ; + double max_recoil_gamma = ( twice_mt2 + max_t*max_t ) / twice_mt2 ; + + double max_beta = sqrt( 1. - 1./(max_recoil_gamma*max_recoil_gamma) ); + + double max_W = target_mass + fDeltaW ; + double max_gamma_energy = ( max_W*max_W - mt2 ) / (2*target_mass*(1.-max_beta) ); + + return Range1D_t( controls::kASmallNum, + std::min( in.InitState().ProbeE( kRfLab ) - controls::kASmallNum, + max_gamma_energy ) + ) ; +} +//____________________________________________________________________________ +Range1D_t COHGammaIntegrationLimits::ThetaGamma( const Interaction & ) const { + + return Range1D_t( controls::kASmallNum, fMaxThetag ) ; +} +//____________________________________________________________________________ +Range1D_t COHGammaIntegrationLimits::PhiGamma( const Interaction & ) const { + + return Range1D_t( 0., + 2*constants::kPi - controls::kASmallNum ) ; +} +//____________________________________________________________________________ +Range1D_t COHGammaIntegrationLimits::ThetaLepton( const Interaction & in ) const { + + double e_nu = in.InitState().ProbeE( kRfLab ) ; + double max_t = t( in ).max ; + Range1D_t e_gamma_range = EGamma( in ) ; + double target_mass = in.InitState().Tgt().Mass() ; + + double min_e_l = e_nu - e_gamma_range.max - 0.5 * max_t / target_mass ; + + double min = controls::kASmallNum ; + double max = constants::kPi - controls::kASmallNum ; + + if ( min_e_l > 0. ) { + + double sqrt_s = sqrt( target_mass * target_mass + 2. * e_nu * target_mass ) ; + + double min_cos_theta_limit = 1. - 2. * target_mass * ( sqrt_s - target_mass - e_gamma_range.min ) / ( sqrt_s * min_e_l ) ; + + if ( min_cos_theta_limit > -1. ) { + max = acos( min_cos_theta_limit ) ; + } + + } + + return Range1D_t( min, max ) ; +} +//____________________________________________________________________________ +Range1D_t COHGammaIntegrationLimits::t( const Interaction & i ) const { + + Range1D_t Q_range = fFF -> QRange( i.InitState().Tgt().Pdg() ) ; + return Range1D_t( Q_range.min*Q_range.min , + Q_range.max*Q_range.max ) ; + +} +//____________________________________________________________________________ +void COHGammaIntegrationLimits::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void COHGammaIntegrationLimits::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void COHGammaIntegrationLimits::LoadConfig(void) +{ + + bool good_configuration = true ; + + //-- load the form factor + fFF = dynamic_cast (this->SubAlg("COH-FormFactor")); + if (! fFF ) { + good_configuration = false ; + LOG("COHGammaIntegrationLimits", pERROR ) << "Form factor not retrieved" ; + } + + GetParam( "AsymptoticMaxGammaEnergy", fDeltaW ) ; + + GetParamDef( "MaxGammaTheta", fMaxThetag, 180. - controls::kASmallNum ) ; + fMaxThetag *= constants::kPi / 180. ; + fMaxThetag = std::min( fMaxThetag, constants::kPi ) ; + + if ( ! good_configuration ) { + LOG("COHGammaIntegrationLimits", pFATAL ) << "Bad configuration: exiting" ; + exit( 78 ) ; + } + + +} +//____________________________________________________________________________ diff --git a/src/Physics/Coherent/XSection/COHGammaIntegrationLimits.h b/src/Physics/Coherent/XSection/COHGammaIntegrationLimits.h new file mode 100644 index 000000000..427acdc10 --- /dev/null +++ b/src/Physics/Coherent/XSection/COHGammaIntegrationLimits.h @@ -0,0 +1,65 @@ +//____________________________________________________________________________ +/*! + +\class genie::COHGammaIntegrationLimits + +\brief Algorithm to define ina single place the hyper-cube to be used to + integrate the complicated phase space of the COH Gamma cross sections + +\author Marco Roda + University of Liverpool + +\created October 2020 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COH_GAMMA_INTEGRATION_LIMITS_H_ +#define _COH_GAMMA_INTEGRATION_LIMITS_H_ + +#include "Framework/Utils/Range1.h" +#include "Framework/Algorithm/Algorithm.h" +#include "Framework/Interaction/Interaction.h" + +#include "Physics/Coherent/XSection/COHFormFactorI.h" + +namespace genie { + +class COHGammaIntegrationLimits : public Algorithm { + +public: + + COHGammaIntegrationLimits(); + COHGammaIntegrationLimits(string config); + + virtual ~COHGammaIntegrationLimits(); + + virtual Range1D_t EGamma( const Interaction & ) const ; + virtual Range1D_t ThetaGamma( const Interaction & ) const ; + virtual Range1D_t PhiGamma( const Interaction & ) const ; + + virtual Range1D_t ThetaLepton( const Interaction & ) const ; + virtual Range1D_t t( const Interaction & ) const ; + + //-- override the Algorithm::Configure methods to load configuration + // data to private data members + void Configure (const Registry & config); + void Configure (string param_set); + +protected: + + void LoadConfig(void); + +private: + + const COHFormFactorI * fFF ; + double fDeltaW ; + double fMaxThetag ; + +}; + +} // genie namespace +#endif // _COH_GAMMA_INTEGRATION_LIMITS_H_ diff --git a/src/Physics/Coherent/XSection/COHHadronicCurrentI.cxx b/src/Physics/Coherent/XSection/COHHadronicCurrentI.cxx new file mode 100644 index 000000000..7c771ef52 --- /dev/null +++ b/src/Physics/Coherent/XSection/COHHadronicCurrentI.cxx @@ -0,0 +1,33 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + + +#include "Physics/Coherent/XSection/COHHadronicCurrentI.h" +#include "Framework/Messenger/Messenger.h" + +using namespace genie; + +COHHadronicCurrentI::COHHadronicCurrentI( string name ) : + Algorithm( name ) { + +} + +//____________________________________________________________________________ + +COHHadronicCurrentI::COHHadronicCurrentI( string name, string config ) : + Algorithm( name, config ) { + +} diff --git a/src/Physics/Coherent/XSection/COHHadronicCurrentI.h b/src/Physics/Coherent/XSection/COHHadronicCurrentI.h new file mode 100644 index 000000000..7fa87585f --- /dev/null +++ b/src/Physics/Coherent/XSection/COHHadronicCurrentI.h @@ -0,0 +1,58 @@ +//____________________________________________________________________________ +/*! + +\class genie::COHHadronicCurrentI + +\brief Interface for COH Hadronic Current for COH NC Gamma production + +\author Marco Roda + University of Liverpool + +\created November 2019 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COH_HADRONIC_CURRENT_I_H_ +#define _COH_HADRONIC_CURRENT_I_H_ + +#include "Framework/Algorithm/Algorithm.h" +#include "Framework/ParticleData/BaryonResonance.h" +#include "Framework/ParticleData/BaryonResUtils.h" +#include "Framework/Interaction/Interaction.h" +#include "Framework/Conventions/Constants.h" +#include "Framework/Numerical/GTrace.h" + +namespace genie { + +class COHHadronicCurrentI : public Algorithm { + +public: + + virtual ~COHHadronicCurrentI() { ; } + + virtual utils::math::GTrace R( const Interaction & i, + double proton_ff, double neutron_ff ) const = 0 ; + + virtual utils::math::GTrace R( const Interaction & i, double ff ) const { return R( i, ff, ff) ; } + + virtual Resonance_t Resonance() const { return kNoResonance ; } + + protected: + + COHHadronicCurrentI( string name ); + COHHadronicCurrentI( string name, string config ); + + +private: + + COHHadronicCurrentI() {;} + +}; + +} // genie namespace +#endif // #ifndef _COH_HADRONIC_CURRENT_I_H_ + diff --git a/src/Physics/Coherent/XSection/COHProtonFormFactorInterpolation.cxx b/src/Physics/Coherent/XSection/COHProtonFormFactorInterpolation.cxx new file mode 100644 index 000000000..2a24bd1be --- /dev/null +++ b/src/Physics/Coherent/XSection/COHProtonFormFactorInterpolation.cxx @@ -0,0 +1,280 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2020, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include +#include +#include + +#include "Framework/Messenger/Messenger.h" +#include "Framework/ParticleData/PDGUtils.h" +#include "Framework/ParticleData/PDGLibrary.h" +#include "Physics/Coherent/XSection/COHProtonFormFactorInterpolation.h" + + +using namespace genie; + + +COHProtonFormFactorInterpolation::COHProtonFormFactorInterpolation() : + COHFormFactorI("genie::COHProtonFormFactorInterpolation", "Default" ), + fArchive(), + fBaseFF(nullptr), + fAllowExtrapolation(false) +{ + +} +//____________________________________________________________________________ +COHProtonFormFactorInterpolation::COHProtonFormFactorInterpolation(string config) : + COHFormFactorI("genie::COHProtonFormFactorInterpolation", config), + fArchive(), + fBaseFF(nullptr), + fAllowExtrapolation(false) +{ + +} +//____________________________________________________________________________ +COHProtonFormFactorInterpolation::~COHProtonFormFactorInterpolation() +{ + +} +//____________________________________________________________________________ +double COHProtonFormFactorInterpolation::ProtonFF( double Q, int pdg ) const { + + if ( ! HasNucleus(pdg) ) return 0. ; + + if ( fBaseFF -> HasNucleus( pdg ) ) return fBaseFF -> ProtonFF( Q, pdg ) ; + + std::vector neighbours = Neighbours( pdg ) ; + + if ( neighbours.size() == 0 ) return 0. ; + // this might happen if the nucleus is too far from any known nucleus + // configurations might prevent interpolation or extrapolation + + if ( neighbours.size() == 1 ) return fBaseFF ->ProtonFF( Q, neighbours[0] ) ; + + // here we interpolate + vector ffs( neighbours.size(), 0. ) ; + vector zs( neighbours.size(), 0 ) ; + + for ( unsigned int i = 0 ; i < neighbours.size() ; i++ ) { + ffs[i] = fBaseFF -> ProtonFF( Q, neighbours[i] ) ; + zs[i] = pdg::IonPdgCodeToZ( neighbours[i] ) ; + } + + int z = pdg::IonPdgCodeToZ( pdg ) ; + + return Interpolate( zs, ffs, z ) ; + +} +//____________________________________________________________________________ +double COHProtonFormFactorInterpolation::NeutronFF( double Q, int pdg ) const { + + double pff = ProtonFF( Q, pdg ) ; + + if ( pff == 0. ) return pff ; + + int z = pdg::IonPdgCodeToZ( pdg ) ; + + double scale = ( pdg::IonPdgCodeToA( pdg ) - z ) / (double) z ; + + return scale * pff ; + +} +//____________________________________________________________________________ +bool COHProtonFormFactorInterpolation::HasNucleus( int pdg ) const { + + if ( fBaseFF -> HasNucleus( pdg ) ) return true ; + + int z = pdg::IonPdgCodeToZ( pdg ) ; + + if ( fAllowExtrapolation ) { + if ( z >= fArchive.begin()->first ) return true ; + else return false; + } + else { + if ( z < fArchive.begin()->first ) return false ; + else if ( z > fArchive.rbegin()->first ) return false ; + else return true ; + } + + return true ; +} +//____________________________________________________________________________ +genie::Range1D_t COHProtonFormFactorInterpolation::QRange( int pdg ) const { + + if ( ! HasNucleus(pdg) ) return COHFormFactorI::QRange( pdg ) ; + + if ( fBaseFF -> HasNucleus(pdg) ) return fBaseFF -> QRange( pdg ) ; + + auto neighbours = Neighbours( pdg ) ; + + Range1D_t range = fBaseFF -> QRange( neighbours[0] ) ; + // we already tested if the nucleus is ok + // so the neighbours are not empty and it's always possible to get the first + + for ( unsigned int i = 1 ; i < neighbours.size() ; ++i ) { + auto temp_range = fBaseFF -> QRange( neighbours[i] ) ; + if ( temp_range.min < range.min ) range.min = temp_range.min ; + if ( temp_range.max > range.max ) range.max = temp_range.max ; + } + + return range ; + +} +//____________________________________________________________________________ +std::vector COHProtonFormFactorInterpolation::Neighbours( int pdg ) const { + + int z = pdg::IonPdgCodeToZ( pdg ) ; + int n = pdg::IonPdgCodeToA( pdg ) - z ; + + std::vector result ; + + // first we check if a nucleus with the same z is available + // in that case that's what we return + if ( fArchive.count( z ) > 0 ) { + // find the closest N + result.push_back( ClosestIsotope( fArchive.at(z), n ) ) ; + return result ; + } + + // here we are in the case where we need to extract 2 nuclei from the archive + + auto res = fArchive.rbegin() ; + + // then if z > max_z + // in that case we take the latest nuclei we at our disposal for extrapolation + if ( res -> first < z ) { + + result.push_back( ClosestIsotope( res->second, n ) ) ; + result.push_back( ClosestIsotope( (++res)->second, n ) ) ; + + return result ; + } + + + // otherwise we loop down + + do { + res++ ; + } while ( res -> first > z && res != fArchive.rend() ) ; + + // since we are iterating backward + // now res is point to the closes z we have that is smaller than the z we need + + auto second = res ; + second-- ; + + result.push_back( ClosestIsotope( second->second, n ) ) ; + result.push_back( ClosestIsotope( res->second, n ) ) ; + + return result ; +} +//____________________________________________________________________________ +int COHProtonFormFactorInterpolation::ClosestIsotope( const neutron_map & map , + int n ) const { + + if ( map.count( n ) > 0 ) return map.at(n) ; + + if ( n > map.rbegin()->first ) return map.rbegin()->second ; + + if ( n < map.begin()->first ) return map.begin()->second ; + + auto min_it = map.begin() ; + while ( min_it->first < n ) { + min_it ++ ; + } + + // at this point the iterator min_it points to the closet after n + // but we need also the previous one + auto max_it = min_it-- ; + + // we now check which one of the two is che closes + + if ( max_it -> first - n < n - min_it -> first ) { + // the closest is max + return max_it -> second ; + } + else { + return min_it -> second ; + } +} +//____________________________________________________________________________ +double COHProtonFormFactorInterpolation::Interpolate( const vector & zs, + const vector & ffs, + int final_z ) const { + + // linear interpolation + double ret = ffs[0] + (ffs[1] - ffs[0])*(final_z - zs[0])/(double)(zs[1] - zs[0]) ; + + return ret ; + +} + +//____________________________________________________________________________ +void COHProtonFormFactorInterpolation::LoadConfig(void) +{ + + fArchive.clear() ; + + bool good_configuration = true ; + + fBaseFF = dynamic_cast( SubAlg( "BaseCOHFormFactor" ) ) ; + + if ( ! fBaseFF ) { + good_configuration = false ; + LOG("COHProtonFormFactorInterpolation", pERROR ) << "Invalid Base Form Factor subalgo" ; + } + + // load the archive for fast retrieving during operation + for ( unsigned int z = 1 ; z < 100 ; ++z ) { + + neutron_map temp ; + + for ( unsigned int n = z/2 ; n <= 2*z ; ++n ) { + + int pdg = pdg::IonPdgCode( n+z, z ) ; + + TParticlePDG * pdg_particle = PDGLibrary::Instance() -> Find( pdg ) ; + if ( ! pdg_particle ) continue ; + + if ( fBaseFF -> HasNucleus( pdg ) ) { + + LOG("COHProtonFormFactorInterpolation", pINFO ) << "Adding nucleus " << pdg ; + + temp[n] = pdg ; + } + + } + + if ( temp.size() > 0 ) { + fArchive[z] = std::move(temp) ; + } + + } + + + if ( fArchive.size() < 2 ) { + LOG("COHProtonFormFactorInterpolation", pERROR ) << "Not enough FormFactors inside the Map" ; + good_configuration = false ; + } + + GetParamDef( "AllowExtrapolation", fAllowExtrapolation, false ) ; + + if ( ! good_configuration ) { + LOG("COHProtonFormFactorInterpolation", pFATAL ) << "Configuration not good, exiting" ; + exit ( 78 ) ; + } + +} +//____________________________________________________________________________ diff --git a/src/Physics/Coherent/XSection/COHProtonFormFactorInterpolation.h b/src/Physics/Coherent/XSection/COHProtonFormFactorInterpolation.h new file mode 100644 index 000000000..a2410e133 --- /dev/null +++ b/src/Physics/Coherent/XSection/COHProtonFormFactorInterpolation.h @@ -0,0 +1,88 @@ +//____________________________________________________________________________ +/*! + +\class genie::COHProtonFormFactorInterpolation + +\brief for COH Production Form Factor Model + The class is develope specifically for the NC COH Gamma + But in principle these Form Factors could be reused. + It extends the functionality of a generic COHFormFactorI providing + interpolation for the nuclei that are missing from the + actual implementationthe. + We only interpolate the proton component in this class + The neutron component will be the proton of the same nuclei rescaled + +\author Marco Roda + University of Liverpool + +\created November 2020 + +\cpright Copyright (c) 2003-2020, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _COH_PROTON_FORM_FACTOR_INTERPOLATION_H_ +#define _COH_PROTON_FORM_FACTOR_INTERPOLATION_H_ + +#include +#include + +#include "Physics/Coherent/XSection/COHFormFactorI.h" + +namespace genie { + +class COHProtonFormFactorInterpolation : public COHFormFactorI { + + using neutron_map = std::map ; + // first number of neutron + // second pdg + +public: + + COHProtonFormFactorInterpolation(); + COHProtonFormFactorInterpolation( string config ); + virtual ~COHProtonFormFactorInterpolation(); + + // methods to be implemented from COHFormFactorI + virtual double ProtonFF ( double Q, int pdg ) const override ; + virtual double NeutronFF( double Q, int pdg ) const override ; + + virtual bool HasNucleus( int pdg ) const override ; + + virtual genie::Range1D_t QRange( int pdg ) const override ; + // In this case, it will return the smallest interval that contains all the + // ranges from the neighbours used in the interpolation + + + + protected: + + virtual void LoadConfig(void) override ; + + std::vector Neighbours( int pdg ) const ; + + int ClosestIsotope( const neutron_map & map , int n ) const ; + // return the closest isotope with than n + + double Interpolate( const vector & zs, const vector & ffs, + int final_z ) const ; + // The interpolation interface is done with a generic vector because we think about + // more than linear interpolations + + private: + + std::map fArchive ; + // the archive is the list of available nuclei in the base Form Factors that you interpolate + // it is organised with the first key being Z, and the second begin N + // The contained object is the pdg + + const genie::COHFormFactorI * fBaseFF ; + + bool fAllowExtrapolation ; + +}; + +} // genie namespace +#endif // #ifndef _COH_PROTON_FORM_FACTOR_INTERPOLATION_H_ diff --git a/src/Physics/Coherent/XSection/COHXSecAR.cxx b/src/Physics/Coherent/XSection/COHXSecAR.cxx index d39ace849..837850b84 100644 --- a/src/Physics/Coherent/XSection/COHXSecAR.cxx +++ b/src/Physics/Coherent/XSection/COHXSecAR.cxx @@ -33,13 +33,19 @@ using namespace genie::utils; //____________________________________________________________________________ COHXSecAR::COHXSecAR() : -XSecIntegratorI("genie::COHXSecAR") + XSecIntegratorI("genie::COHXSecAR"), + fHasPion( false ), fHasPhoton( false ), + fOmegaIntegral( false ), ftIntegral( false ), + fGammaLimits( nullptr ) { } //____________________________________________________________________________ COHXSecAR::COHXSecAR(string config) : -XSecIntegratorI("genie::COHXSecAR", config) + XSecIntegratorI("genie::COHXSecAR", config), + fHasPion( false ), fHasPhoton( false ), + fOmegaIntegral( false ), ftIntegral( false ), + fGammaLimits( nullptr ) { } @@ -47,9 +53,20 @@ XSecIntegratorI("genie::COHXSecAR", config) COHXSecAR::~COHXSecAR() { +} + +//____________________________________________________________________________ + +double COHXSecAR::Integrate( const XSecAlgorithmI * model, const Interaction * in) const { + + if ( fHasPion ) return IntegratePion( model, in ) ; + else if ( fHasPhoton ) return IntegratePhoton( model, in ) ; + + return 0. ; + } //____________________________________________________________________________ -double COHXSecAR::Integrate( +double COHXSecAR::IntegratePion( const XSecAlgorithmI * model, const Interaction * in) const { const InitialState & init_state = in -> InitState(); @@ -78,9 +95,8 @@ double COHXSecAR::Integrate( double xsec = 0; if (fSplitIntegral) { - utils::gsl::dXSec_dElep_AR * func = - new utils::gsl::dXSec_dElep_AR(model, interaction, fGSLIntgType, fGSLRelTol, fGSLMaxEval); - + utils::gsl::dXSec_dElep_AR_pion func(model, interaction, fGSLIntgType, fGSLRelTol, fGSLMaxEval); + //~ ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kNONADAPTIVE; ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kADAPTIVE; @@ -88,10 +104,10 @@ double COHXSecAR::Integrate( int size = 1000; // Max number of subintervals, won't reach nearly this. int rule = 2; // See https://www.gnu.org/software/gsl/manual/gsl-ref_17.html#SEC283 // Rule 2 is 21 points min - ROOT::Math::Integrator ig(*func,ig_type,abstol,fGSLRelTol,size,rule); + ROOT::Math::Integrator ig( func,ig_type,abstol,fGSLRelTol,size,rule); + xsec = ig.Integral(Elep_min, Elep_max) * (1E-38 * units::cm2); - delete func; } else { double zero = kASmallNum; @@ -123,6 +139,98 @@ double COHXSecAR::Integrate( return xsec; } //____________________________________________________________________________ +double COHXSecAR::IntegratePhoton( const XSecAlgorithmI * model, const Interaction * in) const { + + //const InitialState & init_state = in -> InitState(); + + if(! model->ValidProcess(in) ) { return 0.; } + + const KPhaseSpace & kps = in->PhaseSpace(); + if(!kps.IsAboveThreshold()) { + LOG("COHXSecAR", pDEBUG) << "*** Below energy threshold"; + return 0; + } + + // Check this + Range1D_t e_gamma = fGammaLimits -> EGamma( *in ) ; + Range1D_t theta_gamma = fGammaLimits -> ThetaGamma( *in ) ; + Range1D_t phi_gamma = fGammaLimits -> PhiGamma( *in ) ; + + // LOG("COHXSecAR", pINFO) + // << "Lepton energy integration range = [" << Elep_min << ", " << Elep_max << "]"; + + Interaction interaction(*in); + interaction.SetBit(kISkipProcessChk); + //interaction.SetBit(kISkipKinematicChk); + + + //for the time begin the option of splitting the integral is not there for photon + + // if (fSplitIntegral) { + // utils::gsl::dXSec_dElep_AR * func = + // new utils::gsl::dXSec_dElep_AR(model, interaction, fGSLIntgType, fGSLRelTol, fGSLMaxEval); + + // //~ ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kNONADAPTIVE; + // ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kADAPTIVE; + + // double abstol = 1; // Pretty sure this parameter is unused by ROOT. + // int size = 1000; // Max number of subintervals, won't reach nearly this. + // int rule = 2; // See https://www.gnu.org/software/gsl/manual/gsl-ref_17.html#SEC283 + // // Rule 2 is 21 points min + // ROOT::Math::Integrator ig(*func,ig_type,abstol,fGSLRelTol,size,rule); + + // xsec = ig.Integral(Elep_min, Elep_max) * (1E-38 * units::cm2); + // delete func; + // } + // else { + + ROOT::Math::IBaseFunctionMultiDim * func = nullptr ; + double min_second, max_second ; + if ( fOmegaIntegral ) { + func = new utils::gsl::d5Xsec_dEgdOmegaldOmegag(model, & interaction); + Range1D_t theta_lep = fGammaLimits -> ThetaLepton( *in ) ; + min_second = cos( theta_lep.max ) ; + max_second = cos( theta_lep.min ) ; + } + else if ( ftIntegral ) { + func = new utils::gsl::d4Xsec_dEgdtdThetagdPhig(model, & interaction); + Range1D_t t = fGammaLimits -> t( *in ) ; + min_second = t.min ; + max_second = t.max ; + } + else { + func = new utils::gsl::d4Xsec_dEgdThetaldThetagdPhig(model, & interaction); + Range1D_t theta_lep = fGammaLimits -> ThetaLepton( *in ) ; + min_second = theta_lep.min ; + max_second = theta_lep.max ; + } + + + std::array kine_min = { e_gamma.min, + min_second, + fOmegaIntegral ? cos( theta_gamma.max ) : theta_gamma.min, + phi_gamma.min } ; + std::array kine_max = { e_gamma.max, + max_second, + fOmegaIntegral ? cos( theta_gamma.min ) : theta_gamma.max, + phi_gamma.max } ; + + ROOT::Math::IntegrationMultiDim::Type ig_type = + utils::gsl::IntegrationNDimTypeFromString(fGSLIntgType); + + double abstol = 1; //We mostly care about relative tolerance. + ROOT::Math::IntegratorMultiDim ig(*func, ig_type, abstol, fGSLRelTol, fGSLMaxEval); + + double xsec = ig.Integral(kine_min.data(), kine_max.data()) * (1E-38 * units::cm2) ; + + if ( fOmegaIntegral ) xsec *= 2 * constants::kPi ; + + delete func; + // } + + return xsec; +} +//____________________________________________________________________________ void COHXSecAR::Configure(const Registry & config) { Algorithm::Configure(config); @@ -147,5 +255,39 @@ void COHXSecAR::LoadConfig(void) GetParamDef( "gsl-relative-tolerance", fGSLRelTol, 0.01) ; GetParamDef( "split-integral", fSplitIntegral, true ) ; + GetParamDef( "IsCOHPion", fHasPion, false ) ; + GetParamDef( "IsCOHGamma", fHasPhoton, false ) ; + + bool error = false ; + + if ( fHasPhoton ) { + GetParam( "OmegaPhaseSpace", fOmegaIntegral ) ; + + GetParamDef( "tPhaseSpace", ftIntegral, false ) ; + + + const Algorithm * temp = SubAlg( "IntegrationLimits" ) ; + fGammaLimits = dynamic_cast( temp ) ; + if (! fGammaLimits ) { + LOG( "COHXSecAR", pERROR ) << "Gamma integration limits subalgo failed to load" ; + error = true ; + } + } + + if ( !fHasPion && !fHasPhoton ) { + LOG( "COHXSecAR", pERROR ) << "No pion nor gamma option has been requested" ; + error = true ; + } + + if ( fHasPion && fHasPhoton ) { + LOG( "COHXSecAR", pERROR ) << "Pion and Gamma options have been requested at the same time" ; + error = true ; + } + + if ( error ) { + LOG( "COHXSecAR", pFATAL ) << "Invalid configuration. Exiting" ; + exit( 78 ) ; + } + } //_____________________________________________________________________________ diff --git a/src/Physics/Coherent/XSection/COHXSecAR.h b/src/Physics/Coherent/XSection/COHXSecAR.h index 94a31f504..08462f671 100644 --- a/src/Physics/Coherent/XSection/COHXSecAR.h +++ b/src/Physics/Coherent/XSection/COHXSecAR.h @@ -20,6 +20,7 @@ #define _COH_XSEC_AR_H_ #include "Physics/XSectionIntegration/XSecIntegratorI.h" +#include "Physics/Coherent/XSection/COHGammaIntegrationLimits.h" namespace genie { @@ -37,11 +38,22 @@ class COHXSecAR : public XSecIntegratorI { void Configure(const Registry & config); void Configure(string config); -protected: + protected: bool fSplitIntegral; + double IntegratePion ( const XSecAlgorithmI * model, const Interaction * i) const; + double IntegratePhoton( const XSecAlgorithmI * model, const Interaction * i) const; + private: void LoadConfig (void); + + bool fHasPion ; + bool fHasPhoton ; + bool fOmegaIntegral ; + bool ftIntegral ; + + + const COHGammaIntegrationLimits * fGammaLimits ; }; } // genie namespace diff --git a/src/Physics/Coherent/XSection/DeVriesFormFactor.cxx b/src/Physics/Coherent/XSection/DeVriesFormFactor.cxx new file mode 100644 index 000000000..bce679648 --- /dev/null +++ b/src/Physics/Coherent/XSection/DeVriesFormFactor.cxx @@ -0,0 +1,87 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: + + For the class documentation see the corresponding header file. + + Important revisions after version 2.0.0 : + @ Feb 09, 2009 - CA + Moved into the new Coherent package from its previous location (Elastic + package) + +*/ +//____________________________________________________________________________ + +#include + +#include "Physics/Coherent/XSection/DeVriesFormFactor.h" +#include "Framework/Messenger/Messenger.h" + +#include "Framework/Conventions/Constants.h" +#include "Framework/Conventions/Units.h" + +#include "Framework/Utils/StringUtils.h" + +using namespace genie; + + +//____________________________________________________________________________ +DeVriesFormFactor::DeVriesFormFactor() : + Algorithm("genie::DeVriesFormFactor"), + fCalculator( {}, 0., 0., 0. ), + fPDG(0) { ; } +//____________________________________________________________________________ +DeVriesFormFactor::DeVriesFormFactor(string config) : + Algorithm("genie::DeVriesFormFactor", config), + fCalculator( {}, 0., 0., 0. ), + fPDG(0) { ; } +//____________________________________________________________________________ +DeVriesFormFactor::~DeVriesFormFactor() +{ + +} +//____________________________________________________________________________ +void DeVriesFormFactor::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void DeVriesFormFactor::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void DeVriesFormFactor::LoadConfig(void) +{ + + // load coefficients + vector cs; + this -> GetParamVect( "DV-Coefficient", cs ) ; + + double r; + GetParam( "DV-Radius", r ) ; + r *= units::fm ; + + double Qmax, Qmin; + GetParamDef( "DV-QMin", Qmin, 0. ) ; + GetParam( "DV-QMax", Qmax ) ; + // Qmax and Qmin are released in the DeVries paper in fm. + // and so is the input in the xml file + // So we need to convert it back to natural units + Qmin /= units::fm ; + Qmax /= units::fm ; + + fCalculator = FourierBesselFFCalculator( cs, r, Qmin, Qmax ) ; + + GetParam( "DV-Nucleus", fPDG ) ; + + LOG("DeVriesFormFactor", pINFO) << "Loaded " << cs.size() << " coefficients for nucleus " << fPDG ; + +} +//____________________________________________________________________________ diff --git a/src/Physics/Coherent/XSection/DeVriesFormFactor.h b/src/Physics/Coherent/XSection/DeVriesFormFactor.h new file mode 100644 index 000000000..92a8ec110 --- /dev/null +++ b/src/Physics/Coherent/XSection/DeVriesFormFactor.h @@ -0,0 +1,58 @@ +//____________________________________________________________________________ +/*! + +\class genie::DeVriesFormFactor + +\brief De Vries Form factor interfaces for COH Production model + The class is develope specifically for the NC COH Gamma + But in principle these Form Factors could be reused. + +\ref Atom.Data Nucl.Data Tabl. 36 (1987) 495-536 + DOI: 10.1016/0092-640X(87)90013-1 + + +\author Marco Roda + University of Liverpool + +\created October 2019 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _DEVRIES_FORM_FACTOR_H_ +#define _DEVRIES_FORM_FACTOR_H_ + +#include "Framework/Algorithm/Algorithm.h" +#include "Physics/Coherent/XSection/FourierBesselFFCalculator.h" + +namespace genie { + +class DeVriesFormFactor : public Algorithm { + +public: + DeVriesFormFactor(); + DeVriesFormFactor(string config); + virtual ~DeVriesFormFactor(); + + int NucleusPDG() const noexcept { return fPDG ; } + const FourierBesselFFCalculator & Calculator() const noexcept { return fCalculator; } + + //-- override the Algorithm::Configure methods to load configuration + // data to private data members + void Configure (const Registry & config); + void Configure (string param_set); + +private: + + void LoadConfig(void); + + FourierBesselFFCalculator fCalculator ; + int fPDG ; + +}; + +} // genie namespace +#endif // _COHERENT_ELASTIC_PXSEC_H_ diff --git a/src/Physics/Coherent/XSection/DeVriesFormFactorMap.cxx b/src/Physics/Coherent/XSection/DeVriesFormFactorMap.cxx new file mode 100644 index 000000000..1a1fca1b6 --- /dev/null +++ b/src/Physics/Coherent/XSection/DeVriesFormFactorMap.cxx @@ -0,0 +1,122 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include + +#include "Framework/Messenger/Messenger.h" + +#include "Framework/Registry/RegistryItemTypeDef.h" +#include "Physics/Coherent/XSection/DeVriesFormFactorMap.h" + +#include "Framework/ParticleData/PDGUtils.h" + +using namespace genie; + +DeVriesFormFactorMap::DeVriesFormFactorMap() + : COHFormFactorI("genie::DeVriesFormFactorMap") {} +//____________________________________________________________________________ +DeVriesFormFactorMap::DeVriesFormFactorMap(string config) + : COHFormFactorI("genie::DeVriesFormFactorMap", config) {} +//____________________________________________________________________________ +DeVriesFormFactorMap::DeVriesFormFactorMap(string name, string config) + : COHFormFactorI(name, config) {} +//____________________________________________________________________________ +DeVriesFormFactorMap::~DeVriesFormFactorMap() {} +//____________________________________________________________________________ +double DeVriesFormFactorMap::ProtonFF(double Q, int pdg) const { + + const std::map::const_iterator it = + fNuclearFFs.find(pdg); + + if (it == fNuclearFFs.end()) + return 0.; + + return it->second->Calculator().FormFactor(Q); +} +//____________________________________________________________________________ +double DeVriesFormFactorMap::NeutronFF(double Q, int pdg) const { + + // DeVries form factor are measured from EM interactions + // so they are the EM charge distribution inside the nucleus + // The neutron charge distribution is assumed to be the same + // as the proton component, with a normalization as the total weak charge is + // the number of neutron, not the number of protons. + // In Fourier transform, the normalization is easy as + // FF(Q=0) = total charge = Z for proton or (A-Z) for Neutron + + int z = pdg::IonPdgCodeToZ(pdg); + double scale = (pdg::IonPdgCodeToA(pdg) - z) / (double)z; + + return scale * ProtonFF(Q, pdg); +} +//____________________________________________________________________________ +genie::Range1D_t DeVriesFormFactorMap::QRange(int pdg) const { + + const std::map::const_iterator it = + fNuclearFFs.find(pdg); + + if (it == fNuclearFFs.end()) + return COHFormFactorI::QRange(pdg); + + return Range1D_t(it->second->Calculator().QMin(), + it->second->Calculator().QMax()); +} +//____________________________________________________________________________ +bool DeVriesFormFactorMap::HasNucleus(int pdg) const { + + return (fNuclearFFs.count(pdg) > 0); +} +//____________________________________________________________________________ +void DeVriesFormFactorMap::LoadConfig(void) { + + fNuclearFFs.clear(); + + bool good_configuration = true; + + // read the vector of algos from the xml file + std::vector keys; + GetParamVectKeys("COH-DV-FormFactor", keys); + + // Store pointers to subalgos in the local map + for (unsigned int i = 0; i < keys.size(); ++i) { + + const Algorithm *algo = SubAlg(keys[i]); + + const DeVriesFormFactor *ff = dynamic_cast(algo); + + if (!ff) { + good_configuration = false; + LOG("DeVriesFormFactorMap", pERROR) + << "SubAlgo with key " << keys[i] << " not retrieved"; + } + + if (fNuclearFFs.count(ff->NucleusPDG()) > 0) { + + good_configuration = false; + LOG("DeVriesFormFactorMap", pERROR) + << "Attempt to add a second DeVries form factor for PDG " + << ff->NucleusPDG(); + } + + fNuclearFFs[ff->NucleusPDG()] = ff; + + } // loop over subalgo + + if (!good_configuration) { + LOG("DeVriesFormFactorMap", pFATAL) << "Configuration not good, exiting"; + exit(78); + } +} +//____________________________________________________________________________ diff --git a/src/Physics/Coherent/XSection/DeVriesFormFactorMap.h b/src/Physics/Coherent/XSection/DeVriesFormFactorMap.h new file mode 100644 index 000000000..2682cb9ef --- /dev/null +++ b/src/Physics/Coherent/XSection/DeVriesFormFactorMap.h @@ -0,0 +1,64 @@ +//____________________________________________________________________________ +/*! + +\class genie::DeVriesFormFactorMap + +\brief for COH Production Form Factor Model + The class is develope specifically for the NC COH Gamma + But in principle these Form Factors could be reused. + +\author Marco Roda + University of Liverpool + +\created November 2019 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _DEVRIES_FORM_FACTOR_MAP_H_ +#define _DEVRIES_FORM_FACTOR_MAP_H_ + +#include + +#include "Physics/Coherent/XSection/COHFormFactorI.h" +#include "Physics/Coherent/XSection/DeVriesFormFactor.h" + +namespace genie { + +class DeVriesFormFactorMap : public COHFormFactorI { + +public: + + DeVriesFormFactorMap(); + DeVriesFormFactorMap( string config ); + virtual ~DeVriesFormFactorMap(); + + // methods to be implemented from COHFormFactorI + virtual double ProtonFF ( double Q, int pdg ) const override ; + + virtual double NeutronFF( double Q, int pdg ) const override ; + + virtual bool HasNucleus( int pdg ) const override ; + + virtual genie::Range1D_t QRange( int pdg ) const override ; + + protected: + + DeVriesFormFactorMap( string name, string config ); + + virtual void LoadConfig(void) override ; + + const std::map & Map() const noexcept { return fNuclearFFs; } + +private: + + std::map fNuclearFFs ; + // the map key is given by the pdg + +}; + +} // genie namespace +#endif // #ifndef _DEVRIES_FORM_FACTOR_MAP_H_ diff --git a/src/Physics/Coherent/XSection/DeltaInMediumCorrections.cxx b/src/Physics/Coherent/XSection/DeltaInMediumCorrections.cxx new file mode 100644 index 000000000..723c457a6 --- /dev/null +++ b/src/Physics/Coherent/XSection/DeltaInMediumCorrections.cxx @@ -0,0 +1,206 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include +#include +#include + +#include "Physics/Coherent/XSection/DeltaInMediumCorrections.h" +#include "Physics/NuclearState/FermiMomentumTablePool.h" + + +#include "Framework/Messenger/Messenger.h" + +#include "Framework/Conventions/Constants.h" +#include "Framework/Conventions/Units.h" +#include "Framework/ParticleData/PDGCodes.h" + +#include "Framework/Utils/StringUtils.h" + +using namespace genie; + + +//____________________________________________________________________________ +DeltaInMediumCorrections::DeltaInMediumCorrections() : + Algorithm("genie::DeltaInMediumCorrections") +{ + +} +//____________________________________________________________________________ +DeltaInMediumCorrections::DeltaInMediumCorrections(string config) : + Algorithm("genie::DeltaInMediumCorrections", config) +{ + +} +//____________________________________________________________________________ +DeltaInMediumCorrections::~DeltaInMediumCorrections() +{ + +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::FermiMomentum( int nucleus_pdg, int nucleon_pdg ) const { + + double kf = fKFTable->FindClosestKF(nucleus_pdg, nucleon_pdg); + return kf ; + +} +double DeltaInMediumCorrections::FermiMomentum( int nucleus_pdg ) const { + // Invert avg. nucleus density to obtain avg. Fermi momentum for consistency. + return pow( ( 3*constants::kPi2*AverageDensity( nucleus_pdg ) / 2 ), 1./3.) ; +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::AverageDensity( int nucleus_pdg, int nucleon_pdg ) const { + + double rho = std::pow( FermiMomentum( nucleus_pdg, nucleon_pdg ), 3 ) * 2. / ( 3 * constants::kPi2 ); + return rho ; + +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::AverageDensity( int nucleus_pdg ) const { + + if ( fKFTable ) { + // this is the average density between proton and neutron matters + std::array pdgs = { kPdgProton, kPdgNeutron} ; + double rho = 0. ; + for ( auto pdg : pdgs ) { + rho += AverageDensity( nucleus_pdg, pdg ) ; + } + + rho /= pdgs.size() ; + + return rho ; + } + else { + + double rho = 3. / (4. * constants::kPi * pow( fNuclR0, 3 ) ) ; + + return rho ; + } + + +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::Sigma( int nucleus_pdg ) const { + + double sigma = -0.5 * fDeltaV0 * AverageDensity( nucleus_pdg ) / fRho0 ; + return sigma ; +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::Gamma_vacuum( double p2 ) const { + + double Gamma = 0.0 ; + + if ( p2 > pow( constants::kNucleonMass + constants::kPionMass, 2 ) ) { + + double q2cm = Q2_cm( p2, { constants::kNucleonMass2, constants::kPionMass2 } ) ; + + Gamma = ( fDeltaNCoupling2 * constants::kNucleonMass * pow(q2cm, 3./2 ) ) + / ( 6.0 * constants::kPi * constants::kPionMass2 * sqrt(p2) ) ; + + } + + return Gamma; +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::I_series( double q ) { + + double I = 1.0; + + if (q != 0) { + if (q > 1.0) I += -2.0 / (5.0 * q * q) + 9.0 / ( 35.0 * pow(q, 4) ) - 2.0 / ( 21.0 * pow(q, 6) ) ; + else if (q < 1.0) I += 34.0 / 35.0 * q - 22.0 / 105.0 * q * q * q - 1.0 ; + } + + return I; +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::Gamma_tilde( double p2, int nucleus_pdg ) const { + + double q2cm = Q2_cm( p2, { constants::kNucleonMass2, constants::kPionMass2 } ) ; + + if ( q2cm <= 0. ) return 0. ; + // somtimes the p is smaller than ( m_N + m_pi ) so the q2cm is negative. + // In that case the gamma_vacuum will be 0 anyway, so not point in propagating a NaN in the code + + double q_tilde = sqrt( q2cm ) / FermiMomentum(nucleus_pdg) ; + + return Gamma_vacuum(p2) * I_series(q_tilde); +} +//____________________________________________________________________________ +std::complex DeltaInMediumCorrections::AverageDirectPropagator( double p2, int nucleus_pdg ) const { + + double mDelta = utils::res::Mass( kP33_1232 ) ; + double mDelta2 = pow( mDelta, 2 ) ; + + // Simplified form since Sigma.real = 0 + return 1.0 / ( p2 - mDelta2 + std::complex(0,1)*mDelta*( Gamma_tilde(p2, nucleus_pdg) - 2*Sigma(nucleus_pdg)) ) ; +} +//____________________________________________________________________________ +std::complex DeltaInMediumCorrections::AverageCrossPropagator( double p2 ) const { + + double mDelta = utils::res::Mass( kP33_1232 ) ; + double mDelta2 = pow( mDelta, 2 ) ; + + return 1.0 / ( p2 - mDelta2 + std::complex(0,1) * mDelta * Gamma_vacuum(p2) ) ; +} +//____________________________________________________________________________ +void DeltaInMediumCorrections::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void DeltaInMediumCorrections::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void DeltaInMediumCorrections::LoadConfig(void) +{ + + fKFTable = nullptr ; + + // get the Fermi momentum table for relativistic Fermi gas + string table_name ; + if ( GetParam( "FermiMomentumTable", table_name, false ) ) { + FermiMomentumTablePool * kftp = FermiMomentumTablePool::Instance(); + fKFTable = kftp->GetTable( table_name ); + assert(fKFTable); + LOG( "DeltaInMediumCorrections", pINFO ) << "Configured using Fermi Momentum table called " << table_name ; + } + + GetParam( "NCG-Delta-V0", fDeltaV0 ) ; + + GetParam( "NCG-Rho0", fRho0 ) ; + // Rho0 is in fm-3, we use it in GeV^3 in the code + fRho0 /= units::fermi3 ; + + double deltaN_coupling = 0. ; + GetParam( "Delta-N-Coupling", deltaN_coupling ) ; + fDeltaNCoupling2 = deltaN_coupling * deltaN_coupling ; + + GetParam( "NUCL-R0", fNuclR0 ); + fNuclR0 *= units::fm ; + + +} +//____________________________________________________________________________ +double DeltaInMediumCorrections::Q2_cm( double s, + const std::array & masses2 ) { + + const double & m1 = masses2[0] ; + const double & m2 = masses2[1] ; + return ( s*s + pow(m1,2) + pow(m2,2) - 2.0*s*m1 - 2.0*m1*m2 - 2.0*s*m2) / (4.0 * s ) ; + +} diff --git a/src/Physics/Coherent/XSection/DeltaInMediumCorrections.h b/src/Physics/Coherent/XSection/DeltaInMediumCorrections.h new file mode 100644 index 000000000..467badce6 --- /dev/null +++ b/src/Physics/Coherent/XSection/DeltaInMediumCorrections.h @@ -0,0 +1,112 @@ +//____________________________________________________________________________ +/*! + +\class genie::DeltaInMediumCorrections + +\brief Transition form factor from Nucleon to Delta + To be used for the evaluation of the Cross section of + COH NC Gamma production + + +\author Marco Roda + University of Liverpool + +\created January 2020 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _DELTA_IN_MEDIUM_CORRECTIONS_H_ +#define _DELTA_IN_MEDIUM_CORRECTIONS_H_ + +#include "Framework/Algorithm/Algorithm.h" +#include "Framework/ParticleData/BaryonResonance.h" +#include "Framework/ParticleData/BaryonResUtils.h" +#include "Physics/NuclearState/FermiMomentumTable.h" +#include "Physics/Coherent/XSection/ARConstants.h" +#include + +namespace genie { + +class DeltaInMediumCorrections : public Algorithm { + +public: + DeltaInMediumCorrections(); + DeltaInMediumCorrections(string config); + virtual ~DeltaInMediumCorrections(); + + virtual Resonance_t Resonance() const { return kP33_1232 ; } + + //-- override the Algorithm::Configure methods to load configuration + // data to private data members + void Configure (const Registry & config) override ; + void Configure (string param_set) override ; + + /* + + ** Comments about Fermi Momentum and Density ** + + The corrections to the delta are implemented in the NC COH gamma model as average corrections. + There are no integrals performed at run time. + + Hence, the density is not space dependent and it's an average on the nucleus. + It is also the average of the two nucleon densities, that is why there are two methods. + + The model is developed in the context of a Local Fermi Gas model, so tampering with + the density means tempering with the fermi momentum. Some degrees of consistency need to be granted. + + Because in these model the nuclear corrections are applied as averages, the FermiMomentum cannot be evaluated + as a function of the position, simply because that is not a degree of freedom. + So the consistency is achieved in this way: + 1) the fermi momenta for proton and neutrons are taken from the GENIE tables (as if it was a Relativistic Fermi Gas + 2) from the fermi Momenta, we evaluate the average densities. The nucleus density is the average of the two + 3) that average density is what is used to evaluate all the corrections, e.g. the Sigma corrections. + This approach should grant consistency within the GENIE framework and with the model itself + + */ + + double FermiMomentum( int pdg ) const ; + double FermiMomentum( int nucleus_pdg, int nucleon_pdg ) const ; + + double AverageDensity( int pdg ) const ; + double AverageDensity( int nucleus_pdg, int nucleon_pdg ) const ; + + double Sigma( int pdg ) const ; + double Gamma_tilde( double p2, int nucleus_pdg ) const ; + double Gamma_vacuum( double p2 ) const ; + static double I_series( double q ) ; + + static double Q2_cm( double s, + const std::array & masses2 = { constants::kNucleonMass2, constants::kPionMass2 } ) ; + // Given a particle that decays into 2 bodies + // this function returns the momentum module of each of the daughters in the centre of mass + // s is the mother mass square, or in general the square of the CM energy + // the array specifies the square masses of the two daughters + // Since this method is implemented directly into a Delta related class + // the masses are initialised with the typical Delta decaying into pion and nucleon + + + std::complex AverageDirectPropagator( double p2, int nucleus_pdg ) const ; + std::complex AverageCrossPropagator( double p2 ) const ; + +private: + + void LoadConfig(void); + + const FermiMomentumTable * fKFTable = nullptr ; + // this object is retrieved with a Pool that keeps ownerships of the tables + // No need to delete this object + + double fDeltaNCoupling2 ; + double fDeltaV0 ; + double fRho0 ; // this is the nuclear matter density. + // It should be in natural units but it's read from the xml in fm^-3 as that is how it's usually reported + double fNuclR0 ; + +}; + +} // genie namespace +#endif // _DELTA_TRANSITION_FORM_FACTOR_H_ diff --git a/src/Physics/Coherent/XSection/DeltaTransitionFormFactor.cxx b/src/Physics/Coherent/XSection/DeltaTransitionFormFactor.cxx new file mode 100644 index 000000000..2321af73c --- /dev/null +++ b/src/Physics/Coherent/XSection/DeltaTransitionFormFactor.cxx @@ -0,0 +1,136 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: + + For the class documentation see the corresponding header file. + + Important revisions after version 2.0.0 : + @ Feb 09, 2009 - CA + Moved into the new Coherent package from its previous location (Elastic + package) + +*/ +//____________________________________________________________________________ + +#include + +#include "Physics/Coherent/XSection/DeltaTransitionFormFactor.h" +#include "Framework/Messenger/Messenger.h" + +#include "Framework/Conventions/Constants.h" +#include "Framework/Conventions/Units.h" + +#include "Framework/Utils/StringUtils.h" + +#include "Framework/ParticleData/BaryonResUtils.h" + +using namespace genie; + + +//____________________________________________________________________________ +DeltaTransitionFormFactor::DeltaTransitionFormFactor() : +Algorithm("genie::DeltaTransitionFormFactor") +{ + +} +//____________________________________________________________________________ +DeltaTransitionFormFactor::DeltaTransitionFormFactor(string config) : +Algorithm("genie::DeltaTransitionFormFactor", config) +{ + +} +//____________________________________________________________________________ +DeltaTransitionFormFactor::~DeltaTransitionFormFactor() +{ + +} +//____________________________________________________________________________ +double DeltaTransitionFormFactor::C3V( double Q2 ) const { + + double r = sqrt( 2.0 * fKgcm0 * constants::kProtonMass * fDeltaMass / ( constants::kPi * constants::kAem * ( fMmw2+Q2) ) ); + + double egcm = ( fDeltaMass2 - Q2 - pow( constants::kProtonMass, 2 ) )/ ( 2.0 * fDeltaMass ) ; + double qcm = sqrt(egcm*egcm + Q2); + + double Fq = 1.0 / pow(1.0 + Q2/fParam_071, 2) ; + + double AM = fParam_03 * (1.0 + fParam_001*Q2)*exp(-fParam_023*Q2)*(qcm/ fKgcm0)*Fq; + double a32 = constants::kSqrt3 * ( -AM ) / 2.0 ; + + return -r * 2.0 * a32 * constants::kProtonMass * fDeltaMass / (fMpw2+Q2); + +} +//____________________________________________________________________________ +double DeltaTransitionFormFactor::C3VNC( double Q2 ) const { + + return C3V(Q2) * fANC ; + +} +//____________________________________________________________________________ +double DeltaTransitionFormFactor::C5ANC( double Q2 ) const { + + double Fd = pow( 1.0 + Q2 / fN_Delta_Ma2, -2 ) ; + return fN_Delta_CA5_0 * Fd; + +} +//____________________________________________________________________________ +void DeltaTransitionFormFactor::Configure(const Registry & config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void DeltaTransitionFormFactor::Configure(string config) +{ + Algorithm::Configure(config); + this->LoadConfig(); +} +//____________________________________________________________________________ +void DeltaTransitionFormFactor::LoadConfig(void) +{ + + fDeltaMass = utils::res::Mass( kP33_1232 ) ; + fDeltaMass2 = pow( fDeltaMass, 2 ) ; + + double n_Delta_Ma ; + GetParam( "N-Delta-Ma", n_Delta_Ma ) ; + fN_Delta_Ma2 = pow( n_Delta_Ma, 2 ) ; + + double f_pi; + GetParam( "N-Delta-f_Pi", f_pi ) ; + + // Using the Goldberger-Treiman relation we will use the pion + // decay constant to derive CA5(0) + double delta_mass = utils::res::Mass(kP33_1232); + double delta_width = utils::res::Width(kP33_1232); + + double E_N = 0.5*(delta_mass*delta_mass + constants::kNucleonMass2 - constants::kPionMass2)/delta_mass; + double p2_N = E_N*E_N - constants::kNucleonMass2 ; + double p3_N = pow( p2_N, 3./2.); + + fN_Delta_CA5_0 = 2 * f_pi * sqrt(constants::kPi*2*delta_mass*delta_width/((E_N+constants::kNucleonMass)*p3_N) ); + + double mN2 = pow( constants::kProtonMass, 2 ) ; + + fKgcm0 = ( fDeltaMass2 - mN2 ) / ( 2 * fDeltaMass ) ; + fMpw2 = pow( fDeltaMass + constants::kProtonMass, 2 ) ; + fMmw2 = pow( fDeltaMass - constants::kProtonMass, 2 ) ; + + double w_A ; + GetParam( "WeinbergAngle", w_A ) ; + + fANC = 1. - 2 * pow( sin( w_A ), 2 ) ; + + GetParam( "NCG-Param03" , fParam_03 ) ; + GetParam( "NCG-Param001" , fParam_001 ) ; + GetParam( "NCG-Param023" , fParam_023 ) ; + GetParam( "NCG-Param071" , fParam_071 ) ; + + //LOG("DeltaTransitionFormFactor", pINFO) << "Loaded " << fFBCs.size() << " coeffictients for nucleus " << fPDG ; + +} +//____________________________________________________________________________ diff --git a/src/Physics/Coherent/XSection/DeltaTransitionFormFactor.h b/src/Physics/Coherent/XSection/DeltaTransitionFormFactor.h new file mode 100644 index 000000000..c9dc87d69 --- /dev/null +++ b/src/Physics/Coherent/XSection/DeltaTransitionFormFactor.h @@ -0,0 +1,83 @@ +//____________________________________________________________________________ +/*! + +\class genie::DeltaTransitiontFormFactor + +\brief Transition form factor from Nucleon to Delta + To be used for the evaluation of the Cross section of + COH NC Gamma production + + +\author Marco Roda + University of Liverpool + +\created November 2019 + +\cpright Copyright (c) 2003-2019, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _DELTA_TRANSITION_FORM_FACTOR_H_ +#define _DELTA_TRANSITION_FORM_FACTOR_H_ + +#include "Framework/Algorithm/Algorithm.h" + +namespace genie { + +class DeltaTransitionFormFactor : public Algorithm { + +public: + DeltaTransitionFormFactor(); + DeltaTransitionFormFactor(string config); + virtual ~DeltaTransitionFormFactor(); + + double C3V( double Q2 ) const ; + double C4V( double ) const { return 0 ; } + double C5V( double ) const { return 0 ; } + + double C3A( double ) const { return 0 ; } + double C4A( double ) const { return 0 ; } + double C5A( double ) const { return 0 ; } + double C6A( double ) const { return 0 ; } + + double C3VNC( double Q2 ) const ; + double C4VNC( double ) const { return 0 ; } + double C5VNC( double ) const { return 0 ; } + + double C3ANC( double ) const { return 0 ; } + double C4ANC( double ) const { return 0 ; } + double C5ANC( double Q2 ) const ; + double C6ANC( double ) const { return 0 ; } + + //-- override the Algorithm::Configure methods to load configuration + // data to private data members + void Configure (const Registry & config); + void Configure (string param_set); + + +private: + + void LoadConfig(void); + + double fDeltaMass ; + double fDeltaMass2 ; + + double fN_Delta_Ma2 ; + double fN_Delta_CA5_0 ; + + double fKgcm0 ; + double fMpw2, fMmw2 ; + + double fANC ; + + double fParam_03 ; //GeV^(-1/2) + double fParam_001 ; // GeV^-2 + double fParam_023 ; // GeV^-2 + double fParam_071 ; // GeV^2 a sort of mass used in a dipole + +}; + +} // genie namespace +#endif // _DELTA_TRANSITION_FORM_FACTOR_H_ diff --git a/src/Physics/Coherent/XSection/FourierBesselFFCalculator.cxx b/src/Physics/Coherent/XSection/FourierBesselFFCalculator.cxx new file mode 100644 index 000000000..0ff9cf1b4 --- /dev/null +++ b/src/Physics/Coherent/XSection/FourierBesselFFCalculator.cxx @@ -0,0 +1,51 @@ +//____________________________________________________________________________ +/* + Copyright (c) 2003-2020, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE + + Author: Marco Roda + University of Liverpool + + For the class documentation see the corresponding header file. + +*/ +//____________________________________________________________________________ + +#include + +#include "Physics/Coherent/XSection/FourierBesselFFCalculator.h" +#include "Framework/Messenger/Messenger.h" + +#include "Framework/Conventions/Constants.h" +#include "Framework/Conventions/Units.h" + +using namespace genie; + +//____________________________________________________________________________ +double FourierBesselFFCalculator::FormFactor( double Q ) const { + + // Only keep Q values within valid range for parameters + if ( Q > fQmax ) return 0. ; + if ( Q < fQmin ) return 0. ; + + double qr = Q * fRadius ; + + double aux_sum = 0.0, nu ; + + for ( int i = fFBCs.size() - 1 ; i >= 0 ; --i ) { + nu = i + 1. ; + double pi_x_i = constants::kPi*nu ; + aux_sum += pow( -1.0, i )*fFBCs[i]/( ( pi_x_i + qr )*( pi_x_i - qr ) ) ; + } + + return 4.*constants::kPi*pow( fRadius/units::fm, 3)*aux_sum* FourierBesselFFCalculator::sinc(qr) ; + +} +//____________________________________________________________________________ +double FourierBesselFFCalculator::sinc( double x ) { + + if ( x == 0. ) return 1. ; + return sin( x ) / x ; + +} diff --git a/src/Physics/Coherent/XSection/FourierBesselFFCalculator.h b/src/Physics/Coherent/XSection/FourierBesselFFCalculator.h new file mode 100644 index 000000000..d898767ed --- /dev/null +++ b/src/Physics/Coherent/XSection/FourierBesselFFCalculator.h @@ -0,0 +1,71 @@ +//____________________________________________________________________________ +/*! + +\class genie::FourierBesselFFCa + +\brief This class impelments the calculation of De Vries Form factor + as a function of Q, for a given nucleus radius and a series of + coeffictients. + +\ref Atom.Data Nucl.Data Tabl. 36 (1987) 495-536 + DOI: 10.1016/0092-640X(87)90013-1 + + +\author Marco Roda + University of Liverpool + +\created July 2020 + +\cpright Copyright (c) 2003-2020, The GENIE Collaboration + For the full text of the license visit http://copyright.genie-mc.org + or see $GENIE/LICENSE +*/ +//____________________________________________________________________________ + +#ifndef _FOURIER_BESSEL_FF_CALCULATOR_ +#define _FOURIER_BESSEL_FF_CALCULATOR_ + +#include + +namespace genie { + +class FourierBesselFFCalculator { + +public: + + FourierBesselFFCalculator( const std::vector & coeffs, double radius, + double Qmin, double Qmax ) noexcept : + fFBCs(coeffs), + fRadius(radius), + fQmin(Qmin), + fQmax(Qmax) {;} + + FourierBesselFFCalculator( const FourierBesselFFCalculator & ) = default ; + + ~FourierBesselFFCalculator() = default ; + + double FormFactor( double Q ) const ; + // The Q has to be in GeV + // The returned FF is in fm^3 + + const std::vector & Coefficients() const noexcept { return fFBCs; } + double Radius() const noexcept { return fRadius; } + double QMax() const noexcept { return fQmax; } + double QMin() const noexcept { return fQmin; } + + static double sinc( double ) ; + +protected: + FourierBesselFFCalculator( ) noexcept : fFBCs(), fRadius(0.), fQmin(0.), fQmax(0.) {;} + +private: + + std::vector fFBCs ; // Fourier-Bessel Coeffictients + double fRadius ; // this is the radius of the nucleus in GeV^-1 + double fQmin ; // this is the min q for the DeVries coeffs in GeV + double fQmax ; // this is the max q for the DeVries coeffs in GeV + +}; + +} // genie namespace +#endif // _FOURIER_BESSEL_FF_CALCULATOR_ diff --git a/src/Physics/Coherent/XSection/LinkDef.h b/src/Physics/Coherent/XSection/LinkDef.h index 20174123b..e3b75d0d4 100644 --- a/src/Physics/Coherent/XSection/LinkDef.h +++ b/src/Physics/Coherent/XSection/LinkDef.h @@ -12,13 +12,27 @@ #pragma link C++ class genie::alvarezruso::ARSampledNucleus; #pragma link C++ class genie::AlvarezRusoCOHPiPXSec; +#pragma link C++ class genie::AlvarezRusoSalaCOHGammaPXSec ; + #pragma link C++ class genie::BergerSehgalCOHPiPXSec2015; #pragma link C++ class genie::BergerSehgalFMCOHPiPXSec2015; #pragma link C++ class genie::ReinSehgalCOHPiPXSec; +#pragma link C++ class genie::COHElasticPXSec; + +#pragma link C++ class genie::DeVriesFormFactor; +#pragma link C++ class genie::DeVriesFormFactorMap; +#pragma link C++ class genie::COHProtonFormFactorInterpolation; + +#pragma link C++ class genie::COHDeltaCurrent; +#pragma link C++ class genie::DeltaInMediumCorrections; +#pragma link C++ class genie::DeltaTransitionFormFactor; + #pragma link C++ class genie::COHXSec; #pragma link C++ class genie::COHXSecAR; +#pragma link C++ class genie::COHGammaIntegrationLimits; + #pragma link C++ class genie::PattonCEvNSPXSec; #pragma link C++ class genie::CEvNSXSec; diff --git a/src/Physics/XSectionIntegration/GSLXSecFunc.cxx b/src/Physics/XSectionIntegration/GSLXSecFunc.cxx index 4525a9339..19c67dc2a 100644 --- a/src/Physics/XSectionIntegration/GSLXSecFunc.cxx +++ b/src/Physics/XSectionIntegration/GSLXSecFunc.cxx @@ -17,6 +17,7 @@ #include #include +#include #include "Framework/EventGen/XSecAlgorithmI.h" #include "Framework/Conventions/Constants.h" @@ -794,10 +795,11 @@ ROOT::Math::IBaseFunctionMultiDim * // genie::utils::gsl::d4Xsec_dEldThetaldOmegapi::d4Xsec_dEldThetaldOmegapi( - const XSecAlgorithmI * m, const Interaction * i) : -ROOT::Math::IBaseFunctionMultiDim(), -fModel(m), -fInteraction(i) + const XSecAlgorithmI * m, + const Interaction * i) : + ROOT::Math::IBaseFunctionMultiDim(), + fModel(m), + fInteraction(i) { } @@ -896,6 +898,335 @@ double genie::utils::gsl::d4Xsec_dEldThetaldOmegapi::GetFactor(void) const return fFactor; } //____________________________________________________________________________ +genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::d4Xsec_dEgdThetaldThetagdPhig( + const XSecAlgorithmI * m, + const Interaction * i) : + ROOT::Math::IBaseFunctionMultiDim(), + fModel(m), + fInteraction(i), + fFactor(1.) +{ + +} +genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::~d4Xsec_dEgdThetaldThetagdPhig() +{ + +} +unsigned int genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::NDim(void) const +{ + return 4; +} +//____________________________________________________________________________ +double genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::DoEval(const double * xin) const +{ + // inputs: + // E gamma [GeV] + // theta l [rad] + // theta gamma [rad] + // phi gamma [rad] + // + // outputs: + // differential cross section [10^-38 cm^2] + // + + Kinematics * kinematics = fInteraction->KinePtr(); + double E_nu = fInteraction->InitState().ProbeE(kRfLab); + const TLorentzVector P4_nu( 0., 0., E_nu, E_nu ) ; + + //double E_g = xin[0]; // No need to define this, left here for comments + + // Complex correct formula for E_l that takes into account the target mass + double m_t = fInteraction->InitState().Tgt().Mass() ; + double cos_theta_g = cos( xin[2] ) ; + double cos_theta_l = cos( xin[1] ) ; + double E_l = ( m_t*(E_nu - xin[0]) - E_nu*xin[0]*(1. - cos_theta_g) ) + / ( m_t + E_nu*(1.-cos_theta_l) + - xin[0]*(1.-cos_theta_l*cos_theta_g - sin(xin[1])*sin(xin[2])*cos(xin[3]) ) ) ; + + if ( E_l <= 0. ) return 0. ; + + //double theta_l = xin[1]; + //double phi_l = 0.0; + + //double theta_g = xin[2]; + //double phi_g = xin[3]; + + TVector3 lepton_3vector = TVector3(0,0,0); + lepton_3vector.SetMagThetaPhi( E_l, xin[1], 0. ) ; + TLorentzVector P4_lep = TLorentzVector( lepton_3vector , E_l ); + + TVector3 photon_3vector = TVector3(0,0,0); + photon_3vector.SetMagThetaPhi( xin[0], xin[2], xin[3] ) ; + TLorentzVector P4_photon = TLorentzVector(photon_3vector, xin[0] ); + + TLorentzVector q = P4_nu-P4_lep ; + + double Q2 = -q.Mag2(); + kinematics -> SetQ2( Q2 ) ; + + TLorentzVector target( 0., 0., 0., m_t ) ; + double W = (target + q).Mag() ; + kinematics -> SetW( W ) ; + + double x = 0.5* Q2 / q.Dot( target ) ; + kinematics->Setx(x); + + double y = target.Dot( q ) / target.Dot( P4_nu ) ; + kinematics->Sety(y); + + // Range1D_t xlim = fInteraction->PhaseSpace().XLim(); + + // if ( x < xlim.min || x > xlim.max ) { + // return 0.; + // } + + double t = TMath::Abs( (q - P4_photon).Mag2() ); + kinematics -> Sett( t ) ; + + kinematics->SetFSLeptonP4(P4_lep ); + kinematics->SetHadSystP4 (P4_photon); // use Hadronic System variable to store photon momentum + + double xsec = fModel->XSec(fInteraction,kPSEgTlTgPgfE); + + return fFactor * xsec/(1E-38 * units::cm2); +} +//____________________________________________________________________________ +ROOT::Math::IBaseFunctionMultiDim * +genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::Clone() const +{ + return + new genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig(fModel,fInteraction); +} +void genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::SetFactor(double factor) +{ + fFactor = factor; +} +double genie::utils::gsl::d4Xsec_dEgdThetaldThetagdPhig::GetFactor(void) const +{ + return fFactor; +} +//____________________________________________________________________________ +genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::d4Xsec_dEgdtdThetagdPhig( + const XSecAlgorithmI * m, + const Interaction * i) : + ROOT::Math::IBaseFunctionMultiDim(), + fModel(m), + fInteraction(i), + fFactor(1.) +{ + +} +genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::~d4Xsec_dEgdtdThetagdPhig() +{ + +} +unsigned int genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::NDim(void) const +{ + return 4; +} +//____________________________________________________________________________ +double genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::DoEval(const double * xin) const +{ + // inputs: + // E gamma [GeV] = xin[0] + // t [GeV^2] = xin[1] + // theta gamma [rad] = xin[2] + // phi gamma [rad] = xin[3] + // + // outputs: + // differential cross section [10^-38 cm^2] + // + + Kinematics * kinematics = fInteraction->KinePtr(); + double E_nu = fInteraction->InitState().ProbeE(kRfLab); + const TLorentzVector P4_nu( 0., 0., E_nu, E_nu ) ; + + double m_t = fInteraction->InitState().Tgt().Mass() ; + + // Compute values so there are no repeated computations + double cos_theta_g = cos( xin[2] ) ; + double A = xin[0] * cos_theta_g - E_nu ; + double B = E_nu - xin[0] ; + double C = xin[0] * sin( xin[2] ) * cos( xin[3] ) ; + + // E_l and theta_l as a function of t + double E_l = B - (0.5*xin[1])/m_t ; + + if ( E_l <= 0. ) return 0. ; + + double alpha = atan2( C, A ) ; + + double arcosin = acos( ( (0.5*xin[1] - E_nu * xin[0]*( 1-cos_theta_g ) )/E_l - B ) / + sqrt( pow( A, 2 ) + pow( C, 2 ) ) + ) ; + + std::array solutions = { alpha + arcosin, alpha - arcosin } ; + for ( auto & s : solutions ) { + if ( s < 0. ) s+= 2 * constants::kPi ; + } + + double theta_l = std::min( solutions[0], solutions[1] ) ; + + TVector3 lepton_3vector = TVector3(0,0,0); + lepton_3vector.SetMagThetaPhi( E_l, theta_l, 0. ) ; + TLorentzVector P4_lep = TLorentzVector( lepton_3vector , E_l ); + + TVector3 photon_3vector = TVector3(0,0,0); + photon_3vector.SetMagThetaPhi( xin[0], xin[2], xin[3] ) ; + TLorentzVector P4_photon = TLorentzVector(photon_3vector, xin[0] ); + + TLorentzVector target( 0., 0., 0., m_t ) ; + + TLorentzVector q = P4_nu-P4_lep ; + + double Q2 = -q.Mag2(); + kinematics -> SetQ2( Q2 ) ; + + double W = (target + q).Mag() ; + kinematics -> SetW( W ) ; + + // Range1D_t xlim = fInteraction->PhaseSpace().XLim(); + + // if ( x < xlim.min || x > xlim.max ) { + // return 0.; + // } + + double x = 0.5* Q2 / q.Dot( target ) ; + kinematics->Setx(x); + + double y = target.Dot( q ) / target.Dot( P4_nu ) ; + kinematics->Sety(y); + + kinematics -> Sett( xin[1] ) ; + + kinematics->SetFSLeptonP4(P4_lep ); + kinematics->SetHadSystP4 (P4_photon); // use Hadronic System variable to store photon momentum + + double xsec = fModel->XSec(fInteraction,kPSEgtTgPgfE); + + return fFactor * xsec/(1E-38 * units::cm2); +} + +//____________________________________________________________________________ +ROOT::Math::IBaseFunctionMultiDim * +genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::Clone() const +{ + return + new genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig(fModel,fInteraction); +} +void genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::SetFactor(double factor) +{ + fFactor = factor; +} +double genie::utils::gsl::d4Xsec_dEgdtdThetagdPhig::GetFactor(void) const +{ + return fFactor; +} +//____________________________________________________________________________ +genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::d5Xsec_dEgdOmegaldOmegag( + const XSecAlgorithmI * m, + const Interaction * i) : + ROOT::Math::IBaseFunctionMultiDim(), + fModel(m), + fInteraction(i), + fFactor(1.) +{ + +} +genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::~d5Xsec_dEgdOmegaldOmegag() +{ + +} +unsigned int genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::NDim(void) const +{ + return 4; +} +double genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::DoEval(const double * xin) const +{ + // inputs: + // E gamma [GeV] + // cos theta l + // cos theta gamma + // phi gamma [rad] + // + // outputs: + // differential cross section [10^-38 cm^2] + // + + Kinematics * kinematics = fInteraction->KinePtr(); + double E_nu = fInteraction->InitState().ProbeE(kRfLab); + const TLorentzVector P4_nu( 0., 0., E_nu, E_nu ) ; + + double sin_theta_l = sqrt( 1. - xin[1]*xin[1] ) ; + double sin_theta_g = sqrt( 1. - xin[2]*xin[2] ) ; + + //double E_g = xin[0]; // No need to define this, left here for comments + + // Complex correct formula for E_l that takes into account the target mass + double m_t = fInteraction->InitState().Tgt().Mass() ; + //double cos_theta_g = xin[2] ; + //double cos_theta_l = xin[1] ; + double E_l = ( m_t*(E_nu - xin[0]) - E_nu*xin[0]*(1. - xin[2]) ) + / ( m_t + E_nu*(1.-xin[1]) + - xin[0]*(1.-xin[1]*xin[2] - sin_theta_l*sin_theta_g*cos(xin[3]) ) ) ; + + if ( E_l <= 0. ) return 0. ; + + //double theta_l = xin[1]; + //double phi_l = 0.0; + + //double theta_g = xin[2]; + //double phi_g = xin[3]; + + TVector3 lepton_3vector( E_l * sin_theta_l, 0., E_l * xin[1] ); + TLorentzVector P4_lep = TLorentzVector( lepton_3vector , E_l ); + + TVector3 photon_3vector(xin[0] * sin_theta_g * cos(xin[3] ), + xin[0] * sin_theta_g * sin(xin[3] ), + xin[0] * xin[2] ) ; + TLorentzVector P4_photon = TLorentzVector(photon_3vector, xin[0] ); + + TLorentzVector q = P4_nu-P4_lep ; + + double Q2 = -q.Mag2(); + kinematics -> SetQ2( Q2 ) ; + + TLorentzVector target( 0., 0., 0., m_t ) ; + double W = (target + q).Mag() ; + kinematics -> SetW( W ) ; + + double x = 0.5* Q2 / q.Dot( target ) ; + kinematics->Setx(x); + + double y = target.Dot( q ) / target.Dot( P4_nu ) ; + kinematics->Sety(y); + + double t = TMath::Abs( (q - P4_photon).Mag2() ); + kinematics -> Sett( t ) ; + + kinematics->SetFSLeptonP4(P4_lep ); + kinematics->SetHadSystP4 (P4_photon); // use Hadronic System variable to store photon momentum + + double xsec = fModel->XSec(fInteraction,kPSEgOlOgfE); + + return fFactor * xsec/(1E-38 * units::cm2); +} + +ROOT::Math::IBaseFunctionMultiDim * +genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::Clone() const +{ + return + new genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag(fModel,fInteraction); +} +void genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::SetFactor(double factor) +{ + fFactor = factor; +} +double genie::utils::gsl::d5Xsec_dEgdOmegaldOmegag::GetFactor(void) const +{ + return fFactor; +} +//____________________________________________________________________________ genie::utils::gsl::d3Xsec_dOmegaldThetapi::d3Xsec_dOmegaldThetapi( const XSecAlgorithmI * m, const Interaction * i) : ROOT::Math::IBaseFunctionMultiDim(), @@ -998,7 +1329,7 @@ void genie::utils::gsl::d3Xsec_dOmegaldThetapi::SetE_lep(double E_lepton) const fElep = E_lepton; } //____________________________________________________________________________ -genie::utils::gsl::dXSec_dElep_AR::dXSec_dElep_AR( +genie::utils::gsl::dXSec_dElep_AR_pion::dXSec_dElep_AR_pion( const XSecAlgorithmI * m, const Interaction * i, string gsl_nd_integrator_type, double gsl_relative_tolerance, unsigned int max_n_calls) : @@ -1020,23 +1351,23 @@ fGSLMaxCalls(max_n_calls) kine_max[0] = kine_max[2] = constants::kPi-controls::kASmallNum; kine_max[1] = 2 * constants::kPi-controls::kASmallNum; } -genie::utils::gsl::dXSec_dElep_AR::~dXSec_dElep_AR() +genie::utils::gsl::dXSec_dElep_AR_pion::~dXSec_dElep_AR_pion() { delete func; } -double genie::utils::gsl::dXSec_dElep_AR::DoEval(double xin) const +double genie::utils::gsl::dXSec_dElep_AR_pion::DoEval(double xin) const { double Elep = xin; func->SetE_lep(Elep); double xsec = integrator.Integral(&kine_min[0], &kine_max[0]) ; - LOG("GSLXSecFunc",pINFO) << "dXSec_dElep_AR >> "<NDim()<<"d integral done. (Elep = " <> "<NDim()<<"d integral done. (Elep = " < +#include "NCgamma_Diff_Cross_Section.h" +#include "NCgamma_Form_Factors.h" +#include "NCgamma_Parameters_GeV.h" +#include +#include +#include + +using namespace NC_gamma; + +Diff_Cross_Section::Diff_Cross_Section(const std::string &m, const std::string &n) : mode(m), + nucleus(n) { + this->c_i = NCgamma_Param::c_i; + double e2 = 4.0 * NCgamma_Param::pi * NCgamma_Param::alpha; + + // The factor 2*pi of the phi_l integral is taken off, so none integral has been performed to this point +// this->constant_factors = NCgamma_Param::Gf2 * e2 / (2.0 * 8.0 * pow(2.0*NCgamma_Param::pi,4) );// * NCgamma_Param::hccm2; + this->constant_factors = NCgamma_Param::Gf2 * e2 / (2.0 * 8.0 * pow(2.0*NCgamma_Param::pi,5) );// * NCgamma_Param::hccm2; + + this->nuclearFF = new Nucleus_FF_DeVries(nucleus); + this->vector_of_currents.push_back(new Hadronic_Current_R_Delta(nuclearFF)); + this->current_R = new Hadronic_Current_R_Sum(this->vector_of_currents); +} + + +Diff_Cross_Section::~Diff_Cross_Section() { + delete this->nuclearFF; + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + delete this->vector_of_currents[i]; + } + delete this->current_R; +} + +double Diff_Cross_Section::getDiffCrossSection(double Enu, double Enu_final, double theta_l, double theta_g, double phi_g) { + double Eg = Enu - Enu_final; + + double params_aux[]= {Enu, Eg, phi_g, theta_g}; + std::vector param (params_aux, params_aux + sizeof(params_aux) / sizeof(double) ); + + this->change_other_parameters(param); + + double cs =this->integrand(theta_l); + + if(std::isnan(cs)) return 0.0; + else return cs; +} + + + +double Diff_Cross_Section::integrand(double th) { + + double kp_aux[] = {kp0, kp0 * sin(th), 0., kp0 * cos(th)}; + this->kp.assign(kp_aux, kp_aux + sizeof(kp_aux) / sizeof(double) ); + + this->q = this->k; + std::transform(q.begin( ), q.end( ), kp.begin( ), q.begin( ),std::minus( )); + + this->current_R->setQ(this->q); + + double kg_aux[] = {this->k0g, this->k0g * sin(this->thg) * cos(this->phig), + this->k0g * sin(this->thg) * sin(this->phig), this->k0g * cos(this->thg)}; + this->kg.assign(kg_aux, kg_aux + sizeof(kg_aux) / sizeof(double) ); + + std::vector p(this->kg.size()); + for (int j = 0; j < static_cast(this->kg.size()); ++j) { + p[j] = (this->kg[j] - this->q[j])/2.0; + } + + double pv2 = p[1]*p[1] + p[2]*p[2] + p[3]*p[3]; + p[0] = sqrt(NCgamma_Param::mp2 + pv2); + + this->current_R->setP(p); + this->current_R->setKg(this->kg); + + double lh; + if(this->mode == "nu") lh = this->LH_contraction_neutrino(); + else lh = this->LH_contraction_antineutrino(); + + return lh*this->constant_factors*this->factors; +} + +void Diff_Cross_Section::change_other_parameters(std::vector k0_k0g_phig_thg) { + this->k0 = k0_k0g_phig_thg[0]; + this->k0g = k0_k0g_phig_thg[1]; + this->phig = k0_k0g_phig_thg[2]; + this->thg = k0_k0g_phig_thg[3]; + + //q0 = k0g approx + this->kp0 = k0 - this->k0g; + + double k_aux[] = {k0, 0., 0., k0}; + this->k.assign(k_aux, k_aux + sizeof(k_aux) / sizeof(double) ); + + this->factors = this->k0g * (this->k0-this->k0g) /this->k0; + +} + +double Diff_Cross_Section::LH_contraction_neutrino() { + std::complex lh = -8*k[0]*((2*k[0] - this->q[0] - this->q[3])*H(0,0,0,0) + this->q[1]*H(0,0,0,1) - this->c_i*this->q[1]*H(0,0,0,2) + + (-2*k[0] + this->q[0] + this->q[3])*H(0,0,0,3) + this->q[1]*H(0,1,0,0) + (-this->q[0] + this->q[3])*H(0,1,0,1) + + this->c_i*(this->q[0] - this->q[3])*H(0,1,0,2) - this->q[1]*H(0,1,0,3) + this->c_i*this->q[1]*H(0,2,0,0) - + this->c_i*(this->q[0] - this->q[3])*H(0,2,0,1) + (-this->q[0] + this->q[3])*H(0,2,0,2) - this->c_i*this->q[1]*H(0,2,0,3) + + (-2*k[0] + this->q[0] + this->q[3])*H(0,3,0,0) - this->q[1]*H(0,3,0,1) + this->c_i*this->q[1]*H(0,3,0,2) + + (2*k[0] - this->q[0] - this->q[3])*H(0,3,0,3) + (-2*k[0] + this->q[0] + this->q[3])*H(1,0,1,0) - this->q[1]*H(1,0,1,1) + + this->c_i*this->q[1]*H(1,0,1,2) + (2*k[0] - this->q[0] - this->q[3])*H(1,0,1,3) - this->q[1]*H(1,1,1,0) + + (this->q[0] - this->q[3])*H(1,1,1,1) - this->c_i*(this->q[0] - this->q[3])*H(1,1,1,2) + this->q[1]*H(1,1,1,3) - + this->c_i*this->q[1]*H(1,2,1,0) + this->c_i*(this->q[0] - this->q[3])*H(1,2,1,1) + (this->q[0] - this->q[3])*H(1,2,1,2) + + this->c_i*this->q[1]*H(1,2,1,3) + (2*k[0] - this->q[0] - this->q[3])*H(1,3,1,0) + this->q[1]*H(1,3,1,1) - + this->c_i*this->q[1]*H(1,3,1,2) + (-2*k[0] + this->q[0] + this->q[3])*H(1,3,1,3) + (-2*k[0] + this->q[0] + this->q[3])*H(2,0,2,0) - + this->q[1]*H(2,0,2,1) + this->c_i*this->q[1]*H(2,0,2,2) + (2*k[0] - this->q[0] - this->q[3])*H(2,0,2,3) - this->q[1]*H(2,1,2,0) + + (this->q[0] - this->q[3])*H(2,1,2,1) - this->c_i*(this->q[0] - this->q[3])*H(2,1,2,2) + this->q[1]*H(2,1,2,3) - + this->c_i*this->q[1]*H(2,2,2,0) + this->c_i*(this->q[0] - this->q[3])*H(2,2,2,1) + (this->q[0] - this->q[3])*H(2,2,2,2) + + this->c_i*this->q[1]*H(2,2,2,3) + (2*k[0] - this->q[0] - this->q[3])*H(2,3,2,0) + this->q[1]*H(2,3,2,1) - + this->c_i*this->q[1]*H(2,3,2,2) + (-2*k[0] + this->q[0] + this->q[3])*H(2,3,2,3) + (-2*k[0] + this->q[0] + this->q[3])*H(3,0,3,0) - + this->q[1]*H(3,0,3,1) + this->c_i*this->q[1]*H(3,0,3,2) + (2*k[0] - this->q[0] - this->q[3])*H(3,0,3,3) - this->q[1]*H(3,1,3,0) + + (this->q[0] - this->q[3])*H(3,1,3,1) - this->c_i*(this->q[0] - this->q[3])*H(3,1,3,2) + this->q[1]*H(3,1,3,3) - + this->c_i*this->q[1]*H(3,2,3,0) + this->c_i*(this->q[0] - this->q[3])*H(3,2,3,1) + (this->q[0] - this->q[3])*H(3,2,3,2) + + this->c_i*this->q[1]*H(3,2,3,3) + (2*k[0] - this->q[0] - this->q[3])*H(3,3,3,0) + this->q[1]*H(3,3,3,1) - + this->c_i*this->q[1]*H(3,3,3,2) + (-2*k[0] + this->q[0] + this->q[3])*H(3,3,3,3)); + + return lh.real(); +} + +double Diff_Cross_Section::LH_contraction_antineutrino() { + std::complex lh = -8*this->k[0]*((2*this->k[0] - this->q[0] - this->q[3])*H(0,0,0,0) + this->q[1]*H(0,0,0,1) + this->c_i*this->q[1]*H(0,0,0,2) + + (-2*this->k[0] + this->q[0] + this->q[3])*H(0,0,0,3) + this->q[1]*H(0,1,0,0) + (-this->q[0] + this->q[3])*H(0,1,0,1) - + this->c_i*(this->q[0] - this->q[3])*H(0,1,0,2) - this->q[1]*H(0,1,0,3) - this->c_i*this->q[1]*H(0,2,0,0) + + this->c_i*(this->q[0] - this->q[3])*H(0,2,0,1) + (-this->q[0] + this->q[3])*H(0,2,0,2) + this->c_i*this->q[1]*H(0,2,0,3) + + (-2*this->k[0] + this->q[0] + this->q[3])*H(0,3,0,0) - this->q[1]*H(0,3,0,1) - this->c_i*this->q[1]*H(0,3,0,2) + + (2*this->k[0] - this->q[0] - this->q[3])*H(0,3,0,3) + (-2*this->k[0] + this->q[0] + this->q[3])*H(1,0,1,0) - this->q[1]*H(1,0,1,1) - + this->c_i*this->q[1]*H(1,0,1,2) + (2*this->k[0] - this->q[0] - this->q[3])*H(1,0,1,3) - this->q[1]*H(1,1,1,0) + + (this->q[0] - this->q[3])*H(1,1,1,1) + this->c_i*(this->q[0] - this->q[3])*H(1,1,1,2) + this->q[1]*H(1,1,1,3) + + this->c_i*this->q[1]*H(1,2,1,0) - this->c_i*(this->q[0] - this->q[3])*H(1,2,1,1) + (this->q[0] - this->q[3])*H(1,2,1,2) - + this->c_i*this->q[1]*H(1,2,1,3) + (2*this->k[0] - this->q[0] - this->q[3])*H(1,3,1,0) + this->q[1]*H(1,3,1,1) + + this->c_i*this->q[1]*H(1,3,1,2) + (-2*this->k[0] + this->q[0] + this->q[3])*H(1,3,1,3) + (-2*this->k[0] + this->q[0] + this->q[3])*H(2,0,2,0) - + this->q[1]*H(2,0,2,1) - this->c_i*this->q[1]*H(2,0,2,2) + (2*this->k[0] - this->q[0] - this->q[3])*H(2,0,2,3) - this->q[1]*H(2,1,2,0) + + (this->q[0] - this->q[3])*H(2,1,2,1) + this->c_i*(this->q[0] - this->q[3])*H(2,1,2,2) + this->q[1]*H(2,1,2,3) + + this->c_i*this->q[1]*H(2,2,2,0) - this->c_i*(this->q[0] - this->q[3])*H(2,2,2,1) + (this->q[0] - this->q[3])*H(2,2,2,2) - + this->c_i*this->q[1]*H(2,2,2,3) + (2*this->k[0] - this->q[0] - this->q[3])*H(2,3,2,0) + this->q[1]*H(2,3,2,1) + + this->c_i*this->q[1]*H(2,3,2,2) + (-2*this->k[0] + this->q[0] + this->q[3])*H(2,3,2,3) + (-2*this->k[0] + this->q[0] + this->q[3])*H(3,0,3,0) - + this->q[1]*H(3,0,3,1) - this->c_i*this->q[1]*H(3,0,3,2) + (2*this->k[0] - this->q[0] - this->q[3])*H(3,0,3,3) - this->q[1]*H(3,1,3,0) + + (this->q[0] - this->q[3])*H(3,1,3,1) + this->c_i*(this->q[0] - this->q[3])*H(3,1,3,2) + this->q[1]*H(3,1,3,3) + + this->c_i*this->q[1]*H(3,2,3,0) - this->c_i*(this->q[0] - this->q[3])*H(3,2,3,1) + (this->q[0] - this->q[3])*H(3,2,3,2) - + this->c_i*this->q[1]*H(3,2,3,3) + (2*this->k[0] - this->q[0] - this->q[3])*H(3,3,3,0) + this->q[1]*H(3,3,3,1) + + this->c_i*this->q[1]*H(3,3,3,2) + (-2*this->k[0] + this->q[0] + this->q[3])*H(3,3,3,3)); + + return lh.real(); +} + + +std::complex Diff_Cross_Section::H(int l, int m, int n, int o) { + std::complex r1c = std::conj(this->current_R->getR(l,m)); + std::complex r1 = this->current_R->getR(n,o); + std::complex r = r1 * r1c; + return r; +} + +void Diff_Cross_Section::setMode(const std::string &mode_input) { + Diff_Cross_Section::mode = mode_input; +} + +void Diff_Cross_Section::setNucleus(const std::string &nucleus_input) { + Diff_Cross_Section::nucleus = nucleus_input; +} + + + + + + + + + + + + + + + diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Diff_Cross_Section.h b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Diff_Cross_Section.h new file mode 100644 index 000000000..d46bfb360 --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Diff_Cross_Section.h @@ -0,0 +1,62 @@ +// +// Created by edusaul on 23/04/19. +// + +#ifndef GENIE_XSECTION_NCGAMMA_DIFF_CROSS_SECTION_H +#define GENIE_XSECTION_NCGAMMA_DIFF_CROSS_SECTION_H + +#include +#include +#include "NCgamma_Hadronic_Current_R.h" + +namespace NC_gamma { + + class Diff_Cross_Section { + protected: + std::string mode; + std::string nucleus; + std::vector k; + std::vector kp; + std::vector q; + std::vector kg; + + std::complex c_i; + + double k0; + double k0g; + double thg; + double phig; + double kp0; + double constant_factors; + double factors; + + Nucleus_FF_DeVries *nuclearFF; + std::vector vector_of_currents; + Hadronic_Current_R *current_R; + + + public: + Diff_Cross_Section(const std::string &m, const std::string &n); + + virtual ~Diff_Cross_Section(); + + double getDiffCrossSection(double Enu, double Enu_final, double theta_l, double theta_g, double phi_g); + + double integrand(double); + + void change_other_parameters(std::vector); + + double LH_contraction_neutrino(); + + double LH_contraction_antineutrino(); + + std::complex H(int, int, int, int); + + void setMode(const std::string &mode_input); + + void setNucleus(const std::string &nucleus_input); + }; + +} + +#endif //GENIE_XSECTION_NCGAMMA_DIFF_CROSS_SECTION_H diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Form_Factors.cpp b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Form_Factors.cpp new file mode 100644 index 000000000..2fb2efb9d --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Form_Factors.cpp @@ -0,0 +1,212 @@ +// +// Created by edusaul on 8/04/19. +// + +#include "NCgamma_Form_Factors.h" +#include +#include "NCgamma_Parameters_GeV.h" +#include + +using namespace NC_gamma; + +const std::complex &Nuclear_FF::getFfP() const { + return FF_p; +} + +const std::complex &Nuclear_FF::getFfN() const { + return FF_n; +} + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + +Nucleus_FF_DeVries::Nucleus_FF_DeVries(const std::string &n) : nucleus(n) { + this->pi= NCgamma_Param::pi; + this->hc=NCgamma_Param::hc; + + if(this->nucleus == "12C") this->set_12C(); + else if(this->nucleus == "40Ar") this->set_40Ar(); + else { + std::cout<<"WARNING: wrong nucleus, setting 12C as default..."<set_12C(); + } + +} + + +void Nucleus_FF_DeVries::setFF(double Q) { + + double aux,nu; + int i; + + aux=0.0; + + for (i=1;i<16; i++){ + nu=double(i); + aux += pow(-1.0,nu+1.0)*R*R*R*a[i]*hc*hc*hc/(pi*pi*nu*nu-Q*Q*R*R); + } + + this->FF_p = 4.0*pi*sin(Q*R)/(Q*R)*aux;// /6.0; + this->FF_n = this->FF_p; + +} + +void Nucleus_FF_DeVries::set_12C() { + //a(i) en fm^-3 + this->a[1]=0.15737e-1; + this->a[2]=0.38897e-1; + this->a[3]=0.37085e-1; + this->a[4]=0.14795e-1; + this->a[5]=-0.44834e-2; + + this->a[6]=-0.10057e-1; + this->a[7]=-0.68696e-2; + this->a[8]=-0.28813e-2; + this->a[9]=-0.77229e-3; + this->a[10]=0.66908e-4; + + this->a[11]=0.10636e-3; + this->a[12]=-0.36864e-4; + this->a[13]=-0.50135e-5; + this->a[14]=0.9455e-5; + this->a[15]=-0.47687e-5; + + this->R=8.0/hc; // [fm]/hc +} + +void Nucleus_FF_DeVries::set_40Ar() { + //a(i) en fm^-3 + this->a[1]=0.30451e-1; + this->a[2]=0.55337e-1; + this->a[3]=0.20203e-1; + this->a[4]=-0.16765e-1; + this->a[5]=-0.13578e-1; + + this->a[6]=-0.43204e-4; + this->a[7]=0.91988e-3; + this->a[8]=-0.41205e-3; + this->a[9]=0.11971e-3; + this->a[10]=-0.19801e-4; + + this->a[11]=-0.43204e-5; + this->a[12]=0.61205e-5; + this->a[13]=-0.37803e-5; + this->a[14]=0.18001e-5; + this->a[15]=-0.77407e-6; + + this->R=9.0/hc; // [fm]/hc +} + +Nucleus_FF_DeVries::~Nucleus_FF_DeVries() {} + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + + +Form_Factors_Delta::Form_Factors_Delta() { + this->mn = NCgamma_Param::mp; + this->mn2 = NCgamma_Param::mp2; + this->mDelta = NCgamma_Param::mDelta; + this->mDelta2 = this->mDelta*this->mDelta; + this->N_Delta_MA = NCgamma_Param::N_Delta_MA; + this->aNC = 1.0 - 2.0*NCgamma_Param::sinw2; + + this->kgcm0 = (this->mDelta2-this->mn2)/2.0/this->mDelta; + this->mpw2 = (this->mn+this->mDelta)*(this->mn+this->mDelta); + this->mmw2 = (this->mn - this->mDelta)*(this->mn - this->mDelta); + + this->C4v = 0.0; + this->C5v = 0.0; + this->C3a = 0.0; + this->C4a = 0.0; + this->C5a = 0.0; + this->C6a = 0.0; + + this->C4vNC = 0.0; + this->C5vNC = 0.0; + this->C3aNC = 0.0; + this->C4aNC = 0.0; + this->C6aNC = 0.0; + +} + +void Form_Factors_Delta::setFF(double Q2) { + + double egcm = (this->mDelta2-Q2-this->mn2)/2.0/this->mDelta; + double qcm = sqrt(egcm*egcm + Q2); + + double Fq = 1.0/((1.0 + Q2/NCgamma_Param::parameter_071)*(1.0 + Q2/NCgamma_Param::parameter_071)); + double AM = NCgamma_Param::parameter_03*(1.0 + NCgamma_Param::parameter_001*Q2)*exp(-NCgamma_Param::parameter_023*Q2)*(qcm/this->kgcm0)*Fq; + double A32= sqrt(3.0)/2.0*(-AM); + + double r = sqrt(2.0*this->kgcm0/NCgamma_Param::pi/NCgamma_Param::alpha*this->mn*this->mDelta/(this->mmw2+Q2)); + + this->C3v=-r*this->mn*this->mDelta/(this->mpw2+Q2)*(2.0*A32); + + double Fd=pow((1.0 + Q2/(this->N_Delta_MA*this->N_Delta_MA)),-2); + this->C5aNC=1.2*Fd; + this->C3vNC = this->C3v * this->aNC; + +} + +double Form_Factors_Delta::getC3v() const { + return C3v; +} + +double Form_Factors_Delta::getC4v() const { + return C4v; +} + +double Form_Factors_Delta::getC5v() const { + return C5v; +} + +double Form_Factors_Delta::getC3a() const { + return C3a; +} + +double Form_Factors_Delta::getC4a() const { + return C4a; +} + +double Form_Factors_Delta::getC5a() const { + return C5a; +} + +double Form_Factors_Delta::getC6a() const { + return C6a; +} + +double Form_Factors_Delta::getC3vNC() const { + return C3vNC; +} + +double Form_Factors_Delta::getC4vNC() const { + return C4vNC; +} + +double Form_Factors_Delta::getC5vNC() const { + return C5vNC; +} + +double Form_Factors_Delta::getC3aNC() const { + return C3aNC; +} + +double Form_Factors_Delta::getC4aNC() const { + return C4aNC; +} + +double Form_Factors_Delta::getC5aNC() const { + return C5aNC; +} + +double Form_Factors_Delta::getC6aNC() const { + return C6aNC; +} + diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Form_Factors.h b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Form_Factors.h new file mode 100644 index 000000000..5c50a2660 --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Form_Factors.h @@ -0,0 +1,130 @@ +// +// Created by edusaul on 8/04/19. +// + +#ifndef COHERENT_PHOTON_NUCLEAR_FF_H +#define COHERENT_PHOTON_NUCLEAR_FF_H +#include +#include + +namespace NC_gamma { + + class Nuclear_FF { + protected: + std::complex FF_p; + std::complex FF_n; + public: + + const std::complex &getFfP() const; + + const std::complex &getFfN() const; + + virtual void setFF(double) = 0; + + }; + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + class Nucleus_FF_DeVries : public Nuclear_FF { + protected: + std::string nucleus; + + double a[16]; + double R; + double pi; + double hc; + + public: + explicit Nucleus_FF_DeVries(const std::string &n); + + virtual void setFF(double); + + void set_12C(); + + void set_40Ar(); + + virtual ~Nucleus_FF_DeVries(); + + }; + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + + class Form_Factors_Delta { + protected: + double mn; + double mn2; + double mDelta; + double mDelta2; + double N_Delta_MA; + double aNC; + + double kgcm0; + double mpw2; + double mmw2; + + double C3v; + double C4v; + double C5v; + + double C3a; + double C4a; + double C5a; + double C6a; + + double C3vNC; + double C4vNC; + double C5vNC; + + double C3aNC; + double C4aNC; + double C5aNC; + double C6aNC; + + public: + Form_Factors_Delta(); + + void setFF(double); + + double getC3v() const; + + double getC4v() const; + + double getC5v() const; + + double getC3a() const; + + double getC4a() const; + + double getC5a() const; + + double getC6a() const; + + double getC3vNC() const; + + double getC4vNC() const; + + double getC5vNC() const; + + double getC3aNC() const; + + double getC4aNC() const; + + double getC5aNC() const; + + double getC6aNC() const; + + }; + +} + + + +#endif //COHERENT_PHOTON_NUCLEAR_FF_H diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Hadronic_Current_R.cpp b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Hadronic_Current_R.cpp new file mode 100644 index 000000000..343bcc912 --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Hadronic_Current_R.cpp @@ -0,0 +1,862 @@ +// +// Created by edusaul on 11/03/19. +// + +#include "NCgamma_Parameters_GeV.h" +#include "NCgamma_Hadronic_Current_R.h" +#include +#include + +using namespace NC_gamma; + +Delta_in_medium::Delta_in_medium() { + this->mDelta = NCgamma_Param::mDelta; + this->mDelta2 = NCgamma_Param::mDelta*NCgamma_Param::mDelta; + this->mn = NCgamma_Param::mp; + this->mn2 = NCgamma_Param::mp2; + this->mpi = NCgamma_Param::mpi; + this->V0 = NCgamma_Param::Delta_V0; + this->coupling_DeltaNpi = NCgamma_Param::coupling_DeltaNpi; + this->c_i = NCgamma_Param::c_i; + this->hc3 = NCgamma_Param::hc * NCgamma_Param::hc * NCgamma_Param::hc; + this->dir_or_crs = "dir"; + this->rho0 = NCgamma_Param::rho0; + + this->rho_avg = 3.0/(4.0*NCgamma_Param::pi*(1.2*1.2*1.2)) * this->hc3; // average density in fm^-3 * hc^3 + this->rho_r = this->rho_avg ; +} + + +Delta_in_medium::~Delta_in_medium() { + +} + + +std::complex Delta_in_medium::Delta_propagator_dir(double r) { + + std::complex sigma = this->Sigma(); + + std::complex D_Delta_med = 1.0/(this->p2 - (this->mDelta + sigma.real() )*(this->mDelta + sigma.real() ) + + this->c_i * (this->mDelta + sigma.real()) * (Gamma_tilde_Delta(this->rho_r) - 2.0 * sigma.imag() ) ); + return D_Delta_med; +} + +std::complex Delta_in_medium::Delta_propagator_crs() { + return 1.0/(this->p2 - this->mDelta2 + this->c_i * this->mDelta * this->Gamma_vacuum(this->p2)); +} + +void Delta_in_medium::change_other_parameters(std::vector > param) { + this->p2 = param[0].real(); + this->q_minus_kg = param[1].real(); + this->p = sqrt(this->p2); + this->qcm = sqrt(this->lambda_func(p2, this->mpi*this->mpi, this->mn*this->mn))/(2.0 * this->p); + this->gamma_vac = this->Gamma_vacuum(this->p2); + + this->propagator_crs = this->Delta_propagator_crs(); + this->propagator_avg = this->Delta_propagator_avg_dir(); +} + +std::complex Delta_in_medium::Sigma() { + double reSigma = 0.0; + + double imSigma = - 1.0/2.0 * this->V0 * this->rho_r/this->rho0; + + std::complex Sigma(reSigma, imSigma); + return Sigma; +} + +double Delta_in_medium::Gamma_tilde_Delta(double rho_r_in) { + + double q_tilde = this->qcm/this->kf(rho_r_in); + return this->gamma_vac * this->I_series(q_tilde); +} + +double Delta_in_medium::Gamma_vacuum(double p2_in) { + if(p2_in > (this->mn + this->mpi)*(this->mn + this->mpi)) { + + return 1.0/(6.0*NCgamma_Param::pi) * (this->coupling_DeltaNpi/this->mpi)*(this->coupling_DeltaNpi/this->mpi) + *this->mn/sqrt(p2_in) * this->qcm*qcm*qcm; + }else return 0; +} + +double Delta_in_medium::I_series(double q) { + double res = 1.0; + + if (q != 0) { + if (q > 1.0) res += -2.0 / (5.0 * q * q) + 9.0 / (35.0 * pow(q, 4)) - 2.0 / (21.0 * pow(q, 6)); + else if (q < 1.0) res += 34.0 / 35.0 * q - 22.0 / 105.0 * q * q * q - 1.0; + } + + return res; +} + +void Delta_in_medium::setNucleon(const std::string &n) { + Delta_in_medium::nucleon = n; +} + +double Delta_in_medium::lambda_func(double x, double y, double z) { + return x*x + y*y + z*z - 2.0*x*y - 2.0*y*z - 2.0*x*z; +} + +double Delta_in_medium::kf(double rho_r_in) { + return pow(3.0 * NCgamma_Param::pi*NCgamma_Param::pi * rho_r_in/2.0, 1.0/3.0); +} + +void Delta_in_medium::setDirOrCrs(const std::string &dirOrCrs) { + this->dir_or_crs = dirOrCrs; +} + +std::complex Delta_in_medium::Delta_propagator_avg_dir() { + std::complex sigma = this->Sigma(); + + std::complex D_Delta_med = 1.0/(this->p2 - (this->mDelta + sigma.real() )*(this->mDelta + sigma.real() ) + + this->c_i * (this->mDelta + sigma.real()) * (Gamma_tilde_Delta(this->rho_r) - 2.0 * sigma.imag() ) ); + return D_Delta_med; +} + + + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +Hadronic_Current_R::Hadronic_Current_R() { + this->c_i = NCgamma_Param::c_i; +} + +void Hadronic_Current_R::set_tr_dir(Array4x4 &tr) {} + +void Hadronic_Current_R::set_tr_crs(Array4x4 &tr) {} + +void Hadronic_Current_R::setQ(const std::vector &q_in) { + Hadronic_Current_R::q = q_in; + double q2 = q_in[0] * q_in[0] - q_in[1] * q_in[1] -q_in[2] * q_in[2] -q_in[3] * q_in[3]; + this->setFF(q2); +} + +void Hadronic_Current_R::setKg(const std::vector &kg_in) { + Hadronic_Current_R::kg = kg_in; +} + +void Hadronic_Current_R::setP(std::vector p_in) { + Hadronic_Current_R::p = p_in; + this->p0 = p_in[0]; + double pp_aux[] = {p_in[0], -p_in[1], -p_in[2], -p_in[3]}; + this->pp.assign(pp_aux, pp_aux + sizeof(pp_aux) / sizeof(double) ); +} + +std::complex Hadronic_Current_R::getR(int i, int j) { + return 0; +} + +void Hadronic_Current_R::setFF(double q2) {} + +Hadronic_Current_R::~Hadronic_Current_R() {} + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +Hadronic_Current_R_Sum::Hadronic_Current_R_Sum(const std::vector &vectorOfCurrents) + : vector_of_currents(vectorOfCurrents) {} + +void Hadronic_Current_R_Sum::setQ(const std::vector &q_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setQ(q_in); + } +} + +void Hadronic_Current_R_Sum::setKg(const std::vector &kg_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setKg(kg_in); + } +} + +void Hadronic_Current_R_Sum::setP(std::vector p_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setP(p_in); + } +} + +std::complex Hadronic_Current_R_Sum::getR(int i, int j) { + std::complex R (0.0,0.0); + for (int k = 0; k < static_cast(this->vector_of_currents.size()); ++k) { + R += vector_of_currents[k]->getR(i,j); + } + return R; +} + +void Hadronic_Current_R_Sum::setFF(double p_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setFF(p_in); + } +} + + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + +Hadronic_Current_R_Delta::Hadronic_Current_R_Delta(Nuclear_FF *nuclearFf) : nuclearFF(nuclearFf) { + this->mn = NCgamma_Param::mp; + this->mn2 = NCgamma_Param::mp2; + this->mDelta = NCgamma_Param::mDelta; + this->mDelta2 = NCgamma_Param::mDelta*NCgamma_Param::mDelta; + this->mpi = NCgamma_Param::mpi; + this->mpi2 = NCgamma_Param::mpi2; + this->c_i = NCgamma_Param::c_i; + this->ff_Delta = new Form_Factors_Delta(); + + this->ff_Delta->setFF(0.0); + this->C3v = this->ff_Delta->getC3v(); + this->C4v = this->ff_Delta->getC4v(); + this->C5v = this->ff_Delta->getC5v(); + + this->propagator = new Delta_in_medium(); +} + +Hadronic_Current_R_Delta::~Hadronic_Current_R_Delta() { + delete this->ff_Delta; + delete propagator; +} + + +void Hadronic_Current_R_Delta::setFF(double q2) { + double Q2 = -q2; + this->ff_Delta->setFF(Q2); +} + +void Hadronic_Current_R_Delta::setKg(const std::vector &kg_in) { + this->kg = kg_in; + + this->C3vNC = this->ff_Delta->getC3vNC(); + this->C4vNC = this->ff_Delta->getC4vNC(); + this->C5vNC = this->ff_Delta->getC5vNC(); + this->C3aNC = this->ff_Delta->getC3aNC(); + this->C4aNC = this->ff_Delta->getC4aNC(); + this->C5aNC = this->ff_Delta->getC5aNC(); + + this->set_tr_dir(tr_p_dir); + this->set_tr_crs(tr_p_crs); + + this->set_tr_dir(tr_n_dir); + this->set_tr_crs(tr_n_crs); + + std::vector pm = this->q; + std::transform(pm.begin( ), pm.end( ), this->kg.begin( ), pm.begin( ),std::minus( )); + this->q_minus_kg = sqrt(pm[1]*pm[1]+pm[2]*pm[2]+pm[3]*pm[3]); + + this->nuclearFF->setFF(this->q_minus_kg); + this->N_FF_p = this->nuclearFF->getFfP(); + this->N_FF_n = this->nuclearFF->getFfN(); + + this->dir_or_crs = "dir"; + Propagator_Delta(this->p_dir); + this->dir_or_crs = "crs"; + Propagator_Delta(this->p_crs); +} + + +void Hadronic_Current_R_Delta::set_tr_dir(Array4x4 &tr) { + + tr[0][0] = -(C3v*C3vNC*(mDelta*p0 + this->mn*(p0 + this->q[0]))*(4*mDelta2*this->q[1]*this->kg[1] - 4*pow(p0,2)*this->q[1]*this->kg[1] + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] - 3*this->q[1]*this->kg[1] + this->q[3]*(2*this->q[3] - 3*this->kg[3])) + + this->q[3]*(4*mDelta2 - 4*pow(p0,2) + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] - 8*p0*this->q[0]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])))/ + (3.*mDelta2*pow(this->mn,3)); + + tr[0][1] = (this->c_i*C3v*C5aNC*mDelta*(mDelta*p0 + this->mn*(p0 + this->q[0]))*this->q[3]*this->kg[2]* + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) - + C3v*C3vNC*this->mn*(16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->kg[1] + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->kg[1] + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0]*this->kg[1] + 8*p0*this->q[0] * this->q[0]*this->kg[1] + 4*pow(this->q[0],3)*this->kg[1] - this->q[0]*this->q[1] * this->q[1]*this->kg[1] + + 2*p0*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3]) - this->q[0]*this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->kg[3]*(-this->q[3] + this->kg[3])) - + this->q[0]*this->kg[1]*(this->q[0] * this->q[0] + this->q[3]*(2*this->q[3] + this->kg[3]))) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->kg[1] - this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) - + 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->kg[1] + 3*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + 4*p0*this->q[0]*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(4*this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - 3*this->q[3]*this->kg[3])))))/ + (12.*mDelta2*pow(this->mn,4)); + + tr[0][2] = (C3v*(std::complex(0,-1)*C5aNC*mDelta*(mDelta*p0 + this->mn*(p0 + this->q[0]))*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])* + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + C3vNC*this->mn*this->kg[2]*(-16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0]) + 4*pow(mDelta,3)*(-4*p0*this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] + 8*p0*this->q[0] * this->q[0] + 3*pow(this->q[0],3) - 2*p0*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) - + this->q[0]*this->q[1]*(2*this->q[1] + this->kg[1]) - this->q[0]*this->q[3]*(2*this->q[3] + this->kg[3])) + + mDelta*(16*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(8*this->q[0] * this->q[0] - 3*(this->q[1] * this->q[1] + this->q[3] * this->q[3])) + + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*this->q[0]*(3*this->q[0] * this->q[0] - this->q[1]*(4*this->q[1] + this->kg[1]) - this->q[3]*(4*this->q[3] + this->kg[3]))))))/(12.*mDelta2*pow(this->mn,4)); + + tr[0][3] = (C3v*(std::complex(0,-1)*C5aNC*mDelta*(mDelta*p0 + this->mn*(p0 + this->q[0]))*this->q[1]*this->kg[2]* + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + C3vNC*this->mn*(-16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->kg[3] + 4*pow(mDelta,3)*(-(this->q[1]*this->q[3]*this->kg[1]) - 4*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3]) + + 4*this->mn*(p0 + this->q[0])*(this->q[0]*this->q[3]*(this->kg[1]*(this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2]) + 8*p0*this->q[0] * this->q[0]*this->kg[3] - + this->q[0]*(-4*pow(p0,2) + this->q[3] * this->q[3] + this->q[1]*(2*this->q[1] + this->kg[1]))*this->kg[3] + pow(this->q[0],3)*(-2*this->q[3] + 3*this->kg[3]) + 2*p0*this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))\ + + mDelta*(16*pow(p0,3)*this->q[0]*this->kg[3] + 4*pow(p0,2)*(3*this->q[1]*this->q[3]*this->kg[1] + 8*this->q[0] * this->q[0]*this->kg[3] - 3*this->q[1] * this->q[1]*this->kg[3]) + + this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*this->q[0]*(-(this->q[3]*(3*this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + + (this->q[3] * this->q[3] + this->q[1]*(4*this->q[1] + this->kg[1]))*this->kg[3])))))/(12.*mDelta2*pow(this->mn,4)); + + + tr[1][0] = (C3v*(this->c_i*C5aNC*this->q[3]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(p0 + this->q[0]) - + 4*this->mn2*(p0 + this->q[0])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 2*mDelta*this->mn*(p0 + this->q[0])*(8*this->mn2 + 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + mDelta2*(8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 4*p0*this->q[0] * this->q[0] + 8*this->mn2*(-2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] - this->q[1]*this->kg[1] + this->q[3]*(this->q[3] - this->kg[3])) - 2*p0*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])))) - + 2*C3vNC*this->mn*(16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->q[1] + + 4*pow(mDelta,3)*(this->q[1]*(4*p0*this->q[0] - this->q[0] * this->q[0] + this->kg[1] * this->kg[1]) + this->q[3]*this->kg[1]*this->kg[3]) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[1] + 4*p0*this->q[0]*(pow(this->q[1],3) + 2*this->q[1] * this->q[1]*this->kg[1] - 3*this->q[1]*this->kg[1] * this->kg[1] + this->q[3]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + + this->q[1]*this->q[3]*(this->q[3] + this->kg[3])) + (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))*(this->q[0] * this->q[0]*this->q[1] - this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) - + 4*pow(p0,2)*(5*this->q[0] * this->q[0]*this->q[1] + 3*this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]))) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0]*this->q[1] + 6*p0*this->q[0] * this->q[0]*this->q[1] + 2*p0*this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + this->q[0]*(2*this->q[0] * this->q[0]*this->q[1] - pow(this->q[1],3) - 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - this->q[3]*(this->q[3] + this->kg[3])))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[1][1] = (C3v*(this->c_i*C5aNC*this->q[3]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[1] + this->kg[1]) + 2*this->mn2*(this->q[1] + this->kg[1])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[1] + this->kg[1])*(-4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 8*this->mn2*this->kg[1] - 2*p0*this->q[0]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + + 4*pow(p0,2)*(this->q[1] + this->kg[1]) - this->q[1]*this->q[3]*this->kg[3])) - + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 + this->q[0])*(this->q[0] * this->q[0] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(-(this->q[0]*(-4*p0*this->q[0] + this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1])) + 2*(-2*p0 + this->q[0])*this->q[3]*this->kg[3]) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) - + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] - this->kg[1] * this->kg[1] + 3*this->q[3]*this->kg[3]) + + this->q[3]*(-(this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + (this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3]) + + 2*p0*this->q[0]*(3*this->q[0] * this->q[0] + this->kg[1] * this->kg[1] - this->q[3]*(this->q[3] + 2*this->kg[3]))) - + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]*(5*this->q[0] * this->q[0] - 3*this->q[3] * this->q[3] + 3*this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3]) + + 4*p0*(-2*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[0] * this->q[0]*(2*this->q[3] * this->q[3] + (this->q[1] - this->kg[1])*(this->q[1] + 3*this->kg[1])) + + this->q[3]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3]) - + this->q[0]*(this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3])*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[1][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[1] + 4*pow(mDelta,3)*(4*p0*this->q[1] + this->q[0]*(-2*this->q[1] + this->kg[1])) + + 4*this->mn*(p0 + this->q[0])*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] - 2*p0*this->q[0]*(2*this->q[1] + this->kg[1]) - + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + this->q[1]*this->q[3]*this->kg[3]) + + mDelta*(-4*pow(p0,2)*this->q[0]*(2*this->q[1] + 3*this->kg[1]) + + 4*p0*(this->q[0] * this->q[0]*(2*this->q[1] - 3*this->kg[1]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[1] + 2*this->kg[1])) - + this->q[0]*(2*this->q[1] - this->kg[1])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + this->c_i*C5aNC*(2*this->mn2*this->q[3]*this->kg[2] * this->kg[2]*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(-(this->q[3]*this->kg[1] * this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 2*this->kg[3]) - 2*p0*this->q[0]*this->kg[3] + + (8*this->mn2 + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3]) + + mDelta2*(-2*p0*this->q[3]*(2*p0*(-2*this->q[0] * this->q[0] + this->kg[1] * this->kg[1]) + + this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + this->kg[1] * this->kg[1])) + + this->q[3]*(-(this->q[0]*(4*p0 + this->q[0])) + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 2*p0*(-4*pow(p0,2)*this->q[0] - 2*pow(this->q[0],3) + this->q[0]*this->q[1]*(this->q[1] + this->kg[1]) + + 2*p0*(-3*this->q[0] * this->q[0] + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1])))*this->kg[3] + + 8*this->mn2*(this->q[3]*(-2*p0*this->q[0] + this->kg[2] * this->kg[2]) + 2*p0*(2*p0 + this->q[0])*this->kg[3])) + + mDelta*this->mn*(this->q[3]*(-pow(this->q[0],4) - this->kg[1] * this->kg[1]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 4*this->q[1]*this->kg[1]) - + 2*(this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 5*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2])) + + (2*pow(this->q[0],4) + pow(this->q[1] * this->q[1] + this->q[3] * this->q[3],2) + 3*this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[1] + + 2*(this->q[1] - this->q[3])*(this->q[1] + this->q[3])*this->kg[1] * this->kg[1] - this->q[0] * this->q[0]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 5*this->q[1]*this->kg[1]))*this->kg[3] + + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[3] + this->kg[3]) - + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) + this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) - + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-(this->q[1] * this->q[1]*(this->q[3] + 2*this->kg[3])) + this->q[0] * this->q[0]*(this->q[3] + 3*this->kg[3]) - this->q[1]*this->kg[1]*(this->q[3] + 3*this->kg[3]) + + this->q[3]*(3*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + 3*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[1][3] = -(C3v*(this->c_i*C5aNC*this->kg[2]*(4*pow(mDelta,3)*this->mn*(8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1])) - + 2*this->mn2*this->q[3]*(this->q[3] + this->kg[3])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(4*pow(p0,2)*this->q[0] * this->q[0] + 6*p0*pow(this->q[0],3) + 2*pow(this->q[0],4) - 4*p0*this->q[0]*this->q[1] * this->q[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1] + pow(this->q[1],4) + this->q[1] * this->q[1]*this->q[3] * this->q[3] - 6*p0*this->q[0]*this->q[1]*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] + + 3*pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->kg[1] * this->kg[1] + 2*this->q[3]*(-(this->q[0]*(p0 + this->q[0])) + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3] + + 8*this->mn2*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3]))) + + mDelta2*(-8*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + this->kg[1])) + + 8*this->mn2*(2*p0*(2*p0 + this->q[0]) - this->q[3]*this->kg[3]) + 2*p0*this->q[0]*(-2*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[3]*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[1]*this->kg[3] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*(this->q[3] - 2*this->kg[3]) + 4*p0*this->q[1]*this->kg[3] + this->q[0]*this->kg[1]*this->kg[3]) - + 4*this->mn*(p0 + this->q[0])*(this->q[1]*this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(-(this->q[3]*(this->q[1] + this->kg[1])) + (2*this->q[1] + this->kg[1])*this->kg[3]) + 2*p0*this->q[0]*(this->kg[1]*this->kg[3] + this->q[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[1]*this->kg[3] + 3*this->kg[1]*this->kg[3]) - + this->q[0]*(this->q[1]*(this->q[3] - 2*this->kg[3]) + this->kg[1]*this->kg[3])*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(-2*this->q[1]*this->q[3]*this->kg[1] * this->kg[1] + this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(-(this->q[1]*this->q[3]) + this->q[3]*this->kg[1] + 2*this->q[1]*this->kg[3] - 3*this->kg[1]*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + + tr[2][0] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) - + 4*this->mn*(p0 + this->q[0])*(-(this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3])) + 2*p0*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + mDelta*(4*p0*this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] - 3*this->q[3]*this->kg[3]) - 12*pow(p0,2)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + (this->q[1]*this->kg[1] + this->q[3]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + this->c_i*C5aNC*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(8*pow(mDelta,3)*this->mn*(p0 + this->q[0]) - + 4*this->mn2*(p0 + this->q[0])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 2*mDelta*this->mn*(p0 + this->q[0])*(8*this->mn2 + 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + mDelta2*(8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 4*p0*this->q[0] * this->q[0] + 8*this->mn2*(-2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] - this->q[1]*this->kg[1] + this->q[3]*(this->q[3] - this->kg[3])) - 2*p0*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3]))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[2][1] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[1] - 4*this->mn*(p0 + this->q[0])* + (2*p0*this->q[0]*this->kg[1] + this->q[0] * this->q[0]*(-this->q[1] + this->kg[1]) + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + mDelta*(4*p0*this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) - 12*pow(p0,2)*this->q[0]*this->kg[1] + 8*p0*this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]) + + this->q[0]*this->kg[1]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + this->c_i*C5aNC*(2*this->mn2*(this->q[1] + this->kg[1])*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[3]*(this->q[0] * this->q[0] + this->q[1]*this->kg[1] - this->kg[2] * this->kg[2]) + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[3] * this->q[3])*this->kg[3]) + + mDelta2*(-8*pow(p0,3)*this->q[0]*this->kg[3] + 2*p0*this->q[0]* + (-(this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[0] * this->q[0]*(3*this->q[3] - 2*this->kg[3]) + + this->q[1]*(this->q[1] + 2*this->kg[1])*this->kg[3]) + 4*pow(p0,2)*(this->q[3]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) + this->q[3]*this->kg[3]*(this->q[3] + this->kg[3])) + + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(4*pow(p0,2)*this->kg[3] + 2*p0*this->q[0]*(-this->q[3] + this->kg[3]) + this->kg[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))) + + mDelta*this->mn*(this->q[3]*(-pow(this->q[0],4) + this->kg[1]*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[1]) - + (this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(-this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + 5*this->kg[2] * this->kg[2])) + + (2*pow(this->q[0],4) - this->q[0] * this->q[0]*(3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1]) + + this->q[3] * this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 4*this->q[1]*this->kg[1] - 2*this->kg[2] * this->kg[2]))*this->kg[3] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[3] + this->kg[3]) - + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) + this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) - + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-(this->q[1] * this->q[1]*this->q[3]) - this->q[1]*this->kg[1]*(3*this->q[3] + this->kg[3]) + this->q[0] * this->q[0]*(this->q[3] + 3*this->kg[3]) + + this->q[3]*(this->kg[1] * this->kg[1] + 3*this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + 3*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][2] = (C3v*(std::complex(0,-1)*C5aNC*this->kg[2]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(4*pow(mDelta,3)*this->mn + + mDelta2*(8*this->mn2 + 4*pow(p0,2) - 2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 2*this->mn2*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(-4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*C3vNC*this->mn*(-16*mDelta2*this->mn*(p0 + this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3]) + + 4*p0*(-this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[1] * this->q[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] - this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 3*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]) + + 2*p0*this->q[0]*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (5*this->q[0] * this->q[0] - 3*this->q[1] * this->q[1] - 3*this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] + 3*this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3]) - + this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3])* + (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + this->q[3] * this->q[3]*(-2*this->kg[2] * this->kg[2] + this->q[3]*this->kg[3]) + + this->q[0] * this->q[0]*(this->q[1]*(-4*this->q[1] + this->kg[1]) + 3*this->kg[2] * this->kg[2] + this->q[3]*(-2*this->q[3] + this->kg[3])) + this->q[1] * this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[3]*(this->q[3] + 2*this->kg[3])) + )))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][3] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[3] - 4*this->mn*(p0 + this->q[0])*(2*p0*this->q[0]*this->kg[3] + this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + mDelta*(4*p0*this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) - 12*pow(p0,2)*this->q[0]*this->kg[3] + 8*p0*this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3]) + + this->q[0]*this->kg[3]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + this->c_i*C5aNC*(-2*this->mn2*(this->q[3] + this->kg[3])*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + 8*this->mn2*this->kg[1] - 2*p0*this->q[0]*this->kg[1] + this->q[1]*(this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + this->q[3]*this->kg[3])) + + mDelta2*(-8*pow(p0,3)*this->q[0]*this->kg[1] + 4*pow(p0,2)* + (this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[1]*this->kg[3]*(this->q[3] + this->kg[3])) + + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(4*pow(p0,2)*this->kg[1] + 2*p0*this->q[0]*(-this->q[1] + this->kg[1]) + this->kg[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) + this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]) + + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(pow(this->q[0],4)*this->q[1] - this->q[0] * this->q[0]*pow(this->q[1],3) + this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] + this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] - 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + + 2*pow(this->q[1],3)*this->kg[1] * this->kg[1] - 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) + + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] - pow(this->q[1],3)*this->kg[2] * this->kg[2] - 3*this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] - + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 3*this->q[0] * this->q[0]*this->q[1]*this->q[3]*this->kg[3] + pow(this->q[1],3)*this->q[3]*this->kg[3] + this->q[1]*pow(this->q[3],3)*this->kg[3] - + 2*this->q[0] * this->q[0]*this->q[3]*this->kg[1]*this->kg[3] + 4*this->q[1] * this->q[1]*this->q[3]*this->kg[1]*this->kg[3] - 2*this->q[1]*this->q[3]*this->kg[2] * this->kg[2]*this->kg[3] - + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) - + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) - 3*this->q[1] * this->q[1]*this->kg[1] + 2*this->q[0] * this->q[0]*(this->q[1] + 2*this->kg[1]) - + this->q[1]*(this->q[3] * this->q[3] + this->kg[1] * this->kg[1] - 2*this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]) - this->kg[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->kg[3]*(this->q[3] + this->kg[3])))))) + )/(24.*mDelta2*pow(this->mn,4)); + + + tr[3][0] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(p0 + this->q[0]) - + 4*this->mn2*(p0 + this->q[0])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 2*mDelta*this->mn*(p0 + this->q[0])*(8*this->mn2 + 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + mDelta2*(8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 4*p0*this->q[0] * this->q[0] + 8*this->mn2*(-2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] - this->q[1]*this->kg[1] + this->q[3]*(this->q[3] - this->kg[3])) - 2*p0*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->q[3] + + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->q[3] - this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[1]*this->kg[1]*this->kg[3]) + + 4*this->mn*(p0 + this->q[0])*(-4*pow(p0,2)*this->q[0]*this->q[3] - 8*p0*this->q[0] * this->q[0]*this->q[3] - 3*pow(this->q[0],3)*this->q[3] + + 2*p0*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[0]*this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - + 2*p0*this->q[1]*this->kg[1]*this->kg[3] + this->q[0]*(this->q[1] * this->q[1] + 2*this->q[3] * this->q[3] - this->q[1]*this->kg[1])*this->kg[3]) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[3] - 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->q[3] - 3*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + 3*this->q[1]*this->kg[1]*this->kg[3]) - + (this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*this->kg[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*this->q[0]*(-3*this->q[0] * this->q[0]*this->q[3] + this->q[1]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + this->q[1] * this->q[1]*(this->q[3] + this->kg[3]) + + this->q[3]*(3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][1] = (this->c_i*C3v*C5aNC*this->kg[2]*(-2*this->mn2*this->q[1]*(this->q[1] + this->kg[1])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[3]*(this->q[3] + this->kg[3])) - + mDelta*this->mn*(-4*pow(p0,2)*this->q[0] * this->q[0] - 2*pow(this->q[0],4) + this->q[0] * this->q[0]*this->q[3] * this->q[3] - this->q[1] * this->q[1]*this->q[3] * this->q[3] - pow(this->q[3],4) + + 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] - 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] - + this->q[3]*(-5*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + 2*this->q[3] * this->q[3] + this->q[1]*this->kg[1] + 3*this->q[3]*this->kg[3]) + + 8*this->mn2*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))) + + mDelta2*(-8*pow(p0,3)*this->q[0] + 8*this->mn2*(2*p0*(2*p0 + this->q[0]) - this->q[1]*this->kg[1]) + + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[3]*(this->q[3] + this->kg[3])) + 2*p0*this->q[0]*(-2*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + 2*this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + this->q[1]*(this->q[0] * this->q[0]*(-this->q[1] + this->kg[1]) + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])))) - + 2*C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[3]*this->kg[1] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*this->q[3] + 4*p0*this->q[3]*this->kg[1] + this->q[0]*this->kg[1]*(-2*this->q[3] + this->kg[3])) - + 4*this->mn*(p0 + this->q[0])*(2*p0*this->q[0]*(this->q[1]*this->q[3] + this->kg[1]*(2*this->q[3] + this->kg[3])) + this->q[0] * this->q[0]*(this->q[1]*(this->q[3] - this->kg[3]) + this->kg[1]*(2*this->q[3] + this->kg[3])) - + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + 3*this->kg[1]*this->kg[3]) + + this->q[0]*(this->q[1]*this->q[3] + this->kg[1]*(-2*this->q[3] + this->kg[3]))*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(this->q[0] * this->q[0]*(-3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + this->q[1]*this->kg[3] - 3*this->kg[1]*this->kg[3]) + + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[3] - + 4*this->mn*(p0 + this->q[0])*(-(this->q[3]*(-2*this->q[0]*(2*p0 + this->q[0]) + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))) + + (2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1] * this->q[1] - 2*this->q[3] * this->q[3])*this->kg[3]) + 4*pow(mDelta,3)*(4*p0*this->q[3] + this->q[0]*(-2*this->q[3] + this->kg[3])) + + mDelta*(-4*pow(p0,2)*this->q[0]*(2*this->q[3] + 3*this->kg[3]) - + this->q[0]*(2*this->q[3] - this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*(this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[3] + 2*this->kg[3])))) - + this->c_i*C5aNC*(2*this->mn2*this->q[1]*this->kg[2] * this->kg[2]*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2*this->kg[1] - 2*p0*this->q[0]*this->kg[1] - 2*this->q[0] * this->q[0]*this->kg[1] + this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + + this->q[1]*this->kg[1] * this->kg[1] + this->q[1]*this->kg[2] * this->kg[2] + this->q[3]*this->kg[1]*this->kg[3]) + + mDelta2*(-8*pow(p0,3)*this->q[0]*this->kg[1] + this->q[1]*(-this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 8*this->mn2*(4*pow(p0,2)*this->kg[1] + 2*p0*this->q[0]*(-this->q[1] + this->kg[1]) + this->q[1]*this->kg[2] * this->kg[2]) + + 4*pow(p0,2)*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) + 2*this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3]) - + this->q[1]*(-this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(4*pow(this->q[0],4)*this->q[1] - 2*this->q[0] * this->q[0]*pow(this->q[1],3) - 2*this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 5*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] - this->q[0] * this->q[0]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + pow(this->q[3],4)*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + 3*pow(this->q[1],3)*this->kg[1] * this->kg[1] + 3*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + + 2*this->q[1] * this->q[1]*pow(this->kg[1],3) - 2*this->q[3] * this->q[3]*pow(this->kg[1],3) + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) - + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] + pow(this->q[1],3)*this->kg[2] * this->kg[2] + this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[1]*this->kg[2] * this->kg[2] - 2*this->q[0] * this->q[0]*this->q[1]*this->q[3]*this->kg[3] - 5*this->q[0] * this->q[0]*this->q[3]*this->kg[1]*this->kg[3] + + 3*this->q[1] * this->q[1]*this->q[3]*this->kg[1]*this->kg[3] + 3*pow(this->q[3],3)*this->kg[1]*this->kg[3] + 4*this->q[1]*this->q[3]*this->kg[1] * this->kg[1]*this->kg[3] + 2*this->q[1]*this->q[3]*this->kg[2] * this->kg[2]*this->kg[3] - + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) - + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) - 3*this->q[1] * this->q[1]*this->kg[1] + this->q[0] * this->q[0]*(4*this->q[1] + 3*this->kg[1]) - this->q[3]*this->kg[1]*(2*this->q[3] + 3*this->kg[3]) - + this->q[1]*(3*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][3] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[3] + this->kg[3]) + + 2*this->mn2*(this->q[3] + this->kg[3])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[3] + this->kg[3])*(-4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(-(this->q[1]*this->q[3]*this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - this->kg[3]) + 8*this->mn2*this->kg[3] - 2*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3] + + 4*pow(p0,2)*(this->q[3] + this->kg[3]))) + 2*C3vNC*this->mn* + (16*mDelta2*this->mn*(p0 + this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) + + 4*pow(mDelta,3)*(4*p0*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) - this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 3*pow(this->q[0],4) + + 2*p0*this->q[0]*(4*this->q[0] * this->q[0] - pow(this->q[1] + this->kg[1],2) - this->kg[2] * this->kg[2]) - + this->q[0] * this->q[0]*(this->q[3] * this->q[3] + (this->q[1] + this->kg[1])*(2*this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) - + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (8*this->q[0] * this->q[0] - 3*this->q[1] * this->q[1] - 2*this->q[1]*this->kg[1] - 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + + this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*(3*pow(this->q[0],4) - this->q[0] * this->q[0]*(4*this->q[1] * this->q[1] - this->q[1]*this->kg[1] + 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3])))))))/ + (24.*mDelta2*pow(this->mn,4)); + +} + +void Hadronic_Current_R_Delta::set_tr_crs(Array4x4 &tr) { + + tr[0][0] = -(C3v*C3vNC*((mDelta + this->mn)*p0 - this->mn*this->q[0])*(4*mDelta2*this->q[1]*this->kg[1] - 4*pow(p0,2)*this->q[1]*this->kg[1] + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] - 3*this->q[1]*this->kg[1] + this->q[3]*(2*this->q[3] - 3*this->kg[3])) + + this->q[3]*(4*mDelta2 - 4*pow(p0,2) + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + 8*p0*this->q[0]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])))/ + (3.*mDelta2*pow(this->mn,3)); + + tr[0][1] = -(C3v*(this->c_i*C5aNC*mDelta*((mDelta + this->mn)*p0 - this->mn*this->q[0])*this->q[3]*this->kg[2]* + (8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->kg[1] + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->kg[1] + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 4*this->mn*(p0 - this->q[0])*(pow(this->q[0],3)*(this->q[1] - 3*this->kg[1]) + 8*p0*this->q[0] * this->q[0]*this->kg[1] + 2*p0*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3]) + + this->q[0]*(-4*pow(p0,2)*this->kg[1] + 2*this->q[3] * this->q[3]*this->kg[1] + this->q[1]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[3]*(-this->q[1] + this->kg[1])*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->kg[1] + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->kg[1] + 3*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + 4*p0*this->q[0]*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(4*this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - 3*this->q[3]*this->kg[3]))))))/ + (12.*mDelta2*pow(this->mn,4)); + + tr[0][2] = (this->c_i*C3v*C5aNC*mDelta*((mDelta + this->mn)*p0 - this->mn*this->q[0])*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])* + (8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) - + C3v*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0] + 4*pow(mDelta,3)*(4*p0*this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 4*this->mn*(p0 - this->q[0])*(-4*pow(p0,2)*this->q[0] + 8*p0*this->q[0] * this->q[0] - 3*pow(this->q[0],3) - 2*p0*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + this->q[0]*this->q[1]*(2*this->q[1] + this->kg[1]) + this->q[0]*this->q[3]*(2*this->q[3] + this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(8*this->q[0] * this->q[0] - 3*(this->q[1] * this->q[1] + this->q[3] * this->q[3])) + + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1]*(4*this->q[1] + this->kg[1]) + this->q[3]*(4*this->q[3] + this->kg[3])))))/(12.*mDelta2*pow(this->mn,4)); + + tr[0][3] = (this->c_i*C3v*C5aNC*mDelta*((mDelta + this->mn)*p0 - this->mn*this->q[0])*this->q[1]*this->kg[2]*(8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) - + C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->kg[3] + 4*pow(mDelta,3)*(-(this->q[1]*this->q[3]*this->kg[1]) + 4*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3]) + + 4*this->mn*(p0 - this->q[0])*(-(this->q[0]*this->q[3]*(this->kg[1]*(this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2])) + pow(this->q[0],3)*(2*this->q[3] - 3*this->kg[3]) + 8*p0*this->q[0] * this->q[0]*this->kg[3] + + this->q[0]*(-4*pow(p0,2) + this->q[3] * this->q[3] + this->q[1]*(2*this->q[1] + this->kg[1]))*this->kg[3] + 2*p0*this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->kg[3] + 4*pow(p0,2)*(3*this->q[1]*this->q[3]*this->kg[1] + 8*this->q[0] * this->q[0]*this->kg[3] - 3*this->q[1] * this->q[1]*this->kg[3]) + + this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*this->q[0]*(-(this->q[3]*(3*this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + + (this->q[3] * this->q[3] + this->q[1]*(4*this->q[1] + this->kg[1]))*this->kg[3]))))/(12.*mDelta2*pow(this->mn,4)); + + + tr[1][0] = (this->c_i*C3v*C5aNC*this->q[3]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(-p0 + this->q[0]) + + 2*mDelta*this->mn*(p0 - this->q[0])*(8*this->mn2 - 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 4*this->mn2*(p0 - this->q[0])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta2*(-8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 8*this->mn2*(2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 2*p0*(-2*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + 2*C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->q[1] + + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->q[1] + this->q[0] * this->q[0]*this->q[1] - this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[1] + 4*p0*this->q[0]*(pow(this->q[1],3) + 2*this->q[1] * this->q[1]*this->kg[1] - 3*this->q[1]*this->kg[1] * this->kg[1] + this->q[3]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + + this->q[1]*this->q[3]*(this->q[3] + this->kg[3])) - (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))*(this->q[0] * this->q[0]*this->q[1] - this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + 4*pow(p0,2)*(5*this->q[0] * this->q[0]*this->q[1] + 3*this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]))) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0]*this->q[1] - 2*p0*(3*this->q[0] * this->q[0]*this->q[1] + this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + this->q[0]*(2*this->q[0] * this->q[0]*this->q[1] - pow(this->q[1],3) - 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - this->q[3]*(this->q[3] + this->kg[3]))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[1][1] = (this->c_i*C3v*C5aNC*this->q[3]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[1] + this->kg[1]) + + 2*this->mn2*(this->q[1] + this->kg[1])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[1] + this->kg[1])*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 8*this->mn2*this->kg[1] + 2*p0*this->q[0]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + 4*pow(p0,2)*(this->q[1] + this->kg[1]) - + this->q[1]*this->q[3]*this->kg[3])) - 2*C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(this->q[0]*(4*p0*this->q[0] + this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1]) - 2*(2*p0 + this->q[0])*this->q[3]*this->kg[3]) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1] + 2*this->q[3]*this->kg[3]) - + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] - this->kg[1] * this->kg[1] + 3*this->q[3]*this->kg[3]) + + this->q[3]*(-(this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + (this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]*(5*this->q[0] * this->q[0] - 3*this->q[3] * this->q[3] + 3*this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3]) - + this->q[0]*(this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3])*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(this->q[0] * this->q[0]*((this->q[1] - this->kg[1])*(this->q[1] + 3*this->kg[1]) + this->q[3]*(2*this->q[3] - this->kg[3])) + + this->q[3]*(2*this->q[3]*this->kg[1] * this->kg[1] - (this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3])))))/(24.*mDelta2*pow(this->mn,4)); + + tr[1][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[1] + 4*pow(mDelta,3)*(4*p0*this->q[1] + 2*this->q[0]*this->q[1] - this->q[0]*this->kg[1]) + + 4*this->mn*(p0 - this->q[0])*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + 2*p0*this->q[0]*(2*this->q[1] + this->kg[1]) - + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + this->q[1]*this->q[3]*this->kg[3]) + + mDelta*(4*pow(p0,2)*this->q[0]*(2*this->q[1] + 3*this->kg[1]) + 4*p0* + (this->q[0] * this->q[0]*(2*this->q[1] - 3*this->kg[1]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[1] + 2*this->kg[1])) + + this->q[0]*(2*this->q[1] - this->kg[1])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + this->c_i*C5aNC*(2*this->mn2*this->q[3]*this->kg[2] * this->kg[2]*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(-(this->q[3]*this->kg[1] * this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 2*this->kg[3]) + 2*p0*this->q[0]*this->kg[3] + + (8*this->mn2 + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3]) + + mDelta2*(2*p0*this->q[3]*(this->q[0]*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + this->q[0]*this->q[1]*this->kg[1] + + (-2*p0 + this->q[0])*this->kg[1] * this->kg[1]) + this->q[3]*(4*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 2*p0*(4*pow(p0,2)*this->q[0] + 2*pow(this->q[0],3) - this->q[0]*this->q[1]*(this->q[1] + this->kg[1]) + 2*p0*(-3*this->q[0] * this->q[0] + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1])))* + this->kg[3] + 8*this->mn2*(this->q[3]*this->kg[2] * this->kg[2] + 2*p0*this->q[0]*(this->q[3] - this->kg[3]) + 4*pow(p0,2)*this->kg[3])) + + mDelta*this->mn*(this->q[3]*(4*pow(p0,2)*this->q[0] * this->q[0] - pow(this->q[0],4) - this->kg[1] * this->kg[1]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 4*this->q[1]*this->kg[1]) - + 2*(this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[2] * this->kg[2] + + 2*p0*this->q[0]*(-this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] - 3*this->kg[1] * this->kg[1] - this->kg[2] * this->kg[2]) + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 5*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2])) + + (4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + pow(this->q[1] * this->q[1] + this->q[3] * this->q[3],2) + + 3*this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[1] + 2*(this->q[1] - this->q[3])*(this->q[1] + this->q[3])*this->kg[1] * this->kg[1] + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + 2*this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 3*this->q[1]*this->kg[1]) - + this->q[0] * this->q[0]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 5*this->q[1]*this->kg[1]))*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) - this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + ))))/(24.*mDelta2*pow(this->mn,4)); + + tr[1][3] = (C3v*(2*C3vNC*this->mn*(16*mDelta2*this->mn*(-p0 + this->q[0])*this->q[1]*this->kg[3] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*(this->q[3] - 2*this->kg[3]) - 4*p0*this->q[1]*this->kg[3] + this->q[0]*this->kg[1]*this->kg[3]) - + 4*this->mn*(p0 - this->q[0])*(-(this->q[1]*this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(this->q[3]*(this->q[1] + this->kg[1]) - (2*this->q[1] + this->kg[1])*this->kg[3]) + 2*p0*this->q[0]*(this->kg[1]*this->kg[3] + this->q[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(4*p0*this->q[3]*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 2*this->q[1]*this->kg[1] * this->kg[1]) - + 4*p0*(this->q[0] * this->q[0]*(2*this->q[1] - 3*this->kg[1]) + this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1]))*this->kg[3] - + 4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[1]*this->kg[3] + 3*this->kg[1]*this->kg[3]) + + this->q[0]*(this->q[1]*(this->q[3] - 2*this->kg[3]) + this->kg[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])))) - + this->c_i*C5aNC*this->kg[2]*(4*pow(mDelta,3)*this->mn*(8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1])) - + 2*this->mn2*this->q[3]*(this->q[3] + this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(4*pow(p0,2)*this->q[0] * this->q[0] - 6*p0*pow(this->q[0],3) + 2*pow(this->q[0],4) + 4*p0*this->q[0]*this->q[1] * this->q[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1] + pow(this->q[1],4) + this->q[1] * this->q[1]*this->q[3] * this->q[3] + 6*p0*this->q[0]*this->q[1]*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] + + 3*pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->kg[1] * this->kg[1] + 2*this->q[3]*((p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + mDelta2*(8*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + this->kg[1])) + + 8*this->mn2*(4*pow(p0,2) - 2*p0*this->q[0] - this->q[3]*this->kg[3]) + 2*p0*this->q[0]*(2*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[3]*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + + tr[2][0] = (C3v*(2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) - + 4*this->mn*(p0 - this->q[0])*(this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + 2*p0*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + mDelta*(-4*p0*this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] - 3*this->q[3]*this->kg[3]) - 12*pow(p0,2)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + (this->q[1]*this->kg[1] + this->q[3]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + this->c_i*C5aNC*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(8*pow(mDelta,3)*this->mn*(-p0 + this->q[0]) + + 2*mDelta*this->mn*(p0 - this->q[0])*(8*this->mn2 - 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 4*this->mn2*(p0 - this->q[0])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta2*(-8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 8*this->mn2*(2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 2*p0*(-2*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][1] = (C3v*(2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[1] - 4*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 2*p0*this->q[0]*this->kg[1] + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + mDelta*(-12*pow(p0,2)*this->q[0]*this->kg[1] + this->q[0]*this->kg[1]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + 2*this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])))) - + this->c_i*C5aNC*(-2*this->mn2*(this->q[1] + this->kg[1])*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[3]*(this->q[0] * this->q[0] + this->q[1]*this->kg[1] - this->kg[2] * this->kg[2]) + (8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[3] * this->q[3])*this->kg[3]) + + mDelta2*(8*pow(p0,3)*this->q[0]*this->kg[3] + 4*pow(p0,2)* + (this->q[3]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) + this->q[3]*this->kg[3]*(this->q[3] + this->kg[3])) + + 2*p0*this->q[0]*(this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*(this->q[1] + 2*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(-3*this->q[3] + 2*this->kg[3])) + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] - this->kg[3]) + 4*pow(p0,2)*this->kg[3] + this->kg[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))) + + mDelta*this->mn*(this->q[3]*(-pow(this->q[0],4) + this->kg[1]*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[1]) - + (this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(-this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + 5*this->kg[2] * this->kg[2])) + + (2*pow(this->q[0],4) - this->q[0] * this->q[0]*(3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1]) + + this->q[3] * this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 4*this->q[1]*this->kg[1] - 2*this->kg[2] * this->kg[2]))*this->kg[3] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[3] + this->kg[3]) + + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) - this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) + + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(this->q[1] * this->q[1]*this->q[3] + this->q[1]*this->kg[1]*(3*this->q[3] + this->kg[3]) - this->q[0] * this->q[0]*(this->q[3] + 3*this->kg[3]) + + this->q[3]*(this->q[3] * this->q[3] - this->kg[1] * this->kg[1] - 3*this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][2] = -(C3v*(this->c_i*C5aNC*this->kg[2]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(4*pow(mDelta,3)*this->mn + + mDelta2*(8*this->mn2 + 4*pow(p0,2) + 2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 2*this->mn2*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3]) + + 4*p0*(this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3])) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[1] * this->q[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) - + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 3*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3])) - + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (-5*this->q[0] * this->q[0] + 3*this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] - 3*this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) + + this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3])* + (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + this->q[3] * this->q[3]*(-2*this->kg[2] * this->kg[2] + this->q[3]*this->kg[3]) + + this->q[0] * this->q[0]*(this->q[1]*(-4*this->q[1] + this->kg[1]) + 3*this->kg[2] * this->kg[2] + this->q[3]*(-2*this->q[3] + this->kg[3])) + + this->q[1] * this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[3]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][3] = (C3v*(2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[3] - 4*this->mn*(p0 - this->q[0])* + (this->q[0] * this->q[0]*(this->q[3] - this->kg[3]) + 2*p0*this->q[0]*this->kg[3] + this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + mDelta*(-12*pow(p0,2)*this->q[0]*this->kg[3] + this->q[0]*this->kg[3]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*(this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) + 2*this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])))) + + this->c_i*C5aNC*(-2*this->mn2*(this->q[3] + this->kg[3])*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + 8*this->mn2*this->kg[1] + 2*p0*this->q[0]*this->kg[1] + this->q[1]*(this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + this->q[3]*this->kg[3])) + + mDelta2*(8*pow(p0,3)*this->q[0]*this->kg[1] + 4*pow(p0,2)* + (this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[1]*this->kg[3]*(this->q[3] + this->kg[3])) + + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] - this->kg[1]) + 4*pow(p0,2)*this->kg[1] + this->kg[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) - + 2*p0*this->q[0]*(-pow(this->q[1],3) + this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]) + + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(pow(this->q[0],4)*this->q[1] - this->q[0] * this->q[0]*pow(this->q[1],3) + this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] + this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] - 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + + 2*pow(this->q[1],3)*this->kg[1] * this->kg[1] - 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) + + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] - pow(this->q[1],3)*this->kg[2] * this->kg[2] - 3*this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] - + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 3*this->q[0] * this->q[0]*this->q[1]*this->q[3]*this->kg[3] + pow(this->q[1],3)*this->q[3]*this->kg[3] + this->q[1]*pow(this->q[3],3)*this->kg[3] - + 2*this->q[0] * this->q[0]*this->q[3]*this->kg[1]*this->kg[3] + 4*this->q[1] * this->q[1]*this->q[3]*this->kg[1]*this->kg[3] - 2*this->q[1]*this->q[3]*this->kg[2] * this->kg[2]*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) - this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(pow(this->q[1],3) + 3*this->q[1] * this->q[1]*this->kg[1] - 2*this->q[0] * this->q[0]*(this->q[1] + 2*this->kg[1]) + + this->q[1]*(this->q[3] * this->q[3] + this->kg[1] * this->kg[1] - 2*this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]) + this->kg[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->kg[3]*(this->q[3] + this->kg[3])))))) + )/(24.*mDelta2*pow(this->mn,4)); + + + tr[3][0] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(-p0 + this->q[0]) + + 2*mDelta*this->mn*(p0 - this->q[0])*(8*this->mn2 - 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 4*this->mn2*(p0 - this->q[0])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta2*(-8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 8*this->mn2*(2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 2*p0*(-2*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->q[3] + + 4*pow(mDelta,3)*(this->q[3]*(4*p0*this->q[0] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*this->kg[1]*this->kg[3]) + + 4*this->mn*(p0 - this->q[0])*(-4*pow(p0,2)*this->q[0]*this->q[3] + 8*p0*this->q[0] * this->q[0]*this->q[3] - 3*pow(this->q[0],3)*this->q[3] - + 2*p0*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[0]*this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + + 2*p0*this->q[1]*this->kg[1]*this->kg[3] + this->q[0]*(this->q[1] * this->q[1] + 2*this->q[3] * this->q[3] - this->q[1]*this->kg[1])*this->kg[3]) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[3] + 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->q[3] - 3*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + 3*this->q[1]*this->kg[1]*this->kg[3]) + + (this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*this->kg[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*this->q[0]*(-3*this->q[0] * this->q[0]*this->q[3] + this->q[1]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + this->q[1] * this->q[1]*(this->q[3] + this->kg[3]) + + this->q[3]*(3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][1] = (C3v*(this->c_i*C5aNC*this->kg[2]*(-2*this->mn2*this->q[1]*(this->q[1] + this->kg[1])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[3]*(this->q[3] + this->kg[3])) + + mDelta*this->mn*(4*pow(p0,2)*this->q[0] * this->q[0] - 6*p0*pow(this->q[0],3) + 2*pow(this->q[0],4) + 4*p0*this->q[0]*this->q[3] * this->q[3] - + this->q[0] * this->q[0]*this->q[3] * this->q[3] + this->q[1] * this->q[1]*this->q[3] * this->q[3] + pow(this->q[3],4) + 2*p0*this->q[0]*this->q[1]*this->kg[1] - 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] + + 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[3]*(6*p0*this->q[0] - 5*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + mDelta2*(8*pow(p0,3)*this->q[0] + 8*this->mn2*(4*pow(p0,2) - 2*p0*this->q[0] - this->q[1]*this->kg[1]) + + 2*p0*this->q[0]*(2*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + this->kg[3])) + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[3]*(this->q[3] + this->kg[3])) + + this->q[1]*(this->q[0] * this->q[0]*(-this->q[1] + this->kg[1]) + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(-p0 + this->q[0])*this->q[3]*this->kg[1] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*this->q[3] - 4*p0*this->q[3]*this->kg[1] + this->q[0]*this->kg[1]*(-2*this->q[3] + this->kg[3])) - + 4*this->mn*(p0 - this->q[0])*(2*p0*this->q[0]*(this->q[1]*this->q[3] + this->kg[1]*(2*this->q[3] + this->kg[3])) - this->q[0] * this->q[0]*(this->q[1]*(this->q[3] - this->kg[3]) + this->kg[1]*(2*this->q[3] + this->kg[3])) + + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + 3*this->kg[1]*this->kg[3]) + + this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])*(this->q[1]*this->q[3] + this->kg[1]*(-2*this->q[3] + this->kg[3])) - + 4*p0*(this->q[0] * this->q[0]*(-3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + this->q[1]*this->kg[3] - 3*this->kg[1]*this->kg[3]) + + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[3] + 4*pow(mDelta,3)*(4*p0*this->q[3] + 2*this->q[0]*this->q[3] - this->q[0]*this->kg[3]) + + 4*this->mn*(p0 - this->q[0])*(this->q[3]*(4*p0*this->q[0] - 2*this->q[0] * this->q[0] + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1])) + + (2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[3] * this->q[3])*this->kg[3]) + + mDelta*(4*pow(p0,2)*this->q[0]*(2*this->q[3] + 3*this->kg[3]) + this->q[0]*(2*this->q[3] - this->kg[3])* + (-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*(this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[3] + 2*this->kg[3])))) - + this->c_i*C5aNC*(2*this->mn2*this->q[1]*this->kg[2] * this->kg[2]*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2*this->kg[1] + 2*p0*this->q[0]*this->kg[1] - 2*this->q[0] * this->q[0]*this->kg[1] + this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + + this->q[1]*this->kg[1] * this->kg[1] + this->q[1]*this->kg[2] * this->kg[2] + this->q[3]*this->kg[1]*this->kg[3]) + + mDelta2*(8*pow(p0,3)*this->q[0]*this->kg[1] + this->q[1]*(-this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] - this->kg[1]) + 4*pow(p0,2)*this->kg[1] + this->q[1]*this->kg[2] * this->kg[2]) + + 4*pow(p0,2)*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3])) - + 2*p0*this->q[0]*(-pow(this->q[1],3) + 2*this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3]) - + this->q[1]*(-this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(4*pow(this->q[0],4)*this->q[1] - 2*this->q[0] * this->q[0]*pow(this->q[1],3) - 2*this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 5*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] - this->q[0] * this->q[0]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + pow(this->q[3],4)*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + 3*pow(this->q[1],3)*this->kg[1] * this->kg[1] + 3*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + + 2*this->q[1] * this->q[1]*pow(this->kg[1],3) - 2*this->q[3] * this->q[3]*pow(this->kg[1],3) + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) - + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] + pow(this->q[1],3)*this->kg[2] * this->kg[2] + this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[1]*this->kg[2] * this->kg[2] + + this->q[3]*(-(this->q[0] * this->q[0]*(2*this->q[1] + 5*this->kg[1])) + this->kg[1]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 4*this->q[1]*this->kg[1]) + 2*this->q[1]*this->kg[2] * this->kg[2])*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) - this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(pow(this->q[1],3) + 3*this->q[1] * this->q[1]*this->kg[1] - this->q[0] * this->q[0]*(4*this->q[1] + 3*this->kg[1]) + this->q[3]*this->kg[1]*(2*this->q[3] + 3*this->kg[3]) + + this->q[1]*(3*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][3] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[3] + this->kg[3]) + + 2*this->mn2*(this->q[3] + this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[3] + this->kg[3])*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(-(this->q[1]*this->q[3]*this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - this->kg[3]) + 8*this->mn2*this->kg[3] + 2*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3] + + 4*pow(p0,2)*(this->q[3] + this->kg[3]))) + 2*C3vNC*this->mn* + (16*mDelta2*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) + + 4*pow(mDelta,3)*(4*p0*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) + this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 3*pow(this->q[0],4) + + 2*p0*this->q[0]*(-4*this->q[0] * this->q[0] + pow(this->q[1] + this->kg[1],2) + this->kg[2] * this->kg[2]) - + this->q[0] * this->q[0]*(this->q[3] * this->q[3] + (this->q[1] + this->kg[1])*(2*this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (8*this->q[0] * this->q[0] - 3*this->q[1] * this->q[1] - 2*this->q[1]*this->kg[1] - 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + + this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*(3*pow(this->q[0],4) - this->q[0] * this->q[0]*(4*this->q[1] * this->q[1] - this->q[1]*this->kg[1] + 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3])))))))/ + (24.*mDelta2*pow(this->mn,4)); + +} + +double Hadronic_Current_R_Delta::qcm(double s) { +// Returns the 3-momentum of the pion formed after the decay of a +// resonance (R->N pi) of inv. mass s in the rest frame of the resonance + return sqrt((s-this->mpi2-this->mn2)*(s-this->mpi2-this->mn2) - 4.0 * this->mpi2 * this->mn2)/2.0/sqrt(s); +} + +std::complex Hadronic_Current_R_Delta::getR(int i, int j) { + std::complex tr_p = this->tr_p_dir[i][j]*this->propagator_dir_p + + this->tr_p_crs[i][j]*this->propagator_crs_p; + std::complex tr_n = this->tr_n_dir[i][j]*this->propagator_dir_n + + this->tr_n_crs[i][j]*this->propagator_crs_n; + + return (tr_p * this->N_FF_p + tr_n * this->N_FF_n) * this->mn / this->p0 / 2.0; //Factor 1/2 from the trace, see notes +} + +void Hadronic_Current_R_Delta::setP(std::vector p_in) { + this->p = p_in; + this->p0 = p_in[0]; + + double aux_pp[] = {p_in[0], -p_in[1], -p_in[2], -p_in[3]}; + this->pp.assign(aux_pp, aux_pp + sizeof(aux_pp) / sizeof(double) ); + + this->p_dir = this->p; + std::transform(this->p_dir.begin( ), this->p_dir.end( ), this->q.begin( ), this->p_dir.begin( ),std::plus( )); + + this->p_crs = this->pp; + std::transform(this->p_crs.begin( ), this->p_crs.end( ), this->q.begin( ), this->p_crs.begin( ),std::minus( )); +} + +std::complex Hadronic_Current_R_Delta::Propagator_Delta(std::vector p_in) { + double p2 = p_in[0] * p_in[0] - p_in[1] * p_in[1] - p_in[2] * p_in[2] - p_in[3] * p_in[3]; + + std::vector > param(2); + param[0] = p2; + param[1] = this->q_minus_kg; + this->propagator->change_other_parameters(param); + + if (this->dir_or_crs == "dir") { + this->propagator->setNucleon("p"); + this->propagator_dir_p = this->propagator->Delta_propagator_avg_dir(); + this->propagator->setNucleon("n"); + this->propagator_dir_n = this->propagator->Delta_propagator_avg_dir(); + } else if (this->dir_or_crs == "crs") { + this->propagator->setNucleon("p"); + this->propagator_crs_p = this->propagator->Delta_propagator_crs(); + this->propagator->setNucleon("n"); + this->propagator_crs_n = this->propagator->Delta_propagator_crs(); + } + + return 0; +} + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + + diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Hadronic_Current_R.h b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Hadronic_Current_R.h new file mode 100644 index 000000000..c0f23a88e --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Hadronic_Current_R.h @@ -0,0 +1,221 @@ +// +// Created by edusaul on 11/03/19. +// + +#ifndef COHERENT_PHOTON_HADRONIC_CURRENT_R_H +#define COHERENT_PHOTON_HADRONIC_CURRENT_R_H + +#include +#include +#include "NCgamma_Form_Factors.h" + + + +namespace NC_gamma { + + class Delta_in_medium { + protected: + std::string nucleon; + std::string dir_or_crs; + double p; + double p2; + double q_minus_kg; + double qcm; + double mDelta; + double mDelta2; + double mn; + double mn2; + double mpi; + double V0; + double rho0; + double coupling_DeltaNpi; + std::complex c_i; + double hc3; + + double gamma_vac; + double rho_r; + + double rho_avg; // average density in units of rho0 + std::complex propagator_avg; + + std::complex propagator_crs; + + public: + + Delta_in_medium(); + + virtual ~Delta_in_medium(); + + void setNucleon(const std::string &n); + + virtual std::complex Delta_propagator_dir(double); + + virtual std::complex Delta_propagator_crs(); + + void change_other_parameters(std::vector >); + + std::complex Sigma(); + + double Gamma_tilde_Delta(double); + + double Gamma_vacuum(double); + + double I_series(double); + + double lambda_func(double, double, double); + + double kf(double); + + void setDirOrCrs(const std::string &dirOrCrs); + + std::complex Delta_propagator_avg_dir(); + + }; + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + + class Hadronic_Current_R { + protected: + std::complex c_i; + + std::vector q; + std::vector kg; + std::vector p; + std::vector pp; + double p0; + + typedef std::complex Array4x4[4][4]; + + Array4x4 tr_p_dir; + Array4x4 tr_p_crs; + Array4x4 tr_n_dir; + Array4x4 tr_n_crs; + + virtual void set_tr_dir(Array4x4 &); + + virtual void set_tr_crs(Array4x4 &); + + public: + + explicit Hadronic_Current_R(); + + virtual void setQ(const std::vector &q_in); + + virtual void setKg(const std::vector &kg_in); + + virtual void setP(std::vector); + + virtual std::complex getR(int, int); + + virtual void setFF(double); + + virtual ~Hadronic_Current_R(); + }; + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + class Hadronic_Current_R_Sum : public Hadronic_Current_R { + protected: + std::vector vector_of_currents; + + public: + explicit Hadronic_Current_R_Sum(const std::vector &vectorOfCurrents); + + virtual void setQ(const std::vector &q); + + virtual void setKg(const std::vector &kg); + + virtual void setP(std::vector); + + virtual std::complex getR(int, int); + + virtual void setFF(double); + + }; + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + class Hadronic_Current_R_Delta : public Hadronic_Current_R { + protected: + Form_Factors_Delta *ff_Delta; + + double mn; + double mn2; + double mDelta; + double mDelta2; + double mpi; + double mpi2; + std::complex c_i; + double q_minus_kg; + + double C3v; + double C4v; + double C5v; + double C3vNC; + double C4vNC; + double C5vNC; + double C3aNC; + double C4aNC; + double C5aNC; + double C6aNC; + + std::complex N_FF_p; + std::complex N_FF_n; + + std::complex propagator_dir_p; + std::complex propagator_crs_p; + std::complex propagator_dir_n; + std::complex propagator_crs_n; + + std::vector p_dir; + std::vector p_crs; + + Delta_in_medium *propagator; + std::string dir_or_crs; + + Nuclear_FF *nuclearFF; + + + virtual void set_tr_dir(Array4x4 &); + + virtual void set_tr_crs(Array4x4 &); + + public: + + explicit Hadronic_Current_R_Delta(Nuclear_FF *nuclearFf); + + virtual ~Hadronic_Current_R_Delta(); + + virtual void setFF(double); + + virtual void setKg(const std::vector &kg_in); + + std::complex Propagator_Delta(std::vector); + + double qcm(double); + + virtual std::complex getR(int, int); + + virtual void setP(std::vector); + + }; + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + +} + +#endif //COHERENT_PHOTON_HADRONIC_CURRENT_R_H diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Parameters_GeV.h b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Parameters_GeV.h new file mode 100644 index 000000000..b8e30aecc --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/NCgamma_Parameters_GeV.h @@ -0,0 +1,74 @@ +#ifndef _PARAMETERS_H_ +#define _PARAMETERS_H_ +#include +#include + +namespace NCgamma_Param +{ + + const std::complex c_i(0.0,1.0); + const double pi= 4.0*atan(1.0); + const double alpha= 1.0/137.0; + const double hc=0.19733; // (GeV x fm) + const double hccm=197.33e-16; // (GeV x cm) + const double Gf=1.16639e-5; // GeV^-2 + const double cosw2=0.23122; // Weak angle squared + const double sinw2=0.2223; + const double ga=1.2723; //from the PDG value for gA/gV (measured in beta decay: http://pdglive.lbl.gov/DataBlock.action?node=S017AV&init=0) using gV=1 as expected. + const double gas=0.15; + const double MA = 1.049; // GeV Axial mass + + //nuclear matter density (in fm^-3 * hc^3) + const double rho0=0.17 * hc*hc*hc; + + //lepton mases + const double me= 0.51099892e-3; //GeV + const double mmu= 0.1056583715; //GeV + + //messon mass + const double mpi=0.13957; //GeV + + //nucleon + const double mp= 0.93827203; //GeV + const double mn= 0.93827203; //GeV + const double mup = 1.7928; //proton anomalous magnetic moment + const double mun = -1.913; //neutron anomalous magnetic moment + //for the form factors: + const double lambdanN=5.6; + const double MD = 0.843; // GeV + + //barion mass + const double mLambda_1115= 1.115; //GeV + const double mSigma_1190= 1.197449; //GeV + const double mDelta= 1.232; //GeV + const double mN1440= 1.440; //GeV + const double mN1520= 1.515; //GeV + const double mN1535= 1.530; //GeV + + const double coupling_DeltaNpi= 2.14; + const double N_Delta_MA= 0.93; //GeV + const double Delta_V0= 0.08; //GeV + + //Carbon nucleus + const double AC= 12.0; + const double ZC= 6.0; + const double MC= 12.0*mp; + + //Powers + + const double hccm2= hccm*hccm; + const double Gf2=Gf*Gf; + const double mpi2=mpi*mpi; + const double mp2=mp*mp; + + //Delta FF parameters + const double parameter_001 = 0.01; //GeV^-2 + const double parameter_023 = 0.23; //GeV^-2 + const double parameter_071 = 0.71; //GeV^2 + const double parameter_093 = 0.93; //GeV^2 + const double parameter_03 = 0.3; //GeV^(-1/2) + + +} + +#endif diff --git a/src/contrib/coh_gamma/COHNCGamma_ext/main.cpp b/src/contrib/coh_gamma/COHNCGamma_ext/main.cpp new file mode 100644 index 000000000..52468a1d7 --- /dev/null +++ b/src/contrib/coh_gamma/COHNCGamma_ext/main.cpp @@ -0,0 +1,73 @@ +#include +#include +#include "NCgamma_Diff_Cross_Section.h" +#include "NCgamma_Parameters_GeV.h" + +using namespace NC_gamma; + +int main() { + + std::ofstream file; + file.open("/home/edusaul/Desktop/d5_Delta_avg.dat"); + + std::string nucleus = "12C"; + std::string mode = "nu"; + + Diff_Cross_Section cs(mode, nucleus); + + double k0 = 1.0; //GeV + double kg0 = 0.0;//0.3; //GeV + double phig = 10.0 * 3.14159/180.0;//* NCgamma_Param::pi/180; + double thetag = 10.0 * 3.14159/180.0;//* NCgamma_Param::pi/180; + double th = 10.0 * 3.14159/180.0;//* NCgamma_Param::pi/180; +// double Enu_final = 0.00525802;//k0 - kg0; + + int npts = 50; + double Enu_final_min = 0.0; + double Enu_final_max = k0; + double Enu_final = Enu_final_max; + + double diff_cs; + +// std::cout<<"k0 = "< (in_file.Get("header")); + + // Get the GENIE GHEP tree and set its branch address + TTree * in_tree = dynamic_cast (in_file.Get("gtree")); + NtpMCEventRecord * mcrec = 0; + in_tree->SetBranchAddress("gmcrec", & mcrec); + + + std::map hists ; + + // plots we need + TH1* h_theta_gamma = hists["theta_gamma"] = new TH1D("h_theta_gamma", "#theta_{#gamma};#theta_{#gamma} [rad]", + 80, 0., TMath::Pi() ) ; + TH1* h_theta_lep = hists["theta_lep"] = new TH1D("h_theta_lep", "#theta_{l};#theta_{l} [rad]", + 80, 0., TMath::Pi() ) ; + TH1* h_theta_recoil = hists["theta_nuc"] = new TH1D("h_theta_recoil", "#theta_{recoil};#theta_{recoil} [rad]", + 80, 0., TMath::Pi() ) ; + + TH1* h_phi_gamma = hists["phi_gamma"] = new TH1D("h_phi_gamma", "#phi_{#gamma};#phi_{#gamma} [rad]", + 100, -TMath::Pi(), TMath::Pi() ) ; + TH1* h_phi_lep = hists["phi_lep"] = new TH1D("h_phi_lep", "#phi_{l};#phi_{#phi} [rad]", + 100, -TMath::Pi(), TMath::Pi() ) ; + + TH1* h_E_l = hists["E_l"] = new TH1D("h_E_l", "E_{l};E_{l} [GeV]", + 80, 0., 2. ) ; + + TH1* h_E_g = hists["E_g"] = new TH1D("h_E_g", "E_{#gamma};E_{#gamma} [GeV]", + 80, 0., 2. ) ; + + + + + // Event loop + for(Long64_t i=0; i < in_tree->GetEntries(); i++) { + + in_tree->GetEntry(i); + + EventRecord & event = *(mcrec->event); + + const Interaction & inter = *( event.Summary() ) ; + + const ProcessInfo & proc_info = inter.ProcInfo() ; + + if ( proc_info.IsCoherentProduction() ) { + + const XclsTag & xcl_tag = inter.ExclTag() ; + + if ( xcl_tag.NSingleGammas() == 1 ) { + + TLorentzVector probe ( * event.Probe() -> P4() ) ; + TLorentzVector lep ( * event.FinalStatePrimaryLepton() -> P4() ) ; + TLorentzVector gamma ( * event.Particle(3) -> P4() ) ; + TLorentzVector recoil ( * event.Particle(4) -> P4() ) ; + + h_theta_gamma -> Fill( gamma.Angle( probe.Vect() ) ) ; + h_theta_lep -> Fill( lep.Angle( probe.Vect() ) ) ; + h_theta_recoil -> Fill( recoil.Angle( probe.Vect() ) ) ; + + h_phi_gamma -> Fill( GammaPhi( probe, gamma, lep ) ) ; + h_phi_lep -> Fill( LepPhi( probe, lep ) ) ; + + + h_E_l -> Fill( lep.E() ) ; + h_E_g -> Fill( gamma.E() ) ; + + } // single gamma + + } // coherent production + + mcrec->Clear() ; + } // event loop + + + TFile out_file ( out_file_name, "RECREATE" ) ; + out_file.cd() ; + + for ( auto & h : hists ) { + h.second -> Write() ; + delete h.second ; + } + +} + + + +double LepPhi( const TLorentzVector & probe, TLorentzVector lep ) { + + + TVector3 probe_dir = probe.Vect().Unit() ; + lep.RotateUz( probe_dir ) ; + return lep.Phi() ; + +} + +double GammaPhi( const TLorentzVector & probe, TLorentzVector gamma, TLorentzVector lep ) { + + TVector3 probe_dir = probe.Vect().Unit() ; + gamma.RotateUz( probe_dir ) ; + lep.RotateUz( probe_dir ) ; + + return gamma.DeltaPhi( lep ) ; + +} diff --git a/src/contrib/coh_gamma/event_valid.C b/src/contrib/coh_gamma/event_valid.C new file mode 100644 index 000000000..c2797e570 --- /dev/null +++ b/src/contrib/coh_gamma/event_valid.C @@ -0,0 +1,416 @@ +///////////////////////////////////////////////////////// +// +// To run use `genie -l event_valid.C` +// +// or `genie -l "event_valid.C( int nbins, TString input_file, TString output_file )"` +// - e.g: `genie -l "event_valid.C( 5, \"vmu_12c_1gev.root\", \"test.root\" )"` +// +// Parameters: +// +// Input file: in_file_name (line 76) +// Output file: out_file_name (line 77) +// +// Bin number: nbins (line 75) +// - bins for theta_l = theta_g = nbins +// - bins for phi_g = nbins * 2 +// - bins for E_g = nbins * 6 +// +// J. Sensenig 12/2020 +// +////////////////////////////////////////////////////// + +#include "TString.h" +#include "TFile.h" +#include "TTree.h" +#include "TH1.h" +#include "TH2.h" + +#include "Framework/Ntuple/NtpMCTreeHeader.h" +#include "Framework/Ntuple/NtpMCEventRecord.h" +#include "Framework/EventGen/EventRecord.h" +#include "Framework/ParticleData/BaryonResUtils.h" + +#include "Framework/GHEP/GHepParticle.h" +#include "Framework/ParticleData/PDGUtils.h" +#include "Framework/GHEP/GHepStatus.h" +#include "Framework/Conventions/Units.h" + +#include "Framework/ParticleData/PDGCodes.h" +#include "Framework/Algorithm/AlgConfigPool.h" +#include "Physics/XSectionIntegration/GSLXSecFunc.h" + + +using namespace genie ; + + +void SetValues( TTree * in_tree ) ; +void event_proc( TTree * in_tree, TFile & ofile ) ; +double LepPhi( const TLorentzVector & probe, TLorentzVector lep ) ; +double GammaPhi( const TLorentzVector & probe, TLorentzVector gamma, TLorentzVector lep ) ; +void GetLimits( std::pair &theta_l ) ; +void ComputeCOHGammXSec( double xsec, TH3 * h_Eg_thetag_phig ); +void GraphIntegratedCOHGammaXsec( int nbin, double nevts, double *xsec_i_arr, double *xsec_arr, double *eg_arr, double *x_err, double *y_err ); + +///////////////////// +// Global constants + +int g_nbins ; +double g_theta_l_width ; +double g_theta_l ; +double g_theta_g ; +double g_theta_g_max ; +double g_phi_g ; +double g_phi_g_max ; +double g_phi_g_min ; +double g_Ev ; +double g_Eg_max ; +double g_nevts; +int g_nu ; +int g_target ; +int g_min_number_of_events = 0; + +// COH Gamma xsec config set ("Default" or "Consistent") +std::string config = "Default" ; + + +void event_valid( int nbins = 10, //use 10 bins + TString in_file_name = "fixed_energy_file.gntp.root" , + TString out_file_name = "", + int min_number_of_events = 0, + std::string _config = "Default" + ) { + + config = _config ; + g_min_number_of_events = min_number_of_events ; + + g_nbins = nbins ; + + if ( out_file_name == "" ) { + out_file_name = in_file_name ; + out_file_name.ReplaceAll( ".ghep.root", ".evtplots.root" ) ; + } + + TFile in_file( in_file_name ) ; + + if ( !in_file.IsOpen() ) { + + std::cout << "File " << in_file_name << " not open! Exiting!" << std::endl ; + return ; + + } + + TFile out_file ( out_file_name, "RECREATE" ) ; + out_file.cd() ; + + // Get the GENIE GHEP tree and set its branch address + TTree * in_tree = dynamic_cast (in_file.Get("gtree")); + + std::cout << "Extracting and setting values" << std::endl; + + // Get the data ranges + SetValues( in_tree ) ; + + int loop_cnt = 0; + + for ( int i = 0; i < g_nbins; i++ ) { // theta_l + + loop_cnt += 1; + std::cout << "Loop " << loop_cnt << "/" << g_nbins << " with theta_l = " << g_theta_l << std::endl; + + event_proc( in_tree, out_file ) ; + g_theta_l += g_theta_l_width ; + + } + + out_file.Close() ; +} + +void SetValues( TTree * in_tree ) { + + // Grab interaction details from first event + NtpMCEventRecord * mcrec = 0; + in_tree->SetBranchAddress("gmcrec", & mcrec); + in_tree->GetEntry(0); + EventRecord & event = *(mcrec->event); + + g_nu = event.Probe() -> Pdg() ; + g_Ev = event.Probe() -> E() ; + g_target = event.Particle(4) -> Pdg() ; + + mcrec->Clear(); + + double Eg_max = 0. ; + double theta_l_max = 0. ; + double theta_g_max = 0. ; + double phi_g_max = 0. ; + double phi_g_min = 0. ; + + // Get the max/min limits from the data + for(Long64_t i=0; i < in_tree->GetEntries(); i++) { + + in_tree->GetEntry(i); + EventRecord & event = *(mcrec->event); + + const Interaction & inter = *( event.Summary() ) ; + const ProcessInfo & proc_info = inter.ProcInfo() ; + + if ( proc_info.IsCoherentProduction() ) { + const XclsTag & xcl_tag = inter.ExclTag() ; + + if ( xcl_tag.NSingleGammas() == 1 ) { + TLorentzVector probe ( * event.Probe() -> P4() ) ; + TLorentzVector lep ( * event.FinalStatePrimaryLepton() -> P4() ) ; + TLorentzVector gamma ( * event.Particle(3) -> P4() ) ; + + double Eg = gamma.E() ; + double theta_l = lep.Angle( probe.Vect() ) ; + double theta_g = gamma.Angle( probe.Vect() ) ; + double phi_g = GammaPhi( probe, gamma, lep ) ; + + if ( Eg > Eg_max ) Eg_max = Eg ; + if ( theta_l > theta_l_max ) theta_l_max = theta_l ; + if ( theta_g > theta_g_max ) theta_g_max = theta_g ; + if ( phi_g > phi_g_max ) phi_g_max = phi_g ; + if ( phi_g < phi_g_min ) phi_g_min = phi_g ; + + } + } + mcrec->Clear(); + } + + // Long tail avoid for now + if ( theta_l_max > TMath::PiOver2() ) theta_l_max = TMath::PiOver2() ; + if ( theta_g_max > TMath::PiOver2() ) theta_g_max = TMath::PiOver2() ; + + std::cout << " Ev = " << g_Ev + << " Probe = " << g_nu + << " Target = " << g_target << std::endl; + + std::cout << " Eg max = " << Eg_max + << " theta_l max = " << theta_l_max + << " theta_g max = " << theta_g_max + << " phi_g max = " << phi_g_max + << " phi_g min = " << phi_g_min << std::endl; + + g_theta_l_width = theta_l_max / g_nbins ; + g_theta_l = g_theta_l_width ; + g_theta_g_max = theta_g_max; + g_phi_g_max = phi_g_max; + g_phi_g_min = phi_g_min; + g_Eg_max = Eg_max ; + +} + + + +void event_proc( TTree * in_tree, TFile & ofile ) { + + std::pair theta_l_lim ; + + GetLimits( theta_l_lim ) ; + + NtpMCEventRecord * mcrec = 0; + in_tree->SetBranchAddress("gmcrec", & mcrec); + + TH3* h_Eg_thetag_phig = new TH3D("h_Eg_thetag_phig", "E_{#gamma} #theta_{#gamma} #phi_{#gamma};E_{#gamma} [GeV];#theta_{#gamma} [rad];#phi_{#gamma} [rad]", + (g_nbins*6), 0., g_Eg_max, g_nbins, 0, g_theta_g_max, (g_nbins*2), g_phi_g_min, g_phi_g_max ) ; + + g_nevts = in_tree->GetEntries() ; + size_t evts = 0; + double xsec ; + + // Event loop + for(Long64_t i=0; i < in_tree->GetEntries(); i++) { + + in_tree->GetEntry(i); + + EventRecord & event = *(mcrec->event); + + const Interaction & inter = *( event.Summary() ) ; + + const ProcessInfo & proc_info = inter.ProcInfo() ; + + if ( proc_info.IsCoherentProduction() ) { + + const XclsTag & xcl_tag = inter.ExclTag() ; + + if ( xcl_tag.NSingleGammas() == 1 ) { + + TLorentzVector probe ( * event.Probe() -> P4() ) ; + TLorentzVector lep ( * event.FinalStatePrimaryLepton() -> P4() ) ; + TLorentzVector gamma ( * event.Particle(3) -> P4() ) ; + TLorentzVector recoil ( * event.Particle(4) -> P4() ) ; + + double theta_l = lep.Angle( probe.Vect() ) ; + double theta_g = gamma.Angle( probe.Vect() ) ; + double phi_g = GammaPhi( probe, gamma, lep ) ; + + // Follow the ROOT histogram convection of bin lower limit inclusive upper limit exclusive + if ( theta_l <= theta_l_lim.first || theta_l > theta_l_lim.second ) { mcrec->Clear(); continue; } + + h_Eg_thetag_phig -> Fill( gamma.E(), theta_g, phi_g ) ; + + xsec = event.XSec()/(1.e-38 * units::cm2) ; + + } // single gamma + + } // coherent production + + mcrec->Clear() ; + } // event loop + + ComputeCOHGammXSec( xsec, h_Eg_thetag_phig ) ; + + h_Eg_thetag_phig -> Write(); + + std::cout << "Processed " << g_nevts << " events." << std::endl; + + delete h_Eg_thetag_phig ; + + return ; + +} + +double LepPhi( const TLorentzVector & probe, TLorentzVector lep ) { + + TVector3 probe_dir = probe.Vect().Unit() ; + lep.RotateUz( probe_dir ) ; + return lep.Phi() ; + +} + +double GammaPhi( const TLorentzVector & probe, TLorentzVector gamma, TLorentzVector lep ) { + + TVector3 probe_dir = probe.Vect().Unit() ; + gamma.RotateUz( probe_dir ) ; + lep.RotateUz( probe_dir ) ; + + return gamma.DeltaPhi( lep ) ; + +} + + +void GetLimits( std::pair &theta_l ) { + + theta_l = std::make_pair( g_theta_l - (g_theta_l_width/2.), g_theta_l + (g_theta_l_width/2.) ) ; + +} + + +void ComputeCOHGammXSec( double xsec, TH3 * h_Eg_thetag_phig ) { + + // -- request the COH NC Gamma mode + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("AlvarezRusoSalaCOHGammaPXSec",config) ; + const Algorithm * algXsec = algf->GetAlgorithm(id); + const XSecAlgorithmI * fXSec = dynamic_cast(algXsec); + + Interaction * in = Interaction::COHNC(g_target, g_nu, 22, g_Ev); + utils::gsl::d4Xsec_dEgdThetaldThetagdPhig func = utils::gsl::d4Xsec_dEgdThetaldThetagdPhig( fXSec, in ) ; + + int nbins_Eg = h_Eg_thetag_phig -> GetNbinsX(); // X = E_g + int nbins_thetag = h_Eg_thetag_phig -> GetNbinsY(); // Y = theta_g + int nbins_phig = h_Eg_thetag_phig -> GetNbinsZ(); // Z = phi_g + + std::cout << "Processing Eg bins " << nbins_Eg << " theta_g bins " << nbins_thetag << " phi_g bins " << nbins_phig << std::endl; + + // Loop over bins on each axis ignoring the under/over flow bins + for ( int b_theta = 1; b_theta < (nbins_thetag+1); b_theta++ ) { // theta_g + for ( int b_phi = 1; b_phi < (nbins_phig+1); b_phi++ ) { // phi_g + + double theta_g = h_Eg_thetag_phig -> GetYaxis() -> GetBinCenter( b_theta ); + double theta_g_width = h_Eg_thetag_phig -> GetYaxis() -> GetBinWidth( b_theta ); + double phi_g = h_Eg_thetag_phig -> GetZaxis() -> GetBinCenter( b_phi ); + double phi_g_width = h_Eg_thetag_phig -> GetZaxis() -> GetBinWidth( b_phi ); + + double xsec_i_arr[nbins_Eg]; + double xsec_arr[nbins_Eg]; + double eg_arr[nbins_Eg]; + double x_err[nbins_Eg]; + double y_err[nbins_Eg]; + + // Project out Eg so we can get the bin error + TH1D * h_E_g = h_Eg_thetag_phig -> ProjectionX( "h_E_g", b_theta, b_theta, b_phi, b_phi, "e" ); + + double cnt = 0; + + for ( int b = 1; b < (nbins_Eg+1); b++ ) { // E_g + + double Eg = h_Eg_thetag_phig -> GetXaxis() -> GetBinCenter( b ); + double Eg_width = h_Eg_thetag_phig -> GetXaxis() -> GetBinWidth( b ); + double Ni = h_Eg_thetag_phig -> GetBinContent( b, b_theta, b_phi ); + + // Calculate xsec from events + xsec_i_arr[b-1] = ( 1.e3 ) * xsec * ( Ni / g_nevts ) / ( Eg_width * g_theta_l_width * theta_g_width * phi_g_width ); + + x_err[b-1] = Eg_width / 2.; + y_err[b-1] = ( xsec_i_arr[b-1] / Ni ) * h_E_g -> GetBinError( b ); + + // Get the xsec from the functor at given 4d point + std::array point = {Eg, g_theta_l, theta_g, phi_g}; + xsec_arr[b-1] = ( 1.e3 ) * func( point.data() ) ; + + eg_arr[b-1] = Eg; + + cnt += Ni; + + } // E_g + + if ( cnt < 1 ) continue; // Skip plotting if no events in bin + + g_theta_g = theta_g; g_phi_g = phi_g; + GraphIntegratedCOHGammaXsec( nbins_Eg, cnt, xsec_i_arr, xsec_arr, eg_arr, x_err, y_err ); + + } // phi_g + } // theta_g + +} + + +void GraphIntegratedCOHGammaXsec( int nbin, double nevts, double *xsec_i_arr, double *xsec_arr, double *eg_arr, double *x_err, double *y_err ) { + + + if ( nevts < g_min_number_of_events ) return ; + + auto evt_xsec = new TGraphErrors( nbin, eg_arr, xsec_i_arr, x_err, y_err); + evt_xsec -> SetLineColor(1); evt_xsec -> SetLineWidth(1); evt_xsec -> SetMarkerStyle(8); evt_xsec -> SetMarkerSize(0.5); + + auto func_xsec = new TGraph( nbin, eg_arr, xsec_arr ); + func_xsec -> SetLineColor(2); func_xsec -> SetLineWidth(1); func_xsec -> SetMarkerStyle(8); func_xsec -> SetMarkerSize(0.3); + + TParticlePDG * tprobe = PDGLibrary::Instance() -> Find( g_nu ) ; + TParticlePDG * ttgt = PDGLibrary::Instance() -> Find( g_target ) ; + + stringstream description ; + + description << g_Ev << " GeV #" << tprobe -> GetTitle() << " on " << ttgt -> GetTitle() ; + description << " #theta_{l}=" << (int)( TMath::RadToDeg()*g_theta_l ) << "#circ" ; + description << " #theta_{#gamma}=" << (int)( TMath::RadToDeg()*g_theta_g ) << "#circ" ; + description << " #phi_{#gamma}=" << (int)( TMath::RadToDeg()*g_phi_g ) << "#circ" ; + description << " (" << nevts << "/" << g_nevts << " evts)" ; + description << ";E_{#gamma} [GeV];#frac{d^{4}#sigma}{dE_{#gamma}d#theta_{l}d#Omega_{#gamma}} [10^{-41} #frac{cm^{2}}{GeV}]" ; + + std::string evt_title = "Event #sigma: " + description.str() ; + std::string func_title = "Functor #sigma: " + description.str() ; + std::string sigma_title = "#sigma: " + description.str() ; + + evt_xsec -> SetTitle( evt_title.c_str() ); + func_xsec -> SetTitle( func_title.c_str() ); + + stringstream mg_descrip ; + mg_descrip << "xsec_angles_" << (int)( g_theta_l*TMath::RadToDeg() ) + << "_" << (int)( g_theta_g*TMath::RadToDeg() ) + << "_" << (int)( g_phi_g*TMath::RadToDeg() ) ; + std::string mg_name = mg_descrip.str() ; + + auto mg = new TMultiGraph(); + mg -> Add( func_xsec ) ; + mg -> Add( evt_xsec ) ; + mg -> SetTitle( sigma_title.c_str() ); + mg -> Write( mg_name.c_str() ) ; + + return ; + +} + + diff --git a/src/contrib/coh_gamma/formfactor_test.C b/src/contrib/coh_gamma/formfactor_test.C new file mode 100644 index 000000000..1d0ab5d23 --- /dev/null +++ b/src/contrib/coh_gamma/formfactor_test.C @@ -0,0 +1,114 @@ + +#include "TString.h" +#include "TFile.h" +#include "TTree.h" +#include "TH1.h" +#include "TH2.h" +#include "TGraph.h" + +#include "Framework/Algorithm/AlgFactory.h" +#include "Framework/Algorithm/Algorithm.h" +#include "Physics/Coherent/XSection/COHFormFactorI.h" + +#include "Framework/Ntuple/NtpMCTreeHeader.h" +#include "Framework/Ntuple/NtpMCEventRecord.h" +#include "Framework/EventGen/EventRecord.h" +#include "Framework/ParticleData/BaryonResUtils.h" + +#include "Framework/GHEP/GHepParticle.h" +#include "Framework/ParticleData/PDGUtils.h" +#include "Framework/ParticleData/PDGLibrary.h" +#include "Framework/GHEP/GHepStatus.h" + +#include "Framework/ParticleData/PDGCodes.h" + +using namespace genie ; + + +void formfactor_test( std::string algo_name = "genie::DeVriesFormFactorMap" , + std::string algo_par_set = "Default", + TString out_file_name = "" ) { + + if ( out_file_name == "" ) { + + std::string name = algo_name.substr( algo_name.find("::") + 2 ) ; + name += "_ff_graphs.root" ; + + out_file_name = name.c_str() ; + + } + + std::map proton_graphs, neutron_graphs ; // int = pdg + + AlgId id( algo_name, algo_par_set ); + const Algorithm * algo = AlgFactory::Instance()->GetAlgorithm( id ) ; + + std::cout << algo << std::endl ; + + const COHFormFactorI * form_factor = dynamic_cast( algo ) ; + + std::cout << form_factor << std::endl ; + + for ( unsigned int z = 1 ; z < 100 ; ++z ) { // a better limit coudl be nice, don't even know what z is + for ( unsigned int n = z/2 ; n <= 2*z ; ++n ) { + + int pdg = pdg::IonPdgCode( n+z, z ) ; + + TParticlePDG * pdg_particle = PDGLibrary::Instance() -> Find( pdg ) ; + if ( ! pdg_particle ) continue ; + + if ( form_factor -> HasNucleus( pdg ) ) { + + std::cout << "FF Has Nucleus " << pdg << std::endl; + Range1D_t q_range = form_factor -> QRange( pdg ) ; + + int nQ = 200; + double Q = q_range.min; + double ff_p_arr[nQ]; + double ff_n_arr[nQ]; + double Q_arr[nQ]; + + double delta_q = (q_range.max - q_range.min ) / (nQ-1) ; + + for ( int Qstep = 0; Qstep < nQ; Qstep++ ) { + ff_p_arr[Qstep] = form_factor -> ProtonFF( Q, pdg ) ; + ff_n_arr[Qstep] = form_factor -> NeutronFF( Q, pdg ) ; + Q_arr[Qstep] = Q; + Q += delta_q ; + } + + std::string nucleus( pdg_particle -> GetTitle() ) ; + std::string p_title = "Proton Form Factor for " + nucleus + ";Q [GeV];FF"; + std::string n_title = "Neutron Form Factor for " + nucleus + ";Q [GeV];FF"; + + proton_graphs[pdg] = new TGraph( nQ, Q_arr, ff_p_arr ); + proton_graphs[pdg]->SetName( ("proton_FF_" + nucleus).c_str() ); + proton_graphs[pdg]->SetTitle( p_title.c_str() ); + + neutron_graphs[pdg] = new TGraph( nQ, Q_arr, ff_n_arr ); + neutron_graphs[pdg]->SetName( ("neutron_FF_" + nucleus).c_str() ); + neutron_graphs[pdg]->SetTitle( n_title.c_str() ); + + } + } + } + + + TFile out_file ( out_file_name, "RECREATE" ) ; + out_file.cd() ; + + for ( auto & g : proton_graphs ) { + g.second -> Write() ; + delete g.second ; + } + + for ( auto & g : neutron_graphs ) { + g.second -> Write() ; + delete g.second ; + } + + +} + + + diff --git a/src/contrib/test/COHNCGamma_ext/CMakeLists.txt b/src/contrib/test/COHNCGamma_ext/CMakeLists.txt new file mode 100644 index 000000000..3f5490b7c --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.14) +project(Genie_XSection) + +set(CMAKE_CXX_STANDARD) + +add_library(Genie_XSection SHARED NCgamma_Diff_Cross_Section.cpp NCgamma_Diff_Cross_Section.h NCgamma_Form_Factors.h NCgamma_Form_Factors.cpp NCgamma_Hadronic_Current_R.h NCgamma_Hadronic_Current_R.cpp) + diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Diff_Cross_Section.cpp b/src/contrib/test/COHNCGamma_ext/NCgamma_Diff_Cross_Section.cpp new file mode 100644 index 000000000..2c99663f3 --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Diff_Cross_Section.cpp @@ -0,0 +1,183 @@ +// +// Created by edusaul on 23/04/19. +// + +#include +#include "NCgamma_Diff_Cross_Section.h" +#include "NCgamma_Form_Factors.h" +#include "NCgamma_Parameters_GeV.h" +#include +#include +#include + +using namespace NC_gamma; + +Diff_Cross_Section::Diff_Cross_Section(const std::string &m, const std::string &n) : mode(m), + nucleus(n) { + this->c_i = NCgamma_Param::c_i; + double e2 = 4.0 * NCgamma_Param::pi * NCgamma_Param::alpha; + + // The factor 2*pi of the phi_l integral is taken off, so none integral has been performed to this point +// this->constant_factors = NCgamma_Param::Gf2 * e2 / (2.0 * 8.0 * pow(2.0*NCgamma_Param::pi,4) );// * NCgamma_Param::hccm2; + this->constant_factors = NCgamma_Param::Gf2 * e2 / (2.0 * 8.0 * pow(2.0*NCgamma_Param::pi,5) );// * NCgamma_Param::hccm2; + + this->nuclearFF = new Nucleus_FF_DeVries(nucleus); + this->vector_of_currents.push_back(new Hadronic_Current_R_Delta(nuclearFF)); + this->current_R = new Hadronic_Current_R_Sum(this->vector_of_currents); +} + + +Diff_Cross_Section::~Diff_Cross_Section() { + delete this->nuclearFF; + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + delete this->vector_of_currents[i]; + } + delete this->current_R; +} + +double Diff_Cross_Section::getDiffCrossSection(double Enu, double Enu_final, double theta_l, double theta_g, double phi_g) { + double Eg = Enu - Enu_final; + + double params_aux[]= {Enu, Eg, phi_g, theta_g}; + std::vector param (params_aux, params_aux + sizeof(params_aux) / sizeof(double) ); + + this->change_other_parameters(param); + + double cs =this->integrand(theta_l); + + if(std::isnan(cs)) return 0.0; + else return cs; +} + + + +double Diff_Cross_Section::integrand(double th) { + + double kp_aux[] = {kp0, kp0 * sin(th), 0., kp0 * cos(th)}; + this->kp.assign(kp_aux, kp_aux + sizeof(kp_aux) / sizeof(double) ); + + this->q = this->k; + std::transform(q.begin( ), q.end( ), kp.begin( ), q.begin( ),std::minus( )); + + this->current_R->setQ(this->q); + + double kg_aux[] = {this->k0g, this->k0g * sin(this->thg) * cos(this->phig), + this->k0g * sin(this->thg) * sin(this->phig), this->k0g * cos(this->thg)}; + this->kg.assign(kg_aux, kg_aux + sizeof(kg_aux) / sizeof(double) ); + + std::vector p(this->kg.size()); + for (int j = 0; j < static_cast(this->kg.size()); ++j) { + p[j] = (this->kg[j] - this->q[j])/2.0; + } + + double pv2 = p[1]*p[1] + p[2]*p[2] + p[3]*p[3]; + p[0] = sqrt(NCgamma_Param::mp2 + pv2); + + this->current_R->setP(p); + this->current_R->setKg(this->kg); + + double lh; + if(this->mode == "nu") lh = this->LH_contraction_neutrino(); + else lh = this->LH_contraction_antineutrino(); + + return lh*this->constant_factors*this->factors; +} + +void Diff_Cross_Section::change_other_parameters(std::vector k0_k0g_phig_thg) { + this->k0 = k0_k0g_phig_thg[0]; + this->k0g = k0_k0g_phig_thg[1]; + this->phig = k0_k0g_phig_thg[2]; + this->thg = k0_k0g_phig_thg[3]; + + //q0 = k0g approx + this->kp0 = k0 - this->k0g; + + double k_aux[] = {k0, 0., 0., k0}; + this->k.assign(k_aux, k_aux + sizeof(k_aux) / sizeof(double) ); + + this->factors = this->k0g * (this->k0-this->k0g) /this->k0; + +} + +double Diff_Cross_Section::LH_contraction_neutrino() { + std::complex lh = -8*k[0]*((2*k[0] - this->q[0] - this->q[3])*H(0,0,0,0) + this->q[1]*H(0,0,0,1) - this->c_i*this->q[1]*H(0,0,0,2) + + (-2*k[0] + this->q[0] + this->q[3])*H(0,0,0,3) + this->q[1]*H(0,1,0,0) + (-this->q[0] + this->q[3])*H(0,1,0,1) + + this->c_i*(this->q[0] - this->q[3])*H(0,1,0,2) - this->q[1]*H(0,1,0,3) + this->c_i*this->q[1]*H(0,2,0,0) - + this->c_i*(this->q[0] - this->q[3])*H(0,2,0,1) + (-this->q[0] + this->q[3])*H(0,2,0,2) - this->c_i*this->q[1]*H(0,2,0,3) + + (-2*k[0] + this->q[0] + this->q[3])*H(0,3,0,0) - this->q[1]*H(0,3,0,1) + this->c_i*this->q[1]*H(0,3,0,2) + + (2*k[0] - this->q[0] - this->q[3])*H(0,3,0,3) + (-2*k[0] + this->q[0] + this->q[3])*H(1,0,1,0) - this->q[1]*H(1,0,1,1) + + this->c_i*this->q[1]*H(1,0,1,2) + (2*k[0] - this->q[0] - this->q[3])*H(1,0,1,3) - this->q[1]*H(1,1,1,0) + + (this->q[0] - this->q[3])*H(1,1,1,1) - this->c_i*(this->q[0] - this->q[3])*H(1,1,1,2) + this->q[1]*H(1,1,1,3) - + this->c_i*this->q[1]*H(1,2,1,0) + this->c_i*(this->q[0] - this->q[3])*H(1,2,1,1) + (this->q[0] - this->q[3])*H(1,2,1,2) + + this->c_i*this->q[1]*H(1,2,1,3) + (2*k[0] - this->q[0] - this->q[3])*H(1,3,1,0) + this->q[1]*H(1,3,1,1) - + this->c_i*this->q[1]*H(1,3,1,2) + (-2*k[0] + this->q[0] + this->q[3])*H(1,3,1,3) + (-2*k[0] + this->q[0] + this->q[3])*H(2,0,2,0) - + this->q[1]*H(2,0,2,1) + this->c_i*this->q[1]*H(2,0,2,2) + (2*k[0] - this->q[0] - this->q[3])*H(2,0,2,3) - this->q[1]*H(2,1,2,0) + + (this->q[0] - this->q[3])*H(2,1,2,1) - this->c_i*(this->q[0] - this->q[3])*H(2,1,2,2) + this->q[1]*H(2,1,2,3) - + this->c_i*this->q[1]*H(2,2,2,0) + this->c_i*(this->q[0] - this->q[3])*H(2,2,2,1) + (this->q[0] - this->q[3])*H(2,2,2,2) + + this->c_i*this->q[1]*H(2,2,2,3) + (2*k[0] - this->q[0] - this->q[3])*H(2,3,2,0) + this->q[1]*H(2,3,2,1) - + this->c_i*this->q[1]*H(2,3,2,2) + (-2*k[0] + this->q[0] + this->q[3])*H(2,3,2,3) + (-2*k[0] + this->q[0] + this->q[3])*H(3,0,3,0) - + this->q[1]*H(3,0,3,1) + this->c_i*this->q[1]*H(3,0,3,2) + (2*k[0] - this->q[0] - this->q[3])*H(3,0,3,3) - this->q[1]*H(3,1,3,0) + + (this->q[0] - this->q[3])*H(3,1,3,1) - this->c_i*(this->q[0] - this->q[3])*H(3,1,3,2) + this->q[1]*H(3,1,3,3) - + this->c_i*this->q[1]*H(3,2,3,0) + this->c_i*(this->q[0] - this->q[3])*H(3,2,3,1) + (this->q[0] - this->q[3])*H(3,2,3,2) + + this->c_i*this->q[1]*H(3,2,3,3) + (2*k[0] - this->q[0] - this->q[3])*H(3,3,3,0) + this->q[1]*H(3,3,3,1) - + this->c_i*this->q[1]*H(3,3,3,2) + (-2*k[0] + this->q[0] + this->q[3])*H(3,3,3,3)); + + return lh.real(); +} + +double Diff_Cross_Section::LH_contraction_antineutrino() { + std::complex lh = -8*this->k[0]*((2*this->k[0] - this->q[0] - this->q[3])*H(0,0,0,0) + this->q[1]*H(0,0,0,1) + this->c_i*this->q[1]*H(0,0,0,2) + + (-2*this->k[0] + this->q[0] + this->q[3])*H(0,0,0,3) + this->q[1]*H(0,1,0,0) + (-this->q[0] + this->q[3])*H(0,1,0,1) - + this->c_i*(this->q[0] - this->q[3])*H(0,1,0,2) - this->q[1]*H(0,1,0,3) - this->c_i*this->q[1]*H(0,2,0,0) + + this->c_i*(this->q[0] - this->q[3])*H(0,2,0,1) + (-this->q[0] + this->q[3])*H(0,2,0,2) + this->c_i*this->q[1]*H(0,2,0,3) + + (-2*this->k[0] + this->q[0] + this->q[3])*H(0,3,0,0) - this->q[1]*H(0,3,0,1) - this->c_i*this->q[1]*H(0,3,0,2) + + (2*this->k[0] - this->q[0] - this->q[3])*H(0,3,0,3) + (-2*this->k[0] + this->q[0] + this->q[3])*H(1,0,1,0) - this->q[1]*H(1,0,1,1) - + this->c_i*this->q[1]*H(1,0,1,2) + (2*this->k[0] - this->q[0] - this->q[3])*H(1,0,1,3) - this->q[1]*H(1,1,1,0) + + (this->q[0] - this->q[3])*H(1,1,1,1) + this->c_i*(this->q[0] - this->q[3])*H(1,1,1,2) + this->q[1]*H(1,1,1,3) + + this->c_i*this->q[1]*H(1,2,1,0) - this->c_i*(this->q[0] - this->q[3])*H(1,2,1,1) + (this->q[0] - this->q[3])*H(1,2,1,2) - + this->c_i*this->q[1]*H(1,2,1,3) + (2*this->k[0] - this->q[0] - this->q[3])*H(1,3,1,0) + this->q[1]*H(1,3,1,1) + + this->c_i*this->q[1]*H(1,3,1,2) + (-2*this->k[0] + this->q[0] + this->q[3])*H(1,3,1,3) + (-2*this->k[0] + this->q[0] + this->q[3])*H(2,0,2,0) - + this->q[1]*H(2,0,2,1) - this->c_i*this->q[1]*H(2,0,2,2) + (2*this->k[0] - this->q[0] - this->q[3])*H(2,0,2,3) - this->q[1]*H(2,1,2,0) + + (this->q[0] - this->q[3])*H(2,1,2,1) + this->c_i*(this->q[0] - this->q[3])*H(2,1,2,2) + this->q[1]*H(2,1,2,3) + + this->c_i*this->q[1]*H(2,2,2,0) - this->c_i*(this->q[0] - this->q[3])*H(2,2,2,1) + (this->q[0] - this->q[3])*H(2,2,2,2) - + this->c_i*this->q[1]*H(2,2,2,3) + (2*this->k[0] - this->q[0] - this->q[3])*H(2,3,2,0) + this->q[1]*H(2,3,2,1) + + this->c_i*this->q[1]*H(2,3,2,2) + (-2*this->k[0] + this->q[0] + this->q[3])*H(2,3,2,3) + (-2*this->k[0] + this->q[0] + this->q[3])*H(3,0,3,0) - + this->q[1]*H(3,0,3,1) - this->c_i*this->q[1]*H(3,0,3,2) + (2*this->k[0] - this->q[0] - this->q[3])*H(3,0,3,3) - this->q[1]*H(3,1,3,0) + + (this->q[0] - this->q[3])*H(3,1,3,1) + this->c_i*(this->q[0] - this->q[3])*H(3,1,3,2) + this->q[1]*H(3,1,3,3) + + this->c_i*this->q[1]*H(3,2,3,0) - this->c_i*(this->q[0] - this->q[3])*H(3,2,3,1) + (this->q[0] - this->q[3])*H(3,2,3,2) - + this->c_i*this->q[1]*H(3,2,3,3) + (2*this->k[0] - this->q[0] - this->q[3])*H(3,3,3,0) + this->q[1]*H(3,3,3,1) + + this->c_i*this->q[1]*H(3,3,3,2) + (-2*this->k[0] + this->q[0] + this->q[3])*H(3,3,3,3)); + + return lh.real(); +} + + +std::complex Diff_Cross_Section::H(int l, int m, int n, int o) { + std::complex r1c = std::conj(this->current_R->getR(l,m)); + std::complex r1 = this->current_R->getR(n,o); + std::complex r = r1 * r1c; + return r; +} + +void Diff_Cross_Section::setMode(const std::string &mode_input) { + Diff_Cross_Section::mode = mode_input; +} + +void Diff_Cross_Section::setNucleus(const std::string &nucleus_input) { + Diff_Cross_Section::nucleus = nucleus_input; +} + + + + + + + + + + + + + + + diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Diff_Cross_Section.h b/src/contrib/test/COHNCGamma_ext/NCgamma_Diff_Cross_Section.h new file mode 100644 index 000000000..d46bfb360 --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Diff_Cross_Section.h @@ -0,0 +1,62 @@ +// +// Created by edusaul on 23/04/19. +// + +#ifndef GENIE_XSECTION_NCGAMMA_DIFF_CROSS_SECTION_H +#define GENIE_XSECTION_NCGAMMA_DIFF_CROSS_SECTION_H + +#include +#include +#include "NCgamma_Hadronic_Current_R.h" + +namespace NC_gamma { + + class Diff_Cross_Section { + protected: + std::string mode; + std::string nucleus; + std::vector k; + std::vector kp; + std::vector q; + std::vector kg; + + std::complex c_i; + + double k0; + double k0g; + double thg; + double phig; + double kp0; + double constant_factors; + double factors; + + Nucleus_FF_DeVries *nuclearFF; + std::vector vector_of_currents; + Hadronic_Current_R *current_R; + + + public: + Diff_Cross_Section(const std::string &m, const std::string &n); + + virtual ~Diff_Cross_Section(); + + double getDiffCrossSection(double Enu, double Enu_final, double theta_l, double theta_g, double phi_g); + + double integrand(double); + + void change_other_parameters(std::vector); + + double LH_contraction_neutrino(); + + double LH_contraction_antineutrino(); + + std::complex H(int, int, int, int); + + void setMode(const std::string &mode_input); + + void setNucleus(const std::string &nucleus_input); + }; + +} + +#endif //GENIE_XSECTION_NCGAMMA_DIFF_CROSS_SECTION_H diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Form_Factors.cpp b/src/contrib/test/COHNCGamma_ext/NCgamma_Form_Factors.cpp new file mode 100644 index 000000000..f725d5a2a --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Form_Factors.cpp @@ -0,0 +1,213 @@ +// +// Created by edusaul on 8/04/19. +// + +#include "NCgamma_Form_Factors.h" +#include +#include "NCgamma_Parameters_GeV.h" +#include + +using namespace NC_gamma; + +const std::complex &Nuclear_FF::getFfP() const { + return FF_p; +} + +const std::complex &Nuclear_FF::getFfN() const { + return FF_n; +} + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + +Nucleus_FF_DeVries::Nucleus_FF_DeVries(const std::string &n) : nucleus(n) { + this->pi= NCgamma_Param::pi; + this->hc=NCgamma_Param::hc; + + if(this->nucleus == "12C") this->set_12C(); + else if(this->nucleus == "40Ar") this->set_40Ar(); + else { + std::cout<<"WARNING: wrong nucleus, setting 12C as default..."<set_12C(); + } + +} + + +void Nucleus_FF_DeVries::setFF(double Q) { + + double aux,nu; + int i; + + aux=0.0; + + for (i=1;i<16; i++){ + nu=double(i); + aux += pow(-1.0,nu+1.0)*R*R*R*a[i]*hc*hc*hc/(pi*pi*nu*nu-Q*Q*R*R); + } + + this->FF_p = 4.0*pi*sin(Q*R)/(Q*R)*aux;// /6.0; + this->FF_n = this->FF_p; + + std::cout << "Form Factor wiht Q " << Q << " GeV and FF: " << FF_n << std::endl ; +} + +void Nucleus_FF_DeVries::set_12C() { + //a(i) en fm^-3 + this->a[1]=0.15737e-1; + this->a[2]=0.38897e-1; + this->a[3]=0.37085e-1; + this->a[4]=0.14795e-1; + this->a[5]=-0.44834e-2; + + this->a[6]=-0.10057e-1; + this->a[7]=-0.68696e-2; + this->a[8]=-0.28813e-2; + this->a[9]=-0.77229e-3; + this->a[10]=0.66908e-4; + + this->a[11]=0.10636e-3; + this->a[12]=-0.36864e-4; + this->a[13]=-0.50135e-5; + this->a[14]=0.9455e-5; + this->a[15]=-0.47687e-5; + + this->R=8.0/hc; // [fm]/hc +} + +void Nucleus_FF_DeVries::set_40Ar() { + //a(i) en fm^-3 + this->a[1]=0.30451e-1; + this->a[2]=0.55337e-1; + this->a[3]=0.20203e-1; + this->a[4]=-0.16765e-1; + this->a[5]=-0.13578e-1; + + this->a[6]=-0.43204e-4; + this->a[7]=0.91988e-3; + this->a[8]=-0.41205e-3; + this->a[9]=0.11971e-3; + this->a[10]=-0.19801e-4; + + this->a[11]=-0.43204e-5; + this->a[12]=0.61205e-5; + this->a[13]=-0.37803e-5; + this->a[14]=0.18001e-5; + this->a[15]=-0.77407e-6; + + this->R=9.0/hc; // [fm]/hc +} + +Nucleus_FF_DeVries::~Nucleus_FF_DeVries() {} + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + + +Form_Factors_Delta::Form_Factors_Delta() { + this->mn = NCgamma_Param::mp; + this->mn2 = NCgamma_Param::mp2; + this->mDelta = NCgamma_Param::mDelta; + this->mDelta2 = this->mDelta*this->mDelta; + this->N_Delta_MA = NCgamma_Param::N_Delta_MA; + this->aNC = 1.0 - 2.0*NCgamma_Param::sinw2; + + this->kgcm0 = (this->mDelta2-this->mn2)/2.0/this->mDelta; + this->mpw2 = (this->mn+this->mDelta)*(this->mn+this->mDelta); + this->mmw2 = (this->mn - this->mDelta)*(this->mn - this->mDelta); + + this->C4v = 0.0; + this->C5v = 0.0; + this->C3a = 0.0; + this->C4a = 0.0; + this->C5a = 0.0; + this->C6a = 0.0; + + this->C4vNC = 0.0; + this->C5vNC = 0.0; + this->C3aNC = 0.0; + this->C4aNC = 0.0; + this->C6aNC = 0.0; + +} + +void Form_Factors_Delta::setFF(double Q2) { + + double egcm = (this->mDelta2-Q2-this->mn2)/2.0/this->mDelta; + double qcm = sqrt(egcm*egcm + Q2); + + double Fq = 1.0/((1.0 + Q2/NCgamma_Param::parameter_071)*(1.0 + Q2/NCgamma_Param::parameter_071)); + double AM = NCgamma_Param::parameter_03*(1.0 + NCgamma_Param::parameter_001*Q2)*exp(-NCgamma_Param::parameter_023*Q2)*(qcm/this->kgcm0)*Fq; + double A32= sqrt(3.0)/2.0*(-AM); + + double r = sqrt(2.0*this->kgcm0/NCgamma_Param::pi/NCgamma_Param::alpha*this->mn*this->mDelta/(this->mmw2+Q2)); + + this->C3v=-r*this->mn*this->mDelta/(this->mpw2+Q2)*(2.0*A32); + + double Fd=pow((1.0 + Q2/(this->N_Delta_MA*this->N_Delta_MA)),-2); + this->C5aNC=1.2*Fd; + this->C3vNC = this->C3v * this->aNC; + +} + +double Form_Factors_Delta::getC3v() const { + return C3v; +} + +double Form_Factors_Delta::getC4v() const { + return C4v; +} + +double Form_Factors_Delta::getC5v() const { + return C5v; +} + +double Form_Factors_Delta::getC3a() const { + return C3a; +} + +double Form_Factors_Delta::getC4a() const { + return C4a; +} + +double Form_Factors_Delta::getC5a() const { + return C5a; +} + +double Form_Factors_Delta::getC6a() const { + return C6a; +} + +double Form_Factors_Delta::getC3vNC() const { + return C3vNC; +} + +double Form_Factors_Delta::getC4vNC() const { + return C4vNC; +} + +double Form_Factors_Delta::getC5vNC() const { + return C5vNC; +} + +double Form_Factors_Delta::getC3aNC() const { + return C3aNC; +} + +double Form_Factors_Delta::getC4aNC() const { + return C4aNC; +} + +double Form_Factors_Delta::getC5aNC() const { + return C5aNC; +} + +double Form_Factors_Delta::getC6aNC() const { + return C6aNC; +} + diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Form_Factors.h b/src/contrib/test/COHNCGamma_ext/NCgamma_Form_Factors.h new file mode 100644 index 000000000..5c50a2660 --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Form_Factors.h @@ -0,0 +1,130 @@ +// +// Created by edusaul on 8/04/19. +// + +#ifndef COHERENT_PHOTON_NUCLEAR_FF_H +#define COHERENT_PHOTON_NUCLEAR_FF_H +#include +#include + +namespace NC_gamma { + + class Nuclear_FF { + protected: + std::complex FF_p; + std::complex FF_n; + public: + + const std::complex &getFfP() const; + + const std::complex &getFfN() const; + + virtual void setFF(double) = 0; + + }; + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + class Nucleus_FF_DeVries : public Nuclear_FF { + protected: + std::string nucleus; + + double a[16]; + double R; + double pi; + double hc; + + public: + explicit Nucleus_FF_DeVries(const std::string &n); + + virtual void setFF(double); + + void set_12C(); + + void set_40Ar(); + + virtual ~Nucleus_FF_DeVries(); + + }; + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + + class Form_Factors_Delta { + protected: + double mn; + double mn2; + double mDelta; + double mDelta2; + double N_Delta_MA; + double aNC; + + double kgcm0; + double mpw2; + double mmw2; + + double C3v; + double C4v; + double C5v; + + double C3a; + double C4a; + double C5a; + double C6a; + + double C3vNC; + double C4vNC; + double C5vNC; + + double C3aNC; + double C4aNC; + double C5aNC; + double C6aNC; + + public: + Form_Factors_Delta(); + + void setFF(double); + + double getC3v() const; + + double getC4v() const; + + double getC5v() const; + + double getC3a() const; + + double getC4a() const; + + double getC5a() const; + + double getC6a() const; + + double getC3vNC() const; + + double getC4vNC() const; + + double getC5vNC() const; + + double getC3aNC() const; + + double getC4aNC() const; + + double getC5aNC() const; + + double getC6aNC() const; + + }; + +} + + + +#endif //COHERENT_PHOTON_NUCLEAR_FF_H diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Hadronic_Current_R.cpp b/src/contrib/test/COHNCGamma_ext/NCgamma_Hadronic_Current_R.cpp new file mode 100644 index 000000000..343bcc912 --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Hadronic_Current_R.cpp @@ -0,0 +1,862 @@ +// +// Created by edusaul on 11/03/19. +// + +#include "NCgamma_Parameters_GeV.h" +#include "NCgamma_Hadronic_Current_R.h" +#include +#include + +using namespace NC_gamma; + +Delta_in_medium::Delta_in_medium() { + this->mDelta = NCgamma_Param::mDelta; + this->mDelta2 = NCgamma_Param::mDelta*NCgamma_Param::mDelta; + this->mn = NCgamma_Param::mp; + this->mn2 = NCgamma_Param::mp2; + this->mpi = NCgamma_Param::mpi; + this->V0 = NCgamma_Param::Delta_V0; + this->coupling_DeltaNpi = NCgamma_Param::coupling_DeltaNpi; + this->c_i = NCgamma_Param::c_i; + this->hc3 = NCgamma_Param::hc * NCgamma_Param::hc * NCgamma_Param::hc; + this->dir_or_crs = "dir"; + this->rho0 = NCgamma_Param::rho0; + + this->rho_avg = 3.0/(4.0*NCgamma_Param::pi*(1.2*1.2*1.2)) * this->hc3; // average density in fm^-3 * hc^3 + this->rho_r = this->rho_avg ; +} + + +Delta_in_medium::~Delta_in_medium() { + +} + + +std::complex Delta_in_medium::Delta_propagator_dir(double r) { + + std::complex sigma = this->Sigma(); + + std::complex D_Delta_med = 1.0/(this->p2 - (this->mDelta + sigma.real() )*(this->mDelta + sigma.real() ) + + this->c_i * (this->mDelta + sigma.real()) * (Gamma_tilde_Delta(this->rho_r) - 2.0 * sigma.imag() ) ); + return D_Delta_med; +} + +std::complex Delta_in_medium::Delta_propagator_crs() { + return 1.0/(this->p2 - this->mDelta2 + this->c_i * this->mDelta * this->Gamma_vacuum(this->p2)); +} + +void Delta_in_medium::change_other_parameters(std::vector > param) { + this->p2 = param[0].real(); + this->q_minus_kg = param[1].real(); + this->p = sqrt(this->p2); + this->qcm = sqrt(this->lambda_func(p2, this->mpi*this->mpi, this->mn*this->mn))/(2.0 * this->p); + this->gamma_vac = this->Gamma_vacuum(this->p2); + + this->propagator_crs = this->Delta_propagator_crs(); + this->propagator_avg = this->Delta_propagator_avg_dir(); +} + +std::complex Delta_in_medium::Sigma() { + double reSigma = 0.0; + + double imSigma = - 1.0/2.0 * this->V0 * this->rho_r/this->rho0; + + std::complex Sigma(reSigma, imSigma); + return Sigma; +} + +double Delta_in_medium::Gamma_tilde_Delta(double rho_r_in) { + + double q_tilde = this->qcm/this->kf(rho_r_in); + return this->gamma_vac * this->I_series(q_tilde); +} + +double Delta_in_medium::Gamma_vacuum(double p2_in) { + if(p2_in > (this->mn + this->mpi)*(this->mn + this->mpi)) { + + return 1.0/(6.0*NCgamma_Param::pi) * (this->coupling_DeltaNpi/this->mpi)*(this->coupling_DeltaNpi/this->mpi) + *this->mn/sqrt(p2_in) * this->qcm*qcm*qcm; + }else return 0; +} + +double Delta_in_medium::I_series(double q) { + double res = 1.0; + + if (q != 0) { + if (q > 1.0) res += -2.0 / (5.0 * q * q) + 9.0 / (35.0 * pow(q, 4)) - 2.0 / (21.0 * pow(q, 6)); + else if (q < 1.0) res += 34.0 / 35.0 * q - 22.0 / 105.0 * q * q * q - 1.0; + } + + return res; +} + +void Delta_in_medium::setNucleon(const std::string &n) { + Delta_in_medium::nucleon = n; +} + +double Delta_in_medium::lambda_func(double x, double y, double z) { + return x*x + y*y + z*z - 2.0*x*y - 2.0*y*z - 2.0*x*z; +} + +double Delta_in_medium::kf(double rho_r_in) { + return pow(3.0 * NCgamma_Param::pi*NCgamma_Param::pi * rho_r_in/2.0, 1.0/3.0); +} + +void Delta_in_medium::setDirOrCrs(const std::string &dirOrCrs) { + this->dir_or_crs = dirOrCrs; +} + +std::complex Delta_in_medium::Delta_propagator_avg_dir() { + std::complex sigma = this->Sigma(); + + std::complex D_Delta_med = 1.0/(this->p2 - (this->mDelta + sigma.real() )*(this->mDelta + sigma.real() ) + + this->c_i * (this->mDelta + sigma.real()) * (Gamma_tilde_Delta(this->rho_r) - 2.0 * sigma.imag() ) ); + return D_Delta_med; +} + + + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +Hadronic_Current_R::Hadronic_Current_R() { + this->c_i = NCgamma_Param::c_i; +} + +void Hadronic_Current_R::set_tr_dir(Array4x4 &tr) {} + +void Hadronic_Current_R::set_tr_crs(Array4x4 &tr) {} + +void Hadronic_Current_R::setQ(const std::vector &q_in) { + Hadronic_Current_R::q = q_in; + double q2 = q_in[0] * q_in[0] - q_in[1] * q_in[1] -q_in[2] * q_in[2] -q_in[3] * q_in[3]; + this->setFF(q2); +} + +void Hadronic_Current_R::setKg(const std::vector &kg_in) { + Hadronic_Current_R::kg = kg_in; +} + +void Hadronic_Current_R::setP(std::vector p_in) { + Hadronic_Current_R::p = p_in; + this->p0 = p_in[0]; + double pp_aux[] = {p_in[0], -p_in[1], -p_in[2], -p_in[3]}; + this->pp.assign(pp_aux, pp_aux + sizeof(pp_aux) / sizeof(double) ); +} + +std::complex Hadronic_Current_R::getR(int i, int j) { + return 0; +} + +void Hadronic_Current_R::setFF(double q2) {} + +Hadronic_Current_R::~Hadronic_Current_R() {} + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +Hadronic_Current_R_Sum::Hadronic_Current_R_Sum(const std::vector &vectorOfCurrents) + : vector_of_currents(vectorOfCurrents) {} + +void Hadronic_Current_R_Sum::setQ(const std::vector &q_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setQ(q_in); + } +} + +void Hadronic_Current_R_Sum::setKg(const std::vector &kg_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setKg(kg_in); + } +} + +void Hadronic_Current_R_Sum::setP(std::vector p_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setP(p_in); + } +} + +std::complex Hadronic_Current_R_Sum::getR(int i, int j) { + std::complex R (0.0,0.0); + for (int k = 0; k < static_cast(this->vector_of_currents.size()); ++k) { + R += vector_of_currents[k]->getR(i,j); + } + return R; +} + +void Hadronic_Current_R_Sum::setFF(double p_in) { + for (int i = 0; i < static_cast(this->vector_of_currents.size()); ++i) { + vector_of_currents[i]->setFF(p_in); + } +} + + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + +Hadronic_Current_R_Delta::Hadronic_Current_R_Delta(Nuclear_FF *nuclearFf) : nuclearFF(nuclearFf) { + this->mn = NCgamma_Param::mp; + this->mn2 = NCgamma_Param::mp2; + this->mDelta = NCgamma_Param::mDelta; + this->mDelta2 = NCgamma_Param::mDelta*NCgamma_Param::mDelta; + this->mpi = NCgamma_Param::mpi; + this->mpi2 = NCgamma_Param::mpi2; + this->c_i = NCgamma_Param::c_i; + this->ff_Delta = new Form_Factors_Delta(); + + this->ff_Delta->setFF(0.0); + this->C3v = this->ff_Delta->getC3v(); + this->C4v = this->ff_Delta->getC4v(); + this->C5v = this->ff_Delta->getC5v(); + + this->propagator = new Delta_in_medium(); +} + +Hadronic_Current_R_Delta::~Hadronic_Current_R_Delta() { + delete this->ff_Delta; + delete propagator; +} + + +void Hadronic_Current_R_Delta::setFF(double q2) { + double Q2 = -q2; + this->ff_Delta->setFF(Q2); +} + +void Hadronic_Current_R_Delta::setKg(const std::vector &kg_in) { + this->kg = kg_in; + + this->C3vNC = this->ff_Delta->getC3vNC(); + this->C4vNC = this->ff_Delta->getC4vNC(); + this->C5vNC = this->ff_Delta->getC5vNC(); + this->C3aNC = this->ff_Delta->getC3aNC(); + this->C4aNC = this->ff_Delta->getC4aNC(); + this->C5aNC = this->ff_Delta->getC5aNC(); + + this->set_tr_dir(tr_p_dir); + this->set_tr_crs(tr_p_crs); + + this->set_tr_dir(tr_n_dir); + this->set_tr_crs(tr_n_crs); + + std::vector pm = this->q; + std::transform(pm.begin( ), pm.end( ), this->kg.begin( ), pm.begin( ),std::minus( )); + this->q_minus_kg = sqrt(pm[1]*pm[1]+pm[2]*pm[2]+pm[3]*pm[3]); + + this->nuclearFF->setFF(this->q_minus_kg); + this->N_FF_p = this->nuclearFF->getFfP(); + this->N_FF_n = this->nuclearFF->getFfN(); + + this->dir_or_crs = "dir"; + Propagator_Delta(this->p_dir); + this->dir_or_crs = "crs"; + Propagator_Delta(this->p_crs); +} + + +void Hadronic_Current_R_Delta::set_tr_dir(Array4x4 &tr) { + + tr[0][0] = -(C3v*C3vNC*(mDelta*p0 + this->mn*(p0 + this->q[0]))*(4*mDelta2*this->q[1]*this->kg[1] - 4*pow(p0,2)*this->q[1]*this->kg[1] + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] - 3*this->q[1]*this->kg[1] + this->q[3]*(2*this->q[3] - 3*this->kg[3])) + + this->q[3]*(4*mDelta2 - 4*pow(p0,2) + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] - 8*p0*this->q[0]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])))/ + (3.*mDelta2*pow(this->mn,3)); + + tr[0][1] = (this->c_i*C3v*C5aNC*mDelta*(mDelta*p0 + this->mn*(p0 + this->q[0]))*this->q[3]*this->kg[2]* + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) - + C3v*C3vNC*this->mn*(16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->kg[1] + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->kg[1] + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0]*this->kg[1] + 8*p0*this->q[0] * this->q[0]*this->kg[1] + 4*pow(this->q[0],3)*this->kg[1] - this->q[0]*this->q[1] * this->q[1]*this->kg[1] + + 2*p0*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3]) - this->q[0]*this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->kg[3]*(-this->q[3] + this->kg[3])) - + this->q[0]*this->kg[1]*(this->q[0] * this->q[0] + this->q[3]*(2*this->q[3] + this->kg[3]))) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->kg[1] - this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) - + 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->kg[1] + 3*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + 4*p0*this->q[0]*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(4*this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - 3*this->q[3]*this->kg[3])))))/ + (12.*mDelta2*pow(this->mn,4)); + + tr[0][2] = (C3v*(std::complex(0,-1)*C5aNC*mDelta*(mDelta*p0 + this->mn*(p0 + this->q[0]))*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])* + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + C3vNC*this->mn*this->kg[2]*(-16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0]) + 4*pow(mDelta,3)*(-4*p0*this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] + 8*p0*this->q[0] * this->q[0] + 3*pow(this->q[0],3) - 2*p0*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) - + this->q[0]*this->q[1]*(2*this->q[1] + this->kg[1]) - this->q[0]*this->q[3]*(2*this->q[3] + this->kg[3])) + + mDelta*(16*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(8*this->q[0] * this->q[0] - 3*(this->q[1] * this->q[1] + this->q[3] * this->q[3])) + + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*this->q[0]*(3*this->q[0] * this->q[0] - this->q[1]*(4*this->q[1] + this->kg[1]) - this->q[3]*(4*this->q[3] + this->kg[3]))))))/(12.*mDelta2*pow(this->mn,4)); + + tr[0][3] = (C3v*(std::complex(0,-1)*C5aNC*mDelta*(mDelta*p0 + this->mn*(p0 + this->q[0]))*this->q[1]*this->kg[2]* + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + C3vNC*this->mn*(-16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->kg[3] + 4*pow(mDelta,3)*(-(this->q[1]*this->q[3]*this->kg[1]) - 4*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3]) + + 4*this->mn*(p0 + this->q[0])*(this->q[0]*this->q[3]*(this->kg[1]*(this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2]) + 8*p0*this->q[0] * this->q[0]*this->kg[3] - + this->q[0]*(-4*pow(p0,2) + this->q[3] * this->q[3] + this->q[1]*(2*this->q[1] + this->kg[1]))*this->kg[3] + pow(this->q[0],3)*(-2*this->q[3] + 3*this->kg[3]) + 2*p0*this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))\ + + mDelta*(16*pow(p0,3)*this->q[0]*this->kg[3] + 4*pow(p0,2)*(3*this->q[1]*this->q[3]*this->kg[1] + 8*this->q[0] * this->q[0]*this->kg[3] - 3*this->q[1] * this->q[1]*this->kg[3]) + + this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*this->q[0]*(-(this->q[3]*(3*this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + + (this->q[3] * this->q[3] + this->q[1]*(4*this->q[1] + this->kg[1]))*this->kg[3])))))/(12.*mDelta2*pow(this->mn,4)); + + + tr[1][0] = (C3v*(this->c_i*C5aNC*this->q[3]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(p0 + this->q[0]) - + 4*this->mn2*(p0 + this->q[0])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 2*mDelta*this->mn*(p0 + this->q[0])*(8*this->mn2 + 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + mDelta2*(8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 4*p0*this->q[0] * this->q[0] + 8*this->mn2*(-2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] - this->q[1]*this->kg[1] + this->q[3]*(this->q[3] - this->kg[3])) - 2*p0*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])))) - + 2*C3vNC*this->mn*(16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->q[1] + + 4*pow(mDelta,3)*(this->q[1]*(4*p0*this->q[0] - this->q[0] * this->q[0] + this->kg[1] * this->kg[1]) + this->q[3]*this->kg[1]*this->kg[3]) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[1] + 4*p0*this->q[0]*(pow(this->q[1],3) + 2*this->q[1] * this->q[1]*this->kg[1] - 3*this->q[1]*this->kg[1] * this->kg[1] + this->q[3]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + + this->q[1]*this->q[3]*(this->q[3] + this->kg[3])) + (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))*(this->q[0] * this->q[0]*this->q[1] - this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) - + 4*pow(p0,2)*(5*this->q[0] * this->q[0]*this->q[1] + 3*this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]))) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0]*this->q[1] + 6*p0*this->q[0] * this->q[0]*this->q[1] + 2*p0*this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + this->q[0]*(2*this->q[0] * this->q[0]*this->q[1] - pow(this->q[1],3) - 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - this->q[3]*(this->q[3] + this->kg[3])))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[1][1] = (C3v*(this->c_i*C5aNC*this->q[3]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[1] + this->kg[1]) + 2*this->mn2*(this->q[1] + this->kg[1])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[1] + this->kg[1])*(-4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 8*this->mn2*this->kg[1] - 2*p0*this->q[0]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + + 4*pow(p0,2)*(this->q[1] + this->kg[1]) - this->q[1]*this->q[3]*this->kg[3])) - + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 + this->q[0])*(this->q[0] * this->q[0] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(-(this->q[0]*(-4*p0*this->q[0] + this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1])) + 2*(-2*p0 + this->q[0])*this->q[3]*this->kg[3]) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) - + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] - this->kg[1] * this->kg[1] + 3*this->q[3]*this->kg[3]) + + this->q[3]*(-(this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + (this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3]) + + 2*p0*this->q[0]*(3*this->q[0] * this->q[0] + this->kg[1] * this->kg[1] - this->q[3]*(this->q[3] + 2*this->kg[3]))) - + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]*(5*this->q[0] * this->q[0] - 3*this->q[3] * this->q[3] + 3*this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3]) + + 4*p0*(-2*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[0] * this->q[0]*(2*this->q[3] * this->q[3] + (this->q[1] - this->kg[1])*(this->q[1] + 3*this->kg[1])) + + this->q[3]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3]) - + this->q[0]*(this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3])*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[1][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[1] + 4*pow(mDelta,3)*(4*p0*this->q[1] + this->q[0]*(-2*this->q[1] + this->kg[1])) + + 4*this->mn*(p0 + this->q[0])*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] - 2*p0*this->q[0]*(2*this->q[1] + this->kg[1]) - + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + this->q[1]*this->q[3]*this->kg[3]) + + mDelta*(-4*pow(p0,2)*this->q[0]*(2*this->q[1] + 3*this->kg[1]) + + 4*p0*(this->q[0] * this->q[0]*(2*this->q[1] - 3*this->kg[1]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[1] + 2*this->kg[1])) - + this->q[0]*(2*this->q[1] - this->kg[1])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + this->c_i*C5aNC*(2*this->mn2*this->q[3]*this->kg[2] * this->kg[2]*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(-(this->q[3]*this->kg[1] * this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 2*this->kg[3]) - 2*p0*this->q[0]*this->kg[3] + + (8*this->mn2 + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3]) + + mDelta2*(-2*p0*this->q[3]*(2*p0*(-2*this->q[0] * this->q[0] + this->kg[1] * this->kg[1]) + + this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + this->kg[1] * this->kg[1])) + + this->q[3]*(-(this->q[0]*(4*p0 + this->q[0])) + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 2*p0*(-4*pow(p0,2)*this->q[0] - 2*pow(this->q[0],3) + this->q[0]*this->q[1]*(this->q[1] + this->kg[1]) + + 2*p0*(-3*this->q[0] * this->q[0] + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1])))*this->kg[3] + + 8*this->mn2*(this->q[3]*(-2*p0*this->q[0] + this->kg[2] * this->kg[2]) + 2*p0*(2*p0 + this->q[0])*this->kg[3])) + + mDelta*this->mn*(this->q[3]*(-pow(this->q[0],4) - this->kg[1] * this->kg[1]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 4*this->q[1]*this->kg[1]) - + 2*(this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 5*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2])) + + (2*pow(this->q[0],4) + pow(this->q[1] * this->q[1] + this->q[3] * this->q[3],2) + 3*this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[1] + + 2*(this->q[1] - this->q[3])*(this->q[1] + this->q[3])*this->kg[1] * this->kg[1] - this->q[0] * this->q[0]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 5*this->q[1]*this->kg[1]))*this->kg[3] + + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[3] + this->kg[3]) - + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) + this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) - + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-(this->q[1] * this->q[1]*(this->q[3] + 2*this->kg[3])) + this->q[0] * this->q[0]*(this->q[3] + 3*this->kg[3]) - this->q[1]*this->kg[1]*(this->q[3] + 3*this->kg[3]) + + this->q[3]*(3*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + 3*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[1][3] = -(C3v*(this->c_i*C5aNC*this->kg[2]*(4*pow(mDelta,3)*this->mn*(8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[1]*(this->q[1] + this->kg[1])) - + 2*this->mn2*this->q[3]*(this->q[3] + this->kg[3])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(4*pow(p0,2)*this->q[0] * this->q[0] + 6*p0*pow(this->q[0],3) + 2*pow(this->q[0],4) - 4*p0*this->q[0]*this->q[1] * this->q[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1] + pow(this->q[1],4) + this->q[1] * this->q[1]*this->q[3] * this->q[3] - 6*p0*this->q[0]*this->q[1]*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] + + 3*pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->kg[1] * this->kg[1] + 2*this->q[3]*(-(this->q[0]*(p0 + this->q[0])) + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3] + + 8*this->mn2*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3]))) + + mDelta2*(-8*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + this->kg[1])) + + 8*this->mn2*(2*p0*(2*p0 + this->q[0]) - this->q[3]*this->kg[3]) + 2*p0*this->q[0]*(-2*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[3]*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[1]*this->kg[3] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*(this->q[3] - 2*this->kg[3]) + 4*p0*this->q[1]*this->kg[3] + this->q[0]*this->kg[1]*this->kg[3]) - + 4*this->mn*(p0 + this->q[0])*(this->q[1]*this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(-(this->q[3]*(this->q[1] + this->kg[1])) + (2*this->q[1] + this->kg[1])*this->kg[3]) + 2*p0*this->q[0]*(this->kg[1]*this->kg[3] + this->q[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[1]*this->kg[3] + 3*this->kg[1]*this->kg[3]) - + this->q[0]*(this->q[1]*(this->q[3] - 2*this->kg[3]) + this->kg[1]*this->kg[3])*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(-2*this->q[1]*this->q[3]*this->kg[1] * this->kg[1] + this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(-(this->q[1]*this->q[3]) + this->q[3]*this->kg[1] + 2*this->q[1]*this->kg[3] - 3*this->kg[1]*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + + tr[2][0] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) - + 4*this->mn*(p0 + this->q[0])*(-(this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3])) + 2*p0*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + mDelta*(4*p0*this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] - 3*this->q[3]*this->kg[3]) - 12*pow(p0,2)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + (this->q[1]*this->kg[1] + this->q[3]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + this->c_i*C5aNC*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(8*pow(mDelta,3)*this->mn*(p0 + this->q[0]) - + 4*this->mn2*(p0 + this->q[0])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 2*mDelta*this->mn*(p0 + this->q[0])*(8*this->mn2 + 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + mDelta2*(8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 4*p0*this->q[0] * this->q[0] + 8*this->mn2*(-2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] - this->q[1]*this->kg[1] + this->q[3]*(this->q[3] - this->kg[3])) - 2*p0*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3]))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[2][1] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[1] - 4*this->mn*(p0 + this->q[0])* + (2*p0*this->q[0]*this->kg[1] + this->q[0] * this->q[0]*(-this->q[1] + this->kg[1]) + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + mDelta*(4*p0*this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) - 12*pow(p0,2)*this->q[0]*this->kg[1] + 8*p0*this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]) + + this->q[0]*this->kg[1]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + this->c_i*C5aNC*(2*this->mn2*(this->q[1] + this->kg[1])*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[3]*(this->q[0] * this->q[0] + this->q[1]*this->kg[1] - this->kg[2] * this->kg[2]) + (8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[3] * this->q[3])*this->kg[3]) + + mDelta2*(-8*pow(p0,3)*this->q[0]*this->kg[3] + 2*p0*this->q[0]* + (-(this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[0] * this->q[0]*(3*this->q[3] - 2*this->kg[3]) + + this->q[1]*(this->q[1] + 2*this->kg[1])*this->kg[3]) + 4*pow(p0,2)*(this->q[3]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) + this->q[3]*this->kg[3]*(this->q[3] + this->kg[3])) + + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(4*pow(p0,2)*this->kg[3] + 2*p0*this->q[0]*(-this->q[3] + this->kg[3]) + this->kg[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))) + + mDelta*this->mn*(this->q[3]*(-pow(this->q[0],4) + this->kg[1]*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[1]) - + (this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(-this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + 5*this->kg[2] * this->kg[2])) + + (2*pow(this->q[0],4) - this->q[0] * this->q[0]*(3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1]) + + this->q[3] * this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 4*this->q[1]*this->kg[1] - 2*this->kg[2] * this->kg[2]))*this->kg[3] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[3] + this->kg[3]) - + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) + this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) - + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-(this->q[1] * this->q[1]*this->q[3]) - this->q[1]*this->kg[1]*(3*this->q[3] + this->kg[3]) + this->q[0] * this->q[0]*(this->q[3] + 3*this->kg[3]) + + this->q[3]*(this->kg[1] * this->kg[1] + 3*this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + 3*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][2] = (C3v*(std::complex(0,-1)*C5aNC*this->kg[2]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(4*pow(mDelta,3)*this->mn + + mDelta2*(8*this->mn2 + 4*pow(p0,2) - 2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 2*this->mn2*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(-4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*C3vNC*this->mn*(-16*mDelta2*this->mn*(p0 + this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3]) + + 4*p0*(-this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[1] * this->q[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] - this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 3*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]) + + 2*p0*this->q[0]*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (5*this->q[0] * this->q[0] - 3*this->q[1] * this->q[1] - 3*this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] + 3*this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3]) - + this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3])* + (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + this->q[3] * this->q[3]*(-2*this->kg[2] * this->kg[2] + this->q[3]*this->kg[3]) + + this->q[0] * this->q[0]*(this->q[1]*(-4*this->q[1] + this->kg[1]) + 3*this->kg[2] * this->kg[2] + this->q[3]*(-2*this->q[3] + this->kg[3])) + this->q[1] * this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[3]*(this->q[3] + 2*this->kg[3])) + )))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][3] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[3] - 4*this->mn*(p0 + this->q[0])*(2*p0*this->q[0]*this->kg[3] + this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + mDelta*(4*p0*this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) - 12*pow(p0,2)*this->q[0]*this->kg[3] + 8*p0*this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3]) + + this->q[0]*this->kg[3]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + this->c_i*C5aNC*(-2*this->mn2*(this->q[3] + this->kg[3])*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + 8*this->mn2*this->kg[1] - 2*p0*this->q[0]*this->kg[1] + this->q[1]*(this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + this->q[3]*this->kg[3])) + + mDelta2*(-8*pow(p0,3)*this->q[0]*this->kg[1] + 4*pow(p0,2)* + (this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[1]*this->kg[3]*(this->q[3] + this->kg[3])) + + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(4*pow(p0,2)*this->kg[1] + 2*p0*this->q[0]*(-this->q[1] + this->kg[1]) + this->kg[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) + this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]) + + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(pow(this->q[0],4)*this->q[1] - this->q[0] * this->q[0]*pow(this->q[1],3) + this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] + this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] - 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + + 2*pow(this->q[1],3)*this->kg[1] * this->kg[1] - 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) + + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] - pow(this->q[1],3)*this->kg[2] * this->kg[2] - 3*this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] - + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 3*this->q[0] * this->q[0]*this->q[1]*this->q[3]*this->kg[3] + pow(this->q[1],3)*this->q[3]*this->kg[3] + this->q[1]*pow(this->q[3],3)*this->kg[3] - + 2*this->q[0] * this->q[0]*this->q[3]*this->kg[1]*this->kg[3] + 4*this->q[1] * this->q[1]*this->q[3]*this->kg[1]*this->kg[3] - 2*this->q[1]*this->q[3]*this->kg[2] * this->kg[2]*this->kg[3] - + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) - + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) - 3*this->q[1] * this->q[1]*this->kg[1] + 2*this->q[0] * this->q[0]*(this->q[1] + 2*this->kg[1]) - + this->q[1]*(this->q[3] * this->q[3] + this->kg[1] * this->kg[1] - 2*this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]) - this->kg[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->kg[3]*(this->q[3] + this->kg[3])))))) + )/(24.*mDelta2*pow(this->mn,4)); + + + tr[3][0] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(p0 + this->q[0]) - + 4*this->mn2*(p0 + this->q[0])*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 2*mDelta*this->mn*(p0 + this->q[0])*(8*this->mn2 + 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + mDelta2*(8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 4*p0*this->q[0] * this->q[0] + 8*this->mn2*(-2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] - this->q[1]*this->kg[1] + this->q[3]*(this->q[3] - this->kg[3])) - 2*p0*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*this->q[0]*(p0 + this->q[0])*this->q[3] + + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->q[3] - this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[1]*this->kg[1]*this->kg[3]) + + 4*this->mn*(p0 + this->q[0])*(-4*pow(p0,2)*this->q[0]*this->q[3] - 8*p0*this->q[0] * this->q[0]*this->q[3] - 3*pow(this->q[0],3)*this->q[3] + + 2*p0*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[0]*this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - + 2*p0*this->q[1]*this->kg[1]*this->kg[3] + this->q[0]*(this->q[1] * this->q[1] + 2*this->q[3] * this->q[3] - this->q[1]*this->kg[1])*this->kg[3]) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[3] - 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->q[3] - 3*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + 3*this->q[1]*this->kg[1]*this->kg[3]) - + (this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*this->kg[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*this->q[0]*(-3*this->q[0] * this->q[0]*this->q[3] + this->q[1]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + this->q[1] * this->q[1]*(this->q[3] + this->kg[3]) + + this->q[3]*(3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][1] = (this->c_i*C3v*C5aNC*this->kg[2]*(-2*this->mn2*this->q[1]*(this->q[1] + this->kg[1])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2 - 2*this->q[0]*(p0 + this->q[0]) + this->q[3]*(this->q[3] + this->kg[3])) - + mDelta*this->mn*(-4*pow(p0,2)*this->q[0] * this->q[0] - 2*pow(this->q[0],4) + this->q[0] * this->q[0]*this->q[3] * this->q[3] - this->q[1] * this->q[1]*this->q[3] * this->q[3] - pow(this->q[3],4) + + 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] - 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] - + this->q[3]*(-5*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + 2*this->q[3] * this->q[3] + this->q[1]*this->kg[1] + 3*this->q[3]*this->kg[3]) + + 8*this->mn2*(2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))) + + mDelta2*(-8*pow(p0,3)*this->q[0] + 8*this->mn2*(2*p0*(2*p0 + this->q[0]) - this->q[1]*this->kg[1]) + + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[3]*(this->q[3] + this->kg[3])) + 2*p0*this->q[0]*(-2*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + 2*this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + this->q[1]*(this->q[0] * this->q[0]*(-this->q[1] + this->kg[1]) + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])))) - + 2*C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[3]*this->kg[1] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*this->q[3] + 4*p0*this->q[3]*this->kg[1] + this->q[0]*this->kg[1]*(-2*this->q[3] + this->kg[3])) - + 4*this->mn*(p0 + this->q[0])*(2*p0*this->q[0]*(this->q[1]*this->q[3] + this->kg[1]*(2*this->q[3] + this->kg[3])) + this->q[0] * this->q[0]*(this->q[1]*(this->q[3] - this->kg[3]) + this->kg[1]*(2*this->q[3] + this->kg[3])) - + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + 3*this->kg[1]*this->kg[3]) + + this->q[0]*(this->q[1]*this->q[3] + this->kg[1]*(-2*this->q[3] + this->kg[3]))*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(this->q[0] * this->q[0]*(-3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + this->q[1]*this->kg[3] - 3*this->kg[1]*this->kg[3]) + + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 + this->q[0])*this->q[3] - + 4*this->mn*(p0 + this->q[0])*(-(this->q[3]*(-2*this->q[0]*(2*p0 + this->q[0]) + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))) + + (2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1] * this->q[1] - 2*this->q[3] * this->q[3])*this->kg[3]) + 4*pow(mDelta,3)*(4*p0*this->q[3] + this->q[0]*(-2*this->q[3] + this->kg[3])) + + mDelta*(-4*pow(p0,2)*this->q[0]*(2*this->q[3] + 3*this->kg[3]) - + this->q[0]*(2*this->q[3] - this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*(this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[3] + 2*this->kg[3])))) - + this->c_i*C5aNC*(2*this->mn2*this->q[1]*this->kg[2] * this->kg[2]*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2*this->kg[1] - 2*p0*this->q[0]*this->kg[1] - 2*this->q[0] * this->q[0]*this->kg[1] + this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + + this->q[1]*this->kg[1] * this->kg[1] + this->q[1]*this->kg[2] * this->kg[2] + this->q[3]*this->kg[1]*this->kg[3]) + + mDelta2*(-8*pow(p0,3)*this->q[0]*this->kg[1] + this->q[1]*(-this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 8*this->mn2*(4*pow(p0,2)*this->kg[1] + 2*p0*this->q[0]*(-this->q[1] + this->kg[1]) + this->q[1]*this->kg[2] * this->kg[2]) + + 4*pow(p0,2)*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) + 2*this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3]) - + this->q[1]*(-this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(4*pow(this->q[0],4)*this->q[1] - 2*this->q[0] * this->q[0]*pow(this->q[1],3) - 2*this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 5*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] - this->q[0] * this->q[0]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + pow(this->q[3],4)*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + 3*pow(this->q[1],3)*this->kg[1] * this->kg[1] + 3*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + + 2*this->q[1] * this->q[1]*pow(this->kg[1],3) - 2*this->q[3] * this->q[3]*pow(this->kg[1],3) + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) - + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] + pow(this->q[1],3)*this->kg[2] * this->kg[2] + this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[1]*this->kg[2] * this->kg[2] - 2*this->q[0] * this->q[0]*this->q[1]*this->q[3]*this->kg[3] - 5*this->q[0] * this->q[0]*this->q[3]*this->kg[1]*this->kg[3] + + 3*this->q[1] * this->q[1]*this->q[3]*this->kg[1]*this->kg[3] + 3*pow(this->q[3],3)*this->kg[1]*this->kg[3] + 4*this->q[1]*this->q[3]*this->kg[1] * this->kg[1]*this->kg[3] + 2*this->q[1]*this->q[3]*this->kg[2] * this->kg[2]*this->kg[3] - + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) - + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(-pow(this->q[1],3) - 3*this->q[1] * this->q[1]*this->kg[1] + this->q[0] * this->q[0]*(4*this->q[1] + 3*this->kg[1]) - this->q[3]*this->kg[1]*(2*this->q[3] + 3*this->kg[3]) - + this->q[1]*(3*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][3] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[3] + this->kg[3]) + + 2*this->mn2*(this->q[3] + this->kg[3])*(-(this->q[0]*(2*p0 + this->q[0])) + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[3] + this->kg[3])*(-4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(-(this->q[1]*this->q[3]*this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - this->kg[3]) + 8*this->mn2*this->kg[3] - 2*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3] + + 4*pow(p0,2)*(this->q[3] + this->kg[3]))) + 2*C3vNC*this->mn* + (16*mDelta2*this->mn*(p0 + this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) + + 4*pow(mDelta,3)*(4*p0*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) - this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])) - + 4*this->mn*(p0 + this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 3*pow(this->q[0],4) + + 2*p0*this->q[0]*(4*this->q[0] * this->q[0] - pow(this->q[1] + this->kg[1],2) - this->kg[2] * this->kg[2]) - + this->q[0] * this->q[0]*(this->q[3] * this->q[3] + (this->q[1] + this->kg[1])*(2*this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) - + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (8*this->q[0] * this->q[0] - 3*this->q[1] * this->q[1] - 2*this->q[1]*this->kg[1] - 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + + this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*(3*pow(this->q[0],4) - this->q[0] * this->q[0]*(4*this->q[1] * this->q[1] - this->q[1]*this->kg[1] + 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3])))))))/ + (24.*mDelta2*pow(this->mn,4)); + +} + +void Hadronic_Current_R_Delta::set_tr_crs(Array4x4 &tr) { + + tr[0][0] = -(C3v*C3vNC*((mDelta + this->mn)*p0 - this->mn*this->q[0])*(4*mDelta2*this->q[1]*this->kg[1] - 4*pow(p0,2)*this->q[1]*this->kg[1] + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] - 3*this->q[1]*this->kg[1] + this->q[3]*(2*this->q[3] - 3*this->kg[3])) + + this->q[3]*(4*mDelta2 - 4*pow(p0,2) + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + 8*p0*this->q[0]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])))/ + (3.*mDelta2*pow(this->mn,3)); + + tr[0][1] = -(C3v*(this->c_i*C5aNC*mDelta*((mDelta + this->mn)*p0 - this->mn*this->q[0])*this->q[3]*this->kg[2]* + (8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) + + C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->kg[1] + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->kg[1] + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 4*this->mn*(p0 - this->q[0])*(pow(this->q[0],3)*(this->q[1] - 3*this->kg[1]) + 8*p0*this->q[0] * this->q[0]*this->kg[1] + 2*p0*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3]) + + this->q[0]*(-4*pow(p0,2)*this->kg[1] + 2*this->q[3] * this->q[3]*this->kg[1] + this->q[1]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[3]*(-this->q[1] + this->kg[1])*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->kg[1] + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->kg[1] + 3*this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + 4*p0*this->q[0]*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(4*this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - 3*this->q[3]*this->kg[3]))))))/ + (12.*mDelta2*pow(this->mn,4)); + + tr[0][2] = (this->c_i*C3v*C5aNC*mDelta*((mDelta + this->mn)*p0 - this->mn*this->q[0])*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])* + (8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) - + C3v*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0] + 4*pow(mDelta,3)*(4*p0*this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 4*this->mn*(p0 - this->q[0])*(-4*pow(p0,2)*this->q[0] + 8*p0*this->q[0] * this->q[0] - 3*pow(this->q[0],3) - 2*p0*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + this->q[0]*this->q[1]*(2*this->q[1] + this->kg[1]) + this->q[0]*this->q[3]*(2*this->q[3] + this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(8*this->q[0] * this->q[0] - 3*(this->q[1] * this->q[1] + this->q[3] * this->q[3])) + + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1]*(4*this->q[1] + this->kg[1]) + this->q[3]*(4*this->q[3] + this->kg[3])))))/(12.*mDelta2*pow(this->mn,4)); + + tr[0][3] = (this->c_i*C3v*C5aNC*mDelta*((mDelta + this->mn)*p0 - this->mn*this->q[0])*this->q[1]*this->kg[2]*(8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]) + this->q[3]*(this->q[3] + this->kg[3])) - + C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->kg[3] + 4*pow(mDelta,3)*(-(this->q[1]*this->q[3]*this->kg[1]) + 4*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3]) + + 4*this->mn*(p0 - this->q[0])*(-(this->q[0]*this->q[3]*(this->kg[1]*(this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2])) + pow(this->q[0],3)*(2*this->q[3] - 3*this->kg[3]) + 8*p0*this->q[0] * this->q[0]*this->kg[3] + + this->q[0]*(-4*pow(p0,2) + this->q[3] * this->q[3] + this->q[1]*(2*this->q[1] + this->kg[1]))*this->kg[3] + 2*p0*this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->kg[3] + 4*pow(p0,2)*(3*this->q[1]*this->q[3]*this->kg[1] + 8*this->q[0] * this->q[0]*this->kg[3] - 3*this->q[1] * this->q[1]*this->kg[3]) + + this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*this->q[0]*(-(this->q[3]*(3*this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + + (this->q[3] * this->q[3] + this->q[1]*(4*this->q[1] + this->kg[1]))*this->kg[3]))))/(12.*mDelta2*pow(this->mn,4)); + + + tr[1][0] = (this->c_i*C3v*C5aNC*this->q[3]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(-p0 + this->q[0]) + + 2*mDelta*this->mn*(p0 - this->q[0])*(8*this->mn2 - 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 4*this->mn2*(p0 - this->q[0])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta2*(-8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 8*this->mn2*(2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 2*p0*(-2*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + 2*C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->q[1] + + 4*pow(mDelta,3)*(4*p0*this->q[0]*this->q[1] + this->q[0] * this->q[0]*this->q[1] - this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[1] + 4*p0*this->q[0]*(pow(this->q[1],3) + 2*this->q[1] * this->q[1]*this->kg[1] - 3*this->q[1]*this->kg[1] * this->kg[1] + this->q[3]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + + this->q[1]*this->q[3]*(this->q[3] + this->kg[3])) - (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3]))*(this->q[0] * this->q[0]*this->q[1] - this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + 4*pow(p0,2)*(5*this->q[0] * this->q[0]*this->q[1] + 3*this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]))) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0]*this->q[1] - 2*p0*(3*this->q[0] * this->q[0]*this->q[1] + this->kg[1]*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + this->q[0]*(2*this->q[0] * this->q[0]*this->q[1] - pow(this->q[1],3) - 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3]*this->kg[1]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->kg[1] * this->kg[1] - this->q[3]*(this->q[3] + this->kg[3]))))))/ + (24.*mDelta2*pow(this->mn,4)); + + tr[1][1] = (this->c_i*C3v*C5aNC*this->q[3]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[1] + this->kg[1]) + + 2*this->mn2*(this->q[1] + this->kg[1])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[1] + this->kg[1])*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 8*this->mn2*this->kg[1] + 2*p0*this->q[0]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + 4*pow(p0,2)*(this->q[1] + this->kg[1]) - + this->q[1]*this->q[3]*this->kg[3])) - 2*C3v*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(this->q[0]*(4*p0*this->q[0] + this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1]) - 2*(2*p0 + this->q[0])*this->q[3]*this->kg[3]) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1] + 2*this->q[3]*this->kg[3]) - + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] - this->kg[1] * this->kg[1] + 3*this->q[3]*this->kg[3]) + + this->q[3]*(-(this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + (this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3])) + + mDelta*(-16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]*(5*this->q[0] * this->q[0] - 3*this->q[3] * this->q[3] + 3*this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3]) - + this->q[0]*(this->q[0] * this->q[0] + this->q[3] * this->q[3] - this->kg[1] * this->kg[1] - 2*this->q[3]*this->kg[3])*(3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(this->q[0] * this->q[0]*((this->q[1] - this->kg[1])*(this->q[1] + 3*this->kg[1]) + this->q[3]*(2*this->q[3] - this->kg[3])) + + this->q[3]*(2*this->q[3]*this->kg[1] * this->kg[1] - (this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3])))))/(24.*mDelta2*pow(this->mn,4)); + + tr[1][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[1] + 4*pow(mDelta,3)*(4*p0*this->q[1] + 2*this->q[0]*this->q[1] - this->q[0]*this->kg[1]) + + 4*this->mn*(p0 - this->q[0])*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + 2*p0*this->q[0]*(2*this->q[1] + this->kg[1]) - + this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + this->q[1]*this->q[3]*this->kg[3]) + + mDelta*(4*pow(p0,2)*this->q[0]*(2*this->q[1] + 3*this->kg[1]) + 4*p0* + (this->q[0] * this->q[0]*(2*this->q[1] - 3*this->kg[1]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[1] + 2*this->kg[1])) + + this->q[0]*(2*this->q[1] - this->kg[1])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + this->c_i*C5aNC*(2*this->mn2*this->q[3]*this->kg[2] * this->kg[2]*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(-(this->q[3]*this->kg[1] * this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 2*this->kg[3]) + 2*p0*this->q[0]*this->kg[3] + + (8*this->mn2 + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3]) + + mDelta2*(2*p0*this->q[3]*(this->q[0]*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + this->q[0]*this->q[1]*this->kg[1] + + (-2*p0 + this->q[0])*this->kg[1] * this->kg[1]) + this->q[3]*(4*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 2*p0*(4*pow(p0,2)*this->q[0] + 2*pow(this->q[0],3) - this->q[0]*this->q[1]*(this->q[1] + this->kg[1]) + 2*p0*(-3*this->q[0] * this->q[0] + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1])))* + this->kg[3] + 8*this->mn2*(this->q[3]*this->kg[2] * this->kg[2] + 2*p0*this->q[0]*(this->q[3] - this->kg[3]) + 4*pow(p0,2)*this->kg[3])) + + mDelta*this->mn*(this->q[3]*(4*pow(p0,2)*this->q[0] * this->q[0] - pow(this->q[0],4) - this->kg[1] * this->kg[1]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 4*this->q[1]*this->kg[1]) - + 2*(this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[2] * this->kg[2] + + 2*p0*this->q[0]*(-this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] - 3*this->kg[1] * this->kg[1] - this->kg[2] * this->kg[2]) + + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 5*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2])) + + (4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + pow(this->q[1] * this->q[1] + this->q[3] * this->q[3],2) + + 3*this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[1] + 2*(this->q[1] - this->q[3])*(this->q[1] + this->q[3])*this->kg[1] * this->kg[1] + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + 2*this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 3*this->q[1]*this->kg[1]) - + this->q[0] * this->q[0]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 5*this->q[1]*this->kg[1]))*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) - this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + ))))/(24.*mDelta2*pow(this->mn,4)); + + tr[1][3] = (C3v*(2*C3vNC*this->mn*(16*mDelta2*this->mn*(-p0 + this->q[0])*this->q[1]*this->kg[3] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*(this->q[3] - 2*this->kg[3]) - 4*p0*this->q[1]*this->kg[3] + this->q[0]*this->kg[1]*this->kg[3]) - + 4*this->mn*(p0 - this->q[0])*(-(this->q[1]*this->q[3]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(this->q[3]*(this->q[1] + this->kg[1]) - (2*this->q[1] + this->kg[1])*this->kg[3]) + 2*p0*this->q[0]*(this->kg[1]*this->kg[3] + this->q[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(4*p0*this->q[3]*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 2*this->q[1]*this->kg[1] * this->kg[1]) - + 4*p0*(this->q[0] * this->q[0]*(2*this->q[1] - 3*this->kg[1]) + this->q[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1]))*this->kg[3] - + 4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[1]*this->kg[3] + 3*this->kg[1]*this->kg[3]) + + this->q[0]*(this->q[1]*(this->q[3] - 2*this->kg[3]) + this->kg[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])))) - + this->c_i*C5aNC*this->kg[2]*(4*pow(mDelta,3)*this->mn*(8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1])) - + 2*this->mn2*this->q[3]*(this->q[3] + this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(4*pow(p0,2)*this->q[0] * this->q[0] - 6*p0*pow(this->q[0],3) + 2*pow(this->q[0],4) + 4*p0*this->q[0]*this->q[1] * this->q[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1] + pow(this->q[1],4) + this->q[1] * this->q[1]*this->q[3] * this->q[3] + 6*p0*this->q[0]*this->q[1]*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] + + 3*pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->kg[1] * this->kg[1] + 2*this->q[3]*((p0 - this->q[0])*this->q[0] + this->q[1]*(this->q[1] + this->kg[1]))*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + mDelta2*(8*pow(p0,3)*this->q[0] + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[1]*(this->q[1] + this->kg[1])) + + 8*this->mn2*(4*pow(p0,2) - 2*p0*this->q[0] - this->q[3]*this->kg[3]) + 2*p0*this->q[0]*(2*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[3]*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + + tr[2][0] = (C3v*(2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) - + 4*this->mn*(p0 - this->q[0])*(this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + 2*p0*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3])) + + mDelta*(-4*p0*this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] - 3*this->q[3]*this->kg[3]) - 12*pow(p0,2)*(this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + (this->q[1]*this->kg[1] + this->q[3]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) - + this->c_i*C5aNC*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(8*pow(mDelta,3)*this->mn*(-p0 + this->q[0]) + + 2*mDelta*this->mn*(p0 - this->q[0])*(8*this->mn2 - 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 4*this->mn2*(p0 - this->q[0])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta2*(-8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 8*this->mn2*(2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 2*p0*(-2*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][1] = (C3v*(2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[1] - 4*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + 2*p0*this->q[0]*this->kg[1] + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + mDelta*(-12*pow(p0,2)*this->q[0]*this->kg[1] + this->q[0]*this->kg[1]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + 2*this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])))) - + this->c_i*C5aNC*(-2*this->mn2*(this->q[1] + this->kg[1])*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[3]*(this->q[0] * this->q[0] + this->q[1]*this->kg[1] - this->kg[2] * this->kg[2]) + (8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[3] * this->q[3])*this->kg[3]) + + mDelta2*(8*pow(p0,3)*this->q[0]*this->kg[3] + 4*pow(p0,2)* + (this->q[3]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) + this->q[3]*this->kg[3]*(this->q[3] + this->kg[3])) + + 2*p0*this->q[0]*(this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*(this->q[1] + 2*this->kg[1])*this->kg[3] + + this->q[0] * this->q[0]*(-3*this->q[3] + 2*this->kg[3])) + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] - this->kg[3]) + 4*pow(p0,2)*this->kg[3] + this->kg[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3]))) + + mDelta*this->mn*(this->q[3]*(-pow(this->q[0],4) + this->kg[1]*(pow(this->q[1],3) + this->q[1]*this->q[3] * this->q[3] + 2*this->q[1] * this->q[1]*this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[1]) - + (this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[2] * this->kg[2] + + this->q[0] * this->q[0]*(-this->q[1] * this->q[1] + this->q[3] * this->q[3] - 3*this->q[1]*this->kg[1] + 2*this->kg[1] * this->kg[1] + 5*this->kg[2] * this->kg[2])) + + (2*pow(this->q[0],4) - this->q[0] * this->q[0]*(3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1]) + + this->q[3] * this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 4*this->q[1]*this->kg[1] - 2*this->kg[2] * this->kg[2]))*this->kg[3] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[3] + this->kg[3]) + + 8*this->mn2*(2*p0*this->q[0]*(this->q[3] + this->kg[3]) - this->q[0] * this->q[0]*(2*this->q[3] + this->kg[3]) + + this->kg[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(this->q[1] * this->q[1]*this->q[3] + this->q[1]*this->kg[1]*(3*this->q[3] + this->kg[3]) - this->q[0] * this->q[0]*(this->q[3] + 3*this->kg[3]) + + this->q[3]*(this->q[3] * this->q[3] - this->kg[1] * this->kg[1] - 3*this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][2] = -(C3v*(this->c_i*C5aNC*this->kg[2]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(4*pow(mDelta,3)*this->mn + + mDelta2*(8*this->mn2 + 4*pow(p0,2) + 2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3]) + + 2*this->mn2*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*(this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3]) + + 4*p0*(this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3])) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 2*pow(this->q[0],4) + pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + this->q[1] * this->q[1]*this->kg[1] * this->kg[1] - this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - this->q[1] * this->q[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + 2*p0*this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) - + this->q[0] * this->q[0]*(this->q[1] * this->q[1] + 3*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3])) - + mDelta*(16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (-5*this->q[0] * this->q[0] + 3*this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] - 3*this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) + + this->q[0]*(this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] - 2*this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] - 2*this->q[3]*this->kg[3])* + (3*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*(pow(this->q[1],3)*this->kg[1] + this->q[1]*this->q[3] * this->q[3]*this->kg[1] + this->q[3] * this->q[3]*(-2*this->kg[2] * this->kg[2] + this->q[3]*this->kg[3]) + + this->q[0] * this->q[0]*(this->q[1]*(-4*this->q[1] + this->kg[1]) + 3*this->kg[2] * this->kg[2] + this->q[3]*(-2*this->q[3] + this->kg[3])) + + this->q[1] * this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[3]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[2][3] = (C3v*(2*C3vNC*this->mn*this->kg[2]*(4*pow(mDelta,3)*this->q[0]*this->kg[3] - 4*this->mn*(p0 - this->q[0])* + (this->q[0] * this->q[0]*(this->q[3] - this->kg[3]) + 2*p0*this->q[0]*this->kg[3] + this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) + + mDelta*(-12*pow(p0,2)*this->q[0]*this->kg[3] + this->q[0]*this->kg[3]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*(this->q[0] * this->q[0]*(this->q[3] - 3*this->kg[3]) + 2*this->q[1]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])))) + + this->c_i*C5aNC*(-2*this->mn2*(this->q[3] + this->kg[3])*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + 8*this->mn2*this->kg[1] + 2*p0*this->q[0]*this->kg[1] + this->q[1]*(this->q[1]*this->kg[1] - this->kg[2] * this->kg[2] + this->q[3]*this->kg[3])) + + mDelta2*(8*pow(p0,3)*this->q[0]*this->kg[1] + 4*pow(p0,2)* + (this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1]*this->kg[1]*(this->q[1] + this->kg[1]) + this->q[1]*this->kg[3]*(this->q[3] + this->kg[3])) + + (this->q[3]*this->kg[1] - this->q[1]*this->kg[3])*(this->q[0] * this->q[0]*(-this->q[3] + this->kg[3]) + this->q[1]*(this->q[3]*this->kg[1] - this->q[1]*this->kg[3])) + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] - this->kg[1]) + 4*pow(p0,2)*this->kg[1] + this->kg[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])) - + 2*p0*this->q[0]*(-pow(this->q[1],3) + this->q[0] * this->q[0]*(this->q[1] - 2*this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]) + + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] - this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(pow(this->q[0],4)*this->q[1] - this->q[0] * this->q[0]*pow(this->q[1],3) + this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 3*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] + this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] - 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + + 2*pow(this->q[1],3)*this->kg[1] * this->kg[1] - 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) + + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] - pow(this->q[1],3)*this->kg[2] * this->kg[2] - 3*this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] - + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 3*this->q[0] * this->q[0]*this->q[1]*this->q[3]*this->kg[3] + pow(this->q[1],3)*this->q[3]*this->kg[3] + this->q[1]*pow(this->q[3],3)*this->kg[3] - + 2*this->q[0] * this->q[0]*this->q[3]*this->kg[1]*this->kg[3] + 4*this->q[1] * this->q[1]*this->q[3]*this->kg[1]*this->kg[3] - 2*this->q[1]*this->q[3]*this->kg[2] * this->kg[2]*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) - this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(pow(this->q[1],3) + 3*this->q[1] * this->q[1]*this->kg[1] - 2*this->q[0] * this->q[0]*(this->q[1] + 2*this->kg[1]) + + this->q[1]*(this->q[3] * this->q[3] + this->kg[1] * this->kg[1] - 2*this->kg[2] * this->kg[2] + 3*this->q[3]*this->kg[3]) + this->kg[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->kg[3]*(this->q[3] + this->kg[3])))))) + )/(24.*mDelta2*pow(this->mn,4)); + + + tr[3][0] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(8*pow(mDelta,3)*this->mn*(-p0 + this->q[0]) + + 2*mDelta*this->mn*(p0 - this->q[0])*(8*this->mn2 - 2*p0*this->q[0] + this->q[0] * this->q[0] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) - + 4*this->mn2*(p0 - this->q[0])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta2*(-8*pow(p0,3) + 12*pow(p0,2)*this->q[0] + 8*this->mn2*(2*p0 + this->q[0]) + + this->q[0]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] - this->q[1]*this->kg[1] - this->q[3]*this->kg[3]) + + 2*p0*(-2*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[0]*this->q[3] + + 4*pow(mDelta,3)*(this->q[3]*(4*p0*this->q[0] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*this->kg[1]*this->kg[3]) + + 4*this->mn*(p0 - this->q[0])*(-4*pow(p0,2)*this->q[0]*this->q[3] + 8*p0*this->q[0] * this->q[0]*this->q[3] - 3*pow(this->q[0],3)*this->q[3] - + 2*p0*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[0]*this->q[3]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + this->q[1]*this->kg[1] + this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + + 2*p0*this->q[1]*this->kg[1]*this->kg[3] + this->q[0]*(this->q[1] * this->q[1] + 2*this->q[3] * this->q[3] - this->q[1]*this->kg[1])*this->kg[3]) + + mDelta*(-16*pow(p0,3)*this->q[0]*this->q[3] + 4*pow(p0,2)*(8*this->q[0] * this->q[0]*this->q[3] - 3*this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + 3*this->q[1]*this->kg[1]*this->kg[3]) + + (this->q[3]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) - this->q[1]*this->kg[1]*this->kg[3])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[1]*this->kg[1] + this->q[3]*(this->q[3] + 2*this->kg[3])) + + 4*p0*this->q[0]*(-3*this->q[0] * this->q[0]*this->q[3] + this->q[1]*this->kg[1]*(this->q[3] - 3*this->kg[3]) + this->q[1] * this->q[1]*(this->q[3] + this->kg[3]) + + this->q[3]*(3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][1] = (C3v*(this->c_i*C5aNC*this->kg[2]*(-2*this->mn2*this->q[1]*(this->q[1] + this->kg[1])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2 + 2*(p0 - this->q[0])*this->q[0] + this->q[3]*(this->q[3] + this->kg[3])) + + mDelta*this->mn*(4*pow(p0,2)*this->q[0] * this->q[0] - 6*p0*pow(this->q[0],3) + 2*pow(this->q[0],4) + 4*p0*this->q[0]*this->q[3] * this->q[3] - + this->q[0] * this->q[0]*this->q[3] * this->q[3] + this->q[1] * this->q[1]*this->q[3] * this->q[3] + pow(this->q[3],4) + 2*p0*this->q[0]*this->q[1]*this->kg[1] - 2*this->q[0] * this->q[0]*this->q[1]*this->kg[1] + + 2*this->q[1]*this->q[3] * this->q[3]*this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] - 2*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + this->q[3]*(6*p0*this->q[0] - 5*this->q[0] * this->q[0] + this->q[1] * this->q[1] + 3*this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1])*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + mDelta2*(8*pow(p0,3)*this->q[0] + 8*this->mn2*(4*pow(p0,2) - 2*p0*this->q[0] - this->q[1]*this->kg[1]) + + 2*p0*this->q[0]*(2*this->q[0] * this->q[0] - this->q[1]*(this->q[1] + 2*this->kg[1]) - this->q[3]*(this->q[3] + this->kg[3])) + 4*pow(p0,2)*(-3*this->q[0] * this->q[0] + this->q[3]*(this->q[3] + this->kg[3])) + + this->q[1]*(this->q[0] * this->q[0]*(-this->q[1] + this->kg[1]) + this->q[3]*(-(this->q[3]*this->kg[1]) + this->q[1]*this->kg[3])))) + + 2*C3vNC*this->mn*(16*mDelta2*this->mn*(-p0 + this->q[0])*this->q[3]*this->kg[1] + 4*pow(mDelta,3)*(this->q[0]*this->q[1]*this->q[3] - 4*p0*this->q[3]*this->kg[1] + this->q[0]*this->kg[1]*(-2*this->q[3] + this->kg[3])) - + 4*this->mn*(p0 - this->q[0])*(2*p0*this->q[0]*(this->q[1]*this->q[3] + this->kg[1]*(2*this->q[3] + this->kg[3])) - this->q[0] * this->q[0]*(this->q[1]*(this->q[3] - this->kg[3]) + this->kg[1]*(2*this->q[3] + this->kg[3])) + + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-4*pow(p0,2)*this->q[0]*(3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + 3*this->kg[1]*this->kg[3]) + + this->q[0]*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])*(this->q[1]*this->q[3] + this->kg[1]*(-2*this->q[3] + this->kg[3])) - + 4*p0*(this->q[0] * this->q[0]*(-3*this->q[1]*this->q[3] + 2*this->q[3]*this->kg[1] + this->q[1]*this->kg[3] - 3*this->kg[1]*this->kg[3]) + + this->q[3]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][2] = (C3v*(-2*C3vNC*this->mn*this->kg[2]*(16*mDelta2*this->mn*(p0 - this->q[0])*this->q[3] + 4*pow(mDelta,3)*(4*p0*this->q[3] + 2*this->q[0]*this->q[3] - this->q[0]*this->kg[3]) + + 4*this->mn*(p0 - this->q[0])*(this->q[3]*(4*p0*this->q[0] - 2*this->q[0] * this->q[0] + this->q[3] * this->q[3] + this->q[1]*(this->q[1] + this->kg[1])) + + (2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1] * this->q[1] + 2*this->q[3] * this->q[3])*this->kg[3]) + + mDelta*(4*pow(p0,2)*this->q[0]*(2*this->q[3] + 3*this->kg[3]) + this->q[0]*(2*this->q[3] - this->kg[3])* + (-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + 4*p0*(this->q[0] * this->q[0]*(2*this->q[3] - 3*this->kg[3]) + (this->q[1] * this->q[1] + this->q[3] * this->q[3])*(this->q[3] + 2*this->kg[3])))) - + this->c_i*C5aNC*(2*this->mn2*this->q[1]*this->kg[2] * this->kg[2]*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + 4*pow(mDelta,3)*this->mn*(8*this->mn2*this->kg[1] + 2*p0*this->q[0]*this->kg[1] - 2*this->q[0] * this->q[0]*this->kg[1] + this->q[1] * this->q[1]*this->kg[1] + this->q[3] * this->q[3]*this->kg[1] + + this->q[1]*this->kg[1] * this->kg[1] + this->q[1]*this->kg[2] * this->kg[2] + this->q[3]*this->kg[1]*this->kg[3]) + + mDelta2*(8*pow(p0,3)*this->q[0]*this->kg[1] + this->q[1]*(-this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3])*this->kg[2] * this->kg[2] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] - this->kg[1]) + 4*pow(p0,2)*this->kg[1] + this->q[1]*this->kg[2] * this->kg[2]) + + 4*pow(p0,2)*(this->q[0] * this->q[0]*(this->q[1] - 3*this->kg[1]) + this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3])) - + 2*p0*this->q[0]*(-pow(this->q[1],3) + 2*this->q[0] * this->q[0]*(this->q[1] - this->kg[1]) + this->q[3]*this->kg[1]*(this->q[3] + this->kg[3]) - + this->q[1]*(-this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))) + + mDelta*this->mn*(4*pow(this->q[0],4)*this->q[1] - 2*this->q[0] * this->q[0]*pow(this->q[1],3) - 2*this->q[0] * this->q[0]*this->q[1]*this->q[3] * this->q[3] + 2*pow(this->q[0],4)*this->kg[1] - + 5*this->q[0] * this->q[0]*this->q[1] * this->q[1]*this->kg[1] + pow(this->q[1],4)*this->kg[1] - this->q[0] * this->q[0]*this->q[3] * this->q[3]*this->kg[1] + 2*this->q[1] * this->q[1]*this->q[3] * this->q[3]*this->kg[1] + + pow(this->q[3],4)*this->kg[1] - 5*this->q[0] * this->q[0]*this->q[1]*this->kg[1] * this->kg[1] + 3*pow(this->q[1],3)*this->kg[1] * this->kg[1] + 3*this->q[1]*this->q[3] * this->q[3]*this->kg[1] * this->kg[1] + + 2*this->q[1] * this->q[1]*pow(this->kg[1],3) - 2*this->q[3] * this->q[3]*pow(this->kg[1],3) + 4*pow(p0,2)*this->q[0] * this->q[0]*(this->q[1] + this->kg[1]) - + 3*this->q[0] * this->q[0]*this->q[1]*this->kg[2] * this->kg[2] + pow(this->q[1],3)*this->kg[2] * this->kg[2] + this->q[1]*this->q[3] * this->q[3]*this->kg[2] * this->kg[2] + + 2*this->q[1] * this->q[1]*this->kg[1]*this->kg[2] * this->kg[2] - 2*this->q[3] * this->q[3]*this->kg[1]*this->kg[2] * this->kg[2] + + this->q[3]*(-(this->q[0] * this->q[0]*(2*this->q[1] + 5*this->kg[1])) + this->kg[1]*(3*(this->q[1] * this->q[1] + this->q[3] * this->q[3]) + 4*this->q[1]*this->kg[1]) + 2*this->q[1]*this->kg[2] * this->kg[2])*this->kg[3] + + 8*this->mn2*(2*p0*this->q[0]*(this->q[1] + this->kg[1]) - this->q[0] * this->q[0]*(2*this->q[1] + this->kg[1]) + + this->kg[1]*(this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3])) + + 2*p0*this->q[0]*(pow(this->q[1],3) + 3*this->q[1] * this->q[1]*this->kg[1] - this->q[0] * this->q[0]*(4*this->q[1] + 3*this->kg[1]) + this->q[3]*this->kg[1]*(2*this->q[3] + 3*this->kg[3]) + + this->q[1]*(3*this->kg[1] * this->kg[1] + 2*this->kg[2] * this->kg[2] + this->q[3]*(this->q[3] + this->kg[3])))))))/(24.*mDelta2*pow(this->mn,4)); + + tr[3][3] = -(C3v*(this->c_i*C5aNC*this->q[1]*this->kg[2]*(4*pow(mDelta,3)*this->mn*(this->q[3] + this->kg[3]) + + 2*this->mn2*(this->q[3] + this->kg[3])*(2*p0*this->q[0] - this->q[0] * this->q[0] + this->q[1]*this->kg[1] + this->q[3]*this->kg[3]) + + mDelta*this->mn*(this->q[3] + this->kg[3])*(4*p0*this->q[0] - 3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) + + mDelta2*(-(this->q[1]*this->q[3]*this->kg[1]) + this->q[0] * this->q[0]*(this->q[3] - this->kg[3]) + 8*this->mn2*this->kg[3] + 2*p0*this->q[0]*this->kg[3] + this->q[1] * this->q[1]*this->kg[3] + + 4*pow(p0,2)*(this->q[3] + this->kg[3]))) + 2*C3vNC*this->mn* + (16*mDelta2*this->mn*(p0 - this->q[0])*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) + + 4*pow(mDelta,3)*(4*p0*(this->q[0] * this->q[0] - this->q[1]*this->kg[1]) + this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])) - + 4*this->mn*(p0 - this->q[0])*(4*pow(p0,2)*this->q[0] * this->q[0] + 3*pow(this->q[0],4) + + 2*p0*this->q[0]*(-4*this->q[0] * this->q[0] + pow(this->q[1] + this->kg[1],2) + this->kg[2] * this->kg[2]) - + this->q[0] * this->q[0]*(this->q[3] * this->q[3] + (this->q[1] + this->kg[1])*(2*this->q[1] + this->kg[1]) + this->kg[2] * this->kg[2] + 2*this->q[3]*this->kg[3]) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + this->q[1]*(2*this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3]))) + + mDelta*(-16*pow(p0,3)*this->q[0] * this->q[0] + 4*pow(p0,2)*this->q[0]* + (8*this->q[0] * this->q[0] - 3*this->q[1] * this->q[1] - 2*this->q[1]*this->kg[1] - 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2])) + + this->q[0]*(pow(this->q[1] - this->kg[1],2) + this->kg[2] * this->kg[2])*(-3*this->q[0] * this->q[0] + this->q[1] * this->q[1] + this->q[3] * this->q[3] + 2*this->q[1]*this->kg[1] + 2*this->q[3]*this->kg[3]) - + 4*p0*(3*pow(this->q[0],4) - this->q[0] * this->q[0]*(4*this->q[1] * this->q[1] - this->q[1]*this->kg[1] + 3*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*(this->q[3] + 2*this->kg[3])) + + this->q[1]*(this->q[1] * this->q[1]*this->kg[1] + 2*this->q[1]*(this->kg[1] * this->kg[1] + this->kg[2] * this->kg[2]) + this->q[3]*this->kg[1]*(this->q[3] + 2*this->kg[3])))))))/ + (24.*mDelta2*pow(this->mn,4)); + +} + +double Hadronic_Current_R_Delta::qcm(double s) { +// Returns the 3-momentum of the pion formed after the decay of a +// resonance (R->N pi) of inv. mass s in the rest frame of the resonance + return sqrt((s-this->mpi2-this->mn2)*(s-this->mpi2-this->mn2) - 4.0 * this->mpi2 * this->mn2)/2.0/sqrt(s); +} + +std::complex Hadronic_Current_R_Delta::getR(int i, int j) { + std::complex tr_p = this->tr_p_dir[i][j]*this->propagator_dir_p + + this->tr_p_crs[i][j]*this->propagator_crs_p; + std::complex tr_n = this->tr_n_dir[i][j]*this->propagator_dir_n + + this->tr_n_crs[i][j]*this->propagator_crs_n; + + return (tr_p * this->N_FF_p + tr_n * this->N_FF_n) * this->mn / this->p0 / 2.0; //Factor 1/2 from the trace, see notes +} + +void Hadronic_Current_R_Delta::setP(std::vector p_in) { + this->p = p_in; + this->p0 = p_in[0]; + + double aux_pp[] = {p_in[0], -p_in[1], -p_in[2], -p_in[3]}; + this->pp.assign(aux_pp, aux_pp + sizeof(aux_pp) / sizeof(double) ); + + this->p_dir = this->p; + std::transform(this->p_dir.begin( ), this->p_dir.end( ), this->q.begin( ), this->p_dir.begin( ),std::plus( )); + + this->p_crs = this->pp; + std::transform(this->p_crs.begin( ), this->p_crs.end( ), this->q.begin( ), this->p_crs.begin( ),std::minus( )); +} + +std::complex Hadronic_Current_R_Delta::Propagator_Delta(std::vector p_in) { + double p2 = p_in[0] * p_in[0] - p_in[1] * p_in[1] - p_in[2] * p_in[2] - p_in[3] * p_in[3]; + + std::vector > param(2); + param[0] = p2; + param[1] = this->q_minus_kg; + this->propagator->change_other_parameters(param); + + if (this->dir_or_crs == "dir") { + this->propagator->setNucleon("p"); + this->propagator_dir_p = this->propagator->Delta_propagator_avg_dir(); + this->propagator->setNucleon("n"); + this->propagator_dir_n = this->propagator->Delta_propagator_avg_dir(); + } else if (this->dir_or_crs == "crs") { + this->propagator->setNucleon("p"); + this->propagator_crs_p = this->propagator->Delta_propagator_crs(); + this->propagator->setNucleon("n"); + this->propagator_crs_n = this->propagator->Delta_propagator_crs(); + } + + return 0; +} + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + + diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Hadronic_Current_R.h b/src/contrib/test/COHNCGamma_ext/NCgamma_Hadronic_Current_R.h new file mode 100644 index 000000000..c0f23a88e --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Hadronic_Current_R.h @@ -0,0 +1,221 @@ +// +// Created by edusaul on 11/03/19. +// + +#ifndef COHERENT_PHOTON_HADRONIC_CURRENT_R_H +#define COHERENT_PHOTON_HADRONIC_CURRENT_R_H + +#include +#include +#include "NCgamma_Form_Factors.h" + + + +namespace NC_gamma { + + class Delta_in_medium { + protected: + std::string nucleon; + std::string dir_or_crs; + double p; + double p2; + double q_minus_kg; + double qcm; + double mDelta; + double mDelta2; + double mn; + double mn2; + double mpi; + double V0; + double rho0; + double coupling_DeltaNpi; + std::complex c_i; + double hc3; + + double gamma_vac; + double rho_r; + + double rho_avg; // average density in units of rho0 + std::complex propagator_avg; + + std::complex propagator_crs; + + public: + + Delta_in_medium(); + + virtual ~Delta_in_medium(); + + void setNucleon(const std::string &n); + + virtual std::complex Delta_propagator_dir(double); + + virtual std::complex Delta_propagator_crs(); + + void change_other_parameters(std::vector >); + + std::complex Sigma(); + + double Gamma_tilde_Delta(double); + + double Gamma_vacuum(double); + + double I_series(double); + + double lambda_func(double, double, double); + + double kf(double); + + void setDirOrCrs(const std::string &dirOrCrs); + + std::complex Delta_propagator_avg_dir(); + + }; + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + + class Hadronic_Current_R { + protected: + std::complex c_i; + + std::vector q; + std::vector kg; + std::vector p; + std::vector pp; + double p0; + + typedef std::complex Array4x4[4][4]; + + Array4x4 tr_p_dir; + Array4x4 tr_p_crs; + Array4x4 tr_n_dir; + Array4x4 tr_n_crs; + + virtual void set_tr_dir(Array4x4 &); + + virtual void set_tr_crs(Array4x4 &); + + public: + + explicit Hadronic_Current_R(); + + virtual void setQ(const std::vector &q_in); + + virtual void setKg(const std::vector &kg_in); + + virtual void setP(std::vector); + + virtual std::complex getR(int, int); + + virtual void setFF(double); + + virtual ~Hadronic_Current_R(); + }; + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + class Hadronic_Current_R_Sum : public Hadronic_Current_R { + protected: + std::vector vector_of_currents; + + public: + explicit Hadronic_Current_R_Sum(const std::vector &vectorOfCurrents); + + virtual void setQ(const std::vector &q); + + virtual void setKg(const std::vector &kg); + + virtual void setP(std::vector); + + virtual std::complex getR(int, int); + + virtual void setFF(double); + + }; + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + + class Hadronic_Current_R_Delta : public Hadronic_Current_R { + protected: + Form_Factors_Delta *ff_Delta; + + double mn; + double mn2; + double mDelta; + double mDelta2; + double mpi; + double mpi2; + std::complex c_i; + double q_minus_kg; + + double C3v; + double C4v; + double C5v; + double C3vNC; + double C4vNC; + double C5vNC; + double C3aNC; + double C4aNC; + double C5aNC; + double C6aNC; + + std::complex N_FF_p; + std::complex N_FF_n; + + std::complex propagator_dir_p; + std::complex propagator_crs_p; + std::complex propagator_dir_n; + std::complex propagator_crs_n; + + std::vector p_dir; + std::vector p_crs; + + Delta_in_medium *propagator; + std::string dir_or_crs; + + Nuclear_FF *nuclearFF; + + + virtual void set_tr_dir(Array4x4 &); + + virtual void set_tr_crs(Array4x4 &); + + public: + + explicit Hadronic_Current_R_Delta(Nuclear_FF *nuclearFf); + + virtual ~Hadronic_Current_R_Delta(); + + virtual void setFF(double); + + virtual void setKg(const std::vector &kg_in); + + std::complex Propagator_Delta(std::vector); + + double qcm(double); + + virtual std::complex getR(int, int); + + virtual void setP(std::vector); + + }; + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + +} + +#endif //COHERENT_PHOTON_HADRONIC_CURRENT_R_H diff --git a/src/contrib/test/COHNCGamma_ext/NCgamma_Parameters_GeV.h b/src/contrib/test/COHNCGamma_ext/NCgamma_Parameters_GeV.h new file mode 100644 index 000000000..b8e30aecc --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/NCgamma_Parameters_GeV.h @@ -0,0 +1,74 @@ +#ifndef _PARAMETERS_H_ +#define _PARAMETERS_H_ +#include +#include + +namespace NCgamma_Param +{ + + const std::complex c_i(0.0,1.0); + const double pi= 4.0*atan(1.0); + const double alpha= 1.0/137.0; + const double hc=0.19733; // (GeV x fm) + const double hccm=197.33e-16; // (GeV x cm) + const double Gf=1.16639e-5; // GeV^-2 + const double cosw2=0.23122; // Weak angle squared + const double sinw2=0.2223; + const double ga=1.2723; //from the PDG value for gA/gV (measured in beta decay: http://pdglive.lbl.gov/DataBlock.action?node=S017AV&init=0) using gV=1 as expected. + const double gas=0.15; + const double MA = 1.049; // GeV Axial mass + + //nuclear matter density (in fm^-3 * hc^3) + const double rho0=0.17 * hc*hc*hc; + + //lepton mases + const double me= 0.51099892e-3; //GeV + const double mmu= 0.1056583715; //GeV + + //messon mass + const double mpi=0.13957; //GeV + + //nucleon + const double mp= 0.93827203; //GeV + const double mn= 0.93827203; //GeV + const double mup = 1.7928; //proton anomalous magnetic moment + const double mun = -1.913; //neutron anomalous magnetic moment + //for the form factors: + const double lambdanN=5.6; + const double MD = 0.843; // GeV + + //barion mass + const double mLambda_1115= 1.115; //GeV + const double mSigma_1190= 1.197449; //GeV + const double mDelta= 1.232; //GeV + const double mN1440= 1.440; //GeV + const double mN1520= 1.515; //GeV + const double mN1535= 1.530; //GeV + + const double coupling_DeltaNpi= 2.14; + const double N_Delta_MA= 0.93; //GeV + const double Delta_V0= 0.08; //GeV + + //Carbon nucleus + const double AC= 12.0; + const double ZC= 6.0; + const double MC= 12.0*mp; + + //Powers + + const double hccm2= hccm*hccm; + const double Gf2=Gf*Gf; + const double mpi2=mpi*mpi; + const double mp2=mp*mp; + + //Delta FF parameters + const double parameter_001 = 0.01; //GeV^-2 + const double parameter_023 = 0.23; //GeV^-2 + const double parameter_071 = 0.71; //GeV^2 + const double parameter_093 = 0.93; //GeV^2 + const double parameter_03 = 0.3; //GeV^(-1/2) + + +} + +#endif diff --git a/src/contrib/test/COHNCGamma_ext/main.cpp b/src/contrib/test/COHNCGamma_ext/main.cpp new file mode 100644 index 000000000..52468a1d7 --- /dev/null +++ b/src/contrib/test/COHNCGamma_ext/main.cpp @@ -0,0 +1,73 @@ +#include +#include +#include "NCgamma_Diff_Cross_Section.h" +#include "NCgamma_Parameters_GeV.h" + +using namespace NC_gamma; + +int main() { + + std::ofstream file; + file.open("/home/edusaul/Desktop/d5_Delta_avg.dat"); + + std::string nucleus = "12C"; + std::string mode = "nu"; + + Diff_Cross_Section cs(mode, nucleus); + + double k0 = 1.0; //GeV + double kg0 = 0.0;//0.3; //GeV + double phig = 10.0 * 3.14159/180.0;//* NCgamma_Param::pi/180; + double thetag = 10.0 * 3.14159/180.0;//* NCgamma_Param::pi/180; + double th = 10.0 * 3.14159/180.0;//* NCgamma_Param::pi/180; +// double Enu_final = 0.00525802;//k0 - kg0; + + int npts = 50; + double Enu_final_min = 0.0; + double Enu_final_max = k0; + double Enu_final = Enu_final_max; + + double diff_cs; + +// std::cout<<"k0 = "< +#include + +#include +#include + +#include "Framework/Algorithm/Algorithm.h" +#include "Framework/Algorithm/AlgFactory.h" +#include "Framework/Messenger/Messenger.h" +#include "Framework/ParticleData/PDGCodes.h" +#include "Framework/Utils/CmdLnArgParser.h" +#include "Framework/Utils/KineUtils.h" +#include "Physics/Coherent/XSection/COHFormFactorI.h" +#include "Physics/Coherent/XSection/COHFormFactorMap.h" +#include "Physics/Coherent/XSection/DeVriesFormFactor.h" +#include "Physics/Coherent/XSection/FourierBesselFFCalculator.h" + +using namespace genie; +using namespace std; + + +void gtestCOHNCGamma (); +void FormFactorTest(const TFile & f); +void FFInterpolateTest(const TFile & f); +void DeltaFFTest(const TFile & f); +void RTest(); +void XSecTest(const TFile & f); + + +//__________________________________________________________________________ +void gtestCOHNCGamma () +{ + TFile file("./coh_ncgamma.root","recreate"); + + // Modules under test + FormFactorTest(file); // DeVries form factors + FFInterpolateTest(file); // Interpolation and Fourier Bessel coeffs. + DeltaFFTest(file); // Delta transition form factors + RTest(); // Delta current matrix traces + XSecTest(file); // Top level cross section + + file.Close(); +} + +//__________________________________________________________________________ +void FormFactorTest(const TFile & f) +{ + + cout << "\n ============= Beginning DeVries FF Test ============== \n" << endl; + + // -- define the out TTree + TTree * ncgamma = new TTree("FF_DeVries","COH NC Gamma"); + int brTgt; // neutrino PDG code + double brpFF; // proton FF + double brnFF; // neutron FF + double brQ; // Q momentum + bool brNuc; // Nucleus check + + ncgamma->Branch("tgt", &brTgt, "tgt/I"); + ncgamma->Branch("pFF", &brpFF, "pFF/D"); + ncgamma->Branch("nFF", &brnFF, "nFF/D"); + ncgamma->Branch("qmom", &brQ, "qmom/D"); + ncgamma->Branch("has_nuc", &brNuc, "has_nuc/B"); + + // -- request the COH NC Gamma model + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("COHFormFactorMap","Default"); + const Algorithm * alg = algf->GetAlgorithm(id); + const COHFormFactorMap * ffmap_alg = dynamic_cast(alg); + + const int kNTgt = 5; + const int kNQ = 20; + int target [kNTgt] = {1000010030, 1000060120, 1000020030, 1000180400, 1000260560}; // = { 3H, 12C, 3He, 40Ar, 56Fe }; + double Qmom [kNQ] = {0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1}; + double pFF_arr [kNQ]; + double nFF_arr [kNQ]; + + for(int itgt=0; itgtHasNucleus(brTgt); + if( !brNuc ) { + cout << "Target " << brTgt << " not found " << endl; + continue; + } + + for(int iQ=0; iQProtonFF( brQ, brTgt ); + brnFF = ffmap_alg->NeutronFF( brQ, brTgt ); + + pFF_arr[iQ] = brpFF; + nFF_arr[iQ] = brnFF; + + if ( brpFF != brnFF ) { cout << "Warning Proton and Neutron FF differ!" <SetTitle("neutron FF vs Q"); + pFF_Q->GetXaxis()->SetTitle("Q (GeV)"); + nFF_Q->GetXaxis()->SetTitle("Q (GeV)"); + pFF_Q->GetYaxis()->SetTitle("FF"); + nFF_Q->GetYaxis()->SetTitle("FF"); + + ncgamma->Write(); + pFF_Q->Write(); + nFF_Q->Write(); + + cout << "End of DeVries FF test!" << endl; +} + +//__________________________________________________________________________ +void FFInterpolateTest(const TFile & f) +{ + + cout << "\n ============= Beginning FF Interpolation Test ============== \n" << endl; + + // -- define the out TTree + TTree * ff_int = new TTree("FF_Int","COH NC Gamma"); + int brTgt; // neutrino PDG code + double brpFF; // proton FF + double brnFF; // neutron FF + double brQ; // Q momentum + bool brNuc; // Nucleus check + + ff_int->Branch("tgt", &brTgt, "tgt/I"); + ff_int->Branch("pFF", &brpFF, "pFF/D"); + ff_int->Branch("nFF", &brnFF, "nFF/D"); + ff_int->Branch("qmom", &brQ, "qmom/D"); + ff_int->Branch("has_nuc", &brNuc, "has_nuc/B"); + + // -- request the COH NC Gamma model + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("COHFormFactorInterpolation","Default"); + const Algorithm * alg = algf->GetAlgorithm(id); + const COHFormFactorInterpolation * ffint_alg = dynamic_cast(alg); + + const int kNTgt = 5; + const int kNQ = 20; + int target [kNTgt] = {1000010030, 1000060120, 1000020030, 1000180400, 1000260560}; // = { 3H, 12C, 3He, 40Ar, 56Fe }; + double Qmom [kNQ] = {0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1}; + double pFF_arr [kNQ]; + double nFF_arr [kNQ]; + + for(int itgt=0; itgtHasNucleus(brTgt); + if( !brNuc ) { + cout << "Target " << brTgt << " not found " << endl; + continue; + } + + for(int iQ=0; iQProtonFF( brQ, brTgt ); + brnFF = ffint_alg->NeutronFF( brQ, brTgt ); + + pFF_arr[iQ] = brpFF; + nFF_arr[iQ] = brnFF; + + if ( brpFF != brnFF ) { cout << "Warning Proton and Neutron FF differ!" <SetTitle("neutron FF vs Q"); + pFF_Q->GetXaxis()->SetTitle("Q (GeV)"); + nFF_Q->GetXaxis()->SetTitle("Q (GeV)"); + pFF_Q->GetYaxis()->SetTitle("FF"); + nFF_Q->GetYaxis()->SetTitle("FF"); + + ff_int->Write(); + pFF_Q->Write(); + nFF_Q->Write(); + + cout << "End of FF Interpolation test!" << endl; +} + +//__________________________________________________________________________ +void DeltaFFTest(const TFile & f) +{ + + cout << "\n ============= Beginning Delta Transition FF Test ============== \n" << endl; + + // -- define the out TTree + TTree * dt_ff = new TTree("DeltaTransFF","COH NC Gamma"); + double brC3V; // FF + double brC3VNC; // FF + double brC5ANC; // FF + double brQ; // Q momentum + + dt_ff->Branch("C3V", &brC3V, "C3V/D"); + dt_ff->Branch("C3VNC", &brC3VNC, "C3VNC/D"); + dt_ff->Branch("C5ANC", &brC5ANC, "C5ANC/D"); + dt_ff->Branch("qmom", &brQ, "qmom/D"); + + // -- request the COH NC Gamma model + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("DeltaTransitionFormFactor","Default"); + const Algorithm * alg = algf->GetAlgorithm(id); + const DeltaTransitionFormFactor * dt_ff_alg = dynamic_cast(alg); + + const int kNQ = 20; + double Qmom [kNQ] = {0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1}; + double C3V_arr [kNQ]; + double C3VNC_arr [kNQ]; + double C5ANC_arr [kNQ]; + + for(int iQ=0; iQC3V(brQ); + brC3VNC = dt_ff_alg->C3VNC(brQ); + brC5ANC = dt_ff_alg->C5ANC(brQ); + + C3V_arr[iQ] = brC3V; + C3VNC_arr[iQ] = brC3VNC; + C5ANC_arr[iQ] = brC5ANC; + + cout << "Q = " << brQ << " C3V = " << brC3V << " C3VNC = " << brC3VNC << " C5ANC = " << brC5ANC << endl; + dt_ff->Fill(); + } + + TGraph * C3V = new TGraph(kNQ, Qmom, C3V_arr); + TGraph * C3VNC = new TGraph(kNQ, Qmom, C3VNC_arr); + TGraph * C5ANC = new TGraph(kNQ, Qmom, C5ANC_arr); + + C3V->SetTitle("C3V vs Q"); + C3VNC->SetTitle("C3VNC vs Q"); + C5ANC->SetTitle("C5ANC vs Q"); + C3V->GetXaxis()->SetTitle("Q (GeV)"); + C3VNC->GetXaxis()->SetTitle("Q (GeV)"); + C5ANC->GetXaxis()->SetTitle("Q (GeV)"); + C3V->GetYaxis()->SetTitle("C3V"); + C3VNC->GetYaxis()->SetTitle("C3VNC"); + C5ANC->GetYaxis()->SetTitle("C5ANC"); + + dt_ff->Write(); + C3V->Write(); + C3VNC->Write(); + C5ANC->Write(); + + cout << "End of Delta Transistion FF test!" << endl; +} + +//__________________________________________________________________________ +void RTest() +{ + + cout << "\n ============= Beginning Delta Current Trace Test ============== \n" << endl; + + int target = 1000180400; // 40Ar + int probe = 14; // nu mu + int prod = 22; // gamma + double E = 1.1; + + // -- request the COH NC Gamma model + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("COHDeltaCurrent","Default"); // combine + const Algorithm * algR = algf->GetAlgorithm(id); + const COHDeltaCurrent * Dcurr_alg = dynamic_cast(algR); + + // Get the DeVries form factors + AlgId idFF("COHFormFactorMap","Default"); + const Algorithm * algFF = algf->GetAlgorithm(idFF); + const COHFormFactorMap * ffmap_alg = dynamic_cast(algFF); + + // Set up the interaction and kinematics + Interaction * i = genie::Interaction::COHNC(target, probe, prod, E); + Kinematics * kine = i->KinePtr(); + + // Naively set kinematic values + kine->SetHadSystP4(0.1,0.1,0.3,0.7); + kine->SetFSLeptonP4(0.1,0.1,0.5,0.9); + + const int kNQ = 8; + double Qmom [kNQ] = {0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; + + cout << "Resonance Delta 1232 code " << Dcurr_alg->Resonance() << endl; + + for(int iQ=0; iQSetQ2(pow( Qmom[iQ], 2 )); + utils::math::GTrace R = Dcurr_alg->R(i, ffmap_alg); + + for ( unsigned int i=0; iBranch("xsec", &brXsec, "xsec/D"); + ncgamma_xsec->Branch("integral", &brInt, "integral/D"); + ncgamma_xsec->Branch("q", &brQ, "q/D"); + ncgamma_xsec->Branch("e", &brE, "e/D"); + + int target = 1000180400; // 40Ar + int probe = 14; // nu mu + int prod = 22; // gamma + + // -- request the COH NC Gamma model + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("AlvarezRusoSalaCOHGammaPXSec","Default"); + const Algorithm * algXsec = algf->GetAlgorithm(id); + const AlvarezRusoSalaCOHGammaPXSec * xsec_alg = dynamic_cast(algXsec); + + // Not used for now so let it initialize to whatever + KinePhaseSpace_t t; + + const int kNQ = 20; + double Qmom [kNQ] = {0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.65,0.07,0.075,0.08,0.085,0.09,0.1,0.15,0.2}; + double Evec [kNQ] = {0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0}; + double Xsec_arr [kNQ]; + double Int_arr [kNQ]; + + for(int iQ=0; iQKinePtr(); + + // Naively set kinematic values + kine->SetHadSystP4(0.01,0.01,0.03,brE*0.5); + kine->SetFSLeptonP4(0.01,0.01,0.05,brE*0.2); + kine->Setx(0.1); + kine->Sety(0.15); + + bool vp = xsec_alg->ValidProcess(i); + bool vk = xsec_alg->ValidKinematics(i); + if ( (!vp) || (!vk) ) { + cout << "Valid Process " << vp << " Valid Kinematics " << vk << endl; + continue; + } + + kine->SetQ2(pow( brQ, 2 )); + + brXsec = xsec_alg->XSec(i, t); + brInt = xsec_alg->Integral(i); + cout << "Q " << brQ << " E " << brE << " XSec " << brXsec << " XSec Integral " << brInt << endl; + + Xsec_arr[iE] = brXsec; + Int_arr[iE] = brInt; + ncgamma_xsec->Fill(); + } + } + + TGraph * gxsec = new TGraph(kNQ, Evec, Xsec_arr); + TGraph * gint = new TGraph(kNQ, Evec, Int_arr); + + gxsec->SetTitle("XSec vs E"); + gint->SetTitle("Integral vs E"); + gxsec->GetXaxis()->SetTitle("E (GeV)"); + gint->GetXaxis()->SetTitle("E (GeV)"); + gxsec->GetYaxis()->SetTitle("XSec"); + gint->GetYaxis()->SetTitle("Integral"); + + ncgamma_xsec->Write(); + gxsec->Write(); + gint->Write(); + + cout << "End of NC Gamma XSec test!" << endl; +} diff --git a/src/contrib/test/gtestCOHNCGammaXSec.C b/src/contrib/test/gtestCOHNCGammaXSec.C new file mode 100644 index 000000000..b6c8cfd25 --- /dev/null +++ b/src/contrib/test/gtestCOHNCGammaXSec.C @@ -0,0 +1,298 @@ +//____________________________________________________________________________ +/*! + +\program gtestCOHNCGammaXSec.C + +\brief Macro to use for testing/debugging the COH NCGamma model and compare to external + cross section results. + + Run with: (make sure to enclose the macro in "" ) + `genie -l "COHNCGammaXSec.C(target, probe_pdg, max_nu_energy)"` + + optional additional arguements are: + `genie -l "COHNCGammaXSec.C(target, probe_pdg, max_nu_energy, theta_incoming_nu, theta_gamma, phi_gamma)"` + + For example: an incoming neutrino (14) with energy of 1GeV interacting with a 40Ar (1000180400) nucleus + `genie -l "COHNCGammaXSec.C(14,1000180400,1)"` + + See below in "Main parameters for COH NC Single Gamma Cross Section for defintion of the parameters. + +\author Jon Sensenig inspired by gtestDISSF test file + +\created July 23, 2020 + +*/ +//____________________________________________________________________________ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +#include "Framework/Algorithm/Algorithm.h" +#include "Framework/Algorithm/AlgFactory.h" +#include "Framework/Messenger/Messenger.h" +#include "Framework/Conventions/Units.h" +#include "Framework/ParticleData/PDGCodes.h" +#include "Framework/Utils/CmdLnArgParser.h" +#include "Framework/Utils/KineUtils.h" +#include "Framework/ParticleData/PDGLibrary.h" +#include "Physics/Coherent/XSection/COHFormFactorI.h" +#include "Physics/Coherent/XSection/DeVriesFormFactorMap.h" +#include "Physics/Coherent/XSection/DeVriesFormFactor.h" +#include "Physics/Coherent/XSection/FourierBesselFFCalculator.h" +#include "Physics/Coherent/XSection/AlvarezRusoSalaCOHGammaPXSec.h" + +#include "COHNCGamma_ext/NCgamma_Diff_Cross_Section.h" + +// Load the shared library for the external NC COH Gamma xsection +R__LOAD_LIBRARY(COHNCGamma_ext/libGenie_XSection.so) + +using namespace genie; +using namespace std; + +// Constructor for external X-Sec code +using namespace NC_gamma; +//Diff_Cross_Section CS("nu", "40Ar"); + +// Define so cleaner code later +typedef AlvarezRusoSalaCOHGammaPXSec ARSXSec; + +const unsigned int steps = 100; // Number of plotted xsec points +const unsigned int angles = 7; // Number of plotted gamma theta angles + +void gtestCOHNCGammaXSec(int tgt, int prb, double E, double theta_nu=1., double phi=0., bool loop_all=false); +void XSectionTest(const TFile & f); +void SigmaEg(const Interaction *i, const ARSXSec * xsec_alg, Kinematics * kine); +std::pair ExtXSec(int nu_probe, int tgt); +void PlotXSecs(double Eg_arr[steps], double gxsec[][steps], double exsec[][steps]); + +//////////////////////////// +// +// Main parameters for COH NC Single Gamma Cross Section +// +//////////////////////////// + +// Require set by main function +int target = -1000;// Target nucleus [pdg] +int probe = -1000;// Incoming particle pdg [pdg] +double probe_E = -1.; // Incoming nu energy [GeV] +// Defaults +int prod = 22; // Produced FS particle = gamma [pdg] +double theta_lep = 15.; // Outgoing nu wrt incoming nu [deg] +double phi_lep = 0.; // Outgoing nu in plane transverse to incoming nu [deg] +double theta_g = 1.; // Gamma angle wrt to incoming nu [deg] +double phi_g = 0.; // Gamma angle in plane transverse to incoming nu [deg] + +array theta_gamma = {1,5,10,30, 60, 90, 170}; // FS gamma wrt z-axis in deg +array root_color = {600,1,632,416,616,800,432}; + +///////////////////////////// + +double Eg_arr [steps]; +double xsec_arr[angles][steps]; +double ext_xsec_arr[angles][steps]; + +//__________________________________________________________________________ +void gtestCOHNCGammaXSec (int tgt, int prb, double E, double theta_nu, double phi, bool loop_all) +{ + + std::vector target_pdgs = {1000010030, 1000020030, 1000060120, 1000070150, 1000080160, 1000130270, 1000140280, + 1000140290, 1000140300, 1000150310, 1000160320, 1000160340, 1000160360, 1000180400, + 1000200400, 1000200480, 1000220480, 1000220500, 1000240500, 1000240520, 1000240540, + 1000260540, 1000260560, 1000260580, 1000270590, 1000280580, 1000280600, 1000280620, + 1000280640, 1000290630, 1000290650, 1000300640, 1000300660, 1000300680, 1000300700, + 1000320700, 1000320720, 1000320740, 1000320760, 1000380880, 1000400900, 1000400920, + 1000400940, 1000420920, 1000420940, 1000420960, 1000420980, 1000421000, 1000461040, + 1000461060, 1000461080, 1000461100, 1000621440, 1000621480, 1000621500, 1000621520, + 1000621540, 1000641540, 1000641580, 1000681660, 1000701740, 1000711750, 1000761920, + 1000781960, 1000812030, 1000812050, 1000822040, 1000822060, 1000822070, 1000822080, 1000832090}; + + target = tgt; + probe = prb; + probe_E = E; + theta_lep = theta_nu; + phi_g = phi; + + if ( loop_all ) { + for ( int tgt = 0; tgt < target_pdgs.size(); tgt++ ) { + target = target_pdgs.at(tgt); + TFile file("./coh_ncgamma.root","recreate"); + XSectionTest(file); // Top level cross section + file.Close(); + sleep(3); + } + } else { + + TFile file("./coh_ncgamma.root","recreate"); + XSectionTest(file); // Top level cross section + file.Close(); + } +} +//__________________________________________________________________________ +void XSectionTest(const TFile & file) +{ + + cout << "\n ============= Beginning COH NC 1gamma Test ============== \n" << endl; + + // Instantiate external cross section + std::pair params = ExtXSec(probe, target); + Diff_Cross_Section CS(params.first, params.second); // 1st = probe 2nd = target + + double range = probe_E; + double E_lep = probe_E; + + // -- request the COH NC Gamma model + AlgFactory * algf = AlgFactory::Instance(); + AlgId id("AlvarezRusoSalaCOHGammaPXSec","Default"); + const Algorithm * algXsec = algf->GetAlgorithm(id); + const XSecAlgorithmI * xsec_alg = dynamic_cast(algXsec); + + // Set up the interaction and kinematics + Interaction * i = Interaction::COHNC(target, probe, prod, probe_E); + Kinematics * kine = i->KinePtr(); + + // Set up the interaction kinematics + TVector3 p3_g; + TVector3 p3_lep; + TLorentzVector p4_g; + TLorentzVector p4_lep; + TLorentzVector p4_nu(0., 0., probe_E, probe_E); // probe along z + + KinePhaseSpace_t t = kPSEgOlOgfE; + + for( unsigned int ang = 0; ang < angles; ang++ ) { + theta_g = theta_gamma[ang]*TMath::DegToRad(); + E_lep = probe_E; + for( unsigned int eg = 0; eg < steps; eg++ ) { + + double E_g = probe_E - E_lep; + // Set FS gamma 4-mom. + p3_g.SetMagThetaPhi( E_g, theta_g*TMath::DegToRad(), + phi_g*TMath::DegToRad() ); + p4_g.SetVect( p3_g ); + p4_g.SetE( E_g ); + + // Set FS lepton (nu) 4-mom. + p3_lep.SetMagThetaPhi( E_lep, theta_lep*TMath::DegToRad(), 0. ); + p4_lep.SetVect( p3_lep ); + p4_lep.SetE( E_lep ); + + kine->SetHadSystP4( p4_g ); + kine->SetFSLeptonP4( p4_lep ); + + TLorentzVector q = p4_nu-p4_lep ; + double Q2 = -q.Mag2(); + double x = Q2/(2 * E_g * constants::kNucleonMass ); + double y = E_g/probe_E; + kine->Setx( x ); + kine->Sety( y ); + utils::kinematics::UpdateWQ2FromXY(i); + double coh_t = TMath::Abs( (q - p4_g).Mag2() ) ; + kine->Sett( coh_t ) ; + + // Check the validity + cout << " Gamma theta angle " << theta_gamma[ang] + << " Gamma Energy " << E_g << " Q2 " << Q2 << " x " << x << " y " << y + << " Valid process: " << xsec_alg->ValidProcess(i) + << " Valid Kinematics: " << xsec_alg->ValidKinematics(i) << endl; + + // Calculate Genie Xsection + xsec_arr[ang][eg] = (xsec_alg->XSec(i, t) * 1.e41)/units::cm2; + + // Calculate external Xsection + // If invalid process or kinematics set cross section to 0 + if ( !xsec_alg->ValidProcess(i) || !xsec_alg->ValidKinematics(i) ) { + ext_xsec_arr[ang][eg] = 0.; + } else { + ext_xsec_arr[ang][eg] = ( CS.getDiffCrossSection( probe_E, E_lep, theta_lep*TMath::DegToRad(), + theta_g*TMath::DegToRad(), phi_g*TMath::DegToRad() + )*1e41 ) / units::cm2; + } + + cout << "---> GENIE Cross Section: " << xsec_arr[ang][eg] + << " External Cross Section: " << ext_xsec_arr[ang][eg] << endl; + + Eg_arr[eg] = E_g; + E_lep -= range / double( steps-1 ); + + } // gamma E + } // gamma angle + + PlotXSecs(Eg_arr, xsec_arr, ext_xsec_arr); +} +//__________________________________________________________________________ +std::pair ExtXSec(int nu_probe, int tgt) +{ + std::pair ext_pdgs("",""); + + if (nu_probe == kPdgNuMu) ext_pdgs.first = "nu"; + else if (nu_probe == kPdgAntiNuMu) ext_pdgs.first = "anti-nu"; + else std::cout << "Unknown probe pdg!" << std::endl; + + if (tgt == 1000060120) ext_pdgs.second = "12C"; + else if (tgt == 1000180400) ext_pdgs.second = "40Ar"; + else std::cout << "Unknown nucleus pdg!" << std::endl; + + return ext_pdgs; +} +//__________________________________________________________________________ +void PlotXSecs(double Eg_arr[steps], double gxsec[][steps], double exsec[][steps]) { + + + TLegend *legend = new TLegend(0.5,0.7,0.9,0.9); + TCanvas *c1 = new TCanvas("c1","COH NC Gamma",10,10,1000,450); + c1->Divide(2,1); + + auto mg = new TMultiGraph(); + auto ext_mg = new TMultiGraph(); + + char text[50]; + for( unsigned int k = 0; k < angles; k++ ) { + auto gr = new TGraph( steps, Eg_arr, gxsec[k] ); gr->SetLineColor( root_color[k] ); gr->SetLineWidth(2); + auto egr = new TGraph( steps, Eg_arr, exsec[k] ); egr->SetLineColor( root_color[k] ); egr->SetLineWidth(2); + + snprintf( text, 50, "#theta_{#gamma} = %d",(int)theta_gamma[k] ); + legend->AddEntry( gr, (char*)text, "l" ); + + mg->Add(gr); + ext_mg->Add(egr); + } + + stringstream description ; + + TParticlePDG * tprobe = PDGLibrary::Instance() -> Find( probe ) ; + TParticlePDG * ttgt = PDGLibrary::Instance() -> Find( target ) ; + + description << probe_E << " GeV " << tprobe -> GetTitle() << " on " << ttgt -> GetTitle() ; + description << " #theta_{l}=" << theta_lep << "#circ" ; + description << " #phi_{#gamma}=" << phi_g << "#circ" ; + description << ";E_{#gamma} [GeV];#frac{d^{5}#sigma}{dE_{#gamma}d#Omega_{l}d#Omega_{#gamma}} [10^{-41} #frac{cm^{2}}{GeV}]" ; + + std::string genie_title = "GENIE " + description.str() ; + std::string ext_title = "Eduardo " + description.str() ; + + mg->SetTitle( genie_title.c_str() ); + ext_mg->SetTitle( ext_title.c_str() ); + + c1->cd(1); + mg->Draw("ACP"); + legend->Draw("same"); + c1 -> Update() ; + c1->cd(2); + ext_mg->Draw("ACP"); + + mg->Write(); + ext_mg->Write(); + legend -> Write( "legend" ) ; + +} diff --git a/src/scripts/production/batch/xsec_splines/vA_spline_generator.pl b/src/scripts/production/batch/xsec_splines/vA_spline_generator.pl index 8ee583f7d..f61bce94a 100644 --- a/src/scripts/production/batch/xsec_splines/vA_spline_generator.pl +++ b/src/scripts/production/batch/xsec_splines/vA_spline_generator.pl @@ -132,6 +132,7 @@ @nuclei_proc = ( 'none', 'WeakMEC', 'CCCOHPION', 'NCCOHPION', + 'COHGAMMA', 'Fast', 'FastWithMEC' ## this is supposed to be better with G16_01 comprehensive models );