protected Section ConstructReportSection(INCCTestDataSection section, MeasOptionSelector moskey, Detector det) { INCCTestDataStyle sec = null; try { switch (section) { case INCCTestDataSection.CyclesWithMultiplicityDistributions: sec = new INCCTestDataStyle(null, 0, INCCStyleSection.ReportSection.MultiColumn); //Singles 1st Scaler 2nd Scaler Reals + Accidentals Accidentals int[] crdwidths = new int[] { 10, 10, 10, 10, 10 }; int[] srawidths = new int[] { 12, 12 }; foreach (Cycle cyc in meas.Cycles) { // if no results on the cycle, these map indexers throw if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; sec.AddColumnRow( new ulong[] { (ulong)mcr.Totals, (ulong)mcr.Scaler1.v, (ulong)mcr.Scaler2.v, (ulong)mcr.RASum, (ulong)mcr.ASum }, crdwidths); int minbin, maxbin; minbin = Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length); maxbin = Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length); sec.AddOne(maxbin); for (int i = 0; i < minbin; i++) { sec.AddColumnRow(new ulong[] { mcr.RAMult[i], mcr.NormedAMult[i] }, srawidths); } for (int i = minbin; i < maxbin; i++) // check for uneven column { ulong[] potential = new ulong[2]; if (i < mcr.RAMult.Length) { potential[0] = mcr.RAMult[i]; } if (i < mcr.NormedAMult.Length) { potential[1] = mcr.NormedAMult[i]; } sec.AddColumnRow(potential, srawidths); } } } break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return(sec); }
public void GenerateReport(Measurement m) { if (N.App.Opstate.IsAbortRequested) // handle stop, cancel, abort here, for stop does it roll back all report gen from here? { return; } IEnumerator iter = m.INCCAnalysisResults.GetMeasSelectorResultsEnumerator(); while (iter.MoveNext()) { MeasOptionSelector moskey = (MeasOptionSelector)iter.Current; // create one results for each SR key StartReportGeneration(m, m.MeasOption.PrintName() + " INCC " + (m.INCCAnalysisResults.Count > 1 ? "[" + moskey.MultiplicityParams.ShortName() + "] " : ""), // add an identifying signature to each file name if more than one active virtual SR ' ', "dat"); // make these text files with .dat suffix //Detector det = meas.Detectors.GetIt(moskey.SRParams); // now assuming only one detector on the list, so can use [0] Detector det = meas.Detectors[0]; try { sections.Add(ConstructReportSection(INCCTestDataSection.CycleSummary, det, moskey)); sections.Add(ConstructReportSection(INCCTestDataSection.CyclesWithMultiplicityDistributions, moskey, det)); sections.RemoveAll(s => (s == null)); // copy all section rows to the report row list (t.rows) int rowcount = 0; foreach (Section sec in sections) { rowcount += sec.Count; } Array.Resize(ref t.rows, rowcount); int idx = 0; foreach (Section sec in sections) { Array.Copy(sec.ToArray(), 0, t.rows, idx, sec.Count); idx += sec.Count; } } catch (Exception e) { ctrllog.TraceException(e); } FinishReportGeneration(); } }
internal static unsafe iresultsbase MovePrecision(INCCResults ir, MeasOptionSelector mos) { results_precision_rec res = new results_precision_rec(); INCCResult results; bool found = ir.TryGetValue(mos, out results); if (found) { INCCResults.results_precision_rec t = (INCCResults.results_precision_rec)results; StatePack(t.pass, res.prec_pass_fail); res.chi_sq_lower_limit = t.chiSqLowerLimit; res.chi_sq_upper_limit = t.chiSqUpperLimit; res.prec_chi_sq = t.precChiSq; res.prec_sample_var = t.precSampleVar; res.prec_theoretical_var = t.precTheoreticalVar; } return res; }
internal static unsafe iresultsbase MoveKnownM(INCCAnalysisState ias, MeasOptionSelector mos) { results_known_m_rec res = new results_known_m_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.KnownM, out result); if (found) { INCCMethodResults.results_known_m_rec m = (INCCMethodResults.results_known_m_rec)result; res.km_mult = m.mult; res.km_alpha = m.alpha; res.km_pu239e_mass = m.pu239e_mass; res.km_pu240e_mass = m.pu240e_mass.v; res.km_pu240e_mass_err = m.pu240e_mass.err; res.km_pu_mass = m.pu_mass.v; res.km_pu_mass_err = m.pu_mass.err; res.km_dcl_pu240e_mass = m.dcl_pu240e_mass; res.km_dcl_minus_asy_pu_mass = m.dcl_minus_asy_pu_mass.v; res.km_dcl_minus_asy_pu_mass_err = m.dcl_minus_asy_pu_mass.err; res.km_dcl_minus_asy_pu_mass_pct = m.dcl_minus_asy_pu_mass_pct; StatePack(m.pass, res.km_pass_fail); res.km_sf_rate_res = m.methodParams.sf_rate; res.km_vs1_res = m.methodParams.vs1; res.km_vs2_res = m.methodParams.vs2; res.km_vi1_res = m.methodParams.vi1; res.km_vi2_res = m.methodParams.vi2; res.km_b_res = m.methodParams.b; res.km_c_res = m.methodParams.c; res.km_sigma_x_res = m.methodParams.sigma_x; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.km_known_m_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.km_known_m_item_type); } return res; }
internal static unsafe iresultsbase MoveInitSrc(INCCResults ir, MeasOptionSelector mos) { results_init_src_rec res = new results_init_src_rec(); INCCResult results; bool found = ir.TryGetValue(mos, out results); if (found) { INCCResults.results_init_src_rec t = (INCCResults.results_init_src_rec)results; res.init_src_mode = NewToOldBiasTestId(t.mode); StatePack(t.pass, res.init_src_pass_fail); StrToBytes(INCC.SOURCE_ID_LENGTH,t.init_src_id, res.init_src_id); } return res; }
internal static unsafe iresultsbase MoveCurium(INCCAnalysisState ias, MeasOptionSelector mos) { results_curium_ratio_rec res = new results_curium_ratio_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.CuriumRatio, out result); if (found) { INCCMethodResults.results_curium_ratio_rec m = (INCCMethodResults.results_curium_ratio_rec)result; res.cr_pu240e_mass = m.pu.pu240e_mass.v; res.cr_pu240e_mass_err = m.pu.pu240e_mass.err; res.cr_cm_mass = m.cm_mass.v; res.cr_cm_mass_err = m.cm_mass.err; res.cr_pu_mass = m.pu.mass.v; res.cr_pu_mass_err = m.pu.mass.err; res.cr_u_mass = m.u.mass.v; res.cr_u_mass_err = m.u.mass.err; res.cr_u235_mass = m.u235.mass.v; res.cr_u235_mass_err = m.u235.mass.err; res.cr_dcl_pu_mass = m.pu.dcl_mass; res.cr_dcl_minus_asy_pu_mass = m.pu.dcl_minus_asy_mass.v; res.cr_dcl_minus_asy_pu_mass_err = m.pu.dcl_minus_asy_mass.err; res.cr_dcl_minus_asy_pu_mass_pct = m.pu.dcl_minus_asy_mass_pct; res.cr_dcl_minus_asy_u_mass = m.u235.dcl_minus_asy_mass.v; res.cr_dcl_minus_asy_u_mass_err = m.u235.dcl_minus_asy_mass.err; res.cr_dcl_minus_asy_u_mass_pct = m.u235.dcl_minus_asy_mass_pct; res.cr_dcl_minus_asy_u235_mass = m.u235.dcl_minus_asy_mass.v; res.cr_dcl_minus_asy_u235_mass_err = m.u235.dcl_minus_asy_mass.err; res.cr_dcl_minus_asy_u235_mass_pct = m.u235.dcl_minus_asy_mass_pct; StatePack(m.pu.pass, res.cr_pu_pass_fail); StatePack(m.u.pass, res.cr_u_pass_fail); res.cr_cm_pu_ratio = m.methodParams2.cm_pu_ratio.v; res.cr_cm_pu_ratio_err = m.methodParams2.cm_pu_ratio.err; res.cr_pu_half_life = m.methodParams2.pu_half_life; byte[] b = new byte[INCC.DATE_TIME_LENGTH]; char[] a = m.methodParams2.cm_pu_ratio_date.ToString("yy.MM.dd").ToCharArray(); Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0); TransferUtils.Copy(b, res.cr_cm_pu_ratio_date); res.cr_cm_u_ratio = m.methodParams2.cm_u_ratio.v; res.cr_cm_u_ratio = m.methodParams2.cm_u_ratio.err; a = m.methodParams2.cm_u_ratio_date.ToString("yy.MM.dd").ToCharArray(); Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0); TransferUtils.Copy(b, res.cr_cm_u_ratio_date); StrToBytes(INCC.MAX_ITEM_ID_LENGTH, m.methodParams2.cm_id_label, res.cr_cm_id_label); StrToBytes(INCC.MAX_ITEM_ID_LENGTH, m.methodParams2.cm_id, res.cr_cm_id); StrToBytes(INCC.MAX_ITEM_ID_LENGTH, m.methodParams2.cm_input_batch_id, res.cr_cm_input_batch_id); res.cr_dcl_u_mass_res = m.methodParams2.cm_dcl_u_mass; res.cr_dcl_u235_mass_res = m.methodParams2.cm_dcl_u_mass; res.cr_cm_pu_ratio_decay_corr = m.cm_pu_ratio_decay_corr.v; res.cr_cm_pu_ratio_decay_corr_err = m.cm_pu_ratio_decay_corr.err; res.cr_cm_u_ratio_decay_corr = m.cm_u_ratio_decay_corr.v; res.cr_cm_u_ratio_decay_corr_err = m.cm_u_ratio_decay_corr.err; res.cr_curium_ratio_equation = (byte)m.methodParams.cev.cal_curve_equation; res.cr_a_res = m.methodParams.cev.a; res.cr_b_res = m.methodParams.cev.b; res.cr_c_res = m.methodParams.cev.c; res.cr_d_res = m.methodParams.cev.d; res.cr_covar_ab_res = m.methodParams.cev.covar(Coeff.a, Coeff.b); res.cr_covar_ac_res = m.methodParams.cev.covar(Coeff.a, Coeff.c); res.cr_covar_ad_res = m.methodParams.cev.covar(Coeff.a, Coeff.d); res.cr_covar_bc_res = m.methodParams.cev.covar(Coeff.b, Coeff.c); res.cr_covar_bd_res = m.methodParams.cev.covar(Coeff.b, Coeff.d); res.cr_covar_cd_res = m.methodParams.cev.covar(Coeff.c, Coeff.d); res.cr_var_a_res = m.methodParams.cev.var_a; res.cr_var_b_res = m.methodParams.cev.var_b; res.cr_var_c_res = m.methodParams.cev.var_c; res.cr_var_d_res = m.methodParams.cev.var_d; res.cr_sigma_x_res = m.methodParams.cev.sigma_x; res.curium_ratio_type_res = NewToOldCRVariants(m.methodParams.curium_ratio_type); StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.cr_curium_ratio_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.cr_curium_ratio_item_type); } return res; }
internal static unsafe iresultsbase MoveCalCurve(INCCAnalysisState ias, MeasOptionSelector mos) { results_cal_curve_rec res = new results_cal_curve_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.CalibrationCurve, out result); if (found) { INCCMethodResults.results_cal_curve_rec m = (INCCMethodResults.results_cal_curve_rec)result; res.cc_pu240e_mass = m.pu240e_mass.v; res.cc_pu240e_mass_err = m.pu240e_mass.err; res.cc_pu_mass = m.pu_mass.v; res.cc_pu_mass_err = m.pu_mass.err; res.cc_dcl_pu240e_mass = m.dcl_pu240e_mass; res.cc_dcl_pu_mass = m.dcl_pu_mass; res.cc_dcl_minus_asy_pu_mass = m.dcl_minus_asy_pu_mass.v; res.cc_dcl_minus_asy_pu_mass_err = m.dcl_minus_asy_pu_mass.err; res.cc_dcl_minus_asy_pu_mass_pct = m.dcl_minus_asy_pu_mass_pct; StatePack(m.pass, res.cc_pass_fail); res.cc_dcl_u_mass = m.dcl_u_mass; res.cc_length = m.length; res.cc_heavy_metal_content = m.heavy_metal_content; res.cc_heavy_metal_correction = m.heavy_metal_correction; res.cc_heavy_metal_corr_singles = m.heavy_metal_corr_singles.v; res.cc_heavy_metal_corr_singles_err = m.heavy_metal_corr_singles.err; res.cc_heavy_metal_corr_doubles = m.heavy_metal_corr_doubles.v; res.cc_heavy_metal_corr_doubles_err = m.heavy_metal_corr_doubles.err; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.cc_cal_curve_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.cc_cal_curve_item_type); res.cc_a_res = m.methodParams.cev.a; res.cc_b_res = m.methodParams.cev.b; res.cc_c_res = m.methodParams.cev.c; res.cc_d_res = m.methodParams.cev.d; res.cc_cal_curve_type_res = (double)m.methodParams.CalCurveType; res.cc_covar_ab_res = m.methodParams.cev.covar(Coeff.a, Coeff.b); res.cc_covar_ac_res = m.methodParams.cev.covar(Coeff.a, Coeff.c); res.cc_covar_ad_res = m.methodParams.cev.covar(Coeff.a, Coeff.d); res.cc_covar_bc_res = m.methodParams.cev.covar(Coeff.b, Coeff.c); res.cc_covar_bd_res = m.methodParams.cev.covar(Coeff.b, Coeff.d); res.cc_covar_cd_res = m.methodParams.cev.covar(Coeff.c, Coeff.d); res.cc_var_a_res = m.methodParams.cev.var_a; res.cc_var_b_res = m.methodParams.cev.var_b; res.cc_var_c_res = m.methodParams.cev.var_c; res.cc_var_d_res = m.methodParams.cev.var_d; res.cc_sigma_x_res = m.methodParams.cev.sigma_x; res.cc_heavy_metal_corr_factor_res = m.methodParams.heavy_metal_corr_factor; res.cc_heavy_metal_reference_res = m.methodParams.heavy_metal_reference; res.cc_percent_u235_res = m.methodParams.percent_u235; } return res; }
protected Section ConstructReportSection(INCCReportSection section, Detector det, MeasOptionSelector moskey = null) { INCCStyleSection sec = null; try { switch (section) { case INCCReportSection.Header: sec = new INCCStyleSection(null, 1); sec.AddHeader(N.App.Name + " " + N.App.Config.VersionString); // section header break; case INCCReportSection.Context: sec = new INCCStyleSection(null, 1); ConstructContextContent(sec, det); break; case INCCReportSection.Isotopics: if (AssaySelector.ForMass(meas.MeasOption)) { sec = new INCCStyleSection(null, 1); sec.SetFPCurrentFormatPrecision(4); Isotopics curiso = Isotopics.update_isotopics(1.0, meas.MeasDate, meas.Isotopics, meas.logger, N.App.AppContext.INCCParity); if (curiso == null) { curiso = new Isotopics(); meas.Isotopics.CopyTo(curiso); ctrllog.TraceEvent(LogLevels.Warning, 82034, "Using incorrect updated defaults for " + meas.Isotopics.id); } sec.AddTwo("Isotopics id:", meas.Isotopics.id); sec.AddTwo("Isotopics source code:", meas.Isotopics.source_code.ToString()); sec.AddDualNumericRow("Pu238:", meas.Isotopics[Isotope.pu238], curiso[Isotope.pu238]); sec.AddDualNumericRow("Pu239:", meas.Isotopics[Isotope.pu239], curiso[Isotope.pu239]); sec.AddDualNumericRow("Pu240:", meas.Isotopics[Isotope.pu240], curiso[Isotope.pu240]); sec.AddDualNumericRow("Pu241:", meas.Isotopics[Isotope.pu241], curiso[Isotope.pu241]); sec.AddDualNumericRow("Pu242:", meas.Isotopics[Isotope.pu242], curiso[Isotope.pu242]); sec.AddDualDateOnlyRow("Pu date:", meas.Isotopics.pu_date, curiso.pu_date); sec.AddDualNumericRow("Am241:", meas.Isotopics[Isotope.am241], curiso[Isotope.am241]); sec.AddDualDateOnlyRow("Am date:", meas.Isotopics.am_date, curiso.am_date); // dev note: here is where the alternative K vals are added in the Euratom version } break; case INCCReportSection.ShiftRegister: sec = new INCCStyleSection(null, 1); ConstructSRSection(sec, moskey.MultiplicityParams, det); break; case INCCReportSection.Adjustments: sec = new INCCStyleSection(null, 1); if (AssaySelector.ForMass(meas.MeasOption) || meas.MeasOption == AssaySelector.MeasurementOption.rates) { ushort push = sec.FPFormatPrecision; sec.SetFPCurrentFormatPrecision(4); sec.AddNumericRow("Normalization constant:", meas.Norm.currNormalizationConstant); sec.SetFPCurrentFormatPrecision(push); } if (AssaySelector.UsesBackground(meas.MeasOption)) { sec.AddNumericRow("Passive singles bkgrnd:", meas.Background.DeadtimeCorrectedSinglesRate); sec.AddNumericRow("Passive doubles bkgrnd:", meas.Background.DeadtimeCorrectedDoublesRate); sec.AddNumericRow("Passive triples bkgrnd:", meas.Background.DeadtimeCorrectedTriplesRate); if (det.Id.SRType <= InstrType.AMSR) { sec.AddNumericRow("Passive scaler1 bkgrnd:", meas.Background.Scaler1.v); sec.AddNumericRow("Passive scaler2 bkgrnd:", meas.Background.Scaler2.v); } sec.AddNumericRow("Active singles bkgrnd:", meas.Background.INCCActive.Singles); sec.AddNumericRow("Active doubles bkgrnd:", meas.Background.INCCActive.Doubles); sec.AddNumericRow("Active triples bkgrnd:", meas.Background.INCCActive.Triples); if (det.Id.SRType <= InstrType.AMSR) { sec.AddNumericRow("Passive scaler1 bkgrnd:", meas.Background.INCCActive.Scaler1Rate); sec.AddNumericRow("Passive scaler2 bkgrnd:", meas.Background.INCCActive.Scaler2Rate); } } break; case INCCReportSection.CycleSummary: sec = new INCCStyleSection(null, 1); sec.AddIntegerRow(String.Format("Number {0} cycles:", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive"), (int)meas.Cycles.GetValidCycleCountForThisKey(moskey.MultiplicityParams)); //det.MultiplicityParams)); // could also use CycleList length but CycleList can be longer when a reanalysis occurs and the analysis processing stops short of the end of the list due to modified termination conditions sec.AddNumericRow("Count time (sec):", (meas.Cycles.Count > 0 ? meas.Cycles[0].TS.TotalSeconds : 0.0)); break; case INCCReportSection.Messages: List <MeasurementMsg> sl = null; bool found = meas.Messages.TryGetValue(moskey.MultiplicityParams, out sl); if (found) { sec = new INCCStyleSection(null, 1); sec.AddHeader(String.Format("{0} messages", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected() ? "Active" : "Passive")); /// todo: is there an active messages section header analog? foreach (MeasurementMsg m in sl) { Row r = new Row(); r.Add(0, m.text); // expand to log style with toString? sec.Add(r); } } break; case INCCReportSection.Reference: sec = new INCCStyleSection(null, 1); sec.AddHeader("Counting results, summaries and cycle counts file name"); // section header Row resline = new Row(); resline.Add(0, " " + meas.ResultsFileName); sec.Add(resline); break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return(sec); }
protected Section ConstructReportSection(INCCReportSection section, Detector det, MeasOptionSelector moskey = null) { INCCStyleSection sec = null; try { switch (section) { case INCCReportSection.Header: sec = new INCCStyleSection(null, 1); sec.AddHeader(N.App.Name + " " + N.App.Config.VersionString); // section header break; case INCCReportSection.Context: sec = new INCCStyleSection(null, 1); ConstructContextContent(sec, det); break; case INCCReportSection.Isotopics: if (AssaySelector.ForMass(meas.MeasOption)) { sec = new INCCStyleSection(null, 1); sec.SetFPCurrentFormatPrecision(4); Isotopics curiso = Isotopics.update_isotopics(1.0, meas.MeasDate, meas.Isotopics, meas.logger, N.App.AppContext.INCCParity); if (curiso == null) { curiso = new Isotopics(); meas.Isotopics.CopyTo(curiso); ctrllog.TraceEvent(LogLevels.Warning, 82034, "Using incorrect updated defaults for " + meas.Isotopics.id); } sec.AddTwo("Isotopics id:", meas.Isotopics.id); sec.AddTwo("Isotopics source code:", meas.Isotopics.source_code.ToString()); sec.AddDualNumericRow("Pu238:", meas.Isotopics[Isotope.pu238], curiso[Isotope.pu238]); sec.AddDualNumericRow("Pu239:", meas.Isotopics[Isotope.pu239], curiso[Isotope.pu239]); sec.AddDualNumericRow("Pu240:", meas.Isotopics[Isotope.pu240], curiso[Isotope.pu240]); sec.AddDualNumericRow("Pu241:", meas.Isotopics[Isotope.pu241], curiso[Isotope.pu241]); sec.AddDualNumericRow("Pu242:", meas.Isotopics[Isotope.pu242], curiso[Isotope.pu242]); sec.AddDualDateOnlyRow("Pu date:", meas.Isotopics.pu_date, curiso.pu_date); sec.AddDualNumericRow("Am241:", meas.Isotopics[Isotope.am241], curiso[Isotope.am241]); sec.AddDualDateOnlyRow("Am date:", meas.Isotopics.am_date, curiso.am_date); // dev note: here is where the alternative K vals are added in the Euratom version } break; case INCCReportSection.ShiftRegister: sec = new INCCStyleSection(null, 1); ConstructSRSection(sec, moskey.MultiplicityParams, det); break; case INCCReportSection.Adjustments: sec = new INCCStyleSection(null, 1); if (AssaySelector.ForMass(meas.MeasOption) || meas.MeasOption == AssaySelector.MeasurementOption.rates) { ushort push = sec.FPFormatPrecision; sec.SetFPCurrentFormatPrecision(4); sec.AddNumericRow("Normalization constant:", meas.Norm.currNormalizationConstant); sec.SetFPCurrentFormatPrecision(push); } if (AssaySelector.UsesBackground(meas.MeasOption)) { sec.AddNumericRow("Passive singles bkgrnd:", meas.Background.DeadtimeCorrectedSinglesRate); sec.AddNumericRow("Passive doubles bkgrnd:", meas.Background.DeadtimeCorrectedDoublesRate); sec.AddNumericRow("Passive triples bkgrnd:", meas.Background.DeadtimeCorrectedTriplesRate); if (det.Id.SRType <= InstrType.AMSR) { sec.AddNumericRow("Passive scaler1 bkgrnd:", meas.Background.Scaler1.v); sec.AddNumericRow("Passive scaler2 bkgrnd:", meas.Background.Scaler2.v); } sec.AddNumericRow("Active singles bkgrnd:", meas.Background.INCCActive.Singles); sec.AddNumericRow("Active doubles bkgrnd:", meas.Background.INCCActive.Doubles); sec.AddNumericRow("Active triples bkgrnd:", meas.Background.INCCActive.Triples); if (det.Id.SRType <= InstrType.AMSR) { sec.AddNumericRow("Passive scaler1 bkgrnd:", meas.Background.INCCActive.Scaler1Rate); sec.AddNumericRow("Passive scaler2 bkgrnd:", meas.Background.INCCActive.Scaler2Rate); } } break; case INCCReportSection.CycleSummary: sec = new INCCStyleSection(null, 1); sec.AddIntegerRow(String.Format("Number {0} cycles:",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive"), (int)meas.Cycles.GetValidCycleCountForThisKey(moskey.MultiplicityParams)); //det.MultiplicityParams)); // could also use CycleList length but CycleList can be longer when a reanalysis occurs and the analysis processing stops short of the end of the list due to modified termination conditions sec.AddNumericRow("Count time (sec):", (meas.Cycles.Count > 0 ? meas.Cycles[0].TS.TotalSeconds : 0.0)); break; case INCCReportSection.Messages: List<MeasurementMsg> sl = null; bool found = meas.Messages.TryGetValue(moskey.MultiplicityParams, out sl); if (found) { sec = new INCCStyleSection(null, 1); sec.AddHeader(String.Format("{0} messages", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected() ? "Active" : "Passive")); /// todo: is there an active messages section header analog? foreach (MeasurementMsg m in sl) { Row r = new Row(); r.Add(0, m.text); // expand to log style with toString? sec.Add(r); } } break; case INCCReportSection.Reference: sec = new INCCStyleSection(null, 1); sec.AddHeader("Counting results, summaries and cycle counts file name"); // section header Row resline = new Row(); resline.Add(0, " " + meas.ResultsFileName); sec.Add(resline); break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }
/// <summary> /// Save in the database the summary <see cref="INCCResults.results_rec"/> results for every type of INCC measurement. /// </summary> /// <param name="m">The measurement to preserve</param> /// <param name="moskey">The option selector+multiplicity key for the method results map</param> static void SaveSummaryResultsForThisMeasurement(this Measurement m, MeasOptionSelector moskey) { DB.Measurements ms = new DB.Measurements(); long mid = ms.Lookup(m.Detectors[0].Id.DetectorName, m.MeasDate, m.MeasOption.PrintName()); DB.Results dbres = new DB.Results(ms.db); // save results with mid as foreign key bool b = dbres.Update(mid, m.INCCAnalysisResults.TradResultsRec.ToDBElementList()); m.Logger.TraceEvent(NCCReporter.LogLevels.Info, 34045, (b ? "Preserved " : "Failed to save ") + "summary results"); }
/// <summary> /// Save all updated and new results in the database /// </summary> public static void SaveMeasurementResults(this Measurement meas) { SaveMeasurementCycles(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 moskey = new MeasOptionSelector(meas.MeasOption, mkey); bool found = meas.INCCAnalysisResults.TryGetValue(moskey, out results); try { switch (meas.MeasOption) { case AssaySelector.MeasurementOption.background: // calculated in CalculateResults, update bkg and save the result to the DB // save the background result to the bkg_parms_rec table under the current SR key BackgroundParameters c = NC.App.DB.BackgroundParameters.Get(meas.Detectors[0]); if (c != null) c.Copy(meas.Background); // copy changes back to original on user affirmation else { c = meas.Background; NC.App.DB.BackgroundParameters.GetMap().Add(meas.Detectors[0], c); } NC.App.DB.BackgroundParameters.Set(meas.Detectors[0], c); break; case AssaySelector.MeasurementOption.initial: // calculated in CalculateResults, update norm and save the norm and init_src result to the DB INCCResults.results_init_src_rec results_init_src = (INCCResults.results_init_src_rec)results; // 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 updated. if (results_init_src.pass) { NormParameters np = NC.App.DB.NormParameters.Get(meas.Detectors[0]); if (np != null) np.Copy(meas.Norm); // copy any changes made to Norm as defined for the current detector else { np = meas.Norm; NC.App.DB.NormParameters.GetMap().Add(meas.Detectors[0], np); } NC.App.DB.NormParameters.Set(meas.Detectors[0], np); } SaveSpecificResultsForThisMeasurement(meas, results); break; case AssaySelector.MeasurementOption.normalization: // calculated in CalculateResults, now save the result to the DB case AssaySelector.MeasurementOption.precision: // ditto SaveSpecificResultsForThisMeasurement(meas, results); break; case AssaySelector.MeasurementOption.calibration: // ditto with the method analyses results, but they're a bit different case AssaySelector.MeasurementOption.verification: SaveMethodResultsForThisMeasurement(meas, moskey); break; case AssaySelector.MeasurementOption.holdup: // NEXT: Hold-up held up, implement it #102 break; } } catch (Exception e) { meas.Logger.TraceException(e); } SaveSummaryResultsForThisMeasurement(meas, moskey); } meas.PersistFileNames(); }
protected Section ConstructReportSection(INCCTestDataSection section, Detector det, MeasOptionSelector moskey = null) { INCCTestDataStyle sec = null; try { switch (section) { case INCCTestDataSection.CycleSummary: sec = new INCCTestDataStyle(null, 0); sec.AddOne((Int32)meas.Cycles.GetValidCycleCountForThisKey(moskey.MultiplicityParams)); // could also use CycleList length but CycleList can be longer when a reanalysis occurs and the analysis processing stops short of the end of the list due to modified termination conditions sec.AddOne((Int32)(meas.Cycles.Count > 0 ? meas.Cycles[0].TS.TotalSeconds : 0.0)); break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return(sec); }
protected Section ConstructReportSection(INCCReportSection section, MeasOptionSelector moskey, INCCResult ir, Detector det) { INCCStyleSection sec = null; try { switch (section) { // NEXT: in progress, an identical copy of full INCC report sections case INCCReportSection.SummedRawData: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.Summary); sec.SetFPCurrentFormatPrecision(0); sec.AddHeader(String.Format("{0} summed raw data", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header sec.AddNumericRow("Shift register singles sum:", meas.SinglesSum); sec.AddNumericRow("Shift register reals + accidentals sum:", ir.RASum); sec.AddNumericRow("Shift register accidentals sum:", ir.ASum); if (!det.Id.source.UsingVirtualSRCounting(det.Id.SRType)) { sec.AddNumericRow("Shift register 1st scaler sum:", ir.S1Sum); sec.AddNumericRow("Shift register 2nd scaler sum:", ir.S2Sum); } break; case INCCReportSection.SummedRA: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} summed multiplicity distributions", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header int[] srawidths = new int[] { 5, 12, 12 }; int minbin, maxbin; minbin = Math.Min(ir.RAMult.Length, ir.NormedAMult.Length); maxbin = Math.Max(ir.RAMult.Length, ir.NormedAMult.Length); sec.AddColumnRowHeader(new string[] { " ", "R+A sums", "A sums" }, srawidths); for (int i = 0; i < minbin; i++) { sec.AddColumnRow(new ulong[] { (ulong)i, ir.RAMult[i], ir.NormedAMult[i] }, srawidths); } for (int i = minbin; i < maxbin; i++) // check for uneven column { ulong[] potential = new ulong[3]; potential[0] = (ulong)i; if (i < ir.RAMult.Length) { potential[1] = ir.RAMult[i]; } if (i < ir.NormedAMult.Length) { potential[2] = ir.NormedAMult[i]; } sec.AddColumnRow(potential, srawidths); } break; case INCCReportSection.MassResults: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MethodResults); //Results are not always passive. Boo. sec.AddHeader(String.Format("{0} Results", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header sec.AddNumericRow("Singles:", ir.DeadtimeCorrectedSinglesRate); sec.AddNumericRow("Doubles:", ir.DeadtimeCorrectedDoublesRate); sec.AddNumericRow("Triples:", ir.DeadtimeCorrectedTriplesRate); //changed to DTC rates. Raw rates meaningless here hn 11.5.2014 //sec.AddNumericRow("Quads:", mcr.DeadtimeCorrectedQuadsRate); // todo: quads delayed until pents are ready per DN if (!det.Id.source.UsingVirtualSRCounting(det.Id.SRType)) { sec.AddNumericRow("Scaler 1:", ir.Scaler1); sec.AddNumericRow("Scaler 2:", ir.Scaler2); } //if (det.Id.SRType >= LMDAQ.InstrType.NPOD) //{ // sec.Add(new Row()); // blank line // sec.AddNumericRow("Dyt. Singles:", ir.DytlewskiCorrectedSinglesRate); // sec.AddNumericRow("Dyt. Doubles:", ir.DytlewskiCorrectedDoublesRate); // sec.AddNumericRow("Dyt. Triples:", ir.DytlewskiCorrectedTriplesRate); //} break; case INCCReportSection.MethodResultsAndParams: // 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 List <Row> rl = ir.ToLines(meas); sec = new INCCStyleSection(null, 0, INCCStyleSection.ReportSection.MethodResults); sec.AddRange(rl); switch (meas.MeasOption) { case AssaySelector.MeasurementOption.background: if (meas.Background.TMBkgParams.ComputeTMBkg) { ctrllog.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: break; case AssaySelector.MeasurementOption.verification: case AssaySelector.MeasurementOption.calibration: { INCCMethodResults imrs; bool beendonegot = meas.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrs); if (beendonegot && imrs.Count > 0) // should be true for verification and calibration { // 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()) { INCCMethodResult imr = ai.Current.Value; // show the primaryMethod if (ai.Current.Key.Equals(imrs.primaryMethod)) { sec.Add(new Row()); Row rh = new Row(); rh.Add(0, " PRIMARY RESULT"); sec.Add(rh); } rl = imr.ToLines(meas); sec.AddRange(rl); // todo: optional use of END_PRIMARY_RESULT as in some INCC report formats, but not others } } } break; case AssaySelector.MeasurementOption.rates: case AssaySelector.MeasurementOption.holdup: case AssaySelector.MeasurementOption.unspecified: default: // nothing new to present with these break; } break; case INCCReportSection.RawCycles: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} cycle raw data", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header int[] crdwidths = new int[] { 5, 10, 10, 10, 10, 10, 10 }; sec.AddColumnRowHeader(new string[] { "Cycle", "Singles", "R+A ", "A ", "Scaler1", "Scaler2", "QC Tests" }, crdwidths); foreach (Cycle cyc in meas.Cycles) { // if no results on the cycle, these map indexers throw if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; sec.AddCycleColumnRow(cyc.seq, new ulong[] { (ulong)mcr.Totals, (ulong)mcr.RASum, (ulong)mcr.ASum, (ulong)mcr.Scaler1.v, (ulong)mcr.Scaler2.v }, meas.AcquireState.qc_tests?cyc.QCStatus(moskey.MultiplicityParams).INCCString():"Off", crdwidths); } } break; case INCCReportSection.DTCRateCycles: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} cycle DTC rate data", meas.AcquireState.well_config == WellConfiguration.Active?"Active":"Passive")); // section header int[] crawidths = new int[] { 5, 13, 13, 13, 13, 10 }; sec.AddColumnRowHeader(new string[] { "Cycle", "Singles", "Doubles", "Triples", "Mass", "QC Tests" }, crawidths); foreach (Cycle cyc in meas.Cycles) { if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; //These debug rows show raw rates for comparison hn 10.30 //sec.AddCycleColumnRow(cyc.seq, //Again, could be wrong. // new double[] { mcr.RawSinglesRate.v, mcr.RawDoublesRate.v, -1, -1 }, // cyc.QCStatus(moskey.MultiplicityParams).INCCString(), crawidths); //Again, could be wrong. // TODO: Am actually printing out the DTC rates per cycle. This seems to work in all cases EXCEPT "precision" hn 11.5 sec.AddCycleColumnRow(cyc.seq, // Using the corrected rates! new double[] { mcr.DeadtimeCorrectedSinglesRate.v, mcr.DeadtimeCorrectedDoublesRate.v, mcr.DeadtimeCorrectedTriplesRate.v, mcr.mass /*Mass*/ }, meas.AcquireState.qc_tests?cyc.QCStatus(moskey.MultiplicityParams).INCCString():"Off", crawidths); } } break; case INCCReportSection.MultiplicityDistributions: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} multiplicity distributions for each cycle", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header int[] csrawidths = new int[] { 6, 12, 12 }; foreach (Cycle cyc in meas.Cycles) { if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; minbin = Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length); maxbin = Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length); sec.AddColumnRowHeader(new string[] { "Cycle " + cyc.seq, "R+A ", "A " }, csrawidths); for (int i = 0; i < minbin; i++) { sec.AddColumnRow(new ulong[] { (ulong)i, mcr.RAMult[i], mcr.NormedAMult[i] }, csrawidths); } for (int i = minbin; i < maxbin; i++) // check for uneven column { ulong[] potential = new ulong[3]; potential[0] = (ulong)i; if (i < mcr.RAMult.Length) { potential[1] = mcr.RAMult[i]; } if (i < mcr.NormedAMult.Length) { potential[2] = mcr.NormedAMult[i]; } sec.AddColumnRow(potential, csrawidths); } } sec.Add(new Row()); // blank } break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return(sec); }
public void GenerateReport(Measurement m) { if (N.App.Opstate.IsAbortRequested) // handle stop, cancel, abort here, for stop does it roll back all report gen from here? { return; } IEnumerator iter = m.INCCAnalysisResults.GetMeasSelectorResultsEnumerator(); while (iter.MoveNext()) { MeasOptionSelector moskey = (MeasOptionSelector)iter.Current; INCCResult ir = m.INCCAnalysisResults[moskey]; // create one results for each SR key StartReportGeneration(m, m.MeasOption.PrintName() + " INCC " + (m.INCCAnalysisResults.Count > 1 ? "[" + moskey.MultiplicityParams.ShortName() + "] " : ""), // add an identifying signature to each file name if more than one active virtual SR ' '); // make these text files //Detector det = meas.Detectors.GetIt(moskey.SRParams); // now assuming only one detector on the list, so can use [0], the mos keys have specific values for virtual SR counting, overiding the detector Detector det = meas.Detectors[0]; try { sections.Add(ConstructReportSection(INCCReportSection.Header, det)); sections.Add(ConstructReportSection(INCCReportSection.Context, det)); sections.Add(ConstructReportSection(INCCReportSection.Isotopics, det)); sections.Add(ConstructReportSection(INCCReportSection.ShiftRegister, det, moskey)); sections.Add(ConstructReportSection(INCCReportSection.Adjustments, det)); sections.Add(ConstructReportSection(INCCReportSection.CycleSummary, det, moskey)); sections.Add(ConstructReportSection(INCCReportSection.Messages, det, moskey)); sections.Add(ConstructReportSection(INCCReportSection.SummedRawData, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.SummedRA, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.MassResults, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.MethodResultsAndParams, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.RawCycles, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.DTCRateCycles, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.MultiplicityDistributions, moskey, ir, det)); sections.Add(ConstructReportSection(INCCReportSection.Reference, det)); sections.RemoveAll(s => (s == null)); // copy all section rows to the report row list (t.rows) int rowcount = 0; foreach (Section sec in sections) { rowcount += sec.Count; } Array.Resize(ref t.rows, rowcount); int idx = 0; foreach (Section sec in sections) { Array.Copy(sec.ToArray(), 0, t.rows, idx, sec.Count); idx += sec.Count; } } catch (Exception e) { ctrllog.TraceException(e); } FinishReportGeneration(); } }
internal static unsafe iresultsbase MoveTruncMult(INCCAnalysisState ias, MeasOptionSelector mos) { results_truncated_mult_rec res = new results_truncated_mult_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.TruncatedMultiplicity, out result); if (found) { INCCMethodResults.results_truncated_mult_rec m = (INCCMethodResults.results_truncated_mult_rec)result; res.tm_bkg_singles = m.bkg.Singles.v; res.tm_bkg_singles_err = m.bkg.Singles.err; res.tm_bkg_zeros = m.bkg.Zeros.v; res.tm_bkg_zeros_err = m.bkg.Zeros.err; res.tm_bkg_ones = m.bkg.Ones.v; res.tm_bkg_ones_err = m.bkg.Ones.err; res.tm_bkg_twos = m.bkg.Twos.v; res.tm_bkg_twos_err = m.bkg.Twos.err; res.tm_net_singles = m.net.Singles.v; res.tm_net_singles_err = m.net.Singles.err; res.tm_net_zeros = m.net.Zeros.v; res.tm_net_zeros_err = m.net.Zeros.err; res.tm_net_ones = m.net.Ones.v; res.tm_net_ones_err = m.net.Ones.err; res.tm_net_twos = m.net.Twos.v; res.tm_net_twos_err = m.net.Twos.err; res.tm_k_alpha = m.k.alpha.v; res.tm_k_alpha_err = m.k.alpha.err; res.tm_k_pu240e_mass = m.k.pu240e_mass.v; res.tm_k_pu240e_mass_err = m.k.pu240e_mass.err; res.tm_k_pu_mass = m.k.pu_mass.v; res.tm_k_pu_mass_err = m.k.pu_mass.err; res.tm_k_dcl_pu240e_mass = m.k.dcl_pu240e_mass; res.tm_k_dcl_pu_mass = m.k.dcl_pu_mass; res.tm_k_dcl_minus_asy_pu_mass = m.k.dcl_minus_asy_pu_mass.v; res.tm_k_dcl_minus_asy_pu_mass_err = m.k.dcl_minus_asy_pu_mass.err; res.tm_k_dcl_minus_asy_pu_mass_pct = m.k.dcl_minus_asy_pu_mass_pct; StatePack(m.k.pass, res.tm_k_pass_fail); res.tm_s_eff = m.s.eff.v; res.tm_s_eff_err = m.s.eff.err; res.tm_s_alpha = m.s.alpha.v; res.tm_s_alpha_err = m.s.alpha.err; res.tm_s_pu240e_mass = m.s.pu240e_mass.v; res.tm_s_pu240e_mass_err = m.s.pu240e_mass.err; res.tm_s_pu_mass = m.s.pu_mass.v; res.tm_s_pu_mass_err = m.s.pu_mass.err; res.tm_s_dcl_pu240e_mass = m.s.dcl_pu240e_mass; res.tm_s_dcl_pu_mass = m.s.dcl_pu_mass; res.tm_s_dcl_minus_asy_pu_mass = m.s.dcl_minus_asy_pu_mass.v; res.tm_s_dcl_minus_asy_pu_mass_err = m.s.dcl_minus_asy_pu_mass.err; res.tm_s_dcl_minus_asy_pu_mass_pct = m.s.dcl_minus_asy_pu_mass_pct; StatePack(m.s.pass, res.tm_s_pass_fail); res.tm_a_res = m.methodParams.a; res.tm_b_res = m.methodParams.b; res.tm_known_eff_res = (byte)(m.methodParams.known_eff ? 1 : 0); res.tm_solve_eff_res = (byte)(m.methodParams.known_eff ? 1 : 0); } return res; }
/// <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 }
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; }
/// <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); } } }
protected Section ConstructReportSection(INCCTestDataSection section, MeasOptionSelector moskey, Detector det) { INCCTestDataStyle sec = null; try { switch (section) { case INCCTestDataSection.CyclesWithMultiplicityDistributions: sec = new INCCTestDataStyle(null, 0, INCCStyleSection.ReportSection.MultiColumn); //Singles 1st Scaler 2nd Scaler Reals + Accidentals Accidentals int[] crdwidths = new int[] {10, 10, 10, 10, 10 }; int[] srawidths = new int[] { 12, 12 }; foreach (Cycle cyc in meas.Cycles) { // if no results on the cycle, these map indexers throw if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; sec.AddColumnRow( new ulong[] { (ulong)mcr.Totals, (ulong)mcr.Scaler1.v, (ulong)mcr.Scaler2.v, (ulong)mcr.RASum, (ulong)mcr.ASum }, crdwidths); int minbin, maxbin; minbin = Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length); maxbin = Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length); sec.AddOne(maxbin); for (int i = 0; i < minbin; i++) sec.AddColumnRow(new ulong[] { mcr.RAMult[i], mcr.NormedAMult[i] }, srawidths); for (int i = minbin; i < maxbin; i++) // check for uneven column { ulong[] potential = new ulong[2]; if (i < mcr.RAMult.Length) potential[0] = mcr.RAMult[i]; if (i < mcr.NormedAMult.Length) potential[1] = mcr.NormedAMult[i]; sec.AddColumnRow(potential, srawidths); } } } break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }
/// <summary> /// Save in the database the method results and copies of the current method parameters. /// The table entries are related back to the measurement. /// The method results are preserved in the results_\<method table name\> and \<method table name\>_m DB tables. /// </summary> /// <param name="m">The measurement to preserve</param> /// <param name="moskey">The option selector+multiplicity key for the method results map</param> static void SaveMethodResultsForThisMeasurement(this Measurement m, MeasOptionSelector moskey) { // DB.Measurements ms = new DB.Measurements(); long mid = m.MeasurementId.UniqueId; INCCMethodResults imrs; bool gotten = m.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrs); if (gotten && imrs.Count > 0) // expected to be true for verification and calibration { //The distinct detector id and material type index the methods and the method results Dictionary<AnalysisMethod, INCCMethodResult> amimr = imrs[m.INCCAnalysisState.Methods.selector]; // now get an enumerator over the map of method results Dictionary<AnalysisMethod, INCCMethodResult>.Enumerator ai = amimr.GetEnumerator(); while (ai.MoveNext()) { INCCMethodResult imr = ai.Current.Value; DB.ElementList els = imr.ToDBElementList(); // generates the Table property content too DB.ParamsRelatedBackToMeasurement ar = new DB.ParamsRelatedBackToMeasurement(imr.Table); long resid = ar.Create(mid, els); // save the method results in the relevant results table do { long mresid = ar.CreateMethod(resid, mid, imr.methodParams.ToDBElementList()); // save the initial method params (the copy rides on the results) m.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34104, string.Format("Method results {0} preserved ({1}, {2})", imr.Table, resid, mresid)); } while (imr.methodParams.Pump > 0); } } }
internal static unsafe iresultsbase MoveBias(INCCResults ir, MeasOptionSelector mos) { results_bias_rec res = new results_bias_rec(); INCCResult results; bool found = ir.TryGetValue(mos, out results); if (found) { INCCResults.results_bias_rec t = (INCCResults.results_bias_rec)results; res.results_bias_mode = NewToOldBiasTestId(t.mode); StatePack(t.pass, res.bias_pass_fail); StrToBytes(INCC.SOURCE_ID_LENGTH, t.sourceId, res.bias_source_id); res.bias_sngls_rate_expect = t.biasSnglsRateExpect.v; res.bias_sngls_rate_expect_err = t.biasSnglsRateExpect.err; res.bias_sngls_rate_expect_meas = t.biasSnglsRateExpectMeas.v; res.bias_sngls_rate_expect_meas_err = t.biasSnglsRateExpectMeas.err; res.bias_dbls_rate_expect = t.biasDblsRateExpect.v; res.bias_dbls_rate_expect_err = t.biasDblsRateExpect.err; res.bias_dbls_rate_expect_meas = t.biasDblsRateExpectMeas.v; res.bias_dbls_rate_expect_meas_err = t.biasDblsRateExpectMeas.err; res.new_norm_constant = t.newNormConstant.v; res.new_norm_constant_err = t.newNormConstant.err; res.required_precision = t.requiredPrecision; res.required_meas_seconds = t.requiredMeasSeconds; } return res; }
/// <summary> /// Save in the database the summary <see cref="INCCResults.results_rec"/> results for every type of INCC measurement. /// </summary> /// <param name="m">The measurement to preserve</param> /// <param name="moskey">The option selector+multiplicity key for the method results map</param> static void SaveSummaryResultsForThisMeasurement(this Measurement m, MeasOptionSelector moskey) { long mid = m.MeasurementId.UniqueId; DB.Results dbres = new DB.Results(); // save results with mid as foreign key bool b = dbres.Update(mid, m.INCCAnalysisResults.TradResultsRec.ToDBElementList()); // APluralityOfMultiplicityAnalyzers: results rec needs to be fully populated before here, or it needs to be saved again at the end of the processing m.Logger.TraceEvent(NCCReporter.LogLevels.Info, 34045, (b ? "Preserved " : "Failed to save ") + "summary results"); }
internal static unsafe iresultsbase MoveCollar(INCCAnalysisState ias, MeasOptionSelector mos) { results_collar_rec res = new results_collar_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.Collar, out result); if (found) { INCCMethodResults.results_collar_rec m = (INCCMethodResults.results_collar_rec)result; res.col_u235_mass = m.u235_mass.v; res.col_u235_mass_err = m.u235_mass.err; res.col_percent_u235 = m.percent_u235; res.col_total_u_mass = m.total_u_mass; res.col_k0 = m.k0.v; res.col_k0_err = m.k0.err; res.col_k1 = m.k1.v; res.col_k1_err = m.k1.err; res.col_k2 = m.k2.v; res.col_k2_err = m.k2.err; res.col_k3 = m.k3.v; res.col_k3_err = m.k3.err; res.col_k4 = m.k4.v; res.col_k4_err = m.k4.err; res.col_k5 = m.k5.v; res.col_k5_err = m.k5.err; res.col_total_corr_fact = m.total_corr_fact.v; res.col_total_corr_fact_err = m.total_corr_fact.err; StrToBytes(INCC.SOURCE_ID_LENGTH, m.source_id, res.col_source_id); res.col_corr_doubles = m.corr_doubles.v; res.col_corr_doubles_err = m.corr_doubles.err; res.col_dcl_length = m.dcl_length.v; res.col_dcl_length_err = m.dcl_length.err; res.col_dcl_total_u235 = m.dcl_total_u235.v; res.col_dcl_total_u235_err = m.dcl_total_u235.err; res.col_dcl_total_u238 = m.dcl_total_u238.v; res.col_dcl_total_u238_err = m.dcl_total_u238.err; res.col_dcl_total_rods = m.dcl_total_rods; res.col_dcl_total_poison_rods = m.dcl_total_poison_rods; res.col_dcl_poison_percent = m.dcl_poison_percent.v; res.col_dcl_poison_percent_err = m.dcl_poison_percent.err; res.col_dcl_minus_asy_u235_mass = m.dcl_minus_asy_u235_mass.v; res.col_dcl_minus_asy_u235_mass_err = m.dcl_minus_asy_u235_mass.err; res.col_dcl_minus_asy_u235_mass_pct = m.dcl_minus_asy_u235_mass_pct; StatePack(m.pass, res.col_pass_fail); StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.col_collar_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.col_collar_item_type); res.col_collar_mode = (byte)(m.methodParams.collar.collar_mode ? 1 : 0); res.col_collar_equation = (byte)m.methodParamsC.cev.cal_curve_equation; res.col_a_res = m.methodParamsC.cev.a; res.col_b_res = m.methodParamsC.cev.b; res.col_c_res = m.methodParamsC.cev.c; res.col_d_res = m.methodParamsC.cev.d; res.col_covar_ab_res = m.methodParamsC.cev.covar(Coeff.a, Coeff.b); res.col_covar_ac_res = m.methodParamsC.cev.covar(Coeff.a, Coeff.c); res.col_covar_ad_res = m.methodParamsC.cev.covar(Coeff.a, Coeff.d); res.col_covar_bc_res = m.methodParamsC.cev.covar(Coeff.b, Coeff.c); res.col_covar_bd_res = m.methodParamsC.cev.covar(Coeff.b, Coeff.d); res.col_covar_cd_res = m.methodParamsC.cev.covar(Coeff.c, Coeff.d); res.col_var_a_res = m.methodParamsC.cev.var_a; res.col_var_b_res = m.methodParamsC.cev.var_b; res.col_var_c_res = m.methodParamsC.cev.var_c; res.col_var_d_res = m.methodParamsC.cev.var_d; res.col_sigma_x_res = m.methodParamsC.cev.sigma_x; res.col_number_calib_rods_res = m.methodParamsC.number_calib_rods; StrToBytes(INCC.MAX_ROD_TYPE_LENGTH, m.methodParamsC.poison_rod_type[0], res.col_poison_rod_type_res); res.col_poison_absorption_fact_res = m.methodParamsC.poison_absorption_fact[0]; res.col_poison_rod_a_res = m.methodParamsC.poison_rod_a[0].v; res.col_poison_rod_a_err_res = m.methodParamsC.poison_rod_a[0].err; res.col_poison_rod_b_res = m.methodParamsC.poison_rod_b[0].v; res.col_poison_rod_b_err_res = m.methodParamsC.poison_rod_b[0].err; res.col_poison_rod_c_res = m.methodParamsC.poison_rod_c[0].v; res.col_poison_rod_c_err_res = m.methodParamsC.poison_rod_c[0].err; res.col_u_mass_corr_fact_a_res = m.methodParamsC.u_mass_corr_fact_a.v; res.col_u_mass_corr_fact_a_err_res = m.methodParamsC.u_mass_corr_fact_a.err; res.col_u_mass_corr_fact_b_res = m.methodParamsC.u_mass_corr_fact_b.v; res.col_u_mass_corr_fact_b_err_res = m.methodParamsC.u_mass_corr_fact_b.err; res.col_sample_corr_fact_res = m.methodParamsC.sample_corr_fact.v; res.col_sample_corr_fact_err_res = m.methodParamsC.sample_corr_fact.err; byte[] b = new byte[INCC.DATE_TIME_LENGTH]; char[] a = m.methodParamsDetector.reference_date.ToString("yy.MM.dd").ToCharArray(); Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0); TransferUtils.Copy(b, res.col_reference_date_res); res.col_relative_doubles_rate_res = m.methodParamsDetector.relative_doubles_rate; 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 = m.methodParamsK5.k5_label[i].ToCharArray(0, Math.Min(m.methodParamsK5.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, res.collar_k5_label_res, 0, INCC.MAX_COLLAR_K5_PARAMETERS * INCC.MAX_K5_LABEL_LENGTH); TransferUtils.CopyBoolsToBytes(m.methodParamsK5.k5_checkbox, res.collar_k5_checkbox_res); CopyTuples(m.methodParamsK5.k5, res.collar_k5_res, res.collar_k5_err_res, INCC.MAX_COLLAR_K5_PARAMETERS); } return res; }
/// <summary> /// after each cycle, run this cycle limit test and exit code /// </summary> /// <param name="seq"></param> /// <param name="mkey"></param> public static void CycleStatusTerminationCheck(this Measurement meas, Cycle cc) { bool stopAndComputeResults = meas.AcquireState.lm.SaveOnTerminate; IEnumerator iter = cc.CountingAnalysisResults.GetMultiplicityEnumerator(); while (iter.MoveNext()) { Multiplicity mkey = (Multiplicity)((KeyValuePair<SpecificCountingAnalyzerParams, object>)(iter.Current)).Key; MultiplicityCountingRes mcr = (MultiplicityCountingRes)((KeyValuePair<SpecificCountingAnalyzerParams, object>)(iter.Current)).Value; if (meas.MeasCycleStatus.num_checksum_failures > meas.Tests.maxNumFailures) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 7071, "Maximum checksum failure count met, cycle {0} {1}", cc.seq, mkey); if (stopAndComputeResults) { // URGENT: set state to end of measurement so that state moves out of cycles and skips forward to CalculateMeasurementResults } else { // exit processing completely, do not compute or save results NC.App.Opstate.Abort(); } } if (meas.MeasCycleStatus.num_acc_sngl_failures > meas.Tests.maxNumFailures) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 7072, "Maximum A/S failure count met, cycle {0} {1}", cc.seq, mkey); // ditto above comment block } if (meas.MeasCycleStatus.num_high_voltage_failures > meas.Tests.maxNumFailures) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 7073, "Maximum checksum failure count met, cycle {0} {1}", cc.seq, mkey); // ditto above comment block } if ((meas.MeasCycleStatus.num_acc_sngl_failures >= NUM_ACC_SNGL_WARNING) && (!meas.MeasCycleStatus.acc_sngl_warning_sent)) { meas.AddWarningMessage("At least " + meas.MeasCycleStatus.num_acc_sngl_failures + " A/S test failures", 7074, mkey); meas.MeasCycleStatus.acc_sngl_warning_sent = true; } if ((meas.MeasCycleStatus.num_checksum_failures >= NUM_CHECKSUM_WARNING) && (!meas.MeasCycleStatus.checksum_warning_sent)) { meas.AddWarningMessage("At least " + meas.MeasCycleStatus.num_checksum_failures + " checksum failures", 7075, mkey); meas.MeasCycleStatus.checksum_warning_sent = true; } if ((meas.MeasCycleStatus.num_high_voltage_failures >= NUM_HIGH_VOLTAGE_WARNING) && (!meas.MeasCycleStatus.high_voltage_warning_sent)) { meas.AddWarningMessage("At least " + meas.MeasCycleStatus.num_high_voltage_failures + " high voltage failures", 7076, mkey); meas.MeasCycleStatus.high_voltage_warning_sent = true; } if (meas.AcquireState.acquire_type == AcquireConvergence.CycleCount) { meas.MeasCycleStatus.acquire_num_runs = meas.MeasCycleStatus.initial_num_runs + meas.MeasCycleStatus.num_outlier_failures + meas.MeasCycleStatus.num_acc_sngl_failures + meas.MeasCycleStatus.num_checksum_failures; } else if (meas.Cycles.GetValidCycleCountForThisKey(mkey) < 100) // an arbitrary limit, make it a config item { // URGENT: set state to end of measurement so that state moves out of cycles and skips forward to CalculateMeasurementResults // todo: see take_data.cpp line 733 for mass check processing steps if (meas.Cycles.GetValidCycleCountForThisKey(mkey) > 1) { INCCResult results; MeasOptionSelector ar = new MeasOptionSelector(meas.MeasOption, mkey); bool found = meas.INCCAnalysisResults.TryGetValue(ar, out results); double error = 0; if (meas.AcquireState.acquire_type == AcquireConvergence.DoublesPrecision) { if (results.rates.DTCRates.Doubles.v != 0.0) { error = results.rates.DTCRates.Doubles.err / results.rates.DTCRates.Doubles.v * 100.0; } } else if (meas.AcquireState.acquire_type == AcquireConvergence.TriplesPrecision) { if (results.rates.DTCRates.Triples.v != 0.0) { error = results.rates.DTCRates.Triples.err / results.rates.DTCRates.Triples.v * 100.0; } } else if (meas.AcquireState.acquire_type == AcquireConvergence.Pu240EffPrecision) { RatesAdjustments dtchoice = RatesAdjustments.Raw; // NEXT: design out this choice everywhere, it shoud be a flag on the current computational state somewhere INCCMethodResults.results_multiplicity_rec res = INCCAnalysis.CalculateMultiplicity(mkey, results.covariance_matrix, results.rates.GetDTCRates(dtchoice), meas, dtchoice); if (res != null) { // the results obtained within the method are already stored on the result and they do not need to be copied here (VERIFY THIS) if (res.pu240e_mass.v != 0.0) { error = res.pu240e_mass.err / res.pu240e_mass.v * 100.0; } else error = 0.0; } } meas.MeasCycleStatus.acquire_num_runs = (uint)((double)cc.seq * (error / meas.AcquireState.meas_precision) * (error / meas.AcquireState.meas_precision)) + 1; meas.MeasCycleStatus.acquire_num_runs += meas.MeasCycleStatus.num_outlier_failures + meas.MeasCycleStatus.num_acc_sngl_failures + meas.MeasCycleStatus.num_checksum_failures; } else meas.MeasCycleStatus.acquire_num_runs = meas.AcquireState.max_num_runs; if (meas.MeasCycleStatus.acquire_num_runs > meas.AcquireState.max_num_runs) meas.MeasCycleStatus.acquire_num_runs = meas.AcquireState.max_num_runs; if (meas.MeasCycleStatus.acquire_num_runs < meas.AcquireState.min_num_runs) meas.MeasCycleStatus.acquire_num_runs = meas.AcquireState.min_num_runs; } } }
internal static unsafe iresultsbase MoveDEMult(INCCAnalysisState ias, MeasOptionSelector mos) { results_de_mult_rec res = new results_de_mult_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.DUAL_ENERGY_MULT_SAVE_RESTORE, out result); if (found) { INCCMethodResults.results_de_mult_rec m = (INCCMethodResults.results_de_mult_rec)result; res.de_meas_ring_ratio = m.meas_ring_ratio; res.de_interpolated_neutron_energy = m.interpolated_neutron_energy; res.de_energy_corr_factor = m.energy_corr_factor; TransferUtils.CopyDbls(m.methodParams.neutron_energy, res.de_neutron_energy_res); TransferUtils.CopyDbls(m.methodParams.detector_efficiency, res.de_detector_efficiency_res); TransferUtils.CopyDbls(m.methodParams.inner_outer_ring_ratio, res.de_inner_outer_ring_ratio_res); TransferUtils.CopyDbls(m.methodParams.relative_fission, res.de_relative_fission_res); res.de_inner_ring_efficiency_res = m.methodParams.inner_ring_efficiency; res.de_outer_ring_efficiency_res = m.methodParams.outer_ring_efficiency; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.de_mult_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.de_mult_item_type); } return res; }
/// <summary> /// Calculate averages and sums for all cycles in a measurement that pass all tests /// Do processing for all the Multiplicity results across all the cycles of the current Measurement /// </summary> public static void CalcAvgAndSums(this Measurement meas) { RatesAdjustments dtchoice = RatesAdjustments.DeadtimeCorrected; if (NC.App.Opstate.IsAbortRequested) return; IEnumerator iter = meas.CountingAnalysisResults.GetMultiplicityEnumerator(); while (iter.MoveNext()) { Multiplicity mkey = (Multiplicity)((KeyValuePair<SpecificCountingAnalyzerParams, object>)(iter.Current)).Key; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 7003, "Calculating averages and sums for valid cycles {0} {1}", dtchoice, mkey); MultiplicityCountingRes mcr = (MultiplicityCountingRes)meas.CountingAnalysisResults[mkey]; mcr.ComputeHitSums(); // APluralityOfMultiplicityAnalyzers: When a list mode sourced measurement is in use, and // cycle data comes from a prior analysis via a DB cycle source or Verification reanalysis, // doubles are computed using the LMSupport.SDTMultiplicityCalculator. // Note that DAQ LM sourced INCC5 analyses will have the unnormalized Acc distro. // The method INCCAnalysis.CalcAveragesAndSums uses the unnormalized // Acc distro (mcr.UnAMult), but in the two cases above there is only the normalized Acc and RealsAcc distros are present. // So the *unnormalized distro* must be computed and placed on each cycle, then and only then are doubles calculated correctly. INCCAnalysis.CalcAveragesAndSums(mkey, mcr, meas, dtchoice, meas.Detector.Id.SRType); mcr.Scaler1Rate.v = mcr.Scaler1.v; mcr.Scaler1Rate.err = mcr.Scaler1.err; mcr.Scaler2Rate.v = mcr.Scaler2.v; mcr.Scaler2Rate.err = mcr.Scaler2.err; MeasOptionSelector mos = new MeasOptionSelector(meas.MeasOption, mkey); INCCResult results = meas.INCCAnalysisState.Lookup(mos); if (results != null) { results.Scaler1Rate.v = mcr.Scaler1.v; results.Scaler1Rate.err = mcr.Scaler1.err; results.Scaler2Rate.v = mcr.Scaler2.v; results.Scaler2Rate.err = mcr.Scaler2.err; } } }
internal static unsafe iresultsbase MoveKnownA(INCCAnalysisState ias, MeasOptionSelector mos) { results_known_alpha_rec res = new results_known_alpha_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.KnownA, out result); if (found) { INCCMethodResults.results_known_alpha_rec m = (INCCMethodResults.results_known_alpha_rec)result; res.ka_mult = m.mult; res.ka_alpha = m.alphaK; res.ka_mult_corr_doubles = m.mult_corr_doubles.v; res.ka_mult_corr_doubles_err = m.mult_corr_doubles.err; res.ka_pu240e_mass = m.pu240e_mass.v; res.ka_pu240e_mass_err = m.pu240e_mass.err; res.ka_pu_mass = m.pu_mass.v; res.ka_pu_mass_err = m.pu_mass.err; res.ka_dcl_pu240e_mass = m.dcl_pu240e_mass; res.ka_dcl_minus_asy_pu_mass = m.dcl_minus_asy_pu_mass.v; res.ka_dcl_minus_asy_pu_mass_err = m.dcl_minus_asy_pu_mass.err; res.ka_dcl_minus_asy_pu_mass_pct = m.dcl_minus_asy_pu_mass_pct; StatePack(m.pass, res.ka_pass_fail); res.ka_dcl_u_mass = m.dcl_u_mass; res.ka_length = m.length; res.ka_heavy_metal_content = m.heavy_metal_content; res.ka_heavy_metal_correction = m.heavy_metal_correction; res.ka_corr_singles = m.corr_singles.v; res.ka_corr_singles_err = m.corr_singles.err; res.ka_corr_doubles = m.corr_doubles.v; res.ka_corr_doubles_err = m.corr_doubles.err; res.ka_corr_factor = m.corr_factor; res.ka_dry_alpha_or_mult_dbls = m.dry_alpha_or_mult_dbls; res.ka_alpha_wt_res = m.methodParams.alpha_wt; res.ka_rho_zero_res = m.methodParams.rho_zero; res.ka_k_res = m.methodParams.k; res.ka_a_res = m.methodParams.cev.a; res.ka_b_res = m.methodParams.cev.b; res.ka_var_a_res = m.methodParams.cev.var_a; res.ka_var_b_res = m.methodParams.cev.var_b; res.ka_covar_ab_res = m.methodParams.cev.covar(Coeff.a, Coeff.b); res.ka_sigma_x_res = m.methodParams.cev.sigma_x; res.ka_known_alpha_type_res = (double)m.methodParams.known_alpha_type; res.ka_heavy_metal_corr_factor_res = m.methodParams.heavy_metal_corr_factor; res.ka_heavy_metal_reference_res = m.methodParams.heavy_metal_reference; res.ka_lower_corr_factor_limit_res = m.methodParams.lower_corr_factor_limit; res.ka_upper_corr_factor_limit_res = m.methodParams.upper_corr_factor_limit; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.ka_known_alpha_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.ka_known_alpha_item_type); } return res; }
/// <summary> /// Save all updated and new results in the database /// </summary> public static void SaveMeasurementResults(this Measurement meas) { if (meas.Detector.ListMode) { long mid = meas.MeasurementId.UniqueId; foreach(SpecificCountingAnalyzerParams s in meas.CountingAnalysisResults.Keys) { // this is a virtual LMSR so save each mkey Type t = s.GetType(); DB.ElementList els = s.ToDBElementList(); if (t.Equals(typeof(Multiplicity))) { Multiplicity thisone = ((Multiplicity)s); els.Add(new DB.Element("predelay", thisone.SR.predelay)); } else if (t.Equals(typeof(Coincidence))) { Coincidence thisone = ((Coincidence)s); els.Add(new DB.Element("predelay", thisone.SR.predelay)); } DB.LMParamsRelatedBackToMeasurement counter = new DB.LMParamsRelatedBackToMeasurement(s.Table); s.Rank = counter.Create(mid, els); meas.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34103, string.Format("Preserving {0}_m as {1}", s.Table, s.Rank)); } } SaveMeasurementCycles(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 moskey = new MeasOptionSelector(meas.MeasOption, mkey); bool found = meas.INCCAnalysisResults.TryGetValue(moskey, out results); // APluralityOfMultiplicityAnalyzers: when does this actually get saved? It needs to be saved to DB after all calculations are complete try { switch (meas.MeasOption) { case AssaySelector.MeasurementOption.background: // calculated in CalculateResults, update bkg and save the result to the DB // save the background result to the bkg_parms_rec table under the current SR key BackgroundParameters c = NC.App.DB.BackgroundParameters.Get(meas.Detector); if (c != null) c.Copy(meas.Background); // copy changes back to original on user affirmation else { c = meas.Background; NC.App.DB.BackgroundParameters.GetMap().Add(meas.Detector, c); } NC.App.DB.BackgroundParameters.Set(meas.Detector, c); break; case AssaySelector.MeasurementOption.initial: // calculated in CalculateResults, update norm and save the norm and init_src result to the DB INCCResults.results_init_src_rec results_init_src = (INCCResults.results_init_src_rec)results; // 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 updated. if (results_init_src.pass) { NormParameters np = NC.App.DB.NormParameters.Get(meas.Detector); if (np != null) np.Copy(meas.Norm); // copy any changes made to Norm as defined for the current detector else { np = meas.Norm; NC.App.DB.NormParameters.GetMap().Add(meas.Detector, np); } NC.App.DB.NormParameters.Set(meas.Detector, np); } SaveSpecificResultsForThisMeasurement(meas, results); break; case AssaySelector.MeasurementOption.normalization: // calculated in CalculateResults, now save the result to the DB case AssaySelector.MeasurementOption.precision: // ditto SaveSpecificResultsForThisMeasurement(meas, results); break; case AssaySelector.MeasurementOption.calibration: // ditto with the method analyses results, but they're a bit different case AssaySelector.MeasurementOption.verification: SaveMethodResultsForThisMeasurement(meas, moskey); break; case AssaySelector.MeasurementOption.holdup: // NEXT: Hold-up held up, implement it #35 break; } } catch (Exception e) { meas.Logger.TraceException(e); } SaveSummaryResultsForThisMeasurement(meas, moskey); } meas.PersistFileNames(); }
internal static unsafe iresultsbase MoveMult(INCCAnalysisState ias, MeasOptionSelector mos) { results_multiplicity_rec res = new results_multiplicity_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.Multiplicity, out result); if (found) { INCCMethodResults.results_multiplicity_rec m = (INCCMethodResults.results_multiplicity_rec)result; res.mul_mult = m.mult.v; res.mul_mult_err = m.mult.err; res.mul_alpha = m.alphaK.v; res.mul_alpha_err = m.alphaK.err; res.mul_corr_factor = m.alphaK.v; res.mul_corr_factor_err = m.alphaK.err; res.mul_efficiency = m.alphaK.v; res.mul_efficiency_err = m.alphaK.err; res.mul_pu240e_mass = m.pu240e_mass.v; res.mul_pu240e_mass_err = m.pu240e_mass.err; res.mul_pu_mass = m.pu_mass.v; res.mul_pu_mass_err = m.pu_mass.err; res.mul_dcl_pu240e_mass = m.dcl_pu240e_mass; res.mul_dcl_minus_asy_pu_mass = m.dcl_minus_asy_pu_mass.v; res.mul_dcl_minus_asy_pu_mass_err = m.dcl_minus_asy_pu_mass.err; res.mul_dcl_minus_asy_pu_mass_pct = m.dcl_minus_asy_pu_mass_pct; StatePack(m.pass, res.mul_pass_fail); res.mul_solve_efficiency_res = (byte)m.solve_efficiency_choice; res.mul_sf_rate_res = m.methodParams.sf_rate; res.mul_vs1_res = m.methodParams.vs1; res.mul_vs2_res = m.methodParams.vs2; res.mul_vs3_res = m.methodParams.vs3; res.mul_vi1_res = m.methodParams.vi1; res.mul_vi2_res = m.methodParams.vi2; res.mul_vi3_res = m.methodParams.vi3; res.mul_a_res = m.methodParams.a; res.mul_b_res = m.methodParams.b; res.mul_c_res = m.methodParams.c; res.mul_sigma_x_res = m.methodParams.sigma_x; res.mul_alpha_weight_res = m.methodParams.alpha_weight; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.mul_multiplicity_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.mul_multiplicity_item_type); } return res; }
// INCC5 enables subselecting each field and creates a two line header instead of one. Dictionary <string, string> GenerateEntries(Selections s, Measurement m) { Dictionary <string, string> entries = new Dictionary <string, string>(); switch (s) { case Selections.AcquireParams: entries["Facility"] = Q(m.AcquireState.facility.Name); entries["MBA"] = Q(m.AcquireState.mba.Name); entries["Detector"] = Q(m.AcquireState.detector_id); entries["IC"] = Q(m.AcquireState.inventory_change_code); entries["IO"] = Q(m.AcquireState.io_code); entries["Measurement Type"] = Q(m.MeasOption.PrintName()); entries["Meas Date"] = m.MeasurementId.MeasDateTime.ToString("yy.MM.dd"); entries["Meas Time"] = m.MeasurementId.MeasDateTime.ToString("HH:mm:ss"); entries["File Name"] = Q(GetMainFilePath(m.ResultsFiles, m.MeasOption, true)); entries["Inspector"] = Q(m.AcquireState.user_id); entries["Inspection Number"] = Q(m.AcquireState.campaign_id); entries["Item ID"] = Q(m.AcquireState.item_id); entries["Isotopics ID"] = Q(m.AcquireState.isotopics_id); entries["Stratum ID"] = Q(m.AcquireState.stratum_id.Name); entries["Material Type"] = Q(m.AcquireState.item_type); break; case Selections.NormalizationParams: entries["Norm Cnst"] = m.Norm.currNormalizationConstant.v.ToString("F4"); // "Normalization constant" entries["Norm Cnst Error"] = m.Norm.currNormalizationConstant.err.ToString("F4"); // "Normalization constant error" break; case Selections.BackgroundParams: entries["Singles Bkg"] = m.Background.DeadtimeCorrectedSinglesRate.v.ToString("F1"); // "Passive singles background" entries["Singles Bkg Error"] = m.Background.DeadtimeCorrectedSinglesRate.err.ToString("F3"); // "Passive singles background error" entries["Doubles Bkg"] = m.Background.DeadtimeCorrectedDoublesRate.v.ToString("F2"); // "Passive doubles background" entries["Doubles Bkg Error"] = m.Background.DeadtimeCorrectedDoublesRate.err.ToString("F3"); // "Passive doubles background error" entries["Triples Bkg"] = m.Background.DeadtimeCorrectedTriplesRate.v.ToString("F2"); // "Passive triples background" entries["Triples Bkg Error"] = m.Background.DeadtimeCorrectedTriplesRate.err.ToString("F3"); // "Passive triples background error" entries["Act Sngls Bkg"] = m.Background.INCCActive.SinglesRate.ToString("F1"); // "Active singles background" entries["Act Sngls Bkg Error"] = m.Background.INCCActive.Singles.err.ToString("F3"); // "Active singles background error" break; case Selections.Summaries: if (m.INCCAnalysisState != null && m.INCCAnalysisResults != null) { System.Collections.IEnumerator iter = m.INCCAnalysisResults.GetMeasSelectorResultsEnumerator(); while (iter.MoveNext()) { MeasOptionSelector moskey = (MeasOptionSelector)iter.Current; INCCResult ir = m.INCCAnalysisResults[moskey]; entries["Singles"] = ir.DeadtimeCorrectedSinglesRate.v.ToString("F1"); // "Singles" entries["Singles Error"] = ir.DeadtimeCorrectedSinglesRate.err.ToString("F3"); // "Singles error" entries["Doubles"] = ir.DeadtimeCorrectedDoublesRate.v.ToString("F2"); // "Doubles" entries["Doubles Error"] = ir.DeadtimeCorrectedDoublesRate.err.ToString("F3"); // "Doubles error" entries["Triples"] = ir.DeadtimeCorrectedTriplesRate.v.ToString("F2"); // "Triples" entries["Triples Error"] = ir.DeadtimeCorrectedTriplesRate.err.ToString("F3"); // "Triples error" if (ir.Scaler1.v > 0 || ir.Scaler2.v > 0) { entries["Scaler 1"] = ir.Scaler1.v.ToString("F1"); entries["Scaler 1 Error"] = ir.Scaler1.err.ToString("F3"); entries["Scaler 2"] = ir.Scaler2.v.ToString("F1"); entries["Scaler 2 Error"] = ir.Scaler2.err.ToString("F3"); } entries["Count Time"] = (m.Cycles.Count > 0 ? m.Cycles[0].TS.TotalSeconds.ToString("F0") : "0"); // "Total count time for a measurement" entries["Singles Sum"] = m.SinglesSum.ToString("F0"); // Sums - singles Singles sum for a measurement" entries["R+A Sum"] = ir.RASum.ToString("F0"); // Reals + accidentals sum for a measurement" entries["A Sum"] = ir.ASum.ToString("F0"); // "Accidentals sum for a measurement" } } break; case Selections.Comments: entries["Comment"] = m.AcquireState.comment; if (m.INCCAnalysisResults.TradResultsRec.acq.ending_comment && !string.IsNullOrEmpty(m.INCCAnalysisResults.TradResultsRec.acq.ending_comment_str)) { entries["End Comment"] = m.AcquireState.ending_comment_str; } break; case Selections.MassAnalysisMethods: break; case Selections.CalibrationCurve: INCCMethodResults.results_cal_curve_rec ccres = (INCCMethodResults.results_cal_curve_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CalibrationCurve, false); if (ccres != null) { entries["Cal Cur Dcl Mass"] = ccres.dcl_pu_mass.ToString("F2"); // Calibration curve - declared mass" entries["Cal Cur Mass"] = ccres.pu_mass.v.ToString("F2"); // "Calibration curve - mass" entries["Cal Cur Mass Err"] = ccres.pu_mass.err.ToString("F3"); // "Calibration curve - mass error" entries["Cal Cur Dcl-Asy"] = ccres.dcl_minus_asy_pu_mass.v.ToString("F2"); // "Calibration curve - declared minus assay" entries["Cal Cur Dcl-Asy %"] = ccres.dcl_minus_asy_pu_mass_pct.ToString("F2"); // "Calibration curve - declared minus assay %" entries["Cal Cur Status"] = ccres.pass ? "Pass": ""; // "Calibration curve - measurement status" } break; case Selections.KnownAlpha: INCCMethodResults.results_known_alpha_rec kares = (INCCMethodResults.results_known_alpha_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownA, false); if (kares != null) { entries["Known A Dcl Mass"] = kares.dcl_pu_mass.ToString("F2"); // Known alpha - declared mass" entries["Known A Mass"] = kares.pu_mass.v.ToString("F2"); // "Known alpha - mass" entries["Known A Mass Err"] = kares.pu_mass.err.ToString("F3"); // "Known alpha - mass error" entries["Known A Dcl-Asy"] = kares.dcl_minus_asy_pu_mass.v.ToString("F2"); // "Known alpha - declared minus assay" entries["Known A Dcl-Asy %"] = kares.dcl_minus_asy_pu_mass_pct.ToString("F2"); // "Known alpha - declared minus assay %" entries["Known A Mult"] = kares.mult.ToString("F3"); // "Known alpha - multiplication" entries["Known A Alpha"] = kares.alphaK.ToString("F3"); // "Known alpha - alpha" entries["Known A Status"] = kares.pass ? "Pass": ""; // "Known alpha - measurement status" } break; case Selections.KnownM: INCCMethodResults.results_known_m_rec kmres = (INCCMethodResults.results_known_m_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownM, false); if (kmres != null) { entries["Known M Dcl Mass"] = kmres.dcl_pu_mass.ToString("F2"); // Known M - declared mass" entries["Known M Mass"] = kmres.pu_mass.v.ToString("F2"); // "Known M - mass" entries["Known M Mass Err"] = kmres.pu_mass.err.ToString("F3"); // "Known M - mass error" entries["Known M Dcl-Asy"] = kmres.dcl_minus_asy_pu_mass.v.ToString("F2"); // "Known M - declared minus assay" entries["Known M Dcl-Asy %"] = kmres.dcl_minus_asy_pu_mass_pct.ToString("F2"); // "Known M - declared minus assay %" entries["Known M Mult"] = kmres.mult.ToString("F3"); // "Known M - multiplication" entries["Known M Alpha"] = kmres.alpha.ToString("F3"); // "Known M - alpha" entries["Known M Status"] = kmres.pass ? "Pass": ""; // "Known M - measurement status" } break; case Selections.Multiplicity: INCCMethodResults.results_multiplicity_rec mres = (INCCMethodResults.results_multiplicity_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.Multiplicity, false); if (mres != null) { entries["Mult Dcl Mass"] = mres.dcl_pu_mass.ToString("F2"); // Multiplicity - declared mass" entries["Mult Mass"] = mres.pu_mass.v.ToString("F2"); // "Multiplicity- mass" entries["Mult Mass Err"] = mres.pu_mass.err.ToString("F3"); // "Multiplicity - mass error" entries["Mult Dcl-Asy"] = mres.dcl_minus_asy_pu_mass.v.ToString("F2"); // "Multiplicity - declared minus assay" entries["Mult Dcl-Asy %"] = mres.dcl_minus_asy_pu_mass_pct.ToString("F2"); // "Multiplicity - declared minus assay %" entries["Mult Mult"] = mres.mult.v.ToString("F3"); // "Multiplicity - multiplication" entries["Mult Mult Err"] = mres.mult.err.ToString("F3"); // "Multiplicity - multiplication error" entries["Mult Alpha"] = mres.alphaK.v.ToString("F3"); // "Multiplicity - alpha" entries["Mult Alpha Err"] = mres.alphaK.err.ToString("F3"); // "Multiplicity - alpha error" entries["Mult Efficiency"] = mres.efficiencyComputed.v.ToString("F3"); // "Multiplicity - efficiency" entries["Mult Eff Err"] = mres.efficiencyComputed.err.ToString("F3"); // "Multiplicity - efficiency error" entries["Mult Status"] = mres.pass ? "Pass": ""; // "Multiplicity - measurement status" entries["Mult Predelay ms"] = m.Detector.SRParams.predelayMS.ToString(); // "Multiplicity - predelay " entries["Mult Gate ms"] = m.Detector.SRParams.gateLengthMS.ToString(); // "Multiplicity - gate width" } break; case Selections.AddASource: INCCMethodResults.results_add_a_source_rec aares = (INCCMethodResults.results_add_a_source_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.AddASource, false); if (aares != null) { entries["Add-a-src Dcl Mass"] = aares.dcl_pu_mass.ToString("F2"); // Add-a-source - declared mass" entries["Add-a-src Mass"] = aares.pu_mass.v.ToString("F2"); // "Add-a-source - mass" entries["Add-a-src Mass Err"] = aares.pu_mass.err.ToString("F3"); // "Add-a-source - mass error" entries["Add-a-src Dcl-Asy"] = aares.dcl_minus_asy_pu_mass.v.ToString("F2"); // "Add-a-source - declared minus assay" entries["Add-a-src Dcl-Asy %"] = aares.dcl_minus_asy_pu_mass_pct.ToString("F2"); // "Add-a-source - declared minus assay %" entries["Add-a-src Status"] = aares.pass ? "Pass": ""; // "Add-a-source - measurement status" entries["Add-a-src Corr"] = aares.corr_factor.v.ToString("F3"); // "Add-a-source - measurement status" } break; case Selections.CuriumRatio: INCCMethodResults.results_curium_ratio_rec cures = (INCCMethodResults.results_curium_ratio_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CuriumRatio, false); if (cures != null) { entries["Cm Ratio ID"] = cures.methodParams2.cm_id; // Curium ratio - ID" entries["Cm Ratio Input ID"] = cures.methodParams2.cm_input_batch_id; // Curium ratio - input batch ID" entries["Cm Ratio Cm/Pu"] = cures.methodParams2.cm_pu_ratio.v.ToString("F4"); // Curium ratio - Cm/Pu ratio" entries["Cm Ratio Cm/U"] = cures.methodParams2.cm_u_ratio.v.ToString("F4"); // Curium ratio - Cm/U ratio" entries["Cm Mass"] = cures.cm_mass.v.ToString("F3"); // Curium ratio - Cm mass" entries["Cm Err"] = cures.cm_mass.err.ToString("F3"); // Curium ratio - Cm mass error" entries["Cm Ratio Pu Dcl Mass"] = cures.pu.dcl_pu_mass.ToString("F2"); // Curium ratio - declared mass" entries["Cm Ratio Pu Mass"] = cures.pu.pu_mass.v.ToString("F2"); // "Curium ratio - mass" entries["Cm Ratio Pu Mass Err"] = cures.pu.pu_mass.err.ToString("F3"); // "Curium ratio - mass error" entries["Cm Ratio Pu Dcl-Asy"] = cures.pu.dcl_minus_asy_pu_mass.v.ToString("F2"); // "Curium ratio - declared minus assay" entries["Cm Ratio Pu Dcl-Asy %"] = cures.pu.dcl_minus_asy_pu_mass_pct.ToString("F2"); // "Curium ratio - declared minus assay %" entries["Cm Ratio U Dcl Mass"] = cures.u.dcl_mass.ToString("F2"); // "Curium ratio - U declared mass" entries["Cm Ratio U Mass"] = cures.u.mass.v.ToString("F2"); // "Curium ratio - U mass" entries["Cm Ratio U Mass Err"] = cures.u.mass.err.ToString("F3"); // "Curium ratio - U mass error" entries["Cm Ratio U Dcl-Asy"] = cures.u.dcl_minus_asy_mass.v.ToString("F2"); // "Curium ratio - U declared minus assay" entries["Cm Ratio U Dcl-Asy %"] = cures.u.dcl_minus_asy_mass_pct.ToString("F2"); // "Curium ratio - U declared minus assay %" entries["Cm Ratio U235 Dcl Mass"] = cures.u235.dcl_mass.ToString("F2"); // Curium ratio - U235 declared mass" entries["Cm Ratio U235 Mass"] = cures.u235.mass.v.ToString("F2"); // "Curium ratio - U235 mass" entries["Cm Ratio U235 Mass Err"] = cures.u235.mass.err.ToString("F3"); // "Curium ratio - U235 mass error" entries["Cm Ratio U235 Dcl-Asy"] = cures.u235.dcl_minus_asy_mass.v.ToString("F2"); // "Curium ratio - U235 declared minus assay" entries["Cm Ratio U235 Dcl-Asy %"] = cures.u235.dcl_minus_asy_mass_pct.ToString("F2"); // "Curium ratio - U235 declared minus assay %" entries["Cm Ratio Pu Status"] = cures.pu.pass ? "Pass": ""; // "Curium ratio - Pu measurement status" entries["Cm Ratio U Status"] = cures.u.pass ? "Pass": ""; // "Curium ratio - U measurement status" } break; case Selections.TruncatedMultiplicity: INCCMethodResults.results_truncated_mult_rec tmres = (INCCMethodResults.results_truncated_mult_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.TruncatedMultiplicity, false); if (tmres != null) { entries["Trunc Mult Dcl Mass"] = tmres.k.dcl_mass.ToString("F2"); // "Truncated multiplicity - declared mass" entries["Trunc Mult Mass"] = tmres.k.pu_mass.v.ToString("F2"); // "Truncated multiplicity - mass" entries["Trunc Mult Mass Err"] = tmres.k.pu_mass.err.ToString("F3"); // "Truncated multiplicity - mass error" entries["Trunc Mult Dcl-Asy"] = tmres.k.dcl_minus_asy_mass.v.ToString("F2"); // "Truncated multiplicity - declared minus assay" entries["Trunc Dcl-Asy %"] = tmres.k.dcl_minus_asy_mass_pct.ToString("F2"); //"Truncated multiplicity - declared minus assay %" entries["Trunc Mult Status"] = tmres.k.pass ? "Pass": ""; // "Truncated multiplicity - measurement status" // todo: what about 's'? } break; case Selections.ActiveCalibCurve: INCCMethodResults.results_active_rec acres = (INCCMethodResults.results_active_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.Active, false); if (acres != null) { entries["Active Dcl Mass"] = acres.dcl_u235_mass.ToString("F2"); // Active calibration curve - declared mass" entries["Active Mass"] = acres.u235_mass.v.ToString("F2"); // "Active calibration curve - mass" entries["Active Mass Err"] = acres.u235_mass.err.ToString("F3"); // "Active calibration curve - mass error" entries["Active Dcl-Asy"] = acres.dcl_minus_asy_u235_mass.v.ToString("F2"); // "Active calibration curve - declared minus assay" entries["Active Dcl-Asy %"] = acres.dcl_minus_asy_u235_mass_pct.ToString("F2"); // "Active calibration curve - declared minus assay %" entries["Active Status"] = acres.pass ? "Pass": ""; // "Active calibration curve - measurement status" } break; case Selections.CollarAmLi: INCCMethodResults.results_collar_rec rcres = (INCCMethodResults.results_collar_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CollarAmLi, false); if (rcres != null) { entries["Collar Dbls Rate"] = rcres.total_corr_fact.v.ToString("F2"); // Collar - corrected doubles rate" entries["Collar Dbls Rate Err"] = rcres.total_corr_fact.v.ToString("F2"); // Collar -- corrected doubles rate error" entries["Collar Dcl Mass"] = rcres.dcl_total_u235.v.ToString("F2"); // Collar - declared mass" entries["Collar Mass"] = rcres.u235_mass.v.ToString("F2"); // "Collar - mass" entries["Collar Mass Err"] = rcres.u235_mass.err.ToString("F3"); // "Collar - mass error" entries["Collar Dcl-Asy"] = rcres.dcl_minus_asy_u235_mass.v.ToString("F2"); // "Collar - declared minus assay" entries["Collar Dcl-Asy %"] = rcres.dcl_minus_asy_u235_mass_pct.ToString("F2"); // "Collar - declared minus assay %" entries["Collar Status"] = rcres.pass ? "Pass": ""; // "Collar - measurement status" } break; case Selections.CollarCf: rcres = (INCCMethodResults.results_collar_rec) m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CollarCf, false); if (rcres != null) { entries["Collar Dbls Rate"] = rcres.total_corr_fact.v.ToString("F2"); // Collar - corrected doubles rate" entries["Collar Dbls Rate Err"] = rcres.total_corr_fact.v.ToString("F2"); // Collar -- corrected doubles rate error" entries["Collar Dcl Mass"] = rcres.dcl_total_u235.v.ToString("F2"); // Collar - declared mass" entries["Collar Mass"] = rcres.u235_mass.v.ToString("F2"); // "Collar - mass" entries["Collar Mass Err"] = rcres.u235_mass.err.ToString("F3"); // "Collar - mass error" entries["Collar Dcl-Asy"] = rcres.dcl_minus_asy_u235_mass.v.ToString("F2"); // "Collar - declared minus assay" entries["Collar Dcl-Asy %"] = rcres.dcl_minus_asy_u235_mass_pct.ToString("F2"); // "Collar - declared minus assay %" entries["Collar Status"] = rcres.pass ? "Pass" : ""; // "Collar - measurement status" } break; default: break; } return(entries); }
// NEXT: confused with tm_bkg and bkg measurements internal static unsafe iresultsbase MoveTruncBkg(INCCAnalysisState ias, MeasOptionSelector mos) { results_tm_bkg_rec res = new results_tm_bkg_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.None, out result); if (found) { INCCMethodResults.results_tm_bkg_rec m = (INCCMethodResults.results_tm_bkg_rec)result; // todo: tm bkg handling design incomplete res.results_tm_singles_bkg = m.methodParams.Singles.v; res.results_tm_singles_bkg_err = m.methodParams.Singles.err; res.results_tm_zeros_bkg = m.methodParams.Zeros.v; res.results_tm_zeros_bkg_err = m.methodParams.Zeros.err; res.results_tm_ones_bkg = m.methodParams.Ones.v; res.results_tm_ones_bkg_err = m.methodParams.Ones.err; res.results_tm_twos_bkg = m.methodParams.Twos.v; res.results_tm_twos_bkg_err = m.methodParams.Twos.err; } return res; }
/// <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 }
public static unsafe List<INCCTransferFile> XFerFromMeasurements(List<Measurement> meas) { List<INCCTransferFile> list = new List<INCCTransferFile>(); foreach (Measurement m in meas) { IEnumerator iter = m.CountingAnalysisResults.GetMultiplicityEnumerator(); while (iter.MoveNext()) // for each mkey, a seperate xfer file should be emitted { INCCTransferFile itf = new INCCTransferFile(NC.App.Loggers.Logger(LMLoggers.AppSection.Control), null); itf.Name = MethodResultsReport.EightCharConvert(m.MeasDate) + "." + m.MeasOption.INCC5Suffix(); list.Add(itf); itf.results_rec_list.Add(Result5.MoveResultsRec(m)); itf.results_status_list.Add(Result5.EncodeResultsStatus(m)); Multiplicity mkey = (Multiplicity)((KeyValuePair<SpecificCountingAnalyzerParams, object>)(iter.Current)).Key; if (m.MeasOption >= AssaySelector.MeasurementOption.background && m.MeasOption <= AssaySelector.MeasurementOption.holdup) { MeasOptionSelector mos = new MeasOptionSelector(m.MeasOption, mkey); if (m.MeasOption == AssaySelector.MeasurementOption.initial) itf.method_results_list.Add(Result5.MoveInitSrc(m.INCCAnalysisResults, mos)); else if (m.MeasOption == AssaySelector.MeasurementOption.normalization) itf.method_results_list.Add(Result5.MoveBias(m.INCCAnalysisResults, mos)); else if (m.MeasOption == AssaySelector.MeasurementOption.precision) itf.method_results_list.Add(Result5.MovePrecision(m.INCCAnalysisResults, mos)); else if (m.MeasOption == AssaySelector.MeasurementOption.background) itf.method_results_list.Add(Result5.MoveTruncBkg(m.INCCAnalysisState, mos)); // NEXT: tm bkg, special case, unfinished else if (m.MeasOption == AssaySelector.MeasurementOption.verification || m.MeasOption == AssaySelector.MeasurementOption.calibration) { itf.method_results_list.Add(Result5.MoveCalCurve(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveKnownA(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveKnownM(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveMult(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveDEMult(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveActPass(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveCollar(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveActive(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveActiveMult(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveCurium(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveTruncMult(m.INCCAnalysisState, mos)); itf.method_results_list.Add(Result5.MoveTruncBkg(m.INCCAnalysisState, mos)); // todo: here too, or just for bkg measurement? itf.method_results_list.Add(Result5.MoveAAS(m.INCCAnalysisState, mos)); } } foreach (Cycle c in m.Cycles) { itf.run_rec_list.Add(Result5.MoveCycleToRunRec(c, mkey)); } if (m.MeasOption == AssaySelector.MeasurementOption.verification && m.INCCAnalysisState.Methods.HasMethod(AnalysisMethod.AddASource)) { itf.InitCFRunLists(); int aasp = 0; foreach (CycleList cl in m.CFCycles) { foreach(Cycle cfc in cl) itf.CFrun_rec_list[aasp].Add(Result5.MoveCycleToRunRec(cfc, mkey)); aasp++; } } } } return list; }
internal static unsafe iresultsbase MoveAAS(INCCAnalysisState ias, MeasOptionSelector mos) { results_add_a_source_rec res = new results_add_a_source_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.AddASource, out result); if (found) { INCCMethodResults.results_add_a_source_rec m = (INCCMethodResults.results_add_a_source_rec)result; res.ad_dzero_cf252_doubles = m.dzero_cf252_doubles; CopyTuples(m.sample_cf252_doubles, res.ad_sample_cf252_doubles, res.ad_sample_cf252_doubles_err, INCC.MAX_ADDASRC_POSITIONS); TransferUtils.CopyDbls(m.sample_cf252_ratio, res.ad_sample_cf252_ratio); res.ad_sample_avg_cf252_doubles = m.sample_avg_cf252_doubles.v; res.ad_sample_avg_cf252_doubles_err = m.sample_avg_cf252_doubles.err; res.ad_corr_doubles = m.corr_doubles.v; res.ad_corr_doubles_err = m.corr_doubles.err; res.ad_delta = m.delta.v; res.ad_delta_err = m.delta.err; res.ad_corr_factor = m.corr_factor.v; res.ad_corr_factor_err = m.corr_factor.err; res.ad_pu240e_mass = m.pu240e_mass.v; res.ad_pu240e_mass_err = m.pu240e_mass.err; res.ad_pu_mass = m.pu_mass.v; res.ad_pu_mass_err = m.pu_mass.err; res.ad_dcl_pu240e_mass = m.dcl_pu240e_mass; res.ad_dcl_pu_mass = m.dcl_pu_mass; res.ad_dcl_minus_asy_pu_mass = m.dcl_minus_asy_pu_mass.v; res.ad_dcl_minus_asy_pu_mass_err = m.dcl_minus_asy_pu_mass.err; res.ad_dcl_minus_asy_pu_mass_pct = m.dcl_minus_asy_pu_mass_pct; StatePack(m.pass, res.ad_pass_fail); res.ad_tm_corr_doubles = m.tm_corr_doubles.v; res.ad_tm_corr_doubles_err = m.tm_corr_doubles.err; res.ad_tm_doubles_bkg = m.tm_doubles_bkg.v; res.ad_tm_doubles_bkg_err = m.tm_doubles_bkg.err; res.ad_tm_uncorr_doubles = m.tm_uncorr_doubles.v; res.ad_tm_uncorr_doubles_err = m.tm_uncorr_doubles.err; res.ad_add_a_source_equation = (byte)m.methodParams.cev.cal_curve_equation; res.ad_a_res = m.methodParams.cev.a; res.ad_b_res = m.methodParams.cev.b; res.ad_c_res = m.methodParams.cev.c; res.ad_d_res = m.methodParams.cev.d; res.ad_covar_ab_res = m.methodParams.cev.covar(Coeff.a, Coeff.b); res.ad_covar_ac_res = m.methodParams.cev.covar(Coeff.a, Coeff.c); res.ad_covar_ad_res = m.methodParams.cev.covar(Coeff.a, Coeff.d); res.ad_covar_bc_res = m.methodParams.cev.covar(Coeff.b, Coeff.c); res.ad_covar_bd_res = m.methodParams.cev.covar(Coeff.b, Coeff.d); res.ad_covar_cd_res = m.methodParams.cev.covar(Coeff.c, Coeff.d); res.ad_var_a_res = m.methodParams.cev.var_a; res.ad_var_b_res = m.methodParams.cev.var_b; res.ad_var_c_res = m.methodParams.cev.var_c; res.ad_var_d_res = m.methodParams.cev.var_d; res.ad_sigma_x_res = m.methodParams.cev.sigma_x; TransferUtils.CopyDbls(m.methodParams.position_dzero, res.ad_position_dzero_res); res.ad_dzero_avg_res = m.methodParams.dzero_avg; byte[] b = new byte[INCC.DATE_TIME_LENGTH]; char[] a = m.methodParams.dzero_ref_date.ToString("yy.MM.dd").ToCharArray(); Encoding.ASCII.GetBytes(a, 0, a.Length, b, 0); TransferUtils.Copy(b, res.ad_dzero_ref_date_res); res.ad_num_runs_res = m.methodParams.num_runs; res.ad_cf_a_res = m.methodParams.cf.a; res.ad_cf_b_res = m.methodParams.cf.b; res.ad_cf_c_res = m.methodParams.cf.c; res.ad_cf_d_res = m.methodParams.cf.d; res.ad_use_truncated_mult_res = (m.methodParams.use_truncated_mult ? 1 : 0); res.ad_tm_weighting_factor_res = m.methodParams.tm_weighting_factor; res.ad_tm_dbls_rate_upper_limit_res = m.methodParams.tm_dbls_rate_upper_limit; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.ad_add_a_source_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.ad_add_a_source_item_type); } return res; }
/// <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 }
internal static unsafe iresultsbase MoveActiveMult(INCCAnalysisState ias, MeasOptionSelector mos) { results_active_mult_rec res = new results_active_mult_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.ActiveMultiplicity, out result); if (found) { INCCMethodResults.results_active_mult_rec m = (INCCMethodResults.results_active_mult_rec)result; res.am_mult = m.mult.v; res.am_mult_err = m.mult.err; res.am_vt1_res = m.methodParams.vt1; res.am_vt2_res = m.methodParams.vt2; res.am_vt3_res = m.methodParams.vt3; res.am_vf1_res = m.methodParams.vf1; res.am_vf2_res = m.methodParams.vf2; res.am_vf3_res = m.methodParams.vf3; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.am_mult_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.am_mult_item_type); } return res; }
protected Section ConstructReportSection(INCCReportSection section, MeasOptionSelector moskey, INCCResult ir, Detector det) { INCCStyleSection sec = null; try { switch (section) { // NEXT: in progress, an identical copy of full INCC report sections case INCCReportSection.SummedRawData: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.Summary); sec.SetFPCurrentFormatPrecision(0); sec.AddHeader(String.Format("{0} summed raw data",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header sec.AddNumericRow("Shift register singles sum:", meas.SinglesSum); sec.AddNumericRow("Shift register reals + accidentals sum:", ir.RASum); sec.AddNumericRow("Shift register accidentals sum:", ir.ASum); if (!det.Id.source.UsingVirtualSRCounting(det.Id.SRType)) { sec.AddNumericRow("Shift register 1st scaler sum:", ir.S1Sum); sec.AddNumericRow("Shift register 2nd scaler sum:", ir.S2Sum); } break; case INCCReportSection.SummedRA: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} summed multiplicity distributions",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header int[] srawidths = new int[] { 5, 12, 12 }; int minbin, maxbin; minbin = Math.Min(ir.RAMult.Length, ir.NormedAMult.Length); maxbin = Math.Max(ir.RAMult.Length, ir.NormedAMult.Length); sec.AddColumnRowHeader(new string[] { " ", "R+A sums", "A sums" }, srawidths); for (int i = 0; i < minbin; i++) sec.AddColumnRow(new ulong[] { (ulong)i, ir.RAMult[i], ir.NormedAMult[i] }, srawidths); for (int i = minbin; i < maxbin; i++) // check for uneven column { ulong[] potential = new ulong[3]; potential[0] = (ulong)i; if (i < ir.RAMult.Length) potential[1] = ir.RAMult[i]; if (i < ir.NormedAMult.Length) potential[2] = ir.NormedAMult[i]; sec.AddColumnRow(potential, srawidths); } break; case INCCReportSection.MassResults: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MethodResults); //Results are not always passive. Boo. sec.AddHeader(String.Format("{0} Results",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header sec.AddNumericRow("Singles:", ir.DeadtimeCorrectedSinglesRate); sec.AddNumericRow("Doubles:", ir.DeadtimeCorrectedDoublesRate); sec.AddNumericRow("Triples:", ir.DeadtimeCorrectedTriplesRate); //changed to DTC rates. Raw rates meaningless here hn 11.5.2014 //sec.AddNumericRow("Quads:", mcr.DeadtimeCorrectedQuadsRate); // todo: quads delayed until pents are ready per DN if (!det.Id.source.UsingVirtualSRCounting(det.Id.SRType)) { sec.AddNumericRow("Scaler 1:", ir.Scaler1); sec.AddNumericRow("Scaler 2:", ir.Scaler2); } //if (det.Id.SRType >= LMDAQ.InstrType.NPOD) //{ // sec.Add(new Row()); // blank line // sec.AddNumericRow("Dyt. Singles:", ir.DytlewskiCorrectedSinglesRate); // sec.AddNumericRow("Dyt. Doubles:", ir.DytlewskiCorrectedDoublesRate); // sec.AddNumericRow("Dyt. Triples:", ir.DytlewskiCorrectedTriplesRate); //} break; case INCCReportSection.MethodResultsAndParams: // 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 List<Row> rl = ir.ToLines(meas); sec = new INCCStyleSection(null, 0, INCCStyleSection.ReportSection.MethodResults); sec.AddRange(rl); switch (meas.MeasOption) { case AssaySelector.MeasurementOption.background: if (meas.Background.TMBkgParams.ComputeTMBkg) ctrllog.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: break; case AssaySelector.MeasurementOption.verification: case AssaySelector.MeasurementOption.calibration: { INCCMethodResults imrs; bool beendonegot = meas.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrs); if (beendonegot && imrs.Count > 0) // should be true for verification and calibration { // 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()) { INCCMethodResult imr = ai.Current.Value; // show the primaryMethod if (ai.Current.Key.Equals(imrs.primaryMethod)) { sec.Add(new Row()); Row rh = new Row(); rh.Add(0, " PRIMARY RESULT"); sec.Add(rh); } rl = imr.ToLines(meas); sec.AddRange(rl); // todo: optional use of END_PRIMARY_RESULT as in some INCC report formats, but not others } } } break; case AssaySelector.MeasurementOption.rates: case AssaySelector.MeasurementOption.holdup: case AssaySelector.MeasurementOption.unspecified: default: // nothing new to present with these break; } break; case INCCReportSection.RawCycles: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} cycle raw data",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header int[] crdwidths = new int[] { 5, 10, 10, 10, 10, 10, 10 }; sec.AddColumnRowHeader(new string[] { "Cycle", "Singles", "R+A ", "A ", "Scaler1", "Scaler2", "QC Tests" }, crdwidths); foreach (Cycle cyc in meas.Cycles) { // if no results on the cycle, these map indexers throw if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; sec.AddCycleColumnRow(cyc.seq, new ulong[] { (ulong)mcr.Totals, (ulong)mcr.RASum, (ulong)mcr.ASum, (ulong)mcr.Scaler1.v, (ulong)mcr.Scaler2.v }, meas.AcquireState.qc_tests?cyc.QCStatus(moskey.MultiplicityParams).INCCString():"Off", crdwidths); } } break; case INCCReportSection.DTCRateCycles: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} cycle DTC rate data",meas.AcquireState.well_config == WellConfiguration.Active?"Active":"Passive")); // section header int[] crawidths = new int[] { 5, 13, 13, 13, 13, 10 }; sec.AddColumnRowHeader(new string[] { "Cycle", "Singles", "Doubles", "Triples", "Mass", "QC Tests" }, crawidths); foreach (Cycle cyc in meas.Cycles) { if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; //These debug rows show raw rates for comparison hn 10.30 //sec.AddCycleColumnRow(cyc.seq, //Again, could be wrong. // new double[] { mcr.RawSinglesRate.v, mcr.RawDoublesRate.v, -1, -1 }, // cyc.QCStatus(moskey.MultiplicityParams).INCCString(), crawidths); //Again, could be wrong. // TODO: Am actually printing out the DTC rates per cycle. This seems to work in all cases EXCEPT "precision" hn 11.5 sec.AddCycleColumnRow(cyc.seq, // Using the corrected rates! new double[] { mcr.DeadtimeCorrectedSinglesRate.v, mcr.DeadtimeCorrectedDoublesRate.v, mcr.DeadtimeCorrectedTriplesRate.v, mcr.mass/*Mass*/ }, meas.AcquireState.qc_tests?cyc.QCStatus(moskey.MultiplicityParams).INCCString():"Off", crawidths); } } break; case INCCReportSection.MultiplicityDistributions: sec = new INCCStyleSection(null, 1, INCCStyleSection.ReportSection.MultiColumn); sec.AddHeader(String.Format("{0} multiplicity distributions for each cycle",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive")); // section header int[] csrawidths = new int[] { 6, 12, 12 }; foreach (Cycle cyc in meas.Cycles) { if (cyc.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)) > 0) // if no results on the cycle, these map indexers throw { MultiplicityCountingRes mcr = (MultiplicityCountingRes)cyc.CountingAnalysisResults[moskey.MultiplicityParams]; minbin = Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length); maxbin = Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length); sec.AddColumnRowHeader(new string[] { "Cycle " + cyc.seq, "R+A ", "A " }, csrawidths); for (int i = 0; i < minbin; i++) sec.AddColumnRow(new ulong[] { (ulong)i, mcr.RAMult[i], mcr.NormedAMult[i] }, csrawidths); for (int i = minbin; i < maxbin; i++) // check for uneven column { ulong[] potential = new ulong[3]; potential[0] = (ulong)i; if (i < mcr.RAMult.Length) potential[1] = mcr.RAMult[i]; if (i < mcr.NormedAMult.Length) potential[2] = mcr.NormedAMult[i]; sec.AddColumnRow(potential, csrawidths); } } sec.Add(new Row());// blank } break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }
internal static unsafe iresultsbase MoveActPass(INCCAnalysisState ias, MeasOptionSelector mos) { results_active_passive_rec res = new results_active_passive_rec(); INCCMethodResult result; bool found = ias.Results.TryGetMethodResults(mos.MultiplicityParams, ias.Methods.selector, AnalysisMethod.ActivePassive, out result); if (found) { INCCMethodResults.results_active_passive_rec m = (INCCMethodResults.results_active_passive_rec)result; res.ap_delta_doubles = m.delta_doubles.v; res.ap_delta_doubles_err = m.delta_doubles.err; res.ap_u235_mass = m.u235_mass.v; res.ap_u235_mass_err = m.u235_mass.err; res.ap_k0 = m.k0.v; res.ap_k1 = m.k1.v; res.ap_k1_err = m.k1.err; res.ap_k = m.k.v; res.ap_k_err = m.k.err; res.ap_dcl_u235_mass = m.dcl_u235_mass; res.ap_dcl_minus_asy_u235_mass = m.dcl_minus_asy_u235_mass.v; res.ap_dcl_minus_asy_u235_mass_err = m.dcl_minus_asy_u235_mass.err; res.ap_dcl_minus_asy_u235_mass_pct = m.dcl_minus_asy_u235_mass_pct; StatePack(m.pass, res.ap_pass_fail); res.ap_active_passive_equation = (byte)m.methodParams.cev.cal_curve_equation; res.ap_a_res = m.methodParams.cev.a; res.ap_b_res = m.methodParams.cev.b; res.ap_c_res = m.methodParams.cev.c; res.ap_d_res = m.methodParams.cev.d; res.ap_covar_ab_res = m.methodParams.cev.covar(Coeff.a, Coeff.b); res.ap_covar_ac_res = m.methodParams.cev.covar(Coeff.a, Coeff.c); res.ap_covar_ad_res = m.methodParams.cev.covar(Coeff.a, Coeff.d); res.ap_covar_bc_res = m.methodParams.cev.covar(Coeff.b, Coeff.c); res.ap_covar_bd_res = m.methodParams.cev.covar(Coeff.b, Coeff.d); res.ap_covar_cd_res = m.methodParams.cev.covar(Coeff.c, Coeff.d); res.ap_var_a_res = m.methodParams.cev.var_a; res.ap_var_b_res = m.methodParams.cev.var_b; res.ap_var_c_res = m.methodParams.cev.var_c; res.ap_var_d_res = m.methodParams.cev.var_d; res.ap_sigma_x_res = m.methodParams.cev.sigma_x; StrToBytes(INCC.MAX_DETECTOR_ID_LENGTH, ias.Methods.selector.detectorid, res.ap_active_passive_detector_id); StrToBytes(INCC.MAX_ITEM_TYPE_LENGTH, ias.Methods.selector.material, res.ap_active_passive_item_type); } return res; }
protected Section ConstructReportSection(INCCTestDataSection section, Detector det, MeasOptionSelector moskey = null) { INCCTestDataStyle sec = null; try { switch (section) { case INCCTestDataSection.CycleSummary: sec = new INCCTestDataStyle(null, 0); sec.AddOne( (Int32)meas.Cycles.GetValidCycleCountForThisKey(moskey.MultiplicityParams)); // could also use CycleList length but CycleList can be longer when a reanalysis occurs and the analysis processing stops short of the end of the list due to modified termination conditions sec.AddOne( (Int32)(meas.Cycles.Count > 0 ? meas.Cycles[0].TS.TotalSeconds : 0.0)); break; default: break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }
// Based on the measurement type and result, show a bunch of stuff void FieldFiller() { Measurement m = N.App.Opstate.Measurement; int rep = m.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)); int i = 0; IEnumerator iter = m.CountingAnalysisResults.GetMultiplicityEnumerator(); while (iter.MoveNext()) { i++; string augmenter = (rep > 1 ? " " + i.ToString() : ""); // use mkey indicator here, not just this indexer Multiplicity mkey = (Multiplicity)((KeyValuePair <SpecificCountingAnalyzerParams, object>)(iter.Current)).Key; INCCResult r; MeasOptionSelector moskey = new MeasOptionSelector(m.MeasOption, mkey); bool found = m.INCCAnalysisResults.TryGetValue(moskey, out r); // APluralityOfMultiplicityAnalyzers: switch (m.MeasOption) { case AssaySelector.MeasurementOption.rates: case AssaySelector.MeasurementOption.background: //if (passive) listView1.Items.Add(new ListViewItem(new string[] { "Passive rates" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Singles: {0,13:F3} +- {1,9:F3}", r.DeadtimeCorrectedSinglesRate.v, r.DeadtimeCorrectedSinglesRate.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Doubles: {0,13:F3} +- {1,9:F3}", r.DeadtimeCorrectedDoublesRate.v, r.DeadtimeCorrectedDoublesRate.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Triples: {0,13:F3} +- {1,9:F3}", r.DeadtimeCorrectedTriplesRate.v, r.DeadtimeCorrectedTriplesRate.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Scaler 1: {0,13:F3} +- {1,9:F3}", r.Scaler1Rate.v, r.Scaler1Rate.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Scaler 2: {0,13:F3} +- {1,9:F3}", r.Scaler2Rate.v, r.Scaler2Rate.err) })); //if (active) break; case AssaySelector.MeasurementOption.initial: INCCResults.results_init_src_rec isr = (INCCResults.results_init_src_rec)r; listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Source id: {0}", isr.init_src_id) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Initial source measurement: {0}", (isr.pass ? "passed" : "failed")) })); break; case AssaySelector.MeasurementOption.normalization: INCCResults.results_bias_rec br = (INCCResults.results_bias_rec)r; listView1.Items.Add(new ListViewItem(new string[] { string.Format("Normalization results for reference source: {0}", br.sourceId) })); if (br.mode == NormTest.Cf252Doubles) { listView1.Items.Add(new ListViewItem(new string[] { string.Format("Normalization doubles rate expected/measured: {0,13:F3} +- {1,9:F3}", br.biasDblsRateExpectMeas.v, br.biasDblsRateExpectMeas.err) })); } else if (br.mode == NormTest.Cf252Singles) { listView1.Items.Add(new ListViewItem(new string[] { string.Format("Normalization singles rate expected/measured: {0,13:F3} +- {1,9:F3}", br.biasDblsRateExpectMeas.v, br.biasDblsRateExpectMeas.err) })); } else { listView1.Items.Add(new ListViewItem(new string[] { string.Format("Normalization singles rate expected/measured: {0,13:F3} +- {1,9:F3}", br.biasSnglsRateExpectMeas.v, br.biasSnglsRateExpectMeas.err) })); } listView1.Items.Add(new ListViewItem(new string[] { string.Format("Normalization test {0}", (br.pass ? "passed" : "failed")) })); break; case AssaySelector.MeasurementOption.precision: INCCResults.results_precision_rec pr = (INCCResults.results_precision_rec)r; listView1.Items.Add(new ListViewItem(new string[] { "Precision results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Chi-square lower limit: {0,13:F3}", pr.chiSqLowerLimit) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Chi-square upper limit: {0,13:F3}", pr.chiSqUpperLimit) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Sample variance: {0,13:F3}", pr.precSampleVar) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Theoretical variance: {0,13:F3}", pr.precTheoreticalVar) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Chi-square: {0,13:F3}", pr.precChiSq) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Precision test {0}.", (pr.pass ? "passed" : "failed")) })); break; case AssaySelector.MeasurementOption.calibration: INCCMethodResults imrs; bool ok = m.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrs); if (ok && imrs.Count > 0) // should be true for verification and calibration { // we've got a distinct detector id and material type on the methods, so that is the indexer here Dictionary <AnalysisMethod, INCCMethodResult> amimr = imrs[m.INCCAnalysisState.Methods.selector]; // now get an enumerator over the map of method results Dictionary <AnalysisMethod, INCCMethodResult> .Enumerator ai = amimr.GetEnumerator(); while (ai.MoveNext()) { INCCMethodResult imr = ai.Current.Value; if (imr is INCCMethodResults.results_cal_curve_rec) { listView1.Items.Add(new ListViewItem(new string[] { "Passive calibration curve results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3}", ((INCCMethodResults.results_cal_curve_rec)imr).pu_mass.v) })); } else if (imr is INCCMethodResults.results_known_alpha_rec) { listView1.Items.Add(new ListViewItem(new string[] { "Known alpha results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Multiplication: {0,13:F3}", ((INCCMethodResults.results_known_alpha_rec)imr).mult) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Alpha: {0,13:F3}", ((INCCMethodResults.results_known_alpha_rec)imr).alphaK) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3}", ((INCCMethodResults.results_known_alpha_rec)imr).pu_mass.v) })); } else if (imr is INCCMethodResults.results_add_a_source_rec) { listView1.Items.Add(new ListViewItem(new string[] { "Add-a-source results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3}", ((INCCMethodResults.results_add_a_source_rec)imr).pu_mass.v) })); } else if (imr is INCCMethodResults.results_active_rec) { listView1.Items.Add(new ListViewItem(new string[] { "Active calibration curve results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" U235 mass: {0,13:F3}", ((INCCMethodResults.results_active_rec)imr).u235_mass.v) })); } } } break; case AssaySelector.MeasurementOption.verification: case AssaySelector.MeasurementOption.holdup: INCCMethodResults imrvs; bool okv = m.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrvs); if (okv && imrvs.Count > 0) // should be true for verification and calibration { // we've got a distinct detector id and material type on the methods, so that is the indexer here Dictionary <AnalysisMethod, INCCMethodResult> amimr = imrvs[m.INCCAnalysisState.Methods.selector]; // now get an enumerator over the map of method results Dictionary <AnalysisMethod, INCCMethodResult> .Enumerator ai = amimr.GetEnumerator(); while (ai.MoveNext()) { INCCMethodResult imr = ai.Current.Value; if (imr is INCCMethodResults.results_cal_curve_rec) { INCCMethodResults.results_cal_curve_rec d = (INCCMethodResults.results_cal_curve_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Passive calibration curve results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.pu_mass.v, d.pu_mass.err) })); if (d.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_pu_mass.v, d.dcl_minus_asy_pu_mass.err, d.dcl_minus_asy_pu_mass_pct) })); } } else if (imr is INCCMethodResults.results_known_alpha_rec) { INCCMethodResults.results_known_alpha_rec d = (INCCMethodResults.results_known_alpha_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Known alpha results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Multiplication: {0,13:F3}", d.mult) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Alpha: {0,13:F3}", d.alphaK) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.pu_mass.v, d.pu_mass.err) })); if (d.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_pu_mass.v, d.dcl_minus_asy_pu_mass.err, d.dcl_minus_asy_pu_mass_pct) })); } } else if (imr is INCCMethodResults.results_known_m_rec) { INCCMethodResults.results_known_m_rec d = (INCCMethodResults.results_known_m_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Known M results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Multiplication: {0,13:F3}", d.mult) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Alpha: {0,13:F3}", d.alpha) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.pu_mass.v, d.pu_mass.err) })); if (d.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_pu_mass.v, d.dcl_minus_asy_pu_mass.err, d.dcl_minus_asy_pu_mass_pct) })); } } else if (imr is INCCMethodResults.results_multiplicity_rec) { INCCMethodResults.results_multiplicity_rec d = (INCCMethodResults.results_multiplicity_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Passive multiplicity results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Multiplication: {0,13:F3} +- {1,9:F3}", d.mult.v, d.mult.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Alpha: {0,13:F3} +- {1,9:F3}", d.alphaK.v, d.alphaK.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Correction factor: {0,13:F3}", d.corr_factor.v, d.corr_factor.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.pu_mass.v, d.pu_mass.err) })); if (d.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_pu_mass.v, d.dcl_minus_asy_pu_mass.err, d.dcl_minus_asy_pu_mass_pct) })); } } else if (imr is INCCMethodResults.results_add_a_source_rec) { INCCMethodResults.results_add_a_source_rec d = (INCCMethodResults.results_add_a_source_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Add-a-source results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Delta: {0,13:F3} +- {1,9:F3}", d.delta.v, d.delta.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Correction factor: {0,13:F3}", d.corr_factor.v, d.corr_factor.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.pu_mass.v, d.pu_mass.err) })); if (d.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_pu_mass.v, d.dcl_minus_asy_pu_mass.err, d.dcl_minus_asy_pu_mass_pct) })); } } else if (imr is INCCMethodResults.results_curium_ratio_rec) { INCCMethodResults.results_curium_ratio_rec d = (INCCMethodResults.results_curium_ratio_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Curium ratio results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Cm mass: {0,13:F3} +- {1,9:F3}", d.cm_mass.v, d.cm_mass.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.pu.pu_mass.v, d.pu.pu_mass.err) })); if (d.pu.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.pu.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.pu.dcl_minus_asy_pu_mass.v, d.pu.dcl_minus_asy_pu_mass.err, d.pu.dcl_minus_asy_pu_mass_pct) })); } listView1.Items.Add(new ListViewItem(new string[] { string.Format(" U mass: {0,13:F3} +- {1,9:F3}", d.u.mass.v, d.u.mass.err) })); if (d.u.dcl_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared U mass: {0,13:F3}", d.u.dcl_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared - assay U mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.u.dcl_minus_asy_mass.v, d.u.dcl_minus_asy_mass.err, d.u.dcl_minus_asy_mass_pct) })); } listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared U235 mass: {0,13:F3} +- {1,9:F3}", d.u235.mass.v, d.u235.mass.err) })); if (d.u235.dcl_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared U235 mass: {0,13:F3}", d.u235.dcl_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Decl - assay U235 mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.u235.dcl_minus_asy_mass.v, d.u235.dcl_minus_asy_mass.err, d.u235.dcl_minus_asy_mass_pct) })); } } else if (imr is INCCMethodResults.results_truncated_mult_rec) { INCCMethodResults.results_truncated_mult_rec d = (INCCMethodResults.results_truncated_mult_rec)imr; if (d.methodParams.known_eff) { listView1.Items.Add(new ListViewItem(new string[] { "Known efficiency truncated multiplicity results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.k.pu_mass.v, d.k.pu_mass.err) })); if (d.k.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.k.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.k.dcl_minus_asy_pu_mass.v, d.k.dcl_minus_asy_pu_mass.err, d.k.dcl_minus_asy_pu_mass_pct) })); } } if (d.methodParams.solve_eff) { listView1.Items.Add(new ListViewItem(new string[] { "Solve efficiency truncated multiplicity results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Pu mass: {0,13:F3} +- {1,9:F3}", d.s.pu_mass.v, d.s.pu_mass.err) })); if (d.s.dcl_pu_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared Pu mass: {0,13:F3}", d.s.dcl_pu_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay Pu mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.s.dcl_minus_asy_pu_mass.v, d.s.dcl_minus_asy_pu_mass.err, d.s.dcl_minus_asy_pu_mass_pct) })); } } } else if (imr is INCCMethodResults.results_active_rec) { INCCMethodResults.results_active_rec d = (INCCMethodResults.results_active_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Active calibration curve results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" U235 mass: {0,13:F3} +- {1,9:F3}", d.u235_mass.v, d.u235_mass.err) })); if (d.dcl_u235_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared U235 mass: {0,13:F3}", d.dcl_u235_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay U235 mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_u235_mass.v, d.dcl_minus_asy_u235_mass.err, d.dcl_minus_asy_u235_mass_pct) })); } } else if (imr is INCCMethodResults.results_active_passive_rec) { INCCMethodResults.results_active_passive_rec d = (INCCMethodResults.results_active_passive_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Active/passive results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" U235 mass: {0,13:F3} +- {1,9:F3}", d.u235_mass.v, d.u235_mass.err) })); if (d.dcl_u235_mass > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared U235 mass: {0,13:F3}", d.dcl_u235_mass) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay U235 mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_u235_mass.v, d.dcl_minus_asy_u235_mass.err, d.dcl_minus_asy_u235_mass_pct) })); } } else if (imr is INCCMethodResults.results_collar_rec) { INCCMethodResults.results_collar_rec d = (INCCMethodResults.results_collar_rec)imr; listView1.Items.Add(new ListViewItem(new string[] { "Collar results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { string.Format(" U235 mass: {0,13:F3} +- {1,9:F3}", d.u235_mass.v, d.u235_mass.err) })); if (d.dcl_total_u235.v > 0) { listView1.Items.Add(new ListViewItem(new string[] { string.Format(" Declared U235 mass: {0,13:F3} +- {1,9:F3}", d.dcl_total_u235.v, d.dcl_total_u235.err) })); listView1.Items.Add(new ListViewItem(new string[] { string.Format("Declared - assay U235 mass: {0,13:F3} +- {1,9:F3} or {2,6:F2}%", d.dcl_minus_asy_u235_mass.v, d.dcl_minus_asy_u235_mass.err, d.dcl_minus_asy_u235_mass_pct) })); } } } } break; case AssaySelector.MeasurementOption.unspecified: listView1.Items.Add(new ListViewItem(new string[] { "List mode results" + augmenter })); listView1.Items.Add(new ListViewItem(new string[] { "TODO " })); // todo: fill in with something useful for LM break; } } }