pow[a_,b_]:=a^b

(*The coefficients C1, C3, CLminus, ... are defined in paper  M.Kabirnezhad  Phys.Rev.D 97, 013002 *)

(*sum(1|3)(Re|Im)(M|P|OM|OP)(M|P)(M|P) implies real or imaginary part of amplitudes sumed by all resonances with  I=1/2 or 3/2. For boson polarazation: M <-> (e^L), P <-> (e^R), OM <-> (SuperMinus[e]), OP <-> (SuperPlus[e]).
For nucleon polarazation P imply helicity +1/2, M imply helicity -1/2.
H(M|P|OM|OP)(M|P)(M|P) implies the difference between vectors and axial background contribution. The meaning of all symbols are the same as for resonance part*)

CL2=CLminus*CLminus+CLplus*CLplus;
CR2=CRminus*CRminus+CRplus*CRplus;
CLR=CLminus*CRminus+CLplus*CRplus;
CSminus2=CSminus*CSminus;
CSplus2=CSplus*CSplus;
C1=0;

(* The general expression for the differential cross section CC-processesses as coded in MK programms.
The expressions for NC processess are analogous and have the same mistakes, but is not conisdered here  
 *)
XSecMK =
CL2*(C3*C3*(sum3ImMPP*sum3ImMPP+sum3ImMMP*sum3ImMMP+sum3ImMPM*sum3ImMPM+sum3ImMMM*sum3ImMMM)+pow[HMPP+C3*sum3ReMPP,2]+pow[HMMP+C3*sum3ReMMP,2]+pow[HMPM+C3*sum3ReMPM,2]+pow[HMMM+C3*sum3ReMMM,2])+CR2*(C3*C3*(sum3ImPPP*sum3ImPPP+sum3ImPMP*sum3ImPMP+sum3ImPPM*sum3ImPPM+sum3ImPMM*sum3ImPMM)+pow[HPPP+C3*sum3RePPP,2]+pow[HPMP+C3*sum3RePMP,2]+pow[HPPM+C3*sum3RePPM,2]+pow[HPMM+C3*sum3RePMM,2])+CSminus2*(C3*C3*(sum3Im0MPP*sum3Im0MPP+sum3Im0MMP*sum3Im0MMP+sum3Im0MPM*sum3Im0MPM+sum3Im0MMM*sum3Im0MMM)+pow[H0MPP+C3*sum3Re0MPP,2]+pow[H0MMP+C3*sum3Re0MMP,2]+pow[H0MPM+C3*sum3Re0MPM,2]+pow[H0MMM+C3*sum3Re0MM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sum3Re0PMP)+sum3ImPPM*(H0PPM+C3*sum3Re0PPM)+sum3ImPMM*(H0PMM+C3*sum3Re0PMM)-(HPPP+C3*sum3RePPP)*sum3Im0PPP-(HPMP+C3*sum3RePMP)*sum3Im0PMP-(HPPM+C3*sum3RePPM)*sum3Im0PPM-(HPMM+C3*sum3RePMM)*sum3Im0PMM))+2*Cos[2*phi]*CLR*(C3*C3*(sum3ImMPP*sum3ImPPP+sum3ImMMP*sum3ImPMP+sum3ImMPM*sum3ImPPM+sum3ImMMM*sum3ImPMM)+(HMPP+C3*sum3ReMPP)*(HPPP+C3*sum3RePPP)+(HMMP+C3*sum3ReMMP)*(HPMP+C3*sum3RePMP)+(HMPM+C3*sum3ReMPM)*(HPPM+C3*sum3RePPM)+(HMMM+C3*sum3ReMMM)*(HPMM+C3*sum3RePMM))-2*Sin[2*phi]*C3*CLR*(sum3ImMPP*(HPPP+C3*sum3RePPP)+sum3ImMMP*(HPMP+C3*sum3RePMP)+sum3ImMPM*(HPPM+C3*sum3RePPM)+sum3ImMMM*(HPMM+C3*sum3RePMM)-(HMPP+C3*sum3ReMPP)*sum3ImPPP-(HMMP+C3*sum3ReMMP)*sum3ImPMP-(HMPM+C3*sum3ReMPM)*sum3ImPPM-(HMMM+C3*sum3ReMMM)*sum3ImPMM);


(* The definitions of helicity amplitudes *) 

