예제 #1
0
        public static List <PETCoincidenceTOF> GenerateCoincList(List <PETSingleEvent> events, string outDir, int index, int window)
        {
            List <PETCoincidenceTOF> result = new List <PETCoincidenceTOF>();

            for (int i = 0; i < events.Count - 1; i++)
            {
                for (int j = i + 1; j < events.Count && (events[j].Timestamp - events[i].Timestamp < window); j++)
                {
                    if (events[j].Timestamp - events[i].Timestamp < window && events[j].Block != events[i].Block)
                    {
                        var coinc = new PETCoincidenceTOF();

                        coinc.Timestamp1 = events[i].Timestamp;
                        coinc.Position1  = events[i].Position;
                        coinc.XMinus1    = events[i].XMinus;
                        coinc.XPlus1     = events[i].XPlus;
                        coinc.YMinus1    = events[i].YMinus;
                        coinc.YPlus1     = events[i].YPlus;
                        coinc.Timestamp2 = events[j].Timestamp;
                        coinc.Position2  = events[j].Position;
                        coinc.XMinus2    = events[j].XMinus;
                        coinc.XPlus2     = events[j].XPlus;
                        coinc.YMinus2    = events[j].YMinus;
                        coinc.YPlus2     = events[j].YPlus;
                        result.Add(coinc);
                        i = j + 1;
                        break;
                    }
                }
            }

            if (result.Count != 0)
            {
                WorkWithFiles.WriteCoincList(string.Format("{1}\\{0}.csv", index++, outDir), result);
            }
            Console.WriteLine("\tFound {0} coincidences", result.Count);
            return(result);
        }