Index: trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc	(revision 9336)
+++ trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc	(revision 9349)
@@ -429,14 +429,15 @@
     TClonesArray &arr  = fEvt->GetArray();
 
-    TClonesArray &cpy0 = fMirror0->GetArray();
-    //TClonesArray &cpy1 = fMirror1->GetArray();
-    TClonesArray &cpy2 = fMirror2->GetArray();
-    TClonesArray &cpy3 = fMirror3->GetArray();
-    TClonesArray &cpy4 = fMirror4->GetArray();
-    cpy0.ExpandCreateFast(arr.GetEntriesFast());
-    //cpy1.ExpandCreateFast(arr.GetEntriesFast());
-    cpy2.ExpandCreateFast(arr.GetEntriesFast());
-    cpy3.ExpandCreateFast(arr.GetEntriesFast());
-    cpy4.ExpandCreateFast(arr.GetEntriesFast());
+    // Because we knwo in advance what the maximum storage space could
+    // be we allocated it in advance (or shrink it if it was extremely
+    // huge before)
+    // Note, that the drawback is that an extremly large event
+    //       will take about five times its storage space
+    //       for a moment even if a lot from it is unused.
+    //       It will be freed in the next step.
+    fMirror0->Resize(arr.GetEntriesFast()); // Free memory of allocated MPhotonData
+    fMirror2->Resize(arr.GetEntriesFast()); // Free memory of allocated MPhotonData
+    fMirror3->Resize(arr.GetEntriesFast()); // Free memory of allocated MPhotonData
+    fMirror4->Resize(arr.GetEntriesFast()); // Free memory of allocated MPhotonData
 
     // Initialize mirror properties
@@ -448,20 +449,10 @@
 
     // Rotation matrix to derotate sky
+    // For the new coordinate system see the Wiki
     TRotation rot;    // The signs are positive because we align the incident point on ground to the telescope axis
     rot.RotateZ( az); // Rotate point on ground to align it with the telescope axis
     rot.RotateX(-zd); // tilt the point from ground to make it parallel to the mirror plane
 
-    // Now: viewed from the backside of the mirror
-    //  x is pointing downwards
-    //  y is pointing left
-
-    // Rotate around z counterclockwise
-    // rot.RotateZ(TMath::Pi()/2); // Rotate x to point right / y downwards / z from mirror to camera
-    // rot.RotateX(TMath::Pi());   // Flip -y and y (also flips Z :( )
-
-    // Now: viewed from the backside of the mirror
-    //  x is pointing upwards
-    //  y is pointing right
-
+    // Now get the impact point from Corsikas output
     const TVector3 impact(fEvtHeader->GetX(), fEvtHeader->GetY(), 0);
 
@@ -500,5 +491,6 @@
         dat->SetDirection(w);
 
-        *static_cast<MPhotonData*>(cpy0.UncheckedAt(cnt[0]++)) = *dat;
+        (*fMirror0)[cnt[0]++] = *dat;
+        //*static_cast<MPhotonData*>(cpy0.UncheckedAt(cnt[0]++)) = *dat;
 
         // Check if the photon has hit the camera housing and holding
@@ -507,4 +499,5 @@
 
         // FIXME: Do we really need this one??
+        //(*fMirror1)[cnt[1]++] = *dat;
         //*static_cast<MPhotonData*>(cpy1.UncheckedAt(cnt[1]++)) = *dat;
 
@@ -513,5 +506,6 @@
             continue;
 
-        *static_cast<MPhotonData*>(cpy2.UncheckedAt(cnt[2]++)) = *dat;
+        (*fMirror2)[cnt[2]++] = *dat;
+        //*static_cast<MPhotonData*>(cpy2.UncheckedAt(cnt[2]++)) = *dat;
 
         // Now execute the reflection of the photon on the mirrors' surfaces
@@ -526,5 +520,6 @@
         dat->SetDirection(w);
 
-        *static_cast<MPhotonData*>(cpy3.UncheckedAt(cnt[3]++)) = *dat;
+        (*fMirror3)[cnt[3]++] = *dat;
+        //*static_cast<MPhotonData*>(cpy3.UncheckedAt(cnt[3]++)) = *dat;
 
         // Propagate the photon along its trajectory to the focal plane z=F
@@ -534,5 +529,6 @@
         dat->SetPosition(p);
 
-        *static_cast<MPhotonData*>(cpy4.UncheckedAt(cnt[4]++)) = *dat;
+        (*fMirror4)[cnt[4]++] = *dat;
+        //*static_cast<MPhotonData*>(cpy4.UncheckedAt(cnt[4]++)) = *dat;
 
         // FIXME: It make make sense to move this out of this class
