[Rivet-svn] r2993 - in trunk: . include/Rivet src/Core

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Mar 1 01:37:40 GMT 2011


Author: buckley
Date: Tue Mar  1 01:37:39 2011
New Revision: 2993

Log:
Allow field setting in AnalysisInfo... and move Analysis functions which use it to inline functions in the header. Use AnalysisInfo for storage of the Analysis 'NeedsCrossSection' analysis flag. Bump ABI version numbers for 1.5.0 release.

Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/include/Rivet/Analysis.hh
   trunk/include/Rivet/AnalysisInfo.hh
   trunk/src/Core/Analysis.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Mon Feb 28 23:53:27 2011	(r2992)
+++ trunk/ChangeLog	Tue Mar  1 01:37:39 2011	(r2993)
@@ -1,3 +1,11 @@
+2011-03-01  Andy Buckley  <andy at insectnation.org>
+
+	* Bump ABI version numbers for 1.5.0 release.
+
+	* Use AnalysisInfo for storage of the NeedsCrossSection analysis flag.
+
+	* Allow field setting in AnalysisInfo.
+
 2011-02-27  Hendrik Hoeth <hendrik.hoeth at cern.ch>
 
 	* Support LineStyle=dashdotted in make-plots

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	Mon Feb 28 23:53:27 2011	(r2992)
+++ trunk/configure.ac	Tue Mar  1 01:37:39 2011	(r2993)
@@ -1,7 +1,7 @@
 ## Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT([Rivet],[1.5.0a1],[rivet at projects.hepforge.org],[Rivet])
+AC_INIT([Rivet],[1.5.0a2],[rivet at projects.hepforge.org],[Rivet])
 AC_CONFIG_SRCDIR([src/Core/Analysis.cc])
 AC_CONFIG_HEADERS([include/Rivet/Config/DummyConfig.hh include/Rivet/Config/RivetConfig.hh include/Rivet/Config/BuildOptions.hh])
 AM_INIT_AUTOMAKE(dist-bzip2)
@@ -17,8 +17,8 @@
 AC_DEFINE_UNQUOTED(RIVET_BUGREPORT, "$PACKAGE_BUGREPORT", "Rivet contact email address")
 
 ## Set library version info code
-## Set for version 1.4.0
-VERSIONINFOFLAGS="-version-info 7:0:0"
+## Set for version 1.5.0
+VERSIONINFOFLAGS="-version-info 8:0:0"
 AC_SUBST(VERSIONINFOFLAGS)
 
 ## OS X

Modified: trunk/include/Rivet/Analysis.hh
==============================================================================
--- trunk/include/Rivet/Analysis.hh	Mon Feb 28 23:53:27 2011	(r2992)
+++ trunk/include/Rivet/Analysis.hh	Tue Mar  1 01:37:39 2011	(r2993)
@@ -4,6 +4,7 @@
 
 #include "Rivet/Rivet.hh"
 #include "Rivet/Analysis.fhh"
+#include "Rivet/AnalysisInfo.hh"
 #include "Rivet/Event.hh"
 #include "Rivet/Projection.hh"
 #include "Rivet/ProjectionApplier.hh"
