00001 // This file is part of the GenericLAND software library. 00002 // $Id: GLG4PosGen.hh,v 1.1.1.1 2004/12/21 22:29:48 GLG4sim Exp $ 00003 // 00004 // GenericLAND global position generator for primary events, 00005 // by G.Horton-Smith, August 3, 2001 00006 // (See note on GenericLAND generators for more information.) 00007 #ifndef __GLG4PosGen_h__ 00008 #define __GLG4PosGen_h__ 1 00009 00010 #include "globals.hh" 00011 class G4PrimaryVertex; 00012 class G4VPhysicalVolume; 00013 class G4Material; 00014 00015 #include <vector> 00016 00017 class GLG4VPosGen { 00018 public: 00019 GLG4VPosGen(const char *arg_dbname) : _dbname(arg_dbname) { } 00020 virtual ~GLG4VPosGen() { } 00021 00022 virtual void GenerateVertexPositions( G4PrimaryVertex *argVertex, 00023 double max_chain_time, 00024 double event_rate, 00025 double dt=0.0 00026 ); 00027 // offsets the positions of already-filled vertices, "splitting" chains at 00028 // max_chain_time ("split" means a new random position is generated and 00029 // a random time offset added according to event_rate), and optionally 00030 // adding an extra time offset to each vertex. Default uses GeneratePosition 00031 // to generate the offset for the chain (or each unsplit segment thereof). 00032 00033 virtual void GeneratePosition( G4ThreeVector *argResult ) = 0; 00034 // generates random position, for usual case where there is no 00035 // dependence on particle types, momenta, etc. 00036 00037 virtual void SetState( G4String newValues ) = 0; 00038 // sets filename or other information needed by global position generator 00039 00040 virtual G4String GetState() = 0; 00041 // returns the current state information in a form that can be understood 00042 // by SetState (and, hopefully, a well-informed human) 00043 00044 static void Strip( G4String &s, const char *stripchars=" \t\""); 00045 // strips leading and trailing characters from s 00046 00047 protected: 00048 G4String _dbname; // used for GLG4param key prefix 00049 }; 00050 00051 class GLG4PosGen_null : public GLG4VPosGen { 00052 public: 00053 GLG4PosGen_null(const char *arg_dbname) : GLG4VPosGen(arg_dbname) { } 00054 virtual void GeneratePosition( G4ThreeVector * /*argResult*/ ) { } 00055 // Does nothing. 00056 // Useful with a vertex generator which already sets positions. 00057 void SetState( G4String /*newValues*/ ) { } 00058 G4String GetState() { return "GLG4PosGen_null has no state"; } 00059 }; 00060 00061 class GLG4PosGen_PointPaintFill : public GLG4VPosGen { 00062 public: 00063 GLG4PosGen_PointPaintFill(const char *arg_dbname); 00064 virtual void GeneratePosition( G4ThreeVector *argResult ); 00065 // Generates a position either at a fixed point in the global coordinates 00066 // or uniformly filling the volume which contains the given point. 00067 // (This approach to specifying the volume isn't my favorite, but 00068 // it is strongly motivated by subtleties in Geant4's geometry code.) 00069 // - Fixed point is fastest. 00070 // - A random point in a compact physical volume is also pretty fast. 00071 // - A volume which only sparsely fills its geometric "extent" may 00072 // require many iterations to find an internal point -- this will be slow. 00073 void SetState( G4String newValues ); 00074 // newValues == x y z coordinates in mm (separated by white space), 00075 // optionally followed by keyword "fill" for volume-filling mode, 00076 // optionally followed by name of physical volume expected at that position; 00077 // or keyword "paint" for surface-painting mode, 00078 // optionally followed by name of physical volume expected at that position, 00079 // optionally followed by thickness of coat of "paint" (external to volume). 00080 // optionally followed by name of material to which to restrict "paint". 00081 G4String GetState(); 00082 // returns current state in format above 00083 private: 00084 enum { kPoint=0, kFill, kPaint }; 00085 G4ThreeVector _fixedPos; 00086 G4int _mode; 00087 G4double _thickness; 00088 G4String _pVolumeName; 00089 G4VPhysicalVolume* _pVolume; 00090 G4String _materialName; 00091 G4Material* _material; 00092 int _ntried; 00093 int _nfound; 00094 G4double _boundingBoxVolume; 00095 std::vector<G4ThreeVector> _intercepts; 00096 00097 }; 00098 00099 class GLG4PosGen_Cosmic : public GLG4VPosGen { 00100 public: 00101 GLG4PosGen_Cosmic(const char *arg_dbname); 00102 virtual void GenerateVertexPositions( G4PrimaryVertex *argVertex, 00103 double max_chain_time, 00104 double event_rate, 00105 double dt=0.0 00106 ); 00107 // external flux uniformly distributed over area normal to 00108 // incident direction of first track in vertex 00109 void GeneratePosition(G4ThreeVector *); // (not used) 00110 void SetState( G4String newValues ); 00111 // newValues == "width height" 00112 // width == width of rectangular area normal to incident direction (mm) 00113 // height == height of rectangular area normal to incident direction (mm) 00114 // Appropriate values for GenericLAND would be 20000 33000. 00115 // The rectangle is rotated so that the "width" direction vector lies in 00116 // the XY plane for non-zero polar angle of the incident track. 00117 // If a track is generated which completely misses the detector, 00118 // the PDG code of the vertex tracks are modified to make them have 00119 // an impossible effective ISTHEP codes of 1, so Geant4 does not attempt 00120 // to track them. 00121 // This means the generated external flux in Hz/mm**2 is always 00122 // flux = (rate/(width*height)), 00123 // regardless of the geometry of the detector, where "rate" is the rate 00124 // set via /generators/rate. The "rate" must be chosen appropriately 00125 // for the area of the rectangle. 00126 G4String GetState(); 00127 // returns current state in format above 00128 private: 00129 G4double _width, _height; 00130 }; 00131 00132 00133 #endif