private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     acq.item_type = (string)((ComboBox)sender).SelectedItem;
     INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
     AnalysisMethods lam;
     bool found = NC.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);
     if (found)
     {
         am = new AnalysisMethods(sel);
         am.CopySettings(lam);
         ActivePassiveCheckBox.Checked = am.choices[(int)AnalysisMethod.ActivePassive];
         ActiveCalCurveCheckBox.Checked = am.choices[(int)AnalysisMethod.Active];
         ActiveMultCheckBox.Checked = am.choices[(int)AnalysisMethod.ActiveMultiplicity];
         CollarCheckBox.Checked = am.choices[(int)AnalysisMethod.Collar];
         PassiveCalCurveCheckBox.Checked = am.choices[(int)AnalysisMethod.CalibrationCurve];
         KnownAlphaCheckBox.Checked = am.choices[(int)AnalysisMethod.KnownA];
         KnownMCheckBox.Checked = am.choices[(int)AnalysisMethod.KnownM];
         PassiveMultiplicityCheckBox.Checked = am.choices[(int)AnalysisMethod.Multiplicity];
         AddASourceCheckBox.Checked = am.choices[(int)AnalysisMethod.AddASource];
         CuRatioCheckBox.Checked = am.choices[(int)AnalysisMethod.CuriumRatio];
         TruncatedMultCheckBox.Checked = am.choices[(int)AnalysisMethod.TruncatedMultiplicity];
         collaractive();
     }
     else
     {
         // create an AM marked None and insert in Map here, set modified flag
         am = new AnalysisMethods(sel);
         NC.App.DB.DetectorMaterialAnalysisMethods.Add(sel, am);
         am.modified = true;
     }
 }
示例#2
0
        private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            acq.item_type = (string)((ComboBox)sender).SelectedItem;
            INCCSelector    sel = new INCCSelector(acq.detector_id, acq.item_type);
            AnalysisMethods lam;
            bool            found = NC.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);

            if (found)
            {
                am = new AnalysisMethods(sel);
                am.CopySettings(lam);
                ActivePassiveCheckBox.Checked       = am.choices[(int)AnalysisMethod.ActivePassive];
                ActiveCalCurveCheckBox.Checked      = am.choices[(int)AnalysisMethod.Active];
                ActiveMultCheckBox.Checked          = am.choices[(int)AnalysisMethod.ActiveMultiplicity];
                CollarAmLiCheckBox.Checked          = am.choices[(int)AnalysisMethod.CollarAmLi] && (acq.collar_mode == (int)CollarType.AmLiThermal || acq.collar_mode == (int)CollarType.AmLiFast);
                CollarCfCheckBox.Checked            = am.choices[(int)AnalysisMethod.CollarCf] && (acq.collar_mode == (int)CollarType.CfThermal || acq.collar_mode == (int)CollarType.CfFast);
                PassiveCalCurveCheckBox.Checked     = am.choices[(int)AnalysisMethod.CalibrationCurve];
                KnownAlphaCheckBox.Checked          = am.choices[(int)AnalysisMethod.KnownA];
                KnownMCheckBox.Checked              = am.choices[(int)AnalysisMethod.KnownM];
                PassiveMultiplicityCheckBox.Checked = am.choices[(int)AnalysisMethod.Multiplicity];
                AddASourceCheckBox.Checked          = am.choices[(int)AnalysisMethod.AddASource];
                CuRatioCheckBox.Checked             = am.choices[(int)AnalysisMethod.CuriumRatio];
                TruncatedMultCheckBox.Checked       = am.choices[(int)AnalysisMethod.TruncatedMultiplicity];
                collaractive();
            }
            else
            {
                // create an AM marked None and insert in Map here, set modified flag
                am = new AnalysisMethods(sel);
                NC.App.DB.DetectorMaterialAnalysisMethods.Add(sel, am);
                am.modified = true;
            }
        }
示例#3
0
        public static AnalysisMethods GetMethodSelections(string det, string mat)
        {
            INCCSelector    sel = new INCCSelector(det, mat);
            AnalysisMethods lam;
            bool            found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);

            return(lam);
        }
示例#4
0
        public void UpdateAnalysisMethod(INCCSelector sel, AnalysisMethods ams)
        {
            DB.AnalysisMethodSpecifiers db = new DB.AnalysisMethodSpecifiers();

            if (ams.modified)
            {
                UpdateAnalysisMethods(sel, ams, db);
            }
            UpdateAnalysisMethodSpecifics(sel.detectorid, sel.material, db);
        }
示例#5
0
 private void OKBtn_Click(object sender, EventArgs e)
 {
     if (modified)
     {
         AnalysisMethod am = AnalysisMethod.CalibrationCurve;
         INCCAnalysisParams.INCCMethodDescriptor c = ams.GetMethodParameters(am);
         ((INCCAnalysisParams.cal_curve_rec)c).percent_u235 = percent;
         INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
         NC.App.DB.UpdateAnalysisMethod(sel, ams);  // flush changes on internal map to the DB
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
示例#6
0
 public void UpdateAnalysisMethods(INCCSelector sel, AnalysisMethods am, DB.AnalysisMethodSpecifiers db = null)
 {
     if (db == null)
     {
         db = new DB.AnalysisMethodSpecifiers();
     }
     DB.ElementList saParams;
     saParams = am.ToDBElementList();
     if (!db.Update(sel.detectorid, sel.material, saParams)) // am not there, so add it
     {
         NC.App.Pest.logger.TraceEvent(LogLevels.Verbose, 34027, "Failed to update analysis method spec for " + sel.ToString());
     }
     else
     {
         NC.App.Pest.logger.TraceEvent(LogLevels.Verbose, 34026, "Updated/created analysis method spec for " + sel.ToString());
     }
     am.modified = false;
 }
示例#7
0
 public void Persist()
 {
     if (imd.modified)
     {
         if (ams == null) // HN No analysis methods existed.
         {
             ams = new AnalysisMethods();
             ams.AddMethod(am, imd);
         }
         if (ams.HasMethod(am)) // if found, update the existing parameter values
         {
             INCCAnalysisParams.INCCMethodDescriptor c = ams.GetMethodParameters(am);
             imd.CopyTo(c);  // This a virtual so imd can be the primary type
         }
         else // add the new method params under the current method key
         {
             ams.AddMethod(am, imd);
         }
         INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
         N.App.DB.UpdateAnalysisMethod(sel, ams);  // flush changes on internal map to the DB
     }
 }
示例#8
0
 internal static unsafe cal_curve_rec MoveCC(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.cal_curve_rec imr = (INCCAnalysisParams.cal_curve_rec)md;
     cal_curve_rec m = new cal_curve_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.cal_curve_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.cal_curve_item_type);
     m.cc_a = imr.cev.a;
     m.cc_b = imr.cev.b;
     m.cc_c = imr.cev.c;
     m.cc_d = imr.cev.d;
     m.cc_cal_curve_type = (double)imr.CalCurveType;
     m.cc_covar_ab = imr.cev.covar(Coeff.a, Coeff.b);
     m.cc_covar_ac = imr.cev.covar(Coeff.a, Coeff.c);
     m.cc_covar_ad = imr.cev.covar(Coeff.a, Coeff.d);
     m.cc_covar_bc = imr.cev.covar(Coeff.b, Coeff.c);
     m.cc_covar_bd = imr.cev.covar(Coeff.b, Coeff.d);
     m.cc_covar_cd = imr.cev.covar(Coeff.c, Coeff.d);
     m.cc_var_a = imr.cev.var_a;
     m.cc_var_b = imr.cev.var_b;
     m.cc_var_c = imr.cev.var_c;
     m.cc_var_d = imr.cev.var_d;
     m.cc_sigma_x = imr.cev.sigma_x;
     m.cc_upper_mass_limit = imr.cev.upper_mass_limit;
     m.cc_lower_mass_limit = imr.cev.lower_mass_limit;
     m.cc_heavy_metal_corr_factor = imr.heavy_metal_corr_factor;
     m.cc_heavy_metal_reference = imr.heavy_metal_reference;
     m.cc_cal_curve_type = (double)imr.CalCurveType;
     m.cc_percent_u235 = imr.percent_u235;
     TransferUtils.CopyDbls(imr.dcl_mass, m.cc_dcl_mass);
     TransferUtils.CopyDbls(imr.doubles, m.cc_doubles);
     return m;
 }
示例#9
0
        void ApplyCoefficients(INCCAnalysisParams.CurveEquationVals coeff, CalibrationCurveList cclist)
        {
            INCCSelector    sel = new INCCSelector(det.Id.DetectorId, Material);
            AnalysisMethods lam;
            bool            found = N.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);

            if (!found)
            {
                lam = new AnalysisMethods(sel);
            }
            if (!lam.HasMethod(AnalysisMethod))              // create it from scratch here ????
            {
                MessageBox.Show(string.Format("{0} method not specified for detector {1} and material {2}",
                                              AnalysisMethod.FullName(), det.Id.DetectorId, Material),
                                "Coefficient File Ingester", MessageBoxButtons.OK);
                return;
            }

            INCCAnalysisParams.INCCMethodDescriptor imd = lam.GetMethodParameters(AnalysisMethod);
            switch (AnalysisMethod)
            {
            case AnalysisMethod.CalibrationCurve:
                INCCAnalysisParams.cal_curve_rec c = (INCCAnalysisParams.cal_curve_rec)imd;
                CopyCoefficients(coeff, c.cev);
                c.cev.cal_curve_equation = CurveEquation;
                c.cev.lower_mass_limit   = cclist.LowerMassLimit;
                c.cev.upper_mass_limit   = cclist.UpperMassLimit;
                c.dcl_mass = cclist.MassAsArray;
                c.doubles  = cclist.DoublesAsArray;
                break;

            case AnalysisMethod.KnownA:
                INCCAnalysisParams.known_alpha_rec ka = (INCCAnalysisParams.known_alpha_rec)imd;
                CopyCoefficients(coeff, ka.cev);
                ka.cev.cal_curve_equation = CurveEquation;
                ka.cev.lower_mass_limit   = cclist.LowerMassLimit;
                ka.cev.upper_mass_limit   = cclist.UpperMassLimit;
                ka.dcl_mass = cclist.MassAsArray;
                ka.doubles  = cclist.DoublesAsArray;
                break;

            case AnalysisMethod.AddASource:
                INCCAnalysisParams.add_a_source_rec aas = (INCCAnalysisParams.add_a_source_rec)imd;
                CopyCoefficients(coeff, aas.cev);
                aas.cev.cal_curve_equation = CurveEquation;
                aas.cev.lower_mass_limit   = cclist.LowerMassLimit;
                aas.cev.upper_mass_limit   = cclist.UpperMassLimit;
                aas.dcl_mass = cclist.MassAsArray;
                aas.doubles  = cclist.DoublesAsArray;
                break;

            case AnalysisMethod.Active:
                INCCAnalysisParams.active_rec ac = (INCCAnalysisParams.active_rec)imd;
                CopyCoefficients(coeff, ac.cev);
                ac.cev.cal_curve_equation = CurveEquation;
                ac.cev.lower_mass_limit   = cclist.LowerMassLimit;
                ac.cev.upper_mass_limit   = cclist.UpperMassLimit;
                ac.dcl_mass = cclist.MassAsArray;
                ac.doubles  = cclist.DoublesAsArray;
                break;
            }
            imd.modified = true;
            // ok save it now
            N.App.DB.UpdateAnalysisMethod(sel, lam);              // flush changes on internal map to the DB
            MessageBox.Show(string.Format("Calibration data for analysis method {0} and material type {1} successfully stored in the database",
                                          det.Id.DetectorId, Material),
                            "Coefficient File Ingester", MessageBoxButtons.OK);
        }
示例#10
0
 internal static unsafe add_a_source_rec MoveAS(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.add_a_source_rec imr = (INCCAnalysisParams.add_a_source_rec)md;
     add_a_source_rec m = new add_a_source_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.add_a_source_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.add_a_source_item_type);
     m.ad_a = imr.cev.a;
     m.ad_b = imr.cev.b;
     m.ad_c = imr.cev.c;
     m.ad_d = imr.cev.d;
     m.add_a_source_equation = (byte)imr.cev.cal_curve_equation;
     m.ad_covar_ab = imr.cev.covar(Coeff.a, Coeff.b);
     m.ad_covar_ac = imr.cev.covar(Coeff.a, Coeff.c);
     m.ad_covar_ad = imr.cev.covar(Coeff.a, Coeff.d);
     m.ad_covar_bc = imr.cev.covar(Coeff.b, Coeff.c);
     m.ad_covar_bd = imr.cev.covar(Coeff.b, Coeff.d);
     m.ad_covar_cd = imr.cev.covar(Coeff.c, Coeff.d);
     m.ad_var_a = imr.cev.var_a;
     m.ad_var_b = imr.cev.var_b;
     m.ad_var_c = imr.cev.var_c;
     m.ad_var_d = imr.cev.var_d;
     m.ad_sigma_x = imr.cev.sigma_x;
     m.ad_upper_mass_limit = imr.cev.upper_mass_limit;
     m.ad_lower_mass_limit = imr.cev.lower_mass_limit;
     TransferUtils.CopyDbls(imr.dcl_mass, m.ad_dcl_mass);
     TransferUtils.CopyDbls(imr.doubles, m.ad_doubles);
     TransferUtils.CopyDbls(imr.position_dzero, m.ad_position_dzero);
     m.ad_cf_a = imr.cf.a;
     m.ad_cf_b = imr.cf.b;
     m.ad_cf_c = imr.cf.c;
     m.ad_cf_d = imr.cf.d;
     m.ad_dzero_avg = imr.dzero_avg;
     m.ad_num_runs = imr.num_runs;
     m.ad_tm_dbls_rate_upper_limit = imr.tm_dbls_rate_upper_limit;
     m.ad_tm_weighting_factor = imr.tm_weighting_factor;
     m.ad_use_truncated_mult = imr.use_truncated_mult ? 1 : 0;
     b = new byte[INCC.DATE_TIME_LENGTH];
     a = imr.dzero_ref_date.ToString("yy.MM.dd").ToCharArray();
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.ad_dzero_ref_date);
     return m;
 }
示例#11
0
 internal static unsafe known_m_rec MoveKM(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.known_m_rec imr = (INCCAnalysisParams.known_m_rec)md;
     known_m_rec m = new known_m_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.known_m_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.known_m_item_type);
     m.km_b = imr.b;
     m.km_c = imr.c;
     m.km_sf_rate = imr.sf_rate;
     m.km_sigma_x = imr.sigma_x;
     m.km_upper_mass_limit = imr.upper_mass_limit;
     m.km_lower_mass_limit = imr.lower_mass_limit;
     m.km_vi1 = imr.vi1;
     m.km_vi2 = imr.vi2;
     m.km_vs1 = imr.vs1;
     m.km_vs2 = imr.vs2;
     return m;
 }
示例#12
0
        /// <summary>
        /// Imprint a new measurement with as much information as possible from a results_rec.
        /// </summary>
        /// <param name="rec">The results_rec with the measurement details</param>
        /// <param name="meaId">Unique id for the measurement, from the results_rec fields</param>
        /// <param name="logger">logger handle</param>
        /// <returns>A new measurement</returns>
        public Measurement(INCCResults.results_rec rec, MeasId meaId, LMLoggers.LognLM logger)
        {
            HVCalibrationParameters hv = NCC.IntegrationHelpers.GetCurrentHVCalibrationParams(rec.det);
            MeasurementTuple        mt = new MeasurementTuple(new DetectorList(rec.det), rec.tests, rec.norm, rec.bkg, rec.iso, rec.acq, hv);

            this.mt     = mt;
            this.logger = logger;
            mid         = meaId;
            InitMisc();

            if (rec.det.ListMode)
            {
                AnalysisParams = NC.App.LMBD.CountingParameters(rec.det, applySRFromDetector: true);
                if (meaId.MeasOption.IsListMode()) // pure List Mode, not INCC5
                {
                    // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params
                    NCC.IntegrationHelpers.ApplyVSRChangesToDefaultDetector(this);
                }
                else // it is an INCC5 analysis driven with LM data
                {
                    // prepare or identify an active CA entry with matching CA gatewidth and FA, with remaining SR params as the detector
                    AnalysisParams.PrepareMatchingVSR(rec.det.MultiplicityParams);
                }
            }
            else
            {
                // prepare analyzer params from detector SR params
                AnalysisParams = NC.App.LMBD.CountingParameters(rec.det, applySRFromDetector: false);
                if (!AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(rec.det.MultiplicityParams)); }))
                {
                    AnalysisParams.Add(rec.det.MultiplicityParams);
                }
            }

            // get the INCC5 analysis methods
            INCCAnalysisState = new INCCAnalysisState();
            INCCSelector    sel = new INCCSelector(rec.acq.detector_id, rec.acq.item_type);
            AnalysisMethods am;
            bool            found = NC.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);

            if (found)
            {
                am.selector = sel; // gotta do this so that the equality operator is correct
                INCCAnalysisState.Methods = am;
            }
            else
            {
                INCCAnalysisState.Methods = new AnalysisMethods(sel);
            }
            InitializeContext(clearCounterResults: true);
            PrepareINCCResults();
            // a list mode measurement may not have a multiplicity analyzer at all, create on results, copying the current values
            if (CountingAnalysisResults.ContainsKey(rec.det.MultiplicityParams))
            {
                MultiplicityCountingRes mcr = (MultiplicityCountingRes)CountingAnalysisResults[rec.det.MultiplicityParams];
                if (rec.mcr.AB.Unset)
                {
                    SDTMultiplicityCalculator.SetAlphaBeta(rec.det.MultiplicityParams, rec.mcr); // works only if MaxBins is set
                }
                mcr.CopyFrom(rec.mcr);                                                           // copy the mcr results onto the first moskey entry
                // the same results are copied to the full results structure
                MeasOptionSelector mos    = new MeasOptionSelector(MeasOption, rec.det.MultiplicityParams);
                INCCResult         result = INCCAnalysisState.Lookup(mos);
                result.CopyFrom(rec.mcr);
            }

            Stratum = new Stratum(rec.st);             // the stratum from the results rec
        }
示例#13
0
            internal static unsafe collar_rec MoveCO(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
            {
                INCCAnalysisParams.collar_combined_rec imr = (INCCAnalysisParams.collar_combined_rec)md;
                collar_rec m = new collar_rec();
                byte[] b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
                char[] a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.collar_item_type);
                m.col_a = imr.collar.cev.a;
                m.col_b = imr.collar.cev.b;
                m.col_c = imr.collar.cev.c;
                m.col_d = imr.collar.cev.d;
                m.collar_equation = (byte)imr.collar.cev.cal_curve_equation;
                m.col_covar_ab = imr.collar.cev.covar(Coeff.a, Coeff.b);
                m.col_covar_ac = imr.collar.cev.covar(Coeff.a, Coeff.c);
                m.col_covar_ad = imr.collar.cev.covar(Coeff.a, Coeff.d);
                m.col_covar_bc = imr.collar.cev.covar(Coeff.b, Coeff.c);
                m.col_covar_bd = imr.collar.cev.covar(Coeff.b, Coeff.d);
                m.col_covar_cd = imr.collar.cev.covar(Coeff.c, Coeff.d);
                m.col_var_a = imr.collar.cev.var_a;
                m.col_var_b = imr.collar.cev.var_b;
                m.col_var_c = imr.collar.cev.var_c;
                m.col_var_d = imr.collar.cev.var_d;
                m.col_sigma_x = imr.collar.cev.sigma_x;
                m.col_upper_mass_limit = imr.collar.cev.upper_mass_limit;
                m.col_lower_mass_limit = imr.collar.cev.lower_mass_limit;

                m.col_number_calib_rods = imr.collar.number_calib_rods;
                m.col_sample_corr_fact = imr.collar.sample_corr_fact.v;
                m.col_sample_corr_fact_err = imr.collar.sample_corr_fact.err;
                m.col_u_mass_corr_fact_a = imr.collar.u_mass_corr_fact_a.v;
                m.col_u_mass_corr_fact_a_err = imr.collar.u_mass_corr_fact_a.err;
                m.col_u_mass_corr_fact_b = imr.collar.u_mass_corr_fact_b.v;
                m.col_u_mass_corr_fact_b_err = imr.collar.u_mass_corr_fact_b.err;
                m.collar_mode = (byte)(imr.collar.collar_mode ? 1 : 0);

                byte[] bb = new byte[INCC.MAX_POISON_ROD_TYPES * INCC.MAX_ROD_TYPE_LENGTH];
                int indx = 0;
                for (int i = 0; i < INCC.MAX_POISON_ROD_TYPES; i++)
                {
                    if (string.IsNullOrEmpty(imr.collar.poison_rod_type[i]))
                    {
                        char[] aa = imr.collar.poison_rod_type[i].ToCharArray(0, Math.Min(imr.collar.poison_rod_type[i].Length, INCC.MAX_ROD_TYPE_LENGTH));
                        Encoding.ASCII.GetBytes(aa, 0, aa.Length, bb, indx);
                    }
                    indx += 2;
                }
                TransferUtils.Copy(bb, 0, m.col_poison_rod_type, 0, INCC.MAX_POISON_ROD_TYPES * INCC.MAX_ROD_TYPE_LENGTH);

                TransferUtils.CopyDbls(imr.collar.poison_absorption_fact, m.col_poison_absorption_fact);
                CopyTuples(imr.collar.poison_rod_a, m.col_poison_rod_a, m.col_poison_rod_a_err, INCC.MAX_POISON_ROD_TYPES);
                CopyTuples(imr.collar.poison_rod_b, m.col_poison_rod_b, m.col_poison_rod_b_err, INCC.MAX_POISON_ROD_TYPES);
                CopyTuples(imr.collar.poison_rod_c, m.col_poison_rod_c, m.col_poison_rod_c_err, INCC.MAX_POISON_ROD_TYPES);
                return m;
            }
示例#14
0
            internal static unsafe de_mult_rec MoveDE(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
            {
                INCCAnalysisParams.de_mult_rec imr = (INCCAnalysisParams.de_mult_rec)md;
                de_mult_rec m = new de_mult_rec();
                byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
                char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.de_detector_id);
                b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
                a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.de_item_type);
                m.de_inner_ring_efficiency = imr.inner_ring_efficiency;
                m.de_outer_ring_efficiency = imr.outer_ring_efficiency;

                TransferUtils.CopyDbls(imr.neutron_energy, m.de_neutron_energy);
                TransferUtils.CopyDbls(imr.detector_efficiency, m.de_detector_efficiency);
                TransferUtils.CopyDbls(imr.inner_outer_ring_ratio, m.de_inner_outer_ring_ratio);
                TransferUtils.CopyDbls(imr.relative_fission, m.de_relative_fission);
                return m;
            }
示例#15
0
 public void Persist()
 {
     if (imd.modified)
     {
         if (ams == null) // HN No analysis methods existed.
         {
             ams = new AnalysisMethods();
             ams.AddMethod(am, imd);
         }
         if (ams.HasMethod(am)) // if found, update the existing parameter values
         {
             INCCAnalysisParams.INCCMethodDescriptor c = ams.GetMethodParameters(am);
             imd.CopyTo(c);  // This a virtual so imd can be the primary type
         }
         else // add the new method params under the current method key
         {
             ams.AddMethod(am, imd);
         }
         INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
         N.App.DB.UpdateAnalysisMethod(sel, ams);  // flush changes on internal map to the DB
     }
 }
示例#16
0
 internal static unsafe truncated_mult_rec MoveTM(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.truncated_mult_rec imr = (INCCAnalysisParams.truncated_mult_rec)md;
     truncated_mult_rec m = new truncated_mult_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.truncated_mult_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.truncated_mult_item_type);
     m.tm_a = imr.a;
     m.tm_b = imr.b;
     m.tm_known_eff = (byte)(imr.known_eff ? 1 : 0);
     m.tm_solve_eff = (byte)(imr.solve_eff ? 1 : 0);
     return m;
 }
