Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

PredictedPlot.java

Go to the documentation of this file.
00001 package cedar.jetweb.model.plots;
00002 
00003 import java.io.File;
00004 import java.util.Enumeration;
00005 import java.util.Vector;
00006 
00007 import cedar.jetweb.db.DBPlotManager;
00008 import cedar.jetweb.model.*;
00009 import cedar.jetweb.*;
00010 import cedar.jetweb.generator.Generator;
00011 
00020 public class PredictedPlot extends DataPlot {
00021 
00022     private int runSeriesId=-1;
00023     private DataPlot comparisonPlot;
00024     private RunSeries runSeries;
00025     private boolean tested=false;
00026     private boolean isValid;
00027     private boolean dirtyData;
00028 
00040     public PredictedPlot(DataPlot basePlot, 
00041              RunSeries runSeriesIn) 
00042     throws JetWebException {
00043     
00044     comparisonPlot = basePlot;
00045     csnId=basePlot.getId();
00046     runSeries=runSeriesIn;
00047     runSeriesId=runSeriesIn.getId();
00048     setFrom(basePlot);  
00049     dirtyData = true;
00050     cuts_ = basePlot.getCutCollection();
00051     }
00052     //accessors
00053 
00054 
00055     public void setDataPoints(Vector<DataPoint> newDataPoints){
00056     super.setDataPoints(newDataPoints);
00057     }
00058 
00059     public PredictedPlot setRunSeries(RunSeries rs){
00060     runSeries = rs;
00061     runSeriesId = rs.getId();
00062     return this;
00063     }
00064 
00065 
00072     public void setRunSeriesId(int id){ runSeriesId = id; }
00079     public int getRunSeriesId(){ return runSeriesId; }
00080 
00081     public RunSeries getRunSeries(){return runSeries; }
00082 
00089     public DataPlot getCompPlot(){ return comparisonPlot; }
00096     public void setCompPlot(DataPlot newplot){ comparisonPlot=newplot; }
00097 
00098 
00099     //public methods
00107     public boolean hasData() throws JetWebException {
00108 
00109     if (!hasdata){// && dirtyData) {
00110 
00111         dataPoints = DBPlotManager.getDataPoints(this);
00112         if (dataPoints.isEmpty()){
00113         hasdata = false;
00114         System.out.println("No data for MC plot " 
00115                    + number + ":" 
00116                    + title+" RSId="+runSeriesId);
00117         
00118         } else {
00119         hasdata = true;
00120         }
00121         dirtyData = false;
00122         }
00123 
00124     return hasdata;
00125     }
00132     public void toDB(int update) throws JetWebException {
00133 
00134         //check whether crossection with this plot id exists
00135     //if it does, update crossection record,otherwise create  
00136     //delete existing data plot (if exists)
00137     //insert new data plot records
00138 
00139     if (update==0){
00140         DBPlotManager.updateCrossSectionPoints(this);
00141     } else {
00142         DBPlotManager.insertData(this);
00143     }
00144 
00145     }
00146     //
00147     // Some plots give unrealistic errors for good reasons. This
00148     // method provides an option to replace/modify them to make them
00149     // more realistic.
00150     // This function is called directly after a plot is read from XML.
00151     //
00152     public static void adjustErrors(PredictedPlot plot) throws JetWebException {
00153 
00154     // Field and Stuart mean pT plots.
00155 
00156         
00157     // The pT away plot.
00158     if (plot.getId() == 115){
00159 
00160         for (DataPoint point : plot.getDataPoints()) {
00161         // Errors are dodgy for points above about 10 GeV.
00162         if (point.getX()>10 && point.getY()!=0){
00163             double y = point.getY();
00164             point.setYUp( y/2.0 + point.getX()/6.0 );
00165             point.setYDown(point.getYUp());
00166         }
00167         }
00168 
00169     } else if (plot.getId() == 115){
00170 
00171         for (DataPoint point : plot.getDataPoints()){
00172 
00173         // Errors are dodgy for points above about 10 GeV.
00174         if (point.getX()>10 && point.getY()!=0){
00175             double y = point.getY();
00176             point.setYUp( y/2.0 + 1.5 );
00177             point.setYDown(point.getYUp());
00178         }
00179         }
00180     }
00181     }
00186      public void add(PredictedPlot plot2) throws JetWebException {
00187 
00188          Enumeration<DataPoint> points  = this.getDataPoints().elements();
00189      Enumeration<DataPoint> points2 = plot2.getDataPoints().elements();
00190      while (points.hasMoreElements()){
00191          double sig1sq=0, sig2sq=0, w1=0, w2=0;
00192 
00193          DataPoint p1 = (DataPoint)points.nextElement();
00194          DataPoint p2 = (DataPoint)points2.nextElement();
00195 
00196          p1.add(p2);
00197      }
00198      }
00206     public void fixZeroErrors(double lumi) throws JetWebException {
00207 
00208     if (lumi<=0.0) {
00209         System.out.println("DataPoint: attempt to fix errors with illegal lumi value="+lumi);
00210         return;
00211     }
00212 
00213     for (DataPoint point : getDataPoints()){
00214         point.fixZeroError(lumi);
00215     }
00216     }
00217 
00221     public boolean isPredictedBy(RunSeries rs){
00222     return (runSeriesId==rs.getId());
00223     }
00224 
00225 
00229     public MCProcessType getMCProcessType() throws JetWebException {
00230 
00231     if (proc==null) {
00232         proc = new MCProcessType(DBPlotManager.getProcId(runSeriesId));
00233     }
00234     return proc;
00235 
00236     }
00237 
00242     public boolean validMCProcessType() throws JetWebException {
00243 
00244     isValid = (getProcIdWanted()==getMCProcessType().getId());
00245 
00246     //System.out.println("Summary of validity test:"+procIdWanted+","
00247     //         +getMCProcessType().getId());
00248     //System.out.println("Plot ID:"+getId()+" "+runSeriesId);
00249 
00250     return isValid;
00251     }
00252 
00257     public int getProcIdWanted() throws JetWebException {
00258 
00259     if (procIdWanted!=0) return procIdWanted;
00260 
00261     // Get the runSeries if necessary.
00262     if ( (runSeries != null) && runSeries.getId()==runSeriesId ){
00263         // Do nothing. The run series exists & is up-to-date.
00264     } else {
00265         //runSeries = new RunSeries(runSeriesId);
00266         runSeries = RunSeries.Maker(runSeriesId);
00267     }
00268 
00269     return getProcIdWanted(runSeries.getGenerator());
00270     }
00271 
00272 
00273 }

Generated Wed Jan 17 09:14:27 GMT 2007