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

JetWebHist Class Reference

List of all members.

Detailed Description

Wrapper around the JAIDA interfaces to create/plot histograms
Author:
Tom Court, UCL.

Definition at line 44 of file JetWebHist.java.


Static Public Member Functions

void writeGraphics (Paper paper, String path)
void writeGraphics (DataPlot plot, String path)

Static Protected Member Functions

IDataPointSet buildHist (DataPlot thisPlot, String path, String title)

Member Function Documentation

IDataPointSet buildHist DataPlot  thisPlot,
String  path,
String  title
[static, protected]
 

Builds a histogram from a DataPlot object. If path != null, a compressed (gzipped) xml file is created along with the histogram.

Definition at line 63 of file JetWebHist.java.

References DataPlot.getDataPoints(), DataPlot.getNDataSources(), DataPlot.getNumber(), DataPlot.getSysScale(), DataPoint.getX(), DataPoint.getY(), DataPoint.getYDown(), and DataPoint.getYUp().

00063                                                                                           {
00064         
00065         IDataPointSet data = null;
00066         try{
00067             System.setProperty("java.awt.headless", "true");
00068             IAnalysisFactory af = IAnalysisFactory.create();
00069             ITree tree = null;
00070             if(path!=null) {
00071                 tree = af.createTreeFactory().create(path+"/plot"+thisPlot.getNumber()+".xml",
00072                              "xml",false,true);
00073                 System.out.println("allow me to write you some XML :)");
00074                 
00075             }else{
00076                 tree = af.createTreeFactory().create();
00077             }
00078             
00079             IDataPointSetFactory dpsf = af.createDataPointSetFactory(tree);
00080             
00081           
00082             
00083             if(thisPlot.getNDataSources()==1) {
00084                 //System.out.println("HERE!");
00085                 Vector<DataPoint> points = thisPlot.getDataPoints();
00086                 
00087                 //data = dpsf.create(thisPlot.getTitle(),thisPlot.getTitle(),2);     //sort this out
00088                 //data = dpsf.create("/data",thisPlot.getTitle(),2);
00089                 data = dpsf.create("/data",title,2);
00090                 
00091                 for(int i=0;i<points.size();i++) {
00092                     
00093                     DataPoint p = points.elementAt(i);
00094                     data.addPoint();
00095                     data.point(i).coordinate(0).setValue(p.getX());
00096                     data.point(i).coordinate(1).setValue(p.getY()*thisPlot.getSysScale());
00097                     data.point(i).coordinate(1).setErrorPlus(p.getYUp()*thisPlot.getSysScale());
00098                     data.point(i).coordinate(1).setErrorMinus(p.getYDown()*thisPlot.getSysScale());
00099                     
00100                     
00101                 }
00102                 
00103                 
00104             }else{
00105                 System.out.println("SHOULDNT BE HERE");
00106             }
00107             
00108             if(path!=null) {
00109                 tree.commit();
00110             }
00111             
00112         }catch(Exception e) {
00113             e.printStackTrace();
00114         }
00115         
00116         return data;
00117     }

void writeGraphics DataPlot  plot,
String  path
[static]
 

Creates a Graphics of the histogram specified at the path specified.

Definition at line 124 of file JetWebHist.java.

References DataPlot.getNumber(), DataPlot.getTitle(), DataPlot.getXLabel(), DataPlot.getYLabel(), DataPlot.getYMax(), DataPlot.getYMinNonZero(), DataPlot.isLogarithmic(), and DataPlot.setTitle().

