コード例 #1
0
        protected static BiasingParameters.RareEventInfo ReadRareEventInfo(JObject eventInfo, BiasingParameters.ReactionInfo reactionInfo)
        {
            var rareEventInfo = new BiasingParameters.RareEventInfo {
                BinCount = (int)eventInfo["BIN_COUNT"]
            };
            var gammasArray = (JArray)eventInfo["GAMMAS"];

            if (gammasArray.Count != rareEventInfo.BinCount)
            {
                throw new GammaArrayLengthException(string.Format("JSON data for reaction '{0}' invalid, GAMMAS array length doesn't match BIN_COUNT.", reactionInfo.Name), reactionInfo.Name);
            }
            for (var i = 0; i < rareEventInfo.BinCount; i++)
            {
                rareEventInfo.Gammas[i] = (double)gammasArray[i];
            }
            var cutoffArray = (JArray)eventInfo["CUTOFF"];

            if (cutoffArray.Count != (rareEventInfo.BinCount - 1) && rareEventInfo.BinCount > 1)
            {
                throw new CutoffArrayLengthException(string.Format("JSON data for reaction '{0}' invalid, CUTOFF array length doesn't match BIN_COUNT - 1.", reactionInfo.Name), reactionInfo.Name);
            }
            if (rareEventInfo.BinCount == 1)
            {
                rareEventInfo.Thresholds[0] = (int)cutoffArray[0];
            }
            else
            {
                for (var j = 0; j < rareEventInfo.BinCount - 1; j++)
                {
                    rareEventInfo.Thresholds[j] = (double)cutoffArray[j];
                }
            }
            return(rareEventInfo);
        }
コード例 #2
0
 protected static void WriteRareEventInfo(BiasingParameters.RareEventInfo rareEvent, StringBuilder builder)
 {
     builder.AppendLine("                        {");
     builder.AppendFormat("                             \"BIN_COUNT\" : {0},", rareEvent.BinCount).AppendLine();
     WriteGammaValues(rareEvent, builder);
     WriteThresholdValues(rareEvent, builder);
     builder.Append("                        }");
 }
コード例 #3
0
        protected static void WriteThresholdValues(BiasingParameters.RareEventInfo rareEvent, StringBuilder builder)
        {
            builder.Append("                             \"CUTOFF\" : [");
            int count = 0;

            foreach (var value in rareEvent.Thresholds)
            {
                builder.Append(value);
                if (++count < rareEvent.Thresholds.Length)
                {
                    builder.Append(", ");
                }
            }
            builder.AppendLine(" ]");
        }
コード例 #4
0
        protected static void WriteGammaValues(BiasingParameters.RareEventInfo rareEvent, StringBuilder builder)
        {
            builder.Append("                             \"GAMMAS\" : [");
            int count = 0;

            foreach (var value in rareEvent.Gammas)
            {
                builder.Append(value);
                if (++count < rareEvent.Gammas.Length)
                {
                    builder.Append(", ");
                }
            }
            builder.AppendLine(" ],");
        }