/** @class RAT::VertexGen_UFO * * @brief Vertex generator - for UFO (Modified from VertexGen_Laserball) * * @author Mark Stringer * * REVISION HISTORY\n * Mark Stringer - First Commit * 10-02-2017 :N. Barros : - Added BeginOfRun and moved DB loading there */ #ifndef __RAT_VertexGen_UFO__ #define __RAT_VertexGen_UFO__ #include #include #include #include #include "RAT/GLG4Gen.hh" #include #include "TF2.h" class G4ParticleDefinition; namespace RAT { class VertexGen_UFO : public GLG4VertexGen { public: /** Class constructor. Does nothing besides it, initialization done in Init*/ VertexGen_UFO(const char *arg_dbname="vertexufo"); /** Class destructor. Does nothing */ virtual ~VertexGen_UFO(); /** Initialization, called in the first event. Reads all parameters from ratdb.*/ void Init(); /** Main event generation function */ virtual void GeneratePrimaryVertex(G4Event *event, G4ThreeVector &dx, G4double dt); /** Helper function. Returns random number given input distribution and cumulative distribution*/ float SampleRandom(std::vector myx, std::vector myy, std::vector mycum); /** Do no use to avoid overriding parameters read from ratdb.*/ virtual void SetState(G4String state); virtual G4String GetState(); virtual void BeginOfRun(); private: //Now the parameters /** Only call the initialisation once - if this flag isn't set */ bool fInitDB; /** Number of photons per UFO pulse */ int fPhotonsPerEvent; /** true = number of photons per pulse is selected from poisson distribution with mean=photons_per_event, \n false = number of photons per pulse=photons_per_event */ bool fPoisson; /** Position mode. 0 to use position from this table */ int fPositionMode; /** Vector for specified wavelengths */ std::vector fwave; /** Vector for cumulative wave intensity distribution */ std::vector fwaveCumMag; /** Vector for wave intensity */ std::vector fwaveInt; /** Lower limit on wavelength distribution */ float fMinWl; /** Upper limit on wavelength distribution */ float fMaxWl; /**Vector for angles*/ std::vector fangle; /**Vector for angular distribution*/ std::vector fAngInt; /**Vector for cumulative angular distribution*/ std::vector fCumAngleDist; /** Number of LEDS on the UFO */ int fNleds; /**Radius of UFO in mm */ double fUFORadius; /**Time it takes the LED pulsing to pass around the entire UFO*/ double fRotationTime; /**Time width of LED light pulse*/ double fTimeWidth; /** Positions of UFO LEDs relative to the centre of the UFO * the unit vector of these will give the direction of the UFO LED*/ std::vector fUFO_XPos; std::vector fUFO_YPos; std::vector fUFO_ZPos; /**Counts the number of times the LED has flashed to ensure correct UFO LED is flashing*/ long fLEDFlashCount; /**Number of flashes for entire rotation of LED*/ long fFlashesPerRotation; /**Flash rate of LEDs*/ long fFlashRate; /** Generate Lambertian distribution from angular array (IN RADIANS)*/ std::vector GenerateLambertian(std::vector angularDistribution); /**Method to generate the photons direction given the direction of the LED and the angle generated from the angular distribution*/ G4ThreeVector GeneratePhotonDirection(G4ThreeVector led_dir, float angle); /**Taken from VertexGen_Laserball*/ /** Helper function for gaussian random*/ double GasDev(); /** Particles must be defined as optical photons */ G4ParticleDefinition *fPhotonDef; }; } // namespace RAT #endif