[Rivet-svn] r2496 - in trunk: . bin include/Rivet pyext src/Core

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Jun 21 20:53:37 BST 2010


Author: buckley
Date: Mon Jun 21 20:53:46 2010
New Revision: 2496

Log:
Fixing a couple of references to temporary variables by correcting the API to return the intended references (and simplifying along the way). This allows the beam info metadata to be used, which is initially demonstrated by the command line info printout.

Modified:
   trunk/ChangeLog
   trunk/bin/rivet
   trunk/include/Rivet/Analysis.hh
   trunk/pyext/rivet.i
   trunk/src/Core/Analysis.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Mon Jun 21 19:12:46 2010	(r2495)
+++ trunk/ChangeLog	Mon Jun 21 20:53:46 2010	(r2496)
@@ -1,5 +1,12 @@
 2010-06-21  Andy Buckley  <andy at insectnation.org>
 
+	* Using .info file beam ID and energy info in command-line printout.
+
+	* Fixing a couple of references to temporary variables in the
+	analysis beam info, which had been introduced during refactoring:
+	have reinstated reference-type returns as the more efficient
+	solution. This should not affect API compatibility.
+
 	* Making SWIG configure-time check include testing for
 	incompatibilities with the C++ compiler (re. the recurring _const_
 	char* literals issue).

Modified: trunk/bin/rivet
==============================================================================
--- trunk/bin/rivet	Mon Jun 21 19:12:46 2010	(r2495)
+++ trunk/bin/rivet	Mon Jun 21 20:53:46 2010	(r2496)
@@ -270,7 +270,7 @@
             msg = aname
             if opts.LOGLEVEL == logging.DEBUG:
                 a = rivet.AnalysisLoader.getAnalysis(aname)
-                msg = "%-25s %s" % (aname, "  " + a.summary())
+                msg = "%-25s   %s" % (aname, a.summary())
             print msg
     sys.exit(0)
 
@@ -315,6 +315,11 @@
         twrap = textwrap.TextWrapper(width=75, initial_indent=2*" ", subsequent_indent=2*" ")
         print twrap.fill(ana.description())
         print ""
+        print "Beams:", "; ".join(ana.requiredBeamsNames())
+        if ana.energies():
+            print "Beam energies:", "; ".join(["(%0.1f, %0.1f)" % (epair[0], epair[1]) for epair in ana.energies()]), "GeV"
+        else:
+            print "Beam energies: ANY"
         print "Run details:"
         twrap = textwrap.TextWrapper(width=75, initial_indent=2*" ", subsequent_indent=4*" ")
         for l in ana.runInfo().split("\n"):

Modified: trunk/include/Rivet/Analysis.hh
==============================================================================
--- trunk/include/Rivet/Analysis.hh	Mon Jun 21 19:12:46 2010	(r2495)
+++ trunk/include/Rivet/Analysis.hh	Mon Jun 21 20:53:46 2010	(r2496)
@@ -148,7 +148,7 @@
     virtual std::string collider() const;
 
     /// Return the pair of incoming beams required by this analysis.
-    virtual const std::vector<PdgIdPair> requiredBeams() const;
+    virtual const std::vector<PdgIdPair>& requiredBeams() const;
 
     /// Sets of valid beam energy pairs, in GeV
     virtual const std::vector<std::pair<double, double> >& energies() const;

Modified: trunk/pyext/rivet.i
==============================================================================
--- trunk/pyext/rivet.i	Mon Jun 21 19:12:46 2010	(r2495)
+++ trunk/pyext/rivet.i	Mon Jun 21 20:53:46 2010	(r2496)
@@ -5,6 +5,7 @@
   #include "Rivet/Analysis.hh"
   #include "Rivet/AnalysisHandler.hh"
   #include "Rivet/AnalysisLoader.hh"
+  #include "Rivet/AnalysisInfo.hh"
   #include "Rivet/Run.hh"
   #include "Rivet/Tools/Logging.hh"
   #include "Rivet/Event.hh"
@@ -72,6 +73,10 @@
 
   double sqrtS(const Event& e);
 
+  // std::string toBeamsString(const PdgIdPair& pair);
+  const std::string& toParticleName(PdgId p);
+  PdgId toParticleId(const std::string& pname);
+
 
   // Mapping of just the metadata parts of the Analysis API
   class Analysis {
@@ -100,6 +105,17 @@
     Analysis();
   };
 
+  %extend Analysis {
+    std::vector<std::string> requiredBeamsNames() {
+      std::vector<std::string> rtn;
+      foreach (const Rivet::PdgIdPair& bp, $self->info().beams()) {
+        std::string bps = Rivet::toBeamsString(bp);
+        rtn.push_back(bps);
+      }
+      return rtn;
+    }
+  }
+
 
   class AnalysisHandler {
   public:
@@ -112,7 +128,7 @@
     double sumOfWeights() const;
     double sqrtS() const;
     const ParticlePair& beams() const;
-    const PdgIdPair& beamIds() const;
+    const PdgIdPair beamIds() const;
     std::vector<std::string> analysisNames();
     AnalysisHandler& addAnalysis(const std::string& analysisname);
     AnalysisHandler& addAnalyses(const std::vector<std::string>& analysisnames);

Modified: trunk/src/Core/Analysis.cc
==============================================================================
--- trunk/src/Core/Analysis.cc	Mon Jun 21 19:12:46 2010	(r2495)
+++ trunk/src/Core/Analysis.cc	Mon Jun 21 20:53:46 2010	(r2496)
@@ -202,12 +202,8 @@
     return _info->todos();
   }
 
-  const vector<PdgIdPair> Analysis::requiredBeams() const {
-    vector<PdgIdPair> reqbeams;
-    foreach (const PdgIdPair& bp, info().beams()) {
-      reqbeams += bp;
-    }
-    return reqbeams;
+  const vector<PdgIdPair>& Analysis::requiredBeams() const {
+    return info().beams();
   }
 
 


More information about the Rivet-svn mailing list