(* *********************************************************** *)
(*                                                             *)
(*                      General.m                              *)
(*                                                             *)
(* *********************************************************** *)

BeginPackage["FeynArts`"]

                          (** symbols without special tasks **)

Gaugetypes  = {  FeynmanGauge, UnitaryGauge };
Fieldpoints = {  e ,  v3 , v4 };
Momenta     = {  p ,  q , k };
ExternProptypes  = { ex , inc , out }; 
InternProptypes  = { in , l1 , l2 , l3 , l4 , l5 , l6 ,
                          l7 , l8 , l9 , l10, l11, l12  };
Indices     = { fi , li , gi };
Results     = { FeynAmpList , FeynAmp , 
		SpinorChain , DiracTrace , GellMannTrace ,
		GraphName , MomentumIntegration ,
		Insertions , Graph , Process };
FeynArtsSymbols = { 
    Greek ,                          (* for greek graph symbols*)
    Sub ,                            (* subscript in graphs    *)
    dummy ,                          (* for gluon-4-coupling   *)
    SU3F ,
    GellMannMatrix ,
    SU3Delta ,
    FeynAmpDenominator ,             (* (complete) Denominator *)
    PropagatorDenominator ,          (* DenominatorFactor      *)
    MetricTensor ,                   (* metric Tensor D-dimens *)
    DiracSlash ,                     (* head of slashed vector *)
    DiracMatrix ,                    (* Gamma(mu), Gamma(5)    *)
    ChiralityProjector ,             (* with args +1/-1        *)
    Unprotect[QMM];Clear[QMM];
    QMM,                             (* QuarkMixing-Matrix     *)
    FourVector ,                    
    LeptonSpinor,                    (* Lepton spinor          *)
    QuarkSpinor,                     (* Quark  spinor          *)
    NonCommutative ,                 (* (of expression PV)     *)
    $D ,                             (* arbitrary dimension    *)
    PV ,                             (* head for anlyt. expr.  *)
    Mu ,		                 	       (* for dimens. regulariz. *)
    GaugeXi ,                        (* for arbitrary gauge .. *)
    A , Z , W ,			             (* .. with boson indices  *)
    Incoming ,                       (* heads for list of ..   *)
    Outgoing                         (* .. extern fields       *)
    }

TopologyList::usage ="
TopologyList is just the head of a list of topologies."

Topology::usage =" 
Topology[ s_ ][ ... ] is the head of one topology with \n
combinatorial factor s."

Propagator::usage =" 
Propagator[ type ][ from , to ] is the representation of one \n
single propagator.`type' is one of: \n
       	        `ex',`inc',`out' extern lines \n
         `in' intern line \n
         `li' intern line on loop nr i "

Vertex::usage ="
Vertex[ fi[1] , fi[2] , ... ] is the representation of a \n
fieldpoint with incoming fields fi[i]. "                               

AntiParticle::usage ="
AntiParticle[ mod ][ field ] gives the antiparticle of a field in \n
model `mod'."

VertexList::usage ="
VertexList[ mod ] gives a list with all couplings of model `mod'. \n
VertexList[ i_Integer ][ mod ] gives only i-Vertices."

ParticleList::usage ="
ParticleList[ mod ] gives a list of all particles of model `mod' ."

PossibleParticles::usage ="
PossibleParticles[ mod ][ vertex ] returns a list of particles that \n
can be inserted into the valences of vertex according to model `mod'."

AnalyticalCoupling::usage ="
AnalyticalCoupling[ mod ][ vertex ] gives the analytical expression \n
for a given vertex in model `mod'."