@@ -22,9 +23,6 @@
 
 namespace Rivet {
 
-  // Forward declaration
-  class AnalysisInfo;
-
 
   /// @brief This is the base class of all analysis classes in Rivet.
   ///
@@ -101,30 +99,41 @@
     //@{
 
     /// Get the actual AnalysisInfo object in which all this metadata is stored.
-    virtual const AnalysisInfo& info() const;
+    const AnalysisInfo& info() const {
+      assert(_info.get() != 0 && "No AnalysisInfo object :O");
+      return *_info;
+    }
 
     /// @brief Get the name of the analysis.
     ///
     /// By default this is computed by combining the results of the experiment,
     /// year and Spires ID metadata methods and you should only override it if
     /// there's a good reason why those won't work.
-    virtual std::string name() const;
+    virtual std::string name() const {
+      return (info().name().empty()) ? _defaultname : info().name();
+    }
 
     /// Get a the SPIRES/Inspire ID code for this analysis.
-    virtual std::string spiresId() const;
+    virtual std::string spiresId() const {
+      return (info().spiresId().empty()) ? "NONE" : info().spiresId();
+    }
 
     /// @brief Names & emails of paper/analysis authors.
     ///
     /// Names and email of authors in 'NAME \<EMAIL\>' format. The first
     /// name in the list should be the primary contact person.
-    virtual std::vector<std::string> authors() const;
+    virtual std::vector<std::string> authors() const {
+      return (info().authors().empty()) ? std::vector<std::string>() : info().authors();
+    }
 
     /// @brief Get a short description of the analysis.
     ///
     /// Short (one sentence) description used as an index entry.
     /// Use @a description() to provide full descriptive paragraphs
     /// of analysis details.
-    virtual std::string summary() const;
+    virtual std::string summary() const {
+      return (info().summary().empty()) ? "NONE" : info().summary();
+    }
 
     /// @brief Get a full description of the analysis.
     ///
@@ -132,44 +141,110 @@
     /// what experimental techniques are applied, etc. Should be treated
     /// as a chunk of restructuredText (http://docutils.sourceforge.net/rst.html),
     /// with equations to be rendered as LaTeX with amsmath operators.
-    virtual std::string description() const;
+    virtual std::string description() const {
+      return (info().description().empty()) ? "NONE" : info().description();
+    }
 
     /// @brief Information about the events needed as input for this analysis.
     ///
     /// Event types, energies, kinematic cuts, particles to be considered
     /// stable, etc. etc. Should be treated as a restructuredText bullet list
     /// (http://docutils.sourceforge.net/rst.html)
-    virtual std::string runInfo() const;
+    virtual std::string runInfo() const {
+      return (info().runInfo().empty()) ? "NONE" : info().runInfo();
+    }
 
     /// Experiment which performed and published this analysis.
-    virtual std::string experiment() const;
+    virtual std::string experiment() const {
+      return (info().experiment().empty()) ? "NONE" : info().experiment();
+    }
 
     /// Collider on which the experiment ran.
-    virtual std::string collider() const;
+    virtual std::string collider() const {
+      return (info().collider().empty()) ? "NONE" : info().collider();
+    }
 
     /// When the original experimental analysis was published.
-    virtual std::string year() const;
+    virtual std::string year() const {
+      return (info().year().empty()) ? "NONE" : info().year();
+    }
 
     /// Journal, and preprint references.
-    virtual std::vector<std::string> references() const;
+    virtual std::vector<std::string> references() const {
+      return (info().references().empty()) ? std::vector<std::string>() : info().references();
+    }
 
     /// BibTeX citation key for this article.
-    virtual std::string bibKey() const;
+    virtual std::string bibKey() const {
+      return (info().bibKey().empty()) ? "NONE" : info().bibKey();
+    }
 
     /// BibTeX citation entry for this article.
-    virtual std::string bibTeX() const;
+    virtual std::string bibTeX() const {
+      return (info().bibTeX().empty()) ? "NONE" : info().bibTeX();
+    }
 
     /// Whether this analysis is trusted (in any way!)
-    virtual std::string status() const;
+    virtual std::string status() const {
+      return (info().status().empty()) ? "UNVALIDATED" : info().status();
+    }
 
     /// Any work to be done on this analysis.
-    virtual std::vector<std::string> todos() const;
+    virtual std::vector<std::string> todos() const {
+      return (info().todos().empty()) ? std::vector<std::string>() : info().todos();
+    }
+
+
+    /// Return the allowed pairs of incoming beams required by this analysis.
+    virtual const std::vector<PdgIdPair>& requiredBeams() const {
+      return info().beams();
+    }
+    /// Declare the allowed pairs of incoming beams required by this analysis.
+    virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
+      info().setBeams(requiredBeams);
+      return *this;
+    }
 
-    /// Return the pair of incoming beams required by this analysis.
-    virtual const std::vector<PdgIdPair>& requiredBeams() const;
 
     /// Sets of valid beam energy pairs, in GeV
