/* 
* Copyright (C) 2001-2008, CompHEP Collaboration
* Copyright (C) 1997, Alexander Pukhov 
* ------------------------------------------------------
* $Id: model.c,v 1.5 2003/09/22 11:34:09 sherstnv Exp $
*
* $Log: model.c,v $
* Revision 1.5  2003/09/22 11:34:09  sherstnv
* Process entering divides to 2 stages:
* 1) At first, we enter beams (name, mass, content, str,fun)
* 2) after that - final state.
*
* Revision 1.4  2003/06/25 18:46:41  kryukov
* *** empty log message ***
*
* Revision 1.3  2003/04/22 09:01:20  kryukov
* Apply indent to improve readability of files
*
* Revision 1.2  2003/04/20 17:55:02  kryukov
* Clean up warnings during make
*/
#include<stdlib.h>
#include<string.h>

#include "service2/include/chep_limits.h"

#include"model.h"

int nmodelvar;
varlist modelvars = NULL;
prtcl_base *prtclbase = NULL;

int nparticles;			/*  Number particles in model */
algvertptr lgrgn = NULL;

int n_cpart;
cparticles cpartbase = NULL;

int n_hadron;
_hadron_  hadronbase = NULL;
hadron hadrons[MAXINOUT];
__beam__ beam[2];

int n_strfun;
_strfun_ strfunbase = NULL;


int 
locateinbase (char *name)
{
  int i;
  for (i = 0; i < nparticles; i++)
    {
      if (strcmp (name, prtclbase[i].name) == 0)
	return i + 1;
    }
  return 0;
}


int
prtclname (int n, vshortstr nm)
{
  if (n > nparticles-1 || n < 1) strcpy(nm,"");
  else strcpy(nm,prtclbase[n-1].name);
  return 0;
}



int 
pseudop (int p)
{
  return (p == 0 || p > nparticles || prtclbase[p - 1].hlp == '*');
}
int 


fermionp (int p)
{
  return (prtclbase[p - 1].spin % 2 == 1 && p <= prtclbase[p - 1].anti);
}


int 
a_fermionp (int p)
{
  return (prtclbase[p - 1].spin % 2 == 1 && p >= prtclbase[p - 1].anti);
}


int 
bosonp (int p)
{
  return (prtclbase[p - 1].spin % 2 == 0);
}


int 
vectorp (int p)
{
  return (prtclbase[p - 1].spin == 2);
}


int 
zeromass (int p)
{
  return (strcmp (prtclbase[p - 1].massidnt, "0") == 0);
}
int 


photonp (int p)
{
  return ((vectorp (p) && zeromass (p)) || pseudop (p));
}


int 
ghostp (int p)
{
  return (prtclbase[p - 1].hlp == 'c' || prtclbase[p - 1].hlp == 'C' || prtclbase[p - 1].hlp == 'f');
}


int 
gaugep (int p)
{
  return (p != 0 && prtclbase[p - 1].hlp == 'G');
}


int 
ghostmother (int j)
{
  if (j == 0)
    return 0;
  switch (prtclbase[j - 1].hlp)
    {
    case 'c':
      return j - 1;
    case 'C':
      return j - 2;
    case 'f':
      return j - 3;
    case 't':
      return j + 1;
    default:
      return j;
    }
}
