Index: trunk/Mars/msimcamera/MSimCamera.cc
===================================================================
--- trunk/Mars/msimcamera/MSimCamera.cc	(revision 19622)
+++ trunk/Mars/msimcamera/MSimCamera.cc	(revision 19623)
@@ -410,15 +410,19 @@
     Double_t tot = 0;
 
-    for (int i=0 ; i<1440 ; i++)
-    {
-        (*fTruePhotons->cherenkov_photons_weight)[i] = 0;
-        (*fTruePhotons->cherenkov_photons_number)[i] = 0;
-        (*fTruePhotons->cherenkov_arrival_time_mean)[i] = 0;
-        (*fTruePhotons->cherenkov_arrival_time_variance)[i] = 0;
-        (*fTruePhotons->muon_cherenkov_photons_weight)[i] = 0;
-        (*fTruePhotons->muon_cherenkov_photons_number)[i] = 0;
-        (*fTruePhotons->cherenkov_arrival_time_min)[i] = 10000;
-        (*fTruePhotons->cherenkov_arrival_time_max)[i] = 0;
-        (*fTruePhotons->noise_photons_weight)[i] = 0;
+    // Sanity check for bad programming style
+    if (npix==1440)
+    {
+        for (int i=0 ; i<1440 ; i++)
+        {
+            (*fTruePhotons->cherenkov_photons_weight)[i] = 0;
+            (*fTruePhotons->cherenkov_photons_number)[i] = 0;
+            (*fTruePhotons->cherenkov_arrival_time_mean)[i] = 0;
+            (*fTruePhotons->cherenkov_arrival_time_variance)[i] = 0;
+            (*fTruePhotons->muon_cherenkov_photons_weight)[i] = 0;
+            (*fTruePhotons->muon_cherenkov_photons_number)[i] = 0;
+            (*fTruePhotons->cherenkov_arrival_time_min)[i] = 10000;
+            (*fTruePhotons->cherenkov_arrival_time_max)[i] = 0;
+            (*fTruePhotons->noise_photons_weight)[i] = 0;
+        }
     }
 
@@ -441,9 +445,9 @@
         // fFixTimeOffsetsBetweenPixelsInNs -> fM matrix. We identify the first
         // column to hold the offsets in ns.
-        t = t + freq*fFixTimeOffsetsBetweenPixelsInNs->fM[idx][0];
+        t += freq*fFixTimeOffsetsBetweenPixelsInNs->fM[idx][0];
 
         // Jens Buss on residual time spread:
         // add random time offset to the arrivaltimes
-        t = t + timeoffset[idx];
+        t += timeoffset[idx];
 
         // FIXME: Time jitter?
@@ -451,6 +455,5 @@
         // add also a time offset to arrival times of single photons
         // TODO: change to ns, use: fRunHeader->GetFreqSampling()
-        Double_t timeJitter = gRandom->Gaus(0.0, gapdTimeJitter);
-        t = t + timeJitter;
+        t += gRandom->Gaus(0.0, gapdTimeJitter);
 
         // FIXME: Add additional routing here?
@@ -460,30 +463,39 @@
         {
             tot += ph.GetWeight();
-            (*fTruePhotons->cherenkov_photons_weight)[idx] += ph.GetWeight();
-            (*fTruePhotons->cherenkov_photons_number)[idx] += 1;
-
-            (*fTruePhotons->cherenkov_arrival_time_mean)[idx] += t;
-            (*fTruePhotons->cherenkov_arrival_time_variance)[idx] += t*t;
-
-            if (ph.GetPrimary()==MMcEvt::kMUON)
+
+            // Sanity check for bad programming style
+            if (npix==1440)
             {
-                (*fTruePhotons->muon_cherenkov_photons_weight)[idx] += ph.GetWeight();
-                (*fTruePhotons->muon_cherenkov_photons_number)[idx] += 1;
-            }
-
-            // find min
-            if (t < (*fTruePhotons->cherenkov_arrival_time_min)[idx] )
-            {
-                (*fTruePhotons->cherenkov_arrival_time_min)[idx] = t;
-            }
-            // find max
-            if (t > (*fTruePhotons->cherenkov_arrival_time_max)[idx] )
-            {
-               (*fTruePhotons->cherenkov_arrival_time_max)[idx] = t;
+                (*fTruePhotons->cherenkov_photons_weight)[idx] += ph.GetWeight();
+                (*fTruePhotons->cherenkov_photons_number)[idx] += 1;
+
+                (*fTruePhotons->cherenkov_arrival_time_mean)[idx] += t;
+                (*fTruePhotons->cherenkov_arrival_time_variance)[idx] += t*t;
+
+                if (ph.GetPrimary()==MMcEvt::kMUON)
+                {
+                    (*fTruePhotons->muon_cherenkov_photons_weight)[idx] += ph.GetWeight();
+                    (*fTruePhotons->muon_cherenkov_photons_number)[idx] += 1;
+                }
+
+                // find min
+                if (t < (*fTruePhotons->cherenkov_arrival_time_min)[idx] )
+                {
+                    (*fTruePhotons->cherenkov_arrival_time_min)[idx] = t;
+                }
+                // find max
+                if (t > (*fTruePhotons->cherenkov_arrival_time_max)[idx] )
+                {
+                    (*fTruePhotons->cherenkov_arrival_time_max)[idx] = t;
+                }
             }
         }
         else
         {
-            (*fTruePhotons->noise_photons_weight)[idx] += ph.GetWeight();
+            // Sanity check for bad programming style
+            if (npix==1440)
+            {
+                (*fTruePhotons->noise_photons_weight)[idx] += ph.GetWeight();
+            }
         }
 
@@ -496,11 +508,15 @@
     }
 
-    for (unsigned int i=0 ; i < 1440 ; i++)
-    {
-        float number = (*fTruePhotons->cherenkov_photons_number)[i];
-        (*fTruePhotons->cherenkov_arrival_time_mean)[i] /= number;
-        float mean = (*fTruePhotons->cherenkov_arrival_time_mean)[i];
-        float sum_tt = (*fTruePhotons->cherenkov_arrival_time_variance)[i];
-        (*fTruePhotons->cherenkov_arrival_time_variance)[i] = (sum_tt / number - mean*mean) /(number - 1);
+    // Sanity check for bad programming style
+    if (npix==1440)
+    {
+        for (unsigned int i=0 ; i < 1440 ; i++)
+        {
+            float number = (*fTruePhotons->cherenkov_photons_number)[i];
+            (*fTruePhotons->cherenkov_arrival_time_mean)[i] /= number;
+            float mean = (*fTruePhotons->cherenkov_arrival_time_mean)[i];
+            float sum_tt = (*fTruePhotons->cherenkov_arrival_time_variance)[i];
+            (*fTruePhotons->cherenkov_arrival_time_variance)[i] = (sum_tt / number - mean*mean) /(number - 1);
+        }
     }
 
