Index: src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp
===================================================================
--- src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp	(revision 0588e9997198820786bc31f4c69ab48e55ac174a)
+++ src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp	(revision f58e56c6f4415dc222f59f2f5d6188b773464ecb)
@@ -374,4 +374,105 @@
 }
 
+
+/** Determines the largest cycle in the container and returns its size.
+ *
+ * \param cycles set of cycles
+ * \return size if largest cycle
+ */
+size_t getMaxCycleSize(const KeySetsContainer &cycles)
+{
+  // gather cycle sizes
+  std::vector<size_t> cyclesizes(cycles.KeySets.size());
+  std::transform(
+      cycles.KeySets.begin(), cycles.KeySets.end(),
+      cyclesizes.begin(),
+      boost::bind(&KeySetsContainer::IntVector::size, boost::lambda::_1)
+  );
+  // get maximum
+  std::vector<size_t>::const_iterator maximum_size =
+      std::max_element(cyclesizes.begin(), cyclesizes.end());
+  if (maximum_size != cyclesizes.end())
+    return *maximum_size;
+  else
+    return 0;
+}
+
+void calculateCycleFullContribution(
+    const std::map<JobId_t, MPQCData> &shortrangedata,
+    const KeySetsContainer &keysets,
+    const KeySetsContainer &forcekeysets,
+    const KeySetsContainer &cycles,
+    const FragmentationShortRangeResults &shortrangeresults)
+{
+  // copy the shortrangeresults such that private MaxLevel is set in
+  // FragmentationShortRangeResults
+  FragmentationShortRangeResults cycleresults(shortrangeresults);
+  // get largest size
+  const size_t maximum_size = getMaxCycleSize(cycles);
+
+  /// The idea here is that (Orthogonal)Summation will place a result
+  /// consisting of level 1,2, and 3 fragment and a level 6 ring nonetheless
+  /// in level 6. If we want to have this result already at level 3, we
+  /// have to specifically inhibit all fragments from later levels but the
+  /// cycles and then pick the result from the last level and placing it at
+  /// the desired one
+
+  // loop from level 1 to max ring size and gather contributions
+  for (size_t level = 1; level <= maximum_size; ++level) {
+    // create ValueMask for this level by stepping through each keyset and checking size
+    std::vector<bool> localValueMask(shortrangedata.size(), false);
+    size_t index=0;
+    // TODO: if only KeySetsContainer was usable as a compliant STL container, might be able to use set_difference or alike.
+    KeySetsContainer::ArrayOfIntVectors::const_iterator keysetsiter = keysets.KeySets.begin();
+    KeySetsContainer::ArrayOfIntVectors::const_iterator cyclesiter = cycles.KeySets.begin();
+    for (; (keysetsiter != keysets.KeySets.end()) && (cyclesiter != cycles.KeySets.end());) {
+      if (cyclesiter->size() > keysetsiter->size()) {
+        // add if not greater than level in size
+        if ((*keysetsiter).size() <= level)
+          localValueMask[index] = true;
+        ++keysetsiter;
+        ++index;
+      } else if (cyclesiter->size() < keysetsiter->size()) {
+        ++cyclesiter;
+      } else { // both sets have same size
+        if (*cyclesiter > *keysetsiter) {
+          // add if not greater than level in size
+          if ((*keysetsiter).size() <= level)
+            localValueMask[index] = true;
+          ++keysetsiter;
+          ++index;
+        } else if (*cyclesiter < *keysetsiter) {
+          ++cyclesiter;
+        } else {
+          // also always add all cycles
+          localValueMask[index] = true;
+          ++cyclesiter;
+          ++keysetsiter;
+          ++index;
+        }
+      }
+    }
+    // activate rest if desired by level
+    for (; keysetsiter != keysets.KeySets.end(); ++keysetsiter) {
+      if ((*keysetsiter).size() <= level)
+        localValueMask[index] = true;
+      ++index;
+    }
+    LOG(2, "DEBUG: ValueMask for cycle correction at level " << level << " is "
+        << localValueMask << ".");
+    // create FragmentationShortRangeResults
+    FragmentationShortRangeResults localresults(shortrangedata, keysets, forcekeysets, localValueMask);
+    // and perform summation
+    localresults(shortrangedata);
+    // finally, extract the corrections from last level
+    cycleresults.Result_Energy_fused[level-1] =
+        localresults.Result_Energy_fused.back();
+    cycleresults.Result_Time_fused[level-1] =
+        localresults.Result_Time_fused.back();
+    cycleresults.Result_Force_fused[level-1] =
+        localresults.Result_Force_fused.back();
+  }
+  printReceivedCycleResults(cycleresults);
+}
 
 ActionState::ptr FragmentationAnalyseFragmentationResultsAction::performCall() {
@@ -444,75 +545,12 @@
   }
 
