private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double rectLengthX, double rectWidthY, Random rng)
        {
            Position finalPosition = null;

            switch (sourceProfile.SourceProfileType)
            {
            case SourceProfileType.Flat:
                // var flatProfile = sourceProfile as FlatSourceProfile;
                SourceToolbox.GetPositionInARectangleRandomFlat(
                    SourceDefaults.DefaultPosition.Clone(),
                    rectLengthX,
                    rectWidthY,
                    rng);
                break;

            case SourceProfileType.Gaussian:
                var gaussianProfile = sourceProfile as GaussianSourceProfile;
                finalPosition = SourceToolbox.GetPositionInARectangleRandomGaussian(
                    SourceDefaults.DefaultPosition.Clone(),
                    0.5 * rectLengthX,
                    0.5 * rectWidthY,
                    gaussianProfile.BeamDiaFWHM,
                    rng);
                break;
            }


            return(finalPosition);
        }
        public void validate_static_method_getpositioninarectanglerandomgaussian()
        {
            Random rng = new MathNet.Numerics.Random.MersenneTwister(0);
            var    pos = SourceToolbox.GetPositionInARectangleRandomGaussian(_position, 0.5 * _lengthX, 0.5 * _widthY, _bdFWHM, rng);

            Assert.Less(Math.Abs(pos.X - _tp[80]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Y - _tp[81]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Z - _tp[82]), ACCEPTABLE_PRECISION);
        }
Esempio n. 3
0
 /// <summary>
 /// returns final position from profile type
 /// </summary>
 /// <param name="sourceProfile">ISourceProfile</param>
 /// <param name="rectLengthX">rectangular length in x direction (length)</param>
 /// <param name="rectWidthY">rectangular length in y direction (width)</param>
 /// <param name="rng">random number generator</param>
 /// <returns>Position</returns>
 protected static Position GetFinalPosition(double beamDimeterFWHM, double rectLengthX, double rectWidthY, Random rng)
 {
     return(beamDimeterFWHM < 0
         ? SourceToolbox.GetPositionInARectangleRandomFlat(
                SourceDefaults.DefaultPosition.Clone(),
                rectLengthX,
                rectWidthY,
                rng)
         : SourceToolbox.GetPositionInARectangleRandomGaussian(
                SourceDefaults.DefaultPosition.Clone(),
                0.5 * rectLengthX,
                0.5 * rectWidthY,
                beamDimeterFWHM,
                rng));
 }