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

CombinedPaper Class Reference

Collaboration diagram for CombinedPaper:

Collaboration graph
[legend]
List of all members.

Detailed Description

Represents a single paper Contains Real (data) plots, Predicted plots and fitted plots

Definition at line 21 of file CombinedPaper.java.


Public Member Functions

 CombinedPaper ()
 CombinedPaper (RealPaper paper) throws JetWebException
 CombinedPaper (RealPaper paper, Model model) throws JetWebException
 CombinedPaper (CombinedPaper paper) throws JetWebException
CombinedPaper setFit (Fit fit)
Fit getFit ()
Integer getModelId ()
CombinedPaper add (PredictedPlot plot) throws JetWebException
RealPaper getRealPaper ()
Collection< FittedPlotgetFittedPlots () throws JetWebException
Collection< MergedPlotgetPredictedPlots ()
HashMap< Integer, MergedPlotgetIndexedPredictedPlots ()
HashMap< Integer, FittedPlotgetIndexedFittedPlots ()
Integer getNPredictedPlots ()
CombinedPaper setScale (Double scale)
Double getScale ()
Double getFitChi2 ()
Double getFitChi2 (PlotSelection selection) throws JetWebException
Double getFitDOF ()

Private Attributes

RealPaper paper_
Integer modelId_ = -1
Fit fit_
HashMap< Integer, MergedPlotpredictedPlots_
HashMap< Integer, FittedPlotfittedPlots_
Double chi2_
Double dof_
Boolean dirtyChi2_ = true
Double scale_ = 1.0

Constructor & Destructor Documentation

CombinedPaper  ) 
 

Constructor to create empty paper

Definition at line 46 of file CombinedPaper.java.

00046                           {
00047     
00048     }

CombinedPaper RealPaper  paper  )  throws JetWebException
 

Constructor to create a paper by its Id

Definition at line 54 of file CombinedPaper.java.

00054                                                                 {
00055     
00056     paper_ = paper;
00057     }

CombinedPaper RealPaper  paper,
Model  model
throws JetWebException
 

Definition at line 59 of file CombinedPaper.java.

References MergedPlot.addPlot(), DataPlot.getId(), RealPaper.getId(), PredictedPlot.hasData(), and MergedPlot.mergePoints().

00059                                                                             {
00060 
00061     paper_ = paper;
00062     modelId_ = model.getId();
00063 
00064     // now fill all the predicted plots for that model
00065     model.addAllRunSeries();
00066 
00067     for(RealPlot plot: paper.getPlots()){
00068         MergedPlot existingPlot = null;
00069         boolean foundData = false;
00070 
00071         for(RunSeries runseries: 
00072             model.getRunSeriesCollection().getRunSeriesList()){
00073 
00074         PredictedPlot newPlot = new PredictedPlot(plot, runseries);
00075 
00076         if(newPlot.hasData()){
00077             foundData = true;
00078             existingPlot = 
00079             predictedPlots_.get(newPlot.getId());
00080             if(existingPlot==null){
00081 
00082             existingPlot = new MergedPlot();
00083             }
00084 
00085             existingPlot.addPlot(newPlot, false);
00086             predictedPlots_.put(newPlot.getId(), existingPlot);
00087         }
00088         }
00089         if(foundData){
00090         existingPlot.mergePoints();
00091         }
00092     }
00093 
00094     }

CombinedPaper CombinedPaper  paper  )  throws JetWebException
 

Constructor to create a paper from an existing paper The real plots are copied from the existing paper, but the predicted plots are not so that they can be filled from a different model

Definition at line 102 of file CombinedPaper.java.

References Fit.getScale().

00103                           {
00104 
00105     paper_ = paper.getRealPaper();
00106     fit_ = paper.getFit();
00107     modelId_ = paper.getModelId();
00108     scale_ = paper.getScale();
00109     chi2_ = paper.getFitChi2();
00110     dof_ = paper.getFitDOF();
00111     dirtyChi2_ = false;
00112     predictedPlots_ = 
00113         new HashMap<Integer, MergedPlot>(paper.getIndexedPredictedPlots());
00114     fittedPlots_ = 
00115         new HashMap<Integer, FittedPlot>(paper.getIndexedFittedPlots());
00116 
00117     }


Member Function Documentation

CombinedPaper add PredictedPlot  plot  )  throws JetWebException
 

Definition at line 139 of file CombinedPaper.java.

References MergedPlot.addPlot().

