[Rivet-svn] r3235 - in branches/2011-07-aida2yoda: include/Rivet src/Analyses src/Core src/Tools

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Jul 21 22:17:14 BST 2011


Author: dgrell
Date: Thu Jul 21 22:17:14 2011
New Revision: 3235

Log:
Massively simpler caching, making use of YODA construction from Scatter2D

Modified:
   branches/2011-07-aida2yoda/include/Rivet/Analysis.hh
   branches/2011-07-aida2yoda/include/Rivet/RivetYODA.fhh
   branches/2011-07-aida2yoda/include/Rivet/RivetYODA.hh
   branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8894728.cc
   branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8994773.cc
   branches/2011-07-aida2yoda/src/Analyses/ATLAS_2011_S9002537.cc
   branches/2011-07-aida2yoda/src/Analyses/CDF_1994_S2952106.cc
   branches/2011-07-aida2yoda/src/Analyses/D0_2008_S7837160.cc
   branches/2011-07-aida2yoda/src/Core/Analysis.cc
   branches/2011-07-aida2yoda/src/Tools/RivetYODA.cc

Modified: branches/2011-07-aida2yoda/include/Rivet/Analysis.hh
==============================================================================
--- branches/2011-07-aida2yoda/include/Rivet/Analysis.hh	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/include/Rivet/Analysis.hh	Thu Jul 21 22:17:14 2011	(r3235)
@@ -357,11 +357,12 @@
     /// @name Internal histogram booking (for use by Analysis sub-classes).
     //@{
 
-    /// Get bin edges for a named histo (using ref AIDA caching)
-    const BinEdges& binEdges(const std::string& hname) const;
+    /// Get reference data for a named histo
+    const YODA::Scatter2D & referenceData(const string& hname) const;
 
-    /// Get bin edges for a numbered histo (using ref AIDA caching)
-    const BinEdges& binEdges(size_t datasetId, size_t xAxisId, size_t yAxisId) const;
+    /// Get reference data for a numbered histo
+    const YODA::Scatter2D & referenceData(size_t datasetId, 
+				    size_t xAxisId, size_t yAxisId) const;
 
     /// Get bin edges with logarithmic widths
     BinEdges logBinEdges(size_t nbins, double lower, double upper);
@@ -511,11 +512,8 @@
     /// @name Utility functions
     //@{
 
-    /// Get the bin edges for this paper from the reference AIDA file, and cache them.
-    void _cacheBinEdges() const;
-
-    /// Get the x-axis points for this paper from the reference AIDA file, and cache them.
-    void _cacheXAxisData() const;
+    /// Get the reference data for this paper and cache it.
+    void _cacheRefData() const;
 
     //@}
 
@@ -546,16 +544,9 @@
     /// The controlling AnalysisHandler object.
     AnalysisHandler* _analysishandler;
 
-    // /// Collection of x-axis point data to speed up many autobookings: the
-    // /// reference data file should only be read once.
-    // /// @todo Reduce memory occupancy, or clear after initialisation?
-    mutable map<string, vector<DPSXPoint> > _dpsData;
-
-    /// Collection of cached bin edges to speed up many autobookings: the
+    /// Collection of cached refdata to speed up many autobookings: the
     /// reference data file should only be read once.
-    /// @todo Reduce memory occupancy, or clear after initialisation?
-    mutable map<string, BinEdges> _histBinEdges;
-
+    mutable RefDataMap _refdata;
 
   private:
 

Modified: branches/2011-07-aida2yoda/include/Rivet/RivetYODA.fhh
==============================================================================
--- branches/2011-07-aida2yoda/include/Rivet/RivetYODA.fhh	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/include/Rivet/RivetYODA.fhh	Thu Jul 21 22:17:14 2011	(r3235)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 #ifndef ANALYSIS_RIVETYODA_FHH
 #define ANALYSIS_RIVETYODA_FHH
 