(*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*)
(* Uncomment the code between >>>>>>>>>> lines and comment betwwen <<<<<<<<<<<<<<<<<< to switch on uncorrect phases assumed in the code probided by MK *)

(*sum3PPPC=(sum3RePPP+I*sum3ImPPP)*Exp[-2*I*phi];
sum3PMPC=(sum3RePMP+I*sum3ImPMP)*Exp[-I*phi];
sum3PPMC=(sum3RePPM+I*sum3ImPPM)*Exp[-I*phi];
sum3PMMC=(sum3RePMM+I*sum3ImPMM);

sum3MPPC=(sum3ReMPP+I*sum3ImMPP);
sum3MMPC=(sum3ReMMP+I*sum3ImMMP)*Exp[I*phi];
sum3MPMC=(sum3ReMPM+I*sum3ImMPM)*Exp[I*phi];
sum3MMMC=(sum3ReMMM+I*sum3ImMMM)*Exp[2*I*phi];

sum1PPPC=(sum1RePPP+I*sum1ImPPP)*Exp[-2*I*phi];
sum1PMPC=(sum1RePMP+I*sum1ImPMP)*Exp[-I*phi];
sum1PPMC=(sum1RePPM+I*sum1ImPPM)*Exp[-I*phi];
sum1PMMC=(sum1RePMM+I*sum1ImPMM);

sum1MPPC=(sum1ReMPP+I*sum1ImMPP);
sum1MMPC=(sum1ReMMP+I*sum1ImMMP)*Exp[I*phi];
sum1MPMC=(sum1ReMPM+I*sum1ImMPM)*Exp[I*phi];
sum1MMMC=(sum1ReMMM+I*sum1ImMMM)*Exp[2*I*phi];


HPPPC=HPPP*Exp[-2*I*phi];
HPMPC=HPMP*Exp[-I*phi];
HPPMC=HPPM*Exp[-I*phi];
HPMMC=HPMM;

HMPPC=HMPP;
HMMPC=HMMP*Exp[I*phi];
HMPMC=HMPM*Exp[I*phi];
HMMMC=HMMM*Exp[2*I*phi];*)
(*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*)


(*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*)
(* Uncomment the code between <<<<<<<<<<<<<<< lines and comment between >>>>>>>>>>>>>>>>> to switch on correct phases *)
sum3MPPC=(sum3ReMPP+I*sum3ImMPP)*Exp[-2*I*phi];
sum3MMPC=(sum3ReMMP+I*sum3ImMMP)*Exp[-I*phi];
sum3MPMC=(sum3ReMPM+I*sum3ImMPM)*Exp[-I*phi];
sum3MMMC=(sum3ReMMM+I*sum3ImMMM);

sum3PPPC=(sum3RePPP+I*sum3ImPPP);
sum3PMPC=(sum3RePMP+I*sum3ImPMP)*Exp[I*phi];
sum3PPMC=(sum3RePPM+I*sum3ImPPM)*Exp[I*phi];
sum3PMMC=(sum3RePMM+I*sum3ImPMM)*Exp[2*I*phi];

sum1MPPC=(sum1ReMPP+I*sum1ImMPP)*Exp[-2*I*phi];
sum1MMPC=(sum1ReMMP+I*sum1ImMMP)*Exp[-I*phi];
sum1MPMC=(sum1ReMPM+I*sum1ImMPM)*Exp[-I*phi];
sum1MMMC=(sum1ReMMM+I*sum1ImMMM);

sum1PPPC=(sum1RePPP+I*sum1ImPPP);
sum1PMPC=(sum1RePMP+I*sum1ImPMP)*Exp[I*phi];
sum1PPMC=(sum1RePPM+I*sum1ImPPM)*Exp[I*phi];
sum1PMMC=(sum1RePMM+I*sum1ImPMM)*Exp[2*I*phi];

HMPPC=HMPP*Exp[-2*I*phi];
HMMPC=HMMP*Exp[-I*phi];
HMPMC=HMPM*Exp[-I*phi];
HMMMC=HMMM;

HPPPC=HPPP;
HPMPC=HPMP*Exp[I*phi];
HPPMC=HPPM*Exp[I*phi];
HPMMC=HPMM*Exp[2*I*phi];
(*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*)

sum30PPPC=(sum3Re0PPP+I*sum3Im0PPP)*Exp[-I*phi];
sum30PMPC=(sum3Re0PMP+I*sum3Im0PMP);
sum30PPMC=(sum3Re0PPM+I*sum3Im0PPM);
sum30PMMC=(sum3Re0PMM+I*sum3Im0PMM)*Exp[I*phi];

