Exemplo n.º 1
0
 private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     mp.acq.item_type = (string)((ComboBox)sender).SelectedItem;
     mp.ams = Integ.GetMethodSelections(mp.acq.detector_id, mp.acq.item_type); // unfinished, test and firm up
     if (mp.ams != null)
     {
         mp.imd = new INCCAnalysisParams.known_m_rec((INCCAnalysisParams.known_m_rec)mp.ams.GetMethodParameters(mp.am));
     }
     else
     {
         mp.imd = new INCCAnalysisParams.known_m_rec(); // not mapped, so make a new one
         mp.imd.modified = true;
     }
     kmr = (INCCAnalysisParams.known_m_rec)mp.imd;
     FieldFiller();
 }
Exemplo n.º 2
0
 private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     mp.acq.item_type = (string)((ComboBox)sender).SelectedItem;
     mp.ams           = Integ.GetMethodSelections(mp.acq.detector_id, mp.acq.item_type); // unfinished, test and firm up
     if (mp.ams != null)
     {
         mp.imd = new INCCAnalysisParams.known_m_rec((INCCAnalysisParams.known_m_rec)mp.ams.GetMethodParameters(mp.am));
     }
     else
     {
         mp.imd          = new INCCAnalysisParams.known_m_rec(); // not mapped, so make a new one
         mp.imd.modified = true;
     }
     kmr = (INCCAnalysisParams.known_m_rec)mp.imd;
     FieldFiller();
 }
Exemplo n.º 3
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;
                    }
                }
            }
        }
Exemplo n.º 4
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
        }
Exemplo n.º 5
0
        /// the details
        public void UpdateAnalysisMethodSpecifics(string detname, string mat, DB.AnalysisMethodSpecifiers db = null)
        {
            if (db == null)
                db = new DB.AnalysisMethodSpecifiers();
            var res =   // this finds the am for the given detector and acquire type
                    from am in this.DetectorMaterialAnalysisMethods
                    where (am.Key.detectorid.Equals(detname, StringComparison.OrdinalIgnoreCase) &&
                           am.Key.material.Equals(mat, StringComparison.OrdinalIgnoreCase))
                    select am;
            if (res.Count() > 0)  // now execute the select expression and test the result for existence
            {
                KeyValuePair<INCCSelector, AnalysisMethods> kv = res.First();
                AnalysisMethods sam = kv.Value;  // the descriptor instance

                IEnumerator iter = kv.Value.GetMethodEnumerator();
                while (iter.MoveNext())
                {
                    System.Tuple<AnalysisMethod, INCCAnalysisParams.INCCMethodDescriptor> md = (System.Tuple<AnalysisMethod, INCCAnalysisParams.INCCMethodDescriptor>)iter.Current;
                    if (md.Item2 == null) // case from INCC5 transfer missing params, reflects file write bugs in INCC5 code
                    {
                        NC.App.Pest.logger.TraceEvent(LogLevels.Warning, 34029, "Missing {0}'s INCC {1} {2} method parameters, adding default values", detname, kv.Key.material, md.Item1.FullName());
                        //OK, there is probably smarter way of doing ths, but for now, does find the nulls, then add default params where necessary. hn 9.23.2015
                        if (md.Item2 == null)
                        {
                            INCCAnalysisParams.INCCMethodDescriptor rec = new INCCAnalysisParams.INCCMethodDescriptor();
                            switch (md.Item1)
                            {
                                case AnalysisMethod.Active:
                                    rec = new INCCAnalysisParams.active_rec();
                                    break;
                                case AnalysisMethod.ActiveMultiplicity:
                                    rec = new INCCAnalysisParams.active_mult_rec();
                                    break;
                                case AnalysisMethod.ActivePassive:
                                    rec = new INCCAnalysisParams.active_passive_rec();
                                    break;
                                case AnalysisMethod.AddASource:
                                    rec = new INCCAnalysisParams.add_a_source_rec();
                                    break;
                                case AnalysisMethod.CalibrationCurve:
                                    rec = new INCCAnalysisParams.cal_curve_rec();
                                    break;
                                case AnalysisMethod.Collar:
                                    rec = new INCCAnalysisParams.collar_combined_rec();
                                    break;
                                case AnalysisMethod.CuriumRatio:
                                    rec = new INCCAnalysisParams.curium_ratio_rec();
                                    break;
                                case AnalysisMethod.KnownA:
                                    rec = new INCCAnalysisParams.known_alpha_rec();
                                    break;
                                case AnalysisMethod.KnownM:
                                    rec = new INCCAnalysisParams.known_m_rec();
                                    break;
                                case AnalysisMethod.Multiplicity:
                                    rec = new INCCAnalysisParams.multiplicity_rec();
                                    break;
                                case AnalysisMethod.TruncatedMultiplicity:
                                    rec = new INCCAnalysisParams.truncated_mult_rec();
                                    break;
                                case AnalysisMethod.DUAL_ENERGY_MULT_SAVE_RESTORE:
                                    rec = new INCCAnalysisParams.de_mult_rec();
                                    break;
                                default:
                                    break;
                            }
                            sam.AddMethod(md.Item1, rec);
                        }
                        continue;
                    }

                    NC.App.Pest.logger.TraceEvent(LogLevels.Verbose, 34030, "Updating {0},{1} {2}", detname, mat, md.Item2.GetType().Name);
                    DB.ElementList parms = null;
                    bool bonk = false;
                    switch (md.Item1)
                    {
                        case AnalysisMethod.KnownA:
                        case AnalysisMethod.CalibrationCurve:
                        case AnalysisMethod.KnownM:
                        case AnalysisMethod.Multiplicity:
                        case AnalysisMethod.TruncatedMultiplicity:
                        case AnalysisMethod.AddASource:
                        case AnalysisMethod.CuriumRatio:
                        case AnalysisMethod.Active:
                        case AnalysisMethod.ActivePassive:
                        case AnalysisMethod.ActiveMultiplicity:
                        case AnalysisMethod.DUAL_ENERGY_MULT_SAVE_RESTORE:
                            parms = (md.Item2).ToDBElementList();
                            break;
                        case AnalysisMethod.Collar:  // bad mojo with the design break here
                            parms = (md.Item2).ToDBElementList();
                            db.UpdateCalib(detname, mat, parms.OptTable, parms);
                            parms = (md.Item2).ToDBElementList();
                            db.UpdateCalib(detname, mat, parms.OptTable, parms);
                            parms = (md.Item2).ToDBElementList();
                            db.UpdateCalib(detname, mat, parms.OptTable, parms);
                            parms = null; bonk = false;  // skip the final processing step below
                            break;
                        default:
                            bonk = true;
                            break;
                    }
                    if (parms != null)
                        db.UpdateCalib(detname, mat, md.Item2.GetType().Name, parms);  // det, mat, amid, params
                    else if (bonk)
                    {
                        //Didn't exist, so create and store. hn 9.22.2015
                        sam.AddMethod(md.Item1, md.Item2);
                    }
                }
            }
        }
Exemplo n.º 6
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
        }