示例#17
0
 private void OKBtn_Click(object sender, EventArgs e)
 {
     if (modified)
     {
         AnalysisMethod am = AnalysisMethod.CalibrationCurve;
         INCCAnalysisParams.INCCMethodDescriptor c = ams.GetMethodParameters(am);
         ((INCCAnalysisParams.cal_curve_rec)c).percent_u235 = percent;
         INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
         NC.App.DB.UpdateAnalysisMethod(sel, ams);  // flush changes on internal map to the DB
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
示例#18
0
        void ApplyCoefficients(INCCAnalysisParams.CurveEquationVals coeff, CalibrationCurveList cclist)
        {
            INCCSelector sel = new INCCSelector(det.Id.DetectorId, Material);
            AnalysisMethods lam;
            bool found = N.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);
            if (!found)
            {
                lam = new AnalysisMethods(sel);
            }
            if (!lam.HasMethod(AnalysisMethod))  // create it from scratch here ????
            {
                MessageBox.Show(string.Format("{0} method not specified for detector {1} and material {2}",
                                    AnalysisMethod.FullName(), det.Id.DetectorId, Material),
                    "Coefficient File Ingester", MessageBoxButtons.OK);
                return;
            }

            INCCAnalysisParams.INCCMethodDescriptor imd = lam.GetMethodParameters(AnalysisMethod);
            switch (AnalysisMethod)
            {
            case AnalysisMethod.CalibrationCurve:
                INCCAnalysisParams.cal_curve_rec c = (INCCAnalysisParams.cal_curve_rec)imd;
                CopyCoefficients(coeff, c.cev);
                c.cev.cal_curve_equation = CurveEquation;
                c.cev.lower_mass_limit = cclist.LowerMassLimit;
                c.cev.upper_mass_limit = cclist.UpperMassLimit;
                c.dcl_mass = cclist.MassAsArray;
                c.doubles = cclist.DoublesAsArray;
                break;
            case AnalysisMethod.KnownA:
                INCCAnalysisParams.known_alpha_rec ka = (INCCAnalysisParams.known_alpha_rec)imd;
                CopyCoefficients(coeff, ka.cev);
                ka.cev.cal_curve_equation = CurveEquation;
                ka.cev.lower_mass_limit = cclist.LowerMassLimit;
                ka.cev.upper_mass_limit = cclist.UpperMassLimit;
                ka.dcl_mass = cclist.MassAsArray;
                ka.doubles = cclist.DoublesAsArray;
                break;
            case AnalysisMethod.AddASource:
                INCCAnalysisParams.add_a_source_rec aas = (INCCAnalysisParams.add_a_source_rec)imd;
                CopyCoefficients(coeff, aas.cev);
                aas.cev.cal_curve_equation = CurveEquation;
                aas.cev.lower_mass_limit = cclist.LowerMassLimit;
                aas.cev.upper_mass_limit = cclist.UpperMassLimit;
                aas.dcl_mass = cclist.MassAsArray;
                aas.doubles = cclist.DoublesAsArray;
                break;
            case AnalysisMethod.Active:
                INCCAnalysisParams.active_rec ac = (INCCAnalysisParams.active_rec)imd;
                CopyCoefficients(coeff, ac.cev);
                ac.cev.cal_curve_equation = CurveEquation;
                ac.cev.lower_mass_limit = cclist.LowerMassLimit;
                ac.cev.upper_mass_limit = cclist.UpperMassLimit;
                ac.dcl_mass = cclist.MassAsArray;
                ac.doubles = cclist.DoublesAsArray;
                break;
            }
            imd.modified = true;
            // ok save it now
            N.App.DB.UpdateAnalysisMethod(sel, lam);  // flush changes on internal map to the DB
            MessageBox.Show(string.Format("Calibration data for analysis method {0} and material type {1} successfully stored in the database",
                                    det.Id.DetectorId, Material),
                    "Coefficient File Ingester", MessageBoxButtons.OK);
        }
示例#19
0
        /// <summary>
        /// Get specific parameter sets for the given detector, material type pair.
        /// Returns default values if database entry not found
        /// </summary>
        /// <param name="detname"></param>
        /// <param name="mat"></param>
        /// <param name="db"></param>
        public void IngestAnalysisMethodSpecificsFromDB(INCCSelector sel, AnalysisMethods ams, DB.AnalysisMethodSpecifiers db)
        {
            foreach (AnalysisMethod am in System.Enum.GetValues(typeof(AnalysisMethod)))
            {
                if (!ams.choices[(int)am])
                {
                    continue;
                }
                if (!(am > AnalysisMethod.None && am <= AnalysisMethod.TruncatedMultiplicity && (am != AnalysisMethod.INCCNone)))
                {
                    if (!am.IsNone())
                    {
                        NC.App.Pest.logger.TraceEvent(LogLevels.Warning, 34061, "Skipping DB ingest of {0} {1} calib params", sel, am);
                    }
                    continue;
                }
                string    current = String.Format("{0} {1} parameters", sel, am.FullName());
                int       logid   = 34170 + (int)am;
                LogLevels lvl     = LogLevels.Verbose;
                DataRow   dr;
                switch (am)
                {
                case AnalysisMethod.KnownA:
                    INCCAnalysisParams.known_alpha_rec ks = new INCCAnalysisParams.known_alpha_rec();
                    dr = db.Get(sel.detectorid, sel.material, "known_alpha_rec");
                    if (dr != null)
                    {
                        ks.rho_zero  = DB.Utils.DBDouble(dr["rho_zero"]);
                        ks.alpha_wt  = DB.Utils.DBDouble(dr["alpha_wt"]);
                        ks.k         = DB.Utils.DBDouble(dr["k"]);
                        ks.cev.a     = DB.Utils.DBDouble(dr["a"]);
                        ks.cev.b     = DB.Utils.DBDouble(dr["b"]);
                        ks.cev.var_a = DB.Utils.DBDouble(dr["var_a"]);
                        ks.cev.var_b = DB.Utils.DBDouble(dr["var_b"]);
                        ks.cev.setcovar(Coeff.a, Coeff.b, DB.Utils.DBDouble(dr["covar_ab"]));
                        ks.cev.sigma_x      = DB.Utils.DBDouble(dr["sigma_x"]);
                        ks.known_alpha_type = (INCCAnalysisParams.KnownAlphaVariant)(DB.Utils.DBInt32(dr["known_alpha_type"]));
                        ks.ring_ratio.cal_curve_equation = (INCCAnalysisParams.CurveEquation)(DB.Utils.DBInt32(dr["ring_ratio_equation"]));
                        ks.ring_ratio.a            = DB.Utils.DBDouble(dr["ring_ratio_a"]);
                        ks.ring_ratio.b            = DB.Utils.DBDouble(dr["ring_ratio_b"]);
                        ks.ring_ratio.c            = DB.Utils.DBDouble(dr["ring_ratio_c"]);
                        ks.ring_ratio.d            = DB.Utils.DBDouble(dr["ring_ratio_d"]);
                        ks.dcl_mass                = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                        ks.doubles                 = DB.Utils.ReifyDoubles((string)dr["doubles"]);
                        ks.heavy_metal_reference   = DB.Utils.DBDouble(dr["heavy_metal_reference"]);
                        ks.heavy_metal_corr_factor = DB.Utils.DBDouble(dr["heavy_metal_corr_factor"]);
                        ks.cev.upper_mass_limit    = DB.Utils.DBDouble(dr["upper_mass_limit"]);
                        ks.cev.lower_mass_limit    = DB.Utils.DBDouble(dr["lower_mass_limit"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, ks);
                    break;

                case AnalysisMethod.CalibrationCurve:
                    INCCAnalysisParams.cal_curve_rec cs = new INCCAnalysisParams.cal_curve_rec();
                    dr = db.Get(sel.detectorid, sel.material, "cal_curve_rec");
                    if (dr != null)
                    {
                        CalCurveDBSnock(cs.cev, dr);
                        cs.CalCurveType            = (INCCAnalysisParams.CalCurveType)DB.Utils.DBInt32(dr["cal_curve_type"]);
                        cs.dcl_mass                = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                        cs.doubles                 = DB.Utils.ReifyDoubles((string)dr["doubles"]);
                        cs.percent_u235            = DB.Utils.DBDouble(dr["percent_u235"]);
                        cs.heavy_metal_reference   = DB.Utils.DBDouble(dr["heavy_metal_reference"]);
                        cs.heavy_metal_corr_factor = DB.Utils.DBDouble(dr["heavy_metal_corr_factor"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, cs);
                    break;

                case AnalysisMethod.KnownM:
                    INCCAnalysisParams.known_m_rec ms = new INCCAnalysisParams.known_m_rec();
                    dr = db.Get(sel.detectorid, sel.material, "known_m_rec");
                    if (dr != null)
                    {
                        ms.sf_rate          = DB.Utils.DBDouble(dr["sf_rate"]);
                        ms.vs1              = DB.Utils.DBDouble(dr["vs1"]);
                        ms.vs2              = DB.Utils.DBDouble(dr["vs2"]);
                        ms.vi1              = DB.Utils.DBDouble(dr["vi1"]);
                        ms.vi2              = DB.Utils.DBDouble(dr["vi2"]);
                        ms.b                = DB.Utils.DBDouble(dr["b"]);
                        ms.c                = DB.Utils.DBDouble(dr["c"]);
                        ms.sigma_x          = DB.Utils.DBDouble(dr["sigma_x"]);
                        ms.lower_mass_limit = DB.Utils.DBDouble(dr["lower_mass_limit"]);
                        ms.upper_mass_limit = DB.Utils.DBDouble(dr["upper_mass_limit"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, ms);
                    break;

                case AnalysisMethod.Multiplicity:
                    INCCAnalysisParams.multiplicity_rec mu = new INCCAnalysisParams.multiplicity_rec();
                    dr = db.Get(sel.detectorid, sel.material, "multiplicity_rec");
                    if (dr != null)
                    {
                        mu.solve_efficiency = (INCCAnalysisParams.MultChoice)DB.Utils.DBInt32(dr["solve_efficiency"]);
                        mu.sf_rate          = DB.Utils.DBDouble(dr["sf_rate"]);
                        mu.vs1              = DB.Utils.DBDouble(dr["vs1"]);
                        mu.vs2              = DB.Utils.DBDouble(dr["vs2"]);
                        mu.vs3              = DB.Utils.DBDouble(dr["vs3"]);
                        mu.vi1              = DB.Utils.DBDouble(dr["vi1"]);
                        mu.vi2              = DB.Utils.DBDouble(dr["vi2"]);
                        mu.vi3              = DB.Utils.DBDouble(dr["vi3"]);
                        mu.a                = DB.Utils.DBDouble(dr["a"]);
                        mu.b                = DB.Utils.DBDouble(dr["b"]);
                        mu.c                = DB.Utils.DBDouble(dr["c"]);
                        mu.sigma_x          = DB.Utils.DBDouble(dr["sigma_x"]);
                        mu.alpha_weight     = DB.Utils.DBDouble(dr["alpha_weight"]);
                        mu.multEffCorFactor = DB.Utils.DBDouble(dr["eff_cor"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, mu);
                    break;

                case AnalysisMethod.TruncatedMultiplicity:
                    INCCAnalysisParams.truncated_mult_rec tm = new INCCAnalysisParams.truncated_mult_rec();
                    dr = db.Get(sel.detectorid, sel.material, "truncated_mult_rec");
                    if (dr != null)
                    {
                        tm.known_eff = DB.Utils.DBBool(dr["known_eff"]);
                        tm.solve_eff = DB.Utils.DBBool(dr["vs1"]);
                        tm.a         = DB.Utils.DBDouble(dr["a"]);
                        tm.b         = DB.Utils.DBDouble(dr["b"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, tm);
                    break;

                case AnalysisMethod.CuriumRatio:
                    INCCAnalysisParams.curium_ratio_rec cm = new INCCAnalysisParams.curium_ratio_rec();
                    dr = db.Get(sel.detectorid, sel.material, "curium_ratio_rec");
                    if (dr != null)
                    {
                        cm.curium_ratio_type = (INCCAnalysisParams.CuriumRatioVariant)DB.Utils.DBInt32(dr["curium_ratio_type"]);
                        CalCurveDBSnock(cm.cev, dr);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, cm);
                    break;

                case AnalysisMethod.Active:
                    INCCAnalysisParams.active_rec ar = new INCCAnalysisParams.active_rec();
                    dr = db.Get(sel.detectorid, sel.material, "active_rec");
                    if (dr != null)
                    {
                        CalCurveDBSnock(ar.cev, dr);
                        ar.dcl_mass = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                        ar.doubles  = DB.Utils.ReifyDoubles((string)dr["doubles"]);
                    }
                    else
                    {
                        lvl = LogLevels.Warning;
                    }
                    ams.AddMethod(am, ar);
                    break;

                case AnalysisMethod.AddASource:
                    INCCAnalysisParams.add_a_source_rec aas = new INCCAnalysisParams.add_a_source_rec();
                    dr = db.Get(sel.detectorid, sel.material, "add_a_source_rec");
                    if (dr != null)
                    {
                        CalCurveDBSnock(aas.cev, dr);
                        aas.dcl_mass = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                        aas.doubles  = DB.Utils.ReifyDoubles((string)dr["doubles"]);

                        aas.cf.a = DB.Utils.DBDouble(dr["cf_a"]);
                        aas.cf.b = DB.Utils.DBDouble(dr["cf_b"]);
                        aas.cf.c = DB.Utils.DBDouble(dr["cf_c"]);
                        aas.cf.d = DB.Utils.DBDouble(dr["cf_d"]);

                        aas.dzero_avg                = DB.Utils.DBDouble(dr["dzero_avg"]);
                        aas.num_runs                 = DB.Utils.DBUInt16(dr["num_runs"]);
                        aas.position_dzero           = DB.Utils.ReifyDoubles((string)dr["position_dzero"]);
                        aas.dzero_ref_date           = DB.Utils.DBDateTime(dr["dzero_ref_date"]);
                        aas.use_truncated_mult       = DB.Utils.DBBool(dr["use_truncated_mult"]);
                        aas.tm_dbls_rate_upper_limit = DB.Utils.DBDouble(dr["tm_dbls_rate_upper_limit"]);
                        aas.tm_weighting_factor      = DB.Utils.DBDouble(dr["tm_weighting_factor"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, aas);
                    break;

                case AnalysisMethod.ActiveMultiplicity:
                    INCCAnalysisParams.active_mult_rec amr = new INCCAnalysisParams.active_mult_rec();
                    dr = db.Get(sel.detectorid, sel.material, "active_mult_rec");
                    if (dr != null)
                    {
                        amr.vf1 = DB.Utils.DBDouble(dr["vf1"]);
                        amr.vf2 = DB.Utils.DBDouble(dr["vf2"]);
                        amr.vf3 = DB.Utils.DBDouble(dr["vf3"]);
                        amr.vt1 = DB.Utils.DBDouble(dr["vt1"]);
                        amr.vt2 = DB.Utils.DBDouble(dr["vt2"]);
                        amr.vt3 = DB.Utils.DBDouble(dr["vt3"]);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, amr);
                    break;

                case AnalysisMethod.ActivePassive:
                    INCCAnalysisParams.active_passive_rec acp = new INCCAnalysisParams.active_passive_rec();
                    dr = db.Get(sel.detectorid, sel.material, "active_passive_rec");
                    if (dr != null)
                    {
                        CalCurveDBSnock(acp.cev, dr);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, acp);
                    break;

                case AnalysisMethod.Collar:
                    INCCAnalysisParams.collar_rec cr = new INCCAnalysisParams.collar_rec();
                    dr = db.Get(sel.detectorid, sel.material, "collar_rec");
                    if (dr != null)
                    {
                        CalCurveDBSnock(cr.cev, dr);
                        cr.collar_mode            = DB.Utils.DBBool(dr["collar_mode"]);
                        cr.number_calib_rods      = DB.Utils.DBInt32(dr["number_calib_rods"]);
                        cr.sample_corr_fact.v     = DB.Utils.DBDouble(dr["sample_corr_fact"]);
                        cr.sample_corr_fact.err   = DB.Utils.DBDouble(dr["sample_corr_fact_err"]);
                        cr.u_mass_corr_fact_a.v   = DB.Utils.DBDouble(dr["u_mass_corr_fact_a"]);
                        cr.u_mass_corr_fact_a.err = DB.Utils.DBDouble(dr["u_mass_corr_fact_a_err"]);
                        cr.u_mass_corr_fact_b.v   = DB.Utils.DBDouble(dr["u_mass_corr_fact_b"]);
                        cr.u_mass_corr_fact_b.err = DB.Utils.DBDouble(dr["u_mass_corr_fact_b_err"]);
                        cr.poison_absorption_fact = DB.Utils.ReifyDoubles((string)dr["poison_absorption_fact"]);
                        cr.poison_rod_type        = DB.Utils.ReifyStrings((string)dr["poison_rod_type"]);

                        cr.poison_rod_a = TupleArraySlurp(ref cr.poison_rod_a, "poison_rod_a", dr);
                        cr.poison_rod_b = TupleArraySlurp(ref cr.poison_rod_b, "poison_rod_b", dr);
                        cr.poison_rod_c = TupleArraySlurp(ref cr.poison_rod_c, "poison_rod_c", dr);
                    }
                    else
                    {
                        lvl = LogLevels.Info;
                    }
                    ams.AddMethod(am, cr);
                    break;

                default:
                    lvl = LogLevels.Error; logid = 34181; current = "Choosing to not construct" + current;
                    break;
                }
                switch (lvl)
                {
                case LogLevels.Info:
                    current = "Using default for " + current;
                    lvl     = LogLevels.Verbose;
                    break;

                case LogLevels.Verbose:
                    current = "Retrieved for " + current;
                    break;

                default:
                    break;
                }
                NC.App.Pest.logger.TraceEvent(lvl, logid, current);
            } // for
        }
示例#20
0
        public void UpdateAnalysisMethod(INCCSelector sel, AnalysisMethods ams)
        {
            DB.AnalysisMethodSpecifiers db = new DB.AnalysisMethodSpecifiers();

            if (ams.modified)
            {
                UpdateAnalysisMethods(sel, ams, db);
            }
            UpdateAnalysisMethodSpecifics(sel.detectorid, sel.material,db);
        }
示例#21
0
 public void UpdateAnalysisMethods(INCCSelector sel, AnalysisMethods am, DB.AnalysisMethodSpecifiers db = null)
 {
     if (db == null)
         db = new DB.AnalysisMethodSpecifiers();
     DB.ElementList saParams;
     saParams = am.ToDBElementList();
     if (!db.Update(sel.detectorid, sel.material, saParams)) // am not there, so add it
     {
         NC.App.Pest.logger.TraceEvent(LogLevels.Verbose, 34027, "Failed to update analysis method spec for " + sel.ToString());
     }
     else
     {
         NC.App.Pest.logger.TraceEvent(LogLevels.Verbose, 34026, "Updated/created analysis method spec for " + sel.ToString());
     }
     am.modified = false;
 }
示例#22
0
            internal static unsafe collar_detector_rec MoveCD(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
            {
                INCCAnalysisParams.collar_combined_rec imr = (INCCAnalysisParams.collar_combined_rec)md;
                collar_detector_rec m = new collar_detector_rec();
                byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
                char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.collar_detector_id);
                b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
                a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.collar_detector_item_type);
                m.collar_detector_mode = (byte)(imr.collar_det.collar_mode ? 1 : 0);

                b = new byte[INCC.DATE_TIME_LENGTH];
                a = imr.collar_det.reference_date.ToString("yy.MM.dd").ToCharArray();
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.col_reference_date);
                m.col_relative_doubles_rate = imr.collar_det.relative_doubles_rate;
                return m;
            }
示例#23
0
        public static unsafe List<INCCInitialDataCalibrationFile> CalibFromDetectors(List<Detector> dets)
        {
            List<INCCInitialDataCalibrationFile> list = new List<INCCInitialDataCalibrationFile>();

            foreach(Detector det in dets)
            {
                INCCInitialDataCalibrationFile idcf = new INCCInitialDataCalibrationFile(NC.App.Loggers.Logger(LMLoggers.AppSection.Control), null);
                idcf.Name = det.Id.DetectorId;
                foreach (INCCDB.Descriptor desc in NC.App.DB.Materials.GetList())
                {
                    INCCSelector se = new INCCSelector(det.Id.DetectorId, desc.Name);
                    if (!NC.App.DB.DetectorMaterialAnalysisMethods.ContainsKey(se))
                        continue;

                    // do the method choice rec first
                    DetectorMaterialMethod dmm = new DetectorMaterialMethod(se.material, se.detectorid, INCC.METHOD_NONE);
                    idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveAMR(se));

             					// then do each method rec
                    AnalysisMethods ams = NC.App.DB.DetectorMaterialAnalysisMethods[se];
                    IEnumerator iter = ams.GetMethodEnumerator();
                    while (iter.MoveNext())
                    {
                        Tuple<AnalysisMethod, INCCAnalysisParams.INCCMethodDescriptor> md = (Tuple<AnalysisMethod, INCCAnalysisParams.INCCMethodDescriptor>)iter.Current;
                        dmm = new DetectorMaterialMethod(se.material, se.detectorid, (byte)NewTypeToOldMethodId(md.Item1));
                        switch(md.Item1)
                        {
                            case AnalysisMethod.KnownA:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveKA(se, md.Item2));
                                break;
                            case AnalysisMethod.CalibrationCurve:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveCC(se, md.Item2));
                                break;
                            case AnalysisMethod.KnownM:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveKM(se, md.Item2));
                                break;
                            case AnalysisMethod.Multiplicity:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveMult(se, md.Item2));
                                break;
                            case AnalysisMethod.TruncatedMultiplicity:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveTM(se, md.Item2));
                                break;
                            case AnalysisMethod.AddASource:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveAS(se, md.Item2));
                                break;
                            case AnalysisMethod.CuriumRatio:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveCR(se, md.Item2));
                                break;
                            case AnalysisMethod.Active:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveCA(se, md.Item2));
                                break;
                            case AnalysisMethod.ActivePassive:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveAP(se, md.Item2));
                                break;
                            case AnalysisMethod.ActiveMultiplicity:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveAM(se, md.Item2));
                                break;
                            case AnalysisMethod.DUAL_ENERGY_MULT_SAVE_RESTORE:
                                  idcf.DetectorMaterialMethodParameters.Add(dmm, Calib5.MoveDE(se, md.Item2));
                                break;
                            case AnalysisMethod.Collar:
                                try
                                {
                                      idcf.DetectorMaterialMethodParameters.
                                            Add(new DetectorMaterialMethod(se.material, se.detectorid, INCC.COLLAR_DETECTOR_SAVE_RESTORE), Calib5.MoveCD(se, md.Item2));
                                      idcf.DetectorMaterialMethodParameters.
                                            Add(new DetectorMaterialMethod(se.material, se.detectorid, INCC.COLLAR_SAVE_RESTORE), Calib5.MoveCO(se, md.Item2));
                                      idcf.DetectorMaterialMethodParameters.
                                            Add(new DetectorMaterialMethod(se.material, se.detectorid, INCC.COLLAR_K5_SAVE_RESTORE), Calib5.MoveCK(se, md.Item2));
                                }
                                catch (Exception e)
                                {
                                    NC.App.Loggers.Logger(LMLoggers.AppSection.Control).TraceEvent(LogLevels.Warning, 34102, "Collar xfer processing error {0} {1}", md.Item1.FullName(), e.Message);
                                }
                                break;
                            case AnalysisMethod.COLLAR_SAVE_RESTORE:
                            case AnalysisMethod.COLLAR_DETECTOR_SAVE_RESTORE:
                            case AnalysisMethod.COLLAR_K5_SAVE_RESTORE:
                                    NC.App.Loggers.Logger(LMLoggers.AppSection.Control).TraceEvent(LogLevels.Verbose, 34100, "Got '{0}' ", md.Item1.FullName());
                                break;
                            case AnalysisMethod.INCCNone:
                                break;
                            default:
                                break;
                        }
                    }
                }
                list.Add(idcf);
            }
            return list;
        }
示例#24
0
            internal static unsafe collar_k5_rec MoveCK(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
            {
                INCCAnalysisParams.collar_combined_rec imr = (INCCAnalysisParams.collar_combined_rec)md;
                collar_k5_rec m = new collar_k5_rec();
                byte[] b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
                char[] a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.collar_k5_item_type);
                CopyTuples(imr.k5.k5, m.collar_k5, m.collar_k5_err, INCC.MAX_COLLAR_K5_PARAMETERS);
                TransferUtils.CopyBoolsToInts(imr.k5.k5_checkbox, m.collar_k5_checkbox);
                m.collar_k5_mode = (byte)(imr.k5.k5_mode ? 1 : 0);

                byte[] bb = new byte[INCC.MAX_COLLAR_K5_PARAMETERS * INCC.MAX_K5_LABEL_LENGTH];
                int indx = 0;
                for (int i = 0; i < INCC.MAX_COLLAR_K5_PARAMETERS; i++)
                {
                    char[] aa = imr.k5.k5_label[i].ToCharArray(0, Math.Min(imr.k5.k5_label[i].Length, INCC.MAX_K5_LABEL_LENGTH));
                    Encoding.ASCII.GetBytes(aa, 0, aa.Length, bb, indx);
                    indx += INCC.MAX_K5_LABEL_LENGTH;
                }
                TransferUtils.Copy(bb, 0, m.collar_k5_label, 0, INCC.MAX_COLLAR_K5_PARAMETERS * INCC.MAX_K5_LABEL_LENGTH);
                return m;
            }