AnalyticalPropagator::usage ="
AnalyticalPropagator[ mod ][ from, to, field, momentum ] gives the \n
analytical expression for a propagator in model `mod'."
							   
Mass::usage ="
Mass[ mod ][ field ] yields the mass of the field (what else?)"

PropList::usage ="
PropList[ MOD ] is the list of propagators of model MOD. It is \n
defined in the file ./Models/model.MOD ."

CoupList::usage ="
CoupList[ MOD ] is the list of couplings of model MOD. It is defined \n
in the file ./Models/model.MOD ."

InitializedModels::usage = "
InitializedModels is an internal variable of FeynArts that lists the \n
initialized models (for InsertFields and CreateFeynAmp).   "

QuarkMixingMatrix::usage = "
QuarkMixingMatrix is just a 3x3 Matrix with elements QMMij (i,j=1..3)."

$ModelFiles::usage = "
$ModelFiles is the list of files whose names match `*model.*` when \n
FeynArts is loaded. "

                                          (** Options **)
Model::usage = "
Model is an option of InsertFields ."

ProcessName::usage = "
ProcessName is an option of InsertFields which allows \n
to choose a  cryptic process name that can be used as \n
a file name. "

UnitaryGauge::usage = "
UnitaryGauge is an option of FeynInit which turns the unitary \n
gauge on (because of renormalizability only for tree topologies)."

Generation1::usage = "
Generation1 is an option of FeynInit which switches the first \n
fermion generation on and off (electron, neutrino, up, down). "

Generation2::usage = " 
Generation2 is an option of FeynInit which switches the second \n
fermion generation on and off (muon, neutrino, charm, strange). "

Generation3::usage = "
Generation3 is an option of FeynInit which switches the third \n 
fermion generation on and off (tau, neutrino, top, bottom). "

QuarkMixing::usage = "
QuarkMixing is an option of FeynInit which, if set to True uses a \n
3x3 matrix QMM instead of the IdentityMatrix for quark flavour mixing."

LightFHCoupling::usage = "
LightFHCoupling is an option of FeynInit which switches the coupling \n
of light fermions (=all except the top quark) to the Higgs particles \n
on and off."

ElectronHCoupling::usage = "
ElectronHCoupling is an option of FeynInit that deletes the coupling \n
of the electron to the Higgs particle."

RemoveEmptyTops::usage = "
RemoveEmptyTops is an Option for InsertFields that allows to omit \n
Topologies which do not contain any realisations after the insertion \n
routine. "

ScreenMessages::usage = "
ScreenMessages is an Option InsertFields, Paint and CreateFeynAmp \n
to supress run time messages."

CheckModel::usage = "
CheckModel checks for not initialized models. \n
If all models in option Model of FeynInit are compatible \n
and if the model-files of the not initialized ones exist  \n
FeynInit is mapped onto those to initialize them."

ModelNameSymbol::usage = "
ModelNameSymbol[ Model->MOD, modeloptions ] returns a list of expressions \n
that describes the specified model."

SymbolToModel::usage = "
SymbolToModel extracts the model from the descriptional expression. "

PolarizationVector::usage = "
PolarizationVector is the Head for the Green function of a vector \n
particle. Its two indices are momentum and Lorentzindex.  \n
A negative argument denotes the complex conjugate."

                (** information for the Paint-(DrawLine)-Package **)

LineSpec::usage = "
LineSpec[ particle ] specifies the appearance of a propagator."

LineTypes = { straight, wavy, cycloid, dashed, dotted }

LineDirections = { forward, backward, none }

                (* extract model from descriptional expression *)

Begin["`Private`"]

SymbolToModel[ modelname_ ]:= Module[ {mstr},
       mstr=ToString[modelname];
       ToExpression[
         StringTake[ mstr,
                     Min[ StringPosition[mstr,"1"][[1,1]],
		          StringPosition[mstr,"0"][[1,1]] ]
		     -1 ] ]]

ModelNameSymbol[ opta___Rule , Model->mo_, optb___Rule ] := Module[
 {symbollist},
 Off[General::spell1];
  symbollist = (ToExpression[
    StringJoin@@
      ToString/@ Join[
      {#},
	   Select[ {opta,optb}, (!SameQ[#[[1]],ScreenMessages]
				  && !SameQ[#[[1]],ProcessName]
				  && !SameQ[#[[1]],Process]
				  && !SameQ[#[[1]],RemoveEmptyTops])& ]/.
           {Rule[_,True]->1, Rule[_,False]->0} ] ] )&  /@ mo;
 On[General::spell1];
 symbollist ];


CheckModel::singlemodels = "
model `1` can not be combined with one or more of the other models."

CheckModel[ options_List ] := Module[ {inter,newmodels,modelname},
   inter = Intersection[ Model/.options,SingleModels ];
   If[ Not[ inter === {}  || Length[Model/.options] === 1 ],
       Message[ CheckModel::singlemodels,First[inter] ];
       Return[$Aborted], 
       If[ ScreenMessages/.options ,
	   $Output = {"stdout"} ,
	   $Output = {FeynArtsNullDevice} ];
       Off[ General::spell1 ];
       On[ General::spell1 ];
       modelname = ModelNameSymbol@@ options ;
       newmodels = Select[ modelname,
		  	   !MemberQ[ InitializedModels,# ]& ];
       If[ MemberQ[( Print[" ... initializing model \"",#,"\""];
                     (FeynInit`FeynInit @@ Append[options,#]) )& /@newmodels,
		   $Aborted],
           Return[$Aborted] ];  (* FeynInit sets $Output to stdout *)
       If[ !(ScreenMessages/.options), $Output={FeynArtsNullDevice} ];
       modelname  
     ] ]

$ModelFiles = FileNames["model.*",$Path,2 ]

SetAttributes[Vertex, Orderless]

SetAttributes[TopologyList,Flat]

                 (** default for the QuarkMixingMatrix **)

Attributes[ QMM ] = {}

QMM = { { FeynArts`QMM11,FeynArts`QMM12,FeynArts`QMM13 },
	{ FeynArts`QMM21,FeynArts`QMM22,FeynArts`QMM23 },
	{ FeynArts`QMM31,FeynArts`QMM32,FeynArts`QMM33 } }

QuarkMixingMatrix = QMM
                       (** default for the line specifications **)

LineSpec[x_[y_]]:={straight,none,
                   StringJoin[ToString[x],ToString[Abs[y]]]}

		        	 (** protect FeynArts`-symbols **)

AllSymbols = {Models,Gaugetypes,
              Fieldtypes,Fieldpoints,Momenta,
	      ExternProptypes,InternProptypes,
	      Indices,Results,FeynArtsSymbols}

Map[Function[ z , SetAttributes[ # , Protected ]& /@ z ] , 
     AllSymbols ]

If[ Not[ ValueQ[InitializedModels] ],
	 InitializedModels = {}       ]

End[]

EndPackage[]

Null