00124                                                                  {
00125         try{
00126 
00127         File plotDir = new File(path);
00128         //System.out.println("I am checking "+path);
00129         if (!plotDir.exists()){
00130         try {
00131             //FileUtils.forceMkdir(plotDir);
00132             plotDir.mkdirs();
00133         } catch (Exception io) {
00134             System.out.println("JetWebHist: failed to make "+plotDir);
00135             return;
00136         }       
00137         }
00138 
00139 
00140             IAnalysisFactory af = IAnalysisFactory.create();
00141             IPlotterFactory pf = af.createPlotterFactory();
00142             IPlotter page1 = pf.create("page1");
00143         page1.setParameter("plotterWidth","200");
00144         page1.setParameter("plotterHeight","200");
00145 
00146             
00147         IDataPointSet histMC=null;
00148         IDataPointSet histReal=null;
00149             page1.createRegions(1,1);
00150             
00151         DataPlot comparisonPlot = null;
00152 
00153         //page1.region(0).style().dataStyle().markerStyle().setColor("black");
00154         //page1.region(0).style().dataStyle().markerStyle().setShape("circle");
00155 
00156         page1.region(0).style().setParameter("showStatisticsBox","false");
00157         page1.region(0).setTitle(plot.getTitle());
00158         //      page1.region(0).style().setParameter("showTitle","false");
00159 
00160 
00161         //This styles overwrite some of the region styles
00162         IPlotterStyle styleReal = pf.createPlotterStyle();
00163         styleReal.dataStyle().markerStyle().setParameter("shape","1");
00164         styleReal.dataStyle().markerStyle().setParameter("color","black");
00165         IPlotterStyle styleMC = pf.createPlotterStyle();
00166         styleMC.dataStyle().markerStyle().setParameter("shape","2");
00167         styleMC.dataStyle().markerStyle().setParameter("color","red");
00168 
00169             //list available parameters
00170 
00171         /*      
00172             String[] styles = styleReal.availableParameters();
00173             for(int t = 0;t<styles.length;t++) {
00174         System.out.println(styles[t]);
00175             }
00176         */
00177             
00178             if (plot instanceof FittedPlot){
00179                 comparisonPlot = ((FittedPlot)plot).getCompPlot();
00180         histMC = buildHist(plot,null,"Simulation"); //set at path if you want xml
00181 
00182             } else if (plot instanceof PredictedPlot){
00183                 comparisonPlot = ((PredictedPlot)plot).getCompPlot();
00184         histMC = buildHist(plot,null,"Simulation"); //set at path if you want xml
00185 
00186         } else {
00187         histReal = buildHist(plot,null,"Measurement"); //set at path if you want xml
00188         }
00189 
00190         if ((comparisonPlot!=null)){
00191         histReal = buildHist(comparisonPlot,null,"Measurement"); //set at path if you want xml
00192             }
00193             
00194             if(plot.isLogarithmic()) {
00195                 System.out.println("Using logarithmic scale");
00196                 double ymx = plot.getYMax();
00197                 double ymn = plot.getYMinNonZero();
00198                 
00199                 if(comparisonPlot !=null) {
00200                     ymx = Math.max(ymx,comparisonPlot.getYMax());
00201                     ymn = Math.max(ymn,comparisonPlot.getYMinNonZero());
00202                     
00203                 }
00204                 
00205                 page1.region(0).style().yAxisStyle().setParameter("scale","logarithmic");
00206                 page1.region(0).setYLimits(ymn/2.0,ymx*2.0);
00207             }else {
00208                 double ymx = plot.getYMax();
00209                 double ymn = plot.getYMinNonZero();
00210                 
00211                 if(comparisonPlot !=null) {
00212                     ymx = Math.max(ymx,comparisonPlot.getYMax());
00213                     ymn = Math.max(ymn,comparisonPlot.getYMinNonZero());
00214                     
00215                 }
00216                 page1.region(0).setYLimits(0,ymx*1.1);
00217                 page1.region(0).style().xAxisStyle().setLabel(plot.getXLabel());
00218                 page1.region(0).style().yAxisStyle().setLabel(plot.getYLabel());
00219                 
00220             }
00221 
00222         if (histMC!=null) page1.region(0).plot(histMC,styleMC);     
00223         page1.region(0).plot(histReal,styleReal);
00224             
00225             page1.region(0).style().xAxisStyle().setLabel(plot.getXLabel());
00226             page1.region(0).style().yAxisStyle().setLabel(plot.getYLabel());
00227             
00228         Properties props = new Properties();
00229         props.setProperty("plotWidth",String.valueOf(300));
00230         props.setProperty("plotHeight",String.valueOf(300));
00231 
00232             //System.out.println("JetWebHist writing: "+path);
00233             PlotterUtilities.writeToFile(page1,path+"/plot"+plot.getNumber()
00234                      +"."+JetWebConfig.graphicsType,
00235                      JetWebConfig.graphicsType,props);
00236         }catch (Exception e) {
00237             e.printStackTrace();
00238         }
00239     return;
00240     }

void writeGraphics Paper  paper,
String  path
[static]
 

Remake the graphics of the plots for a given paper. This does not change the DB but takes a long time, so it usually runs in a seperate thread.

Definition at line 50 of file JetWebHist.java.

References Paper.getDirName(), and Paper.getPlots().

00050                                                               {
00051 
00052     String plotPath = path+"/"+paper.getDirName();
00053 
00054         for (DataPlot plot : paper.getPlots()){
00055             writeGraphics(plot,plotPath);
00056         }
00057     }


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

Generated Wed Jan 17 09:14:27 GMT 2007