@@ -11,11 +12,11 @@
 /// @brief Forward declarations of YODA interfaces
 
 namespace YODA {
-   class AnalysisObject;
-   class WriterYODA;
-   class Histo1D;
-   class Profile1D;
-   class Scatter2D;
+  class AnalysisObject;
+  class WriterYODA;
+  class Histo1D;
+  class Profile1D;
+  class Scatter2D;
 }
 
 namespace Rivet {
@@ -26,33 +27,12 @@
 }
 
 #include <vector>
+#include <map>
 
 namespace Rivet {
-
-//   /// Typedef for a collection of bin edges.
-   typedef std::vector<double> BinEdges;
-
-  /// Container for x-axis point details
-  struct DPSXPoint {
-    DPSXPoint(double xval, double xerrminus, double xerrplus) :
-      val(xval), errminus(xerrminus), errplus(xerrplus) { }
-    double val;
-    double errminus;
-    double errplus;
-  };
-
-  /// Container for x-axis point details
-  struct DPSXYPoint {
-    DPSXYPoint(double xval, double xerrminus, double xerrplus, double yval, double yerrminus, double yerrplus) :
-      xval(xval), xerrminus(xerrminus), xerrplus(xerrplus), yval(yval), yerrminus(yerrminus), yerrplus(yerrplus) { }
-    double xval;
-    double xerrminus;
-    double xerrplus;
-    double yval;
-    double yerrminus;
-    double yerrplus;
-  };
-
+  /// Typedef for a collection of bin edges.
+  typedef map<string, Scatter2DPtr> RefDataMap;
+  typedef vector<double> BinEdges;
 }
 
 #endif

Modified: branches/2011-07-aida2yoda/include/Rivet/RivetYODA.hh
==============================================================================
--- branches/2011-07-aida2yoda/include/Rivet/RivetYODA.hh	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/include/Rivet/RivetYODA.hh	Thu Jul 21 22:17:14 2011	(r3235)
@@ -19,15 +19,16 @@
 
 namespace Rivet {
 
-  /// Function to get a map of all the bin edge vectors in a paper with the
-  /// given @a papername.
-  map<string, BinEdges> getBinEdges(string papername);
-
-  map<string, BinEdges> getBinEdges(const map<string, vector<DPSXPoint> >& xpoints);
-
-  map<string, vector<DPSXPoint> > getDPSXValsErrs(string papername);
+  using YODA::WriterYODA;
+  using YODA::ReaderAIDA;
+  using YODA::Histo1D;
+  using YODA::Profile1D;
+  using YODA::Scatter2D;
+  using YODA::Point2D;
 
-  map<string, vector<DPSXYPoint> > getDPSXYValsErrs(string papername);
+  /// Function to get a map of all the refdata in a paper with the
+  /// given @a papername.
+  RefDataMap getRefData(string papername);
 
   /// Get the file system path to the AIDA reference file for this paper.
   string getDatafilePath(string papername);
@@ -41,12 +42,6 @@
     return intg;
   }
 
-  using YODA::WriterYODA;
-  using YODA::ReaderAIDA;
-  using YODA::Histo1D;
-  using YODA::Profile1D;
-  using YODA::Scatter2D;
-  using YODA::Point2D;
 }
 
 #endif

Modified: branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8894728.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8894728.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8894728.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -70,8 +70,8 @@
       // Standard deviation profiles
       // First the higher moments of main profiles to calculate variance and error on variance...
       for (size_t i = 1; i < 4; ++i) {
-        _hist_nch_transverse_500[i].reset(new Profile1D(binEdges(1+isqrts, 1, 1)));
-        _hist_ptsum_transverse_500[i].reset(new Profile1D(binEdges(3+isqrts, 1, 1)));
+        _hist_nch_transverse_500[i].reset(new Profile1D(referenceData(1+isqrts, 1, 1)));
+        _hist_ptsum_transverse_500[i].reset(new Profile1D(referenceData(3+isqrts, 1, 1)));
       }
       // Then the data point sets into which the results will be inserted
       _dps_sdnch_transverse_500   = bookScatter2D(5+isqrts, 1, 1);
