Example #1
0
        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;
        }
Example #2
0
        // INCC5 enables subselecting each field and creates a two line header instead of one.
        Dictionary <string, string> GenerateEntries(Selections s, Measurement m)
        {
            Dictionary <string, string> entries = new Dictionary <string, string>();

            switch (s)
            {
            case Selections.AcquireParams:
                entries["Facility"]          = Q(m.AcquireState.facility.Name);
                entries["MBA"]               = Q(m.AcquireState.mba.Name);
                entries["Detector"]          = Q(m.AcquireState.detector_id);
                entries["IC"]                = Q(m.AcquireState.inventory_change_code);
                entries["IO"]                = Q(m.AcquireState.io_code);
                entries["Measurement Type"]  = Q(m.MeasOption.PrintName());
                entries["Meas Date"]         = m.MeasurementId.MeasDateTime.ToString("yy.MM.dd");
                entries["Meas Time"]         = m.MeasurementId.MeasDateTime.ToString("HH:mm:ss");
                entries["File Name"]         = Q(GetMainFilePath(m.ResultsFiles, m.MeasOption, true));
                entries["Inspector"]         = Q(m.AcquireState.user_id);
                entries["Inspection Number"] = Q(m.AcquireState.campaign_id);
                entries["Item ID"]           = Q(m.AcquireState.item_id);
                entries["Isotopics ID"]      = Q(m.AcquireState.isotopics_id);
                entries["Stratum ID"]        = Q(m.AcquireState.stratum_id.Name);
                entries["Material Type"]     = Q(m.AcquireState.item_type);
                break;

            case Selections.NormalizationParams:
                entries["Norm Cnst"]       = m.Norm.currNormalizationConstant.v.ToString("F4");           //	"Normalization constant"
                entries["Norm Cnst Error"] = m.Norm.currNormalizationConstant.err.ToString("F4");         //	"Normalization constant error"
                break;

            case Selections.BackgroundParams:
                entries["Singles Bkg"]         = m.Background.DeadtimeCorrectedSinglesRate.v.ToString("F1");   //	"Passive singles background"
                entries["Singles Bkg Error"]   = m.Background.DeadtimeCorrectedSinglesRate.err.ToString("F3"); //	"Passive singles background error"
                entries["Doubles Bkg"]         = m.Background.DeadtimeCorrectedDoublesRate.v.ToString("F2");   //	"Passive doubles background"
                entries["Doubles Bkg Error"]   = m.Background.DeadtimeCorrectedDoublesRate.err.ToString("F3"); //	"Passive doubles background error"
                entries["Triples Bkg"]         = m.Background.DeadtimeCorrectedTriplesRate.v.ToString("F2");   //	"Passive triples background"
                entries["Triples Bkg Error"]   = m.Background.DeadtimeCorrectedTriplesRate.err.ToString("F3"); //	"Passive triples background error"
                entries["Act Sngls Bkg"]       = m.Background.INCCActive.SinglesRate.ToString("F1");           //	"Active singles background"
                entries["Act Sngls Bkg Error"] = m.Background.INCCActive.Singles.err.ToString("F3");           //	"Active singles background error"
                break;

            case Selections.Summaries:
                if (m.INCCAnalysisState != null && m.INCCAnalysisResults != null)
                {
                    System.Collections.IEnumerator iter = m.INCCAnalysisResults.GetMeasSelectorResultsEnumerator();
                    while (iter.MoveNext())
                    {
                        MeasOptionSelector moskey = (MeasOptionSelector)iter.Current;
                        INCCResult         ir     = m.INCCAnalysisResults[moskey];
                        entries["Singles"]       = ir.DeadtimeCorrectedSinglesRate.v.ToString("F1");                   //	"Singles"
                        entries["Singles Error"] = ir.DeadtimeCorrectedSinglesRate.err.ToString("F3");                 //	"Singles error"
                        entries["Doubles"]       = ir.DeadtimeCorrectedDoublesRate.v.ToString("F2");                   //	"Doubles"
                        entries["Doubles Error"] = ir.DeadtimeCorrectedDoublesRate.err.ToString("F3");                 //	"Doubles error"
                        entries["Triples"]       = ir.DeadtimeCorrectedTriplesRate.v.ToString("F2");                   //	"Triples"
                        entries["Triples Error"] = ir.DeadtimeCorrectedTriplesRate.err.ToString("F3");                 //	"Triples error"
                        if (ir.Scaler1.v > 0 || ir.Scaler2.v > 0)
                        {
                            entries["Scaler 1"]       = ir.Scaler1.v.ToString("F1");
                            entries["Scaler 1 Error"] = ir.Scaler1.err.ToString("F3");
                            entries["Scaler 2"]       = ir.Scaler2.v.ToString("F1");
                            entries["Scaler 2 Error"] = ir.Scaler2.err.ToString("F3");
                        }
                        entries["Count Time"]  = (m.Cycles.Count > 0 ? m.Cycles[0].TS.TotalSeconds.ToString("F0") : "0"); // "Total count time for a measurement"
                        entries["Singles Sum"] = m.SinglesSum.ToString("F0");                                             // Sums - singles  Singles sum for a measurement"
                        entries["R+A Sum"]     = ir.RASum.ToString("F0");                                                 // Reals + accidentals sum for a measurement"
                        entries["A Sum"]       = ir.ASum.ToString("F0");                                                  // "Accidentals sum for a measurement"
                    }
                }
                break;

            case Selections.Comments:
                entries["Comment"] = m.AcquireState.comment;
                if (m.INCCAnalysisResults.TradResultsRec.acq.ending_comment &&
                    !string.IsNullOrEmpty(m.INCCAnalysisResults.TradResultsRec.acq.ending_comment_str))
                {
                    entries["End Comment"] = m.AcquireState.ending_comment_str;
                }
                break;

            case Selections.MassAnalysisMethods:
                break;

            case Selections.CalibrationCurve:
                INCCMethodResults.results_cal_curve_rec ccres = (INCCMethodResults.results_cal_curve_rec)
                                                                m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CalibrationCurve, false);
                if (ccres != null)
                {
                    entries["Cal Cur Dcl Mass"]  = ccres.dcl_pu_mass.ToString("F2");               //	Calibration curve - declared mass"
                    entries["Cal Cur Mass"]      = ccres.pu_mass.v.ToString("F2");                 //	"Calibration curve - mass"
                    entries["Cal Cur Mass Err"]  = ccres.pu_mass.err.ToString("F3");               //	"Calibration curve - mass error"
                    entries["Cal Cur Dcl-Asy"]   = ccres.dcl_minus_asy_pu_mass.v.ToString("F2");   //	"Calibration curve - declared minus assay"
                    entries["Cal Cur Dcl-Asy %"] = ccres.dcl_minus_asy_pu_mass_pct.ToString("F2"); //	"Calibration curve - declared minus assay %"
                    entries["Cal Cur Status"]    = ccres.pass ? "Pass": "";                        //	"Calibration curve - measurement status"
                }
                break;

            case Selections.KnownAlpha:
                INCCMethodResults.results_known_alpha_rec kares = (INCCMethodResults.results_known_alpha_rec)
                                                                  m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownA, false);
                if (kares != null)
                {
                    entries["Known A Dcl Mass"]  = kares.dcl_pu_mass.ToString("F2");               //	Known alpha - declared mass"
                    entries["Known A Mass"]      = kares.pu_mass.v.ToString("F2");                 //	"Known alpha - mass"
                    entries["Known A Mass Err"]  = kares.pu_mass.err.ToString("F3");               //	"Known alpha - mass error"
                    entries["Known A Dcl-Asy"]   = kares.dcl_minus_asy_pu_mass.v.ToString("F2");   //	"Known alpha - declared minus assay"
                    entries["Known A Dcl-Asy %"] = kares.dcl_minus_asy_pu_mass_pct.ToString("F2"); //	"Known alpha - declared minus assay %"
                    entries["Known A Mult"]      = kares.mult.ToString("F3");                      //	"Known alpha - multiplication"
                    entries["Known A Alpha"]     = kares.alphaK.ToString("F3");                    //	"Known alpha - alpha"
                    entries["Known A Status"]    = kares.pass ? "Pass": "";                        //	"Known alpha - measurement status"
                }
                break;

            case Selections.KnownM:
                INCCMethodResults.results_known_m_rec kmres = (INCCMethodResults.results_known_m_rec)
                                                              m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.KnownM, false);
                if (kmres != null)
                {
                    entries["Known M Dcl Mass"]  = kmres.dcl_pu_mass.ToString("F2");               //	Known M - declared mass"
                    entries["Known M Mass"]      = kmres.pu_mass.v.ToString("F2");                 //	"Known M - mass"
                    entries["Known M Mass Err"]  = kmres.pu_mass.err.ToString("F3");               //	"Known M - mass error"
                    entries["Known M Dcl-Asy"]   = kmres.dcl_minus_asy_pu_mass.v.ToString("F2");   //	"Known M - declared minus assay"
                    entries["Known M Dcl-Asy %"] = kmres.dcl_minus_asy_pu_mass_pct.ToString("F2"); //	"Known M - declared minus assay %"
                    entries["Known M Mult"]      = kmres.mult.ToString("F3");                      //	"Known M - multiplication"
                    entries["Known M Alpha"]     = kmres.alpha.ToString("F3");                     //	"Known M - alpha"
                    entries["Known M Status"]    = kmres.pass ? "Pass": "";                        //	"Known M - measurement status"
                }
                break;

            case Selections.Multiplicity:
                INCCMethodResults.results_multiplicity_rec mres = (INCCMethodResults.results_multiplicity_rec)
                                                                  m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.Multiplicity, false);
                if (mres != null)
                {
                    entries["Mult Dcl Mass"]    = mres.dcl_pu_mass.ToString("F2");               //	Multiplicity - declared mass"
                    entries["Mult Mass"]        = mres.pu_mass.v.ToString("F2");                 //	"Multiplicity- mass"
                    entries["Mult Mass Err"]    = mres.pu_mass.err.ToString("F3");               //	"Multiplicity - mass error"
                    entries["Mult Dcl-Asy"]     = mres.dcl_minus_asy_pu_mass.v.ToString("F2");   //	"Multiplicity - declared minus assay"
                    entries["Mult Dcl-Asy %"]   = mres.dcl_minus_asy_pu_mass_pct.ToString("F2"); //	"Multiplicity - declared minus assay %"
                    entries["Mult Mult"]        = mres.mult.v.ToString("F3");                    //	"Multiplicity - multiplication"
                    entries["Mult Mult Err"]    = mres.mult.err.ToString("F3");                  //	"Multiplicity - multiplication error"
                    entries["Mult Alpha"]       = mres.alphaK.v.ToString("F3");                  //	"Multiplicity - alpha"
                    entries["Mult Alpha Err"]   = mres.alphaK.err.ToString("F3");                //	"Multiplicity - alpha error"
                    entries["Mult Efficiency"]  = mres.efficiencyComputed.v.ToString("F3");      //	"Multiplicity - efficiency"
                    entries["Mult Eff Err"]     = mres.efficiencyComputed.err.ToString("F3");    //	"Multiplicity - efficiency error"
                    entries["Mult Status"]      = mres.pass ? "Pass": "";                        //	"Multiplicity - measurement status"
                    entries["Mult Predelay ms"] = m.Detector.SRParams.predelayMS.ToString();     //     "Multiplicity - predelay "
                    entries["Mult Gate ms"]     = m.Detector.SRParams.gateLengthMS.ToString();   //     "Multiplicity - gate width"
                }
                break;

            case Selections.AddASource:
                INCCMethodResults.results_add_a_source_rec aares = (INCCMethodResults.results_add_a_source_rec)
                                                                   m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.AddASource, false);
                if (aares != null)
                {
                    entries["Add-a-src Dcl Mass"]  = aares.dcl_pu_mass.ToString("F2");               //	Add-a-source - declared mass"
                    entries["Add-a-src Mass"]      = aares.pu_mass.v.ToString("F2");                 //	"Add-a-source - mass"
                    entries["Add-a-src Mass Err"]  = aares.pu_mass.err.ToString("F3");               //	"Add-a-source - mass error"
                    entries["Add-a-src Dcl-Asy"]   = aares.dcl_minus_asy_pu_mass.v.ToString("F2");   //	"Add-a-source - declared minus assay"
                    entries["Add-a-src Dcl-Asy %"] = aares.dcl_minus_asy_pu_mass_pct.ToString("F2"); //	"Add-a-source - declared minus assay %"
                    entries["Add-a-src Status"]    = aares.pass ? "Pass": "";                        //	"Add-a-source - measurement status"
                    entries["Add-a-src Corr"]      = aares.corr_factor.v.ToString("F3");             //	"Add-a-source - measurement status"
                }
                break;

            case Selections.CuriumRatio:
                INCCMethodResults.results_curium_ratio_rec cures = (INCCMethodResults.results_curium_ratio_rec)
                                                                   m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CuriumRatio, false);
                if (cures != null)
                {
                    entries["Cm Ratio ID"]       = cures.methodParams2.cm_id;                               // Curium ratio - ID"
                    entries["Cm Ratio Input ID"] = cures.methodParams2.cm_input_batch_id;                   // Curium ratio - input batch ID"
                    entries["Cm Ratio Cm/Pu"]    = cures.methodParams2.cm_pu_ratio.v.ToString("F4");        // Curium ratio - Cm/Pu ratio"
                    entries["Cm Ratio Cm/U"]     = cures.methodParams2.cm_u_ratio.v.ToString("F4");         // Curium ratio - Cm/U ratio"
                    entries["Cm Mass"]           = cures.cm_mass.v.ToString("F3");                          // Curium ratio - Cm mass"
                    entries["Cm Err"]            = cures.cm_mass.err.ToString("F3");                        // Curium ratio - Cm mass error"

                    entries["Cm Ratio Pu Dcl Mass"]    = cures.pu.dcl_pu_mass.ToString("F2");               // Curium ratio - declared mass"
                    entries["Cm Ratio Pu Mass"]        = cures.pu.pu_mass.v.ToString("F2");                 //	"Curium ratio - mass"
                    entries["Cm Ratio Pu Mass Err"]    = cures.pu.pu_mass.err.ToString("F3");               //	"Curium ratio - mass error"
                    entries["Cm Ratio Pu Dcl-Asy"]     = cures.pu.dcl_minus_asy_pu_mass.v.ToString("F2");   //	"Curium ratio - declared minus assay"
                    entries["Cm Ratio Pu Dcl-Asy %"]   = cures.pu.dcl_minus_asy_pu_mass_pct.ToString("F2"); //	"Curium ratio - declared minus assay %"
                    entries["Cm Ratio U Dcl Mass"]     = cures.u.dcl_mass.ToString("F2");                   // "Curium ratio - U declared mass"
                    entries["Cm Ratio U Mass"]         = cures.u.mass.v.ToString("F2");                     //	"Curium ratio - U mass"
                    entries["Cm Ratio U Mass Err"]     = cures.u.mass.err.ToString("F3");                   //	"Curium ratio - U mass error"
                    entries["Cm Ratio U Dcl-Asy"]      = cures.u.dcl_minus_asy_mass.v.ToString("F2");       //	"Curium ratio - U declared minus assay"
                    entries["Cm Ratio U Dcl-Asy %"]    = cures.u.dcl_minus_asy_mass_pct.ToString("F2");     //	"Curium ratio - U declared minus assay %"
                    entries["Cm Ratio U235 Dcl Mass"]  = cures.u235.dcl_mass.ToString("F2");                // Curium ratio - U235 declared mass"
                    entries["Cm Ratio U235 Mass"]      = cures.u235.mass.v.ToString("F2");                  //	"Curium ratio - U235 mass"
                    entries["Cm Ratio U235 Mass Err"]  = cures.u235.mass.err.ToString("F3");                //	"Curium ratio - U235 mass error"
                    entries["Cm Ratio U235 Dcl-Asy"]   = cures.u235.dcl_minus_asy_mass.v.ToString("F2");    //	"Curium ratio - U235 declared minus assay"
                    entries["Cm Ratio U235 Dcl-Asy %"] = cures.u235.dcl_minus_asy_mass_pct.ToString("F2");  //	"Curium ratio - U235 declared minus assay %"
                    entries["Cm Ratio Pu Status"]      = cures.pu.pass ? "Pass": "";                        //	"Curium ratio - Pu measurement status"
                    entries["Cm Ratio U Status"]       = cures.u.pass ? "Pass": "";                         //	"Curium ratio - U measurement status"
                }
                break;

            case Selections.TruncatedMultiplicity:
                INCCMethodResults.results_truncated_mult_rec tmres = (INCCMethodResults.results_truncated_mult_rec)
                                                                     m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.TruncatedMultiplicity, false);
                if (tmres != null)
                {
                    entries["Trunc Mult Dcl Mass"] = tmres.k.dcl_mass.ToString("F2");               // "Truncated multiplicity - declared mass"
                    entries["Trunc Mult Mass"]     = tmres.k.pu_mass.v.ToString("F2");              // "Truncated multiplicity - mass"
                    entries["Trunc Mult Mass Err"] = tmres.k.pu_mass.err.ToString("F3");            // "Truncated multiplicity - mass error"
                    entries["Trunc Mult Dcl-Asy"]  = tmres.k.dcl_minus_asy_mass.v.ToString("F2");   // "Truncated multiplicity - declared minus assay"
                    entries["Trunc Dcl-Asy %"]     = tmres.k.dcl_minus_asy_mass_pct.ToString("F2"); //"Truncated multiplicity - declared minus assay %"
                    entries["Trunc Mult Status"]   = tmres.k.pass ? "Pass": "";                     // "Truncated multiplicity - measurement status"  // todo: what about 's'?
                }
                break;

            case Selections.ActiveCalibCurve:
                INCCMethodResults.results_active_rec acres = (INCCMethodResults.results_active_rec)
                                                             m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.Active, false);
                if (acres != null)
                {
                    entries["Active Dcl Mass"]  = acres.dcl_u235_mass.ToString("F2");               //	Active calibration curve - declared mass"
                    entries["Active Mass"]      = acres.u235_mass.v.ToString("F2");                 //	"Active calibration curve - mass"
                    entries["Active Mass Err"]  = acres.u235_mass.err.ToString("F3");               //	"Active calibration curve - mass error"
                    entries["Active Dcl-Asy"]   = acres.dcl_minus_asy_u235_mass.v.ToString("F2");   //	"Active calibration curve - declared minus assay"
                    entries["Active Dcl-Asy %"] = acres.dcl_minus_asy_u235_mass_pct.ToString("F2"); //	"Active calibration curve - declared minus assay %"
                    entries["Active Status"]    = acres.pass ? "Pass": "";                          //	"Active calibration curve - measurement status"
                }
                break;

            case Selections.CollarAmLi:
                INCCMethodResults.results_collar_rec rcres = (INCCMethodResults.results_collar_rec)
                                                             m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CollarAmLi, false);
                if (rcres != null)
                {
                    entries["Collar Dbls Rate"]     = rcres.total_corr_fact.v.ToString("F2");           //	Collar - corrected doubles rate"
                    entries["Collar Dbls Rate Err"] = rcres.total_corr_fact.v.ToString("F2");           //	Collar -- corrected doubles rate error"
                    entries["Collar Dcl Mass"]      = rcres.dcl_total_u235.v.ToString("F2");            //	Collar - declared mass"
                    entries["Collar Mass"]          = rcres.u235_mass.v.ToString("F2");                 //	"Collar - mass"
                    entries["Collar Mass Err"]      = rcres.u235_mass.err.ToString("F3");               //	"Collar - mass error"
                    entries["Collar Dcl-Asy"]       = rcres.dcl_minus_asy_u235_mass.v.ToString("F2");   //	"Collar - declared minus assay"
                    entries["Collar Dcl-Asy %"]     = rcres.dcl_minus_asy_u235_mass_pct.ToString("F2"); //	"Collar - declared minus assay %"
                    entries["Collar Status"]        = rcres.pass ? "Pass": "";                          //	"Collar - measurement status"
                }
                break;

            case Selections.CollarCf:
                rcres = (INCCMethodResults.results_collar_rec)
                        m.INCCAnalysisResults.LookupMethodResults(m.Detector.MultiplicityParams, m.INCCAnalysisState.Methods.selector, AnalysisMethod.CollarCf, false);
                if (rcres != null)
                {
                    entries["Collar Dbls Rate"]     = rcres.total_corr_fact.v.ToString("F2");           //	Collar - corrected doubles rate"
                    entries["Collar Dbls Rate Err"] = rcres.total_corr_fact.v.ToString("F2");           //	Collar -- corrected doubles rate error"
                    entries["Collar Dcl Mass"]      = rcres.dcl_total_u235.v.ToString("F2");            //	Collar - declared mass"
                    entries["Collar Mass"]          = rcres.u235_mass.v.ToString("F2");                 //	"Collar - mass"
                    entries["Collar Mass Err"]      = rcres.u235_mass.err.ToString("F3");               //	"Collar - mass error"
                    entries["Collar Dcl-Asy"]       = rcres.dcl_minus_asy_u235_mass.v.ToString("F2");   //	"Collar - declared minus assay"
                    entries["Collar Dcl-Asy %"]     = rcres.dcl_minus_asy_u235_mass_pct.ToString("F2"); //	"Collar - declared minus assay %"
                    entries["Collar Status"]        = rcres.pass ? "Pass" : "";                         //	"Collar - measurement status"
                }
                break;

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

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

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

            // stratum look up, finds existing stratum by name
            if (useCurCalibParams || meas.Stratum == null)
            {
                List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList();
                INCCDB.StratumDescriptor        s  = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0);
                if (s == null)
                {
                    meas.Stratum = new Stratum();
                }
                else
                {
                    meas.Stratum = new Stratum(s.Stratum);
                }
            }
            INCCResults.results_rec xres = new INCCResults.results_rec(meas);
            meas.INCCAnalysisResults.TradResultsRec  = xres;
            CentralizedState.App.Opstate.Measurement = meas;   // put the measurement definition on the global state
        }
