Index: src/Fragmentation/Summation/Makefile.am
===================================================================
--- src/Fragmentation/Summation/Makefile.am	(revision 0a387eb05bb064023a609198c7502635736f7fc8)
+++ src/Fragmentation/Summation/Makefile.am	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -17,4 +17,6 @@
 	IndexSet.hpp \
 	IndexSetContainer.hpp \
+	OrthogonalSummation.hpp \
+	OrthogonalSummation_impl.hpp \
 	SetValue.hpp \
 	SetValueMap.hpp \
Index: src/Fragmentation/Summation/OrthogonalSummation.hpp
===================================================================
--- src/Fragmentation/Summation/OrthogonalSummation.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
+++ src/Fragmentation/Summation/OrthogonalSummation.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -0,0 +1,52 @@
+/*
+ * OrthogonalSummation.hpp
+ *
+ *  Created on: Jun 25, 2012
+ *      Author: heber
+ */
+
+#ifndef ORTHOGONALSUMMATION_HPP_
+#define ORTHOGONALSUMMATION_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <map>
+
+#include "SetValue.hpp"
+#include "SubsetMap.hpp"
+#include "SetValueMap.hpp"
+
+/** OrthogonalSummation is a functor executing an orthogonal summation of SetValue's
+ * that are each associated to a certain IndexSet whose union is a SetOfIndexSets.
+ */
+template <class T>
+class OrthogonalSummation
+{
+public:
+  typedef std::vector< IndexSet::ptr > InputSets_t;
+  typedef std::vector< T > InputValues_t;
+  OrthogonalSummation(InputSets_t &indices, InputValues_t& values, SubsetMap::ptr _subsetmap = SubsetMap::ptr());
+
+  /** Performs the orthogonal summation and returns result.
+   *
+   * @return resulting value
+   */
+  T operator()() const;
+
+private:
+  T Sum() const;
+
+private:
+  //!> SubsetTree with the tree-like structure of subsets
+  SubsetMap::ptr subsetmap;
+  //!> set of all subset values
+  SetValueMap<T> setvalues;
+};
+
+#include "OrthogonalSummation_impl.hpp"
+
+#endif /* ORTHOGONALSUMMATION_HPP_ */
Index: src/Fragmentation/Summation/OrthogonalSummation_impl.hpp
===================================================================
--- src/Fragmentation/Summation/OrthogonalSummation_impl.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
+++ src/Fragmentation/Summation/OrthogonalSummation_impl.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -0,0 +1,81 @@
+/*
+ * OrthogonalSummation_impl.hpp
+ *
+ *  Created on: Jun 25, 2012
+ *      Author: heber
+ */
+
+#ifndef ORTHOGONALSUMMATION_IMPL_HPP_
+#define ORTHOGONALSUMMATION_IMPL_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/IteratorAdaptors.hpp"
+#include "CodePatterns/Log.hpp"
+
+/** Constructor of class OrthogonalSummation.
+ *
+ */
+template <class T>
+OrthogonalSummation<T>::OrthogonalSummation(
+    InputSets_t &indices,
+    InputValues_t& values,
+    SubsetMap::ptr _subsetmap) :
+  subsetmap(_subsetmap)
+{
+  ASSERT( indices.size() == values.size(),
+      "OrthogonalSummation<T>::OrthogonalSummation() - indices and values mismatch in size: "
+      +toString(indices.size())+" != "+toString(values.size())+".");
+  /// place each index
+  /// create own map if none is given
+  if (!subsetmap) {
+    typename InputSets_t::iterator iter = indices.begin();
+    IndexSetContainer container(*iter);
+    for (; iter != indices.end(); ++iter)
+      container.insert(*iter);
+    subsetmap.reset(new SubsetMap(container));
+  } else {
+    LOG(1, "INFO: Using given SubsetMap.");
+  }
+  /// instantiate all SubSetValue's by requesting the IndexSet from the Subsetmap
+  typename InputSets_t::iterator indexiter = indices.begin();
+  typename InputValues_t::iterator valueiter = values.begin();
+  for (;valueiter != values.end(); ++indexiter, ++valueiter) {
+    LOG(1, "INFO: Adding set " << **indexiter << " with value " << *valueiter << ".");
+    setvalues.addValue( *indexiter, *valueiter );
+  }
+  /// bind static lookup functions for SetValue<T>
+  SetValue<T>::lookupSubset =
+      boost::bind(&SubsetMap::getSubsets, boost::ref(*subsetmap), _1);
+  SetValue<T>::lookupValue =
+      boost::bind(&SetValueMap<T>::getValue, boost::ref(setvalues), _1);
+}
+
+template <class T>
+T OrthogonalSummation<T>::operator()() const
+{
+  return Sum();
+}
+
+template <class T>
+T OrthogonalSummation<T>::Sum() const
+{
+  typename SetValueMap<T>::const_iterator iter = setvalues.begin();
+  T sum = (iter->second)->getContribution();
+  LOG(1, "DEBUG: Contribution from subset "+toString(*(iter->second->getIndexSet()))
+      +" is "+toString(sum)+".");
+  for(++iter;iter != setvalues.end(); ++iter) {
+    const T tempvalue = (iter->second)->getContribution();
+    sum += tempvalue;
+    LOG(1, "DEBUG: Contribution from subset "+toString(*(iter->second->getIndexSet()))
+        +" is "+toString(tempvalue)+".");
+  }
+  return sum;
+}
+
+
+#endif /* ORTHOGONALSUMMATION_IMPL_HPP_ */
Index: src/Fragmentation/Summation/SetValue.hpp
===================================================================
--- src/Fragmentation/Summation/SetValue.hpp	(revision 0a387eb05bb064023a609198c7502635736f7fc8)
+++ src/Fragmentation/Summation/SetValue.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -32,4 +32,6 @@
   //!> grant unit test access to allow setting static function
   friend class SetValueTest;
