package jhpro.stat.limit;
/*
syslimit program
computes confidence level for a given limit
based on number(s) of events seen, backgrounds, efficiencies, and
uncertainties on them
Roger Barlow February 2002
see hep-ex/0203002 or CPC (forthcoming) for details
*/
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
public class LimitCalculatorGui implements ActionListener{ // main window
/**
*
*/
private static final long serialVersionUID = 1L;
static final int NMAX=10; // up to 10 experiments
static final double EPSILON=0.0001;
public static void main(String[] args) {
/*
Frame f = new Frame();
f.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
};
});
*/
LimitCalculatorGui ut = new LimitCalculatorGui();
// ut.setSize(100,100); // same size as defined in the HTML APPLET
// f.add(ut);
// f.pack();
ut.init();
// f.setSize(100,100 + 20); // add 20, seems enough for the Frame title,
// f.setVisible(true);
}
public class ExperimentData extends Panel{ // all the data and how to use it
int[] nobs= new int[NMAX]; // number of events observed
double[] back= new double[NMAX]; // estimated background
double[] errback= new double[NMAX]; // error on estimated background
double[] fraction=new double[NMAX]; // efficiency for a channel
double[] errfraction=new double[NMAX]; // error on that
TextField[][] textfields=new TextField[NMAX][5]; // fields to enter the above
int nexp; // actual number of experiments
double pole; // where Eq. 6 may blow up
ExperimentData() {super(); // fill central part of screen
add(new Label("Number Seen ",Label.CENTER));
add(new Label("Background ",Label.RIGHT));
add(new Label("+- Error ",Label.LEFT));
nexp=0;
addexperiment(); // first and at this stage only experiment
setLayout(new GridLayout(0,3));
}
void addexperiment(){ // add fields for another experiment
if(nexp==NMAX) return; // safety check
// nexp is no of existing expts.
// hence index (base 0) for this one
// incremented at end
textfields[nexp][0] = new TextField("0",10); // defaults
textfields[nexp][1] = new TextField("0.0",10);
textfields[nexp][2] = new TextField("0.0",10);
textfields[nexp][3] = new TextField("1.0",10);
textfields[nexp][4] = new TextField("0.0",10);
if(nexp==1){ // for >1 experiment
// screen gets reformatted to
// show fields for individual factors
remove(textfields[0][0]); // remove 3 value fields
remove(textfields[0][1]);
remove(textfields[0][2]);
add(new Label("Specific sensitivity ",Label.RIGHT)); // add 2 titles
add(new Label("+- Error ",Label.LEFT));
for(int j=0;j<5;j++) add(textfields[0][j]); // put back 3+2 more
setLayout(new GridLayout(0,5)); // now 5 columns not 3
}
int icount= (nexp>0) ? 5:3; // display fields for this expt
for(int j=0;jpole || pole>0) pole=p;
}
}
return allzero;
}
}; // end of ExperimentData inner class definition
public class myFrame extends Frame implements ActionListener{ /**
*
*/
private static final long serialVersionUID = 1L;
// do requests
myFrame(String s){super(s);}
public double q(double R, int[] n,double c,ExperimentData e){
// calculate equation 6 of the paper
double result=0;
for(int i=0;i0)
{ // upper edge can be as high as it likes
R2*=2;
}
//R1 and R2 now bracket the solution. Use a boring binary split
int safetycount=0;
do{ R3=0.5*(R1+R2);
Q3= q(R3,elist.nobs,S,elist);
if(Q1*Q3 >0) {R1=R3; Q1=Q3;} else {R2=R3; Q2=Q3;}
safetycount++;
} while (!((Math.abs(Q3)<=10.*FLO.MIN_VALUE) ||
(safetycount>100) ||
(Math.abs(R1-R2)<=10.*FLO.MIN_VALUE)));
}
//R3 is now the critical value - unless allzero is set
int scoreSWG=0;
int scoreCH=0;
int scoreJ=0;
//generate events
textfield6.setText("I'm thinking!");
int[] resultSWG=new int[NMAX];
int[] resultCH=new int[NMAX];
int[] resultJ=new int[NMAX];
int i,j;
for(j=0;j
Ads help maintain this website.