Index: src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
===================================================================
--- src/Actions/FragmentationAction/FragmentationAutomationAction.cpp	(revision 965e2fdeb4a01f3b569d70307746f102a48494ab)
+++ src/Actions/FragmentationAction/FragmentationAutomationAction.cpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
@@ -55,6 +55,5 @@
 #include "Fragmentation/KeySet.hpp"
 #include "Fragmentation/KeySetsContainer.hpp"
-#include "Fragmentation/Summation/OrthogonalSummation.hpp"
-#include "Fragmentation/Summation/SetValue.hpp"
+#include "Fragmentation/Summation/Summator.hpp"
 #include "Graph/DepthFirstSearchAnalysis.hpp"
 #include "Jobs/MPQCJob.hpp"
@@ -277,36 +276,79 @@
   SubsetMap::ptr subsetmap(new SubsetMap(*container));
 
+  // convert all MPQCData to MPQCDataMap_t
+  std::vector<MPQCDataMap_t> MPQCData_fused;
+  MPQCData_fused.reserve(fragmentData.size());
+  for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
+      dataiter != fragmentData.end(); ++dataiter) {
+    MPQCDataMap_t instance;
+    boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = dataiter->energies.total;
+//    boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = dataiter->energies.eigenvalues;
+//    boost::fusion::at_key<MPQCDataFused::forces>(instance) = dataiter->forces;
+//    boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = dataiter->times.walltime;
+  }
+
+  // get a vector of a job ids
+  std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
+//  std::transform(results.begin(), results.end(), jobids.begin(),
+//      boost::bind(&FragmentResult::getId,
+//          boost::bind(&FragmentResult::ptr::, _1)));
+  std::vector<JobId_t>::iterator iditer = jobids.begin();
+  for (std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
+      resultiter != results.end(); ++resultiter) {
+    *iditer = (*resultiter)->getId();
+    ++iditer;
+  }
+
   // associate each index set with its value (do not use the full set, that is also contained!)
   const IndexSetContainer::Container_t &_container = container->getContainer();
-  {
-    OrthogonalSummation<double>::InputSets_t indices(_container.begin(), _container.end()-1);
-    OrthogonalSummation<double>::InputValues_t values(_container.size()-1, 0.);
-    std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
-    std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
-    for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
-      const MPQCData &extractedData = *dataiter;
-      values[ MatrixNrLookup[(*resultiter)->getId()] ] = extractedData.energies.total;
-    }
-
-    // create the summation functor and evaluate
-    OrthogonalSummation<double> OS(indices, values, subsetmap);
-    const double energyresult = OS();
-    LOG(0, "STATUS: Resulting energy is " << energyresult << ".");
-  }
-  {
-    OrthogonalSummation<Histogram>::InputSets_t indices(_container.begin(), _container.end()-1);
-    OrthogonalSummation<Histogram>::InputValues_t values(_container.size()-1);
-    std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
-    std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
-    for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
-      const MPQCData &extractedData = *dataiter;
-      values[ MatrixNrLookup[(*resultiter)->getId()] ] = Histogram(extractedData.energies.eigenvalues, 0., 0.1);
-    }
-
-    // create the summation functor and evaluate
-    OrthogonalSummation<Histogram> OS(indices, values, subsetmap);
-    const Histogram eigenvaluegram = OS();
-    LOG(0, "STATUS: Resulting histogram is " << eigenvaluegram << ".");
-  }
+  Summator<MPQCDataMap_t, MPQCDataFused::energy_total> sum_energy_total(
+      subsetmap,
+      MPQCData_fused,
+      jobids,
+      _container,
+      MatrixNrLookup
+      );
+  double energy_total = sum_energy_total();
+  LOG(0, "STATUS: Resulting total energy is " << energy_total << ".");
+
+  //  Summator<MPQCDataMap_t, MPQCDataFused::energy_eigenvalues> sum_energy_eigenvalues(
+//      subsetmap,
+//      MPQCData_fused,
+//      jobids,
+//      _container,
+//      MatrixNrLookup
+//      );
+
+  // associate each index set with its value (do not use the full set, that is also contained!)
+//  {
+//    OrthogonalSummation<double>::InputSets_t indices(_container.begin(), _container.end()-1);
+//    OrthogonalSummation<double>::InputValues_t values(_container.size()-1, 0.);
+//    std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
+//    std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
+//    for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
+//      const MPQCData &extractedData = *dataiter;
+//      values[ MatrixNrLookup[(*resultiter)->getId()] ] = extractedData.energies.total;
+//    }
+//
+//    // create the summation functor and evaluate
+//    OrthogonalSummation<double> OS(indices, values, subsetmap);
+//    const double energyresult = OS();
+//    LOG(0, "STATUS: Resulting energy is " << energyresult << ".");
+//  }
+//  {
+//    OrthogonalSummation<Histogram>::InputSets_t indices(_container.begin(), _container.end()-1);
+//    OrthogonalSummation<Histogram>::InputValues_t values(_container.size()-1);
+//    std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
+//    std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
+//    for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
+//      const MPQCData &extractedData = *dataiter;
+//      values[ MatrixNrLookup[(*resultiter)->getId()] ] = Histogram(extractedData.energies.eigenvalues, 0., 0.1);
+//    }
+//
+//    // create the summation functor and evaluate
+//    OrthogonalSummation<Histogram> OS(indices, values, subsetmap);
+//    const Histogram eigenvaluegram = OS();
+//    LOG(0, "STATUS: Resulting histogram is " << eigenvaluegram << ".");
+//  }
 
   // combine all found data