@@ -148,8 +148,8 @@
       vector<double> num500(3, 0), ptSum500(3, 0.0);
       // Temporary histos that bin Nch and pT in dPhi.
       // NB. Only one of each needed since binnings are the same for the energies and pT cuts
-      Histo1D hist_num_dphi_500(binEdges(13,1,1));
-      Histo1D hist_pt_dphi_500(binEdges(15,1,1));
+      Histo1D hist_num_dphi_500(referenceData(13,1,1));
+      Histo1D hist_pt_dphi_500(referenceData(15,1,1));
       foreach (const Particle& p, particles500) {
         const double pT = p.momentum().pT();
         const double dPhi = deltaPhi(philead, p.momentum().phi());
@@ -212,7 +212,7 @@
       // Note that we fill dN/dEtadPhi: dEta = 2*2.5, dPhi = 2*PI/nBins
       // The values tabulated in the note are for an (undefined) signed Delta(phi) rather than
       // |Delta(phi)| and so differ by a factor of 2: we have to actually norm for angular range = 2pi
-      const size_t nbins = binEdges(13,1,1).size() - 1;
+      const size_t nbins = referenceData(13,1,1).numPoints();
       std::vector<double> ptcut;
       if (fuzzyEquals(sqrtS(), 900*GeV)) {
         ptcut += 1.0; ptcut += 1.5; ptcut += 2.0; ptcut += 2.5;

Modified: branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8994773.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8994773.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Analyses/ATLAS_2010_S8994773.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -62,7 +62,7 @@
       vector<double> num500(3, 0), ptSum500(3, 0.0);
       // Temporary histos that bin N in dPhi.
       // NB. Only one of each needed since binnings are the same for the energies and pT cuts
-      Histo1D hist_num_dphi_500(binEdges(13+isqrts,1,1));
+      Histo1D hist_num_dphi_500(referenceData(13+isqrts,1,1));
       foreach (const Particle& p, particles500) {
         const double pT = p.momentum().pT();
         const double dPhi = deltaPhi(philead, p.momentum().phi());
@@ -88,7 +88,7 @@
       // Note that we fill dN/dEtadPhi: dEta = 2*2.5, dPhi = 2*PI/nBins
       // The values tabulated in the note are for an (undefined) signed Delta(phi) rather than
       // |Delta(phi)| and so differ by a factor of 2: we have to actually norm for angular range = 2pi
-      const size_t nbins = binEdges(13+isqrts,1,1).size() - 1;
+      const size_t nbins = referenceData(13+isqrts,1,1).numPoints();
       for (size_t i = 0; i < nbins; ++i) {
         const double binmean_num = hist_num_dphi_500.bin(i).xMean();
         const double binvalue_num = hist_num_dphi_500.bin(i).area()/hist_num_dphi_500.bin(i).width()/10.0;

Modified: branches/2011-07-aida2yoda/src/Analyses/ATLAS_2011_S9002537.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Analyses/ATLAS_2011_S9002537.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Analyses/ATLAS_2011_S9002537.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -28,8 +28,8 @@
       MissingMomentum missmom(FinalState(-5.,5.,0.*GeV));
       addProjection(missmom,"MissingMomentum");
 
-      _h_plus   = bookHisto1D("_h_plus",  binEdges(1,1,1));
-      _h_minus  = bookHisto1D("_h_minus", binEdges(1,1,1));
+      _h_plus   = bookHisto1D(1,1,1,"_h_plus");
+      _h_minus  = bookHisto1D(1,1,1,"_h_minus");
       _h_asym   = bookScatter2D(1,1,1);
     }
 

Modified: branches/2011-07-aida2yoda/src/Analyses/CDF_1994_S2952106.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Analyses/CDF_1994_S2952106.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Analyses/CDF_1994_S2952106.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -42,9 +42,9 @@
       _histAlpha   = bookScatter2D(5,1,1);
 
       // Temporary histos: these are the ones we actually fill for the plots which require correction
-      _tmphistJet3eta.reset(new Histo1D(binEdges(3,1,1)));
-      _tmphistR23.reset(    new Histo1D(binEdges(4,1,1)));
-      _tmphistAlpha.reset(  new Histo1D(binEdges(5,1,1)));
+      _tmphistJet3eta.reset(new Histo1D(referenceData(3,1,1)));
+      _tmphistR23.reset(    new Histo1D(referenceData(4,1,1)));
+      _tmphistAlpha.reset(  new Histo1D(referenceData(5,1,1)));
     }
 
 

Modified: branches/2011-07-aida2yoda/src/Analyses/D0_2008_S7837160.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Analyses/D0_2008_S7837160.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Analyses/D0_2008_S7837160.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -38,13 +38,12 @@
       addProjection(wfe, "WFe");
 
       // Cross-section histograms
-      const BinEdges& edges = binEdges(1,1,1);
-      _h_dsigplus_deta_25_35  = bookHisto1D("/dsigplus_deta_25_35", edges);
-      _h_dsigminus_deta_25_35 = bookHisto1D("/dsigminus_deta_25_35", edges);
-      _h_dsigplus_deta_35     = bookHisto1D("/dsigplus_deta_35", edges);
-      _h_dsigminus_deta_35    = bookHisto1D("/dsigminus_deta_35", edges);
-      _h_dsigplus_deta_25     = bookHisto1D("/dsigplus_deta_25", edges);
-      _h_dsigminus_deta_25    = bookHisto1D("/dsigminus_deta_25", edges);
+      _h_dsigplus_deta_25_35  = bookHisto1D(1,1,1,"/dsigplus_deta_25_35");
+      _h_dsigminus_deta_25_35 = bookHisto1D(1,1,1,"/dsigminus_deta_25_35");
+      _h_dsigplus_deta_35     = bookHisto1D(1,1,1,"/dsigplus_deta_35");
+      _h_dsigminus_deta_35    = bookHisto1D(1,1,1,"/dsigminus_deta_35");
+      _h_dsigplus_deta_25     = bookHisto1D(1,1,1,"/dsigplus_deta_25");
+      _h_dsigminus_deta_25    = bookHisto1D(1,1,1,"/dsigminus_deta_25");
     }
 
 

Modified: branches/2011-07-aida2yoda/src/Core/Analysis.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Core/Analysis.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Core/Analysis.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -162,41 +162,24 @@
   // Histogramming
 
 
-  void Analysis::_cacheBinEdges() const {
-    _cacheXAxisData();
-    if (_histBinEdges.empty()) {
-      MSG_TRACE("Getting histo bin edges from AIDA for paper " << name());
-      _histBinEdges = getBinEdges(_dpsData);
+  void Analysis::_cacheRefData() const {
+    if (_refdata.empty()) {
+      MSG_TRACE("Getting refdata cache for paper " << name());
+      _refdata = getRefData(name());
     }
   }
 
 
-  void Analysis::_cacheXAxisData() const {
-    if (_dpsData.empty()) {
-      MSG_TRACE("Getting DPS x-axis data from AIDA for paper " << name());
-      _dpsData = getDPSXValsErrs(name());
-    }
-  }
-
-
-  const BinEdges& Analysis::binEdges(const string& hname) const {
-    _cacheBinEdges();
+  const Scatter2D & Analysis::referenceData(const string& hname) const {
+    _cacheRefData();
     MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
-    const BinEdges& edges = _histBinEdges.find(hname)->second;
-    if (getLog().isActive(Log::TRACE)) {
-      stringstream edges_ss;
-      foreach (const double be, edges) {
-        edges_ss << " " << be;
-      }
-      MSG_TRACE("Edges:" << edges_ss.str());
-    }
-    return edges;
+    return *_refdata[hname];
   }
 
 
-  const BinEdges& Analysis::binEdges(size_t datasetId, size_t xAxisId, size_t yAxisId) const {
+  const Scatter2D & Analysis::referenceData(size_t datasetId, size_t xAxisId, size_t yAxisId) const {
     const string hname = makeAxisCode(datasetId, xAxisId, yAxisId);
-    return binEdges(hname);
+    return referenceData(hname);
   }
 
 
@@ -214,8 +197,8 @@
   }
 
   Histo1DPtr Analysis::bookHisto1D(size_t datasetId, size_t xAxisId,
-                                          size_t yAxisId, const string& title,
-                                          const string& xtitle, const string& ytitle)
+				   size_t yAxisId, const string& title,
+				   const string& xtitle, const string& ytitle)
   {
     const string axisCode = makeAxisCode(datasetId, xAxisId, yAxisId);
     return bookHisto1D(axisCode, title, xtitle, ytitle);
@@ -226,9 +209,9 @@
 				   const string& xtitle, const string& ytitle)
   {
     // Get the bin edges (only read the AIDA file once)
-    const BinEdges edges = binEdges(hname);
+    const Scatter2D & refdata = referenceData(hname);
     const string path = histoPath(hname);
-    Histo1DPtr hist( new Histo1D(edges,path,title) );
+    Histo1DPtr hist( new Histo1D(refdata,title) );
     addPlot(hist);
     MSG_TRACE("Made histogram " << hname <<  " for " << name());
     // hist->setXTitle(xtitle);
@@ -317,9 +300,9 @@
 				       const string& xtitle, const string& ytitle)
   {
     // Get the bin edges (only read the AIDA file once)
-    const BinEdges edges = binEdges(hname);
+    const Scatter2D & refdata = referenceData(hname);
     const string path = histoPath(hname);
-    Profile1DPtr prof( new Profile1D(edges, path, title) );
+    Profile1DPtr prof( new Profile1D(refdata, title) );
     addPlot(prof);
     MSG_TRACE("Made profile histogram " << hname <<  " for " << name());
     // prof->setXTitle(xtitle);
@@ -390,29 +373,30 @@
     return dps;
   }
 
-
-  Scatter2DPtr Analysis::bookScatter2D(size_t datasetId, size_t xAxisId,
-				       size_t yAxisId, const string& title,
-				       const string& xtitle, const string& ytitle) {
-    // Get the bin edges (only read the AIDA file once)
-    _cacheXAxisData();
-    // Build the axis code
-    const string axisCode = makeAxisCode(datasetId, xAxisId, yAxisId);
-    //const map<string, vector<DPSXPoint> > xpoints = getDPSXValsErrs(papername);
-    MSG_TRACE("Using DPS x-positions for " << name() << ":" << axisCode);
-    Scatter2DPtr dps = bookScatter2D(axisCode, title, xtitle, ytitle);
-    const vector<DPSXPoint> xpts = _dpsData.find(axisCode)->second;
-    for (size_t pt = 0; pt < xpts.size(); ++pt) {
-      // \todo YODA check
-      dps->addPoint(xpts[pt].val, xpts[pt].errminus, xpts[pt].errplus, 0, 0, 0);
-      // IMeasurement* meas = dps->point(pt)->coordinate(0);
-      // meas->setValue(xpts[pt].val);
-      // meas->setErrorPlus(xpts[pt].errplus);
-      // meas->setErrorMinus(xpts[pt].errminus);
-    }
-    MSG_TRACE("Made DPS " << axisCode <<  " for " << name());
-    return dps;
-  }
+  // \todo YODA
+  // Scatter2DPtr Analysis::bookScatter2D(size_t datasetId, size_t xAxisId,
+  // 				       size_t yAxisId, const string& title,
+  // 				       const string& xtitle, const string& ytitle) {
+  //   // Get the bin edges (only read the AIDA file once)
+  //   _cacheXAxisData();
+  //   // Build the axis code
+  //   const string axisCode = makeAxisCode(datasetId, xAxisId, yAxisId);
+  //   //const map<string, vector<DPSXPoint> > xpoints = getDPSXValsErrs(papername);
+  //   MSG_TRACE("Using DPS x-positions for " << name() << ":" << axisCode);
+  //   Scatter2DPtr dps = bookScatter2D(axisCode, title, xtitle, ytitle);
+  //   const vector<Point2D> xpts = _dpsData.find(axisCode)->second;
+  //   foreach ( const Point2D & pt, xpts ) {
+  //     // \todo YODA check
+  //     dps->addPoint(pt.x(), pt.xErrMinus(), pt.xErrPlus(), 0, 0, 0);
+  //     // dps->addPoint(xpts[pt].val, xpts[pt].errminus, xpts[pt].errplus, 0, 0, 0);
+  //     // IMeasurement* meas = dps->point(pt)->coordinate(0);
+  //     // meas->setValue(xpts[pt].val);
+  //     // meas->setErrorPlus(xpts[pt].errplus);
+  //     // meas->setErrorMinus(xpts[pt].errminus);
+  //   }
+  //   MSG_TRACE("Made DPS " << axisCode <<  " for " << name());
+  //   return dps;
+  // }
 
 
   void Analysis::normalize(Histo1DPtr histo, double norm) {

Modified: branches/2011-07-aida2yoda/src/Tools/RivetYODA.cc
==============================================================================
--- branches/2011-07-aida2yoda/src/Tools/RivetYODA.cc	Thu Jul 21 20:49:10 2011	(r3234)
+++ branches/2011-07-aida2yoda/src/Tools/RivetYODA.cc	Thu Jul 21 22:17:14 2011	(r3235)
@@ -1,10 +1,6 @@
 #include "Rivet/RivetYODA.hh"
 #include "Rivet/Rivet.hh"
-// #include "Rivet/RivetBoost.hh"
-// #include "Rivet/Tools/Utils.hh"
 #include "Rivet/Tools/RivetPaths.hh"
-// #include <sstream>
-// #include <stdexcept>
 
 using namespace std;
 
@@ -18,222 +14,27 @@
     return "";
   }
 
-
-  map<string, vector<DPSXYPoint> > getDPSXYValsErrs(string papername) {
-    // Get filename
-    const string xmlfile = getDatafilePath(papername);
-    YODA::Reader & reader =  ReaderAIDA::create();
-
-    vector<YODA::AnalysisObject *> aovec;
-    reader.read(xmlfile, aovec);
-    cerr << "HERE1 " << aovec.size() << '\n';
-
-    // MEMLEAK of vector contents
-
-  //   // Open AIDA XML file
-  //   TiXmlDocument doc(xmlfile);
-  //   doc.LoadFile();
-  //   if (doc.Error()) {
-  //     string err = "Error in " + string(doc.Value());
-  //     err += ": " + string(doc.ErrorDesc());
-  //     cerr << err << endl;
-  //     throw Error(err);
-  //   }
-
-    // Return value, to be populated
-    map<string, vector<DPSXYPoint> > rtn;
-  // \todo YODA
-  //   try {
-  //     // Walk down tree to get to the <paper> element
-  //     const TiXmlNode* aidaN = doc.FirstChild("aida");
-  //     if (!aidaN) throw Error("Couldn't get <aida> root element");
-  //     for (const TiXmlNode* dpsN = aidaN->FirstChild("dataPointSet"); dpsN; dpsN = dpsN->NextSibling()) {
-  //       const TiXmlElement* dpsE = dpsN->ToElement();
-  //       const string plotname = dpsE->Attribute("name");
-  //       const string plotpath = dpsE->Attribute("path");
-  //       /// Check path to make sure that this is a reference histogram.
-  //       if (plotpath.find("/REF") != 0) {
-  //         cerr << "Skipping non-reference histogram " << plotname << endl;
-  //         continue;
-  //       }
-
-  //       /// @todo Check that "path" matches filename
-  //       vector<DPSXYPoint> points;
-  //       for (const TiXmlNode* dpN = dpsN->FirstChild("dataPoint"); dpN; dpN = dpN->NextSibling()) {
-  //         const TiXmlNode* xMeasN = dpN->FirstChild("measurement");
-  //         const TiXmlNode* yMeasN = xMeasN->NextSibling();
-  //         if (xMeasN && yMeasN)  {
-  //           const TiXmlElement* xMeasE = xMeasN->ToElement();
-  //           const TiXmlElement* yMeasE = yMeasN->ToElement();
-  //           const string xcentreStr   = xMeasE->Attribute("value");
-  //           const string xerrplusStr  = xMeasE->Attribute("errorPlus");
-  //           const string xerrminusStr = xMeasE->Attribute("errorMinus");
-  //           const string ycentreStr   = yMeasE->Attribute("value");
-  //           const string yerrplusStr  = yMeasE->Attribute("errorPlus");
-  //           const string yerrminusStr = yMeasE->Attribute("errorMinus");
-  //           //if (!centreStr) throw Error("Couldn't get a valid bin centre");
-  //           //if (!errplusStr) throw Error("Couldn't get a valid bin err+");
-  //           //if (!errminusStr) throw Error("Couldn't get a valid bin err-");
-  //           istringstream xssC(xcentreStr);
-  //           istringstream xssP(xerrplusStr);
-  //           istringstream xssM(xerrminusStr);
-  //           istringstream yssC(ycentreStr);
-  //           istringstream yssP(yerrplusStr);
-  //           istringstream yssM(yerrminusStr);
-  //           double xcentre, xerrplus, xerrminus, ycentre, yerrplus, yerrminus;
-  //           xssC >> xcentre; xssP >> xerrplus; xssM >> xerrminus;
-  //           yssC >> ycentre; yssP >> yerrplus; yssM >> yerrminus;
-  //           //cout << "  " << centre << " + " << errplus << " - " << errminus << endl;
-  //           DPSXYPoint pt(xcentre, xerrminus, xerrplus, ycentre, yerrminus, yerrplus);
-  //           points.push_back(pt);
-  //         } else {
-  //           cerr << "Couldn't get <measurement> tag" << endl;
-  //           /// @todo Throw an exception here?
-  //         }
-  //       }
-
-  //       // Add to the map
-  //       rtn[plotname] = points;
-  //     }
-
-  //   }
-  //   // Write out the error
-  //   /// @todo Rethrow as a general XML failure.
-  //   catch (std::exception& e) {
-  //     cerr << e.what() << endl;
-  //     throw;
-  //   }
-
-    // Return
-    return rtn;
-  }
-
-  map<string, vector<DPSXPoint> > getDPSXValsErrs(string papername) {
+  RefDataMap getRefData(string papername) {
     // Get filename
     const string xmlfile = getDatafilePath(papername);
 
     YODA::Reader & reader =  ReaderAIDA::create();
-
     vector<YODA::AnalysisObject *> aovec;
     reader.read(xmlfile, aovec);
     cerr << "HERE2 " << aovec.size() << '\n';
 
-  //   // Open AIDA XML file
-  //   TiXmlDocument doc(xmlfile);
-  //   doc.LoadFile();
-  //   if (doc.Error()) {
-  //     string err = "Error in " + string(doc.Value());
-  //     err += ": " + string(doc.ErrorDesc());
-  //     cerr << err << endl;
-  //     throw Error(err);
-  //   }
-
     // Return value, to be populated
-    map<string, vector<DPSXPoint> > rtn;
-
-  //   try {
-  //     // Walk down tree to get to the <paper> element
-  //     const TiXmlNode* aidaN = doc.FirstChild("aida");
-  //     if (!aidaN) throw Error("Couldn't get <aida> root element");
-  //     for (const TiXmlNode* dpsN = aidaN->FirstChild("dataPointSet"); dpsN; dpsN = dpsN->NextSibling()) {
-  //       const TiXmlElement* dpsE = dpsN->ToElement();
-  //       const string plotname = dpsE->Attribute("name");
-  //       const string plotpath = dpsE->Attribute("path");
-  //       /// Check path to make sure that this is a reference histogram.
-  //       if (plotpath.find("/REF") != 0) {
-  //         cerr << "Skipping non-reference histogram " << plotname << endl;
-  //         continue;
-  //       }
-
-  //       /// @todo Check that "path" matches filename
-  //       vector<DPSXPoint> points;
-  //       for (const TiXmlNode* dpN = dpsN->FirstChild("dataPoint"); dpN; dpN = dpN->NextSibling()) {
-  //         const TiXmlNode* xMeasN = dpN->FirstChild("measurement");
-  //         if (xMeasN) {
-  //           const TiXmlElement* xMeasE = xMeasN->ToElement();
-  //           const string centreStr = xMeasE->Attribute("value");
-  //           const string errplusStr = xMeasE->Attribute("errorPlus");
-  //           const string errminusStr = xMeasE->Attribute("errorMinus");
-  //           //if (!centreStr) throw Error("Couldn't get a valid bin centre");
-  //           //if (!errplusStr) throw Error("Couldn't get a valid bin err+");
-  //           //if (!errminusStr) throw Error("Couldn't get a valid bin err-");
-  //           istringstream ssC(centreStr);
-  //           istringstream ssP(errplusStr);
-  //           istringstream ssM(errminusStr);
-  //           double centre, errplus, errminus;
-  //           ssC >> centre; ssP >> errplus; ssM >> errminus;
-  //           //cout << "  " << centre << " + " << errplus << " - " << errminus << endl;
-  //           DPSXPoint pt(centre, errminus, errplus);
-  //           points.push_back(pt);
-  //         } else {
-  //           cerr << "Couldn't get <measurement> tag" << endl;
-  //           /// @todo Throw an exception here?
-  //         }
-  //       }
-
-  //       // Add to the map
-  //       rtn[plotname] = points;
-  //     }
-
-  //   }
-  //   // Write out the error
-  //   /// @todo Rethrow as a general XML failure.
-  //   catch (std::exception& e) {
-  //     cerr << e.what() << endl;
-  //     throw;
-  //   }
-
-    // Return
-    return rtn;
-  }
-
+    RefDataMap rtn;
 
-
-  map<string, BinEdges> getBinEdges(string papername) {
-    const map<string, vector<DPSXPoint> > xpoints = getDPSXValsErrs(papername);
-    return getBinEdges(xpoints);
-  }
-
-
-
-  map<string, BinEdges> getBinEdges(const map<string, vector<DPSXPoint> >& xpoints) {
-
-    map<string, BinEdges> rtn;
-    for (map<string, vector<DPSXPoint> >::const_iterator dsit = xpoints.begin(); dsit != xpoints.end(); ++dsit) {
-      const string plotname = dsit->first;
-      list<double> edges;
-      foreach (const DPSXPoint& xpt, dsit->second) {
-        const double lowedge = xpt.val - xpt.errminus;
-        const double highedge = xpt.val + xpt.errplus;
-        edges.push_back(lowedge);
-        edges.push_back(highedge);
-      }
-
-      //cout << "*** " << edges << endl;
-
-      // Remove duplicates (the careful testing is why we haven't used a set)
-      //cout << edges.size() << " edges -> " << edges.size()/2 << " bins" << endl;
-      for (list<double>::iterator e = edges.begin(); e != edges.end(); ++e) {
-        list<double>::iterator e2 = e;
-        while (e2 != edges.end()) {
-          if (e != e2) {
-            if (fuzzyEquals(*e, *e2)) {
-              edges.erase(e2++);
-            }
-          }
-          ++e2;
-        }
-      }
-      //cout << edges.size() << " edges after dups removal (should be #bins+1)" << endl;
-      //cout << "@@@ " << edges << endl;
-
-      // Add to the map
-      rtn[plotname] = BinEdges(edges.begin(), edges.end());
+    foreach ( YODA::AnalysisObject * ao, aovec ) {
+      Scatter2DPtr refdata( dynamic_cast<Scatter2D *>(ao) );
+      if ( ! refdata ) 
+	continue;
+      string plotpath = refdata->path();
+      cerr << plotpath << '\n';
+      rtn[plotpath] = refdata;
     }
-
-    // Return
     return rtn;
   }
 
-
 }


More information about the Rivet-svn mailing list