示例#25
0
        /// <summary>
        /// Get specific parameter sets for the given detector, material type pair.
        /// Returns default values if database entry not found
        /// </summary>
        /// <param name="detname"></param>
        /// <param name="mat"></param>
        /// <param name="db"></param>
        public void IngestAnalysisMethodSpecificsFromDB(INCCSelector sel, AnalysisMethods ams, DB.AnalysisMethodSpecifiers db)
        {
            foreach (AnalysisMethod am in System.Enum.GetValues(typeof(AnalysisMethod)))
            {
                if (!ams.choices[(int)am])
                    continue;
                if (!(am > AnalysisMethod.None && am <= AnalysisMethod.TruncatedMultiplicity && (am != AnalysisMethod.INCCNone)))
                {
                    if (!am.IsNone())
                        NC.App.Pest.logger.TraceEvent(LogLevels.Warning, 34061, "Skipping DB ingest of {0} {1} calib params", sel, am);
                    continue;
                }
                string current = String.Format("{0} {1} parameters", sel, am.FullName());
                int logid = 34170 + (int)am;
                LogLevels lvl = LogLevels.Verbose;
                DataRow dr;
                switch (am)
                {
                    case AnalysisMethod.KnownA:
                        INCCAnalysisParams.known_alpha_rec ks = new INCCAnalysisParams.known_alpha_rec();
                        dr = db.Get(sel.detectorid, sel.material, "known_alpha_rec");
                        if (dr != null)
                        {
                            ks.rho_zero = DB.Utils.DBDouble(dr["rho_zero"]);
                            ks.alpha_wt = DB.Utils.DBDouble(dr["alpha_wt"]);
                            ks.k = DB.Utils.DBDouble(dr["k"]);
                            ks.cev.a = DB.Utils.DBDouble(dr["a"]);
                            ks.cev.b = DB.Utils.DBDouble(dr["b"]);
                            ks.cev.var_a = DB.Utils.DBDouble(dr["var_a"]);
                            ks.cev.var_b = DB.Utils.DBDouble(dr["var_b"]);
                            ks.cev.setcovar(Coeff.a, Coeff.b, DB.Utils.DBDouble(dr["covar_ab"]));
                            ks.cev.sigma_x = DB.Utils.DBDouble(dr["sigma_x"]);
                            ks.known_alpha_type = (INCCAnalysisParams.KnownAlphaVariant)(DB.Utils.DBInt32(dr["known_alpha_type"]));
                            ks.ring_ratio.cal_curve_equation = (INCCAnalysisParams.CurveEquation)(DB.Utils.DBInt32(dr["ring_ratio_equation"]));
                            ks.ring_ratio.a = DB.Utils.DBDouble(dr["ring_ratio_a"]);
                            ks.ring_ratio.b = DB.Utils.DBDouble(dr["ring_ratio_b"]);
                            ks.ring_ratio.c = DB.Utils.DBDouble(dr["ring_ratio_c"]);
                            ks.ring_ratio.d = DB.Utils.DBDouble(dr["ring_ratio_d"]);
                            ks.dcl_mass = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                            ks.doubles = DB.Utils.ReifyDoubles((string)dr["doubles"]);
                            ks.heavy_metal_reference = DB.Utils.DBDouble(dr["heavy_metal_reference"]);
                            ks.heavy_metal_corr_factor = DB.Utils.DBDouble(dr["heavy_metal_corr_factor"]);
                            ks.cev.upper_mass_limit = DB.Utils.DBDouble(dr["upper_mass_limit"]);
                            ks.cev.lower_mass_limit = DB.Utils.DBDouble(dr["lower_mass_limit"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, ks);
                        break;
                    case AnalysisMethod.CalibrationCurve:
                        INCCAnalysisParams.cal_curve_rec cs = new INCCAnalysisParams.cal_curve_rec();
                        dr = db.Get(sel.detectorid, sel.material, "cal_curve_rec");
                        if (dr != null)
                        {
                            CalCurveDBSnock(cs.cev, dr);
                            cs.CalCurveType = (INCCAnalysisParams.CalCurveType)DB.Utils.DBInt32(dr["cal_curve_type"]);
                            cs.dcl_mass = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                            cs.doubles = DB.Utils.ReifyDoubles((string)dr["doubles"]);
                            cs.percent_u235 = DB.Utils.DBDouble(dr["percent_u235"]);
                            cs.heavy_metal_reference = DB.Utils.DBDouble(dr["heavy_metal_reference"]);
                            cs.heavy_metal_corr_factor = DB.Utils.DBDouble(dr["heavy_metal_corr_factor"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, cs);
                        break;
                    case AnalysisMethod.KnownM:
                        INCCAnalysisParams.known_m_rec ms = new INCCAnalysisParams.known_m_rec();
                        dr = db.Get(sel.detectorid, sel.material, "known_m_rec");
                        if (dr != null)
                        {
                            ms.sf_rate = DB.Utils.DBDouble(dr["sf_rate"]);
                            ms.vs1 = DB.Utils.DBDouble(dr["vs1"]);
                            ms.vs2 = DB.Utils.DBDouble(dr["vs2"]);
                            ms.vi1 = DB.Utils.DBDouble(dr["vi1"]);
                            ms.vi2 = DB.Utils.DBDouble(dr["vi2"]);
                            ms.b = DB.Utils.DBDouble(dr["b"]);
                            ms.c = DB.Utils.DBDouble(dr["c"]);
                            ms.sigma_x = DB.Utils.DBDouble(dr["sigma_x"]);
                            ms.lower_mass_limit = DB.Utils.DBDouble(dr["lower_mass_limit"]);
                            ms.upper_mass_limit = DB.Utils.DBDouble(dr["upper_mass_limit"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, ms);
                        break;
                    case AnalysisMethod.Multiplicity:
                        INCCAnalysisParams.multiplicity_rec mu = new INCCAnalysisParams.multiplicity_rec();
                        dr = db.Get(sel.detectorid, sel.material, "multiplicity_rec");
                        if (dr != null)
                        {
                            mu.solve_efficiency = (INCCAnalysisParams.MultChoice)DB.Utils.DBInt32(dr["solve_efficiency"]);
                            mu.sf_rate = DB.Utils.DBDouble(dr["sf_rate"]);
                            mu.vs1 = DB.Utils.DBDouble(dr["vs1"]);
                            mu.vs2 = DB.Utils.DBDouble(dr["vs2"]);
                            mu.vs3 = DB.Utils.DBDouble(dr["vs3"]);
                            mu.vi1 = DB.Utils.DBDouble(dr["vi1"]);
                            mu.vi2 = DB.Utils.DBDouble(dr["vi2"]);
                            mu.vi3 = DB.Utils.DBDouble(dr["vi3"]);
                            mu.a = DB.Utils.DBDouble(dr["a"]);
                            mu.b = DB.Utils.DBDouble(dr["b"]);
                            mu.c = DB.Utils.DBDouble(dr["c"]);
                            mu.sigma_x = DB.Utils.DBDouble(dr["sigma_x"]);
                            mu.alpha_weight = DB.Utils.DBDouble(dr["alpha_weight"]);
                            mu.multEffCorFactor = DB.Utils.DBDouble(dr["eff_cor"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, mu);
                        break;
                    case AnalysisMethod.TruncatedMultiplicity:
                        INCCAnalysisParams.truncated_mult_rec tm = new INCCAnalysisParams.truncated_mult_rec();
                        dr = db.Get(sel.detectorid, sel.material, "truncated_mult_rec");
                        if (dr != null)
                        {
                            tm.known_eff = DB.Utils.DBBool(dr["known_eff"]);
                            tm.solve_eff = DB.Utils.DBBool(dr["vs1"]);
                            tm.a = DB.Utils.DBDouble(dr["a"]);
                            tm.b = DB.Utils.DBDouble(dr["b"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, tm);
                        break;
                    case AnalysisMethod.CuriumRatio:
                        INCCAnalysisParams.curium_ratio_rec cm = new INCCAnalysisParams.curium_ratio_rec();
                        dr = db.Get(sel.detectorid, sel.material, "curium_ratio_rec");
                        if (dr != null)
                        {
                            cm.curium_ratio_type = (INCCAnalysisParams.CuriumRatioVariant)DB.Utils.DBInt32(dr["curium_ratio_type"]);
                            CalCurveDBSnock(cm.cev, dr);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, cm);
                        break;
                    case AnalysisMethod.Active:
                        INCCAnalysisParams.active_rec ar = new INCCAnalysisParams.active_rec();
                        dr = db.Get(sel.detectorid, sel.material, "active_rec");
                        if (dr != null)
                        {
                            CalCurveDBSnock(ar.cev, dr);
                            ar.dcl_mass = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                            ar.doubles = DB.Utils.ReifyDoubles((string)dr["doubles"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, ar);
                        break;
                    case AnalysisMethod.AddASource:
                        INCCAnalysisParams.add_a_source_rec aas = new INCCAnalysisParams.add_a_source_rec();
                        dr = db.Get(sel.detectorid, sel.material, "add_a_source_rec");
                        if (dr != null)
                        {
                            CalCurveDBSnock(aas.cev, dr);
                            aas.dcl_mass = DB.Utils.ReifyDoubles((string)dr["dcl_mass"]);
                            aas.doubles = DB.Utils.ReifyDoubles((string)dr["doubles"]);

                            aas.cf.a = DB.Utils.DBDouble(dr["cf_a"]);
                            aas.cf.b = DB.Utils.DBDouble(dr["cf_b"]);
                            aas.cf.c = DB.Utils.DBDouble(dr["cf_c"]);
                            aas.cf.d = DB.Utils.DBDouble(dr["cf_d"]);

                            aas.dzero_avg = DB.Utils.DBDouble(dr["dzero_avg"]);
                            aas.num_runs = DB.Utils.DBUInt16(dr["num_runs"]);
                            aas.position_dzero = DB.Utils.ReifyDoubles((string)dr["position_dzero"]);
                            aas.dzero_ref_date = DB.Utils.DBDateTime(dr["dzero_ref_date"]);
                            aas.use_truncated_mult = DB.Utils.DBBool(dr["use_truncated_mult"]);
                            aas.tm_dbls_rate_upper_limit = DB.Utils.DBDouble(dr["tm_dbls_rate_upper_limit"]);
                            aas.tm_weighting_factor = DB.Utils.DBDouble(dr["tm_weighting_factor"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, aas);
                        break;
                    case AnalysisMethod.ActiveMultiplicity:
                        INCCAnalysisParams.active_mult_rec amr = new INCCAnalysisParams.active_mult_rec();
                        dr = db.Get(sel.detectorid, sel.material, "active_mult_rec");
                        if (dr != null)
                        {
                            amr.vf1 = DB.Utils.DBDouble(dr["vf1"]);
                            amr.vf2 = DB.Utils.DBDouble(dr["vf2"]);
                            amr.vf3 = DB.Utils.DBDouble(dr["vf3"]);
                            amr.vt1 = DB.Utils.DBDouble(dr["vt1"]);
                            amr.vt2 = DB.Utils.DBDouble(dr["vt2"]);
                            amr.vt3 = DB.Utils.DBDouble(dr["vt3"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, amr);
                        break;
                    case AnalysisMethod.ActivePassive:
                        INCCAnalysisParams.active_passive_rec acp = new INCCAnalysisParams.active_passive_rec();
                        dr = db.Get(sel.detectorid, sel.material, "active_passive_rec");
                        if (dr != null)
                        {
                            CalCurveDBSnock(acp.cev, dr);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, acp);
                        break;
                    case AnalysisMethod.Collar:
                        INCCAnalysisParams.collar_combined_rec cr = new INCCAnalysisParams.collar_combined_rec();
                        dr = db.Get(sel.detectorid, sel.material, "collar_detector_rec");
                        if (dr != null)
                        {
                            cr.collar_det.collar_mode = DB.Utils.DBBool(dr["collar_detector_mode"]);
                            cr.collar_det.reference_date = DB.Utils.DBDateTime(dr["reference_date"]);
                            cr.collar_det.relative_doubles_rate = DB.Utils.DBDouble(dr["relative_doubles_rate"]);
                        }
                        else
                            lvl = LogLevels.Info;
                        dr = db.Get(sel.detectorid, sel.material, "collar_rec");
                        if (dr != null)
                        {
                            CalCurveDBSnock(cr.collar.cev, dr);
                            cr.collar.collar_mode = DB.Utils.DBBool(dr["collar_mode"]);
                            cr.collar.number_calib_rods = DB.Utils.DBInt32(dr["number_calib_rods"]);
                            cr.collar.sample_corr_fact.v = DB.Utils.DBDouble(dr["sample_corr_fact"]);
                            cr.collar.sample_corr_fact.err = DB.Utils.DBDouble(dr["sample_corr_fact_err"]);
                            cr.collar.u_mass_corr_fact_a.v = DB.Utils.DBDouble(dr["u_mass_corr_fact_a"]);
                            cr.collar.u_mass_corr_fact_a.err = DB.Utils.DBDouble(dr["u_mass_corr_fact_a_err"]);
                            cr.collar.u_mass_corr_fact_b.v = DB.Utils.DBDouble(dr["u_mass_corr_fact_b"]);
                            cr.collar.u_mass_corr_fact_b.err = DB.Utils.DBDouble(dr["u_mass_corr_fact_b_err"]);
                            cr.collar.poison_absorption_fact = DB.Utils.ReifyDoubles(dr["poison_absorption_fact"].ToString());
                            cr.collar.poison_rod_type = DB.Utils.ReifyStrings(dr["poison_rod_type"].ToString());
                            TupleArraySlurp(ref cr.collar.poison_rod_a, "poison_rod_a", dr);
                            TupleArraySlurp(ref cr.collar.poison_rod_b, "poison_rod_b", dr);
                            TupleArraySlurp(ref cr.collar.poison_rod_c, "poison_rod_c", dr);
                        }
                        else
                            lvl = LogLevels.Info;
                        dr = db.Get(sel.detectorid, sel.material, "collar_k5_rec");
                        if (dr != null)
                        {
                            cr.k5.k5_mode = DB.Utils.DBBool(dr["k5_mode"]);
                            cr.k5.k5_checkbox = DB.Utils.ReifyBools(dr["k5_checkbox"].ToString());
                            cr.k5.k5_item_type = string.Copy(sel.material);
                            cr.k5.k5_label = DB.Utils.ReifyStrings(dr["k5_label"].ToString());
                            TupleArraySlurp(ref cr.k5.k5, "k5", dr);
                        }
                        else
                            lvl = LogLevels.Info;
                        ams.AddMethod(am, cr);
                        break;
                    default:
                        lvl = LogLevels.Error; logid = 34181; current = "Choosing to not construct" + current;
                        break;
                }
                switch (lvl)
                {
                    case LogLevels.Info:
                        current = "Using default for " + current;
                        lvl = LogLevels.Verbose;
                        break;
                    case LogLevels.Verbose:
                        current = "Retrieved for " + current;
                        break;
                    default:
                        break;
                }
                NC.App.Pest.logger.TraceEvent(lvl, logid, current);
            } // for
        }
示例#26
0
 internal static unsafe curium_ratio_rec MoveCR(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.curium_ratio_rec imr = (INCCAnalysisParams.curium_ratio_rec)md;
     curium_ratio_rec m = new curium_ratio_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.curium_ratio_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.curium_ratio_item_type);
     m.cr_a = imr.cev.a;
     m.cr_b = imr.cev.b;
     m.cr_c = imr.cev.c;
     m.cr_d = imr.cev.d;
     m.curium_ratio_equation = (byte)imr.cev.cal_curve_equation;
     m.curium_ratio_type = NewToOldCRVariants(imr.curium_ratio_type);
     m.cr_covar_ab = imr.cev.covar(Coeff.a, Coeff.b);
     m.cr_covar_ac = imr.cev.covar(Coeff.a, Coeff.c);
     m.cr_covar_ad = imr.cev.covar(Coeff.a, Coeff.d);
     m.cr_covar_bc = imr.cev.covar(Coeff.b, Coeff.c);
     m.cr_covar_bd = imr.cev.covar(Coeff.b, Coeff.d);
     m.cr_covar_cd = imr.cev.covar(Coeff.c, Coeff.d);
     m.cr_var_a = imr.cev.var_a;
     m.cr_var_b = imr.cev.var_b;
     m.cr_var_c = imr.cev.var_c;
     m.cr_var_d = imr.cev.var_d;
     m.cr_sigma_x = imr.cev.sigma_x;
     m.cr_upper_mass_limit = imr.cev.upper_mass_limit;
     m.cr_lower_mass_limit = imr.cev.lower_mass_limit;
     return m;
 }
示例#27
0
        /// <summary>
        /// Finalize measurement instance content for analysis
        /// Populate calibration parameters maps
        /// </summary>
        /// <param name="meas">The partially initialized measurement instance</param>
        /// <param name="useCurCalibParams">Default behavior is to use active method and other calibration parameters;
        ///                                 skipped if Reanalysis prepared the details from database measurement results
        /// </param>
        public static void FillInReanalysisRemainingDetails(Measurement meas, bool useCurCalibParams = true)
        {
            // get the current INCC5 analysis methods
            if (useCurCalibParams || meas.INCCAnalysisState == null)
            {
                meas.INCCAnalysisState = new INCCAnalysisState();
                INCCSelector sel = new INCCSelector(meas.AcquireState.detector_id, meas.AcquireState.item_type);
                AnalysisMethods am;
                bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
                if (found)
                {
                    am.selector = sel; // gotta do this so that the equality operator is not incorrect
                    meas.INCCAnalysisState.Methods = am;
                }
                else
                    meas.INCCAnalysisState.Methods = new AnalysisMethods(sel);
            } // else use what was there

            meas.InitializeContext(clearCounterResults:false);
            meas.PrepareINCCResults();

            System.Collections.IEnumerator iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(Multiplicity));
            while (iter.MoveNext())
            {
                Multiplicity mkey = (Multiplicity)iter.Current;
                try
                {
             					MultiplicityCountingRes mcr = (MultiplicityCountingRes)meas.CountingAnalysisResults[mkey];
                    if (mcr.AB.Unset)
                        LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(mkey, mcr); // works only if MaxBins is set
                    MeasOptionSelector mos = new MeasOptionSelector(meas.MeasOption, mkey);
                    INCCResult result = meas.INCCAnalysisState.Lookup(mos);
                    result.CopyFrom(mcr);
                }
                catch (Exception)
                {
                    //logger.TraceEvent(LogLevels.Error, 4027, "PrepareINCCResults error: " + ex.Message);
                }
            }

            // stratum look up, finds existing stratum by name
            if (useCurCalibParams || meas.Stratum == null)
            {
                List<INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();
                INCCDB.StratumDescriptor s = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0);
                if (s == null)
                    meas.Stratum = new Stratum();
                else
                    meas.Stratum = new Stratum(s.Stratum);
            }
            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state
        }
示例#28
0
            internal static unsafe known_alpha_rec MoveKA(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
            {
                INCCAnalysisParams.known_alpha_rec imr = (INCCAnalysisParams.known_alpha_rec)md;
                known_alpha_rec m = new known_alpha_rec();
                byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
                char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.known_alpha_detector_id);
                b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
                a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
                Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
                TransferUtils.Copy(b, m.known_alpha_item_type);
                m.ka_a = imr.cev.a;
                m.ka_b = imr.cev.b;
                m.ka_var_a = imr.cev.var_a;
                m.ka_var_b = imr.cev.var_b;
                m.ka_covar_ab = imr.cev.covar(Coeff.a, Coeff.b);
                m.ka_sigma_x = imr.cev.sigma_x;
                m.ka_ring_ratio_a = imr.ring_ratio.a;
                m.ka_ring_ratio_b = imr.ring_ratio.b;
                m.ka_ring_ratio_c = imr.ring_ratio.c;
                m.ka_ring_ratio_d = imr.ring_ratio.d;
                m.ka_alpha_wt = imr.alpha_wt;
                m.ka_rho_zero = imr.rho_zero;
                m.ka_ring_ratio_equation = (double)imr.ring_ratio.cal_curve_equation;
                m.ka_upper_mass_limit = imr.cev.upper_mass_limit;
                m.ka_lower_mass_limit = imr.cev.lower_mass_limit;
                m.ka_heavy_metal_corr_factor = imr.heavy_metal_corr_factor;
                m.ka_heavy_metal_reference = imr.heavy_metal_reference;
                m.ka_k = imr.k;
                m.ka_known_alpha_type = (double)imr.known_alpha_type;
                TransferUtils.CopyDbls(imr.dcl_mass, m.ka_dcl_mass);
                TransferUtils.CopyDbls(imr.doubles, m.ka_doubles);

                return m;
            }
示例#29
0
        /// <summary>
        /// Construct a full measurement state and set it on the internal lameness
        /// </summary>
        /// <param name="acq">Acquire Parameters</param>
        /// <param name="det">Detector</param>
        /// <param name="mo">MeasurementOption</param>
        public static void BuildMeasurement(AcquireParameters acq, Detector det, AssaySelector.MeasurementOption mo)
        {
            // gather it all together
            MeasurementTuple mt = new MeasurementTuple(new DetectorList(det),
                                                       CentralizedState.App.DB.TestParameters.Get(),
                                                       GetCurrentNormParams(det),
                                                       GetCurrentBackgroundParams(det),
                                                       GetAcquireIsotopics(acq),
                                                       acq,
                                                       GetCurrentHVCalibrationParams(det));

            det.Id.source = acq.data_src;  // set the detector overall data source value here

            // create the context holder for the measurement. Everything is rooted here ...
            Measurement meas = new Measurement(mt, mo, CentralizedState.App.Logger(LMLoggers.AppSection.Data));

            if (det.ListMode)
            {
                // dev note: design flaw exposed by this mess here, when LM has > 1 SVR, there is no way to associate > 1 SVRs with a single detector/SR/Mult/Conn pairing
                // It should be the other way around, the Mult params for each LMMultiplicity analyzer override the single entry on the sr_parms_rec when each analyis is performed.

                meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(det, applySRFromDetector: true);
                if (mo == AssaySelector.MeasurementOption.unspecified) // pure List Mode, not INCC5
                {
                    // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params
                    ApplyVSRChangesToDefaultDetector(meas);
                }
                else // it is an INCC5 analysis driven with LM data
                {
                    // check to see if detector settings are copied into an active CA entry
                    if (!meas.AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(det.MultiplicityParams) && w.Active); }))
                    {
                        meas.AnalysisParams.Add(det.MultiplicityParams);
                    }
                }
            }
            else
            {
                // prepare analyzer params from detector SR params
                meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(det, applySRFromDetector: false);
                if (!meas.AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(det.MultiplicityParams)); }))
                {
                    meas.AnalysisParams.Add(det.MultiplicityParams);
                }
            }

            // get the INCC5 analysis methods
            meas.INCCAnalysisState = new INCCAnalysisState();
            INCCSelector    sel = new INCCSelector(acq.detector_id, acq.item_type);
            AnalysisMethods am;
            bool            found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);

            if (found)
            {
                am.selector = sel; // gotta do this so that the equality operator is not incorrect
                meas.INCCAnalysisState.Methods = am;
            }
            else
            {
                meas.INCCAnalysisState.Methods = new AnalysisMethods(sel);
            }

            meas.InitializeContext();

            meas.PrepareINCCResults();

            // next: stratum not set
            List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();

            INCCDB.StratumDescriptor s = sl.Find(w => w.Desc.CompareTo(acq.stratum_id) == 0);
            if (s == null)
            {
                meas.Stratum = new Stratum();
            }
            else
            {
                meas.Stratum = new Stratum(s.Stratum);
            }

            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec  = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state

            // ready for insertion of methods and processing start
        }
示例#30
0
 internal static unsafe multiplicity_rec MoveMult(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.multiplicity_rec imr = (INCCAnalysisParams.multiplicity_rec)md;
     multiplicity_rec mr = new multiplicity_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, mr.multiplicity_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, mr.multiplicity_item_type);
     mr.mul_a = imr.a;
     mr.mul_b = imr.b;
     mr.mul_c = imr.c;
     mr.mul_vi1 = imr.vi1;
     mr.mul_vi2 = imr.vi2;
     mr.mul_vi3 = imr.vi3;
     mr.mul_vs1 = imr.vs1;
     mr.mul_vs2 = imr.vs2;
     mr.mul_vs3 = imr.vs3;
     mr.mul_alpha_weight = imr.alpha_weight;
     mr.mul_sf_rate = imr.sf_rate;
     mr.mul_sigma_x = imr.sigma_x;
     mr.mul_solve_efficiency = (byte)imr.solve_efficiency;
     return mr;
 }
示例#31
0
        /// <summary>
        /// Do the third phase  . . .
        /// From calc_res.cpp,
        /// </summary>
        public static void CalculateResults(this Measurement meas)
        {
            IEnumerator iter = meas.CountingAnalysisResults.GetMultiplicityEnumerator();
            while (iter.MoveNext())
            {
                Multiplicity mkey = (Multiplicity)((KeyValuePair<SpecificCountingAnalyzerParams, object>)(iter.Current)).Key;
                if (NC.App.Opstate.IsAbortRequested)
                    return;

                INCCResult results;
                MeasOptionSelector ar = new MeasOptionSelector(meas.MeasOption, mkey);
                bool found = meas.INCCAnalysisResults.TryGetValue(ar, out results);
                if (!found)
                {
                    meas.AddErrorMessage("No results available", 10151, mkey);
                    return;
                }
                /* if using measure to precision, and max # runs reached, then add warning message indicating actual precision reached. */
                if (meas.AcquireState.acquire_type == AcquireConvergence.DoublesPrecision)
                {
                    if (results.rates.DTCRates.DoublesRate != 0.0)
                    {
                        double error = results.rates.DTCRates.Doubles.err / results.rates.DTCRates.DoublesRate * 100.0;
                        if (error > meas.AcquireState.meas_precision)
                        {
                            meas.AddWarningMessage("Measurement doubles error = " + error.ToString("F2"), 10126, mkey);
                        }
                    }
                }
                else if (meas.AcquireState.acquire_type == AcquireConvergence.TriplesPrecision)
                {
                    if (results.rates.DTCRates.TriplesRate != 0.0)
                    {
                        double error = results.rates.DTCRates.Triples.err / results.rates.DTCRates.TriplesRate * 100.0;
                        if (error > meas.AcquireState.meas_precision)
                        {
                            meas.AddWarningMessage("Measurement triples error = " + error.ToString("F2"), 10127, mkey);
                        }
                    }
                }

                if (meas.MeasOption == AssaySelector.MeasurementOption.rates)   // Doug  Requirement #2
                {
                    // for a rates only measurement, all done!
                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10180, "Rates Only measurement complete");
                    continue;
                }

                try
                {
                    switch (meas.MeasOption)
                    {
                        case AssaySelector.MeasurementOption.background: // Doug  Requirement #3
                            // a bkg is an average over a bunch of cycles with only the deadtime correction applied,
                            // but note the variant for Truncated Mult background, where an additional calculation is made

                            if (results.rates.DTCRates.DoublesRate > meas.Tests.bkgDoublesRateLimit)
                                meas.AddWarningMessage("Background doubles rate " + results.rates.DTCRates.DoublesRate + " greater than " + meas.Tests.bkgDoublesRateLimit, 10141, mkey);
                            if (results.rates.DTCRates.TriplesRate > meas.Tests.bkgTriplesRateLimit)
                                meas.AddWarningMessage("Background triples rate " + results.rates.DTCRates.TriplesRate + " greater than " + meas.Tests.bkgTriplesRateLimit, 10142, mkey);

                            // dev note: this is a background measurement per se, so we copy the results to the Background class and store the entire thing that way
                            // NEXT: Need to account for Active bkg beginning here.

                            if (Integ.GetCurrentAcquireParams().well_config == WellConfiguration.Active)// Is an active acquisition.
                            {
                                meas.Background.INCCActive.CopyFrom(results.rates.DeadtimeCorrectedRates);
                            }
                            else
                                meas.Background.CopyFrom(results.rates);
                            //  maybe if (INCCAnalysisState.Methods.Has(AnalysisMethod.TruncatedMultiplicity))
                            if (meas.Background.TMBkgParams.ComputeTMBkg)
                                // Trunc Mult Bkg step, calc_tm_rates, sets TM bkg rates on Measurement.Background
                                INCCAnalysis.calc_tm_rates(mkey, results, meas, meas.Background.TMBkgParams, meas.Detector.Id.SRType);

                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10181, "Background measurement complete");
                            break;
                        case AssaySelector.MeasurementOption.initial:

                            INCCResults.results_init_src_rec results_init_src = (INCCResults.results_init_src_rec)results;

                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10182, "Calculating Initial source measurement results");
                            bool funhappy = INCCAnalysis.initial_source_meas(meas, mkey, RatesAdjustments.DeadtimeCorrected);
                            if (!funhappy || !results_init_src.pass)
                            {
                                meas.AddWarningMessage("Initial source measurement failed", 10123, mkey);
                            }
                            // on fail, only the relevant results_init_src_rec is saved
                            // on pass, the normalization parameters are modified with the results_init_src_rec results, and so both are udpated.
                            break;
                        case AssaySelector.MeasurementOption.normalization:

                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10183, "Calculating Normalization measurement results");
                            bool happyfun = INCCAnalysis.bias_test(meas, mkey, RatesAdjustments.DeadtimeCorrected);
                            if (!happyfun)
                            {
                                meas.AddWarningMessage("Normalization test -- data quality is inadequate", 10124, mkey);
                            }
                            break;
                        case AssaySelector.MeasurementOption.precision:

                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10184, "Calculating Precision measurement results");
                            bool charmyfun = INCCAnalysis.precision_test(meas, mkey, RatesAdjustments.DeadtimeCorrected);
                            if (!charmyfun)
                            {
                                meas.AddWarningMessage("Precision test failed", 10125, mkey);
                            }
                            break;
                        case AssaySelector.MeasurementOption.calibration: // from calc_res.cpp
                            if (meas.INCCAnalysisState.Methods.CalibrationAnalysisSelected())
                            {
                                meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10185, "Calculating Calibration measurement results");
                                // dev note: since the analysis routines have similar signatures, design a class OK?
                                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.CalibrationCurve))
                                {
                                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10191, "Calculating " + AnalysisMethod.CalibrationCurve.FullName() + " measurement results");
                                    // get the current results_cal_curve_rec
                                    INCCMethodResults.results_cal_curve_rec ccres = (INCCMethodResults.results_cal_curve_rec)
                                        meas.INCCAnalysisResults.LookupMethodResults(mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.CalibrationCurve, true);

                                    INCCAnalysisParams.cal_curve_rec cal_curve = (INCCAnalysisParams.cal_curve_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.CalibrationCurve);
                                    ccres.methodParams = new INCCAnalysisParams.cal_curve_rec(cal_curve);

                                    double pu_mass = ccres.pu_mass.v;
                                    meas.Isotopics.UpdateDeclaredPuMass(meas.MeasDate, ref pu_mass, INCCAnalysis.INCCParity);
                                    ccres.pu_mass.v = pu_mass;
                                    ccres.pu_mass.err = 0.0;
                                    ccres.pu240e_mass.err = 0.0;

                                    double pu240e_mass = ccres.pu240e_mass.v;
                                    meas.Isotopics.calc_pu240e(pu_mass, out pu240e_mass, meas);
                                    ccres.pu240e_mass.v = pu240e_mass;

                                }
                                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.KnownA))
                                {
                                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10192, "Calculating " + AnalysisMethod.KnownA.FullName() + " calibration results");
                                    INCCMethodResults.results_known_alpha_rec kares = INCCAnalysis.CalculateKnownAlpha(mkey, results.rates, meas, RatesAdjustments.DeadtimeCorrected);
                                    if (kares == null)
                                    {
                                        meas.AddErrorMessage("Known alpha analysis error", 10153, mkey);
                                    }
                                    else
                                    {
                                        kares.pu_mass.v = meas.AcquireState.mass;
                                        double pu_mass = kares.pu_mass.v;
                                        meas.Isotopics.UpdateDeclaredPuMass(meas.MeasDate, ref pu_mass, INCCAnalysis.INCCParity);
                                        kares.pu_mass.v = pu_mass;
                                        kares.pu_mass.err = 0.0;
                                        kares.pu240e_mass.err = 0.0;

                                        double pu240e_mass = kares.pu240e_mass.v;
                                        meas.Isotopics.calc_pu240e(pu_mass, out pu240e_mass, meas);
                                        kares.pu240e_mass.v = pu240e_mass;
                                    }
                                }
                                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Active))
                                {
                                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10192, "Arranging " + AnalysisMethod.Active.FullName() + " calibration results");

                                    INCCSelector sel = new INCCSelector(meas.INCCAnalysisState.Methods.selector);
                                    INCCAnalysisParams.active_rec act;
                                    INCCAnalysisParams.INCCMethodDescriptor surr = meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.Active);
                                    if (surr == null)
                                    {
                                        act = new INCCAnalysisParams.active_rec();
                                        meas.INCCAnalysisState.Methods.AddMethod(AnalysisMethod.Active, act);
                                    }
                                    else
                                    {
                                        act = (INCCAnalysisParams.active_rec)surr;
                                    }
                                    INCCMethodResults.results_active_rec res;
                                    res = (INCCMethodResults.results_active_rec)meas.INCCAnalysisResults.LookupMethodResults(mkey, sel, AnalysisMethod.Active, true);

                                    // all this does is copy the declared mass over to the results, WTF
                                    res.u235_mass.v = meas.AcquireState.mass;

                                }
                                if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource))
                                {
                                    meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10152, "Calculating " + AnalysisMethod.AddASource.FullName() + " calibration results");
                                    INCCSelector sel = new INCCSelector(meas.INCCAnalysisState.Methods.selector);
                                    INCCAnalysisParams.add_a_source_rec aas;
                                    INCCMethodResults.results_add_a_source_rec acres;
                                    INCCAnalysisParams.INCCMethodDescriptor surr = meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.AddASource);
                                    if (surr == null)
                                    {
                                        aas = new INCCAnalysisParams.add_a_source_rec();
                                        meas.INCCAnalysisState.Methods.AddMethod(AnalysisMethod.AddASource, aas);
                                    }
                                    else
                                    {
                                        aas = (INCCAnalysisParams.add_a_source_rec)surr;
                                    }
                                    acres = (INCCMethodResults.results_add_a_source_rec)meas.INCCAnalysisResults.LookupMethodResults(mkey, sel, AnalysisMethod.AddASource, true);

                                    acres.pu_mass.v = meas.AcquireState.mass;
                                    // update_declared_pu_mass
                                    double pu_mass = acres.pu_mass.v;
                                    meas.Isotopics.UpdateDeclaredPuMass(meas.MeasDate, ref pu_mass, INCCAnalysis.INCCParity);
                                    acres.pu_mass.v = pu_mass;
                                    acres.pu_mass.err = 0.0;
                                    acres.pu240e_mass.err = 0.0;

                                    double pu240e_mass = acres.pu240e_mass.v;
                                    meas.Isotopics.calc_pu240e(pu_mass, out pu240e_mass, meas);
                                    acres.pu240e_mass.v = pu240e_mass;

                                }
                            }
                            else
                            {
                                meas.AddErrorMessage("No Calibration analysis methods selected", 10153, mkey);
                            }
                            break;
                        case AssaySelector.MeasurementOption.verification:
                            // see INCC calc_asy.cpp
                            // dev note: check for item in the item table, make sure to place this item id on the MeasurementId.item property
                            if (!string.IsNullOrEmpty(meas.AcquireState.item_id))
                            {
                                meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10194, "Using item id '{0}'", meas.AcquireState.item_id);
                            }
                            else
                                meas.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 10194, "No item id");

                            if (meas.INCCAnalysisState.Methods.VerificationAnalysisSelected())
                            {
                                meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10186, "Calculating {0} measurement results", meas.MeasOption.PrintName());

                                meas.CalculateVerificationResults(mkey, results);
                            }
                            else
                            {
                                meas.AddErrorMessage("No analysis methods selected", 10156, mkey);
                            }
                            break;
                        case AssaySelector.MeasurementOption.holdup:   // NEXT: Hold-up held up, implement it #35
                            meas.Logger.TraceEvent(NCCReporter.LogLevels.Error, 10187, "Holdup analysis unsupported");
                            break;
                    }
                }
                catch (Exception e)
                {
                    meas.Logger.TraceException(e);
                }
            }
        }