-    virtual const std::vector<std::pair<double, double> >& requiredEnergies() const;
+    virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
+      return info().energies();
+    }
+    /// Declare the list of valid beam energy pairs, in GeV
+    virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
+      info().setEnergies(requiredEnergies);
+      return *this;
+    }
+
+
+    /// Return true if this analysis needs to know the process cross-section.
+    bool needsCrossSection() const {
+      return info().needsCrossSection();
+    }
+    /// Declare whether this analysis needs to know the process cross-section from the generator.
+    Analysis& setNeedsCrossSection(bool needed=true) {
+      info().setNeedsCrossSection(needed);
+      return *this;
+    }
+
+    //@}
+
+
+    /// @name Internal metadata modifiying methods
+    //@{
+
+    /// Get the actual AnalysisInfo object in which all this metadata is stored (non-const).
+    AnalysisInfo& info() {
+      assert(_info.get() != 0 && "No AnalysisInfo object :O");
+      return *_info;
+    }
+
+    /// Set the required beams
+    /// @deprecated To be removed in 2.0.0. Use .info file and AnalysisInfo class instead
+    virtual Analysis& setBeams(PdgId beam1, PdgId beam2) {
+      /// @todo Print out a warning to use setRequiredBeams() instead (and really to use .info files)
+      return setRequiredBeams(std::vector<PdgIdPair>(1, make_pair(beam1, beam2)));
+    }
 
     //@}
 
@@ -207,7 +282,7 @@
   public:
 
     /// Access the controlling AnalysisHandler object.
-    AnalysisHandler& handler() const;
+    AnalysisHandler& handler() const { return *_analysishandler; }
 
     /// Normalize the given histogram, @a histo. After this call the
     /// histogram will have been transformed to a DataPointSet with the
@@ -244,11 +319,6 @@
     /// Set the cross section from the generator
     Analysis& setCrossSection(double xs);
 
-    /// Return true if this analysis needs to know the process cross-section.
-    bool needsCrossSection() const {
-      return _needsCrossSection;
-    }
-
 
   protected:
 
@@ -459,19 +529,6 @@
 
   protected:
 
-    /// Set the colliding beam pair.
-    /// @deprecated Use .info file and AnalysisInfo class instead
-    Analysis& setBeams(PdgId beam1, PdgId beam2);
-
-    /// Declare whether this analysis needs to know the process cross-section from the generator.
-    Analysis& setNeedsCrossSection(bool needed=true) {
-      _needsCrossSection = needed;
-      return *this;
-    }
-
-
-  protected:
-
     /// Name passed to constructor (used to find .info analysis data file, and as a fallback)
     string _defaultname;
 
@@ -485,7 +542,6 @@
     //@{
     double _crossSection;
     bool _gotCrossSection;
-    bool _needsCrossSection;
     //@}
 
     /// The controlling AnalysisHandler object.

Modified: trunk/include/Rivet/AnalysisInfo.hh
==============================================================================
--- trunk/include/Rivet/AnalysisInfo.hh	Mon Feb 28 23:53:27 2011	(r2992)
+++ trunk/include/Rivet/AnalysisInfo.hh	Tue Mar  1 01:37:39 2011	(r2993)
@@ -36,6 +36,7 @@
     /// Metadata is used for querying from the command line and also for
     /// building web pages and the analysis pages in the Rivet manual.
     //@{
+
     /// Get the name of the analysis. By default this is computed by
     /// combining the results of the experiment, year and Spires ID
     /// metadata methods and you should only override it if there's a
@@ -48,20 +49,36 @@
       return "";
     }
 
-    /// Get a description of the analysis.
+    /// Set the name of the analysis.
+    void setName(const std::string& name) { _name = name; }
+
+
+    /// Get the SPIRES ID code for this analysis.
     const std::string& spiresId() const { return _spiresId; }
 
+    /// Set the SPIRES ID code for this analysis.
+    void setSpiresId(const std::string& spiresId) { _spiresId = spiresId; }
+
+
     /// @brief Names & emails of paper/analysis authors.
     /// Names and email of authors in 'NAME \<EMAIL\>' format. The first
     /// name in the list should be the primary contact person.
     const std::vector<std::string>& authors() const { return _authors; }
 
