public bool Transfer(Multiplicity mup, MultiplicityResult mr, int idx) { if (mr == null) { return(true); } bool res = true; try { SetQCStatus(mup, QCTestStatus.Pass); // marked Pass at the outset MultiplicityCountingRes lmcs = new MultiplicityCountingRes(mup.FA, idx); countresults.Add(mup, lmcs); lmcs.Totals = Totals; lmcs.TransferRawResult(mr); lmcs.TS = new TimeSpan(TS.Ticks); } catch (OutOfMemoryException e) { mup.reason = "Multiplicity transfer " + e.Message; res = false; logger.TraceEvent(LogLevels.Error, 87406, mup.reason); } return(res); }
public MeasPointData GetTheDataPoints(Measurement m) { MeasPointData p = new MeasPointData(m.MeasDate); MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detector.MultiplicityParams]; INCCMethodResult imr = m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod, create: false); switch (AnalysisMethod) { case AnalysisMethod.CalibrationCurve: INCCMethodResults.results_cal_curve_rec ccres = (INCCMethodResults.results_cal_curve_rec)imr; p.Doubles = mcr.DeadtimeCorrectedDoublesRate.v; p.Mass = ccres.dcl_pu240e_mass; break; case AnalysisMethod.KnownA: INCCMethodResults.results_known_alpha_rec kares = (INCCMethodResults.results_known_alpha_rec)imr; p.Doubles = (kares.mult_corr_doubles.v == 0 ? mcr.DeadtimeCorrectedDoublesRate.v : kares.mult_corr_doubles.v); p.Mass = kares.dcl_pu240e_mass; break; case AnalysisMethod.AddASource: INCCMethodResults.results_add_a_source_rec aares = (INCCMethodResults.results_add_a_source_rec)imr; p.Doubles = mcr.DeadtimeCorrectedDoublesRate.v; p.Mass = aares.dcl_pu240e_mass; break; case AnalysisMethod.Active: INCCMethodResults.results_active_rec acres = (INCCMethodResults.results_active_rec)imr; p.Doubles = mcr.DeadtimeCorrectedDoublesRate.v; p.Mass = acres.dcl_u235_mass; break; } return(p); }
public SourceYieldFactoredRates(MultiplicityCountingRes results, Measurement meas) { corrected_doubles = new VTuple(); corrected_triples = new VTuple(); total_corr_fact = new VTuple(); ApplySourceYieldFactor(results, meas); }
public bool Transfer(Multiplicity mup, MultiplicityResult mr, int idx) { if (mr == null) { return(true); } bool res = true; try { SetQCStatus(mup, QCTestStatus.Pass); // marked Pass at the outset MultiplicityCountingRes lmcs = new MultiplicityCountingRes(mup.FA, idx); countresults.Add(mup, lmcs); lmcs.Totals = Totals; lmcs.TransferRawResult(mr); lmcs.TS = new TimeSpan(TS.Ticks); if (dsid.SRType.IsListMode() && lmcs.FA == FAType.FAOff) { lmcs.LMTS[1] = TimeSpan.FromTicks((long)mr.TotalMeasurementTics);//Slow } else if (dsid.SRType.IsListMode() && lmcs.FA == FAType.FAOn) { lmcs.LMTS[0] = TimeSpan.FromTicks((long)mr.TotalMeasurementTics);//Slow } } catch (OutOfMemoryException e) { mup.reason = "Multiplicity transfer " + e.Message; res = false; logger?.TraceEvent(LogLevels.Error, 87406, mup.reason); } return(res); }
public DoublesDclMass GetTheDataPoints(Measurement m) { DoublesDclMass dl = new DoublesDclMass(); dl.dt = m.MeasDate; MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detector.MultiplicityParams]; dl.Doubles = mcr.DeadtimeCorrectedDoublesRate; INCCMethodResult imr = m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod, create: false); switch (AnalysisMethod) { case AnalysisMethod.CalibrationCurve: INCCMethodResults.results_cal_curve_rec ccres = (INCCMethodResults.results_cal_curve_rec)imr; dl.Mass = ccres.pu240e_mass; break; case AnalysisMethod.KnownA: INCCMethodResults.results_known_alpha_rec kares = (INCCMethodResults.results_known_alpha_rec)imr; dl.Mass = kares.pu240e_mass; break; case AnalysisMethod.AddASource: INCCMethodResults.results_add_a_source_rec aares = (INCCMethodResults.results_add_a_source_rec)imr; dl.Mass = aares.pu240e_mass; break; case AnalysisMethod.Active: INCCMethodResults.results_active_rec acres = (INCCMethodResults.results_active_rec)imr; dl.Mass = acres.u235_mass; break; } return(dl); }
unsafe void AddReviewFileCycle(int i, run_rec_ext run, INCCReviewFile.run_rec_ext_plus rrep, Measurement meas, string fn) { Cycle cycle = new Cycle(datalog); try { cycle.UpdateDataSourceId(ConstructedSource.ReviewFile, meas.Detector.Id.SRType, rrep.dt, fn); cycle.seq = (run.run_number > 0 ? run.run_number : i); // INCC run record sequence numbers start at 1 cycle.TS = TimeSpan.FromSeconds(run.run_count_time); /* init run tests */ cycle.SetQCStatus(meas.Detector.MultiplicityParams, QCTestStatus.Pass, run.run_high_voltage); // APluralityOfMultiplicityAnalyzers: creates entry if not found, expand from the single mult key from detector here meas.Add(cycle); /* singles, reals + accidentals, accidentals */ cycle.Totals = (ulong)run.run_singles; MultiplicityCountingRes mcr = new MultiplicityCountingRes(meas.Detector.MultiplicityParams.FA, cycle.seq); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers cycle.CountingAnalysisResults.Add(meas.Detector.MultiplicityParams, mcr); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers mcr.AB.TransferIntermediates(meas.Detector.AB); // copy alpha beta onto the cycle's results mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = run.run_acc; mcr.RASum = run.run_reals_plus_acc; mcr.Scaler1.v = run.run_scaler1; mcr.Scaler2.v = run.run_scaler2; cycle.SinglesRate = run.run_singles / run.run_count_time; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = cycle.Totals; mcr.RawSinglesRate.v = cycle.SinglesRate; // now back-compute the actual limits of the bins for (int n = rrep.n_mult - 1; n >= 0; n--) { if ((run.run_mult_reals_plus_acc[n] > 0.0) || (run.run_mult_acc[n] > 0.0)) { mcr.MinBins = mcr.MaxBins = (ulong)(n + 1); break; } } mcr.RAMult = new ulong[mcr.MaxBins]; mcr.NormedAMult = new ulong[mcr.MaxBins]; mcr.UnAMult = new ulong[mcr.MaxBins]; // todo: compute this // copy the bin values, if any for (ushort j = 0; j < mcr.MaxBins; j++) { mcr.RAMult[j] = (ulong)run.run_mult_reals_plus_acc[j]; mcr.NormedAMult[j] = (ulong)run.run_mult_acc[j]; } ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString() + (rrep.n_mult > 0 ? " n_:" + rrep.n_mult.ToString() + " max:" + mcr.MaxBins.ToString() : " *")); } catch (Exception e) { ctrllog.TraceEvent(LogLevels.Warning, 33085, "Cycle processing error {0} {1}", run, e.Message); } }
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); }
private void TransferCounts (Measurement m) { m.CalcAvgAndSums(); MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[Integ.GetCurrentAcquireDetector().MultiplicityParams]; PassiveSinglesTextBox.Value = mcr.DeadtimeCorrectedSinglesRate.v; PassiveSinglesErrorTextBox.Value = mcr.DeadtimeCorrectedSinglesRate.err; PassiveDoublesTextBox.Value = mcr.DeadtimeCorrectedDoublesRate.v; PassiveDoublesErrorTextBox.Value = mcr.DeadtimeCorrectedDoublesRate.err; }
void AddMCSRDataCycle(int run, DatazFile.Cycle c, Measurement meas, string fname) { Cycle cycle = new Cycle(datalog); try { cycle.UpdateDataSourceId(ConstructedSource.DatazFile, meas.Detector.Id.SRType, c.DTO, fname); cycle.seq = run; cycle.TS = c.Duration; /* init run tests */ cycle.SetQCStatus(meas.Detector.MultiplicityParams, QCTestStatus.None); // APluralityOfMultiplicityAnalyzers: creates entry if not found, expand from the single mult key from detector here meas.Add(cycle); /* singles, reals + accidentals, accidentals */ cycle.Totals = c.Singles; MultiplicityCountingRes mcr = new MultiplicityCountingRes(meas.Detector.MultiplicityParams.FA, cycle.seq); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers cycle.CountingAnalysisResults.Add(meas.Detector.MultiplicityParams, mcr); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers mcr.AB.TransferIntermediates(meas.Detector.AB); // copy alpha beta onto the cycle's results mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = c.Accidentals; mcr.RASum = c.RealsPlusAccidentals; mcr.Scaler1.v = 0; mcr.Scaler2.v = 0; cycle.SinglesRate = cycle.Totals / c.Duration.TotalSeconds; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = cycle.Totals; mcr.RawSinglesRate.v = cycle.SinglesRate; /* number of multiplicity values */ mcr.MinBins = mcr.MaxBins = (ulong)c.BinLen; mcr.RAMult = new ulong[c.BinLen]; mcr.NormedAMult = new ulong[c.BinLen]; mcr.UnAMult = new ulong[c.BinLen]; // not used, not LM /* multiplicity values */ for (ushort j = 0; j < c.BinLen; j++) { mcr.RAMult[j] = c.MultBins[j]; mcr.NormedAMult[j] = c.MultAccBins[j]; } ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString() + ((mcr.RAMult[0] + mcr.NormedAMult[0]) > 0 ? " max:" + mcr.MaxBins.ToString() : " *")); } catch (Exception e) { ctrllog.TraceEvent(LogLevels.Warning, 33085, "cycle processing error {0} {1}", run, e.Message); } }
/// <summary> /// Create parameter list for the results on a cycle /// </summary> /// <param name="mkey">The multiplicity parameters used to select the specific results. There can be more than one such results set per cycle.</param> public void GenParamList(Multiplicity mkey) { GenParamList(); // ^ does the basic INCC5 and new LM cycle stuff // now add the mkey stuff Table = "cycles"; MultiplicityCountingRes pmcr = null; QCTestStatus status = QCTestStatus.None; if (CountingAnalysisResults.HasMultiplicity) { try { pmcr = (MultiplicityCountingRes)CountingAnalysisResults[mkey]; status = qcstatus[mkey].status; } catch (Exception) // mkey not found happens when a param is changed on a VSR that is not reflected back to the default [0] SR { logger?.TraceEvent(LogLevels.Warning, 7832, "Cycle status not set in DB, mkey mismatch: " + mkey.ToString()); } } if (pmcr == null) { pmcr = new MultiplicityCountingRes(); // null results } ps.Add(new DBParamEntry("scaler1", pmcr.Scaler1.v)); ps.Add(new DBParamEntry("scaler2", pmcr.Scaler2.v)); ps.Add(new DBParamEntry("reals_plus_acc", pmcr.RASum)); ps.Add(new DBParamEntry("acc", pmcr.ASum)); ps.Add(new DBParamEntry("mult_reals_plus_acc", pmcr.RAMult)); ps.Add(new DBParamEntry("mult_acc", pmcr.NormedAMult)); ps.Add(new DBParamEntry("scaler1_rate", pmcr.Scaler1Rate.v)); ps.Add(new DBParamEntry("scaler2_rate", pmcr.Scaler2Rate.v)); ps.Add(new DBParamEntry("doubles_rate", pmcr.RawDoublesRate.v)); ps.Add(new DBParamEntry("triples_rate", pmcr.RawTriplesRate.v)); ps.Add(new DBParamEntry("multiplicity_mult", pmcr.multiplication)); ps.Add(new DBParamEntry("multiplicity_alpha", pmcr.multiAlpha)); ps.Add(new DBParamEntry("multiplicity_efficiency", pmcr.efficiency)); ps.Add(new DBParamEntry("mass", pmcr.mass)); ps.Add(new DBParamEntry("status", (int)status)); { // la super hack-a-whack DB.DB db = new DB.DB(true); if (db.TableHasColumn(Table, "mult_acc_un")) { ps.Add(new DBParamEntry("mult_acc_un", pmcr.UnAMult)); } } }
void PlotThePlots(CycleList cl, Multiplicity mkey) { Series s1 = Singles.Series["Vals"]; s1.MarkerStyle = MarkerStyle.Circle; s1.MarkerColor = System.Drawing.Color.SkyBlue; s1.MarkerSize = 5; s1.MarkerBorderColor = System.Drawing.Color.DarkCyan; s1.Color = System.Drawing.Color.MediumPurple; Series s2 = Doubles.Series["Vals"]; s2.MarkerStyle = MarkerStyle.Circle; s2.MarkerColor = System.Drawing.Color.SkyBlue; s2.MarkerSize = 5; s2.MarkerBorderColor = System.Drawing.Color.DarkCyan; s2.Color = System.Drawing.Color.MediumPurple; Series s3 = Triples.Series["Vals"]; s3.MarkerStyle = MarkerStyle.Circle; s3.MarkerColor = System.Drawing.Color.SkyBlue; s3.MarkerSize = 5; s3.MarkerBorderColor = System.Drawing.Color.DarkCyan; s3.Color = System.Drawing.Color.MediumPurple; int i = 0; foreach (Cycle c in cl) { i++; MultiplicityCountingRes mcr = c.MultiplicityResults(mkey); bool somtingfunnyhere = (c.QCStatus(mkey).status != QCTestStatus.Pass); int idx = s1.Points.AddXY(i, mcr.DeadtimeCorrectedSinglesRate.v); // next: vary color and shape based on cycle status/outlier status s2.Points.AddXY(i, mcr.DeadtimeCorrectedDoublesRate.v); s3.Points.AddXY(i, mcr.DeadtimeCorrectedTriplesRate.v); if (somtingfunnyhere) { s1.Points[idx].MarkerColor = System.Drawing.Color.Orchid; s2.Points[idx].MarkerColor = System.Drawing.Color.Orchid; s3.Points[idx].MarkerColor = System.Drawing.Color.Orchid; s1.Points[idx].ToolTip = string.Format("#{0} {1}", c.seq, c.QCStatus(mkey).INCCString()); s3.Points[idx].ToolTip = s2.Points[idx].ToolTip = s1.Points[idx].ToolTip; } } }
public string[] StringifyCycleMultiplicityDetails() { string[] x = null; try { int j = 0; RatesResultEnhanced rrm = countresults.GetFirstRatesResultMod(); // devnote: only the first is used here, still need multiple rate analyzer output x = new string[3]; if (rrm != null) { x[j++] = string.Format("Channel hits (BaseA): {0}", rrm.NsChnImage()); x[j++] = string.Format("Channel hits (CyclC): {0}", NsChnImage()); x[j++] = string.Format("Cycle status text: " + LMLoggers.LognLM.FlattenChars(Message)); System.Collections.IEnumerator iter = countresults.GetATypedResultEnumerator(typeof(AnalysisDefs.Multiplicity)); while (iter.MoveNext()) { MultiplicityCountingRes mcr = (MultiplicityCountingRes)iter.Current; try { string[] temp = mcr.StringifyCurrentMultiplicityDetails(); Array.Resize(ref x, temp.Length + x.Length); Array.Copy(temp, 0, x, j, temp.Length); j += temp.Length; } catch (Exception ex) { logger?.TraceEvent(LogLevels.Error, 87118, "StringifyCycleMultiplicityDetails error: " + ex.Message); } } } else { x = new string[1] { "" }; //Martyn says this is useless. HN 10-6-2015 //x[j++] = "No multiplicity data for JSR-12 instruments."; } } catch (Exception ex2) { logger?.TraceEvent(LogLevels.Error, 87119, "StringifyCycleMultiplicityDetails error: " + ex2.Message); } return(x); }
void LoadFromCurrentCycles() { ResetGrid(); foreach (Cycle c in NC.App.Opstate.Measurement.Cycles) { MultiplicityCountingRes res = c.MultiplicityResults(ah.det.MultiplicityParams); DataGridViewRow r = cyclesGridView.Rows[c.seq - 1]; r.Cells[1].Value = c.Totals.ToString(); if (res != null) { r.Cells[2].Value = res.RASum; r.Cells[3].Value = res.ASum; } else { r.Cells[2].Value = "0"; r.Cells[3].Value = "0"; } } }
void LoadFromCurrentCycles() { ResetGrid(); foreach (Cycle c in NC.App.Opstate.Measurement.Cycles) { MultiplicityCountingRes res = c.MultiplicityResults(ah.det.MultiplicityParams); // APluralityOfMultiplicityAnalyzers: expand in some logical manner, e.g. enable user to select the analyzer and related results for manual entry and assignment DataGridViewRow r = cyclesGridView.Rows[c.seq - 1]; r.Cells[1].Value = c.Totals.ToString(); if (res != null) { r.Cells[2].Value = res.RASum; r.Cells[3].Value = res.ASum; } else { r.Cells[2].Value = "0"; r.Cells[3].Value = "0"; } } }
/// <summary> /// Create parameter list for the results on a cycle /// </summary> /// <param name="mkey">The multiplicity parameters used to select the specific results. There can be more than one such results set per cycle.</param> public void GenParamList(Multiplicity mkey) { GenParamList(); // does the basic INCC5 and new LM cycle stuff //now add the mkey stuff Table = "cycles"; MultiplicityCountingRes pmcr = null; QCTestStatus status = QCTestStatus.None; if (CountingAnalysisResults.HasMultiplicity) { try { pmcr = (MultiplicityCountingRes)CountingAnalysisResults[mkey]; status = qcstatus[mkey].status; } catch (Exception) // mkey not found happens when a param is changed on a VSR that is not reflected back to the default [0] SR { logger.TraceEvent(NCCReporter.LogLevels.Warning, 7832, "Status not set due to mkey issue: " + mkey.ToString()); } } if (pmcr == null) { pmcr = new MultiplicityCountingRes(); // null results } ps.Add(new DBParamEntry("scaler1", pmcr.Scaler1.v)); ps.Add(new DBParamEntry("scaler2", pmcr.Scaler2.v)); ps.Add(new DBParamEntry("reals_plus_acc", pmcr.RASum)); ps.Add(new DBParamEntry("acc", pmcr.ASum)); ps.Add(new DBParamEntry("mult_reals_plus_acc", pmcr.RAMult)); ps.Add(new DBParamEntry("mult_acc", pmcr.NormedAMult)); ps.Add(new DBParamEntry("scaler1_rate", pmcr.Scaler1Rate.v)); ps.Add(new DBParamEntry("scaler2_rate", pmcr.Scaler2Rate.v)); ps.Add(new DBParamEntry("doubles_rate", pmcr.RawDoublesRate.v)); ps.Add(new DBParamEntry("triples_rate", pmcr.RawTriplesRate.v)); ps.Add(new DBParamEntry("multiplicity_mult", pmcr.multiplication)); ps.Add(new DBParamEntry("multiplicity_alpha", pmcr.multiAlpha)); ps.Add(new DBParamEntry("multiplicity_efficiency", pmcr.efficiency)); ps.Add(new DBParamEntry("mass", pmcr.mass)); ps.Add(new DBParamEntry("status", (Int32)status)); }
protected void ApplySourceYieldFactor(MultiplicityCountingRes results, Measurement meas) { double delta_days; // For Cf, this source yield factor will change -- So Martyn says. Hn 7.23.2015 -- Martyn likes happyfun delta_days = (meas.MeasDate - meas.Norm.refDate).TotalDays; //Now, K0 is modified based on whether AmLi or Cf normalization is chosen.... happyfun if (meas.Norm.biasMode == NormTest.Cf252Doubles || meas.Norm.biasMode == NormTest.Cf252Singles) { source_yield_factor = Math.Pow(2.0, (delta_days / Isotopics.CF252HL)); } else { source_yield_factor = Math.Pow(2.0, (delta_days / Isotopics.AM241HL)); } corrected_doubles.v = source_yield_factor * results.DeadtimeCorrectedDoublesRate.v; corrected_doubles.err = source_yield_factor * results.DeadtimeCorrectedDoublesRate.err; corrected_triples.v = source_yield_factor * results.DeadtimeCorrectedTriplesRate.v; corrected_triples.err = source_yield_factor * results.DeadtimeCorrectedTriplesRate.err; total_corr_fact.v = source_yield_factor * meas.Norm.currNormalizationConstant.v; total_corr_fact.err = source_yield_factor * meas.Norm.currNormalizationConstant.err; }
public static void SetAlphaBeta(Multiplicity mkey, MultiplicityCountingRes mcr) { ABKey abkey = new ABKey(mkey, mcr); SetAlphaBeta(abkey, mcr.AB); }
unsafe void AddReviewFileCycle(int i, run_rec_ext run, INCCReviewFile.run_rec_ext_plus rrep, Measurement meas, string fn) { Cycle cycle = new Cycle(datalog); try { cycle.UpdateDataSourceId(ConstructedSource.ReviewFile, meas.Detectors[0].Id.SRType, rrep.dt, fn); cycle.seq = (run.run_number > 0 ? run.run_number : i); // INCC run record sequence numbers start at 1 cycle.TS = TimeSpan.FromSeconds(run.run_count_time); /* init run tests */ cycle.SetQCStatus(meas.Detectors[0].MultiplicityParams, QCTestStatus.Pass, run.run_high_voltage); // multmult creates entry if not found meas.Add(cycle); /* singles, reals + accidentals, accidentals */ cycle.Totals = (ulong)run.run_singles; MultiplicityCountingRes mcr = new MultiplicityCountingRes(meas.Detectors[0].MultiplicityParams.FA, cycle.seq); // multmult cycle.CountingAnalysisResults.Add(meas.Detectors[0].MultiplicityParams, mcr); // multmult mcr.AB.TransferIntermediates(meas.Detectors[0].AB); // copy alpha beta onto the cycle's results mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = run.run_acc; mcr.RASum = run.run_reals_plus_acc; mcr.Scaler1.v = run.run_scaler1; mcr.Scaler2.v = run.run_scaler2; cycle.SinglesRate = run.run_singles / run.run_count_time; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = cycle.Totals; mcr.RawSinglesRate.v = cycle.SinglesRate; // now back-compute the actual limits of the bins for (int n = rrep.n_mult - 1; n >= 0; n--) { if ((run.run_mult_reals_plus_acc[n] > 0.0) || (run.run_mult_acc[n] > 0.0)) { mcr.MinBins = mcr.MaxBins = (ulong)(n + 1); break; } } mcr.RAMult = new ulong[mcr.MaxBins]; mcr.NormedAMult = new ulong[mcr.MaxBins]; mcr.UnAMult = new ulong[mcr.MaxBins]; // todo: compute this // copy the bin values, if any for (UInt16 j = 0; j < mcr.MaxBins; j++) { mcr.RAMult[j] = (ulong)run.run_mult_reals_plus_acc[j]; mcr.NormedAMult[j] = (ulong)run.run_mult_acc[j]; } ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString() + (rrep.n_mult > 0 ? " n_:" + rrep.n_mult.ToString() + " max:" + mcr.MaxBins.ToString() : " *")); } catch (Exception e) { ctrllog.TraceEvent(LogLevels.Warning, 33085, "Cycle processing error {0} {1}", run, e.Message); } }
void AddTestDataCycle(int run, uint run_seconds, double run_count_time, Measurement meas, TestDataFile td, string pivot = "", int cfindex = -1) { Cycle cycle = new Cycle(datalog); try { cycle.UpdateDataSourceId(ConstructedSource.CycleFile, meas.Detectors[0].Id.SRType, td.DTO.AddSeconds(run_seconds), td.Filename); cycle.seq = run; cycle.TS = TimeSpan.FromSeconds(run_count_time); // dev note: check if this is always only in seconds, or fractions of a second // hn -- 9/4/14 -- not integer for count time. Convert from double seconds here. // Joe still has force to int. bleck! /* init run tests */ cycle.SetQCStatus(meas.Detectors[0].MultiplicityParams, QCTestStatus.None); // multmult creates entry if not found meas.Add(cycle, cfindex); /* singles, reals + accidentals, accidentals */ string l = td.reader.ReadLine(); string[] zorks = l.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); double[] v = new double[5]; for (int z = 0; z < 5; z++) { double d; bool b = Double.TryParse(zorks[z], out d); if (b) v[z] = d; } cycle.Totals = (ulong)v[0]; MultiplicityCountingRes mcr = new MultiplicityCountingRes(meas.Detectors[0].MultiplicityParams.FA, cycle.seq); // multmult cycle.CountingAnalysisResults.Add(meas.Detectors[0].MultiplicityParams, mcr); // multmult mcr.AB.TransferIntermediates(meas.Detectors[0].AB); // copy alpha beta onto the cycle's results mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = v[4]; mcr.RASum = v[3]; mcr.Scaler1.v = v[1]; mcr.Scaler2.v = v[2]; cycle.SinglesRate = v[0] / run_count_time; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = cycle.Totals; mcr.RawSinglesRate.v = cycle.SinglesRate; /* number of multiplicity values */ string mv = td.reader.ReadLine(); UInt16 k = 0; UInt16.TryParse(mv, out k); if (k == 0) // test data files require an entry with 1 bin set 0s for the absence of multiplicity, go figure { ctrllog.TraceEvent(LogLevels.Error, 440, "This" + pivot + " cycle " + run.ToString() + " has no good multiplicity data."); return; } mcr.MinBins = mcr.MaxBins = k; mcr.RAMult = new ulong[k]; mcr.NormedAMult = new ulong[k]; mcr.UnAMult = new ulong[k]; // todo: compute this /* multiplicity values */ for (UInt16 j = 0; j < k; j++) { string ra = td.reader.ReadLine(); string[] blorks = ra.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); double[] ve = new double[2]; for (int z = 0; z < 2; z++) { double d; bool b = Double.TryParse(blorks[z], out d); if (b) ve[z] = d; } mcr.RAMult[j] = (ulong)ve[0]; mcr.NormedAMult[j] = (ulong)ve[1]; } ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString() + pivot + ((mcr.RAMult[0] + mcr.NormedAMult[0]) > 0 ? " max:" + mcr.MaxBins.ToString() : " *")); } catch (Exception e) { ctrllog.TraceEvent(LogLevels.Warning, 33085, pivot + "cycle processing error {0} {1} {2}", run, e.Message, pivot); } }
static void CalculateVerificationResults(this Measurement meas, Multiplicity mkey, MultiplicityCountingRes results) { Tuple normal_mass = new Tuple(-1, 0), backup_mass = new Tuple(-1, 0); try { if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.CalibrationCurve)) { // get the current results_cal_curve_rec and cal_curve params //dev note: the rates as computed by the first and second phases are not yet on ccres, because they exist soley on the counting results MultiplicityCountingRes instance 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); INCCAnalysisParams.CalCurveResult status = INCCAnalysisParams.CalCurveResult.Unknown; if (cal_curve == null) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10199, "No " + AnalysisMethod.KnownA.FullName() + " method parameters found"); return; } if (cal_curve.CalCurveType != INCCAnalysisParams.CalCurveType.HM) { Tuple pu240e = new Tuple(); Tuple doubles; if (cal_curve.cev.useSingles) // the 2009 MTS hack doubles = new Tuple(results.rates.GetDTCRates(RatesAdjustments.DeadtimeCorrected).Singles); else doubles = new Tuple(results.rates.GetDTCRates(RatesAdjustments.DeadtimeCorrected).Doubles); status = INCCAnalysis.CalculateCalibrationCurveOnly(cal_curve.cev, out pu240e, results.rates, doubles, RatesAdjustments.DeadtimeCorrected); // rates (triples) not used ccres.pu240e_mass = pu240e; } else { // get the item id from the acquire record or the ItemId on the measurement itself // if there is no item id use the empty default item id // dev note: at some point the acquire record item id becomes a full ItemId record on the measurmeent //if not NC.App.DB.ItemIdSet.Contains AcquireState.item_id then // get the default empty one //end // from HEAVY_M.cpp INCCAnalysis.calc_heavy_metal( cal_curve.heavy_metal_corr_factor, cal_curve.heavy_metal_reference, results.rates.DTCRates.Singles, results.rates.DTCRates.Doubles, ref ccres.heavy_metal_content, ref ccres.heavy_metal_correction, ref ccres.heavy_metal_corr_singles, ref ccres.heavy_metal_corr_doubles, meas); status = INCCAnalysis.CalculateCalibrationCurveOnly(cal_curve.cev, out ccres.pu240e_mass, results.rates, ccres.heavy_metal_corr_doubles, RatesAdjustments.DeadtimeCorrected); ccres.pu240e_mass.v *= meas.MeasurementId.Item.length; ccres.pu240e_mass.err *= meas.MeasurementId.Item.length; } if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { string msg = String.Format("Passive calibration curve failed mass limits of {0} and {1}", cal_curve.cev.lower_mass_limit, cal_curve.cev.upper_mass_limit); meas.AddErrorMessage(msg, 10196, mkey); } else if (status != INCCAnalysisParams.CalCurveResult.Success) { meas.AddErrorMessage("Passive calibration curve analysis error", 10197, mkey); } if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { ccres.dcl_pu_mass = meas.AcquireState.mass; // another requirement for the acquire state meas.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 10133, "calc_mass/calc_u235_mass are called next"); if (cal_curve.CalCurveType != INCCAnalysisParams.CalCurveType.U) { INCCAnalysis.calc_mass(ccres.pu240e_mass, ref ccres.pu_mass, ref ccres.dcl_pu_mass, ref ccres.dcl_pu240e_mass, ref ccres.dcl_minus_asy_pu_mass, ref ccres.dcl_minus_asy_pu_mass_pct, ref ccres.pass, meas); } else { INCCAnalysis.calc_u235_mass(cal_curve.percent_u235, ccres.pu240e_mass, ref ccres.pu_mass, ref ccres.dcl_pu_mass, ref ccres.dcl_minus_asy_pu_mass, ref ccres.dcl_minus_asy_pu_mass_pct, ref ccres.pass, meas); } if (!ccres.pass) { meas.AddWarningMessage("Passive calibration curve: failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Passive calibration curve: passed stratum rejection limits", 10200, mkey); } if (ccres.pu240e_mass.v > ccres.methodParams.cev.upper_mass_limit) { meas.AddWarningMessage("Passive calibration curve: upper Pu240e mass limit exceeded.", 10210, mkey); } if (ccres.pu240e_mass.v < ccres.methodParams.cev.lower_mass_limit) { meas.AddWarningMessage("Passive calibration curve: lower Pu240e mass limit exceeded.", 10211, mkey); } } // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.CalibrationCurve) { normal_mass.CopyFrom(ccres.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.CalibrationCurve) { backup_mass.CopyFrom(ccres.pu240e_mass); } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.KnownA)) { INCCMethodResults.results_known_alpha_rec kares = (INCCMethodResults.results_known_alpha_rec) meas.INCCAnalysisResults.LookupMethodResults(mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownA, true); INCCAnalysisParams.known_alpha_rec ka_params = (INCCAnalysisParams.known_alpha_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.KnownA); if (ka_params == null) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10199, "No Known alpha method parameters found"); return; } bool success = false; kares.dcl_pu_mass = meas.AcquireState.mass; // dev note: another use of acq, a requirement, here // copy the input calibration params to the copy on the results rec, to be saved with the KA results kares.methodParams = new INCCAnalysisParams.known_alpha_rec(ka_params); if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.Conventional) { INCCMethodResults.results_known_alpha_rec karesdup = INCCAnalysis.CalculateKnownAlpha(mkey, results.rates, meas, RatesAdjustments.DeadtimeCorrected); // rates (triples) not used if (karesdup != null) // we have the new mass results, and they are preserved in the results map { success = true; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha results for pu240E {0} +- {1}", karesdup.pu240e_mass.v, karesdup.pu240e_mass.err); } } else if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.HeavyMetalCorrection) { INCCAnalysis.calc_heavy_metal( ka_params.heavy_metal_corr_factor, ka_params.heavy_metal_reference, results.rates.DTCRates.Singles, results.rates.DTCRates.Doubles, ref kares.heavy_metal_content, ref kares.heavy_metal_correction, ref kares.corr_singles, ref kares.corr_doubles, meas); Rates HMSDRates = new Rates(); HMSDRates.DeadtimeCorrectedRates.Singles.CopyFrom(kares.corr_singles); HMSDRates.DeadtimeCorrectedRates.Doubles.CopyFrom(kares.corr_doubles); INCCMethodResults.results_known_alpha_rec karesdup = INCCAnalysis.CalculateKnownAlpha(mkey, HMSDRates, meas, RatesAdjustments.DeadtimeCorrected); if (karesdup != null) // we have the new mass results, and they are preserved in the results map { success = true; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha HM results for pu240E {0} +- {1}", karesdup.pu240e_mass.v, karesdup.pu240e_mass.err); } kares.pu240e_mass.v *= meas.MeasurementId.Item.length; kares.pu240e_mass.err *= meas.MeasurementId.Item.length; } else if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.MoistureCorrAppliedToDryAlpha) { success = INCCAnalysis.calc_known_alpha_moisture_corr( results.rates.DTCRates.Singles, results.rates.DTCRates.Doubles, results.Scaler1, results.Scaler2, ref kares.corr_singles, /* ring ratio */ ref kares.corr_factor, ref kares.dry_alpha_or_mult_dbls, /* dry alpha */ ref kares.mult_corr_doubles, ref kares.mult, ref kares.alphaK, ref kares.pu240e_mass, ka_params, meas, mkey); if (success) meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha MoistureCorrAppliedToDryAlpha results for pu240E {0} +- {1}", kares.pu240e_mass.v, kares.pu240e_mass.err); } else if (ka_params.known_alpha_type == INCCAnalysisParams.KnownAlphaVariant.MoistureCorrAppliedToMultCorrDoubles) { success = INCCAnalysis.calc_known_alpha_moisture_corr_mult_doubles( results.rates.DTCRates.Singles, results.rates.DTCRates.Doubles, results.Scaler1, results.Scaler2, ref kares.corr_singles, /* ring ratio */ ref kares.corr_factor, ref kares.dry_alpha_or_mult_dbls, /* moist mult_corr_doubles */ ref kares.mult_corr_doubles, ref kares.mult, ref kares.alphaK, ref kares.pu240e_mass, ka_params, meas, mkey); if (success) meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Known alpha MoistureCorrAppliedToMultCorrDoubles results for pu240E {0} +- {1}", kares.pu240e_mass.v, kares.pu240e_mass.err); } if (success) { INCCAnalysis.calc_mass(kares.pu240e_mass, ref kares.pu_mass, ref kares.dcl_pu_mass, ref kares.dcl_pu240e_mass, ref kares.dcl_minus_asy_pu_mass, ref kares.dcl_minus_asy_pu_mass_pct, ref kares.pass, meas); } else { meas.AddErrorMessage("Known alpha analysis error", 10199, mkey); } if (!kares.pass) { meas.AddWarningMessage("Known alpha: failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Known alpha: passed stratum rejection limits", 10200, mkey); } if (kares.pu240e_mass.v > kares.methodParams.cev.upper_mass_limit) { meas.AddWarningMessage("Known alpha: upper Pu240e mass limit exceeded.", 10210, mkey); } if (kares.pu240e_mass.v < kares.methodParams.cev.lower_mass_limit) { meas.AddWarningMessage("Known alpha: lower Pu240e mass limit exceeded.", 10211, mkey); } // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.KnownA) { normal_mass.CopyFrom(kares.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.KnownA) { backup_mass.CopyFrom(kares.pu240e_mass); } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Multiplicity)) { double error = 0.0; INCCAnalysisParams.multiplicity_rec mul_param = (INCCAnalysisParams.multiplicity_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.Multiplicity); if (mul_param == null) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10198, "No Multiplicity method parameters found"); return; } INCCMethodResults.results_multiplicity_rec mmres = (INCCMethodResults.results_multiplicity_rec)meas.INCCAnalysisResults.LookupMethodResults( mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Multiplicity, true); // weird rates (triples) used, but they are wrong (see note line 568 avg_sums.cs) INCCMethodResults.results_multiplicity_rec mmresdup = INCCAnalysis.CalculateMultiplicity(mkey, results.covariance_matrix, results.rates.GetDTCRates(RatesAdjustments.DeadtimeCorrected), meas, RatesAdjustments.DeadtimeCorrected); if (mmresdup != null) // we have the new mass results, and they are preserved in the results map { meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Multiplicity results for pu240E {0} +- {1}", mmres.pu240e_mass.v, mmres.pu240e_mass.err); if (meas.AcquireState.acquire_type == AcquireConvergence.Pu240EffPrecision) { if (mmres.pu240e_mass.v != 0.0) { error = mmres.pu240e_mass.err / mmres.pu240e_mass.v * 100.0; if (error > meas.AcquireState.meas_precision) { meas.AddWarningMessage(String.Format("Multiplicity: Pu240e error = {0}%", error), 10198, mkey); } } } mmres.dcl_pu_mass = meas.AcquireState.mass; // another use of acq, a requirement, here INCCAnalysis.calc_mass(mmres.pu240e_mass, ref mmres.pu_mass, ref mmres.dcl_pu_mass, ref mmres.dcl_pu240e_mass, ref mmres.dcl_minus_asy_pu_mass, ref mmres.dcl_minus_asy_pu_mass_pct, ref mmres.pass, meas); if (!mmres.pass) { meas.AddWarningMessage("Multiplicity: failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Multiplicity: passed stratum rejection limits", 10200, mkey); } if (mul_param.solve_efficiency == INCCAnalysisParams.MultChoice.CONVENTIONAL_MULT_WEIGHTED) // todo: implement Weighted { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 36010, "CONVENTIONAL_MULT_WEIGHTED Multiplicity measurement results"); } else if (mul_param.solve_efficiency == INCCAnalysisParams.MultChoice.MULT_DUAL_ENERGY_MODEL) // todo: implement DE { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 36010, "MULT_DUAL_ENERGY_MODEL Multiplicity measurement results"); } // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.Multiplicity) { normal_mass.CopyFrom(mmres.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.Multiplicity) { backup_mass.CopyFrom(mmres.pu240e_mass); } } else { meas.AddErrorMessage("Multiplicity analysis error", 10198, mkey); } // copy the input calib to the results rec mmres.methodParams = new INCCAnalysisParams.multiplicity_rec(mul_param); } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.KnownM)) { INCCMethodResults.results_known_m_rec kmres = INCCAnalysis.CalculateKnownM(mkey, results, meas, RatesAdjustments.DeadtimeCorrected); // calc mass if (kmres != null) // you have calculated well my child { INCCAnalysis.calc_mass(kmres.pu240e_mass, ref kmres.pu_mass, ref kmres.dcl_pu_mass, ref kmres.dcl_pu240e_mass, ref kmres.dcl_minus_asy_pu_mass, ref kmres.dcl_minus_asy_pu_mass_pct, ref kmres.pass, meas); if (!kmres.pass) { meas.AddWarningMessage("Known M: failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Known M: passed stratum rejection limits", 10200, mkey); } if (kmres.pu240e_mass.v > kmres.methodParams.upper_mass_limit) { meas.AddWarningMessage("Known M: upper Pu240e mass limit exceeded.", 10210, mkey); } if (kmres.pu240e_mass.v < kmres.methodParams.lower_mass_limit) { meas.AddWarningMessage("Known M: lower Pu240e mass limit exceeded.", 10211, mkey); } // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.KnownM) { normal_mass.CopyFrom(kmres.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.KnownM) { backup_mass.CopyFrom(kmres.pu240e_mass); } } else { meas.AddErrorMessage("Known M: analysis error", 10198, mkey); } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Active)) { INCCAnalysisParams.active_rec act_param = (INCCAnalysisParams.active_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.Active); if (act_param == null) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10198, "No Active method parameters found"); return; } INCCMethodResults.results_active_rec actres = (INCCMethodResults.results_active_rec)meas.INCCAnalysisResults.LookupMethodResults( mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.Active, true); /* calculate active doubles rate corrected for source yield factor */ //line 331 if calc_asy.cpp Measurement.SourceYieldFactoredRates syfr = new Measurement.SourceYieldFactoredRates(results, meas); // line 1267 of calc_asy.cpp //Martyn says we need stuff here to deal with Cf active measurements HN 7.23.2015 actres.k0.v = syfr.source_yield_factor; actres.k = new Tuple(syfr.total_corr_fact); actres.k1 = new Tuple(meas.Norm.currNormalizationConstant); // This stays the same for Cf. HN 7.23.2015 INCCAnalysisParams.CalCurveResult status = INCCAnalysis.CalculateCalibrationCurveOnly(act_param.cev, out actres.u235_mass, results.rates, syfr.corrected_doubles, RatesAdjustments.DeadtimeCorrected); if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { string msg = String.Format("Active calibration curve failed mass limits of {0} and {1}", act_param.cev.lower_mass_limit, act_param.cev.upper_mass_limit); meas.AddErrorMessage(msg, 10196, mkey); } else if (status != INCCAnalysisParams.CalCurveResult.Success) { meas.AddErrorMessage("Active calibration curve analysis error", 10197, mkey); } meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 240, "Active results for U235 {0} +- {1}", actres.u235_mass.v, actres.u235_mass.err); if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { actres.dcl_u235_mass = meas.AcquireState.mass; INCCAnalysis.calc_decl_minus_assay_u235(actres.u235_mass, actres.dcl_u235_mass, ref actres.dcl_minus_asy_u235_mass, ref actres.dcl_minus_asy_u235_mass_pct, ref actres.pass, meas); if (!actres.pass) { meas.AddWarningMessage("Active calibration curve: failed stratum rejection limits", 10198, mkey); } else if (!meas.Stratum.Unset) { meas.AddWarningMessage("Active calibration curve: passed stratum rejection limits", 10200, mkey); } if (actres.u235_mass.v > actres.methodParams.cev.upper_mass_limit) { meas.AddWarningMessage("Active calibration curve: upper U235 mass limit exceeded.", 10210, mkey); } if (actres.u235_mass.v < actres.methodParams.cev.lower_mass_limit) { meas.AddWarningMessage("Active calibration curve: lower U235 mass limit exceeded.", 10211, mkey); } } // normal and backup retention not performed for active } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.ActiveMultiplicity)) { // sets results class' mult v,err values at end of calculation INCCMethodResults.results_active_mult_rec res = INCCAnalysis.CalculateActiveMultiplicity(mkey, results, meas, RatesAdjustments.DeadtimeCorrected); if (res == null) { meas.AddErrorMessage("Active multiplicity analysis error", 10152, mkey); } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.TruncatedMultiplicity)) { INCCMethodResults.results_truncated_mult_rec res = INCCAnalysis.CalculateTruncatedMult(mkey, results, meas, RatesAdjustments.DeadtimeCorrected); // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.TruncatedMultiplicity) { if (res.methodParams.known_eff) normal_mass.CopyFrom(res.k.pu240e_mass); else normal_mass.CopyFrom(res.s.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.TruncatedMultiplicity) { if (res.methodParams.known_eff) backup_mass.CopyFrom(res.k.pu240e_mass); else backup_mass.CopyFrom(res.s.pu240e_mass); } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.Collar)) { meas.AddWarningMessage("Collar mass results", 10153, mkey); // NEXT: Collar is incomplete, new design from IAEA is pending, this is a big task INCCAnalysis.CalculateCollar(mkey, results, meas, RatesAdjustments.DeadtimeCorrected); } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.ActivePassive)) { INCCAnalysisParams.active_passive_rec act_param = (INCCAnalysisParams.active_passive_rec)meas.INCCAnalysisState.Methods.GetMethodParameters(AnalysisMethod.ActivePassive); if (act_param == null) { meas.Logger.TraceEvent(NCCReporter.LogLevels.Warning, 10198, "No active/passive method parameters found"); return; } INCCMethodResults.results_active_passive_rec actres = (INCCMethodResults.results_active_passive_rec)meas.INCCAnalysisResults.LookupMethodResults( mkey, meas.INCCAnalysisState.Methods.selector, AnalysisMethod.ActivePassive, true); INCCAnalysis.CalculateActivePassive(mkey, results, meas, RatesAdjustments.DeadtimeCorrected); //line 1134 if calc_asy.cpp // calculate delta doubles and error from passive and active doubles Measurement.SourceYieldFactoredRates syfr = new Measurement.SourceYieldFactoredRates(results, meas); actres.k0.v = syfr.source_yield_factor; actres.k = new Tuple(syfr.total_corr_fact); actres.k1 = new Tuple(meas.Norm.currNormalizationConstant); actres.delta_doubles.v = syfr.corrected_doubles.v - results.DeadtimeCorrectedDoublesRate.v; actres.delta_doubles.err = Math.Sqrt((syfr.corrected_doubles.v * results.DeadtimeCorrectedDoublesRate.err) + (syfr.corrected_doubles.v * results.DeadtimeCorrectedDoublesRate.err)); INCCAnalysisParams.CalCurveResult status = INCCAnalysis.CalculateCalibrationCurveOnly(act_param.cev, out actres.u235_mass, results.rates, actres.delta_doubles, RatesAdjustments.DeadtimeCorrected); if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { string msg = String.Format("Active/passive calibration curve failed mass limits of {0} and {1}", act_param.cev.lower_mass_limit, act_param.cev.upper_mass_limit); meas.AddErrorMessage(msg, 10196, mkey); } else if (status != INCCAnalysisParams.CalCurveResult.Success) { meas.AddErrorMessage("Active/passive calibration curve analysis error", 10197, mkey); } if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { actres.dcl_u235_mass = meas.AcquireState.mass; INCCAnalysis.calc_decl_minus_assay_u235(actres.u235_mass, actres.dcl_u235_mass, ref actres.dcl_minus_asy_u235_mass, ref actres.dcl_minus_asy_u235_mass_pct, ref actres.pass, meas); if (!actres.pass) { meas.AddWarningMessage("Active/passive: failed stratum rejection limits", 10198, mkey); } else if (!meas.Stratum.Unset) { meas.AddWarningMessage("Active/passive: passed stratum rejection limits", 10200, mkey); } if (actres.u235_mass.v > actres.methodParams.cev.upper_mass_limit) { meas.AddWarningMessage("Active/passive: upper U235 mass limit exceeded.", 10210, mkey); } if (actres.u235_mass.v < actres.methodParams.cev.lower_mass_limit) { meas.AddWarningMessage("Active/passive: lower U235 mass limit exceeded.", 10211, mkey); } } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource)) { INCCAnalysisParams.CalCurveResult status; INCCMethodResults.results_add_a_source_rec res = null; // gotta do a sanity check for the AAS cycles, they may not be there due to unfinished processing in the overall code if (meas.CFCycles != null) { res = INCCAnalysis.CalculateAddASource(mkey, results, meas, RatesAdjustments.DeadtimeCorrected, out status); } else { meas.AddErrorMessage("Add-a-source calibration curve cycles not present error", 10197, mkey); status = INCCAnalysisParams.CalCurveResult.EpicFailLOL; } if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { string msg = String.Format("Add-a-source calibration curve failed mass limits of {0} and {1}", res.methodParams.cev.lower_mass_limit, res.methodParams.cev.upper_mass_limit); meas.AddErrorMessage(msg, 10196, mkey); } else if (status != INCCAnalysisParams.CalCurveResult.Success) { meas.AddErrorMessage("Add-a-source calibration curve analysis error", 10197, mkey); } if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { res.dcl_pu_mass = meas.AcquireState.mass; INCCAnalysis.calc_mass(res.pu240e_mass, ref res.pu_mass, ref res.dcl_pu_mass, ref res.dcl_pu240e_mass, ref res.dcl_minus_asy_pu_mass, ref res.dcl_minus_asy_pu_mass_pct, ref res.pass, meas); if (!res.pass) { meas.AddWarningMessage("Add-a-source calibration curve: failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Add-a-source calibration curve: passed stratum rejection limits", 10200, mkey); } if (res.pu240e_mass.v > res.methodParams.cev.upper_mass_limit) { meas.AddWarningMessage("Add-a-source calibration curve: upper Pu240e mass limit exceeded.", 10210, mkey); } if (res.pu240e_mass.v < res.methodParams.cev.lower_mass_limit) { meas.AddWarningMessage("Add-a-source calibration curve: lower Pu240e mass limit exceeded.", 10211, mkey); } // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.AddASource) { normal_mass.CopyFrom(res.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.AddASource) { backup_mass.CopyFrom(res.pu240e_mass); } } } if (meas.INCCAnalysisState.Methods.Has(AnalysisMethod.CuriumRatio)) { INCCAnalysisParams.CalCurveResult status; INCCMethodResults.results_curium_ratio_rec res = INCCAnalysis.CalculateCuriumRatio(mkey, results, meas, RatesAdjustments.DeadtimeCorrected, out status); if (status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { string msg = String.Format("Curium ratio calibration curve failed mass limits of {0} and {1}", res.methodParams.cev.lower_mass_limit, res.methodParams.cev.upper_mass_limit); meas.AddErrorMessage(msg, 10196, mkey); } else if (status != INCCAnalysisParams.CalCurveResult.Success) { meas.AddErrorMessage("Curium ratio calibration curve analysis error", 10197, mkey); } if (status == INCCAnalysisParams.CalCurveResult.Success || status == INCCAnalysisParams.CalCurveResult.FailedOnMassLimit) { INCCAnalysisParams.cm_pu_ratio_rec cm_pu_ratio = NC.App.DB.Cm_Pu_RatioParameters.Get(); // load from DB, just like test params, // dev note: better not to ref DB here, because this is a one-off state retrieval and no other DB access occurs during mass calc processing, but that is how it works this morning //calc curium mass INCCAnalysis.calc_curium_mass(res, cm_pu_ratio, meas); res.u.dcl_mass = cm_pu_ratio.cm_dcl_u_mass; res.u235.dcl_mass = cm_pu_ratio.cm_dcl_u235_mass; if (!res.pu.pass) { meas.AddWarningMessage("Curium ratio: Pu failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Curium ratio: Pu passed stratum rejection limits", 10200, mkey); } if (!res.u.pass) { meas.AddWarningMessage("Curium ratio: U failed stratum rejection limits", 10198, mkey); } else { meas.AddWarningMessage("Curium ratio: U passed stratum rejection limits", 10200, mkey); } // normal and backup retention if (meas.INCCAnalysisState.Methods.Normal == AnalysisMethod.CuriumRatio) { normal_mass.CopyFrom(res.pu.pu240e_mass); } if (meas.INCCAnalysisState.Methods.Backup == AnalysisMethod.CuriumRatio) { backup_mass.CopyFrom(res.pu.pu240e_mass); } } } // annotate the final results method marker on the INCC results instance. INCCMethodResults imr = null; if (normal_mass.v != -1.0) { bool got = meas.INCCAnalysisResults.TryGetINCCResults(mkey, out imr); if (got) imr.primaryMethod = meas.INCCAnalysisState.Methods.Normal; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10100, "Verification primary method {0} with mass {1} is from the normal method", imr.primaryMethod.ToString(), normal_mass.v); } else if (backup_mass.v != -1.0) { bool got = meas.INCCAnalysisResults.TryGetINCCResults(mkey, out imr); if (got) imr.primaryMethod = meas.INCCAnalysisState.Methods.Backup; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10101, "Verification primary method {0} with mass {1} is from the backup method", imr.primaryMethod.ToString(), backup_mass.v); } if ((normal_mass.v != -1.0) && (backup_mass.v != -1.0)) { if (meas.INCCAnalysisState.Methods.Backup.IsNone()) { double delta = Math.Abs(normal_mass.v - backup_mass.v); double delta_error = Math.Sqrt(normal_mass.err * normal_mass.err + backup_mass.err * backup_mass.err); bool got = meas.INCCAnalysisResults.TryGetINCCResults(mkey, out imr); if (delta <= (delta_error * meas.Tests.normalBackupAssayTestLimit)) { if (got) imr.primaryMethod = meas.INCCAnalysisState.Methods.Normal; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10102, "Verification primary method {0} with masses {1} and {2} is from the normal method", imr.primaryMethod.ToString(), normal_mass.v, backup_mass.v); } else { if (got) imr.primaryMethod = meas.INCCAnalysisState.Methods.Backup; meas.Logger.TraceEvent(NCCReporter.LogLevels.Info, 10103, "Verification primary method {0} with masses {1} and {2} is from the backup method", imr.primaryMethod.ToString(), normal_mass.v, backup_mass.v); } } } } catch (Exception e) { meas.Logger.TraceException(e); } }
public unsafe void BuildDetector(INCCInitialDataDetectorFile iddf, int num) { INCCDB DB = NC.App.DB; detector_rec d = iddf.Detector[0]; sr_parms_rec sr = iddf.SRParms[0]; bkg_parms_rec bkh = iddf.BKGParms[0]; norm_parms_rec norm = iddf.NormParms[0]; tm_bkg_parms_rec tmbkg = iddf.TMBKGParms[0]; add_a_source_setup_rec aass = iddf.AASParms[0]; InstrType srtype = (InstrType)sr.sr_type; bool overwrite = NC.App.AppContext.OverwriteImportedDefs; mlogger.TraceEvent(LogLevels.Verbose, 34100, "Building '{0}' detector '{1}' from {2} {3}", srtype.ToString(), TransferUtils.str(d.detector_id, INCC.MAX_DETECTOR_ID_LENGTH), num, iddf.Path); // if the detector is not known internally, then // add the detector to the list of detectors in memory, and // associate a new set of SR, Bkg and Norm and AB params with the new detector // todo: What are the HV Params from INCC5, and once that is known, can they be transferred to the INCC6 HV Param and results tables Detector det = new Detector(); if (srtype.IsListMode()) det.Id.FullConnInfo = new LMConnectionInfo(); try { // this transfer should be a method in this class, it will be used elsewhere too det.Id.DetectorId = TransferUtils.str(d.detector_id, INCC.MAX_DETECTOR_ID_LENGTH); det.Id.SRType = srtype; det.Id.Type = TransferUtils.str(d.detector_type, INCC.DETECTOR_TYPE_LENGTH); det.Id.ElectronicsId = TransferUtils.str(d.electronics_id, INCC.ELECTRONICS_ID_LENGTH); det.Id.ConnInfo = sr.sr_port_number.ToString(); det.Id.source = ConstructedSource.INCCTransferCopy; det.MultiplicityParams.FA = srtype.DefaultFAFor(); det.MultiplicityParams.gateWidthTics = (ulong)(sr.gate_length * 10.0); // shift down to tics from microseconds det.SRParams.deadTimeCoefficientAinMicroSecs = sr.coeff_a_deadtime; det.SRParams.deadTimeCoefficientBinPicoSecs = sr.coeff_b_deadtime; det.SRParams.deadTimeCoefficientCinNanoSecs = sr.coeff_c_deadtime; det.SRParams.deadTimeCoefficientMultiplicityinNanoSecs = sr.multiplicity_deadtime; det.SRParams.dieAwayTime = sr.die_away_time * 10.0; // shift down to tics from microseconds det.SRParams.doublesGateFraction = sr.doubles_gate_fraction; det.SRParams.efficiency = sr.efficiency; det.SRParams.gateLength = (ulong)(sr.gate_length * 10.0); // shift down to tics from microseconds //det.SRParams.gateLength2 = sr.gate_length2; det.SRParams.highVoltage = sr.high_voltage; det.SRParams.predelay = (ulong)(sr.predelay * 10.0); // shift down to tics from microseconds det.SRParams.triplesGateFraction = sr.triples_gate_fraction; // = sr.sr_type , sr.sr_port_number, sr.sr_detector_id these are in the Id now, not the SRparams, but they travel together. if (NC.App.AppContext.OverwriteImportedDefs) DB.Detectors.Replace(det); else DB.Detectors.AddOnlyIfNotThere(det); DetectorIndex = DB.Detectors.Count - 1; BackgroundParameters bkg = new BackgroundParameters(); bkg.DeadtimeCorrectedRates.Singles.v = bkh.curr_passive_bkg_singles_rate; bkg.DeadtimeCorrectedRates.Doubles.v = bkh.curr_passive_bkg_doubles_rate; bkg.DeadtimeCorrectedRates.Triples.v = bkh.curr_passive_bkg_triples_rate; bkg.DeadtimeCorrectedRates.Singles.err = bkh.curr_passive_bkg_singles_err; bkg.DeadtimeCorrectedRates.Doubles.err = bkh.curr_passive_bkg_doubles_err; bkg.DeadtimeCorrectedRates.Triples.err = bkh.curr_passive_bkg_triples_err; bkg.Scaler1.v = bkh.curr_passive_bkg_scaler1_rate; bkg.Scaler2.v = bkh.curr_passive_bkg_scaler2_rate; bkg.INCCActive.Singles.v = bkh.curr_active_bkg_singles_rate; bkg.INCCActive.Singles.err = bkh.curr_active_bkg_singles_err; bkg.INCCActive.Scaler1Rate = bkh.curr_active_bkg_scaler1_rate; bkg.INCCActive.Scaler2Rate = bkh.curr_active_bkg_scaler2_rate; bkg.TMBkgParams.Singles.v = tmbkg.tm_singles_bkg; bkg.TMBkgParams.Ones.v = tmbkg.tm_ones_bkg; bkg.TMBkgParams.Twos.v = tmbkg.tm_twos_bkg; bkg.TMBkgParams.Zeros.v = tmbkg.tm_zeros_bkg; bkg.TMBkgParams.Singles.err = tmbkg.tm_singles_bkg_err; bkg.TMBkgParams.Ones.err = tmbkg.tm_ones_bkg_err; bkg.TMBkgParams.Twos.err = tmbkg.tm_twos_bkg_err; bkg.TMBkgParams.Zeros.err = tmbkg.tm_zeros_bkg_err; bkg.TMBkgParams.ComputeTMBkg = (tmbkg.tm_bkg == 0 ? false : true); if (DB.BackgroundParameters.Get(det.Id.DetectorName) == null) { DB.BackgroundParameters.GetMap().Add(det, bkg); // saved to DB at below } else if (overwrite) { bkg.modified = true; NC.App.DB.BackgroundParameters.GetMap().Remove(det); NC.App.DB.BackgroundParameters.GetMap().Add(det, bkg); NC.App.DB.BackgroundParameters.Set(det, bkg); } // save the params listed here using the detector as the key NormParameters normp = new NormParameters(); normp.acceptanceLimitPercent = norm.acceptance_limit_percent; normp.acceptanceLimitStdDev = norm.acceptance_limit_std_dev; normp.amliRefSinglesRate = norm.amli_ref_singles_rate; normp.biasMode = OldToNewBiasTestId(norm.bias_mode); normp.biasPrecisionLimit = norm.bias_precision_limit; normp.biasTestAddasrcPosition = norm.bias_test_addasrc_position; normp.biasTestUseAddasrc = (norm.bias_test_use_addasrc == 0 ? false : true); normp.cf252RefDoublesRate.v = norm.cf252_ref_doubles_rate; normp.currNormalizationConstant.v = norm.curr_normalization_constant; normp.currNormalizationConstant.err = norm.curr_normalization_constant_err; normp.initSrcPrecisionLimit = norm.init_src_precision_limit; normp.measRate.v = norm.meas_rate; normp.measRate.err = norm.meas_rate_err; normp.refDate = INCC.DateFrom(TransferUtils.str(norm.ref_date, INCC.DATE_TIME_LENGTH)); normp.sourceId = TransferUtils.str(norm.source_id, INCC.SOURCE_ID_LENGTH); normp.yieldRelativeToMrc95 = norm.yield_relative_to_mrc_95; if (DB.NormParameters.Get(det.Id.DetectorName) == null) { DB.NormParameters.GetMap().Add(det, normp); // saved to DB at end } else if (overwrite) { normp.modified = true; DB.NormParameters.GetMap().Remove(det); DB.NormParameters.GetMap().Add(det, normp); // the in-memory map DB.NormParameters.Set(det, normp); // the DB table } AddASourceSetup aassp = new AddASourceSetup(); aassp.type = OldToNewAASId(aass.ad_type); aassp.port_number = aass.ad_port_number; aassp.forward_over_travel = aass.ad_forward_over_travel; aassp.reverse_over_travel = aass.ad_reverse_over_travel; aassp.number_positions = aass.ad_number_positions; aassp.dist_to_move = TransferUtils.Copy(aass.ad_dist_to_move, INCC.MAX_ADDASRC_POSITIONS); aassp.cm_steps_per_inch = aass.cm_steps_per_inch; aassp.cm_forward_mask = aass.cm_forward_mask; aassp.cm_reverse_mask = aass.cm_reverse_mask; aassp.cm_axis_number = aass.cm_axis_number; aassp.cm_over_travel_state = aass.cm_over_travel_state; aassp.cm_step_ratio = aass.cm_step_ratio; aassp.cm_slow_inches = aass.cm_slow_inches; aassp.plc_steps_per_inch = aass.plc_steps_per_inch; aassp.scale_conversion_factor = aass.scale_conversion_factor; aassp.cm_rotation = (aass.cm_rotation == 0 ? false : true); if (!DB.AASSParameters.GetMap().ContainsKey(det)) { DB.AASSParameters.GetMap().Add(det, aassp); } else if (overwrite) { aassp.modified = true; DB.AASSParameters.GetMap().Remove(det); DB.AASSParameters.GetMap().Add(det, aassp); // todo: in-memory and db } if (!DB.UnattendedParameters.GetMap().ContainsKey(det)) { DB.UnattendedParameters.GetMap().Add(det, new UnattendedParameters()); } else if (overwrite) { DB.UnattendedParameters.GetMap().Remove(det); DB.UnattendedParameters.GetMap().Add(det, new UnattendedParameters()); } // the alpha beta arrays must be sized here, for first use by the calc_alpha_beta code in the cycle conditioning code Multiplicity mkey = new Multiplicity(srtype.DefaultFAFor()); mkey.SR = new ShiftRegisterParameters(det.SRParams); MultiplicityCountingRes mcr = new MultiplicityCountingRes(srtype.DefaultFAFor(), 0); ABKey abkey = new ABKey(mkey, 512); // NEXT: maxbins is arbitrary LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, det.AB); mcr.AB.TransferIntermediates(det.AB); } catch (Exception e) { mlogger.TraceEvent(LogLevels.Warning, 34064, "Detector transfer processing error {0} {1} ({2})", det.Id.DetectorName, e.Message, System.IO.Path.GetFileName(iddf.Path)); } }
/// <summary> /// Create the cycle counting results, add it to the measurement and copy the data from the run to the equivalent fields on the cycle /// </summary> /// <param name="run"></param> /// <param name="cycle"></param> public static unsafe MultiplicityCountingRes RunToCycle(run_rec run, Cycle cycle, Multiplicity key) { cycle.seq = run.run_number; cycle.TS = new TimeSpan(0, 0, (int)run.run_count_time); // dev note: check if this is always only in seconds, or fractions of a second cycle.Totals = (ulong)run.run_singles; cycle.SinglesRate = run.run_singles / run.run_count_time; // use this value in the conditioning steps, it is not yet the DT corrected rate string s = TransferUtils.str(run.run_tests, INCC.MAX_RUN_TESTS_LENGTH); QCTestStatus qcts = QCTestStatusExtensions.FromString(s); cycle.SetQCStatus(key, qcts); // creates entry if not found MultiplicityCountingRes mcr = new MultiplicityCountingRes(key.FA, cycle.seq); cycle.CountingAnalysisResults.Add(key, mcr); mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.DeadtimeCorrectedSinglesRate.v = run.run_singles_rate; // overridden later, not used mcr.DeadtimeCorrectedDoublesRate.v = run.run_doubles_rate; mcr.DeadtimeCorrectedTriplesRate.v = run.run_triples_rate; mcr.RASum = (ulong)run.run_reals_plus_acc; mcr.ASum = (ulong)run.run_acc; mcr.efficiency = run.run_multiplicity_efficiency; mcr.mass = run.run_mass; mcr.multiAlpha = run.run_multiplicity_alpha; mcr.multiplication = run.run_multiplicity_mult; cycle.HighVoltage = run.run_high_voltage; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = run.run_singles; mcr.RawSinglesRate.v = run.run_singles_rate; mcr.RawDoublesRate.v = run.run_doubles_rate; mcr.RawTriplesRate.v = run.run_triples_rate; mcr.Scaler1.v = run.run_scaler1; mcr.Scaler2.v = run.run_scaler2; mcr.Scaler1Rate.v = run.run_scaler1_rate; mcr.Scaler2Rate.v = run.run_scaler2_rate; mcr.RAMult = TransferUtils.multarrayxfer(run.run_mult_reals_plus_acc, INCC.MULTI_ARRAY_SIZE); mcr.NormedAMult = TransferUtils.multarrayxfer(run.run_mult_acc, 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.UnAMult = new ulong[mcr.MaxBins]; // todo: compute this return mcr; }
/// <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 }
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); }
private void OKBtn_Click(object sender, EventArgs e) { ClipboardMonitor.OnClipboardChange -= new ClipboardMonitor.OnClipboardChangeEventHandler(ClipboardMonitor_OnClipboardChange); ClipboardMonitor.Stop(); // do not forget to stop ClearMeasCycles(); CycleList newCycles = new CycleList(); // NEXT: manual entry needs more work to get it completed, but you have a good start here Multiplicity key = new Multiplicity(ah.det.MultiplicityParams); // APluralityOfMultiplicityAnalyzers: expand in some logical manner, e.g. enable user to select the analyzer and related results for manual entry and assignment for (int i = 0; i < MAX_MANUAL_ENTRIES; i++) // hard-coded limits are ... lame { DataGridViewRow r = cyclesGridView.Rows[i]; if (r.Cells == null || (r.Cells[1].Value == null) || r.Cells[1].Value.ToString() == string.Empty) break; Cycle cycle = new Cycle(m_log); ulong tots = 0, r_acc = 0, acc = 0; ulong.TryParse(r.Cells[1].Value.ToString(), out tots); ulong.TryParse((string)r.Cells[2].FormattedValue, out r_acc); // FormattedValue gives "" instead of the null checked for in the conditional above ulong.TryParse((string)r.Cells[3].FormattedValue, out acc); newCycles.Add(cycle); cycle.Totals = tots; cycle.TS = new TimeSpan(0, 0, 0, 0, (int)(1000 * m_counttime)); // milliseconds permitted for LM and future cycle.SinglesRate = tots / m_counttime; cycle.SetQCStatus(key, QCTestStatus.Pass); cycle.seq = i+1; MultiplicityCountingRes mcr = new MultiplicityCountingRes(key.FA, cycle.seq); cycle.CountingAnalysisResults.Add(key, mcr); mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = acc; mcr.RASum = r_acc; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = tots; mcr.RawSinglesRate.v = cycle.SinglesRate; // no alpha-beta, mult bins, HV, doubles, triples, raw nor corrected } int seq = 0; foreach (Cycle cycle in newCycles) // add the necessary meta-data to the cycle identifier instance { seq++; cycle.UpdateDataSourceId(ConstructedSource.Manual, ah.det.Id.SRType, new DateTimeOffset(m_refDate.AddTicks(cycle.TS.Ticks * cycle.seq)), string.Empty); } NC.App.Opstate.Measurement.Add(newCycles); if (newCycles.Count > 0) DialogResult = DialogResult.OK; Close(); }
// assumes initalized measurement with at least one cycle, and at least one defined counting analysis result indexed by the detector's mult params, including VSRs fror LM void ComputeFromINCC5SRData(Measurement m, bool ABCorrected = false) { string pre = (m.AcquireState.data_src == ConstructedSource.Reanalysis ? "Rec" : "C"); ctrllog.TraceEvent(LogLevels.Info, 34071, pre + "omputing: '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'"); if (m.Cycles.Count < 1) { ctrllog.TraceEvent(LogLevels.Error, 34830, "Skipping, no cycles on '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'"); return; } if (m.CountingAnalysisResults.Count < 1 || !m.CountingAnalysisResults.HasMultiplicity) { ctrllog.TraceEvent(LogLevels.Error, 34831, "Bad match between detector and this file type." + (!m.CountingAnalysisResults.HasMultiplicity ? " No Multiplicity counter defined." : "")); return; //bad match between detector and this file type. } SRInstrument PseudoInstrument = new SRInstrument(m.Detector); PseudoInstrument.selected = true; if (!Instruments.Active.Contains(PseudoInstrument)) { Instruments.Active.Add(PseudoInstrument); // add to global runtime list } m.CurrentRepetition = 0; NC.App.Opstate.SOH = OperatingState.Living; try { MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detector.MultiplicityParams]; // APluralityOfMultiplicityAnalyzers: check for use of multiple analyzers // start counting using the per-cycle accumulation of summary results Array.Clear(mcr.RAMult, 0, mcr.RAMult.Length); Array.Clear(mcr.NormedAMult, 0, mcr.NormedAMult.Length); Array.Clear(mcr.UnAMult, 0, mcr.UnAMult.Length); mcr.AB.TransferIntermediates(src: m.Detector.AB); // remove, redundant copy in most cases CycleList cl = m.Cycles; m.Cycles = new CycleList(); foreach (Cycle cycle in cl) // process incrementally to match expected outlier processing behavior from INCC { if (NC.App.Opstate.IsQuitRequested) // exit via abort or quit/save, follow-on code decides to continue with processing { ctrllog.TraceEvent(LogLevels.Warning, 430, "Cycle first-pass processing " + NC.App.Opstate.CancelStopAbortStateRep + " at sequence #" + cycle.seq + ", " + m.CurrentRepetition); break; } m.CurrentRepetition++; m.Cycles.Add(cycle); m.SetQCStatus(cycle); CycleProcessing.ApplyTheCycleConditioningSteps(cycle, m); m.CycleStatusTerminationCheck(cycle); ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString()); if (m.CurrentRepetition % 8 == 0) { FireEvent(EventType.ActionInProgress, this); } } FireEvent(EventType.ActionInProgress, this); // trim any None's that were not processed (occurs during a cancel/stop intervention) m.Cycles.Trim(m.Detector.MultiplicityParams); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; ctrllog.TraceException(e, true); ctrllog.TraceEvent(LogLevels.Warning, 430, "Processing stopped at cycle " + m.CurrentRepetition); } finally { NC.App.Loggers.Flush(); } if (!NC.App.Opstate.IsAbortRequested) // stop/quit means continue with what is available { if (m.HasReportableData) { m.CalculateMeasurementResults(); new ReportMangler(ctrllog).GenerateReports(m); m.SaveMeasurementResults(); } } NC.App.Opstate.ResetTokens(); Instruments.All.Remove(PseudoInstrument); }
void AddTestDataCycle(int run, uint run_seconds, double run_count_time, Measurement meas, TestDataFile td, string pivot = "", int cfindex = -1) { Cycle cycle = new Cycle(datalog); try { cycle.UpdateDataSourceId(ConstructedSource.CycleFile, meas.Detector.Id.SRType, td.DTO.AddSeconds(run_seconds), td.Filename); cycle.seq = run; cycle.TS = TimeSpan.FromSeconds(run_count_time); // dev note: check if this is always only in seconds, or fractions of a second // hn -- 9/4/14 -- not integer for count time. Convert from double seconds here. // Joe still has force to int. bleck! /* init run tests */ cycle.SetQCStatus(meas.Detector.MultiplicityParams, QCTestStatus.None); // APluralityOfMultiplicityAnalyzers: creates entry if not found, expand from the single mult key from detector here meas.Add(cycle, cfindex); /* singles, reals + accidentals, accidentals */ string l = td.reader.ReadLine(); string[] zorks = l.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); double[] v = new double[5]; for (int z = 0; z < 5; z++) { double d; bool b = double.TryParse(zorks[z], out d); if (b) { v[z] = d; } } cycle.Totals = (ulong)v[0]; MultiplicityCountingRes mcr = new MultiplicityCountingRes(meas.Detector.MultiplicityParams.FA, cycle.seq); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers cycle.CountingAnalysisResults.Add(meas.Detector.MultiplicityParams, mcr); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers mcr.AB.TransferIntermediates(meas.Detector.AB); // copy alpha beta onto the cycle's results mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = v[4]; mcr.RASum = v[3]; mcr.Scaler1.v = v[1]; mcr.Scaler2.v = v[2]; cycle.SinglesRate = v[0] / run_count_time; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = cycle.Totals; mcr.RawSinglesRate.v = cycle.SinglesRate; /* number of multiplicity values */ string mv = td.reader.ReadLine(); ushort k = 0; ushort.TryParse(mv, out k); if (k == 0) // test data files require an entry with 1 bin set 0s for the absence of multiplicity, go figure { ctrllog.TraceEvent(LogLevels.Error, 440, "This" + pivot + " cycle " + run.ToString() + " has no good multiplicity data."); return; } mcr.MinBins = mcr.MaxBins = k; mcr.RAMult = new ulong[k]; mcr.NormedAMult = new ulong[k]; mcr.UnAMult = new ulong[k]; // todo: compute this /* multiplicity values */ for (ushort j = 0; j < k; j++) { string ra = td.reader.ReadLine(); string[] blorks = ra.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); double[] ve = new double[2]; for (int z = 0; z < 2; z++) { double d; bool b = double.TryParse(blorks[z], out d); if (b) { ve[z] = d; } } mcr.RAMult[j] = (ulong)ve[0]; mcr.NormedAMult[j] = (ulong)ve[1]; } ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString() + pivot + ((mcr.RAMult[0] + mcr.NormedAMult[0]) > 0 ? " max:" + mcr.MaxBins.ToString() : " *")); } catch (Exception e) { ctrllog.TraceEvent(LogLevels.Warning, 33085, pivot + "cycle processing error {0} {1} {2}", run, e.Message, pivot); } }
/// <summary> /// Create parameter list for the results on a cycle /// </summary> /// <param name="mkey">The multiplicity parameters used to select the specific results. There can be more than one such results set per cycle.</param> public void GenParamList(Multiplicity mkey) { GenParamList(); // ^ does the basic INCC5 and new LM cycle stuff // now add the mkey stuff Table = "cycles"; MultiplicityCountingRes pmcr = null; QCTestStatus status = QCTestStatus.None; if (CountingAnalysisResults.HasMultiplicity) try { pmcr = (MultiplicityCountingRes)CountingAnalysisResults[mkey]; status = qcstatus[mkey].status; } catch (Exception) // mkey not found happens when a param is changed on a VSR that is not reflected back to the default [0] SR { logger.TraceEvent(LogLevels.Warning, 7832, "Cycle status not set in DB, mkey mismatch: " + mkey.ToString()); } if (pmcr == null) pmcr = new MultiplicityCountingRes(); // null results ps.Add(new DBParamEntry("scaler1", pmcr.Scaler1.v)); ps.Add(new DBParamEntry("scaler2", pmcr.Scaler2.v)); ps.Add(new DBParamEntry("reals_plus_acc", pmcr.RASum)); ps.Add(new DBParamEntry("acc", pmcr.ASum)); ps.Add(new DBParamEntry("mult_reals_plus_acc", pmcr.RAMult)); ps.Add(new DBParamEntry("mult_acc", pmcr.NormedAMult)); ps.Add(new DBParamEntry("scaler1_rate", pmcr.Scaler1Rate.v)); ps.Add(new DBParamEntry("scaler2_rate", pmcr.Scaler2Rate.v)); ps.Add(new DBParamEntry("doubles_rate", pmcr.RawDoublesRate.v)); ps.Add(new DBParamEntry("triples_rate", pmcr.RawTriplesRate.v)); ps.Add(new DBParamEntry("multiplicity_mult", pmcr.multiplication)); ps.Add(new DBParamEntry("multiplicity_alpha", pmcr.multiAlpha)); ps.Add(new DBParamEntry("multiplicity_efficiency", pmcr.efficiency)); ps.Add(new DBParamEntry("mass", pmcr.mass)); ps.Add(new DBParamEntry("status", (int)status)); { // la super hack-a-whack DB.DB db = new DB.DB(true); if (db.TableHasColumn(Table,"mult_acc_un")) ps.Add(new DBParamEntry("mult_acc_un", pmcr.UnAMult)); } }
// assumes initalized measurement with at least one cycle, and at least one defined counting analysis result indexed by the detector's mult params // NEXT: implement for LM results void ComputeFromINCC5SRData(Measurement m) { ctrllog.TraceEvent(LogLevels.Info, 34071, "Recomputing: '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'"); if (m.Cycles.Count < 1) { ctrllog.TraceEvent(LogLevels.Error, 34830, "Skipping, no cycles on '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'"); return; } if (m.CountingAnalysisResults.Count < 1 || !m.CountingAnalysisResults.HasMultiplicity) { ctrllog.TraceEvent(LogLevels.Error, 34831, "Bad match between detector and this file type." + (!m.CountingAnalysisResults.HasMultiplicity ? " No Multiplicity counter defined." : "")); return; //bad match between detector and this file type. } SRInstrument PseudoInstrument = new SRInstrument(m.Detectors[0]); PseudoInstrument.selected = true; if (!Instruments.Active.Contains(PseudoInstrument)) { Instruments.Active.Add(PseudoInstrument); // add to global runtime list } m.CurrentRepetition = 0; NC.App.Opstate.SOH = NCC.OperatingState.Living; try { // urgent: there is more work to do for the bins and AB here, AB can be copied from the detector values MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detectors[0].MultiplicityParams]; // multmult // start counting using the per-cycle accumulation of summary results Array.Clear(mcr.RAMult, 0, mcr.RAMult.Length); Array.Clear(mcr.NormedAMult, 0, mcr.NormedAMult.Length); mcr.AB.TransferIntermediates(src: m.Detectors[0].AB); foreach (AnalysisDefs.Cycle cycle in m.Cycles) { if (NC.App.Opstate.IsQuitRequested) // exit via abort or quit/save, follow-on code decides to continue with processing { ctrllog.TraceEvent(LogLevels.Warning, 430, "Cycle first-pass processing " + NC.App.Opstate.CancelStopAbortStateRep + " at sequence #" + cycle.seq + ", " + m.CurrentRepetition); break; } m.CurrentRepetition++; cycle.SetQCStatus(m.Detectors[0].MultiplicityParams, QCTestStatus.Pass, cycle.HighVoltage); // multmult prep for analyis one by one CycleProcessing.ApplyTheCycleConditioningSteps(cycle, m); m.CycleStatusTerminationCheck(cycle); ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString()); if (m.CurrentRepetition % 8 == 0) { FireEvent(EventType.ActionInProgress, this); } } FireEvent(EventType.ActionInProgress, this); // trim any None's that were not processed (occurs during a cancel/stop intervention) m.Cycles.Trim(m.Detectors[0].MultiplicityParams); // multmult } catch (Exception e) { NC.App.Opstate.SOH = NCC.OperatingState.Trouble; ctrllog.TraceException(e, true); ctrllog.TraceEvent(LogLevels.Warning, 430, "Processing stopped at cycle " + m.CurrentRepetition); } finally { NC.App.Loggers.Flush(); } if (!NC.App.Opstate.IsAbortRequested) // stop/quit means continue with what is available { // todo: if (meas.HasReportableData) m.CalculateMeasurementResults(); new ReportMangler(ctrllog).GenerateReports(m); m.SaveMeasurementResults(); } NC.App.Opstate.ResetTokens(); Instruments.All.Remove(PseudoInstrument); }
internal static unsafe results_rec MoveResultsRec(Measurement m) { results_rec rec = new results_rec(); byte[] b = StringSquish(m.MeasDate.ToString("yy.MM.dd"), INCC.DATE_TIME_LENGTH); TransferUtils.Copy(b, rec.meas_date); TransferUtils.Copy(b, rec.original_meas_date); // this value is now properly tracked in INCC6 b = StringSquish(m.MeasDate.ToString("HH:mm:ss"), INCC.DATE_TIME_LENGTH); TransferUtils.Copy(b, rec.meas_time); b = StringSquish(System.IO.Path.GetFileName(m.MeasurementId.FileName), INCC.FILE_NAME_LENGTH); TransferUtils.Copy(b, rec.filename); b = StringSquish(m.AcquireState.facility.Name, INCC.FACILITY_LENGTH); TransferUtils.Copy(b, rec.results_facility); b = StringSquish(m.AcquireState.mba.Name, INCC.MBA_LENGTH); TransferUtils.Copy(b, rec.results_mba); b = StringSquish(m.AcquireState.stratum_id.Name, INCC.MAX_STRATUM_ID_LENGTH); TransferUtils.Copy(b, rec.stratum_id); b = StringSquish(m.AcquireState.facility.Desc, INCC.DESCRIPTION_LENGTH); TransferUtils.Copy(b, rec.results_facility_description); b = StringSquish(m.AcquireState.mba.Desc, INCC.DESCRIPTION_LENGTH); TransferUtils.Copy(b, rec.results_mba_description); b = StringSquish(m.AcquireState.stratum_id.Desc, INCC.DESCRIPTION_LENGTH); TransferUtils.Copy(b, rec.stratum_id_description); b = StringSquish(m.AcquireState.item_id, INCC.MAX_ITEM_ID_LENGTH); TransferUtils.Copy(b, rec.item_id); b = StringSquish(m.AcquireState.campaign_id, INCC.MAX_CAMPAIGN_ID_LENGTH); TransferUtils.Copy(b, rec.results_campaign_id); TransferUtils.Copy(b, rec.results_inspection_number); b = StringSquish(m.AcquireState.item_type, INCC.MAX_ITEM_TYPE_LENGTH); TransferUtils.Copy(b, rec.results_item_type); rec.results_collar_mode = (byte)(m.AcquireState.collar_mode ? 1 : 0); b = StringSquish(m.Detector.Id.DetectorId, INCC.MAX_DETECTOR_ID_LENGTH); TransferUtils.Copy(b, rec.results_detector_id); b = StringSquish(m.Detector.Id.Type, INCC.DETECTOR_TYPE_LENGTH); TransferUtils.Copy(b, rec.results_detector_type); b = StringSquish(m.Detector.Id.ElectronicsId, INCC.ELECTRONICS_ID_LENGTH); TransferUtils.Copy(b, rec.results_electronics_id); b = StringSquish(m.AcquireState.glovebox_id, INCC.MAX_GLOVEBOX_ID_LENGTH); TransferUtils.Copy(b, rec.results_glovebox_id); rec.results_num_rows = m.INCCAnalysisResults.TradResultsRec.hc.num_rows; rec.results_num_columns = m.INCCAnalysisResults.TradResultsRec.hc.num_columns; rec.results_distance = m.INCCAnalysisResults.TradResultsRec.hc.distance; // devnote: full hc results record on a measurement is lost in the persist -> restore loop because upon 'read from DB' or restore we normally do not build out the TradResultsRec. rec.bias_uncertainty = m.Stratum.bias_uncertainty; rec.random_uncertainty = m.Stratum.random_uncertainty; rec.systematic_uncertainty = m.Stratum.systematic_uncertainty; rec.relative_std_dev = m.Stratum.relative_std_dev; b = StringSquish(m.AcquireState.inventory_change_code, INCC.INVENTORY_CHG_LENGTH); TransferUtils.Copy(b, rec.inventory_change_code); b = StringSquish(m.AcquireState.io_code, INCC.IO_CODE_LENGTH); TransferUtils.Copy(b, rec.io_code); rec.meas_option = (byte)m.MeasOption; rec.well_config = (byte)m.AcquireState.well_config; rec.data_source = (byte)m.AcquireState.data_src; rec.results_qc_tests = (byte)(m.AcquireState.qc_tests ? 1 : 0); rec.results_print = (byte)(m.AcquireState.print ? 1 : 0); rec.error_calc_method = (ushort) (m.AcquireState.error_calc_method == ErrorCalculationTechnique.Sample ? INCC.IDC_SAMPLE_STD_DEV : INCC.IDC_THEORETICAL_STD_DEV); b = StringSquish(m.AcquireState.user_id, INCC.CHAR_FIELD_LENGTH); TransferUtils.Copy(b, rec.user_id); b = StringSquish(m.AcquireState.comment, INCC.MAX_COMMENT_LENGTH); TransferUtils.Copy(b, rec.comment); b = StringSquish(m.AcquireState.ending_comment_str, INCC.MAX_COMMENT_LENGTH); TransferUtils.Copy(b, rec.ending_comment); rec.item_pu238 = m.Isotopics.pu238; rec.item_pu238_err = m.Isotopics.pu238_err; rec.item_pu239 = m.Isotopics.pu239; rec.item_pu239_err = m.Isotopics.pu239_err; rec.item_pu240 = m.Isotopics.pu240; rec.item_pu240_err = m.Isotopics.pu240_err; rec.item_pu241 = m.Isotopics.pu241; rec.item_pu241_err = m.Isotopics.pu241_err; rec.item_pu242 = m.Isotopics.pu242; rec.item_pu242_err = m.Isotopics.pu242_err; rec.item_am241 = m.Isotopics.am241; rec.item_am241 = m.Isotopics.am241_err; b = StringSquish(m.Isotopics.id, INCC.MAX_ISOTOPICS_ID_LENGTH); TransferUtils.Copy(b, rec.item_isotopics_id); b = StringSquish(m.Isotopics.source_code.ToString(), INCC.ISO_SOURCE_CODE_LENGTH); TransferUtils.Copy(b, rec.item_isotopics_source_code); rec.normalization_constant = m.Norm.currNormalizationConstant.v; rec.normalization_constant_err = m.Norm.currNormalizationConstant.err; rec.results_predelay = m.Detector.SRParams.predelayMS; rec.results_gate_length = m.Detector.SRParams.gateLengthMS; rec.results_gate_length2 = m.Detector.SRParams.gateLengthMS; // not used rec.results_high_voltage = m.Detector.SRParams.highVoltage; rec.results_die_away_time = m.Detector.SRParams.dieAwayTimeMS; rec.results_efficiency = m.Detector.SRParams.efficiency; rec.results_multiplicity_deadtime = m.Detector.SRParams.deadTimeCoefficientMultiplicityinNanoSecs; rec.results_coeff_a_deadtime = m.Detector.SRParams.deadTimeCoefficientAinMicroSecs; rec.results_coeff_b_deadtime = m.Detector.SRParams.deadTimeCoefficientBinPicoSecs; rec.results_coeff_c_deadtime = m.Detector.SRParams.deadTimeCoefficientCinNanoSecs; rec.results_doubles_gate_fraction = m.Detector.SRParams.triplesGateFraction; rec.results_triples_gate_fraction = m.Detector.SRParams.doublesGateFraction; // get the first results from the results map MultiplicityCountingRes mcr = null; if (m.CountingAnalysisResults.Count > 0 && m.CountingAnalysisResults.HasMultiplicity) try { mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detector.MultiplicityParams]; } catch (Exception) { if (mcr == null) mcr = m.CountingAnalysisResults.GetFirstMultiplicity; } if (mcr == null) mcr = new MultiplicityCountingRes(); // inadequate attempt tries to account for LM-only condition, where no mcr, or no matching mcr, exists rec.r_acc_sngl_test_rate_limit = m.Tests.accSnglTestRateLimit; rec.r_acc_sngl_test_precision_limit = m.Tests.accSnglTestPrecisionLimit; rec.r_acc_sngl_test_outlier_limit = m.Tests.accSnglTestOutlierLimit; rec.r_outlier_test_limit = m.Tests.outlierTestLimit; rec.r_bkg_doubles_rate_limit = m.Tests.bkgDoublesRateLimit; rec.r_bkg_triples_rate_limit = m.Tests.bkgTriplesRateLimit; rec.r_chisq_limit = m.Tests.chiSquaredLimit; rec.r_max_num_failures = m.Tests.maxNumFailures; rec.r_high_voltage_test_limit = m.Tests.highVoltageTestLimit; rec.r_normal_backup_assay_test_lim = m.Tests.normalBackupAssayTestLimit; rec.r_max_runs_for_outlier_test = m.Tests.maxCyclesForOutlierTest; rec.r_checksum_test = (byte)(m.Tests.checksum ? 1 : 0); rec.results_accidentals_method = (m.Tests.accidentalsMethod == AccidentalsMethod.Measure ? INCC.IDC_MEASURE_ACCIDENTALS : INCC.IDC_CALCULATE_ACCIDENTALS); rec.passive_bkg_singles_rate = m.Background.DeadtimeCorrectedRates.Singles.v; rec.passive_bkg_singles_rate_err = m.Background.DeadtimeCorrectedRates.Singles.err; rec.passive_bkg_doubles_rate = m.Background.DeadtimeCorrectedRates.Doubles.v; rec.passive_bkg_doubles_rate_err = m.Background.DeadtimeCorrectedRates.Doubles.err; rec.passive_bkg_triples_rate = m.Background.DeadtimeCorrectedRates.Triples.v; rec.passive_bkg_triples_rate_err = m.Background.DeadtimeCorrectedRates.Triples.err; rec.active_bkg_singles_rate = m.Background.INCCActive.Singles.v; rec.active_bkg_singles_rate_err = m.Background.INCCActive.Singles.err; rec.passive_bkg_scaler1_rate = m.Background.Scaler1.v; rec.passive_bkg_scaler2_rate = m.Background.Scaler2.v; rec.active_bkg_scaler1_rate = m.Background.INCCActive.Scaler1Rate; rec.active_bkg_scaler2_rate = m.Background.INCCActive.Scaler2Rate; List<MeasurementMsg> msgs = m.GetMessageList(m.Detector.MultiplicityParams); byte[] bb = new byte[INCC.NUM_ERROR_MSG_CODES * INCC.ERR_MSG_LENGTH]; int indx = 0, recidx = 0; for (int i = 0; i < msgs.Count && recidx < INCC.NUM_ERROR_MSG_CODES; i++) { if (msgs.Count > i && string.IsNullOrEmpty(msgs[i].text) && msgs[i].IsError) { char[] aa = msgs[i].text.ToCharArray(0, Math.Min(msgs[i].text.Length, INCC.ERR_MSG_LENGTH)); Encoding.ASCII.GetBytes(aa, 0, aa.Length, bb, indx); recidx++; } indx += INCC.ERR_MSG_LENGTH; } TransferUtils.Copy(bb, 0, rec.error_msg_codes, 0, INCC.NUM_ERROR_MSG_CODES * INCC.ERR_MSG_LENGTH); bb = new byte[INCC.NUM_ERROR_MSG_CODES * INCC.ERR_MSG_LENGTH]; indx = 0; recidx = 0; for (int i = 0; i < msgs.Count && recidx < INCC.NUM_ERROR_MSG_CODES; i++) { if (msgs.Count > i && string.IsNullOrEmpty(msgs[i].text) && msgs[i].IsWarning) { char[] aa = msgs[i].text.ToCharArray(0, Math.Min(msgs[i].text.Length, INCC.ERR_MSG_LENGTH)); Encoding.ASCII.GetBytes(aa, 0, aa.Length, bb, indx); recidx++; } indx += INCC.ERR_MSG_LENGTH; } TransferUtils.Copy(bb, 0, rec.warning_msg_codes, 0, INCC.NUM_ERROR_MSG_CODES * INCC.ERR_MSG_LENGTH); // these ride on, or can be computed from, m.Cycles, but they sum across multiple analyzers and so are not considered complete yet for LM measurements rec.total_number_runs = (ushort)m.Cycles.GetValidCycleCount(); // any and all cycles rec.number_good_runs = (ushort)m.Cycles.GetUseableCycleCount(); // those that are marked OK rec.total_good_count_time = (ushort)m.Cycles.GetUseableCycleCount() * m.AcquireState.run_count_time; // check against time on first cycle, to assert rec.singles_sum = mcr.Totals; rec.scaler1_sum = mcr.S1Sum; rec.scaler2_sum = mcr.S2Sum; rec.reals_plus_acc_sum = mcr.RASum; rec.acc_sum = mcr.ASum; rec.singles = mcr.DeadtimeCorrectedSinglesRate.v; rec.singles_err = mcr.DeadtimeCorrectedSinglesRate.err; rec.doubles = mcr.DeadtimeCorrectedDoublesRate.v; rec.doubles_err = mcr.DeadtimeCorrectedDoublesRate.err; rec.triples = mcr.DeadtimeCorrectedTriplesRate.v; rec.triples_err = mcr.DeadtimeCorrectedTriplesRate.err; rec.scaler1 = mcr.Scaler1.v; rec.scaler1_err = mcr.Scaler1.err; rec.scaler2 = mcr.Scaler2.v; rec.scaler2_err = mcr.Scaler2.err; rec.uncorrected_doubles = mcr.RawDoublesRate.v; rec.uncorrected_doubles_err = mcr.RawDoublesRate.err; rec.singles_multi = mcr.singles_multi; rec.doubles_multi = mcr.doubles_multi; rec.triples_multi = mcr.triples_multi; rec.declared_mass= mcr.mass; TransferUtils.CopyULongsToDbls(mcr.RAMult, rec.mult_reals_plus_acc_sum); TransferUtils.CopyULongsToDbls(mcr.NormedAMult, rec.mult_acc_sum); for (int ix = 0; ix < 9; ix++) rec.covariance_matrix[ix] = mcr.covariance_matrix[ix]; INCCMethodResults imr; bool got = m.INCCAnalysisResults.TryGetINCCResults(m.Detector.MultiplicityParams, out imr); if (got) rec.primary_analysis_method = (byte)NewTypeToOldMethodId(imr.primaryMethod); // rec.net_drum_weight = // NEXT: no entry in INCC6 results for this result value, add it // NEXT: duo of passive and active measurent results identifier not yet properly handled in INCC6 b = StringSquish(m.MeasDate.ToString("yy.MM.dd"), INCC.DATE_TIME_LENGTH); TransferUtils.Copy(b, rec.passive_meas_date); TransferUtils.Copy(b, rec.active_meas_date); b = StringSquish(m.MeasDate.ToString("HH:mm:ss"), INCC.DATE_TIME_LENGTH); TransferUtils.Copy(b, rec.passive_meas_time); TransferUtils.Copy(b, rec.active_meas_time); b = StringSquish(System.IO.Path.GetFileName(m.MeasurementId.FileName), INCC.FILE_NAME_LENGTH); TransferUtils.Copy(b, rec.passive_filename); TransferUtils.Copy(b, rec.active_filename); b = StringSquish(System.IO.Path.GetFileName(m.MeasurementId.FileName), INCC.FILE_NAME_LENGTH); TransferUtils.Copy(b, rec.passive_results_detector_id); TransferUtils.Copy(b, rec.active_results_detector_id); b = StringSquish(m.Detector.Id.DetectorId, INCC.MAX_DETECTOR_ID_LENGTH); TransferUtils.Copy(b, rec.passive_results_detector_id); TransferUtils.Copy(b, rec.active_results_detector_id); ItemId itid = NC.App.DB.ItemIds.Get(m.AcquireState.item_id); if (itid != null) { rec.declared_u_mass = itid.declaredUMass; rec.length = itid.length; } rec.db_version = 5.0; return rec; }
protected Section ConstructReportSection(ReportSections section, Multiplicity mu, MultiplicityCountingRes mcr) { Section sec = null; if (!(bool)selectedReportSections.GetValue((int)section)) return sec; try { switch (section) { case ReportSections.RepResults: sec = new Section(typeof(RepResults), 1, 1, 1); sec[1].Add(0, "Corrected rates for SR " + mu.ShortName()); sec.Add(GenResultsRow(mcr)); break; case ReportSections.RepDytlewskiResults: sec = new Section(typeof(RepResults), 1, 1, 1); sec[1].Add(0, "Dytlewski rates for SR " + mu.ShortName()); sec.Add(GenDytlewskiResultsRow(mcr)); break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }
unsafe static void RunValuesToResults(run_rec_ext run, Cycle cycle, Multiplicity key, MultiplicityCountingRes mcr) { cycle.seq = run.run_number; cycle.TS = TimeSpan.FromSeconds(run.run_count_time); // is not always whole seconds hn 10-1. cycle.Totals = (ulong)run.run_singles; cycle.SinglesRate = run.run_singles / run.run_count_time; // table lookup on the strings, so test status is correct string s = TransferUtils.str(run.run_tests, INCC.MAX_RUN_TESTS_LENGTH); QCTestStatus qcts = QCTestStatusExtensions.FromString(s); cycle.SetQCStatus(key, qcts); // creates entry if not found mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.DeadtimeCorrectedSinglesRate.v = run.run_singles_rate; mcr.DeadtimeCorrectedDoublesRate.v = run.run_doubles_rate; mcr.DeadtimeCorrectedTriplesRate.v = run.run_triples_rate; mcr.RASum = (ulong)run.run_reals_plus_acc; mcr.ASum = (ulong)run.run_acc; mcr.efficiency = run.run_multiplicity_efficiency; mcr.mass = run.run_mass; mcr.multiAlpha = run.run_multiplicity_alpha; mcr.multiplication = run.run_multiplicity_mult; cycle.HighVoltage = run.run_high_voltage; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = run.run_singles; mcr.RawSinglesRate.v = run.run_singles_rate; mcr.RawDoublesRate.v = run.run_doubles_rate; mcr.RawTriplesRate.v = run.run_triples_rate; mcr.Scaler1.v = run.run_scaler1; mcr.Scaler2.v = run.run_scaler2; mcr.Scaler1Rate.v = run.run_scaler1_rate; mcr.Scaler2Rate.v = run.run_scaler2_rate; long index = 0; for (ulong i = 0; i < INCC.SR_EX_MAX_MULT; i++) { if (run.run_mult_acc[i] > 0 || run.run_mult_reals_plus_acc[i] > 0) { index = (long)i; } } mcr.MaxBins = (ulong)index + 1; mcr.MinBins = (ulong)index + 1; mcr.NormedAMult = new ulong[mcr.MaxBins]; mcr.RAMult = new ulong[mcr.MaxBins]; mcr.UnAMult = new ulong[mcr.MaxBins]; // was not setting these to the right values hn 10-2 for (ulong i = 0; i < (ulong)mcr.MaxBins; i++) { mcr.RAMult[i] = (ulong)run.run_mult_reals_plus_acc[i]; mcr.NormedAMult[i] = (ulong)run.run_mult_acc[i]; } mcr.RASum = run.run_reals_plus_acc; // JFL the cycle summary processing accumulates these sums later in the pipline mcr.ASum = run.run_acc; mcr.AB.Resize((int)mcr.MaxBins); // JFL also happens during transferintermediates }
public bool Transfer(Multiplicity mup, MultiplicityResult mr, int idx) { if (mr == null) return true; bool res = true; try { SetQCStatus(mup, QCTestStatus.Pass); // marked Pass at the outset MultiplicityCountingRes lmcs = new MultiplicityCountingRes(mup.FA, idx); countresults.Add(mup, lmcs); lmcs.Totals = Totals; lmcs.TransferRawResult(mr); lmcs.TS = new TimeSpan(TS.Ticks); } catch (OutOfMemoryException e) { mup.reason = "Multiplicity transfer " + e.Message; res = false; logger.TraceEvent(LogLevels.Error, 87406, mup.reason); } return res; }
Row GenDytlewskiResultsRow(MultiplicityCountingRes mcr) { Row row = new Row(); row.Add((int)RepResults.Singles, mcr.DytlewskiCorrectedSinglesRate.v.ToString()); row.Add((int)RepResults.SinglesSigma, mcr.DytlewskiCorrectedSinglesRate.err.ToString()); row.Add((int)RepResults.Doubles, mcr.DytlewskiCorrectedDoublesRate.v.ToString()); row.Add((int)RepResults.DoublesSigma, mcr.DytlewskiCorrectedDoublesRate.err.ToString()); row.Add((int)RepResults.Triples, mcr.DytlewskiCorrectedTriplesRate.v.ToString()); row.Add((int)RepResults.TripleSigmas, mcr.DytlewskiCorrectedTriplesRate.err.ToString()); //row.Add((int)RepResults.Quads, ""); //row.Add((int)RepResults.QuadsSigma, ""); return row; }
Row GenResultsRow(MultiplicityCountingRes mcr) { Row row = new Row(); row.Add((int)RepResults.Singles, mcr.DeadtimeCorrectedSinglesRate.v.ToString()); // todo: move to results list entry processing scope row.Add((int)RepResults.SinglesSigma, mcr.DeadtimeCorrectedSinglesRate.err.ToString()); row.Add((int)RepResults.Doubles, mcr.DeadtimeCorrectedDoublesRate.v.ToString()); row.Add((int)RepResults.DoublesSigma, mcr.DeadtimeCorrectedDoublesRate.err.ToString()); if (!meas.AcquireState.data_src.ToString().Equals ("Shift Register")) { row.Add((int)RepResults.Triples, mcr.DeadtimeCorrectedTriplesRate.v.ToString()); row.Add((int)RepResults.TripleSigmas, mcr.DeadtimeCorrectedTriplesRate.err.ToString()); } //row.Add((int)RepResults.Quads, ""); //row.Add((int)RepResults.QuadsSigma, ""); return row; }
/// <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 }
private void OKBtn_Click(object sender, EventArgs e) { ClipboardMonitor.OnClipboardChange -= new ClipboardMonitor.OnClipboardChangeEventHandler(ClipboardMonitor_OnClipboardChange); ClipboardMonitor.Stop(); // do not forget to stop ClearMeasCycles(); CycleList newCycles = new CycleList(); // NEXT: manual entry needs more work to get it completed, but you have a good start here Multiplicity key = new Multiplicity(ah.det.MultiplicityParams); // APluralityOfMultiplicityAnalyzers: expand in some logical manner, e.g. enable user to select the analyzer and related results for manual entry and assignment for (int i = 0; i < MAX_MANUAL_ENTRIES; i++) // hard-coded limits are ... lame { DataGridViewRow r = cyclesGridView.Rows[i]; if (r.Cells == null || (r.Cells[1].Value == null) || r.Cells[1].Value.ToString() == string.Empty) { break; } Cycle cycle = new Cycle(m_log); ulong tots = 0, r_acc = 0, acc = 0; ulong.TryParse(r.Cells[1].Value.ToString(), out tots); ulong.TryParse((string)r.Cells[2].FormattedValue, out r_acc); // FormattedValue gives "" instead of the null checked for in the conditional above ulong.TryParse((string)r.Cells[3].FormattedValue, out acc); newCycles.Add(cycle); cycle.Totals = tots; cycle.TS = new TimeSpan(0, 0, 0, 0, (int)(1000 * m_counttime)); // milliseconds permitted for LM and future cycle.SinglesRate = tots / m_counttime; cycle.SetQCStatus(key, QCTestStatus.Pass); cycle.seq = i + 1; MultiplicityCountingRes mcr = new MultiplicityCountingRes(key.FA, cycle.seq); cycle.CountingAnalysisResults.Add(key, mcr); mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = acc; mcr.RASum = r_acc; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = tots; mcr.RawSinglesRate.v = cycle.SinglesRate; // no alpha-beta, mult bins, HV, doubles, triples, raw nor corrected } int seq = 0; foreach (Cycle cycle in newCycles) // add the necessary meta-data to the cycle identifier instance { seq++; cycle.UpdateDataSourceId(ConstructedSource.Manual, ah.det.Id.SRType, new DateTimeOffset(m_refDate.AddTicks(cycle.TS.Ticks * cycle.seq)), string.Empty); } NC.App.Opstate.Measurement.Add(newCycles); if (newCycles.Count > 0) { DialogResult = DialogResult.OK; } Close(); }
void Bloat(ulong _MaxBins, MultiplicityCountingRes amcr) { ulong[] RA = new ulong[_MaxBins]; ulong[] NA = new ulong[_MaxBins]; ulong[] UNA = new ulong[_MaxBins]; amcr.MaxBins = _MaxBins; Array.Copy(amcr.RAMult, RA, amcr.RAMult.Length); // adds trailing 0s by leaving them untouched Array.Copy(amcr.NormedAMult, NA, amcr.NormedAMult.Length); // adds trailing 0s Array.Copy(amcr.UnAMult, UNA, amcr.UnAMult.Length); // adds trailing 0s amcr.RAMult = RA; amcr.NormedAMult = NA; amcr.UnAMult = UNA; }
unsafe static void RunValuesToResults(run_rec_ext run, Cycle cycle, Multiplicity key, MultiplicityCountingRes mcr) { cycle.seq = run.run_number; cycle.TS = TimeSpan.FromSeconds(run.run_count_time); // is not always whole seconds hn 10-1. cycle.Totals = (ulong)run.run_singles; cycle.SinglesRate = run.run_singles / run.run_count_time; // table lookup on the strings, so test status is correct string s = TransferUtils.str(run.run_tests, INCC.MAX_RUN_TESTS_LENGTH); QCTestStatus qcts = QCTestStatusExtensions.FromString(s); cycle.SetQCStatus(key, qcts); // creates entry if not found mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.DeadtimeCorrectedSinglesRate.v = run.run_singles_rate; mcr.DeadtimeCorrectedDoublesRate.v = run.run_doubles_rate; mcr.DeadtimeCorrectedTriplesRate.v = run.run_triples_rate; mcr.RASum = (ulong)run.run_reals_plus_acc; mcr.ASum = (ulong)run.run_acc; mcr.efficiency = run.run_multiplicity_efficiency; mcr.mass = run.run_mass; mcr.multiAlpha = run.run_multiplicity_alpha; mcr.multiplication = run.run_multiplicity_mult; cycle.HighVoltage = run.run_high_voltage; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = run.run_singles; mcr.RawSinglesRate.v = run.run_singles_rate; mcr.RawDoublesRate.v = run.run_doubles_rate; mcr.RawTriplesRate.v = run.run_triples_rate; mcr.Scaler1.v = run.run_scaler1; mcr.Scaler2.v = run.run_scaler2; mcr.Scaler1Rate.v = run.run_scaler1_rate; mcr.Scaler2Rate.v = run.run_scaler2_rate; long index = 0; for (ulong i = 0; i < INCC.SR_EX_MAX_MULT; i++) { if (run.run_mult_acc[i] > 0 || run.run_mult_reals_plus_acc[i] > 0) { index = (long)i; } } mcr.MaxBins = (ulong)index + 1; mcr.MinBins = (ulong)index + 1; mcr.NormedAMult = new ulong[mcr.MaxBins]; mcr.RAMult = new ulong[mcr.MaxBins]; mcr.UnAMult = new ulong[mcr.MaxBins]; // was not setting these to the right values hn 10-2 for (ulong i = 0; i < (ulong)mcr.MaxBins; i++) { mcr.RAMult[i] = (ulong)run.run_mult_reals_plus_acc[i]; mcr.NormedAMult[i] = (ulong)run.run_mult_acc[i]; } mcr.RASum = run.run_reals_plus_acc; mcr.ASum = run.run_acc; mcr.AB.Resize((int)mcr.MaxBins); }
public static void SetAlphaBeta(Multiplicity mkey, MultiplicityCountingRes mcr) { ABKey abkey = new ABKey(mkey, mcr); SetAlphaBeta(abkey, mcr.AB); }