示例#32
0
        public unsafe void BuildCalibration(INCCInitialDataCalibrationFile idcf, int num)
        {
            mlogger.TraceEvent(LogLevels.Verbose, 34200, "Building calibration content from {0} {1}", num, idcf.Path);
            bool overwrite = NC.App.AppContext.OverwriteImportedDefs;
            IEnumerator iter = idcf.DetectorMaterialMethodParameters.GetDetectorMaterialEnumerator();
            while (iter.MoveNext())
            {
                DetectorMaterialMethod mkey = ((KeyValuePair<DetectorMaterialMethod, object>)iter.Current).Key;

                mlogger.TraceEvent(LogLevels.Verbose, 34210, "Constructing calibration for {0} {1}", mkey.detector_id, mkey.item_type);

                INCCDB.Descriptor desc = new INCCDB.Descriptor(mkey.item_type, "");
                if (!NC.App.DB.Materials.Has(desc) || overwrite)
                {
                    NC.App.DB.Materials.Update(desc);
                }

                Detector det;
                // look in real detector list for entry with this basic id, if not found, punt or later try creating a new empty detector, it will be filled in later as processing proceeds

                det = NC.App.DB.Detectors.GetItByDetectorId(mkey.detector_id);
                if (det == null)
                {
                    // old code punted if detector not found
                    mlogger.TraceEvent(LogLevels.Warning, 34207, "Skipping detector {0}, pre-existing def not found", mkey.detector_id); // dev note: need flags to control this ehavior in a few more places
                    continue;
                }
                IEnumerator miter2 = idcf.DetectorMaterialMethodParameters.GetMethodEnumerator(mkey.detector_id, mkey.item_type);
                if (miter2 == null)
                    continue;
                INCCSelector sel = new INCCSelector(mkey.detector_id, mkey.item_type);
                AnalysisMethods am;
                bool found = NC.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
                if (!found || am == null)
                {
                    am = new AnalysisMethods(mlogger);
                    am.modified = true;
                    NC.App.DB.DetectorMaterialAnalysisMethods.Add(sel, am);
                }
                while (miter2.MoveNext())
                {
                    // use ref here, not copy so updates update the ref? nope, it;s a map, need to remove and replace
                    int cam = OldTypeToOldMethodId(miter2.Current);
                    mlogger.TraceEvent(LogLevels.Verbose, 34211, "Converting {0} {1} method {2}", mkey.detector_id, mkey.item_type, OldToNewMethodId(cam).FullName());

                    // save the analysis method obtained here under the existing/new detector+material type pair
                    switch (cam)
                    {
                        case INCC.METHOD_NONE:
                            analysis_method_rec iamr = (analysis_method_rec)miter2.Current;
                            // create entries in the am map if needed, copy other settings onto am proper
                            am.Backup = OldToNewMethodId(iamr.backup_method);
                            am.Normal = OldToNewMethodId(iamr.normal_method);
                            am.choices[(int)AnalysisMethod.CalibrationCurve] = (iamr.cal_curve == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.Active] = (iamr.active == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.ActiveMultiplicity] = (iamr.active_mult == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.ActivePassive] = (iamr.active_passive == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.AddASource] = (iamr.add_a_source == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.Collar] = (iamr.collar == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.CuriumRatio] = (iamr.curium_ratio == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.KnownA] = (iamr.known_alpha == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.KnownM] = (iamr.known_m == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.Multiplicity] = (iamr.multiplicity == 0 ? false : true);
                            am.choices[(int)AnalysisMethod.TruncatedMultiplicity] = (iamr.truncated_mult == 0 ? false : true);
                            if (am.AnySelected())
                                am.choices[(int)AnalysisMethod.None] = am.choices[(int)AnalysisMethod.INCCNone] = false;
                            break;
                        case INCC.METHOD_CALCURVE:
                            cal_curve_rec cal_curve = (cal_curve_rec)miter2.Current;
                            INCCAnalysisParams.cal_curve_rec cc = new INCCAnalysisParams.cal_curve_rec();
                            cc.heavy_metal_corr_factor = cal_curve.cc_heavy_metal_corr_factor;
                            cc.heavy_metal_reference = cal_curve.cc_heavy_metal_reference;
                            cc.cev.lower_mass_limit = cal_curve.cc_lower_mass_limit;
                            cc.cev.upper_mass_limit = cal_curve.cc_upper_mass_limit;
                            cc.percent_u235 = cal_curve.cc_percent_u235;
                            TransferUtils.Copy(ref cc.dcl_mass, cal_curve.cc_dcl_mass, INCC.MAX_NUM_CALIB_PTS);
                            TransferUtils.Copy(ref cc.doubles, cal_curve.cc_doubles, INCC.MAX_NUM_CALIB_PTS);

                            cc.cev.a = cal_curve.cc_a; cc.cev.b = cal_curve.cc_b;
                            cc.cev.c = cal_curve.cc_c; cc.cev.d = cal_curve.cc_d;
                            cc.cev.var_a = cal_curve.cc_var_a; cc.cev.var_b = cal_curve.cc_var_b;
                            cc.cev.var_c = cal_curve.cc_var_c; cc.cev.var_d = cal_curve.cc_var_d;
                            cc.cev.setcovar(Coeff.a,Coeff.b,cal_curve.cc_covar_ab);
                            cc.cev._covar[0, 2] = cal_curve.cc_covar_ac;
                            cc.cev._covar[0, 3] = cal_curve.cc_covar_ad;
                            cc.cev._covar[1, 2] = cal_curve.cc_covar_bc;
                            cc.cev._covar[1, 3] = cal_curve.cc_covar_bd;
                            cc.cev._covar[2, 3] = cal_curve.cc_covar_cd;
                            cc.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)cal_curve.cal_curve_equation;
                            cc.CalCurveType = (INCCAnalysisParams.CalCurveType)cal_curve.cc_cal_curve_type;
                            cc.cev.sigma_x = cal_curve.cc_sigma_x;
                            am.AddMethod(AnalysisMethod.CalibrationCurve, cc);
                            break;
                        case INCC.METHOD_AKNOWN:
                            known_alpha_rec known_alpha = (known_alpha_rec)miter2.Current;
                            INCCAnalysisParams.known_alpha_rec ka = new INCCAnalysisParams.known_alpha_rec();

                            ka.alpha_wt = known_alpha.ka_alpha_wt;
                            TransferUtils.Copy(ref ka.dcl_mass, known_alpha.ka_dcl_mass, INCC.MAX_NUM_CALIB_PTS);
                            TransferUtils.Copy(ref ka.doubles, known_alpha.ka_doubles, INCC.MAX_NUM_CALIB_PTS);
                            ka.heavy_metal_corr_factor = known_alpha.ka_heavy_metal_corr_factor;
                            ka.heavy_metal_reference = known_alpha.ka_heavy_metal_reference;
                            ka.k = known_alpha.ka_k;
                            ka.known_alpha_type = (INCCAnalysisParams.KnownAlphaVariant)known_alpha.ka_known_alpha_type;
                            ka.lower_corr_factor_limit = known_alpha.ka_lower_corr_factor_limit;
                            ka.upper_corr_factor_limit = known_alpha.ka_upper_corr_factor_limit;
                            ka.rho_zero = known_alpha.ka_rho_zero;

                            ka.ring_ratio.cal_curve_equation = (INCCAnalysisParams.CurveEquation)known_alpha.ka_ring_ratio_equation;
                            ka.ring_ratio.a = known_alpha.ka_ring_ratio_a;
                            ka.ring_ratio.b = known_alpha.ka_ring_ratio_b;
                            ka.ring_ratio.c = known_alpha.ka_ring_ratio_c;
                            ka.ring_ratio.d = known_alpha.ka_ring_ratio_d;

                            ka.cev.a = known_alpha.ka_a;
                            ka.cev.b = known_alpha.ka_b;
                            ka.cev.var_a = known_alpha.ka_var_a;
                            ka.cev.var_b = known_alpha.ka_var_b;
                            ka.cev.sigma_x = known_alpha.ka_sigma_x;
                            ka.cev._covar[(int)Coeff.a, (int)Coeff.b] = known_alpha.ka_covar_ab;
                            ka.cev.lower_mass_limit = known_alpha.ka_lower_mass_limit;
                            ka.cev.upper_mass_limit = known_alpha.ka_upper_mass_limit;
                            am.AddMethod(AnalysisMethod.KnownA, ka);
                            break;
                        case INCC.METHOD_MKNOWN:
                            known_m_rec known_m = (known_m_rec)miter2.Current;
                            INCCAnalysisParams.known_m_rec km = new INCCAnalysisParams.known_m_rec();
                            km.sf_rate = known_m.km_sf_rate;
                            km.vs1 = known_m.km_vs1;
                            km.vs2 = known_m.km_vs2;
                            km.vi1 = known_m.km_vi1;
                            km.vi2 = known_m.km_vi2;
                            km.b = known_m.km_b;
                            km.c = known_m.km_c;
                            km.lower_mass_limit = known_m.km_lower_mass_limit;
                            km.upper_mass_limit = known_m.km_upper_mass_limit;
                            am.AddMethod(AnalysisMethod.KnownM, km);
                            break;
                        case INCC.METHOD_MULT:
                            multiplicity_rec multiplicity = (multiplicity_rec)miter2.Current;
                            INCCAnalysisParams.multiplicity_rec m = new INCCAnalysisParams.multiplicity_rec();
                            m.solve_efficiency = (INCCAnalysisParams.MultChoice)multiplicity.mul_solve_efficiency;
                            m.sf_rate = multiplicity.mul_sf_rate;
                            m.vs1 = multiplicity.mul_vs1;
                            m.vs2 = multiplicity.mul_vs2;
                            m.vs3 = multiplicity.mul_vs3;
                            m.vi1 = multiplicity.mul_vi1;
                            m.vi2 = multiplicity.mul_vi2;
                            m.vi3 = multiplicity.mul_vi3;
                            m.a = multiplicity.mul_a;
                            m.b = multiplicity.mul_b;
                            m.c = multiplicity.mul_c;
                            m.sigma_x = multiplicity.mul_sigma_x;
                            m.alpha_weight = multiplicity.mul_alpha_weight;
                            am.AddMethod(AnalysisMethod.Multiplicity, m);
                            break;
                        case INCC.DUAL_ENERGY_MULT_SAVE_RESTORE:
                            de_mult_rec de_mult = (de_mult_rec)miter2.Current;
                            INCCAnalysisParams.de_mult_rec de = new INCCAnalysisParams.de_mult_rec();
                            TransferUtils.Copy(ref de.detector_efficiency, de_mult.de_detector_efficiency, INCC.MAX_DUAL_ENERGY_ROWS);
                            TransferUtils.Copy(ref de.inner_outer_ring_ratio, de_mult.de_inner_outer_ring_ratio, INCC.MAX_DUAL_ENERGY_ROWS);
                            TransferUtils.Copy(ref de.neutron_energy, de_mult.de_neutron_energy, INCC.MAX_DUAL_ENERGY_ROWS);
                            TransferUtils.Copy(ref de.relative_fission, de_mult.de_relative_fission, INCC.MAX_DUAL_ENERGY_ROWS);
                            de.inner_ring_efficiency = de_mult.de_inner_ring_efficiency;
                            de.outer_ring_efficiency = de_mult.de_outer_ring_efficiency;
                            am.AddMethod(AnalysisMethod.DUAL_ENERGY_MULT_SAVE_RESTORE, de);
                            break;
                        case INCC.METHOD_TRUNCATED_MULT:
                            truncated_mult_rec truncated_mult = (truncated_mult_rec)miter2.Current;
                            INCCAnalysisParams.truncated_mult_rec tm = new INCCAnalysisParams.truncated_mult_rec();
                            tm.a = truncated_mult.tm_a;
                            tm.b = truncated_mult.tm_b;
                            tm.known_eff = (truncated_mult.tm_known_eff == 0 ? false : true);
                            tm.solve_eff = (truncated_mult.tm_solve_eff == 0 ? false : true);
                            am.AddMethod(AnalysisMethod.TruncatedMultiplicity, tm);
                            break;
                        case INCC.METHOD_CURIUM_RATIO:
                            curium_ratio_rec curium_ratio = (curium_ratio_rec)miter2.Current;
                            INCCAnalysisParams.curium_ratio_rec cr = new INCCAnalysisParams.curium_ratio_rec();
                            cr.curium_ratio_type = OldToNewCRVariants(curium_ratio.curium_ratio_type);

                            cr.cev.a = curium_ratio.cr_a; cr.cev.b = curium_ratio.cr_b;
                            cr.cev.c = curium_ratio.cr_c; cr.cev.d = curium_ratio.cr_d;
                            cr.cev.var_a = curium_ratio.cr_var_a; cr.cev.var_b = curium_ratio.cr_var_b;
                            cr.cev.var_c = curium_ratio.cr_var_c; cr.cev.var_d = curium_ratio.cr_var_d;
                            cr.cev.setcovar(Coeff.a,Coeff.b,curium_ratio.cr_covar_ab);
                            cr.cev._covar[0, 2] = curium_ratio.cr_covar_ac;
                            cr.cev._covar[0, 3] = curium_ratio.cr_covar_ad;
                            cr.cev._covar[1, 2] = curium_ratio.cr_covar_bc;
                            cr.cev._covar[1, 3] = curium_ratio.cr_covar_bd;
                            cr.cev._covar[2, 3] = curium_ratio.cr_covar_cd;
                            cr.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)curium_ratio.curium_ratio_equation;
                            cr.cev.sigma_x = curium_ratio.cr_sigma_x;
                            cr.cev.lower_mass_limit = curium_ratio.cr_lower_mass_limit;
                            cr.cev.upper_mass_limit = curium_ratio.cr_upper_mass_limit;
                            am.AddMethod(AnalysisMethod.CuriumRatio, cr);
                            break;
                        case INCC.METHOD_ADDASRC:
                            add_a_source_rec add_a_source = (add_a_source_rec)miter2.Current;
                            INCCAnalysisParams.add_a_source_rec aas = new INCCAnalysisParams.add_a_source_rec();
                            aas.cev.a = add_a_source.ad_a; aas.cev.b = add_a_source.ad_b;
                            aas.cev.c = add_a_source.ad_c; aas.cev.d = add_a_source.ad_d;
                            aas.cev.var_a = add_a_source.ad_var_a; aas.cev.var_b = add_a_source.ad_var_b;
                            aas.cev.var_c = add_a_source.ad_var_c; aas.cev.var_d = add_a_source.ad_var_d;
                            aas.cev.setcovar(Coeff.a,Coeff.b,add_a_source.ad_covar_ab);
                            aas.cev._covar[0, 2] = add_a_source.ad_covar_ac;
                            aas.cev._covar[0, 3] = add_a_source.ad_covar_ad;
                            aas.cev._covar[1, 2] = add_a_source.ad_covar_bc;
                            aas.cev._covar[1, 3] = add_a_source.ad_covar_bd;
                            aas.cev._covar[2, 3] = add_a_source.ad_covar_cd;
                            aas.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)add_a_source.add_a_source_equation;
                            aas.cev.sigma_x = add_a_source.ad_sigma_x;
                            aas.cev.lower_mass_limit = add_a_source.ad_lower_mass_limit;
                            aas.cev.upper_mass_limit = add_a_source.ad_upper_mass_limit;

                            TransferUtils.Copy(ref aas.dcl_mass, add_a_source.ad_dcl_mass, INCC.MAX_NUM_CALIB_PTS);
                            TransferUtils.Copy(ref aas.doubles, add_a_source.ad_doubles, INCC.MAX_NUM_CALIB_PTS);

                            aas.cf.a = add_a_source.ad_cf_a; aas.cf.b = add_a_source.ad_cf_b;
                            aas.cf.c = add_a_source.ad_cf_c; aas.cf.d = add_a_source.ad_cf_d;
                            aas.dzero_avg = add_a_source.ad_dzero_avg;
                            aas.num_runs = add_a_source.ad_num_runs;
                            aas.tm_dbls_rate_upper_limit = add_a_source.ad_tm_dbls_rate_upper_limit;
                            aas.tm_weighting_factor = add_a_source.ad_tm_weighting_factor;
                            aas.use_truncated_mult = (add_a_source.ad_use_truncated_mult == 0 ? false : true);
                            aas.dzero_ref_date = INCC.DateFrom(TransferUtils.str(add_a_source.ad_dzero_ref_date, INCC.DATE_TIME_LENGTH));
                            aas.position_dzero = TransferUtils.Copy(add_a_source.ad_position_dzero, INCC.MAX_ADDASRC_POSITIONS);
                            am.AddMethod(AnalysisMethod.AddASource, aas);
                            break;
                        case INCC.METHOD_ACTIVE:
                            active_rec active = (active_rec)miter2.Current;
                            INCCAnalysisParams.active_rec ar = new INCCAnalysisParams.active_rec();

                            ar.cev.lower_mass_limit = active.act_lower_mass_limit;
                            ar.cev.upper_mass_limit = active.act_upper_mass_limit;
                            TransferUtils.Copy(ref ar.dcl_mass, active.act_dcl_mass, INCC.MAX_NUM_CALIB_PTS);
                            TransferUtils.Copy(ref ar.doubles, active.act_doubles, INCC.MAX_NUM_CALIB_PTS);

                            ar.cev.a = active.act_a; ar.cev.b = active.act_b;
                            ar.cev.c = active.act_c; ar.cev.d = active.act_d;
                            ar.cev.var_a = active.act_var_a; ar.cev.var_b = active.act_var_b;
                            ar.cev.var_c = active.act_var_c; ar.cev.var_d = active.act_var_d;
                            ar.cev.setcovar(Coeff.a,Coeff.b,active.act_covar_ab);
                            ar.cev._covar[0, 2] = active.act_covar_ac;
                            ar.cev._covar[0, 3] = active.act_covar_ad;
                            ar.cev._covar[1, 2] = active.act_covar_bc;
                            ar.cev._covar[1, 3] = active.act_covar_bd;
                            ar.cev._covar[2, 3] = active.act_covar_cd;
                            ar.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)active.active_equation;
                            ar.cev.sigma_x = active.act_sigma_x;
                            am.AddMethod(AnalysisMethod.Active, ar);
                            break;
                        case INCC.METHOD_ACTPAS:
                            active_passive_rec active_passive = (active_passive_rec)miter2.Current;
                            INCCAnalysisParams.active_passive_rec apr = new INCCAnalysisParams.active_passive_rec();
                            apr.cev.lower_mass_limit = active_passive.ap_lower_mass_limit;
                            apr.cev.upper_mass_limit = active_passive.ap_upper_mass_limit;

                            apr.cev.a = active_passive.ap_a; apr.cev.b = active_passive.ap_b;
                            apr.cev.c = active_passive.ap_c; apr.cev.d = active_passive.ap_d;
                            apr.cev.var_a = active_passive.ap_var_a; apr.cev.var_b = active_passive.ap_var_b;
                            apr.cev.var_c = active_passive.ap_var_c; apr.cev.var_d = active_passive.ap_var_d;
                            apr.cev.setcovar(Coeff.a,Coeff.b,active_passive.ap_covar_ab);
                            apr.cev._covar[0, 2] = active_passive.ap_covar_ac;
                            apr.cev._covar[0, 3] = active_passive.ap_covar_ad;
                            apr.cev._covar[1, 2] = active_passive.ap_covar_bc;
                            apr.cev._covar[1, 3] = active_passive.ap_covar_bd;
                            apr.cev._covar[2, 3] = active_passive.ap_covar_cd;
                            apr.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)active_passive.active_passive_equation;
                            apr.cev.sigma_x = active_passive.ap_sigma_x;
                            am.AddMethod(AnalysisMethod.ActivePassive, apr);
                            break;
                        case INCC.COLLAR_SAVE_RESTORE:
             							mlogger.TraceEvent(LogLevels.Verbose, 34213, " Collar params entry for COLLAR_SAVE_RESTORE");
                            break;
                        case INCC.COLLAR_DETECTOR_SAVE_RESTORE:
             							mlogger.TraceEvent(LogLevels.Verbose, 34212, " Main entry for COLLAR_DETECTOR_SAVE_RESTORE");
                            break;
                        case INCC.COLLAR_K5_SAVE_RESTORE:
             							mlogger.TraceEvent(LogLevels.Verbose, 34214, " K5 entry for COLLAR_K5_SAVE_RESTORE");
                            collar_k5_rec collar_k5 = (collar_k5_rec)miter2.Current;
                            INCCAnalysisParams.collar_combined_rec combined = CollarEntryProcesser(idcf, sel, collar_k5.collar_k5_mode);
                            if (combined != null)
                                am.AddMethod(AnalysisMethod.Collar, combined);
                            break;
                        case INCC.METHOD_ACTIVE_MULT:
                            active_mult_rec active_mult = (active_mult_rec)miter2.Current;
                            INCCAnalysisParams.active_mult_rec acm = new INCCAnalysisParams.active_mult_rec();
                            acm.vf1 = active_mult.am_vf1;
                            acm.vf2 = active_mult.am_vf2;
                            acm.vf3 = active_mult.am_vf3;
                            acm.vt1 = active_mult.am_vt1;
                            acm.vt2 = active_mult.am_vt2;
                            acm.vt3 = active_mult.am_vt2;
                            am.AddMethod(AnalysisMethod.ActiveMultiplicity, acm);
                            break;
                        case INCC.WMV_CALIB_TOKEN:
                            mlogger.TraceEvent(LogLevels.Warning, 34247, "Skipping calib token");  // todo: weighted multiplicity not fully implemented throughout
                            break;
                    }
                }
            }
        }
