Index: src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
===================================================================
--- src/Actions/FragmentationAction/FragmentationAutomationAction.cpp	(revision 56df379c672f095aa9b6ac364949cfa8c0ba57d5)
+++ src/Actions/FragmentationAction/FragmentationAutomationAction.cpp	(revision 8cae4c222d38d45129885e5a2edc6e31879577de)
@@ -59,4 +59,5 @@
 #include "Jobs/MPQCJob.hpp"
 #include "Jobs/MPQCData.hpp"
+#include "Jobs/MPQCData_printName.hpp"
 #include "molecule.hpp"
 #include "World.hpp"
@@ -65,4 +66,6 @@
 #include <string>
 #include <vector>
+
+#include <boost/mpl/for_each.hpp>
 
 #include "Actions/FragmentationAction/FragmentationAutomationAction.hpp"
@@ -138,4 +141,40 @@
 }
 
+
+template <typename MapType>
+struct printSum {
+  printSum(
+      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)
+  {}
+  template <typename MapKey>
+  void operator()(MapKey &) {
+    Summator<MapType, MapKey> sum_value(
+        subsetmap, data, jobids, container, MatrixNrLookup
+        );
+    double value = sum_value();
+    LOG(0, "STATUS: Resulting " << MPQCDataNames::printName<MapKey>() << " is " << value << ".");
+  }
+
+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;
+};
 
 /** Print MPQCData from received results.
@@ -276,79 +315,92 @@
   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();
-  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 << ".");
-//  }
+  {
+    /// convert all MPQCData to MPQCDataMap_t
+
+    // energy_t
+    std::vector<MPQCDataEnergyMap_t> MPQCData_Energy_fused;
+    MPQCData_Energy_fused.reserve(fragmentData.size());
+    for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
+        dataiter != fragmentData.end(); ++dataiter) {
+      const MPQCData &extractedData = *dataiter;
+      LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
+      MPQCDataEnergyMap_t instance;
+      boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
+      boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
+      boost::fusion::at_key<MPQCDataFused::energy_electron_repulsion>(instance) = extractedData.energies.electron_repulsion;
+      boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
+      boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
+      boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
+      boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
+  //    boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
+      MPQCData_Energy_fused.push_back(instance);
+    }
+
+    // forces
+    std::vector<MPQCDataForceMap_t> MPQCData_Force_fused;
+    MPQCData_Force_fused.reserve(fragmentData.size());
+    for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
+        dataiter != fragmentData.end(); ++dataiter) {
+      const MPQCData &extractedData = *dataiter;
+      LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
+      MPQCDataForceMap_t instance;
+      boost::fusion::at_key<MPQCDataFused::forces>(instance) = extractedData.forces;
+      MPQCData_Force_fused.push_back(instance);
+    }
+
+    // times
+    std::vector<MPQCDataTimeMap_t> MPQCData_Time_fused;
+    MPQCData_Time_fused.reserve(fragmentData.size());
+    for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
+        dataiter != fragmentData.end(); ++dataiter) {
+      const MPQCData &extractedData = *dataiter;
+      LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
+      MPQCDataTimeMap_t instance;
+      boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = extractedData.times.walltime;
+      boost::fusion::at_key<MPQCDataFused::times_cputime>(instance) = extractedData.times.cputime;
+      boost::fusion::at_key<MPQCDataFused::times_flops>(instance) = extractedData.times.flops;
+      MPQCData_Time_fused.push_back(instance);
+    }
+
+    // create a vector of all 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::operator->, _1)));
+
+    // sum up and print energies
+    boost::mpl::for_each<MPQCDataEnergyVector_t>(
+        printSum<MPQCDataEnergyMap_t>(
+            subsetmap,
+            MPQCData_Energy_fused,
+            jobids,
+            container->getContainer(),
+            MatrixNrLookup)
+        );
+    // TODO: Histogram still needs cstor taking just vector<double>
+
+
+    // TODO: We need to put forces into specific class and implement operators
+//    // sum up and print forces
+//    boost::mpl::for_each<MPQCDataForceVector_t>(
+//        printSum<MPQCDataForceMap_t>(
+//            subsetmap,
+//            MPQCData_Force_fused,
+//            jobids,
+//            container->getContainer(),
+//            MatrixNrLookup)
+//        );
+
+    // TODO: Times should just be summed not orthogonalized
+//    // sum up and print times
+//    boost::mpl::for_each<MPQCDataTimeVector_t>(
+//        printSum<MPQCDataTimeMap_t>(
+//            subsetmap,
+//            MPQCData_Time_fused,
+//            jobids,
+//            container->getContainer(),
+//            MatrixNrLookup)
+//        );
+  }
 
   // combine all found data
