[Rivet-svn] rivet: updates from Holger from alpha3.0 branch

Rivet Mercurial rivet at projects.hepforge.org
Thu Oct 6 15:45:02 BST 2016


details:   https://rivet.hepforge.org/hg/rivet/rev/03db49ffb20c
branches:  multiweight
changeset: 5554:03db49ffb20c
user:      Chris Pollard <cspollard at gmail.com>
date:      Thu Oct 06 15:40:36 2016 +0100
description:
updates from Holger from alpha3.0 branch

diffs (truncated from 119 to 50 lines):

--- a/src/Core/AnalysisHandler.cc	Tue Oct 04 12:22:43 2016 +0100
+++ b/src/Core/AnalysisHandler.cc	Thu Oct 06 15:40:36 2016 +0100
@@ -7,6 +7,18 @@
 #include "Rivet/Tools/Logging.hh"
 #include "Rivet/Projections/Beam.hh"
 #include "YODA/WriterYODA.h"
+#include <regex>
+
+namespace {
+    inline std::vector<std::string> split(const std::string& input, const std::string& regex) {
+        // passing -1 as the submatch index parameter performs splitting
+        std::regex re(regex);
+        std::sregex_token_iterator
+            first{input.begin(), input.end(), re, -1},
+            last;
+        return {first, last};
+    }
+};
 
 
 namespace Rivet {
@@ -28,6 +40,28 @@
   }
 
 
+  /// http://stackoverflow.com/questions/4654636/how-to-determine-if-a-string-is-a-number-with-c
+  bool is_number(const std::string& s)
+  {
+    std::string::const_iterator it = s.begin();
+    while (it != s.end() && std::isdigit(*it)) ++it;
+    return !s.empty() && it == s.end();
+  }
+ 
+  /// Check if any of the weightnames is not a number 
+  bool AnalysisHandler::haveNamedWeights() {
+    bool dec=false;
+    for (unsigned int i=0;i<_weightNames.size();++i) {
+      string s = _weightNames[i];
+      if (!is_number(s)) {
+        dec=true;
+        break;
+      }
+    }
+    return dec;
+  }
+
+
   void AnalysisHandler::init(const GenEvent& ge) {
     if (_initialised)
       throw UserError("AnalysisHandler::init has already been called: cannot re-initialize!");


More information about the Rivet-svn mailing list