public IDDNormalizationSetup() { InitializeComponent(); det = Integ.GetCurrentAcquireDetector(); np = Integ.GetCurrentNormParams(det); this.Text += " for detector " + det.Id.DetectorName; switch (np.biasMode) { case NormTest.AmLiSingles: UseAmLiRadioButton.Checked = true; break; case NormTest.Cf252Doubles: UseCf252DoublesRadioButton.Checked = true; break; case NormTest.Cf252Singles: UseCf252SinglesRadioButton.Checked = true; break; case NormTest.Collar: CollarRadioButton.Checked = true; break; } }
/// <summary> /// Save a detector and its related class instances on the in-memory collections to the database /// </summary> /// <param name="newdet">The detector to persist</param> public static void PersistDetectorAndAssociations(Detector newdet) { // write detector essentials to DB, detector must be in DB before related insertions try { CentralizedState.App.DB.UpdateDetector(newdet); // write detector and related sr_parms to database BackgroundParameters bp = CentralizedState.App.DB.BackgroundParameters.Get(newdet); CentralizedState.App.DB.BackgroundParameters.Set(newdet, bp); NormParameters np = CentralizedState.App.DB.NormParameters.Get(newdet); CentralizedState.App.DB.NormParameters.Set(newdet, np); UnattendedParameters unp = CentralizedState.App.DB.UnattendedParameters.Get(newdet); CentralizedState.App.DB.UnattendedParameters.Set(newdet, unp); AddASourceSetup aass = CentralizedState.App.DB.AASSParameters.Get(newdet); CentralizedState.App.DB.AASSParameters.Set(newdet, aass); HVCalibrationParameters hv = CentralizedState.App.DB.HVParameters.Get(newdet); CentralizedState.App.DB.HVParameters.Set(newdet, hv); } catch (Exception) { } }
public IDDAmLiNormalization(NormParameters npp) { np = npp; InitializeComponent(); SourceIdTextBox.Text = np.sourceId; AccLimitTextBox.ToValidate = NumericTextBox.ValidateType.Float; AccLimitTextBox.NumberFormat = NumericTextBox.Formatter.F2; AccLimitTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; AccLimitTextBox.Value = np.acceptanceLimitPercent; NormConstTextBox.ToValidate = NumericTextBox.ValidateType.Float; NormConstTextBox.NumberFormat = NumericTextBox.Formatter.F4; NormConstTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NormConstTextBox.Value = np.currNormalizationConstant.v; NormConstErrorTextBox.ToValidate = NumericTextBox.ValidateType.Float; NormConstErrorTextBox.NumberFormat = NumericTextBox.Formatter.F4; NormConstErrorTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NormConstErrorTextBox.Value = np.currNormalizationConstant.err; RefSinglesRateTextBox.ToValidate = NumericTextBox.ValidateType.Float; RefSinglesRateTextBox.NumberFormat = NumericTextBox.Formatter.F3; RefSinglesRateTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; RefSinglesRateTextBox.Value = np.amliRefSinglesRate; RefSinglesDateTimePicker.Value = np.refDate; }
public IDDAcquireInitSrc() { InitializeComponent(); // Generate an instance of the generic acquire dialog event handlers object (this now includes the AcquireParameters object used for change tracking) ah = new AcquireHandlers(); ah.mo = AssaySelector.MeasurementOption.initial; this.Text += " for detector " + ah.det.Id.DetectorName; np = Integ.GetCurrentNormParams(ah.det); // a copy // Populate the UI fields with values from the local AcquireParameters object this.QCTestsCheckBox.Checked = ah.ap.qc_tests; this.PrintResultsCheckBox.Checked = ah.ap.print; this.CommentAtEndCheckBox.Checked = ah.ap.ending_comment; this.NumCyclesTextBox.Text = Format.Rend(ah.ap.num_runs); this.CommentTextBox.Text = ah.ap.comment; this.CountTimeTextBox.Text = Format.Rend(ah.ap.run_count_time); this.SourceIdTextBox.Text = ah.ap.item_id; this.MeasPrecisionTextBox.Text = ah.ap.meas_precision.ToString("F2"); this.MinNumCyclesTextBox.Text = Format.Rend(ah.ap.min_num_runs); this.MaxNumCyclesTextBox.Text = Format.Rend(ah.ap.max_num_runs); this.UseAddASourceCheckBox.Checked = np.biasTestUseAddasrc; this.DistanceToMoveTextBox.Text = np.biasTestAddasrcPosition.ToString("F1"); this.SourceIdTextBox.Text = np.sourceId; DistanceToMoveTextBox.Enabled = np.biasTestUseAddasrc; switch (np.biasMode) { case NormTest.AmLiSingles: AmLiNormRadioButton.Checked = true; break; case NormTest.Cf252Doubles: Cf252DblsNormRadioButton.Checked = true; break; case NormTest.Cf252Singles: Cf252SinglesNormRadioButton.Checked = true; break; case NormTest.Collar: break; } this.DataSourceComboBox.Items.Clear(); foreach (ConstructedSource cs in System.Enum.GetValues(typeof(ConstructedSource))) { if (cs.AcquireChoices() || cs.LMFiles(ah.det.Id.SRType)) DataSourceComboBox.Items.Add(cs.HappyFunName()); } if (ah.ap.acquire_type == AcquireConvergence.CycleCount) { this.UseNumCyclesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.DoublesPrecision) { this.UseDoublesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.TriplesPrecision) { this.UseTriplesRadioButton.Checked = true; } DataSourceComboBox.SelectedItem = ah.ap.data_src.HappyFunName(); }
public IDDCollarNormalization(NormParameters npp) { np = npp; InitializeComponent(); AmLiSourceIdTextBox.Text = np.sourceId; NeutronYieldTextBox.ToValidate = NumericTextBox.ValidateType.Float; NeutronYieldTextBox.NumberFormat = NumericTextBox.Formatter.F3; NeutronYieldTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NeutronYieldTextBox.Value = np.yieldRelativeToMrc95; NormalizationConstantTextBox.ToValidate = NumericTextBox.ValidateType.Float; NormalizationConstantTextBox.NumberFormat = NumericTextBox.Formatter.F4; NormalizationConstantTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NormalizationConstantTextBox.Value = np.currNormalizationConstant.v; NormalizationConstantErrorTextBox.ToValidate = NumericTextBox.ValidateType.Float; NormalizationConstantErrorTextBox.NumberFormat = NumericTextBox.Formatter.F4; NormalizationConstantErrorTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NormalizationConstantErrorTextBox.Value = np.currNormalizationConstant.err; ReferenceSinglesRateTextBox.ToValidate = NumericTextBox.ValidateType.Float; ReferenceSinglesRateTextBox.NumberFormat = NumericTextBox.Formatter.F3; ReferenceSinglesRateTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; ReferenceSinglesRateTextBox.Value = np.cf252RefDoublesRate.v; ReferenceSinglesDateTimePicker.Value = np.refDate; AcceptanceLimitTextBox.ToValidate = NumericTextBox.ValidateType.Float; AcceptanceLimitTextBox.NumberFormat = NumericTextBox.Formatter.F2; AcceptanceLimitTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; AcceptanceLimitTextBox.Value = np.acceptanceLimitPercent; }
/// <summary> /// Create a new detector in-memory, with the related classes. /// Emulates the INCC relationship constructor, caller must insert new det into global list, then update to DB later for persistence /// </summary> /// <param name="model">detector to copy</param> /// <param name="newId">New detector name</param> /// <param name="elecId">Electronics id (just a string)</param> /// <param name="typeDesc">Type description (just a string)</param> /// <param name="srType">Actual instrument type</param> /// <returns>The newly created in-memory Detector class instance</returns> static public Detector CreateDetectorWithAssociations(Detector model, string newId, string elecId, string typeDesc, InstrType srType = InstrType.AMSR) { if (model != null) { Detector det = new Detector(model); // copies the SR too det.Id.SetIdDetails(newId, elecId, typeDesc, model.Id.SRType); // copy the model detector's related parameters (skips stratum) NormParameters n = CentralizedState.App.DB.NormParameters.Get(model); NormParameters Norm = new NormParameters(n); BackgroundParameters b = CentralizedState.App.DB.BackgroundParameters.Get(model); BackgroundParameters Background = new BackgroundParameters(b); UnattendedParameters u = CentralizedState.App.DB.UnattendedParameters.Get(model); UnattendedParameters Unatt = new UnattendedParameters(u); AddASourceSetup a = CentralizedState.App.DB.AASSParameters.Get(model); AddASourceSetup Aass = new AddASourceSetup(a); HVCalibrationParameters h = CentralizedState.App.DB.HVParameters.Get(model); HVCalibrationParameters Hv = new HVCalibrationParameters(h); // add copied param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, Norm); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, Unatt); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, Background); CentralizedState.App.DB.AASSParameters.Map.Add(det, Aass); CentralizedState.App.DB.HVParameters.Map.Add(det, Hv); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return(det); } else { Detector det = new Detector(); det.Id.SetIdDetails(newId, elecId, typeDesc, srType); if (srType.IsListMode()) { det.Id.FullConnInfo = new LMConnectionInfo(); } // add fresh param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, new NormParameters()); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, new UnattendedParameters()); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, new BackgroundParameters()); CentralizedState.App.DB.AASSParameters.Map.Add(det, new AddASourceSetup()); CentralizedState.App.DB.HVParameters.Map.Add(det, new HVCalibrationParameters()); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return(det); } /* * todo: create analysis selector (or it happens automatically when first referenced?) * creating a stratum association * */ }
public static NormParameters GetCurrentNormParams(Detector det) { NormParameters np = new NormParameters(); if ((det != null) && CentralizedState.App.DB.NormParameters.Map.ContainsKey(det)) { np.Copy(CentralizedState.App.DB.NormParameters.Map[det]); } return(np); }
private void AcquireVerificationClick(object sender, RoutedEventArgs e) { AcquireParameters ap = Integ.GetCurrentAcquireParams(); Detector det = new Detector(); INCCAnalysisParams.collar_combined_rec parms = new INCCAnalysisParams.collar_combined_rec(); Integ.GetCurrentAcquireDetectorPair(ref ap, ref det); NormParameters npp = Integ.GetCurrentNormParams(det); AnalysisMethods am = Integ.GetMethodSelections(ap); if (am != null) { if (Integ.GetMethodSelections(det.Id.DetectorId, ap.ItemId.material).Has(AnalysisMethod.CollarAmLi)) { IDDAcquireAssay f = new IDDAcquireAssay(); DialogResult result = f.ShowDialog(); f.Close(); if (result == System.Windows.Forms.DialogResult.OK) { IDDCollarItemData data = new IDDCollarItemData(); result = data.ShowDialog(); data.Close(); } if (result == System.Windows.Forms.DialogResult.OK) { IDDK5CollarItemData k5 = new IDDK5CollarItemData(parms, true); result = k5.ShowDialog(); k5.Close(); } if (result == System.Windows.Forms.DialogResult.OK) { IDDCollarAcquire dlg = new IDDCollarAcquire(npp); dlg.ShowDialog(); } } else { IDDAcquireAssay f = new IDDAcquireAssay(); f.ShowDialog(); } } else { System.Windows.Forms.MessageBox.Show("You must define at least one analysis method.", "ERROR"); } }
public IDDAcquireBias() { InitializeComponent(); // Generate an instance of the generic acquire dialog event handlers object (this now includes the AcquireParameters object used for change tracking) ah = new AcquireHandlers(); ah.mo = AssaySelector.MeasurementOption.normalization; Text += " for detector " + ah.det.Id.DetectorName; np = Integ.GetCurrentNormParams(ah.det); // a copy // Populate the UI fields with values from the local AcquireParameters object QCTestsCheckBox.Checked = ah.ap.qc_tests; PrintResultsCheckBox.Checked = ah.ap.print; CommentAtEndCheckBox.Checked = ah.ap.ending_comment; NumCyclesTextBox.Text = Format.Rend(ah.ap.num_runs); CommentTextBox.Text = ah.ap.comment; CountTimeTextBox.Text = Format.Rend(ah.ap.run_count_time); MeasPrecisionTextBox.Text = ah.ap.meas_precision.ToString("F2"); MinNumCyclesTextBox.Text = Format.Rend(ah.ap.min_num_runs); MaxNumCyclesTextBox.Text = Format.Rend(ah.ap.max_num_runs); SourceId.Text = np.sourceId; DataSourceComboBox.Items.Clear(); foreach (ConstructedSource cs in Enum.GetValues(typeof(ConstructedSource))) { if (cs.AcquireChoices() || cs.LMFiles(ah.det.Id.SRType)) { DataSourceComboBox.Items.Add(cs.NameForViewing(ah.det.Id.SRType)); } } if (ah.ap.acquire_type == AcquireConvergence.CycleCount) { UseNumCyclesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.DoublesPrecision) { UseDoublesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.TriplesPrecision) { UseTriplesRadioButton.Checked = true; } DataSourceComboBox.SelectedItem = ah.ap.data_src.NameForViewing(ah.det.Id.SRType); SetHelp(); }
public IDDCollarAcquire(NormParameters npp) { InitializeComponent(); ap = Integ.GetCurrentAcquireParams(); col = new INCCAnalysisParams.collar_combined_rec(); ah = new AcquireHandlers(); ah.mo = AssaySelector.MeasurementOption.verification; Text += " for detector " + ah.det.Id.DetectorName; //ableTermControls(); Detector d= new Detector(); Integ.GetCurrentAcquireDetectorPair(ref ap, ref d); npp.CopyTo(norm); Integ.BuildMeasurement(ap, d, AssaySelector.MeasurementOption.verification); am = Integ.GetMethodSelections(ah.ap); // Main window checks if Collar is defined for material type. No check needed here. FillForm(); }
private void OKBtn_Click(object sender, EventArgs e) { DialogResult r = DialogResult.Ignore; switch (np.biasMode) { case NormTest.AmLiSingles: IDDAmLiNormalization dlg = new IDDAmLiNormalization(np); r = dlg.ShowDialog(this); break; case NormTest.Cf252Doubles: IDDCf252Normalization dlg2 = new IDDCf252Normalization(np); r = dlg2.ShowDialog(this); break; case NormTest.Cf252Singles: IDDCf252SinglesNorm dlg3 = new IDDCf252SinglesNorm(np); r = dlg3.ShowDialog(this); break; case NormTest.Collar: IDDCollarNormalization dlg4 = new IDDCollarNormalization(np); r = dlg4.ShowDialog(this); break; } if (r == DialogResult.OK) { /* if normalization constant or error has changed then set * the measured rate and error to zero. */ //This was blowing chunks and I don't know why. NormParameters onp = NC.App.DB.NormParameters.GetMap()[det]; if ((onp.currNormalizationConstant.v != np.currNormalizationConstant.v) || onp.currNormalizationConstant.err != np.currNormalizationConstant.err) { np.measRate.Zero(); } // copy changes back to original on user affirmation NC.App.DB.NormParameters.GetMap()[det] = np; // in the in-memory map NC.App.DB.NormParameters.Set(det, np); // in the database np.modified = false; this.Close(); } }
public IDDAcquireBias() { InitializeComponent(); // Generate an instance of the generic acquire dialog event handlers object (this now includes the AcquireParameters object used for change tracking) ah = new AcquireHandlers(); ah.mo = AssaySelector.MeasurementOption.normalization; Text += " for detector " + ah.det.Id.DetectorName; np = Integ.GetCurrentNormParams(ah.det); // a copy // Populate the UI fields with values from the local AcquireParameters object QCTestsCheckBox.Checked = ah.ap.qc_tests; PrintResultsCheckBox.Checked = ah.ap.print; CommentAtEndCheckBox.Checked = ah.ap.ending_comment; NumCyclesTextBox.Text = Format.Rend(ah.ap.num_runs); CommentTextBox.Text = ah.ap.comment; CountTimeTextBox.Text = Format.Rend(ah.ap.run_count_time); MeasPrecisionTextBox.Text = ah.ap.meas_precision.ToString("F2"); MinNumCyclesTextBox.Text = Format.Rend(ah.ap.min_num_runs); MaxNumCyclesTextBox.Text = Format.Rend(ah.ap.max_num_runs); SourceId.Text = np.sourceId; DataSourceComboBox.Items.Clear(); foreach (ConstructedSource cs in Enum.GetValues(typeof(ConstructedSource))) { if (cs.AcquireChoices() || cs.LMFiles(ah.det.Id.SRType)) DataSourceComboBox.Items.Add(cs.NameForViewing(ah.det.Id.SRType)); } if (ah.ap.acquire_type == AcquireConvergence.CycleCount) { UseNumCyclesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.DoublesPrecision) { UseDoublesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.TriplesPrecision) { UseTriplesRadioButton.Checked = true; } DataSourceComboBox.SelectedItem = ah.ap.data_src.NameForViewing(ah.det.Id.SRType); SetHelp(); }
public IDDCf252SinglesNorm(NormParameters npp) { np = npp; InitializeComponent(); RefSinglesDateTimePicker.Value = np.refDate; CfSourceIdTextBox.Text = np.sourceId; NormConstTextBox.ToValidate = NumericTextBox.ValidateType.Float; NormConstTextBox.NumberFormat = NumericTextBox.Formatter.F4; NormConstTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NormConstTextBox.Value = np.currNormalizationConstant.v; NormConstErrTextBox.ToValidate = NumericTextBox.ValidateType.Float; NormConstErrTextBox.NumberFormat = NumericTextBox.Formatter.F4; NormConstErrTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; NormConstErrTextBox.Value = np.currNormalizationConstant.err; AccLimitPercentTextBox.ToValidate = NumericTextBox.ValidateType.Float; AccLimitPercentTextBox.NumberFormat = NumericTextBox.Formatter.F2; AccLimitPercentTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; AccLimitPercentTextBox.Value = np.acceptanceLimitPercent; RefSinglesRateTextBox.ToValidate = NumericTextBox.ValidateType.Float; RefSinglesRateTextBox.NumberFormat = NumericTextBox.Formatter.F3; RefSinglesRateTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; RefSinglesRateTextBox.Value = np.cf252RefDoublesRate.v; RefSinglesRateErrorTextBox.ToValidate = NumericTextBox.ValidateType.Float; RefSinglesRateErrorTextBox.NumberFormat = NumericTextBox.Formatter.F3; RefSinglesRateErrorTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; RefSinglesRateErrorTextBox.Value = np.cf252RefDoublesRate.err; PrecisionLimitTextBox.ToValidate = NumericTextBox.ValidateType.Float; PrecisionLimitTextBox.NumberFormat = NumericTextBox.Formatter.F1; PrecisionLimitTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; PrecisionLimitTextBox.Value = np.initSrcPrecisionLimit; AccLimitStdDevTextBox.ToValidate = NumericTextBox.ValidateType.Float; AccLimitStdDevTextBox.NumberFormat = NumericTextBox.Formatter.F1; AccLimitStdDevTextBox.NumStyles = System.Globalization.NumberStyles.AllowDecimalPoint; AccLimitStdDevTextBox.Value = np.acceptanceLimitStdDev; }
public IDDCollarAcquire(NormParameters npp) { InitializeComponent(); MessageBox.Show("This functionality is not implemented yet.", "DOING NOTHING NOW"); }
public IDDAcquireInitSrc() { InitializeComponent(); // Generate an instance of the generic acquire dialog event handlers object (this now includes the AcquireParameters object used for change tracking) ah = new AcquireHandlers(); ah.mo = AssaySelector.MeasurementOption.initial; this.Text += " for detector " + ah.det.Id.DetectorName; np = Integ.GetCurrentNormParams(ah.det); // a copy // Populate the UI fields with values from the local AcquireParameters object this.QCTestsCheckBox.Checked = ah.ap.qc_tests; this.PrintResultsCheckBox.Checked = ah.ap.print; this.CommentAtEndCheckBox.Checked = ah.ap.ending_comment; this.NumCyclesTextBox.Text = Format.Rend(ah.ap.num_runs); this.CommentTextBox.Text = ah.ap.comment; this.CountTimeTextBox.Text = Format.Rend(ah.ap.run_count_time); this.SourceIdTextBox.Text = ah.ap.item_id; this.MeasPrecisionTextBox.Text = ah.ap.meas_precision.ToString("F2"); this.MinNumCyclesTextBox.Text = Format.Rend(ah.ap.min_num_runs); this.MaxNumCyclesTextBox.Text = Format.Rend(ah.ap.max_num_runs); this.UseAddASourceCheckBox.Checked = np.biasTestUseAddasrc; this.DistanceToMoveTextBox.Text = np.biasTestAddasrcPosition.ToString("F1"); this.SourceIdTextBox.Text = np.sourceId; DistanceToMoveTextBox.Enabled = np.biasTestUseAddasrc; switch (np.biasMode) { case NormTest.AmLiSingles: AmLiNormRadioButton.Checked = true; break; case NormTest.Cf252Doubles: Cf252DblsNormRadioButton.Checked = true; break; case NormTest.Cf252Singles: Cf252SinglesNormRadioButton.Checked = true; break; case NormTest.Collar: break; } this.DataSourceComboBox.Items.Clear(); foreach (ConstructedSource cs in System.Enum.GetValues(typeof(ConstructedSource))) { if (cs.AcquireChoices() || cs.LMFiles(ah.det.Id.SRType)) { DataSourceComboBox.Items.Add(cs.HappyFunName()); } } if (ah.ap.acquire_type == AcquireConvergence.CycleCount) { this.UseNumCyclesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.DoublesPrecision) { this.UseDoublesRadioButton.Checked = true; } else if (ah.ap.acquire_type == AcquireConvergence.TriplesPrecision) { this.UseTriplesRadioButton.Checked = true; } DataSourceComboBox.SelectedItem = ah.ap.data_src.HappyFunName(); }
public IDDPlotBiasMeasHistory() { InitializeComponent(); Integ.GetCurrentAcquireDetectorPair(ref ap, ref det); Text += " for detector " + det.Id.DetectorName; norm = N.App.DB.NormParameters.Get(det); normlist = new NormList(); if ((norm.biasMode == NormTest.AmLiSingles) || (norm.biasMode == NormTest.Collar)) { normlist.RefDoubles[0] = normlist.RefDoubles[1] = norm.amliRefSinglesRate; normlist.RefDoublesPlusErr[0] = normlist.RefDoublesPlusErr[1] = norm.amliRefSinglesRate; normlist.RefDoublesMinusErr[0] = normlist.RefDoublesMinusErr[1] = norm.amliRefSinglesRate; } else { normlist.RefDoubles[0] = normlist.RefDoubles[1] = norm.cf252RefDoublesRate.v; normlist.RefDoublesPlusErr[0] = normlist.RefDoublesPlusErr[1] = norm.cf252RefDoublesRate.v + norm.cf252RefDoublesRate.err; normlist.RefDoublesMinusErr[0] = normlist.RefDoublesMinusErr[1] = norm.cf252RefDoublesRate.v - norm.cf252RefDoublesRate.err; } irlist = N.App.DB.IndexedResultsFor(det.Id.DetectorId, "normalization", "All"); if (irlist.Count < 1) { return; } irlist.Sort((r1, r2) => // sort chronologically { return(DateTimeOffset.Compare(r1.DateTime, r2.DateTime)); }); if (norm.biasMode != NormTest.Cf252Doubles) { chart1.Titles[1].Text = "Singles Rate"; } // get the mult results with the singles/doubles normlist.RefNumber = irlist.Count; List <INCCResults.results_rec> mlist = new List <INCCResults.results_rec>(); foreach (INCCDB.IndexedResults ir in irlist) { mlist.Add(N.App.DB.ResultsRecFor(ir.Mid)); } // now create the list of norm points int num = 0; foreach (INCCResults.results_rec res in mlist) { NormValues nv = new NormValues(res.acq.MeasDateTime); nv.test = norm.biasMode; if (norm.biasMode == NormTest.Cf252Doubles) { nv.Doubles = res.mcr.DeadtimeCorrectedDoublesRate.v; nv.DoublesPlusErr = res.mcr.DeadtimeCorrectedDoublesRate.v + res.mcr.DeadtimeCorrectedDoublesRate.err; nv.DoublesMinusErr = res.mcr.DeadtimeCorrectedDoublesRate.v - res.mcr.DeadtimeCorrectedDoublesRate.err; normlist.Add(nv); } else { nv.Doubles = res.mcr.DeadtimeCorrectedSinglesRate.v; nv.DoublesPlusErr = res.mcr.DeadtimeCorrectedSinglesRate.v + res.mcr.DeadtimeCorrectedSinglesRate.err; nv.DoublesMinusErr = res.mcr.DeadtimeCorrectedSinglesRate.v - res.mcr.DeadtimeCorrectedSinglesRate.err; normlist.Add(nv); } if (nv.DoublesPlusErr > normlist.MaxDoubles) { normlist.MaxDoubles = nv.DoublesPlusErr; } if (nv.DoublesMinusErr < normlist.MinDoubles) { normlist.MinDoubles = nv.DoublesMinusErr; } nv.number = ++num; } normlist.CalcLowerUpper(); Series s = chart1.Series["Vals"]; // Set error bar upper & lower error style s["ErrorBarStyle"] = "Both"; s["ErrorBarCenterMarkerStyle"] = "Circle"; // Set error bar center marker style s.MarkerStyle = MarkerStyle.None; s.MarkerColor = System.Drawing.Color.DarkViolet; int imax = 0; ArrowAnnotation maxpt = new ArrowAnnotation(); maxpt.Name = "max"; maxpt.Height = -5; maxpt.Width = 0; maxpt.AnchorOffsetY = -2.5; foreach (NormValues n in normlist) { int i = s.Points.AddXY(n.number, n.Doubles, n.DoublesMinusErr, n.DoublesPlusErr); if (n.DoublesPlusErr == normlist.MaxDoubles) { imax = i; maxpt.ToolTip = "Max " + n.ToString(); } s.Points[i].ToolTip = n.ToString(); } chart1.Annotations.Add(maxpt); if (s.Points.Count > 0) { maxpt.AnchorDataPoint = s.Points[imax]; } }
public static Measurement BuildMeasurementTemp(AcquireParameters acq, Detector det, AssaySelector.MeasurementOption mo, TestParameters tp, BackgroundParameters bkg, NormParameters np, AnalysisDefs.Isotopics iso, HVCalibrationParameters hvp) { // gather it all together MeasurementTuple mt = new MeasurementTuple(new DetectorList(det), tp, np, bkg, iso, acq, hvp); det.Id.source = acq.data_src; // set the detector overall data source value here // create the context holder for the measurement. Everything is rooted here ... Measurement meas = new Measurement(mt, mo); FillInMeasurementDetails(meas); // ready for insertion of methods and processing start return(meas); }
public static NormParameters GetCurrentNormParams(Detector det) { NormParameters np = new NormParameters(); if ((det != null) && CentralizedState.App.DB.NormParameters.Map.ContainsKey(det)) np.Copy(CentralizedState.App.DB.NormParameters.Map[det]); return np; }
/// <summary> /// Create a new detector in-memory, with the related classes. /// Emulates the INCC relationship constructor, caller must insert new det into global list, then update to DB later for persistence /// </summary> /// <param name="model">detector to copy</param> /// <param name="newId">New detector name</param> /// <param name="elecId">Electronics id (just a string)</param> /// <param name="typeDesc">Type description (just a string)</param> /// <param name="srType">Actual instrument type</param> /// <returns>The newly created in-memory Detector class instance</returns> public static Detector CreateDetectorWithAssociations(Detector model, string newId, string elecId, string typeDesc, InstrType srType = InstrType.AMSR) { if (model != null) { Detector det = new Detector(model); // copies the SR too det.Id.SetIdDetails(newId, elecId, typeDesc, model.Id.SRType); // copy the model detector's related parameters (skips stratum) NormParameters n = CentralizedState.App.DB.NormParameters.Get(model); NormParameters Norm = new NormParameters(n); BackgroundParameters b = CentralizedState.App.DB.BackgroundParameters.Get(model); BackgroundParameters Background = new BackgroundParameters(b); UnattendedParameters u = CentralizedState.App.DB.UnattendedParameters.Get(model); UnattendedParameters Unatt = new UnattendedParameters(u); AddASourceSetup a = CentralizedState.App.DB.AASSParameters.Get(model); AddASourceSetup Aass = new AddASourceSetup(a); HVCalibrationParameters h = CentralizedState.App.DB.HVParameters.Get(model); HVCalibrationParameters Hv = new HVCalibrationParameters(h); // add copied param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, Norm); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, Unatt); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, Background); CentralizedState.App.DB.AASSParameters.Map.Add(det, Aass); CentralizedState.App.DB.HVParameters.Map.Add(det, Hv); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return det; } else { Detector det = new Detector(); det.Id.SetIdDetails(newId, elecId, typeDesc,srType); if (srType.IsListMode()) det.Id.FullConnInfo = new LMConnectionInfo(); // add fresh param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, new NormParameters()); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, new UnattendedParameters()); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, new BackgroundParameters()); CentralizedState.App.DB.AASSParameters.Map.Add(det, new AddASourceSetup()); CentralizedState.App.DB.HVParameters.Map.Add(det, new HVCalibrationParameters()); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return det; } /* * todo: create analysis selector (or it happens automatically when first referenced?) * creating a stratum association * */ }
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)); } }