-  // copy the shortrangeresults such that private MaxLevel is set in
-  // FragmentationShortRangeResults
-  FragmentationShortRangeResults cycleresults(shortrangeresults);
   // calculate energy if cycles are calculated fully at each level already
   if (!cycles.KeySets.empty()) {
-    // gather cycle sizes
-    std::vector<size_t> cyclesizes(cycles.KeySets.size());
-    std::transform(
-        cycles.KeySets.begin(), cycles.KeySets.end(),
-        cyclesizes.begin(),
-        boost::bind(&KeySetsContainer::IntVector::size, boost::lambda::_1)
-    );
-    // get maximum
-    std::vector<size_t>::const_iterator maximum_size =
-        std::max_element(cyclesizes.begin(), cyclesizes.end());
-
-    // loop from level 1 to max ring size and gather corrections
-    for (size_t level = 1; level <= *maximum_size; ++level) {
-      // create ValueMask for this level by stepping through each keyset and checking size
-      std::vector<bool> localValueMask(shortrangedata.size(), false);
-      size_t index=0;
-      KeySetsContainer::ArrayOfIntVectors::const_iterator keysetsiter = keysets.KeySets.begin();
-      KeySetsContainer::ArrayOfIntVectors::const_iterator cyclesiter = cycles.KeySets.begin();
-      for (; (keysetsiter != keysets.KeySets.end()) && (cyclesiter != cycles.KeySets.end());) {
-        if (cyclesiter->size() > keysetsiter->size()) {
-          // add if not greater than level in size
-          if ((*keysetsiter).size() <= level)
-            localValueMask[index] = true;
-          ++keysetsiter;
-          ++index;
-        } else if (cyclesiter->size() < keysetsiter->size()) {
-          ++cyclesiter;
-        } else { // both sets have same size
-          if (*cyclesiter > *keysetsiter) {
-            // add if not greater than level in size
-            if ((*keysetsiter).size() <= level)
-              localValueMask[index] = true;
-            ++keysetsiter;
-            ++index;
-          } else if (*cyclesiter < *keysetsiter) {
-            ++cyclesiter;
-          } else {
-            // also always add all cycles
-            localValueMask[index] = true;
-            ++cyclesiter;
-            ++keysetsiter;
-            ++index;
-          }
-        }
-      }
-      // activate rest if desired by level
-      for (; keysetsiter != keysets.KeySets.end(); ++keysetsiter) {
-        if ((*keysetsiter).size() <= level)
-          localValueMask[index] = true;
-        ++index;
-      }
-      LOG(2, "DEBUG: ValueMask for cycle correction at level " << level << " is "
-          << localValueMask << ".");
-      // create FragmentationShortRangeResults
-      FragmentationShortRangeResults localresults(shortrangedata, keysets, forcekeysets, localValueMask);
-      // and perform summation
-      localresults(shortrangedata);
-      // finally, extract the corrections
-      cycleresults.Result_Energy_fused[level-1] =
-          localresults.Result_Energy_fused.back();
-      cycleresults.Result_Time_fused[level-1] =
-          localresults.Result_Time_fused.back();
-      cycleresults.Result_Force_fused[level-1] =
-          localresults.Result_Force_fused.back();
-    }
-    printReceivedCycleResults(cycleresults);
+    calculateCycleFullContribution(
+        shortrangedata,
+        keysets,
+        forcekeysets,
+        cycles,
+        shortrangeresults);
   }
 