+  //!> grant OrthogonalSummation access to static lookup functions
+  template <class TT> friend class OrthogonalSummation;
 public:
   typedef boost::shared_ptr< SetValue<T> > ptr;
Index: src/Fragmentation/Summation/unittests/Makefile.am
===================================================================
--- src/Fragmentation/Summation/unittests/Makefile.am	(revision 0a387eb05bb064023a609198c7502635736f7fc8)
+++ src/Fragmentation/Summation/unittests/Makefile.am	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -10,4 +10,5 @@
 	../Fragmentation/unittests/IndexSetUnitTest.cpp \
 	../Fragmentation/unittests/IndexSetContainerUnitTest.cpp \
+	../Fragmentation/unittests/OrthogonalSummationUnitTest.cpp \
 	../Fragmentation/unittests/SetValueUnitTest.cpp \
 	../Fragmentation/unittests/SetValueMapUnitTest.cpp \
@@ -17,4 +18,5 @@
 	../Fragmentation/unittests/IndexSetUnitTest.hpp \
 	../Fragmentation/unittests/IndexSetContainerUnitTest.cpp \
+	../Fragmentation/unittests/OrthogonalSummationUnitTest.hpp \
 	../Fragmentation/unittests/SetValueUnitTest.hpp \
 	../Fragmentation/unittests/SetValueMapUnitTest.hpp \
@@ -24,4 +26,5 @@
   IndexSetUnitTest \
   IndexSetContainerUnitTest \
+  OrthogonalSummationUnitTest \
   SetValueUnitTest \
   SetValueMapUnitTest \
@@ -51,4 +54,17 @@
 	SortedVector.hpp
 IndexSetContainerUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
