// MCDiag.h
// A diagnostic tool used to fire particles at random across a specified
// momentum range and solid angle

#ifndef MCDIAG
#define MCDIAG

#include <stdio.h>
#include <stdlib.h>
#include "TROOT.h"
#include "TMath.h"
#include "TRandom.h"
#include "readStdFile.h"
#include "EventSource.h"


class MCDiag : public EventSource {

public:

  MCDiag(char* ofile);
  ~MCDiag(){};
  
  void Set_Seed(UInt_t seed);
  void Set_Spread(Double_t magspread,Double_t costhspread,Double_t phispread);
  void Set_Momentum(Double_t mag, Double_t costheta, Double_t phi);
  void Set_Start_Point(Double_t xpoint, Double_t ypoint, Double_t zpoint);
  void Set_Production_Time(Double_t time);
  void Set_Particles(Int_t num);

  // For particle type, use StdHep numbering scheme.  Currently (3/23/99)
  // supported types are
  //    11            electron
  //    13            muon
  //   111            pi-zero
  //   211            pi-plus
  //  2112            neutron
  //  2212            proton
  //   321            k-plus
  //   310            k0-short
  //   130            k0-long
  void Set_Type(Int_t type);

  Int_t getEvent(Event* event);
  Int_t doit();
  Int_t spew(char* ofile)const;
  void cleanup();
  
private:
  TRandom* factor;
  Double_t m_MagSpread;
  Double_t  m_CosThSpread;
  Double_t m_PhiSpread;
  Double_t m_xpoint;
  Double_t m_ypoint;
  Double_t m_zpoint;
  Double_t m_prod_time;
  Int_t m_NumParticles;
  Double_t m_mag;
  Double_t m_phi;
  Double_t m_costheta;
  Double_t m_mass;
  Int_t m_type;
  Int_t istr;
  Int_t ilbl;
  static Int_t m_known_parts[];
  static Double_t m_known_masses[];
  static Int_t m_num_known_parts;

public:
  ClassDef(MCDiag,0)        // Generates specified particle

};

#endif