示例#33
0
        /// <summary>
        /// Prepare measurement instance content for analysis
        /// Populate calibration and counting parameters maps
        /// Create general results and specific results dictionary map entries
        /// Set up stratum details
        /// </summary>
        /// <param name="meas">The partially initialized measurement instance</param>
        /// <param name="useCurCalibParams">Default behavior is to use active method and other calibration parameters;
        ///                                 skipped if Reanalysis prepared the details from database measurement results
        /// </param>
        static public void FillInMeasurementDetails(Measurement meas, bool useCurCalibParams = true)
        {
            if (meas.Detector.ListMode)
            {
                // APluralityOfMultiplicityAnalyzers: see below
                // URGENT: see below
                //if (an INCC5 DB cycle read or DB Ver reanalysis then rebuild the analyzers from the associated saved LM results:)
                //	object x = CentralizedState.App.DB.GetAnalyzersFromResults(meas.Detector, meas.MeasurementId);
                //else
                meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(meas.Detector, applySRFromDetector: true);
                if (meas.MeasOption.IsListMode()) // pure List Mode, not INCC5
                {
                    // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params
                    ApplyVSRChangesToDefaultDetector(meas);
                }
                else // it is an INCC5 analysis driven with LM data
                {
                    // prepare or identify an active CA entry with matching CA gatewidth and FA, and has the same SR params as the detector
                    if (meas.AnalysisParams.PrepareMatchingVSR(meas.Detector.MultiplicityParams))
                    {
                        CentralizedState.App.LMBD.UpdateCounters(meas.Detector.Id.DetectorName, meas.AnalysisParams); // added one, save it
                    }
                }
            }
            else // construct param key source with the single mkey entry point
            {
                // prepare analyzer params from detector SR params
                meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(meas.Detector, applySRFromDetector: false);
                if (!meas.AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(meas.Detector.MultiplicityParams)); }))
                {
                    meas.AnalysisParams.Add(meas.Detector.MultiplicityParams);
                }
            }

            // get the current INCC5 analysis methods
            if (useCurCalibParams || meas.INCCAnalysisState == null)
            {
                meas.INCCAnalysisState = new INCCAnalysisState();
                INCCSelector    sel = new INCCSelector(meas.AcquireState.detector_id, meas.AcquireState.item_type);
                AnalysisMethods am;
                bool            found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
                if (found)
                {
                    am.selector = sel;                     // gotta do this so that the equality operator is not incorrect
                    meas.INCCAnalysisState.Methods = am;
                }
                else
                {
                    meas.INCCAnalysisState.Methods = new AnalysisMethods(sel);
                }
            }             // else use what was there

            meas.InitializeContext(clearCounterResults: true);
            meas.PrepareINCCResults();

            // stratum look up, finds existing stratum by name
            if (useCurCalibParams || meas.Stratum == null)
            {
                List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();
                INCCDB.StratumDescriptor        s  = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0);
                if (s == null)
                {
                    meas.Stratum = new Stratum();
                }
                else
                {
                    meas.Stratum = new Stratum(s.Stratum);
                }
            }
            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec  = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state
        }
