示例#1
0
文件: Photon.cs 项目: acs3235/VTS
        /// <summary>
        /// method to move the photon to its next location
        /// </summary>
        /// <param name="distance"></param>
        /// <returns></returns>
        public bool Move(double distance)
        {
            bool willHitBoundary = S >= distance;

            if (willHitBoundary)
            {
                AdjustTrackLength(distance);
            }

            DP.Position.X += S * DP.Direction.Ux;
            DP.Position.Y += S * DP.Direction.Uy;
            DP.Position.Z += S * DP.Direction.Uz;

            DP.TotalTime += DetectorBinning.GetTimeDelay(S, _tissue.Regions[CurrentRegionIndex].RegionOP.N);

            CurrentTrackIndex++;

            History.SubRegionInfoList[CurrentRegionIndex].PathLength += S;

            // only increment number of collisions counter if NOT pseudo-collision
            if (!willHitBoundary)
            {
                History.SubRegionInfoList[CurrentRegionIndex].NumberOfCollisions++;
            }

            History.AddDPToHistory(DP);

            return(willHitBoundary);
        }
        /// <summary>
        /// method to tally reflected photon by determining cumulative MT in each tissue subregion and binning in MT
        /// </summary>
        /// <param name="photon">Photon (includes HistoryData)</param>
        public void Tally(Photon photon)
        {
            if (!IsWithinDetectorAperture(photon))
            {
                return;
            }

            // calculate the radial and time bin of reflected photon
            var ir = DetectorBinning.WhichBin(DetectorBinning.GetRho(photon.DP.Position.X, photon.DP.Position.Y), Rho.Count - 1, Rho.Delta, Rho.Start);

            for (int i = 0; i < NumSubregions; i++)
            {
                var timeInSubRegion = DetectorBinning.GetTimeDelay(photon.History.SubRegionInfoList[i].PathLength,
                                                                   _tissue.Regions[i].RegionOP.N);
                // make sure floating point round in Photon's update to S and subsequently to PathLength in SRIL doesn't get tallied
                if (timeInSubRegion > 1e-14)
                {
                    var it = DetectorBinning.WhichBin(timeInSubRegion, Time.Count - 1, Time.Delta, Time.Start);
                    // tally Continuous Absorption Weighting (CAW)
                    var tally = Math.Exp(-_tissue.Regions[i].RegionOP.Mua * photon.History.SubRegionInfoList[i].PathLength);
                    Mean[ir, i, it] += tally;
                    if (TallySecondMoment)
                    {
                        SecondMoment[ir, i, it] += tally * tally;
                    }
                }
            }
            TallyCount++;
        }