Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

GLG4VertexGen.hh

Go to the documentation of this file.
00001 #ifndef __GLG4VertexGen_h__
00002 #define __GLG4VertexGen_h__ 1
00003 /** @file
00004  Declares GenericLAND global vertex generator classes for primary events,
00005  (See note on GenericLAND generators for more information.)
00006 
00007  This file is part of the GenericLAND software library.
00008  $Id: GLG4VertexGen.hh,v 1.2 2005/01/29 21:50:20 GLG4sim Exp $
00009 
00010  @author G.Horton-Smith, August 3, 2001
00011 */
00012 
00013 #include "globals.hh"
00014 #include <stdio.h> // for FILE
00015 #include <set>     // for multiset
00016 
00017 class G4Event;
00018 class G4Track;
00019 class G4PrimaryVertex;
00020 class G4ParticleDefinition ;
00021 class GLG4PrimaryGeneratorAction;
00022 
00023 /** Virtual base class for vertex generators */
00024 class GLG4VVertexGen {
00025 public:
00026   GLG4VVertexGen(const char *arg_dbname) : _dbname(arg_dbname) { }
00027   virtual ~GLG4VVertexGen() { }
00028   virtual void GeneratePrimaryVertex( G4Event *argEvent )=0;
00029   // adds vertices.
00030   virtual void SetState( G4String newValues ) = 0;
00031   // sets filename or other information needed by vertex generator
00032   virtual G4String GetState() = 0;
00033   // returns the current state information in a form that can be understood
00034   // by SetState (and, hopefully, a well-informed human)
00035 protected:
00036   G4String _dbname; // used for GLG4param key prefix
00037 };
00038 
00039 
00040 /** vertex generator that can generate a primary vertex with one more
00041     particles of a given type, direction, energy, and polarization.
00042     Allows for randomly isotropic direction and random transverse polarization
00043     of spin-1, mass=0 particles */
00044 class GLG4VertexGen_Gun : public GLG4VVertexGen {
00045 public:
00046   GLG4VertexGen_Gun(const char *arg_dbname);
00047   virtual ~GLG4VertexGen_Gun();
00048   virtual void GeneratePrimaryVertex( G4Event *argEvent );
00049   // generates a primary vertex with given particle type, direction, energy,
00050   // and consistent polarization.
00051   virtual void SetState( G4String newValues );
00052   // format: particle_name  dir_x dir_y dir_z  kinetic_energy  polx poly polz
00053   // If dir_x==dir_y==dir_z==0, the directions are isotropic.
00054   // If particle has mass==0 and spin==1, final polarization will be
00055   // projected into plane perpindicular to momentum and made a unit vector;
00056   // if polarization has zero magnitude, a polarization is chosen randomly.
00057   virtual G4String GetState();
00058   // returns current state formatted as above
00059 
00060 public:
00061   // the following useful static const data should be universally accessable
00062   // (I copied it from the G4IonTable source code, where it is privatized
00063   // with no accessor functions.)
00064   enum { numberOfElements = 110};
00065   static const char * theElementNames[numberOfElements];
00066 
00067 private:
00068   G4ParticleDefinition *_pDef;
00069   G4ThreeVector _mom;
00070   G4double _ke;
00071   G4ThreeVector _pol;
00072   G4int _multiplicity;
00073 };
00074 
00075 /** vertex generator that generates a primary vertex based on
00076     information from an ASCII stream.
00077     The ASCII stream contains information in a HEPEVT-like style.
00078 */
00079 class GLG4VertexGen_HEPEvt : public GLG4VVertexGen {
00080 public:
00081   GLG4VertexGen_HEPEvt(const char *arg_dbname);
00082   virtual ~GLG4VertexGen_HEPEvt();
00083   virtual void GeneratePrimaryVertex( G4Event *argEvent );
00084   // Generates a primary vertex based on information from an ASCII stream.
00085   // The ASCII stream contains information in a HEPEVT style.
00086   virtual void SetState( G4String newValues );
00087   // The argument is a Perl "open" style filename argument:
00088   // if the filename ends with '|', the filename is interpreted as
00089   // a command which pipes output to us; otherwise, if the filename begins
00090   // with '<' or an ordinary character, the file is opened for input.
00091   // The "pipe" style can be used to read a gzip'ped file or to start
00092   // a program which feeds events to us directly.
00093   virtual G4String GetState();
00094   // returns current state formatted as above
00095 
00096   void Open(const char *argFilename);
00097   void GetDataLine(char *buffer, size_t size);
00098   void Close();
00099 
00100   enum { kIonCodeOffset = 9800000,       // nuclei have codes like 98zzaaa
00101          kPDGcodeModulus=10000000,       // PDG codes are 7 digits long
00102          kISTHEP_ParticleForTracking=1,  // only ISTHEP==1 are for tracking
00103          kISTHEP_InformatonMin=100,      // 100 and above are "informatons"
00104          kISTHEP_Max=213                 // <= MAXINT / kPDGcodeModulus
00105   };
00106   
00107 private:
00108   G4String _filename;
00109   FILE *   _file;
00110   bool _isPipe;
00111 };
00112 
00113 
00114 class GLG4VertexGen_Stack : public GLG4VVertexGen {
00115 public:
00116   GLG4VertexGen_Stack(const char *arg_dbname,GLG4PrimaryGeneratorAction* argGLG4PGA);
00117   virtual ~GLG4VertexGen_Stack();
00118   virtual void GeneratePrimaryVertex( G4Event *argEvent );
00119   // Generates a primary vertex from stacked tracks.
00120   virtual void SetState( G4String newValues );
00121   // Does nothing.
00122   virtual G4String GetState();
00123   // returns ""
00124 
00125   void StackIt(const G4Track* track);
00126 
00127   struct LessThan_for_VertexTime {
00128     bool operator()(G4PrimaryVertex* a, G4PrimaryVertex* b)
00129     { return ( a->GetT0() < b->GetT0() ); }
00130   };
00131   
00132 private:
00133   GLG4PrimaryGeneratorAction* fGLG4PGA;
00134   std::multiset<G4PrimaryVertex*,LessThan_for_VertexTime> _stack;
00135   typedef std::multiset<G4PrimaryVertex*,LessThan_for_VertexTime>::iterator _stack_iterator_t;
00136 };
00137 
00138 
00139 #endif

Generated on Fri Jul 6 13:31:46 2007 for GLG4sim by  doxygen 1.3.9.1