示例#34
0
        public unsafe bool BuildMeasurement(INCCTransferFile itf, int num)
        {
            bool overwrite = NC.App.AppContext.OverwriteImportedDefs;
            results_rec results = itf.results_rec_list[0];
            meas_id id;

            TransferUtils.Copy(results.meas_date, 0, id.meas_date, 0, INCC.DATE_TIME_LENGTH);
            TransferUtils.Copy(results.meas_time, 0, id.meas_time, 0, INCC.DATE_TIME_LENGTH);
            TransferUtils.Copy(results.filename, 0, id.filename, 0, INCC.FILE_NAME_LENGTH);
            TransferUtils.Copy(results.results_detector_id, 0, id.results_detector_id, 0, INCC.MAX_DETECTOR_ID_LENGTH);
            DateTime dt = INCC.DateTimeFrom(TransferUtils.str(id.meas_date, INCC.DATE_TIME_LENGTH), TransferUtils.str(id.meas_time, INCC.DATE_TIME_LENGTH));

            // do not use content from last BuildDetector call, instead look up the detector on the pre-existing list
            string detname = TransferUtils.str(id.results_detector_id, INCC.MAX_DETECTOR_ID_LENGTH);
            Detector det = NC.App.DB.Detectors.GetItByDetectorId(detname);
            if (det == null)
            {
                mlogger.TraceEvent(LogLevels.Error, 34087, "Unknown detector '{0}', not importing this measurement {1}", detname, dt.ToString("s"));
                return false;
            }

            meas = new Measurement((AssaySelector.MeasurementOption)results.meas_option, mlogger);

            // TODO: update detector details from this meas result, since there could be a difference
            meas.MeasurementId.MeasDateTime = dt;
            meas.MeasurementId.FileName = TransferUtils.str(id.filename, INCC.FILE_NAME_LENGTH);

            meas.Detectors.Add(det);  // in practice this is a list with one element, e.g. meas.Detector

            TestParameters t = new TestParameters();
            t.accSnglTestRateLimit = results.r_acc_sngl_test_rate_limit;
            t.accSnglTestPrecisionLimit = results.r_acc_sngl_test_precision_limit;
            t.accSnglTestOutlierLimit = results.r_acc_sngl_test_outlier_limit;
            t.outlierTestLimit = results.r_outlier_test_limit;
            t.bkgDoublesRateLimit = results.r_bkg_doubles_rate_limit;
            t.bkgTriplesRateLimit = results.r_bkg_triples_rate_limit;
            t.chiSquaredLimit = results.r_chisq_limit;
            t.maxNumFailures = results.r_max_num_failures;
            t.highVoltageTestLimit = results.r_high_voltage_test_limit;
            t.normalBackupAssayTestLimit = results.r_normal_backup_assay_test_lim;
            t.maxCyclesForOutlierTest = (uint)results.r_max_runs_for_outlier_test;
            t.checksum = (results.r_checksum_test == 0.0 ? false : true);
            t.accidentalsMethod = INCCAccidentalsMethod((int)results.results_accidentals_method);
            meas.Tests.Copy(t);

            NormParameters n = NC.App.DB.NormParameters.Get(detname);
            meas.Norm.Copy(n);
            BackgroundParameters b = NC.App.DB.BackgroundParameters.Get(detname);
            meas.Background.Copy(b);
            // DB write for these occurs at end of processing here

            // Isotopics handled in this block
            if (itf.isotopics_table.Count > 0)
            {
                string isoname = TransferUtils.str(results.item_isotopics_id, INCC.MAX_ISOTOPICS_ID_LENGTH);
                NCCTransfer.isotopics_rec isotopics = itf.isotopics_table[0];
                //bool first = true; // forgot why the code does this, to put the default in the map?
                // foreach (LMTransfer.isotopics_rec ir in itf.istopics_table)
                // {
                AnalysisDefs.Isotopics iso;
                //       if (first)
                iso = meas.Isotopics;
                //        else
                //            iso = new Isotopics();
                //         first = false;
                iso.am_date = INCC.DateFrom(TransferUtils.str(isotopics.am_date, INCC.DATE_TIME_LENGTH));
                iso.pu_date = INCC.DateFrom(TransferUtils.str(isotopics.pu_date, INCC.DATE_TIME_LENGTH));
                iso.id = TransferUtils.str(isotopics.isotopics_id, INCC.MAX_ISOTOPICS_ID_LENGTH);
                AnalysisDefs.Isotopics.SourceCode checksc = AnalysisDefs.Isotopics.SourceCode.OD;
                string check = TransferUtils.str(isotopics.isotopics_source_code, INCC.ISO_SOURCE_CODE_LENGTH);
                bool okparse = Enum.TryParse(check, true, out checksc);
                iso.source_code = checksc;
                iso.SetValueError(Isotope.am241, isotopics.am241, isotopics.am241_err);
                iso.SetValueError(Isotope.pu238, isotopics.pu238, isotopics.pu238_err);
                iso.SetValueError(Isotope.pu239, isotopics.pu239, isotopics.pu239_err);
                iso.SetValueError(Isotope.pu240, isotopics.pu240, isotopics.pu240_err);
                iso.SetValueError(Isotope.pu241, isotopics.pu241, isotopics.pu241_err);
                iso.SetValueError(Isotope.pu242, isotopics.pu242, isotopics.pu242_err);

                if (!NC.App.DB.Isotopics.Has(iso.id))
                {
                    NC.App.DB.Isotopics.GetList().Add(iso);
                    mlogger.TraceEvent(LogLevels.Info, 34021, "Identified new isotopics {0}", iso.id);
                }
                else
                {
                    if (overwrite)
                    {
                        NC.App.DB.Isotopics.Replace(iso);
                        mlogger.TraceEvent(LogLevels.Warning, 34022, "Replaced existing isotopics {0}", iso.id);
                    }
                    else
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34022, "Not replacing existing isotopics {0}", iso.id);
                    }
                }
                iso.modified = true;
            }

            AcquireParameters acq = meas.AcquireState;
            acq.detector_id = det.Id.DetectorId;
            acq.meas_detector_id = string.Copy(det.Id.DetectorId);  // probably incorrect usage, but differnce is ambiguous in INCC5
            acq.item_type = TransferUtils.str(results.results_item_type, INCC.MAX_ITEM_TYPE_LENGTH);
            acq.qc_tests = TransferUtils.ByteBool(results.results_qc_tests);
            acq.user_id = TransferUtils.str(results.user_id, INCC.CHAR_FIELD_LENGTH);
            acq.num_runs = results.total_number_runs;
            if (results.number_good_runs > 0)
                acq.run_count_time = results.total_good_count_time / results.number_good_runs;
            else
                acq.run_count_time = results.total_good_count_time; // should be 0.0 by default for this special case
            acq.MeasDateTime = meas.MeasurementId.MeasDateTime;
            acq.error_calc_method = INCCErrorCalculationTechnique(results.error_calc_method);
            acq.campaign_id = TransferUtils.str(results.results_campaign_id, INCC.MAX_CAMPAIGN_ID_LENGTH);
            if (string.IsNullOrEmpty(acq.campaign_id))
                acq.campaign_id = TransferUtils.str(results.results_inspection_number, INCC.MAX_CAMPAIGN_ID_LENGTH);
            acq.comment = TransferUtils.str(results.comment, INCC.MAX_COMMENT_LENGTH);//"Original file name " + meas.MeasurementId.FileName;
            string ending_comment_str = TransferUtils.str(results.ending_comment, INCC.MAX_COMMENT_LENGTH);
            acq.ending_comment = !string.IsNullOrEmpty(acq.ending_comment_str);

            acq.data_src = (ConstructedSource)results.data_source;
            acq.well_config = (WellConfiguration)results.well_config;
            acq.print = TransferUtils.ByteBool(results.results_print);

            mlogger.TraceEvent(LogLevels.Verbose, 34000, "Building {0} measurement {1} '{2},{3}' from {2}", meas.MeasOption.PrintName(), num, acq.detector_id, acq.item_type, itf.Path);

            if (itf.facility_table.Count > 0)
                meas.AcquireState.facility = new INCCDB.Descriptor(string.Copy(itf.facility_table[0].id), string.Copy(itf.facility_table[0].desc));
            if (itf.mba_table.Count > 0)
                meas.AcquireState.mba = new INCCDB.Descriptor(string.Copy(itf.mba_table[0].id), string.Copy(itf.mba_table[0].desc));
            if (itf.stratum_id_names_rec_table.Count > 0)
                meas.AcquireState.stratum_id = new INCCDB.Descriptor(string.Copy(itf.stratum_id_names_rec_table[0].id), string.Copy(itf.stratum_id_names_rec_table[0].desc));

            // stratum values
            meas.Stratum = new Stratum();
            meas.Stratum.bias_uncertainty = results.bias_uncertainty;
            meas.Stratum.random_uncertainty = results.random_uncertainty;
            meas.Stratum.relative_std_dev = results.relative_std_dev;
            meas.Stratum.systematic_uncertainty = results.systematic_uncertainty;

            INCCDB.Descriptor mtdesc = new INCCDB.Descriptor(string.Copy(acq.item_type), string.Empty);
            if (!NC.App.DB.Materials.Has(mtdesc) || overwrite)
            {
                NC.App.DB.Materials.Update(mtdesc);
            }

            // prepare norm parms, should be done with a prior pass with the detector file, then this code looks it up in the collection set at this point in the processing
            meas.Norm.currNormalizationConstant.v = results.normalization_constant;
            meas.Norm.currNormalizationConstant.err = results.normalization_constant_err;

            foreach (DescriptorPair dp in itf.facility_table)
            {
                INCCDB.Descriptor idesc = new INCCDB.Descriptor(string.Copy(dp.id), string.Copy(dp.desc));
                if (!NC.App.DB.Facilities.Has(idesc) || overwrite)
                {
                    idesc.modified = true;
                    NC.App.DB.Facilities.Update(idesc);
                }
            }
            foreach (DescriptorPair dp in itf.mba_table)
            {
                INCCDB.Descriptor idesc = new INCCDB.Descriptor(string.Copy(dp.id), string.Copy(dp.desc));
                if (!NC.App.DB.MBAs.Has(idesc) || overwrite)
                {
                    idesc.modified = true;
                    NC.App.DB.MBAs.Update(idesc);
                }
            }
            foreach (DescriptorPair dp in itf.stratum_id_names_rec_table)
            {
                INCCDB.Descriptor idesc = new INCCDB.Descriptor(string.Copy(dp.id), string.Copy(dp.desc));
                if (meas.Stratum != null)
                {
                   idesc.modified = true;
                   NC.App.DB.UpdateStratum(idesc, meas.Stratum);  // creates it
                   NC.App.DB.AssociateStratum(det, idesc, meas.Stratum); // associates it with the detector
                }
            }

            if (itf.item_id_table.Count > 0)  // devnote: there should be only one item entry
            {
                ItemId item = new ItemId();
                item.declaredMass = results.declared_mass;
                item.declaredUMass = results.declared_u_mass;
                item.length = results.length;
                item.IOCode = TransferUtils.str(results.io_code, INCC.IO_CODE_LENGTH);
                item.inventoryChangeCode = TransferUtils.str(results.inventory_change_code, INCC.INVENTORY_CHG_LENGTH);
                item.isotopics = TransferUtils.str(results.item_isotopics_id, INCC.MAX_ISOTOPICS_ID_LENGTH);
                item.stratum = TransferUtils.str(results.stratum_id, INCC.MAX_STRATUM_ID_LENGTH);
                item.item = TransferUtils.str(results.item_id, INCC.MAX_ITEM_ID_LENGTH);
                item.material = TransferUtils.str(results.results_item_type, INCC.MAX_ITEM_TYPE_LENGTH);
                //copy measurement dates to item
                item.pu_date = new DateTime(meas.Isotopics.pu_date.Ticks);
                item.am_date = new DateTime(meas.Isotopics.am_date.Ticks);
                item.modified = true;

                List<ItemId> list = NC.App.DB.ItemIds.GetList();
                bool flump = list.Exists(i => { return string.Compare(item.item, i.item, true) == 0; });
                if (flump && overwrite)
                {
                    list.Remove(item);
                    list.Add(item);
                }
                else
                    list.Add(item);

                // fill in the acquire record from the item id
                acq.ApplyItemId(item);

                meas.MeasurementId.Item = new ItemId(item);
            }

            meas.INCCAnalysisState = new INCCAnalysisState();

            INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
            AnalysisMethods am;
            bool found = NC.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
            if (found)
            {
                meas.INCCAnalysisState.Methods = am;
                meas.INCCAnalysisState.Methods.selector = sel;
            }
            else
            {
                mlogger.TraceEvent(LogLevels.Error, 34063, "No analysis methods for {0}, (calibration information is missing), creating placeholders", sel.ToString()); // devnote: can get missing paramters from the meas results for calib and verif below, so need to visit this condition after results processing below (newres.methodParams!) and reconstruct the calib parameters.
                meas.INCCAnalysisState.Methods = new AnalysisMethods(mlogger);
                meas.INCCAnalysisState.Methods.selector = sel;
            }
            // prepare analyzer params from sr params above
            meas.AnalysisParams = new AnalysisDefs.CountingAnalysisParameters();
            meas.AnalysisParams.Add(det.MultiplicityParams);

            mlogger.TraceEvent(LogLevels.Verbose, 34030, "Transferring the {0} cycles", itf.run_rec_list.Count);
            meas.InitializeContext();
            meas.PrepareINCCResults(); // prepares INCCResults objects
            ulong MaxBins = 0;
            foreach (run_rec r in itf.run_rec_list)
            {
                ulong x= AddToCycleList(r, det);
                if (x > MaxBins)
                    MaxBins = x;
            }
            for (int cf = 1; (itf.CFrun_rec_list != null) && (cf < itf.CFrun_rec_list.Length); cf++)
            {
                foreach (run_rec r in itf.CFrun_rec_list[cf])
                {
                    AddToCycleList(r, det, cf);
                }
            }

            // summarize the result in the result, if you know what I mean
            MultiplicityCountingRes mcr = (MultiplicityCountingRes)meas.CountingAnalysisResults[det.MultiplicityParams];
            for (int i = 0; i < 9; i++)
                mcr.covariance_matrix[i] = results.covariance_matrix[i];
            mcr.DeadtimeCorrectedRates.Singles.err = results.singles_err;
            mcr.DeadtimeCorrectedRates.Doubles.err = results.doubles_err;
            mcr.DeadtimeCorrectedRates.Triples.err = results.triples_err;
            mcr.DeadtimeCorrectedRates.Singles.v = results.singles;
            mcr.DeadtimeCorrectedRates.Doubles.v = results.doubles;
            mcr.DeadtimeCorrectedRates.Triples.v = results.triples;
            mcr.Scaler1Rate.v = results.scaler1;
            mcr.Scaler2Rate.v = results.scaler2;
            mcr.Scaler1Rate.err = results.scaler1_err;
            mcr.Scaler2Rate.err = results.scaler2_err;
            mcr.Scaler1.v = results.scaler1;
            mcr.Scaler2.v = results.scaler2;
            mcr.Scaler1.err = results.scaler1_err;
            mcr.Scaler2.err = results.scaler2_err;
            mcr.ASum = results.acc_sum;
            mcr.RASum = results.reals_plus_acc_sum;
            mcr.S1Sum = results.scaler1_sum;
            mcr.S2Sum = results.scaler2_sum;
            mcr.mass = results.declared_mass;
            mcr.FA = det.MultiplicityParams.FA;
            mcr.RAMult = TransferUtils.multarrayxfer(results.mult_reals_plus_acc_sum, INCC.MULTI_ARRAY_SIZE);
            mcr.NormedAMult = TransferUtils.multarrayxfer(results.mult_acc_sum, INCC.MULTI_ARRAY_SIZE);
            mcr.MaxBins = (ulong)Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length);
            mcr.MinBins = (ulong)Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length);
            mcr.RawDoublesRate.v = results.uncorrected_doubles;
            mcr.RawDoublesRate.err = results.uncorrected_doubles_err;
            mcr.singles_multi = results.singles_multi;
            mcr.doubles_multi = results.doubles_multi;
            mcr.triples_multi = results.triples_multi;

            INCCResult result;
            MeasOptionSelector mos = new MeasOptionSelector(meas.MeasOption, det.MultiplicityParams);
            result = meas.INCCAnalysisState.Lookup(mos);
            result.DeadtimeCorrectedRates.Singles.err = results.singles_err;
            result.DeadtimeCorrectedRates.Doubles.err = results.doubles_err;
            result.DeadtimeCorrectedRates.Triples.err = results.triples_err;
            result.DeadtimeCorrectedRates.Singles.v = results.singles;
            result.DeadtimeCorrectedRates.Doubles.v = results.doubles;
            result.DeadtimeCorrectedRates.Triples.v = results.triples;
            result.rates.RawRates.Scaler1s.v = results.scaler1;
            result.rates.RawRates.Scaler2s.v = results.scaler2;
            result.rates.RawRates.Scaler1s.err = results.scaler1_err;
            result.rates.RawRates.Scaler2s.err = results.scaler2_err;
            result.S1Sum = results.scaler1_sum;
            result.S2Sum = results.scaler2_sum;
            result.ASum = results.acc_sum;
            result.RASum = results.reals_plus_acc_sum;
            result.RAMult = TransferUtils.multarrayxfer(results.mult_reals_plus_acc_sum, INCC.MULTI_ARRAY_SIZE);
            result.NormedAMult = TransferUtils.multarrayxfer(results.mult_acc_sum, INCC.MULTI_ARRAY_SIZE);
            result.MaxBins = (ulong)Math.Max(result.RAMult.Length, result.NormedAMult.Length);
            result.MinBins = (ulong)Math.Min(result.RAMult.Length, result.NormedAMult.Length);
            mcr.RawDoublesRate.v = results.uncorrected_doubles;
            mcr.RawDoublesRate.err = results.uncorrected_doubles_err;
            result.singles_multi = results.singles_multi;
            result.doubles_multi = results.doubles_multi;
            result.triples_multi = results.triples_multi;

            // hack expansion of Normed mult array to same length as Acc mult array on each cycle to accomodate TheoreticalOutlier calc array length bug
            ExpandMaxBins(MaxBins, meas.Cycles, det.MultiplicityParams);
            Bloat(MaxBins, mcr);

            List<MeasurementMsg> msgs = meas.GetMessageList(det.MultiplicityParams);

            // move the error messages
            for (int i = 0; i < INCC.NUM_ERROR_MSG_CODES; i++)
            {
                int index = i * INCC.ERR_MSG_LENGTH;
                string e = TransferUtils.str(results.error_msg_codes + index, INCC.ERR_MSG_LENGTH);
                if (e.Length > 0)
                    meas.AddMessage(msgs, LogLevels.Error, 911, e, meas.MeasurementId.MeasDateTime);
            }
            // move the warning messages
            for (int i = 0; i < INCC.NUM_WARNING_MSG_CODES; i++)
            {
                int index = i * INCC.ERR_MSG_LENGTH;
                string w = TransferUtils.str(results.warning_msg_codes + index, INCC.ERR_MSG_LENGTH);
                if (w.Length > 0)
                    meas.AddMessage(msgs, LogLevels.Warning, 411, w, meas.MeasurementId.MeasDateTime);
            }

            #region results transfer
            INCCMethodResults imr;
            bool got = meas.INCCAnalysisResults.TryGetINCCResults(det.MultiplicityParams, out imr); // only ever this single mkey for INCC5-style transfer import, (thankfully)
            if (got)
                imr.primaryMethod = OldToNewMethodId(results.primary_analysis_method);
            // check these results against the meas.MeasOption expectation => seems to always be 1 - 1 with (opt, sr) -> results, and subresults only for verif and calib choice
            //         rates -> none,
            //         bkg -> bkg, norm -> bias, init src -> init src, prec ->  prec,
            //         calib -> calib, 1 or more INCC methods on the methods submap
            //         verif -> 1 or more INCC methods on the methods submap
            foreach (iresultsbase r in itf.method_results_list)
            {
                if (r is results_init_src_rec)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 34041, ("Transferring initial source results"));

                    results_init_src_rec oldres = (results_init_src_rec)r;

                    INCCResults.results_init_src_rec newres = (INCCResults.results_init_src_rec)
                    meas.INCCAnalysisState.Lookup(new MeasOptionSelector(meas.MeasOption, det.MultiplicityParams), typeof(INCCResults.results_init_src_rec));

                    newres.mode = OldToNewBiasTestId(oldres.init_src_mode);
                    newres.pass = TransferUtils.PassCheck(oldres.init_src_pass_fail);
                    newres.init_src_id = TransferUtils.str(oldres.init_src_id, INCC.SOURCE_ID_LENGTH);
                }
                else if (r is results_bias_rec)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 34042, ("Transferring normalization results"));

                    results_bias_rec oldres = (results_bias_rec)r;
                    INCCResults.results_bias_rec newres = (INCCResults.results_bias_rec)meas.INCCAnalysisState.Lookup(new MeasOptionSelector(meas.MeasOption, det.MultiplicityParams), typeof(INCCResults.results_bias_rec));

                    newres.pass = TransferUtils.PassCheck(oldres.bias_pass_fail);
                    newres.biasDblsRateExpect.v = oldres.bias_dbls_rate_expect;
                    newres.biasDblsRateExpectMeas.v = oldres.bias_dbls_rate_expect_meas;
                    newres.biasSnglsRateExpect.v = oldres.bias_sngls_rate_expect;
                    newres.biasSnglsRateExpectMeas.v = oldres.bias_sngls_rate_expect_meas;
                    newres.biasDblsRateExpect.err = oldres.bias_dbls_rate_expect_err;
                    newres.biasDblsRateExpectMeas.err = oldres.bias_dbls_rate_expect_meas_err;
                    newres.biasSnglsRateExpect.err = oldres.bias_sngls_rate_expect_err;
                    newres.biasSnglsRateExpectMeas.err = oldres.bias_sngls_rate_expect_meas_err;
                    newres.newNormConstant.v = oldres.new_norm_constant;
                    newres.newNormConstant.err = oldres.new_norm_constant_err;
                    newres.measPrecision = oldres.meas_precision;
                    newres.requiredMeasSeconds = oldres.required_meas_seconds;
                    newres.requiredPrecision = oldres.required_precision;
                    newres.mode = OldToNewBiasTestId(oldres.results_bias_mode);
                    newres.sourceId = TransferUtils.str(oldres.bias_source_id, INCC.SOURCE_ID_LENGTH);
                      // NEXT: for init src and bias, results norm values transferred to meas.norm

                }
                else if (r is results_precision_rec)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 34043, ("Transferring precision results"));

                    results_precision_rec oldres = (results_precision_rec)r;
                    INCCResults.results_precision_rec newres =
                        (INCCResults.results_precision_rec)meas.INCCAnalysisState.Lookup(new MeasOptionSelector(meas.MeasOption, det.MultiplicityParams), typeof(INCCResults.results_precision_rec));

                    newres.chiSqLowerLimit = oldres.chi_sq_lower_limit;
                    newres.chiSqUpperLimit = oldres.chi_sq_upper_limit;
                    newres.precChiSq = oldres.prec_chi_sq;
                    newres.precSampleVar = oldres.prec_sample_var;
                    newres.precTheoreticalVar = oldres.prec_theoretical_var;
                    newres.pass = TransferUtils.PassCheck(oldres.prec_pass_fail);
                }
                else
                {
                    if (r is results_cal_curve_rec)
                    {
                        // need to look up in existing map and see if it is there and then create and load it if not
                        mlogger.TraceEvent(LogLevels.Verbose, 34050, ("Transferring method results for " + r.GetType().ToString()));
                        results_cal_curve_rec oldres = (results_cal_curve_rec)r;
                        INCCMethodResults.results_cal_curve_rec newres =
                            (INCCMethodResults.results_cal_curve_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.CalibrationCurve, true);

                        newres.pu240e_mass = new Tuple(oldres.cc_pu240e_mass, oldres.cc_pu240e_mass_err);
                        newres.pu_mass = new Tuple(oldres.cc_pu_mass, oldres.cc_pu_mass_err);
                        newres.dcl_pu240e_mass = oldres.cc_dcl_pu240e_mass;
                        newres.dcl_pu_mass = oldres.cc_dcl_pu_mass;
                        newres.dcl_minus_asy_pu_mass = new Tuple(oldres.cc_dcl_minus_asy_pu_mass, oldres.cc_dcl_minus_asy_pu_mass_err);
                        newres.dcl_minus_asy_pu_mass_pct = oldres.cc_dcl_minus_asy_pu_mass_pct;
                        newres.pass = TransferUtils.PassCheck(oldres.cc_pass_fail);
                        newres.dcl_u_mass = oldres.cc_dcl_u_mass;
                        newres.length = oldres.cc_length;
                        newres.heavy_metal_content = oldres.cc_heavy_metal_content;
                        newres.heavy_metal_correction = oldres.cc_heavy_metal_correction;
                        newres.heavy_metal_corr_singles = new Tuple(oldres.cc_heavy_metal_corr_singles, oldres.cc_heavy_metal_corr_singles_err);
                        newres.heavy_metal_corr_doubles = new Tuple(oldres.cc_heavy_metal_corr_doubles, oldres.cc_heavy_metal_corr_doubles_err);
                        newres.methodParams.heavy_metal_corr_factor = oldres.cc_heavy_metal_corr_factor_res;
                        newres.methodParams.heavy_metal_reference = oldres.cc_heavy_metal_reference_res;
                        // newres.methodParams.cev.lower_mass_limit = oldres.cc_lower_mass_limit_res;
                        // newres.methodParams.cev.upper_mass_limit = oldres.cc_upper_mass_limit_res;
                        newres.methodParams.percent_u235 = oldres.cc_percent_u235_res;

                        newres.methodParams.cev.a = oldres.cc_a_res; newres.methodParams.cev.b = oldres.cc_b_res;
                        newres.methodParams.cev.c = oldres.cc_c_res; newres.methodParams.cev.d = oldres.cc_d_res;
                        newres.methodParams.cev.var_a = oldres.cc_var_a_res; newres.methodParams.cev.var_b = oldres.cc_var_b_res;
                        newres.methodParams.cev.var_c = oldres.cc_var_c_res; newres.methodParams.cev.var_d = oldres.cc_var_d_res;
                        newres.methodParams.cev.setcovar(Coeff.a,Coeff.b,oldres.cc_covar_ab_res);
                        newres.methodParams.cev._covar[0, 2] = oldres.cc_covar_ac_res;
                        newres.methodParams.cev._covar[0, 3] = oldres.cc_covar_ad_res;
                        newres.methodParams.cev._covar[1, 2] = oldres.cc_covar_bc_res;
                        newres.methodParams.cev._covar[1, 3] = oldres.cc_covar_bd_res;
                        newres.methodParams.cev._covar[2, 3] = oldres.cc_covar_cd_res;
                        newres.methodParams.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.cc_cal_curve_equation;
                        newres.methodParams.CalCurveType = (INCCAnalysisParams.CalCurveType)oldres.cc_cal_curve_type_res;
                        newres.methodParams.cev.sigma_x = oldres.cc_sigma_x_res;
                    }
                    else if (r is results_known_alpha_rec)
                    {
                        //  need to look up in existing map and see if it is there and then create and load it if not
                        mlogger.TraceEvent(LogLevels.Verbose, 34051, ("Transferring method results for " + r.GetType().ToString()));
                        results_known_alpha_rec oldres = (results_known_alpha_rec)r;
                        INCCMethodResults.results_known_alpha_rec newres =
                            (INCCMethodResults.results_known_alpha_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownA, true);
                        newres.corr_doubles.v = oldres.ka_corr_doubles;
                        newres.corr_doubles.err = oldres.ka_corr_doubles_err;
                        newres.mult = oldres.ka_mult;
                        newres.alphaK = oldres.ka_alpha;
                        newres.mult_corr_doubles = new Tuple(oldres.ka_mult_corr_doubles, oldres.ka_mult_corr_doubles_err);
                        newres.pu240e_mass = new Tuple(oldres.ka_pu240e_mass, oldres.ka_pu240e_mass_err);
                        newres.pu_mass = new Tuple(oldres.ka_pu_mass, oldres.ka_pu_mass_err);
                        newres.dcl_pu240e_mass = oldres.ka_dcl_pu240e_mass;
                        newres.dcl_pu_mass = oldres.ka_dcl_pu_mass;
                        newres.dcl_minus_asy_pu_mass = new Tuple(oldres.ka_dcl_minus_asy_pu_mass, oldres.ka_dcl_minus_asy_pu_mass_err);
                        newres.dcl_minus_asy_pu_mass_pct = oldres.ka_dcl_minus_asy_pu_mass_pct;
                        newres.pass = TransferUtils.PassCheck(oldres.ka_pass_fail);
                        newres.dcl_u_mass = oldres.ka_dcl_u_mass;
                        newres.length = oldres.ka_length;
                        newres.heavy_metal_content = oldres.ka_heavy_metal_content;
                        newres.heavy_metal_correction = oldres.ka_heavy_metal_correction;
                        newres.corr_singles = new Tuple(oldres.ka_corr_singles, oldres.ka_corr_singles_err);
                        newres.corr_doubles = new Tuple(oldres.ka_corr_doubles, oldres.ka_corr_doubles_err);
                        newres.corr_factor = oldres.ka_corr_factor;
                        newres.dry_alpha_or_mult_dbls = oldres.ka_dry_alpha_or_mult_dbls;
                        newres.upper_corr_factor_limit = oldres.ka_upper_corr_factor_limit_res;
                        newres.lower_corr_factor_limit = oldres.ka_lower_corr_factor_limit_res;

                        newres.methodParams = new INCCAnalysisParams.known_alpha_rec();
                        newres.methodParams.alpha_wt = oldres.ka_alpha_wt_res;
                        newres.methodParams.heavy_metal_corr_factor = oldres.ka_heavy_metal_corr_factor_res;
                        newres.methodParams.heavy_metal_reference = oldres.ka_heavy_metal_reference_res;
                        newres.methodParams.k = oldres.ka_k_res;
                        newres.methodParams.known_alpha_type = (INCCAnalysisParams.KnownAlphaVariant)oldres.ka_known_alpha_type_res;
                        newres.methodParams.lower_corr_factor_limit = oldres.ka_lower_corr_factor_limit_res;
                        newres.methodParams.upper_corr_factor_limit = oldres.ka_upper_corr_factor_limit_res;
                        newres.methodParams.rho_zero = oldres.ka_rho_zero_res;

                        newres.methodParams.ring_ratio.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.ka_ring_ratio_equation_res;
                        newres.methodParams.ring_ratio.a = oldres.ka_ring_ratio_a_res;
                        newres.methodParams.ring_ratio.b = oldres.ka_ring_ratio_b_res;
                        newres.methodParams.ring_ratio.c = oldres.ka_ring_ratio_c_res;
                        newres.methodParams.ring_ratio.d = oldres.ka_ring_ratio_d_res;

                        newres.methodParams.cev.a = oldres.ka_a_res;
                        newres.methodParams.cev.b = oldres.ka_b_res;
                        newres.methodParams.cev.var_a = oldres.ka_var_a_res;
                        newres.methodParams.cev.var_b= oldres.ka_var_b_res;
                        newres.methodParams.cev.sigma_x = oldres.ka_sigma_x_res;
                        newres.methodParams.cev.setcovar(Coeff.a, Coeff.b, oldres.ka_covar_ab_res);
                        newres.methodParams.cev.lower_mass_limit = oldres.ka_lower_corr_factor_limit_res;
                        newres.methodParams.cev.upper_mass_limit = oldres.ka_upper_corr_factor_limit_res;
                    }
                    else if (r is results_multiplicity_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34052, ("Transferring method results for " + r.GetType().ToString()));
                        results_multiplicity_rec oldres = (results_multiplicity_rec)r;
                        INCCMethodResults.results_multiplicity_rec newres =
                            (INCCMethodResults.results_multiplicity_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Multiplicity, true);

                        newres.solve_efficiency_choice = (INCCAnalysisParams.MultChoice)oldres.mul_solve_efficiency_res;
                        newres.pass = TransferUtils.PassCheck(oldres.mul_pass_fail);
                        newres.efficiencyComputed.v = oldres.mul_efficiency; newres.efficiencyComputed.err = oldres.mul_efficiency_err;
                        newres.mult.v = oldres.mul_mult; newres.mult.err = oldres.mul_mult_err;
                        newres.alphaK.v = oldres.mul_alpha; newres.alphaK.err = oldres.mul_alpha_err;
                        newres.corr_factor.v = oldres.mul_corr_factor; newres.corr_factor.err = oldres.mul_corr_factor_err;
                        newres.pu240e_mass.v = oldres.mul_pu240e_mass; newres.pu240e_mass.err = oldres.mul_pu240e_mass_err;
                        newres.pu_mass.v = oldres.mul_pu_mass; newres.pu_mass.err = oldres.mul_pu_mass_err;
                        newres.dcl_minus_asy_pu_mass.v = oldres.mul_dcl_minus_asy_pu_mass; newres.dcl_minus_asy_pu_mass.err = oldres.mul_dcl_minus_asy_pu_mass_err;
                        newres.dcl_pu240e_mass = oldres.mul_dcl_pu240e_mass;
                        newres.dcl_pu_mass = oldres.mul_dcl_pu_mass;
                        newres.dcl_minus_asy_pu_mass_pct = oldres.mul_dcl_minus_asy_pu_mass_pct;

                        newres.methodParams = new INCCAnalysisParams.multiplicity_rec();
                        newres.methodParams.sf_rate = oldres.mul_sf_rate_res;
                        newres.methodParams.vs1 = oldres.mul_vs1_res;
                        newres.methodParams.vs2 = oldres.mul_vs2_res;
                        newres.methodParams.vs3 = oldres.mul_vs3_res;
                        newres.methodParams.vi1 = oldres.mul_vi1_res;
                        newres.methodParams.vi2 = oldres.mul_vi2_res;
                        newres.methodParams.vi3 = oldres.mul_vi3_res;
                        newres.methodParams.a = oldres.mul_a_res;
                        newres.methodParams.b = oldres.mul_b_res;
                        newres.methodParams.c = oldres.mul_b_res;
                        newres.methodParams.sigma_x = oldres.mul_sigma_x_res;
                        newres.methodParams.alpha_weight = oldres.mul_alpha_weight_res;
                        newres.methodParams.multEffCorFactor = oldres.mul_corr_factor;
                    }
                    else if (r is results_truncated_mult_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34053, ("Transferring method results for " + r.GetType().ToString()));
                        results_truncated_mult_rec oldres = (results_truncated_mult_rec)r;
                        INCCMethodResults.results_truncated_mult_rec newres =
                            (INCCMethodResults.results_truncated_mult_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.TruncatedMultiplicity, true);
                        newres.k.pass = TransferUtils.PassCheck(oldres.tm_k_pass_fail);
                        newres.bkg.Singles.v = oldres.tm_bkg_singles;
                        newres.bkg.Singles.err = oldres.tm_bkg_singles_err;
                        newres.bkg.Zeros.v = oldres.tm_bkg_zeros;
                        newres.bkg.Zeros.err = oldres.tm_bkg_zeros_err;
                        newres.bkg.Ones.v = oldres.tm_bkg_ones;
                        newres.bkg.Ones.err = oldres.tm_bkg_ones_err;
                        newres.bkg.Twos.v = oldres.tm_bkg_twos;
                        newres.bkg.Twos.err = oldres.tm_bkg_twos_err;
                        newres.net.Singles.v = oldres.tm_net_singles;
                        newres.net.Singles.err = oldres.tm_net_singles_err;
                        newres.net.Zeros.v = oldres.tm_net_zeros;
                        newres.net.Zeros.err = oldres.tm_net_zeros_err;
                        newres.net.Ones.v = oldres.tm_net_ones;
                        newres.net.Ones.err = oldres.tm_net_ones_err;
                        newres.net.Twos.v = oldres.tm_net_twos;
                        newres.net.Twos.err = oldres.tm_net_twos_err;
                        newres.k.alpha.v = oldres.tm_k_alpha;
                        newres.k.alpha.err = oldres.tm_k_alpha_err;
                        newres.k.pu_mass.v = oldres.tm_k_pu_mass;
                        newres.k.pu_mass.err = oldres.tm_k_pu_mass_err;
                        newres.k.pu240e_mass.v = oldres.tm_k_pu240e_mass;
                        newres.k.pu240e_mass.err = oldres.tm_k_pu240e_mass_err;
                        newres.k.dcl_minus_asy_pu_mass.v = oldres.tm_k_dcl_minus_asy_pu_mass;
                        newres.k.dcl_minus_asy_pu_mass.err = oldres.tm_k_dcl_minus_asy_pu_mass_err;
                        newres.s.alpha.v = oldres.tm_s_alpha;
                        newres.s.alpha.err = oldres.tm_s_alpha_err;
                        newres.s.pu_mass.v = oldres.tm_s_pu_mass;
                        newres.s.pu_mass.err = oldres.tm_s_pu_mass_err;
                        newres.s.pu240e_mass.v = oldres.tm_s_pu240e_mass;
                        newres.s.pu240e_mass.err = oldres.tm_s_pu240e_mass_err;
                        newres.s.dcl_minus_asy_pu_mass.v = oldres.tm_s_dcl_minus_asy_pu_mass;
                        newres.s.dcl_minus_asy_pu_mass.err = oldres.tm_s_dcl_minus_asy_pu_mass_err;
                        newres.methodParams.a = oldres.tm_a_res;
                        newres.methodParams.b = oldres.tm_b_res;
                        newres.methodParams.known_eff = (oldres.tm_known_eff_res == 0 ? false : true);
                        newres.methodParams.solve_eff = (oldres.tm_solve_eff_res == 0 ? false : true);
                    }
                    else if (r is results_known_m_rec)
                    {
                        // dev note: untested
                        mlogger.TraceEvent(LogLevels.Verbose, 34054, ("Transferring method results for " + r.GetType().ToString()));
                        results_known_m_rec oldres = (results_known_m_rec)r;
                        INCCMethodResults.results_known_m_rec newres =
                            (INCCMethodResults.results_known_m_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownM, true);
                        newres.pu_mass = new Tuple(oldres.km_pu_mass, oldres.km_pu_mass_err);
                        newres.pu240e_mass = new Tuple(oldres.km_pu240e_mass, oldres.km_pu240e_mass);
                        newres.alpha = oldres.km_alpha;
                        newres.mult = oldres.km_mult;
                        newres.dcl_minus_asy_pu_mass = new Tuple(oldres.km_dcl_minus_asy_pu_mass, oldres.km_dcl_minus_asy_pu_mass_err);
                        newres.pu239e_mass = oldres.km_pu240e_mass;
                        newres.dcl_pu240e_mass = oldres.km_dcl_pu240e_mass;
                        newres.dcl_pu_mass = oldres.km_dcl_pu_mass;
                        newres.dcl_minus_asy_pu_mass_pct = oldres.km_dcl_minus_asy_pu_mass_pct;
                        newres.pass = TransferUtils.PassCheck(oldres.km_pass_fail);
                        newres.methodParams.b = oldres.km_b_res;
                        newres.methodParams.c = oldres.km_c_res;
                        newres.methodParams.sf_rate = oldres.km_sf_rate_res;
                        newres.methodParams.sigma_x = oldres.km_sigma_x_res;
                        newres.methodParams.vs1 = oldres.km_vs1_res;
                        newres.methodParams.vi1 = oldres.km_vi1_res;
                        newres.methodParams.vs2 = oldres.km_vs2_res;
                        newres.methodParams.vi2 = oldres.km_vi2_res;
                    }
                    else if (r is results_add_a_source_rec)
                    {
                        // dev note: untested
                        mlogger.TraceEvent(LogLevels.Verbose, 34055, ("Transferring method results for " + r.GetType().ToString()));
                        results_add_a_source_rec oldres = (results_add_a_source_rec)r;
                        INCCMethodResults.results_add_a_source_rec newres =
                            (INCCMethodResults.results_add_a_source_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownM, true);
                        newres.pu_mass = new Tuple(oldres.ad_pu_mass, oldres.ad_pu_mass_err);
                        newres.pu240e_mass = new Tuple(oldres.ad_pu240e_mass, oldres.ad_pu240e_mass);
                        newres.dcl_minus_asy_pu_mass = new Tuple(oldres.ad_dcl_minus_asy_pu_mass, oldres.ad_dcl_minus_asy_pu_mass_err);
                        newres.dcl_pu240e_mass = oldres.ad_dcl_pu240e_mass;
                        newres.dcl_pu_mass = oldres.ad_dcl_pu_mass;
                        newres.dcl_minus_asy_pu_mass_pct = oldres.ad_dcl_minus_asy_pu_mass_pct;
                        newres.pass = TransferUtils.PassCheck(oldres.ad_pass_fail);

                        newres.dzero_cf252_doubles = oldres.ad_dzero_cf252_doubles;
                        newres.sample_avg_cf252_doubles.v = oldres.ad_sample_avg_cf252_doubles;
                        newres.sample_avg_cf252_doubles.err = oldres.ad_sample_avg_cf252_doubles_err;
                        newres.corr_doubles.v = oldres.ad_corr_doubles;
                        newres.corr_doubles.err = oldres.ad_corr_doubles_err;
                        newres.delta.v = oldres.ad_delta;
                        newres.delta.err = oldres.ad_delta_err;
                        newres.corr_factor.v = oldres.ad_corr_factor;
                        newres.corr_factor.err = oldres.ad_corr_factor_err;
                        newres.sample_cf252_ratio = TransferUtils.Copy(oldres.ad_sample_cf252_ratio, INCC.MAX_ADDASRC_POSITIONS);
                        newres.sample_cf252_doubles = Tuple.MakeArray(
                                vals: TransferUtils.Copy(oldres.ad_sample_cf252_doubles, INCC.MAX_ADDASRC_POSITIONS),
                                errs: TransferUtils.Copy(oldres.ad_sample_cf252_doubles_err, INCC.MAX_ADDASRC_POSITIONS));
                        newres.tm_doubles_bkg.v = oldres.ad_tm_doubles_bkg;
                        newres.tm_uncorr_doubles.v = oldres.ad_tm_uncorr_doubles;
                        newres.tm_corr_doubles.v = oldres.ad_corr_doubles;
                        newres.tm_doubles_bkg.err = oldres.ad_tm_doubles_bkg_err;
                        newres.tm_uncorr_doubles.err = oldres.ad_tm_uncorr_doubles_err;
                        newres.tm_corr_doubles.err = oldres.ad_corr_doubles_err;
                        newres.methodParams.cev.a = oldres.ad_a_res; newres.methodParams.cev.b = oldres.ad_b_res;
                        newres.methodParams.cev.c = oldres.ad_c_res; newres.methodParams.cev.d = oldres.ad_d_res;
                        newres.methodParams.cev.var_a = oldres.ad_var_a_res; newres.methodParams.cev.var_b = oldres.ad_var_b_res;
                        newres.methodParams.cev.var_c = oldres.ad_var_c_res; newres.methodParams.cev.var_d = oldres.ad_var_d_res;
                        newres.methodParams.cev.setcovar(Coeff.a, Coeff.b, oldres.ad_covar_ab_res);
                        newres.methodParams.cev._covar[0, 2] = oldres.ad_covar_ac_res;
                        newres.methodParams.cev._covar[0, 3] = oldres.ad_covar_ad_res;
                        newres.methodParams.cev._covar[1, 2] = oldres.ad_covar_bc_res;
                        newres.methodParams.cev._covar[1, 3] = oldres.ad_covar_bd_res;
                        newres.methodParams.cev._covar[2, 3] = oldres.ad_covar_cd_res;
                        newres.methodParams.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.ad_add_a_source_equation;
                        newres.methodParams.cev.sigma_x = oldres.ad_sigma_x_res;

                        newres.methodParams.cf.a = oldres.ad_cf_a_res; newres.methodParams.cf.b = oldres.ad_cf_b_res;
                        newres.methodParams.cf.c = oldres.ad_cf_c_res; newres.methodParams.cf.d = oldres.ad_cf_d_res;
                        newres.methodParams.dzero_avg = oldres.ad_dzero_avg_res;
                        newres.methodParams.num_runs = oldres.ad_num_runs_res;
                        newres.methodParams.tm_dbls_rate_upper_limit = oldres.ad_tm_dbls_rate_upper_limit_res;
                        newres.methodParams.tm_weighting_factor = oldres.ad_tm_weighting_factor_res;
                        newres.methodParams.use_truncated_mult = (oldres.ad_use_truncated_mult_res == 0 ? false : true);
                        newres.methodParams.dzero_ref_date = INCC.DateFrom(TransferUtils.str(oldres.ad_dzero_ref_date_res, INCC.DATE_TIME_LENGTH));
                        newres.methodParams.position_dzero = TransferUtils.Copy(oldres.ad_position_dzero_res, INCC.MAX_ADDASRC_POSITIONS);
                        // devnote: the original methodParams dcl_mass, doubles, min, max not preserved in INCC5 aas result rec
                    }
                    else if (r is results_curium_ratio_rec)
                    {
                        // dev note: untested
                        mlogger.TraceEvent(LogLevels.Verbose, 34056, ("Transferring method results for " + r.GetType().ToString()));
                        results_curium_ratio_rec oldres = (results_curium_ratio_rec)r;
                        INCCMethodResults.results_curium_ratio_rec newres = (INCCMethodResults.results_curium_ratio_rec)
                        meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.CuriumRatio, true);
                        newres.pu.pu240e_mass = new Tuple(oldres.cr_pu240e_mass, oldres.cr_pu240e_mass_err);
                        newres.pu.mass = new Tuple(oldres.cr_pu_mass, oldres.cr_pu_mass_err);
                        newres.pu.dcl_mass = oldres.cr_dcl_pu_mass;
                        newres.pu.dcl_minus_asy_mass = new Tuple(oldres.cr_dcl_minus_asy_pu_mass, oldres.cr_dcl_minus_asy_pu_mass_err);
                        newres.pu.dcl_minus_asy_mass_pct = oldres.cr_dcl_minus_asy_pu_mass_pct;
                        newres.pu.dcl_minus_asy_pu_mass = new Tuple(oldres.cr_dcl_minus_asy_pu_mass, oldres.cr_dcl_minus_asy_pu_mass_err);
                        newres.pu.dcl_minus_asy_pu_mass_pct = oldres.cr_dcl_minus_asy_pu_mass_pct;
                        newres.pu.pass = TransferUtils.PassCheck(oldres.cr_pu_pass_fail);

                        newres.u.mass = new Tuple(oldres.cr_u_mass, oldres.cr_u_mass_err);
                        newres.u.dcl_mass = oldres.cr_dcl_u_mass_res;
                        newres.u.dcl_minus_asy_mass = new Tuple(oldres.cr_dcl_minus_asy_u_mass, oldres.cr_dcl_minus_asy_u_mass_err);
                        newres.u.dcl_minus_asy_mass_pct = oldres.cr_dcl_minus_asy_u_mass_pct;
                        newres.u.pass = TransferUtils.PassCheck(oldres.cr_u_pass_fail);

                        newres.u235.mass = new Tuple(oldres.cr_u235_mass, oldres.cr_u235_mass_err);
                        newres.u235.dcl_mass = oldres.cr_dcl_u235_mass_res;
                        newres.u235.dcl_minus_asy_mass = new Tuple(oldres.cr_dcl_minus_asy_u235_mass, oldres.cr_dcl_minus_asy_u235_mass_err);
                        newres.u235.dcl_minus_asy_mass_pct = oldres.cr_dcl_minus_asy_u235_mass_pct;

                        newres.cm_mass = new Tuple(oldres.cr_cm_mass, oldres.cr_cm_mass_err);
                        newres.methodParams2.cm_pu_ratio = new Tuple(oldres.cr_cm_pu_ratio, oldres.cr_cm_pu_ratio_err);
                        newres.cm_pu_ratio_decay_corr = new Tuple(oldres.cr_cm_pu_ratio_decay_corr, oldres.cr_cm_pu_ratio_decay_corr_err);
                        newres.methodParams2.cm_pu_ratio_date = INCC.DateFrom(TransferUtils.str(oldres.cr_cm_pu_ratio_date, INCC.DATE_TIME_LENGTH));
                        newres.cm_u_ratio_decay_corr = new Tuple(oldres.cr_cm_u_ratio_decay_corr, oldres.cr_cm_u_ratio_decay_corr_err);
                        newres.methodParams2.cm_u_ratio_date = INCC.DateFrom(TransferUtils.str(oldres.cr_cm_pu_ratio_date, INCC.DATE_TIME_LENGTH));
                        newres.methodParams2.pu_half_life = oldres.cr_pu_half_life;

                        newres.methodParams2.cm_id_label = TransferUtils.str(oldres.cr_cm_id_label, INCC.MAX_ITEM_ID_LENGTH);
                        newres.methodParams2.cm_id = TransferUtils.str(oldres.cr_cm_id, INCC.MAX_ITEM_ID_LENGTH);
                        newres.methodParams2.cm_input_batch_id = TransferUtils.str(oldres.cr_cm_input_batch_id, INCC.MAX_ITEM_ID_LENGTH);

                        newres.methodParams.cev.a = oldres.cr_a_res; newres.methodParams.cev.b = oldres.cr_b_res;
                        newres.methodParams.cev.c = oldres.cr_c_res; newres.methodParams.cev.d = oldres.cr_d_res;
                        newres.methodParams.cev.var_a = oldres.cr_var_a_res; newres.methodParams.cev.var_b = oldres.cr_var_b_res;
                        newres.methodParams.cev.var_c = oldres.cr_var_c_res; newres.methodParams.cev.var_d = oldres.cr_var_d_res;
                        newres.methodParams.cev.setcovar(Coeff.a,Coeff.b,oldres.cr_covar_ab_res);
                        newres.methodParams.cev._covar[0, 2] = oldres.cr_covar_ac_res;
                        newres.methodParams.cev._covar[0, 3] = oldres.cr_covar_ad_res;
                        newres.methodParams.cev._covar[1, 2] = oldres.cr_covar_bc_res;
                        newres.methodParams.cev._covar[1, 3] = oldres.cr_covar_bd_res;
                        newres.methodParams.cev._covar[2, 3] = oldres.cr_covar_cd_res;
                        newres.methodParams.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.cr_curium_ratio_equation;
                        newres.methodParams.cev.sigma_x = oldres.cr_sigma_x_res;
                        newres.methodParams.curium_ratio_type = OldToNewCRVariants(oldres.curium_ratio_type_res);
                    }
                    else if (r is results_active_passive_rec) // NEXT: confusion with combined, it's the same as Active internally? expand and study
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34057, ("Transferring method results for " + r.GetType().ToString()));
                        results_active_passive_rec oldres = (results_active_passive_rec)r;
                        INCCMethodResults.results_active_passive_rec newres =
                            (INCCMethodResults.results_active_passive_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.ActivePassive, true);

                        newres.pass = TransferUtils.PassCheck(oldres.ap_pass_fail);
                        newres.k.v = oldres.ap_k; newres.k.err = oldres.ap_k_err;
                        newres.k0.v = oldres.ap_k0;
                        newres.k1.v = oldres.ap_k1; newres.k1.err = oldres.ap_k1_err;
                        newres.u235_mass.v = oldres.ap_u235_mass; newres.u235_mass.err = oldres.ap_u235_mass_err;
                        newres.dcl_minus_asy_u235_mass.v = oldres.ap_dcl_minus_asy_u235_mass; newres.dcl_minus_asy_u235_mass.err = oldres.ap_dcl_minus_asy_u235_mass_err;

                        newres.dcl_u235_mass = oldres.ap_dcl_u235_mass;
                        newres.dcl_minus_asy_u235_mass_pct = oldres.ap_dcl_minus_asy_u235_mass_pct;

                        newres.methodParams = new INCCAnalysisParams.active_passive_rec();
                        newres.methodParams.cev.a = oldres.ap_a_res; newres.methodParams.cev.b = oldres.ap_b_res;
                        newres.methodParams.cev.c = oldres.ap_c_res; newres.methodParams.cev.d = oldres.ap_d_res;
                        newres.methodParams.cev.var_a = oldres.ap_var_a_res; newres.methodParams.cev.var_b = oldres.ap_var_b_res;
                        newres.methodParams.cev.var_c = oldres.ap_var_c_res; newres.methodParams.cev.var_d = oldres.ap_var_d_res;
                        newres.methodParams.cev.setcovar(Coeff.a, Coeff.b, oldres.ap_covar_ab_res);
                        newres.methodParams.cev._covar[0, 2] = oldres.ap_covar_ac_res;
                        newres.methodParams.cev._covar[0, 3] = oldres.ap_covar_ad_res;
                        newres.methodParams.cev._covar[1, 2] = oldres.ap_covar_bc_res;
                        newres.methodParams.cev._covar[1, 3] = oldres.ap_covar_bd_res;
                        newres.methodParams.cev._covar[2, 3] = oldres.ap_covar_cd_res;
                        newres.methodParams.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.ap_active_passive_equation;
                        newres.methodParams.cev.sigma_x = oldres.ap_sigma_x_res;
                        newres.delta_doubles.v = oldres.ap_delta_doubles;
                        newres.delta_doubles.err = oldres.ap_delta_doubles_err;
                    }
                    else if (r is results_active_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34058, ("Transferring method results for " + r.GetType().ToString()));
                        results_active_rec oldres = (results_active_rec)r;
                        INCCMethodResults.results_active_rec newres =
                            (INCCMethodResults.results_active_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Active, true);
                        newres.pass = TransferUtils.PassCheck(oldres.act_pass_fail);
                        newres.k.v = oldres.act_k; newres.k.err = oldres.act_k_err;
                        newres.k0.v = oldres.act_k0;
                        newres.k1.v = oldres.act_k1; newres.k1.err = oldres.act_k1_err;
                        newres.u235_mass.v = oldres.act_u235_mass; newres.u235_mass.err = oldres.act_u235_mass_err;
                        newres.dcl_minus_asy_u235_mass.v = oldres.act_dcl_minus_asy_u235_mass; newres.dcl_minus_asy_u235_mass.err = oldres.act_dcl_minus_asy_u235_mass_err;

                        newres.dcl_u235_mass = oldres.act_dcl_u235_mass;
                        newres.dcl_minus_asy_u235_mass_pct = oldres.act_dcl_minus_asy_u235_mass_pct;

                        newres.methodParams = new INCCAnalysisParams.active_rec();
                        newres.methodParams.cev.a = oldres.act_a_res; newres.methodParams.cev.b = oldres.act_b_res;
                        newres.methodParams.cev.c = oldres.act_c_res; newres.methodParams.cev.d = oldres.act_d_res;
                        newres.methodParams.cev.var_a = oldres.act_var_a_res; newres.methodParams.cev.var_b = oldres.act_var_b_res;
                        newres.methodParams.cev.var_c = oldres.act_var_c_res; newres.methodParams.cev.var_d = oldres.act_var_d_res;
                        newres.methodParams.cev.setcovar(Coeff.a,Coeff.b,oldres.act_covar_ab_res);
                        newres.methodParams.cev._covar[0, 2] = oldres.act_covar_ac_res;
                        newres.methodParams.cev._covar[0, 3] = oldres.act_covar_ad_res;
                        newres.methodParams.cev._covar[1, 2] = oldres.act_covar_bc_res;
                        newres.methodParams.cev._covar[1, 3] = oldres.act_covar_bd_res;
                        newres.methodParams.cev._covar[2, 3] = oldres.act_covar_cd_res;
                        newres.methodParams.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.act_active_equation;
                        newres.methodParams.cev.sigma_x = oldres.act_sigma_x_res;
                    }
                    else if (r is results_active_mult_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34059, ("Transferring method results for " + r.GetType().ToString()));
                        results_active_mult_rec oldres = (results_active_mult_rec)r;
                        INCCMethodResults.results_active_mult_rec newres =
                            (INCCMethodResults.results_active_mult_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.ActiveMultiplicity, true);
                        newres.methodParams = new INCCAnalysisParams.active_mult_rec();
                        newres.methodParams.vf1 = oldres.am_vf1_res;
                        newres.methodParams.vf2 = oldres.am_vf2_res;
                        newres.methodParams.vf3 = oldres.am_vf3_res;
                        newres.methodParams.vt1 = oldres.am_vt1_res;
                        newres.methodParams.vt2 = oldres.am_vt2_res;
                        newres.methodParams.vt3 = oldres.am_vt2_res;
                        newres.mult.v = oldres.am_mult;
                        newres.mult.err = oldres.am_mult_err;
                     }
                    else if (r is results_collar_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34060, ("Transferring method results for " + r.GetType().ToString()));
                        results_collar_rec oldres = (results_collar_rec)r;
                        INCCMethodResults.results_collar_rec newres =
                            (INCCMethodResults.results_collar_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Collar, true);

                        newres.u235_mass.v = oldres.col_u235_mass; newres.u235_mass.err = oldres.col_u235_mass_err;
                        newres.percent_u235 = oldres.col_percent_u235;
                        newres.total_u_mass = oldres.col_total_u_mass;
                        newres.k0.v = oldres.col_k0; newres.k0.err = oldres.col_k0_err;
                        newres.k1.v = oldres.col_k1; newres.k1.err = oldres.col_k1_err;
                        newres.k2.v = oldres.col_k2; newres.k2.err = oldres.col_k2_err;
                        newres.k3.v = oldres.col_k3; newres.k3.err = oldres.col_k3_err;
                        newres.k4.v = oldres.col_k4; newres.k4.err = oldres.col_k4_err;
                        newres.k5.v = oldres.col_k5; newres.k5.err = oldres.col_k5_err;
                        newres.source_id = TransferUtils.str(oldres.col_source_id, INCC.SOURCE_ID_LENGTH);
                        newres.total_corr_fact.v = oldres.col_total_corr_fact; newres.total_corr_fact.err = oldres.col_total_corr_fact_err;
                        newres.corr_doubles.v = oldres.col_corr_doubles; newres.corr_doubles.err = oldres.col_corr_doubles_err;
                        newres.dcl_length.v = oldres.col_dcl_length; newres.dcl_length.err = oldres.col_dcl_length_err;
                        newres.dcl_total_u235.v = oldres.col_dcl_total_u235; newres.dcl_total_u235.err = oldres.col_dcl_total_u235_err;
                        newres.dcl_total_u238.v = oldres.col_dcl_total_u238; newres.dcl_total_u238.err = oldres.col_dcl_total_u238_err;
                        newres.dcl_total_rods = oldres.col_dcl_total_rods;
                        newres.dcl_total_poison_rods = oldres.col_dcl_total_poison_rods;

                        newres.dcl_poison_percent.v = oldres.col_dcl_poison_percent;
                        newres.dcl_poison_percent.err = oldres.col_dcl_poison_percent_err;
                        newres.dcl_minus_asy_u235_mass_pct = oldres.col_dcl_minus_asy_u235_mass_pct;
                        newres.dcl_minus_asy_u235_mass.v = oldres.col_dcl_minus_asy_u235_mass;
                        newres.dcl_minus_asy_u235_mass.err = oldres.col_dcl_minus_asy_u235_mass_err;

                        newres.methodParamsC.cev.a = oldres.col_a_res; newres.methodParamsC.cev.b = oldres.col_b_res;
                        newres.methodParamsC.cev.c = oldres.col_c_res; newres.methodParamsC.cev.d = oldres.col_d_res;
                        newres.methodParamsC.cev.var_a = oldres.col_var_a_res; newres.methodParamsC.cev.var_b = oldres.col_var_b_res;
                        newres.methodParamsC.cev.var_c = oldres.col_var_c_res; newres.methodParamsC.cev.var_d = oldres.col_var_d_res;
                        newres.methodParamsC.cev.setcovar(Coeff.a,Coeff.b,oldres.col_covar_ab_res);
                        newres.methodParamsC.cev._covar[0, 2] = oldres.col_covar_ac_res;
                        newres.methodParamsC.cev._covar[0, 3] = oldres.col_covar_ad_res;
                        newres.methodParamsC.cev._covar[1, 2] = oldres.col_covar_bc_res;
                        newres.methodParamsC.cev._covar[1, 3] = oldres.col_covar_bd_res;
                        newres.methodParamsC.cev._covar[2, 3] = oldres.col_covar_cd_res;
                        newres.methodParamsC.cev.cal_curve_equation = (INCCAnalysisParams.CurveEquation)oldres.col_collar_equation;
                        newres.methodParamsC.cev.sigma_x = oldres.col_sigma_x_res;
                        newres.methodParamsC.poison_absorption_fact[0] = oldres.col_poison_absorption_fact_res;
                        newres.methodParamsC.poison_rod_a[0] = new Tuple(oldres.col_poison_rod_a_res, oldres.col_poison_rod_a_err_res);
                        newres.methodParamsC.poison_rod_b[0] = new Tuple(oldres.col_poison_rod_b_res, oldres.col_poison_rod_b_err_res);
                        newres.methodParamsC.poison_rod_c[0] = new Tuple(oldres.col_poison_rod_c_res, oldres.col_poison_rod_c_err_res);
                        newres.methodParamsC.collar_mode = (oldres.col_collar_mode == 0 ? false : true);
                        newres.methodParamsC.number_calib_rods = (int)oldres.col_number_calib_rods_res;
                        newres.methodParamsC.poison_rod_type[0] = TransferUtils.str(oldres.col_poison_rod_type_res, INCC.MAX_ROD_TYPE_LENGTH);
                        newres.methodParamsC.u_mass_corr_fact_a.v = oldres.col_u_mass_corr_fact_a_res; newres.methodParamsC.u_mass_corr_fact_a.err = oldres.col_u_mass_corr_fact_a_err_res;
                        newres.methodParamsC.u_mass_corr_fact_b.v = oldres.col_u_mass_corr_fact_b_res; newres.methodParamsC.u_mass_corr_fact_b.err = oldres.col_u_mass_corr_fact_b_err_res;
                        newres.methodParamsC.sample_corr_fact.v = oldres.col_sample_corr_fact_res; newres.methodParamsC.sample_corr_fact.err = oldres.col_sample_corr_fact_err_res;

                        newres.methodParamsDetector.collar_mode = (oldres.col_collar_mode == 0 ? false : true);
                        newres.methodParamsDetector.reference_date = INCC.DateFrom(TransferUtils.str(oldres.col_reference_date_res, INCC.DATE_TIME_LENGTH));
                        newres.methodParamsDetector.relative_doubles_rate = oldres.col_relative_doubles_rate_res;

                        newres.methodParamsK5.k5_mode = (oldres.col_collar_mode == 0 ? false : true);
                        newres.methodParamsK5.k5_item_type = TransferUtils.str(oldres.col_collar_item_type, INCC.MAX_ITEM_TYPE_LENGTH);
                        newres.methodParamsK5.k5 = Copy(oldres.collar_k5_res, oldres.collar_k5_err_res, INCC.MAX_COLLAR_K5_PARAMETERS);
                        newres.methodParamsK5.k5_checkbox = TransferUtils.Copy(oldres.collar_k5_checkbox_res, INCC.MAX_COLLAR_K5_PARAMETERS);
                        for (int i = 0; i < INCC.MAX_COLLAR_K5_PARAMETERS; i++)
                        {
                            int index = i * INCC.MAX_K5_LABEL_LENGTH;
                            newres.methodParamsK5.k5_label[i] = TransferUtils.str(oldres.collar_k5_label_res + index, INCC.MAX_K5_LABEL_LENGTH);
                        }

                        CollarItemId cid = new CollarItemId(TransferUtils.str(results.item_id, INCC.MAX_ITEM_ID_LENGTH));
                        cid.length = new Tuple(newres.dcl_length);
                        cid.total_u235 = new Tuple(newres.dcl_total_u235);
                        cid.total_u238 = new Tuple(newres.dcl_total_u238);
                        cid.total_rods = newres.dcl_total_rods;
                        cid.total_poison_rods = newres.dcl_total_poison_rods;
                        cid.poison_percent = new Tuple(newres.dcl_poison_percent);
                        cid.rod_type = newres.methodParamsC.poison_rod_type[0];
                        cid.modified = true;

                        List<CollarItemId> list = NC.App.DB.CollarItemIds.GetList();
                        bool glump = list.Exists(i => { return string.Compare(cid.item_id, i.item_id, true) == 0; });
                        if (glump && overwrite)
                        {
                            list.Remove(cid);
                            list.Add(cid);
                        }
                        else list.Add(cid);
                    }
                    else if (r is results_de_mult_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 34061, ("Transferring method results for " + r.GetType().ToString()));
                        results_de_mult_rec oldres = (results_de_mult_rec)r;
                        INCCMethodResults.results_de_mult_rec newres =
                            (INCCMethodResults.results_de_mult_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.DUAL_ENERGY_MULT_SAVE_RESTORE, true);
                        newres.meas_ring_ratio = oldres.de_meas_ring_ratio;
                        newres.energy_corr_factor = oldres.de_energy_corr_factor;
                        newres.interpolated_neutron_energy = oldres.de_interpolated_neutron_energy;
                        newres.methodParams.detector_efficiency = TransferUtils.Copy(oldres.de_detector_efficiency_res, INCC.MAX_DUAL_ENERGY_ROWS);
                        newres.methodParams.inner_outer_ring_ratio = TransferUtils.Copy(oldres.de_inner_outer_ring_ratio_res, INCC.MAX_DUAL_ENERGY_ROWS);
                        newres.methodParams.neutron_energy = TransferUtils.Copy(oldres.de_neutron_energy_res, INCC.MAX_DUAL_ENERGY_ROWS);
                        newres.methodParams.relative_fission = TransferUtils.Copy(oldres.de_relative_fission_res, INCC.MAX_DUAL_ENERGY_ROWS);
                        newres.methodParams.inner_ring_efficiency = oldres.de_inner_ring_efficiency_res;
                        newres.methodParams.outer_ring_efficiency = oldres.de_outer_ring_efficiency_res;
                    }
                    else if (r is results_tm_bkg_rec)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34062, ("Transferring method results for " + r.GetType().ToString()));
                        results_tm_bkg_rec oldres = (results_tm_bkg_rec)r;  // todo: tm bkg handling design incomplete, these values are attached to bkg measurements when the truncated flag is enabled
                        INCCMethodResults.results_tm_bkg_rec newres =
                            (INCCMethodResults.results_tm_bkg_rec)meas.INCCAnalysisResults.LookupMethodResults(det.MultiplicityParams, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.None, true);
                        newres.methodParams.Singles.v = oldres.results_tm_singles_bkg;
                        newres.methodParams.Singles.err = oldres.results_tm_singles_bkg_err;
                        newres.methodParams.Zeros.v = oldres.results_tm_zeros_bkg;
                        newres.methodParams.Zeros.err = oldres.results_tm_zeros_bkg_err;
                        newres.methodParams.Ones.v = oldres.results_tm_ones_bkg;
                        newres.methodParams.Ones.err = oldres.results_tm_ones_bkg_err;
                        newres.methodParams.Twos.v = oldres.results_tm_twos_bkg;
                        newres.methodParams.Twos.err = oldres.results_tm_twos_bkg_err;
                    }
                    else
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34040, ("todo: Transferring method results for " + r.GetType().ToString())); // todo: complete the list
                    }
                }

            }
            #endregion results transfer
            // dev note: here is where the detector tree creation and replacement with restore_replace_detector_structs occurs in the original code
            // todo: based on overwrite flag, replace det-dependent classes, the analysis_methods: (none-map) and each (det,mat) -> calib from results class instances

            #region Meas&Results

            AnalysisDefs.holdup_config_rec hc = new AnalysisDefs.holdup_config_rec();
            hc.glovebox_id = TransferUtils.str(results.results_glovebox_id, INCC.MAX_GLOVEBOX_ID_LENGTH);
            hc.num_columns = results.results_num_columns;
            hc.num_rows = results.results_num_rows;
            hc.distance = results.results_distance;
            meas.AcquireState.glovebox_id = hc.glovebox_id;
            // this is a good place to create the general results_rec
            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec = xres;
            // oddball entries in need of preservation
            xres.total_good_count_time = results.total_good_count_time;
            xres.total_number_runs = results.total_number_runs;
            xres.primary = imr.primaryMethod;
            xres.net_drum_weight = results.net_drum_weight;
            xres.completed = (results.completed != 0 ? true : false);
            xres.db_version = results.db_version;
            xres.hc = hc;
            xres.original_meas_date = INCC.DateFrom(TransferUtils.str(results.original_meas_date, INCC.DATE_TIME_LENGTH));
            // NEXT: copy move passive and active meas id's here

             long mid = meas.Persist();

            // save the warning and error messages from the results here, these rode on the results rec in INCC5
            NC.App.DB.AddAnalysisMessages(msgs, mid);

            // Store off Params

            NC.App.DB.UpdateDetector(det);
            NC.App.DB.NormParameters.Set(det, meas.Norm);  // might have been saved in earlier step already
            NC.App.DB.BackgroundParameters.Set(det, meas.Background);

            INCCDB.AcquireSelector acqsel = new INCCDB.AcquireSelector(det, acq.item_type, acq.MeasDateTime);
            if (overwrite)
            {
                NC.App.DB.ReplaceAcquireParams(acqsel, acq);
            }
            else
                NC.App.DB.AddAcquireParams(acqsel, acq); // gotta add it to the global map, then push it to the DB

            if (meas.Tests != null) // added only if not found on the list
                NC.App.DB.TestParameters.Set(meas.Tests);

            NC.App.DB.Isotopics.SetList();  // new style de 'mouser'!
            //NC.App.DB.CompositeIsotopics.SetList();// next:NYI
            NC.App.DB.ItemIds.SetList(); // This writes any new items ids to the DB
            NC.App.DB.CollarItemIds.SetList(); // so does this

            //Loop over measurement cycles
            NC.App.DB.AddCycles(meas.Cycles, det.MultiplicityParams, mid);

            //Store off Params

            // todo: complete table design and creation/update here, still have issues with collar and curium ratio results
            // get results based on meas option, (Calib and Verif have method results, others do not), update into DB here
            IEnumerator iter = meas.INCCAnalysisResults.GetMeasSelectorResultsEnumerator();
            while (iter.MoveNext())  // only one result indexer is present when doing an INCC5 transfer
            {
                MeasOptionSelector moskey = (MeasOptionSelector)iter.Current;
                INCCResult ir = meas.INCCAnalysisResults[moskey];
                // ir contains the measurement option-specific results: empty for rates and holdup, and also empty for calib and verif, the method-focused analyses,
                // but values are present for initial, normalization, precision, and should be present for background for the tm bkg results
                switch (meas.MeasOption)
                {
                    case AssaySelector.MeasurementOption.background:
                        if (meas.Background.TMBkgParams.ComputeTMBkg)
                            mlogger.TraceEvent(LogLevels.Warning, 82010, "Background truncated multiplicity"); // todo: present the tm bkg results on m.Background
                        break;
                    case AssaySelector.MeasurementOption.initial:
                    case AssaySelector.MeasurementOption.normalization:
                    case AssaySelector.MeasurementOption.precision:
                        {
                            ElementList els = ir.ToDBElementList();
                            ParamsRelatedBackToMeasurement ar = new ParamsRelatedBackToMeasurement(ir.Table);
                            long resid = ar.Create(mid, els);
                            mlogger.TraceEvent(LogLevels.Verbose, 34103, string.Format("Preserving {0} as {1}", ir.Table, resid));
                        }
                        break;
                    case AssaySelector.MeasurementOption.verification:
                    case AssaySelector.MeasurementOption.calibration:
                    {
                        INCCMethodResults imrs;
                        bool have = meas.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrs);
                        if (have) // should be true for verification and calibration
                        {
                            if (imrs.ContainsKey(meas.INCCAnalysisState.Methods.selector))
                            {
                                // we've got a distinct detector id and material type on the methods, so that is the indexer here
                                Dictionary<AnalysisMethod, INCCMethodResult> amimr = imrs[meas.INCCAnalysisState.Methods.selector];

                                // now get an enumerator over the map of method results
                                Dictionary<AnalysisMethod, INCCMethodResult>.Enumerator ai = amimr.GetEnumerator();
                                while (ai.MoveNext())
                                {
                                    if (ai.Current.Key.IsNone())
                                        continue;
                                    INCCMethodResult _imr = ai.Current.Value;
                                    // insert this into the DB under the current meas key
                                    try
                                    {
                                        ElementList els = _imr.ToDBElementList(); // also sets table property, gotta do it first
                                        ParamsRelatedBackToMeasurement ar = new ParamsRelatedBackToMeasurement(_imr.Table);
                                        long resid = ar.Create(mid, els);
                                        do
                                        {
                                            long resmid = ar.CreateMethod(resid, mid, _imr.methodParams.ToDBElementList());
                                            mlogger.TraceEvent(LogLevels.Verbose, 34101, string.Format("Preserving {0} as {1},{2}", _imr.Table, resmid, resid));
                                        } while (_imr.methodParams.Pump > 0);
                                    }
                                    catch (Exception e)
                                    {
                                        mlogger.TraceEvent(LogLevels.Warning, 34102, "Results processing error {0} {1}", _imr.ToString(), e.Message);
                                    }
                                }
                            } else
                                mlogger.TraceEvent(LogLevels.Error, 34102, "Results missing for {0}", meas.INCCAnalysisState.Methods.selector.ToString());

                        }
                    }
                    break;
                    case AssaySelector.MeasurementOption.rates:
                    case AssaySelector.MeasurementOption.holdup:
                    case AssaySelector.MeasurementOption.unspecified:
                    default: // nothing new to present with these
                        break;
                }
            }
            #endregion Meas&Results

              // todo: handle well config setting with bkg here;

            return true;
        }