Example #4
0
 /// <summary>
 /// Save specific analysis results for Background, Initial Source, Normalization and Precision measurements.
 /// </summary>
 /// <param name="m">The measurement to preserve</param>
 /// <param name="res">The subclassed specific results instance</param> 
 static void SaveSpecificResultsForThisMeasurement(this Measurement m, INCCResult res)
 {
     long mid = m.MeasurementId.UniqueId;
     DB.ElementList els = res.ToDBElementList(); // generates the Table property content too
     DB.ParamsRelatedBackToMeasurement ar = new DB.ParamsRelatedBackToMeasurement(res.Table);
     long resid = ar.Create(mid, els);
     m.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34103, String.Format("Results {0} preserved ({1})",resid, res.Table));
 }
Example #5
0
        /// <summary>
        /// Imprint a new measurement with as much information as possible from a results_rec.
        /// </summary>
        /// <param name="rec">The results_rec with the measurement details</param>
        /// <param name="meaId">Unique id for the measurement, from the results_rec fields</param>
        /// <param name="logger">logger handle</param>
        /// <returns>A new measurement</returns>
        public Measurement(INCCResults.results_rec rec, MeasId meaId, LMLoggers.LognLM logger)
        {
            HVCalibrationParameters hv = NCC.IntegrationHelpers.GetCurrentHVCalibrationParams(rec.det);
            MeasurementTuple        mt = new MeasurementTuple(new DetectorList(rec.det), rec.tests, rec.norm, rec.bkg, rec.iso, rec.acq, hv);

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

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

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

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

            Stratum = new Stratum(rec.st);             // the stratum from the results rec
        }
