//////////////////////////////////////////////////////////////////////// /// \class RAT::VertexGen_Laserball /// /// \brief Vertex generator for the Laserball /// /// \author Jose Maneira /// /// REVISION HISTORY: /// - 17 Dec 2014 : J. Maneira - Major revision of VertexGen_Laserball by M. Hedayatipour. /// Now follows more closely the structure of the ELLIE generators. /// - 20 Apr 2015 : R. Stainforth - Fix phi coordinate binning from (-pi, pi) to (0, 2pi) /// in laserball isotropy generation. /// - 22 Apr 2015 : R. Stainforth - Fix phi coordinate binning from (-pi, pi) to (0, 2pi) /// in 'funlbdist' and 'BoxMethodRandom3Vector'. /// - 16 Jun 2015 : R. Stainforth - Implementation of new laserball phi coordinate system /// as outlined in doc-3141. /// - 26 Oct 2015 : R. Stainforth - Added check for fLBDMaximum during initialisation. /// - 20 Apr 2017 : N. Barros - Added BeginOfRun to load database information. /// - 14 Nov 2017 : A. Inacio - Updated the code to work with non-integer laserball /// orientations, which is the case of external LB runs. /// /// \details This generator simulates bunches of photons from the laserball. User RatDB /// settings for position, angular, timing and wavelength distributions. /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_VertexGen_Laserball__ #define __RAT_VertexGen_Laserball__ #include #include #include #include #include "RAT/GLG4Gen.hh" #include #include "TF2.h" class G4ParticleDefinition; namespace RAT { class VertexGen_Laserball : public GLG4VertexGen { public: /** Class constructor. Does nothing besides it, initialization done in Init*/ VertexGen_Laserball(const char *arg_dbname="vertexlaserball"); /** Class destructor. Does nothing */ virtual ~VertexGen_Laserball(); /** 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); /** Gets string of parameters fDyeName:fLBID */ virtual G4String GetState(); virtual void BeginOfRun(); private: /** Helper function. Random 3 vector*/ G4ThreeVector SphericallyUniform3Vector(); /** Helper function. Rotate azimuthal only*/ G4ThreeVector RotatePhiClock(double aPhi, G4ThreeVector aVector3) const; /** Helper function. Rotate azimuthal only*/ G4ThreeVector RotatePhiAntiClock(double aPhi, G4ThreeVector aVector3) const; /** Helper function. Generate random vector from TF2 angular dist*/ G4ThreeVector FunctionRandom3Vector(); /** Helper function. Generate random vector from TF2 angular dist*/ G4ThreeVector BoxMethodRandom3Vector(); /** Function for actual definition of TF2*/ double funlbdist(double *x, double *par); /** Helper function for gaussian random*/ double GasDev(); //Now the parameters /** Only call the initialisation once - if this flag isn't set */ bool fInitDB; /** Wavelength mode: MONO, for monochromatic line, DYENAME to use the spectrum of the fDyeName dye, DYECELL to use the spectrum of the dye in the dye cell with number fDyeCell. The correspondecne between dye and dye cell number is given in table DYECELL.*/ std::string fWl_Mode; /** Name of the dye used to shift the wavelength: N2 for no-dye * (the basic 337.1 nm line). Also: PBD (365nm), BBQ (386nm) * BIS-MSB (420nm), COUMARIN-500 (500 nm), KITON-RED (620nm) */ std::string fDyeName; /** Number of the dye cell to use.*/ int fDyeCell; /** Name of the dye cell set that provides the correspondence between dye cell number and dye name. This is expected to change between phases of SNO+. This is the index to the ratdb table DYECELL*/ std::string fDyeCellSet; /** Vector containing the correspondence between dye cell number and dye name. */ std::vector fDyeCellOrder; /** Wavelength to use in the case of MONO wavelength mode. */ float fWl_Mono; /** Name of the laserball used. This string can refer to a given LB model, or to a given measurement of the LB angular distribution. It specifies the dimensions, but also the angular distribution. For now, only OCT03. */ std::string fLBID; /** Angular distribution mode. Can be FLAT. Can be TABLE2D, for the usual 2D binned distribution, or also SINCOEF, in which the phi dependence is parametrized with a sin function.*/ std::string fAngleMode; /** Name of the dye to use for the angular distribution. DYEDEFAULT uses for angle the same as for wavelength. But it is possible to choose a different one.*/ std::string fAngleDistDye; /** String combining fAngleDistDye:fLBID, used in GetState. */ std::string fFullAngleIndex; /** Time mode. MONO for a single value. GAUSS for gaussian */ std::string fTimeMode; /** Vector for time parameters. [0,1] are lower and upper limits [2] is the sigma, [3] is the centroid of the gaussian.*/ std::vector fTimeParams; /** Number of photons per Laserball 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; /** Simulation mode. 0 and 10 to use position from this table, 10 identifies laserball runs without side ropes (internal or external). 2 loads position from manip, 3 loads camera position (not implemented) */ int fSimulationMode; /** Laserball orientation. Orientation angle = fOrientation * pi/2 */ /** fOrientation should be a value in the range [0,4[ */ double fOrientation; /** Average wavelength of loaded distribution, */ float fwaveAvg; /** 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 parameters of theta mask function. */ std::vector fMaskCoef; /** Vector for intensity in 2D (costheta,phi) table */ std::vector fAngIntensity; /** Vector for sin function parametrization. */ std::vector fAngSinCoef; /** 2D function providing lb intensity */ TF2* fLBD; /** 2D function maximum, for normalization */ double fLBDMaximum; /** Particles must be defined as optical photons */ G4ParticleDefinition *fPhotonDef; }; } // namespace RAT #endif