sum30MPPC=(sum3Re0MPP+I*sum3Im0MPP)*Exp[-I*phi];
sum30MMPC=(sum3Re0MMP+I*sum3Im0MMP);
sum30MPMC=(sum3Re0MPM+I*sum3Im0MPM);
sum30MMMC=(sum3Re0MMM+I*sum3Im0MMM)*Exp[I*phi];

sum10PPPC=(sum1Re0PPP+I*sum1Im0PPP)*Exp[-I*phi];
sum10PMPC=(sum1Re0PMP+I*sum1Im0PMP);
sum10PPMC=(sum1Re0PPM+I*sum1Im0PPM);
sum10PMMC=(sum1Re0PMM+I*sum1Im0PMM)*Exp[I*phi];

sum10MPPC=(sum1Re0MPP+I*sum1Im0MPP)*Exp[-I*phi];
sum10MMPC=(sum1Re0MMP+I*sum1Im0MMP);
sum10MPMC=(sum1Re0MPM+I*sum1Im0MPM);
sum10MMMC=(sum1Re0MMM+I*sum1Im0MMM)*Exp[I*phi];

H0PPPC=H0PPP*Exp[-I*phi];
H0PMPC=H0PMP;
H0PPMC=H0PPM;
H0PMMC=H0PMM*Exp[I*phi];

H0MPPC=H0MPP*Exp[-I*phi];
H0MMPC=H0MMP;
H0MPMC=H0MPM;
H0MMMC=H0MMM*Exp[I*phi];

(*  The correct cross section implemented in GENIE and presented in Eq. (18) of paper 
M.Kabirnezhad  Phys.Rev.D 97,013002 *)
XSec=
 Abs[CLminus*(HMPPC+C3*sum3MPPC+C1*sum1MPPC)+CRminus*(HPPPC+C3*sum3PPPC+C1*sum1PPPC)+CSminus*(H0MPPC+C3*sum30MPPC+C1*sum10MPPC)]^2+Abs[CLplus*(HMPPC+C3*sum3MPPC+C1*sum1MPPC)+CRplus*(HPPPC+C3*sum3PPPC+C1*sum1PPPC)+CSplus*(H0PPPC+C3*sum30PPPC+C1*sum10PPPC)]^2+Abs[CLminus*(HMPMC+C3*sum3MPMC+C1*sum1MPMC)+CRminus*(HPPMC+C3*sum3PPMC+C1*sum1PPMC)+CSminus*(H0MPMC+C3*sum30MPMC+C1*sum10MPMC)]^2+Abs[CLplus*(HMPMC+C3*sum3MPMC+C1*sum1MPMC)+CRplus*(HPPMC+C3*sum3PPMC+C1*sum1PPMC)+CSplus*(H0PPMC+C3*sum30PPMC+C1*sum10PPMC)]^2+Abs[CLminus*(HMMMC+C3*sum3MMMC+C1*sum1MMMC)+CRminus*(HPMMC+C3*sum3PMMC+C1*sum1PMMC)+CSminus*(H0MMMC+C3*sum30MMMC+C1*sum10MMMC)]^2+Abs[CLplus*(HMMMC+C3*sum3MMMC+C1*sum1MMMC)+CRplus*(HPMMC+C3*sum3PMMC+C1*sum1PMMC)+CSplus*(H0PMMC+C3*sum30PMMC+C1*sum10PMMC)]^2+Abs[CLminus*(HMMPC+C3*sum3MMPC+C1*sum1MMPC)+CRminus*(HPMPC+C3*sum3PMPC+C1*sum1PMPC)+CSminus*(H0MMPC+C3*sum30MMPC+C1*sum10MMPC)]^2+Abs[CLplus*(HMMPC+C3*sum3MMPC+C1*sum1MMPC)+CRplus*(HPMPC+C3*sum3PMPC+C1*sum1PMPC)+CSplus*(H0PMPC+C3*sum30PMPC+C1*sum10PMPC)]^2;

XSecExp=ComplexExpand[XSec];


(* The difference between cross section coded by MK and correct cross section
 It will be equal to zero if one uncomment uncorrect phases between two lines >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 In case of correct amplitudes it shouldn't be equal to zero *)
XSecDiff=FullSimplify[XSecExp-XSecMK]