示例#35
0
        /// <summary>
        /// Finalize measurement instance content for analysis
        /// Populate calibration parameters maps
        /// </summary>
        /// <param name="meas">The partially initialized measurement instance</param>
        /// <param name="useCurCalibParams">Default behavior is to use active method and other calibration parameters;
        ///                                 skipped if Reanalysis prepared the details from database measurement results
        /// </param>
        static public void FillInReanalysisRemainingDetails(Measurement meas, bool useCurCalibParams = true)
        {
            // get the current INCC5 analysis methods
            if (useCurCalibParams || meas.INCCAnalysisState == null)
            {
                meas.INCCAnalysisState = new INCCAnalysisState();
                INCCSelector    sel = new INCCSelector(meas.AcquireState.detector_id, meas.AcquireState.item_type);
                AnalysisMethods am;
                bool            found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
                if (found)
                {
                    am.selector = sel;                     // gotta do this so that the equality operator is not incorrect
                    meas.INCCAnalysisState.Methods = am;
                }
                else
                {
                    meas.INCCAnalysisState.Methods = new AnalysisMethods(sel);
                }
            }             // else use what was there

            meas.InitializeContext(clearCounterResults: false);
            meas.PrepareINCCResults();

            System.Collections.IEnumerator iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(Multiplicity));
            while (iter.MoveNext())
            {
                Multiplicity mkey = (Multiplicity)iter.Current;
                try
                {
                    MultiplicityCountingRes mcr = (MultiplicityCountingRes)meas.CountingAnalysisResults[mkey];
                    if (mcr.AB.Unset)
                    {
                        LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(mkey, mcr);                         // works only if MaxBins is set
                    }
                    MeasOptionSelector mos    = new MeasOptionSelector(meas.MeasOption, mkey);
                    INCCResult         result = meas.INCCAnalysisState.Lookup(mos);
                    result.CopyFrom(mcr);
                }
                catch (Exception)
                {
                    //logger.TraceEvent(LogLevels.Error, 4027, "PrepareINCCResults error: " + ex.Message);
                }
            }

            // stratum look up, finds existing stratum by name
            if (useCurCalibParams || meas.Stratum == null)
            {
                List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();
                INCCDB.StratumDescriptor        s  = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0);
                if (s == null)
                {
                    meas.Stratum = new Stratum();
                }
                else
                {
                    meas.Stratum = new Stratum(s.Stratum);
                }
            }
            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec  = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state
        }
