/// <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 }
/// <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 }