public static List <AnnihilationEvent> GenerateEventsLinearSource(double rad, double phi, double length, ref double activity, double currentTime, double dt, double halfLife, int index) { Console.WriteLine("{0} Generating {1} events list", DateTime.Now.ToString(), index + 1); List <AnnihilationEvent> result = new List <AnnihilationEvent>(); long count = Statistics.GetPoisson(activity * dt); double prevTime = 0; for (long i = 0; i < count; i++) { AnnihilationEvent ev = new AnnihilationEvent(); //uniform sphere distribution ev.Phi = 2 * Math.PI * rnd.NextDouble(); ev.Theta = Math.Acos(2 * rnd.NextDouble() - 1.0) - Math.PI; //uniform linear distribution ev.Position = new Vector3d(rad * Math.Cos(phi), rad * Math.Sin(phi), (rnd.NextDouble() - .5) * length); //uniform time distribution var v = rnd.NextDouble(); var tm = 1 - (1 - prevTime) * Math.Pow(v, 1.0 / (count - i)); prevTime = tm; ev.Time = (tm * dt + currentTime) * 1e9; ev.Energy = 511e3; result.Add(ev); } activity *= Math.Pow(2, -dt / halfLife); return(result); }
public static List <AnnihilationEvent> GenerateEventsCylSource(double rad, double length, ref double activity, double intervalTime, double dt, double halfLife, int index) { Console.WriteLine("{0} Generating {1} events list", DateTime.Now.ToString(), index + 1); var numEvents = Statistics.GetPoisson(activity * dt); var list = new List <AnnihilationEvent>(); double prevtime = 0; for (long i = 0; i < numEvents; i++) { //uniform time distribution var v = rnd.NextDouble(); var tm = 1 - (1 - prevtime) * Math.Pow(v, 1.0 / (numEvents - i)); prevtime = tm; //uniform cyl distribution double phi = 2 * Math.PI * rnd.NextDouble(); double u = rnd.NextDouble() + rnd.NextDouble(); double R = u > 1 ? (2 - u) * rad : u * rad; double z = (rnd.NextDouble() - 0.5) * length; Vector3d position = new Vector3d(R * Math.Cos(phi), R * Math.Sin(phi), z); var evnt = new AnnihilationEvent(position, (intervalTime + tm * dt) * 1e9, 511E3, 2 * Math.PI * rnd.NextDouble(), Math.Acos(2 * rnd.NextDouble() - 1.0) - Math.PI); list.Add(evnt); } activity *= Math.Pow(2, -dt / halfLife); return(list); }
public Photon(AnnihilationEvent ev, bool inverse = false) { this.numScatterEvents = 0; this.StartPosition = this.CurrentPosition = ev.Position; if (inverse) { this.Phi = ev.Phi + Math.PI; this.Theta = -ev.Theta; if (this.Phi > 2 * Math.PI) { this.Phi -= 2 * Math.PI; } } else { this.Phi = ev.Phi; this.Theta = ev.Theta; } this.Status = stat.Free; this.Time = ev.Time; this.Energy = ev.Energy; this.Path = 0; }