+    /// Set the author list.
+    void setAuthors(const std::vector<std::string>& authors) { _authors = authors; }
+
+
     /// @brief Get a short description of the analysis.
     /// Short (one sentence) description used as an index entry.
     /// Use @a description() to provide full descriptive paragraphs
     /// of analysis details.
     const std::string& summary() const { return _summary; }
 
+    /// Set the short description for this analysis.
+    void setSummary(const std::string& summary) { _summary = summary; }
+
+
     /// @brief Get a full description of the analysis.
     /// Full textual description of this analysis, what it is useful for,
     /// what experimental techniques are applied, etc. Should be treated
@@ -69,51 +86,100 @@
     /// with equations to be rendered as LaTeX with amsmath operators.
     const std::string& description() const { return _description; }
 
+    /// Set the full description for this analysis.
+    void setDescription(const std::string& description) { _description = description; }
+
+
     /// @brief Information about the events needed as input for this analysis.
     /// Event types, energies, kinematic cuts, particles to be considered
     /// stable, etc. etc. Should be treated as a restructuredText bullet list
     /// (http://docutils.sourceforge.net/rst.html)
     const std::string& runInfo() const { return _runInfo; }
 
+    /// Set the full description for this analysis.
+    void setRunInfo(const std::string& runInfo) { _runInfo = runInfo; }
+
+
     /// Beam particle types
-    const std::vector<std::pair<PdgId,PdgId> >& beams() const { return _beams; }
+    const std::vector<PdgIdPair>& beams() const { return _beams; }
+
+    /// Set beam particle types
+    void setBeams(const std::vector<PdgIdPair>& beams) { _beams = beams; }
+
 
-    /// Sets of valid beam energy pairs
+    /// Sets of valid beam energies
     const std::vector<std::pair<double,double> >& energies() const { return _energies; }
 
+    /// Set the valid beam energies
+    void setEnergies(const std::vector<std::pair<double, double> >& energies) { _energies = energies; }
+
+
     /// Experiment which performed and published this analysis.
     const std::string& experiment() const { return _experiment; }
 
+    /// Set the experiment which performed and published this analysis.
+    void setExperiment(const std::string& experiment) { _experiment = experiment; }
+
+
     /// Collider on which the experiment ran.
     const std::string& collider() const { return _collider; }
 
+    /// Set the collider on which the experiment ran.
+    void setCollider(const std::string& collider) { _collider = collider; }
+
+
     /// @brief When the original experimental analysis was published.
     /// When the refereed paper on which this is based was published,
     /// according to SPIRES.
     const std::string& year() const { return _year; }
 
-    /// Journal, and preprint references.
+    /// Set the year in which the original experimental analysis was published.
+    void setYear(const std::string& year) { _year = year; }
+
+
+    /// Journal and preprint references.
     const std::vector<std::string>& references() const { return _references; }
 
+    /// Set the journal and preprint reference list.
+    void setReferences(const std::vector<std::string>& references) { _references = references; }
+
+
     /// BibTeX citation key for this article.
     const std::string& bibKey() const { return _bibKey;}
 
+    /// Set the BibTeX citation key for this article.
+    void setBibKey(const std::string& bibKey) { _bibKey = bibKey; }
+
+
     /// BibTeX citation entry for this article.
-    const std::string& bibTeX() const {
-      //return "@Article{" + bibKey() + ",\n" + _bibTeXBody + "\n}";
-      return _bibTeX;
-    }
+    const std::string& bibTeX() const { return _bibTeX; }
+
+    /// Set the BibTeX citation entry for this article.
+    void setBibTeX(const std::string& bibTeX) { _bibTeX = bibTeX; }
+
 
     /// Whether this analysis is trusted (in any way!)
     const std::string& status() const { return _status; }
 
+    /// Set the analysis code status.
+    void setStatus(const std::string& status) { _status = status; }
+
+
     /// Any work to be done on this analysis.
     const std::vector<std::string>& todos() const { return _todos; }