Index: src/Fragmentation/Summation/Makefile.am
===================================================================
--- src/Fragmentation/Summation/Makefile.am	(revision 965e2fdeb4a01f3b569d70307746f102a48494ab)
+++ src/Fragmentation/Summation/Makefile.am	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
@@ -14,5 +14,6 @@
 	Fragmentation/Summation/SetValueMap.hpp \
 	Fragmentation/Summation/SortedVector.hpp \
-	Fragmentation/Summation/SubsetMap.hpp
+	Fragmentation/Summation/SubsetMap.hpp \
+	Fragmentation/Summation/Summator.hpp
 
 
Index: src/Fragmentation/Summation/Summator.hpp
===================================================================
--- src/Fragmentation/Summation/Summator.hpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
+++ src/Fragmentation/Summation/Summator.hpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
@@ -0,0 +1,131 @@
+/*
+ * Summator.hpp
+ *
+ *  Created on: 28.07.2012
+ *      Author: heber
+ */
+
+#ifndef SUMMATOR_HPP_
+#define SUMMATOR_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/fusion/sequence.hpp>
+
+#include "Fragmentation/Summation/OrthogonalSummation.hpp"
+#include "Fragmentation/Summation/SetValue.hpp"
+#include "Jobs/MPQCDataMap.hpp"
+
+/** Summator is a general class for making us of OrthogonalSummation.
+ *
+ * The idea is that we want to sum up not only one value but a whole bunch of.
+ * However, in general the types of the values will all differ. We would like
+ * to call the summation in a as simple a fashion as possible and at best in
+ * a kind of for_each on each type/value.
+ * For this purpose we require a list of all the types, represented  by the
+ * MPQCDataMap_t map that uses the types enumerated in namespace MPQCDataFused,
+ * see the simple example for the associative sequence in boost::fusion.
+ * The MPQCDataMap_t then gives the essential mapping from the type to a specific
+ * key. Via this key, which is a type and hence can be used for template
+ * specification, we may gather all information for launching the
+ * OrthogonalSummation. We only need to convert MPQCData into the above
+ * MPQCDataMap_t instance and may then access the member variables via the above
+ * key and also obtain the type at \b run-time through the key.
+ *
+ * Note that we then need a conversion from the type stored in the MPQCData,
+ * e.g. a vector<double>, to the type in MPQCDataMap_t, e.g. Histogram.
+ *
+ * Boost::fusion is very cool! If we have a namespace with just structs as keys
+ * and the fusion::map from these keys to the true types, then we may do ...
+ * \code
+ *   MPQCDataMap_t MPQCDataMap;
+ *   using namespace MPQCDataFused;
+ *   double MPQCData_energy_total = boost::fusion::at_key<MPQCDataFused::energy_total>(MPQCDataMap);
+ * \endcode
+ * i.e. at_key knows the correct type!
+ *
+ */
+template <typename MapType, typename MapKey>
+struct Summator {
+  /** We retrieve the type of the MPQCData member variable from the
+   * boost::fusion::map and stored it in this typedef. Note that for
+   * internal types (e.g. MapValue::const_iterator we need to place
+   * \b typename before).
+   */
+  typedef typename boost::fusion::result_of::value_at_key<MapType, MapKey>::type MapValue;
+
+  /** Constructor for class Summator.
+   *
+   * \param _subsetmap map with hierarchy of IndexSet's
+   * \param _data MPQCData converted to MPQCDataMap_t type
+   * \param _jobids job ids to sum data in correct order
+   * \param _container container of IndexSet's such that each set has correct order
+   *        to job id and hence to _data.
+   * \param _MatrixNrLookup lookup from job id to ordering in above vectors
+   */
+  Summator(
+      SubsetMap::ptr &_subsetmap,
+      const std::vector<MapType> &_data,
+      const std::vector<JobId_t> &_jobids,
+      const IndexSetContainer::Container_t &_container,
+      std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */
+    subsetmap(_subsetmap),
+    data(_data),
+    jobids(_jobids),
+    container(_container),
+    MatrixNrLookup(_MatrixNrLookup)
+  {
+    ASSERT( data.size() == jobids.size(),
+        "Summator() - data and ids don't have same size.");
+    ASSERT( jobids.size() == MatrixNrLookup.size(),
+        "Summator() - ids and MatrixNrLookup don't have same size.");
+  }
+
+  /** Summation operator.
+   *
+   * Initialises instantiated OrthogonalSummation of the respective type via
+   * \a Summator::data, uses OrthogonalSummation::operator() to sum and returns
+   * the result.
+   *
+   * \return result of OrthogonalSummation for given type from MPQCDataMap_t.
+   */
+  MapValue operator()()
+  {
+    // if we just have one indexset, we don't need to get rid of the "union index set"
+    typename OrthogonalSummation<MapValue>::InputSets_t indices(
+        container.begin(),
+        container.end()-1 == container.begin() ? container.end() : container.end()-1);
+    typename OrthogonalSummation<MapValue>::InputValues_t values(
+        container.size() == 1 ? (size_t)1 : container.size()-1);
+    typename std::vector<MapType>::const_iterator dataiter = data.begin();
+    std::vector<size_t>::const_iterator iditer = jobids.begin();
+    for (; dataiter != data.end(); ++dataiter, ++iditer) {
+      const MapType &Data = *dataiter;
+      const MapValue &value = boost::fusion::at_key<MapKey>(Data);
+      values[ MatrixNrLookup[*iditer] ] = value;
+    }
+
+    // create the summation functor and evaluate
+    OrthogonalSummation<MapValue> OS(indices, values, subsetmap);
+    const MapValue result = OS();
+    return result;
+  }
+
+private:
+  //!> Hierarchy of IndexSet's
+  SubsetMap::ptr &subsetmap;
+  //!> vector of data converted from MPQCData
+  const std::vector<MapType> &data;
+  //!> vector of jobids
+  const std::vector<JobId_t> &jobids;
+  //!> container with all IndexSet's
+  const IndexSetContainer::Container_t &container;
+  //!> lookup map from job ids to ordering in above vectors
+  std::map< JobId_t, size_t > MatrixNrLookup;
+};
+
+
+#endif /* SUMMATOR_HPP_ */
Index: src/Jobs/MPQCDataFused.hpp
===================================================================
--- src/Jobs/MPQCDataFused.hpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
+++ src/Jobs/MPQCDataFused.hpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
@@ -0,0 +1,30 @@
+/*
+ * MPQCDataFused.hpp
+ *
+ *  Created on: 28.07.2012
+ *      Author: heber
+ */
+
+#ifndef MPQCDATAFUSED_HPP_
+#define MPQCDATAFUSED_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/** This namespace contains a key for each data member in MPQCData.
+ *
+ * We need these keys as enumeration of the data members to allow
+ * generic algorithms to work on it.
+ *
+ *
+ */
+namespace MPQCDataFused {
+  struct energy_total;
+  struct energy_eigenvalues;
+  struct forces;
+  struct times_walltime;
+}
+
+#endif /* MPQCDATAFUSED_HPP_ */
Index: src/Jobs/MPQCDataMap.hpp
===================================================================
--- src/Jobs/MPQCDataMap.hpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
+++ src/Jobs/MPQCDataMap.hpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
@@ -0,0 +1,34 @@
+/*
+ * MPQCDataMap.hpp
+ *
+ *  Created on: 28.07.2012
+ *      Author: heber
+ */
+
+#ifndef MPQCDATAMAP_HPP_
+#define MPQCDATAMAP_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/fusion/container/map.hpp>
+
+#include "Jobs/MPQCDataFused.hpp"
+
+/** This boost::fusion map defines key-value or rather key-type pairs with
+ * which we associate data members in MPQCData and their type.
+ *
+ * This lets us resolves any ambiguitites of types in MPQCData, e.g.
+ * to know vector<double> is forces or energy_eigenvalues.
+ *
+ */
+typedef boost::fusion::map<
+    boost::fusion::pair<MPQCDataFused::energy_total, double>
+  ,  boost::fusion::pair<MPQCDataFused::energy_eigenvalues, Histogram >
+  ,  boost::fusion::pair<MPQCDataFused::forces, std::vector< std::vector<double> > >
+  ,  boost::fusion::pair<MPQCDataFused::times_walltime, double> >
+MPQCDataMap_t;
+
+#endif /* MPQCDATAMAP_HPP_ */
Index: src/Jobs/Makefile.am
===================================================================
--- src/Jobs/Makefile.am	(revision 965e2fdeb4a01f3b569d70307746f102a48494ab)
+++ src/Jobs/Makefile.am	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
@@ -10,5 +10,7 @@
         Jobs/MPQCCommandJob.hpp \
         Jobs/MPQCData.hpp \
-        Jobs/MPQCJob.hpp
+        Jobs/MPQCDataFused.hpp \
+        Jobs/MPQCDataMap.hpp \
+        Jobs/MPQCJob.hpp 
 
 lib_LTLIBRARIES += libMolecuilderJobs.la
