Esempio n. 1
0
        public static List <PETCoincidenceTOF> ReadCoincList(string path)
        {
            var          result = new List <PETCoincidenceTOF>();
            StreamReader sr     = new StreamReader(path);

            string line;

            while ((line = sr.ReadLine()) != null)
            {
                string[] parts = line.Split(',');
                if (parts.Length == 12)
                {
                    PETCoincidenceTOF coinc = new PETCoincidenceTOF();
                    uint.TryParse(parts[0], out coinc.Timestamp1);
                    ushort.TryParse(parts[1], out coinc.Position1);
                    ushort.TryParse(parts[2], out coinc.XPlus1);
                    ushort.TryParse(parts[3], out coinc.XMinus1);
                    ushort.TryParse(parts[4], out coinc.YPlus1);
                    ushort.TryParse(parts[5], out coinc.YMinus1);

                    uint.TryParse(parts[6], out coinc.Timestamp2);
                    ushort.TryParse(parts[7], out coinc.Position2);
                    ushort.TryParse(parts[8], out coinc.XPlus2);
                    ushort.TryParse(parts[9], out coinc.XMinus2);
                    ushort.TryParse(parts[10], out coinc.YPlus2);
                    ushort.TryParse(parts[11], out coinc.YMinus2);
                    result.Add(coinc);
                }
            }

            return(result);
        }
Esempio n. 2
0
        public static void CalculateDigitalCoincidenceTOF(PETCoincidenceTOF In, ref PETDigitalCoincidenceTOF OutE)
        {
            OutE.I1 = (byte)iForX(In.XPlus1, In.XMinus1);
            OutE.J1 = (byte)jForY(In.YPlus1, In.YMinus1);

            OutE.I2 = (byte)iForX(In.XPlus2, In.XMinus2);
            OutE.J2 = (byte)jForY(In.YPlus2, In.YMinus2);

            OutE.Position1 = In.Position1;
            OutE.Position2 = In.Position2;

            OutE.Timestamp1 = In.Timestamp1;
            OutE.Timestamp2 = In.Timestamp2;

            // OutE.Flags = In.Flags;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public static void CalculateCoincidenceTOFForDigital(PETDigitalCoincidenceTOF In, ref PETCoincidenceTOF OutE)
        {
            OutE.XPlus1  = XPlusForI(In.I1);
            OutE.XMinus1 = XMinusForI(In.I1);
            OutE.XPlus2  = XPlusForI(In.I2);
            OutE.XMinus2 = XMinusForI(In.I2);

            OutE.YPlus1  = YPlusForJ(In.J1);
            OutE.YMinus1 = YMinusForJ(In.J1);
            OutE.YPlus2  = YPlusForJ(In.J2);
            OutE.YMinus2 = YMinusForJ(In.J2);

            OutE.Position1 = In.Position1;
            OutE.Position2 = In.Position2;

            OutE.Timestamp1 = In.Timestamp1;
            OutE.Timestamp2 = In.Timestamp2;

            // OutE.Flags = In.Flags;
        }