-    //@}
+
+    /// Set the to-do list.
+    void setTodos(const std::vector<std::string>& todos) { _todos = todos; }
+
 
     /// Return true if this analysis needs to know the process cross-section.
     bool needsCrossSection() const { return _needsCrossSection; }
 
+    /// Return true if this analysis needs to know the process cross-section.
+    void setNeedsCrossSection(bool needXsec) { _needsCrossSection = needXsec; }
+
+    //@}
+
 
   private:
 

Modified: trunk/src/Core/Analysis.cc
==============================================================================
--- trunk/src/Core/Analysis.cc	Mon Feb 28 23:53:27 2011	(r2992)
+++ trunk/src/Core/Analysis.cc	Tue Mar  1 01:37:39 2011	(r2993)
@@ -34,7 +34,6 @@
   Analysis::Analysis(const string& name)
     : _crossSection(-1.0),
       _gotCrossSection(false),
-      _needsCrossSection(false),
       _analysishandler(NULL),
       _madeHistoDir(false)
   {
@@ -116,101 +115,7 @@
   }
 
 
-  ////////////////////////////////////////////////////////////
-  // Metadata
-
-  const AnalysisInfo& Analysis::info() const {
-    assert(_info.get() != 0);
-    return *_info;
-  }
-
-  string Analysis::name() const {
-    if (_info && !_info->name().empty()) return _info->name();
-    return _defaultname;
-  }
-
-  string Analysis::spiresId() const {
-    if (!_info) return "NONE";
-    return _info->spiresId();
-  }
-
-  vector<string> Analysis::authors() const {
-    if (!_info) return std::vector<std::string>();
-    return _info->authors();
-  }
-
-  string Analysis::summary() const {
-    if (!_info) return "NONE";
-    return _info->summary();
-  }
-
-  string Analysis::description() const {
-    if (!_info) return "NONE";
-    return _info->description();
-  }
-
-  string Analysis::runInfo() const {
-    if (!_info) return "NONE";
-    return _info->runInfo();
-  }
-
-  string Analysis::experiment() const {
-    if (!_info) return "NONE";
-    return _info->experiment();
-  }
-
-  string Analysis::collider() const {
-    if (!_info) return "NONE";
-    return _info->collider();
-  }
-
-  string Analysis::year() const {
-    if (!_info) return "NONE";
-    return _info->year();
-  }
-
-  vector<string> Analysis::references() const {
-    if (!_info) return vector<string>();
-    return _info->references();
-  }
-
-  string Analysis::bibKey() const {
-    if (!_info) return "";
-    return _info->bibKey();
-  }
-
-  string Analysis::bibTeX() const {
-    if (!_info) return "";
-    return _info->bibTeX();
-  }
-
-  string Analysis::status() const {
-    if (!_info) return "UNVALIDATED";
-    return _info->status();
-  }
-
-  vector<string> Analysis::todos() const {
-    if (!_info) return vector<string>();
-    return _info->todos();
-  }
-
-  const vector<PdgIdPair>& Analysis::requiredBeams() const {
-    return info().beams();
-  }
-
-  const std::vector<std::pair<double,double> >& Analysis::requiredEnergies() const {
-    return info().energies();
-  }
-
-
-  /// @todo Deprecate?
-  Analysis& Analysis::setBeams(PdgId beam1, PdgId beam2) {
-    /// @todo Print out a warning when beams def are used from info files and AI fields can be publicly set
-    assert(_info.get() != 0);
-    _info->_beams.clear();
-    _info->_beams += make_pair(beam1, beam2);
-    return *this;
-  }
+  ///////////////////////////////////////////
 
 
   bool Analysis::isCompatible(const ParticlePair& beams) const {
@@ -254,6 +159,9 @@
   }
 
 
+  ///////////////////////////////////////////
+
+
   Analysis& Analysis::setCrossSection(double xs) {
     _crossSection = xs;
     _gotCrossSection = true;
@@ -275,11 +183,6 @@
   }
 
 
-  AnalysisHandler& Analysis::handler() const {
-    return *_analysishandler;
-  }
-
-
 
   ////////////////////////////////////////////////////////////
   // Histogramming


More information about the Rivet-svn mailing list