コード例 #1
0
ファイル: MomentumFitForm.cs プロジェクト: kryssb/SySal.NET
 private void btnExport_Click(object sender, EventArgs e)
 {
     if (Likelihood == null) 
     {
         MessageBox.Show("No momentum available.", "Missing fit", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     double cl = ((SySal.Processing.MCSLikelihood.Configuration)MCSLikelihood.Config).ConfidenceLevel;
     double[] bounds = Likelihood.ConfidenceRegions(0, cl);
     foreach (FitSet fs in clSlopeSets.Items)            
         fs.Source.SetMomentum(Likelihood, bounds[0], bounds[bounds.Length - 1], cl);
 }
コード例 #2
0
ファイル: MomentumFitForm.cs プロジェクト: kryssb/SySal.NET
 private void btnCompute_Click(object sender, EventArgs e)
 {
     if (clSlopeSets.CheckedItems.Count < 1)
     {
         MessageBox.Show("At least one data set must be enabled.", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     NumericalTools.Likelihood[] lk = new NumericalTools.Likelihood[clSlopeSets.CheckedItems.Count];
     int i;
     for (i = 0; i < clSlopeSets.CheckedItems.Count; i++)
     {
         FitSet fs = (FitSet)clSlopeSets.CheckedItems[i];
         if (fs.Likelihood == null)
             try
             {
                 MCSLikelihood.ProcessData(fs.Tracks, out fs.Likelihood);
             }
             catch (Exception x)
             {
                 MessageBox.Show("Error computing likelihood for set \"" + fs.ToString() + "\":\r\n" + x.Message, "Computation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         lk[i] = fs.Likelihood;
     }
     Likelihood = null;
     txtResults.Text = "";
     try
     {
         Likelihood = new NumericalTools.OneParamLogLikelihood(0.05, lk);
         string t = Likelihood.Best(0).ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + ";";
         double cl = ((SySal.Processing.MCSLikelihood.Configuration)MCSLikelihood.Config).ConfidenceLevel;
         double[] bounds = Likelihood.ConfidenceRegions(0, cl);                
         for (i = 0; i < bounds.Length; i += 2)
             t += " [" + bounds[i].ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "," + bounds[i + 1].ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "]";
         t += "; " + cl.ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
         txtResults.Text = t;
     }
     catch (Exception x)
     {
         MessageBox.Show("Error computing combined likelihood:\r\n" + x.Message, "Computation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     PlotLikelihood("LogL (combined)", Likelihood);
 }