+
+OrthogonalSummationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	unittests/OrthogonalSummationUnitTest.cpp \
+	unittests/OrthogonalSummationUnitTest.hpp \
+	OrthogonalSummation.hpp \
+	OrthogonalSummation_impl.hpp \
+	IndexSet.cpp \
+	IndexSet.hpp \
+	IndexSetContainer.hpp \
+	SortedVector.hpp \
+	SubsetMap.cpp \
+	SubsetMap.hpp
+OrthogonalSummationUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
 
 SetValueUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
Index: src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp
===================================================================
--- src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
+++ src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -0,0 +1,123 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * OrthogonalSummationUnitTest.cpp
+ *
+ *  Created on: Jun 26, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "OrthogonalSummationUnitTest.hpp"
+
+#include "Fragmentation/Summation/OrthogonalSummation.hpp"
+#include "Fragmentation/Summation/SetValue.hpp"
+
+#include <algorithm>
+#include <boost/assign.hpp>
+
+#include "CodePatterns/Log.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+using namespace boost::assign;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( OrthogonalSummationTest );
+//
+//template <class T>
+//struct SetValueAllocator {
+//  SetValueAllocator(const T &_value) :
+//    value(_value)
+//  {}
+//  SetValue<T> * operator()(const IndexSet &set) {
+//    SetValue<T> * _instance = new SetValue<T>(set, value);
+//    return _instance;
+//  }
+//private:
+//  //!> internally stored fixed initial value
+//  const T value;
+//};
+
+void OrthogonalSummationTest::setUp()
+{
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+  setVerbosity(5);
+
+  // create a tree of sets
+  IndexSet::ptr AllIndices(new IndexSet);
+  (*AllIndices) += 1,2,3,4;
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, AllIndices->size() );
+  container.reset(new IndexSetContainer(AllIndices));
+  CPPUNIT_ASSERT_EQUAL( (size_t)1, container->getContainer().size() );
+  IndexSet tempset;
+  tempset += 1;
+  container->insert(tempset);
+  tempset += 2;
+  container->insert(tempset);
+  tempset.clear();
+  tempset += 3;
+  container->insert(tempset);
+  tempset += 2;
+  container->insert(tempset);
+  CPPUNIT_ASSERT_EQUAL( (size_t)5, container->getContainer().size() );
+  subsetmap.reset(new SubsetMap(*container));
+}
+
+
+void OrthogonalSummationTest::tearDown()
+{
+}
+
+/** UnitTest for operator()
+ */
+void OrthogonalSummationTest::operator_staticTest()
+{
+  const IndexSetContainer::Container_t &_container = container->getContainer();
+  for (int value = -5; value <= 5; ++value) {
+    // create a value for each set (and copy indices to overcome constness in container)
+    OrthogonalSummation<int>::InputSets_t indices(_container.begin(), _container.end());
+    OrthogonalSummation<int>::InputValues_t values(_container.size(), value);
+    // create the summation functor
+    OrthogonalSummation<int> OS(indices, values, subsetmap);
+
+    // sum up, as full set is contained we must get value again
+    CPPUNIT_ASSERT_EQUAL( value, OS() );
+  }
+}
Index: src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp
===================================================================
--- src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
+++ src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp	(revision 1e7dd43451cc813dbdf63921c91127e6add87249)
@@ -0,0 +1,41 @@
+/*
+ * OrthogonalSummationUnitTest.hpp
+ *
+ *  Created on: Jun 26, 2012
+ *      Author: heber
+ */
+
+#ifndef ORTHOGONALSUMMATIONUNITTEST_HPP_
+#define ORTHOGONALSUMMATIONUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "Fragmentation/Summation/IndexSetContainer.hpp"
+#include "Fragmentation/Summation/SubsetMap.hpp"
+
+
+/********************************************** Test classes **************************************/
+
+class OrthogonalSummationTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( OrthogonalSummationTest) ;
+    CPPUNIT_TEST ( operator_staticTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void operator_staticTest();
+
+private:
+      SubsetMap::ptr subsetmap;
+      IndexSetContainer::ptr container;
+};
+
+#endif /* ORTHOGONALSUMMATIONUNITTEST_HPP_ */