00140                           {
00141     MergedPlot existingPlot = predictedPlots_.get(plot.getId());
00142     if(existingPlot==null){
00143         existingPlot = new MergedPlot();
00144     }
00145 
00146     existingPlot.addPlot(plot);
00147     predictedPlots_.put(plot.getId(), existingPlot);
00148     dirtyChi2_ = true;
00149     return this;
00150     }

Fit getFit  ) 
 

Definition at line 131 of file CombinedPaper.java.

00131                        {
00132     return fit_;
00133     }

Double getFitChi2 PlotSelection  selection  )  throws JetWebException
 

Calculates the Chi2 for those predicted plots in this paper and the given PlotSelection. Scales the predicted Plots by the already set scale factor (unless they are "shape" plots)

Definition at line 231 of file CombinedPaper.java.

References DataPoint.add(), DataPoint.clone(), DataPlot.getDataPoints(), RealPaper.getPlot(), DataPlot.getSysScale(), DataPoint.getY(), DataPoint.getYDown(), DataPoint.getYUp(), DataPoint.setChi2(), FittedPlot.setDataPoints(), DataPoint.setY(), DataPoint.setYDown(), DataPoint.setYUp(), and DataPoint.toString().

00232                           {
00233 
00234     if(!dirtyChi2_) return chi2_;
00235     dirtyChi2_ = false;
00236     Double chi2 = 0.0;
00237 
00238     Vector<Integer> wantedIds = selection.getPlotIds();
00239 
00240     for(Map.Entry<Integer, MergedPlot> entry: predictedPlots_.entrySet()){
00241         if(wantedIds.contains(entry.getKey())&&
00242            entry.getValue().hasData()){
00243 
00244         RealPlot realPlot = paper_.getPlot(entry.getKey());
00245         Double localScale = 1.0;
00246 
00247         if(!entry.getValue().isShape()){
00248             localScale = scale_;
00249         }
00250 
00251         if(realPlot!=null){
00252             Vector<DataPoint> mcPts = entry.getValue().getDataPoints();
00253             Vector<DataPoint> realPts = realPlot.getDataPoints();
00254             Vector<DataPoint> fPts = new Vector<DataPoint>();
00255 
00256             //sort the data points so they are in the same order
00257 
00258             Collections.sort(mcPts);
00259             Collections.sort(realPts);
00260 
00261             if(mcPts.size()==realPts.size()){
00262             Double sysScale = realPlot.getSysScale();
00263             for(Integer pntNum=0; pntNum!=mcPts.size(); ++pntNum){
00264                 DataPoint mcPt = mcPts.get(pntNum);
00265                 DataPoint realPt = realPts.get(pntNum);
00266                 
00267                 if( mcPt.getYUp()!=0.0 && 
00268                 realPt.getYUp() !=0.0){
00269                 
00270                 Double errorMc = 
00271                     0.5 * localScale*
00272                     (mcPt.getYUp()+mcPt.getYDown());
00273                     
00274                 Double error2 = 0.5 * sysScale *
00275                     (realPt.getYUp() + realPt.getYDown());
00276 
00277                 error2 = error2 * error2;
00278                 error2 = error2 + errorMc*errorMc;
00279 
00280                 Double incr = mcPt.getY()*localScale - 
00281                     realPt.getY()*sysScale;
00282                 incr = incr * incr / error2;
00283                 
00284                 if(incr.isNaN() || incr.isInfinite()){
00285                     System.out.println
00286                     ("Error: plot" + 
00287                      entry.getValue().getNumber());
00288                     System.out.println
00289                     (error2+" , "+ mcPt.toString()+":"+
00290                      realPt.toString());
00291 
00292                 }
00293                 
00294                 chi2 = chi2 + incr;
00295                 mcPt.setChi2(incr);
00296                 DataPoint fPt = (DataPoint)mcPt.clone();
00297                 fPt.setY(mcPt.getY()*localScale);
00298                 fPt.setYUp(mcPt.getYUp()*localScale);
00299                 fPt.setYDown(mcPt.getYDown()*localScale);
00300                 fPts.add(fPt);
00301                 }
00302             }
00303             }
00304             
00305             FittedPlot fPlot = fittedPlots_.get(entry.getKey());
00306             if(fPlot==null){
00307             fPlot = new FittedPlot(entry.getValue(), fit_);
00308             }
00309             fPlot.setDataPoints(fPts);
00310             fittedPlots_.put(entry.getKey(), fPlot);
00311         }
00312         }
00313     }
00314 
00315     return chi2;
00316     }

Double getFitChi2  ) 
 