Example #6
0
 /// <summary>
 /// Save specific analysis results for Background, Initial Source, Normalization and Precision measurements.
 /// </summary>
 /// <param name="m">The measurement to preserve</param>
 /// <param name="res">The subclassed specific results instance</param> 
 static void SaveSpecificResultsForThisMeasurement(this Measurement m, INCCResult res)
 {
     DB.Measurements ms = new DB.Measurements();
     long mid = ms.Lookup(m.Detectors[0].Id.DetectorName, m.MeasDate, m.MeasOption.PrintName());
     DB.ElementList els = res.ToDBElementList(); // generates the Table property content too
     DB.ParamsRelatedBackToMeasurement ar = new DB.ParamsRelatedBackToMeasurement(res.Table, ms.db);
     long resid = ar.Create(mid, els);                          
     m.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34103, String.Format("Results {0} preserved ({1})",resid, res.Table));
 }
Example #7
0
        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);
        }
Example #8
0
        public void GenerateReport(Measurement m)
        {
            if (N.App.Opstate.IsAbortRequested) // handle stop, cancel, abort here, for stop does it roll back all report gen from here?
            {
                return;
            }
            IEnumerator iter = m.INCCAnalysisResults.GetMeasSelectorResultsEnumerator();

            while (iter.MoveNext())
            {
                MeasOptionSelector moskey = (MeasOptionSelector)iter.Current;
                INCCResult         ir     = m.INCCAnalysisResults[moskey];
                // create one results for each SR key
                StartReportGeneration(m, m.MeasOption.PrintName() + " INCC " +
                                      (m.INCCAnalysisResults.Count > 1 ? "[" + moskey.MultiplicityParams.ShortName() + "] " : ""), // add an identifying signature to each file name if more than one active virtual SR
                                      ' ');                                                                                        // make these text files
                //Detector det = meas.Detectors.GetIt(moskey.SRParams);
                // now assuming only one detector on the list, so can use [0], the mos keys have specific values for virtual SR counting, overiding the detector
                Detector det = meas.Detectors[0];
                try
                {
                    sections.Add(ConstructReportSection(INCCReportSection.Header, det));
                    sections.Add(ConstructReportSection(INCCReportSection.Context, det));
                    sections.Add(ConstructReportSection(INCCReportSection.Isotopics, det));
                    sections.Add(ConstructReportSection(INCCReportSection.ShiftRegister, det, moskey));
                    sections.Add(ConstructReportSection(INCCReportSection.Adjustments, det));
                    sections.Add(ConstructReportSection(INCCReportSection.CycleSummary, det, moskey));
                    sections.Add(ConstructReportSection(INCCReportSection.Messages, det, moskey));

                    sections.Add(ConstructReportSection(INCCReportSection.SummedRawData, moskey, ir, det));
                    sections.Add(ConstructReportSection(INCCReportSection.SummedRA, moskey, ir, det));

                    sections.Add(ConstructReportSection(INCCReportSection.MassResults, moskey, ir, det));
                    sections.Add(ConstructReportSection(INCCReportSection.MethodResultsAndParams, moskey, ir, det));
                    sections.Add(ConstructReportSection(INCCReportSection.RawCycles, moskey, ir, det));
                    sections.Add(ConstructReportSection(INCCReportSection.DTCRateCycles, moskey, ir, det));
                    sections.Add(ConstructReportSection(INCCReportSection.MultiplicityDistributions, moskey, ir, det));
                    sections.Add(ConstructReportSection(INCCReportSection.Reference, det));
                    sections.RemoveAll(s => (s == null));

                    // copy all section rows to the report row list (t.rows)
                    int rowcount = 0;
                    foreach (Section sec in sections)
                    {
                        rowcount += sec.Count;
                    }
                    Array.Resize(ref t.rows, rowcount);

                    int idx = 0;
                    foreach (Section sec in sections)
                    {
                        Array.Copy(sec.ToArray(), 0, t.rows, idx, sec.Count); idx += sec.Count;
                    }
                }
                catch (Exception e)
                {
                    ctrllog.TraceException(e);
                }

                FinishReportGeneration();
            }
        }