Ejemplo n.º 1
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
        }