Returns the previously calculated chi2. Does not recalculate the Chi2 even if new plots have been or the scale changed. Should probably only be used by the copy constructor.

Definition at line 221 of file CombinedPaper.java.

00221                               {
00222     return chi2_;
00223     }

Double getFitDOF  ) 
 

Definition at line 318 of file CombinedPaper.java.

00318                              {
00319     return 1.0;
00320     }

Collection<FittedPlot> getFittedPlots  )  throws JetWebException
 

Definition at line 156 of file CombinedPaper.java.

References FittedPlot.getFit(), and Fit.getId().

Referenced by Fit.insertPlots().

00157                           {
00158     
00159     if(fit_.getId()<0){
00160         fittedPlots_.clear();
00161 
00162         dirtyChi2_ = true;
00163         return fittedPlots_.values();
00164     }
00165 
00166     for(MergedPlot plot: getPredictedPlots()){
00167         
00168         FittedPlot fPlot = fittedPlots_.get(plot.getId());
00169         
00170         if(fPlot==null || 
00171            fPlot.getFit()==null || 
00172            fPlot.getFit().getId()!=fit_.getId()){
00173 
00174         fPlot = new FittedPlot(plot, fit_);
00175 
00176         //set other stuff here needed for fittedplot 
00177         //(not sure if there is any)
00178 
00179         fittedPlots_.put(plot.getId(), fPlot);
00180         dirtyChi2_ = true;
00181         }
00182     }
00183 
00184     return fittedPlots_.values();
00185     }

HashMap<Integer, FittedPlot> getIndexedFittedPlots  ) 
 

Definition at line 195 of file CombinedPaper.java.

00195                                                                {
00196     return fittedPlots_;
00197     }

HashMap<Integer, MergedPlot> getIndexedPredictedPlots  ) 
 

Definition at line 191 of file CombinedPaper.java.

00191                                                                   {
00192     return predictedPlots_;
00193     }

Integer getModelId  ) 
 

Definition at line 135 of file CombinedPaper.java.

00135                                {
00136     return modelId_;
00137     }

Integer getNPredictedPlots  ) 
 

Definition at line 199 of file CombinedPaper.java.

Referenced by Fit.populatePapers().

00199                                        {
00200     return predictedPlots_.size();
00201     }

Collection<MergedPlot> getPredictedPlots  ) 
 

Definition at line 187 of file CombinedPaper.java.

00187                                                      {
00188     return predictedPlots_.values();
00189     }

RealPaper getRealPaper  ) 
 

Definition at line 152 of file CombinedPaper.java.

Referenced by Fit.populatePapers().

00152                                    {
00153     return paper_;
00154     }

Double getScale  ) 
 

Definition at line 209 of file CombinedPaper.java.

00209                             {
00210     return scale_;
00211     }

CombinedPaper setFit Fit  fit  ) 
 

Definition at line 119 of file CombinedPaper.java.

Referenced by Fit.insertPlots().

00119                                         {
00120     fit_ = fit;
00121 
00122     for(FittedPlot plot: fittedPlots_.values()){
00123         plot.setFit(fit);
00124     }
00125 
00126     dirtyChi2_ = true;
00127 
00128     return this;
00129     }

CombinedPaper setScale Double  scale  ) 
 

Definition at line 203 of file CombinedPaper.java.

00203                                                {
00204     scale_ = scale;
00205     dirtyChi2_ = true;
00206     return this;
00207     }


Member Data Documentation

Double chi2_ [private]
 

Definition at line 35 of file CombinedPaper.java.

Boolean dirtyChi2_ = true [private]
 

Definition at line 38 of file CombinedPaper.java.

Double dof_ [private]
 

Definition at line 36 of file CombinedPaper.java.

Fit fit_ [private]
 

Definition at line 27 of file CombinedPaper.java.

HashMap<Integer, FittedPlot> fittedPlots_ [private]
 

Initial value:

 
    new HashMap<Integer FittedPlot>()

Definition at line 32 of file CombinedPaper.java.

Integer modelId_ = -1 [private]
 

Definition at line 26 of file CombinedPaper.java.

RealPaper paper_ [private]
 

Definition at line 23 of file CombinedPaper.java.

HashMap<Integer, MergedPlot> predictedPlots_ [private]
 

Initial value:

 
    new HashMap<Integer MergedPlot>()

Definition at line 29 of file CombinedPaper.java.

Double scale_ = 1.0 [private]
 

Definition at line 40 of file CombinedPaper.java.


The documentation for this class was generated from the following file:

Generated Wed Jan 17 09:14:27 GMT 2007