示例#36
0
        /// <summary>
        /// Prepare measurement instance content for analysis
        /// Populate calibration and counting parameters maps
        /// Create general results and specific results dictionary map entries
        /// Set up stratum details
        /// </summary>
        /// <param name="meas">The partially initialized measurement instance</param>
        /// <param name="useCurCalibParams">Default behavior is to use active method and other calibration parameters;
        ///                                 skipped if Reanalysis prepared the details from database measurement results
        /// </param>
        public static void FillInMeasurementDetails(Measurement meas, bool useCurCalibParams = true)
        {
            if (meas.Detector.ListMode)
            {
                // APluralityOfMultiplicityAnalyzers: see below
                // URGENT: see below
                //if (an INCC5 DB cycle read or DB Ver reanalysis then rebuild the analyzers from the associated saved LM results:)
                //	object x = CentralizedState.App.DB.GetAnalyzersFromResults(meas.Detector, meas.MeasurementId);
                //else
                      meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(meas.Detector, applySRFromDetector: true);
                if (meas.MeasOption.IsListMode()) // pure List Mode, not INCC5
                {
                    // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params
                    ApplyVSRChangesToDefaultDetector(meas);
                }
                else // it is an INCC5 analysis driven with LM data
                {
                    // prepare or identify an active CA entry with matching CA gatewidth and FA, and has the same SR params as the detector
                    if (meas.AnalysisParams.PrepareMatchingVSR(meas.Detector.MultiplicityParams))
                        CentralizedState.App.LMBD.UpdateCounters(meas.Detector.Id.DetectorName, meas.AnalysisParams); // added one, save it
                }
            }
            else // construct param key source with the single mkey entry point
            {
                // prepare analyzer params from detector SR params
                meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(meas.Detector, applySRFromDetector: false);
                if (!meas.AnalysisParams.Exists(w => { return (w is Multiplicity) && (w as Multiplicity).Equals(meas.Detector.MultiplicityParams); }))
                    meas.AnalysisParams.Add(meas.Detector.MultiplicityParams);
            }

            // get the current INCC5 analysis methods
            if (useCurCalibParams || meas.INCCAnalysisState == null)
            {
                meas.INCCAnalysisState = new INCCAnalysisState();
                INCCSelector sel = new INCCSelector(meas.AcquireState.detector_id, meas.AcquireState.item_type);
                AnalysisMethods am;
                bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
                if (found)
                {
                    am.selector = sel; // gotta do this so that the equality operator is not incorrect
                    meas.INCCAnalysisState.Methods = am;
                }
                else
                    meas.INCCAnalysisState.Methods = new AnalysisMethods(sel);
            } // else use what was there

            meas.InitializeContext(clearCounterResults:true);
            meas.PrepareINCCResults();

            // stratum look up, finds existing stratum by name
            if (useCurCalibParams || meas.Stratum == null)
            {
                List<INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();
                INCCDB.StratumDescriptor s = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0);
                if (s == null)
                    meas.Stratum = new Stratum();
                else
                    meas.Stratum = new Stratum(s.Stratum);
            }
            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state
        }
示例#37
0
        INCCAnalysisParams.collar_combined_rec CollarEntryProcesser(INCCInitialDataCalibrationFile idcf, INCCSelector sel, byte mode)
        {
            DetectorMaterialMethod m1 = new DetectorMaterialMethod(sel.material, sel.detectorid, INCC.COLLAR_DETECTOR_SAVE_RESTORE); m1.extra = mode;
            DetectorMaterialMethod m2 = new DetectorMaterialMethod(sel.material, sel.detectorid, INCC.COLLAR_SAVE_RESTORE); m2.extra = mode;
            DetectorMaterialMethod m3 = new DetectorMaterialMethod(sel.material, sel.detectorid, INCC.COLLAR_K5_SAVE_RESTORE); m3.extra = mode;

            KeyValuePair<DetectorMaterialMethod, object> k1, k2, k3;
            bool ok = idcf.DetectorMaterialMethodParameters.GetPair(m1, out k1);
            if (!ok)
            {
                mlogger.TraceEvent(LogLevels.Verbose, 30811, "No collar detector values for " + m1.ToString());
                ok = idcf.DetectorMaterialMethodParameters.GetPair(m2, out k2);
                if (ok)
                {
                    // k5 and collar but no det entry, find the closest match det entry and make a fake one and use it
                    List<KeyValuePair<DetectorMaterialMethod, object>> l = idcf.DetectorMaterialMethodParameters.GetDetectorsWithEntries;
                    if (l.Count > 0)
                    {
                        object o = l[0].Value;
                        collar_detector_rec rec = MakeAFake((collar_detector_rec)o, sel.detectorid, sel.material);
                        DetectorMaterialMethod mf1 = new DetectorMaterialMethod(sel.material, sel.detectorid, INCC.COLLAR_DETECTOR_SAVE_RESTORE); mf1.extra = mode;
                        k1 = new KeyValuePair<DetectorMaterialMethod, object>(mf1, rec);
                    }
                    else
                        return null;
                }
                else
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 30812, "No collar values for " + m2.ToString());
                    return null;
                }
            }
            else
            {
                ok = idcf.DetectorMaterialMethodParameters.GetPair(m2, out k2);
                if (!ok)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 30812, "No collar values for " + m2.ToString());
                    return null;
                }
            }
            ok = idcf.DetectorMaterialMethodParameters.GetPair(m3, out k3);
            if (!ok)
            {
                mlogger.TraceEvent(LogLevels.Verbose, 30813, "No k5 values for " + m3.ToString());
                return null;
            }
            collar_rec collar;
            collar_detector_rec collar_detector;
            collar_k5_rec collar_k5;
            if (k1.Key.extra == -1)
                return null;
            collar_detector = (collar_detector_rec)k1.Value;
            if (k2.Key.extra == -1)
                return null;
            collar = (collar_rec)k2.Value;
            if (k3.Key.extra == -1)
                return null;
            collar_k5 = (collar_k5_rec)k3.Value;
            // got the three
            INCCAnalysisParams.collar_combined_rec combined = new INCCAnalysisParams.collar_combined_rec();
            ushort bonk = 0;
            CollarDet(combined, collar_detector, bonk);
            bonk = 1;
            CollarParm(combined, collar, bonk);
            bonk = 2;
            CollarK5(combined, collar_k5, bonk);
            bonk = 3;

            k1.Key.extra = -1;
            k2.Key.extra = -1;
            k3.Key.extra = -1;
            return combined;
        }
示例#38
0
 public static AnalysisMethods GetMethodSelections(string det, string mat)
 {
     INCCSelector sel = new INCCSelector(det, mat);
     AnalysisMethods lam;
     bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);
     return lam;
 }
示例#39
0
 internal static unsafe active_mult_rec MoveAM(INCCSelector se, INCCAnalysisParams.INCCMethodDescriptor md)
 {
     INCCAnalysisParams.active_mult_rec imr = (INCCAnalysisParams.active_mult_rec)md;
     active_mult_rec m = new active_mult_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.active_mult_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, m.active_mult_item_type);
     m.am_vf1 = imr.vf1;
     m.am_vf2 = imr.vf2;
     m.am_vf3 = imr.vf3;
     m.am_vt1 = imr.vt1;
     m.am_vt2 = imr.vt2;
     m.am_vt3 = imr.vt3;
     return m;
 }
示例#40
0
 internal static unsafe analysis_method_rec MoveAMR(INCCSelector se)
 {
     analysis_method_rec amr = new analysis_method_rec();
     byte[] b = new byte[INCC.MAX_DETECTOR_ID_LENGTH];
     char[] a = se.detectorid.ToCharArray(0, Math.Min(se.detectorid.Length, INCC.MAX_DETECTOR_ID_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, amr.analysis_method_detector_id);
     b = new byte[INCC.MAX_ITEM_TYPE_LENGTH];
     a = se.material.ToCharArray(0, Math.Min(se.material.Length, INCC.MAX_ITEM_TYPE_LENGTH));
     Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0);
     TransferUtils.Copy(b, amr.item_type);
     AnalysisMethods ams = NC.App.DB.DetectorMaterialAnalysisMethods[se];
     amr.backup_method = (byte)NewTypeToOldMethodId(ams.Backup);
     amr.normal_method = (byte)NewTypeToOldMethodId(ams.Normal);
     amr.cal_curve = (byte)(ams.choices[(int)AnalysisMethod.CalibrationCurve] ? 1 : 0);
     amr.active = (byte)(ams.choices[(int)AnalysisMethod.Active] ? 1 : 0);
     amr.active_mult = (byte)(ams.choices[(int)AnalysisMethod.ActiveMultiplicity] ? 1 : 0);
     amr.active_passive = (byte)(ams.choices[(int)AnalysisMethod.ActivePassive] ? 1 : 0);
     amr.add_a_source = (byte)(ams.choices[(int)AnalysisMethod.AddASource] ? 1 : 0);
     amr.collar = (byte)(ams.choices[(int)AnalysisMethod.Collar] ? 1 : 0);
     amr.curium_ratio = (byte)(ams.choices[(int)AnalysisMethod.CuriumRatio] ? 1 : 0);
     amr.known_alpha = (byte)(ams.choices[(int)AnalysisMethod.KnownA] ? 1 : 0);
     amr.known_m = (byte)(ams.choices[(int)AnalysisMethod.KnownM] ? 1 : 0);
     amr.multiplicity = (byte)(ams.choices[(int)AnalysisMethod.Multiplicity] ? 1 : 0);
     amr.truncated_mult = (byte)(ams.choices[(int)AnalysisMethod.TruncatedMultiplicity] ? 1 : 0);
     return amr;
 }
示例#41
0
        /// <summary>
        /// Construct a full measurement state and set it on the internal lameness
        /// </summary>
        /// <param name="acq">Acquire Parameters</param>
        /// <param name="det">Detector</param>
        /// <param name="mo">MeasurementOption</param>
        public static void BuildMeasurement(AcquireParameters acq, Detector det, AssaySelector.MeasurementOption mo)
        {
            // gather it all together
            MeasurementTuple mt = new MeasurementTuple(new DetectorList(det),
                                    CentralizedState.App.DB.TestParameters.Get(),
                                    GetCurrentNormParams(det),
                                    GetCurrentBackgroundParams(det),
                                    GetAcquireIsotopics(acq),
                                    acq,
                                    GetCurrentHVCalibrationParams(det));
            det.Id.source = acq.data_src;  // set the detector overall data source value here

            // create the context holder for the measurement. Everything is rooted here ...
            Measurement meas = new Measurement(mt, mo, CentralizedState.App.Logger(LMLoggers.AppSection.Data));

            if (det.ListMode)
            {
                // dev note: design flaw exposed by this mess here, when LM has > 1 SVR, there is no way to associate > 1 SVRs with a single detector/SR/Mult/Conn pairing
                // It should be the other way around, the Mult params for each LMMultiplicity analyzer override the single entry on the sr_parms_rec when each analyis is performed. 

                meas.AnalysisParams =  CentralizedState.App.LMBD.CountingParameters(det, applySRFromDetector:true);
                if (mo == AssaySelector.MeasurementOption.unspecified) // pure List Mode, not INCC5
                {
                    // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params
                    ApplyVSRChangesToDefaultDetector(meas);
                }
                else // it is an INCC5 analysis driven with LM data
                {
                    // check to see if detector settings are copied into an active CA entry
                    if (!meas.AnalysisParams.Exists(w => { return (w is Multiplicity) && (w as Multiplicity).Equals(det.MultiplicityParams) && w.Active; }))
                        meas.AnalysisParams.Add(det.MultiplicityParams);
                }
            }
            else
            {
                // prepare analyzer params from detector SR params
                meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(det, applySRFromDetector:false);
                if (!meas.AnalysisParams.Exists(w => { return (w is Multiplicity) && (w as Multiplicity).Equals(det.MultiplicityParams); }))
                    meas.AnalysisParams.Add(det.MultiplicityParams);
            }

            // get the INCC5 analysis methods
            meas.INCCAnalysisState = new INCCAnalysisState();
            INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type);
            AnalysisMethods am;
            bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am);
            if (found)
            {
                am.selector = sel; // gotta do this so that the equality operator is not incorrect
                meas.INCCAnalysisState.Methods = am;
            }
            else
                meas.INCCAnalysisState.Methods = new AnalysisMethods(sel);

            meas.InitializeContext();

            meas.PrepareINCCResults();

            // next: stratum not set
            List<INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();
            INCCDB.StratumDescriptor s = sl.Find(w => w.Desc.CompareTo(acq.stratum_id) == 0);
            if (s == null)
                meas.Stratum = new Stratum();
            else
                meas.Stratum = new Stratum(s.Stratum);

            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state

            // ready for insertion of methods and processing start

        }