[yoda-svn] r453 - in trunk: include/YODA src

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed May 2 13:57:49 BST 2012


Author: hoeth
Date: Wed May  2 13:57:48 2012
New Revision: 453

Log:
ReaderYODA now supports Scatter2D

Modified:
   trunk/include/YODA/ReaderYODA.h
   trunk/src/ReaderYODA.cc

Modified: trunk/include/YODA/ReaderYODA.h
==============================================================================
--- trunk/include/YODA/ReaderYODA.h	Wed May  2 13:36:52 2012	(r452)
+++ trunk/include/YODA/ReaderYODA.h	Wed May  2 13:57:48 2012	(r453)
@@ -10,6 +10,7 @@
 #include "YODA/Reader.h"
 #include <YODA/Histo1D.h>
 #include <YODA/Profile1D.h>
+#include <YODA/Scatter2D.h>
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
@@ -50,6 +51,8 @@
       _profile1d.dbn_uflow.reset();
       _profile1d.dbn_oflow.reset();
 
+      _scatter2d.points.clear();
+
       _annotations.clear();
     }
 
@@ -99,6 +102,17 @@
       profile1ddbn dbn;
     };
 
+    /// Structs for the Scatter2D parser
+    /// The data for ScatterPoint2D
+    struct scatterpoint2d {
+      double x;
+      double exminus;
+      double explus;
+      double y;
+      double eyminus;
+      double eyplus;
+    };
+
     /// Structs for the key-value pair parser (annotations)
     struct keyval {
       std::string key;
@@ -130,6 +144,13 @@
     static profile1d _profile1d;
 
 
+    /// All information for creating a Scatter2D
+    struct scatter2d {
+      std::vector<YODA::Point2D> points;
+    };
+    static scatter2d _scatter2d;
+
+
     /// Functions to call from the parser
     /// Filling the dbn_tot
     struct filltotaldbn {
@@ -177,6 +198,15 @@
     };
 
 
+    /// Filling a point
+    struct fillpoint {
+      void operator()(const scatterpoint2d p, qi::unused_type, qi::unused_type) const {
+        YODA::Point2D point(p.x, p.y, p.exminus, p.explus, p.eyminus, p.eyplus);
+        _scatter2d.points.push_back(point);
+      }
+    };
+
+
     /// Filling the annotations map
     struct fillkeyval {
       void operator()(const keyval m, qi::unused_type, qi::unused_type) const {
@@ -227,6 +257,7 @@
                Histo1Dtotal[filltotaldbn()]    |
                Histo1Duflow[filluflowdbn()]    |
                Histo1Doflow[filloflowdbn()]    |
+               ScatterPoint2D[fillpoint()]     |
                keyvaluepair[fillkeyval()]      |
                comment;
 
@@ -258,6 +289,7 @@
         // Scatter1D
 
         // Scatter2D
+        ScatterPoint2D %= double_ >> double_ >> double_ >> double_ >> double_ >> double_;
 
         // Scatter3D
 
@@ -288,6 +320,8 @@
 
       qi::rule<Iterator, profile1dbin(), Skipper> Profile1Dbin;
       qi::rule<Iterator, profile1ddbn(), Skipper> Profile1Ddbn, Profile1Dtotal, Profile1Duflow, Profile1Doflow;
+
+      qi::rule<Iterator, scatterpoint2d(), Skipper> ScatterPoint2D;
     };
 
   };
@@ -334,6 +368,16 @@
 )
 
 BOOST_FUSION_ADAPT_STRUCT(
+  YODA::ReaderYODA::scatterpoint2d,
+  (double, x)
+  (double, exminus)
+  (double, explus)
+  (double, y)
+  (double, eyminus)
+  (double, eyplus)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
   YODA::ReaderYODA::keyval,
   (std::string, key)
   (std::string, val)

Modified: trunk/src/ReaderYODA.cc
==============================================================================
--- trunk/src/ReaderYODA.cc	Wed May  2 13:36:52 2012	(r452)
+++ trunk/src/ReaderYODA.cc	Wed May  2 13:57:48 2012	(r453)
@@ -16,6 +16,7 @@
   qi::symbols<char, int> ReaderYODA::egroup;
   ReaderYODA::histo1d ReaderYODA::_histo1d;
   ReaderYODA::profile1d ReaderYODA::_profile1d;
+  ReaderYODA::scatter2d ReaderYODA::_scatter2d;
   std::map<std::string, std::string> ReaderYODA::_annotations;
 
 
@@ -108,6 +109,18 @@
             contextchange = false;
           }
           break;
+        case -6: // we left YODA_SCATTER2D
+          if (contextchange) {
+            YODA::Scatter2D* h = new YODA::Scatter2D(_scatter2d.points);
+            std::pair <std::string, std::string> pss;  // to make boost's foreach happy
+            foreach (pss, _annotations) {
+              h->setAnnotation(pss.first, pss.second);
+            }
+            aos.push_back(h);
+            cleanup();
+            contextchange = false;
+          }
+          break;
       }
     }
   }


More information about the yoda-svn mailing list