From 08d80b0be30b77a1e3359d492c3a1cd78fd426c8 Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Mon, 19 Jan 2015 17:11:56 +0000
Subject: [PATCH]  - added Iterator wrapper to fix problem with iterating   
 over maps on macos

---
 DDG4/python/DDG4.py | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py
index 79c8821f5..c621d7619 100644
--- a/DDG4/python/DDG4.py
+++ b/DDG4/python/DDG4.py
@@ -224,6 +224,23 @@ _props('SensDetActionSequenceHandle')
 
 _props('Geant4PhysicsListActionSequence')
 
+
+
+class Iter():
+  def Iterator(self): 
+    ''' Fix for map iteration on macos '''
+    n = self.m.size()
+    it = self.m.begin()
+    for i in range(0,n):
+      yield it
+      it.__preinc__()
+  def __init__(self,m):
+    self.m = m
+  def __iter__(self):
+    return self.Iterator()
+
+
+
 """
 Helper object to perform stuff, which occurs very often.
 I am sick of typing the same over and over again.
@@ -252,8 +269,8 @@ class Simple:
     return self
 
   def printDetectors(self):
-    print '+++  List of sensitive detectors:'
-    for i in self.lcdd.detectors():
+    print '+++  List of detectors:'
+    for i in Iter( self.lcdd.detectors() ):
       o = DetElement(i.second)
       sd = self.lcdd.sensitiveDetector(o.name())
       if sd.isValid():
-- 
GitLab