Index: branches/Mars_MC/msimcamera/MSimCamera.cc
===================================================================
--- branches/Mars_MC/msimcamera/MSimCamera.cc	(revision 17010)
+++ branches/Mars_MC/msimcamera/MSimCamera.cc	(revision 17011)
@@ -135,4 +135,11 @@
         return kFALSE;
 
+    fAccidentalPhotons = (MPedestalCam*)pList->FindObject("AccidentalPhotonRates","MPedestalCam");
+    if(!fAccidentalPhotons)
+    {
+        *fLog << err << "AccidentalPhotonRates [MPedestalCam] not found... aborting." << endl;
+        return kFALSE;
+    }
+
     MParSpline *pulse = (MParSpline*)pList->FindObject("PulseShape", "MParSpline");
     if (!pulse)
@@ -238,7 +245,45 @@
         const Double_t rms = pix.GetPedestalRms();
 
+        // FTemme: Implementation of AC-coupling:
+        // to calculate the value of the accoupling per slice I use the
+        // following equation:
+        // accouplingPerSlice = accidentalPhotonRate * (1 + crossTalkProb)
+        //       * areaOfOnePulse / samplingRate;
+        // Therefore I need the following variables
+        Double_t accidentalPhotonRate   = 0; // [MHz]
+        Float_t crossTalkProb           = 0; // [1]
+        Double_t areaOfOnePulse         = 0; // [ADC-Counts * s]
+        Double_t samplingRate           = 0; // [slices * MHz]
+
+        // The accidental photon rate is stored in GHz, so we have to multiply
+        // with 1E3 to get MHz:
+        MPedestalPix &accPhoPix         = (*fAccidentalPhotons)[i];
+        accidentalPhotonRate            = accPhoPix.GetPedestal() * 1E3;
+
+        // I don't know how to get the variable fCrosstalkProb from
+        // the class APD (see MAvalanchePhotoDiode.h), because there is no
+        // getter for the APD array(fAPDs) in MSimAPD.
+        // So I set the crossTalkProb hardcoded to the value 0.15, which is
+        // equal to the value of the apd of type 4
+        crossTalkProb                   = 0.15;
+
+        // To get the area of one Pulse, I only need to calculate the Integral
+        // of the Pulse Shape, which is stored in fSpline. Because the spline is
+        // normalized to a maximal amplitude of 1.0, I had to multiply it with
+        // the Default gain:
+        areaOfOnePulse                  = fSpline->Integral() * fDefaultGain;
+
+        // The sampling rate I get from the RunHeader:
+        samplingRate                    = fRunHeader->GetFreqSampling();
+
+        Double_t accouplingPerSlice = accidentalPhotonRate  * (1 + crossTalkProb)
+                * areaOfOnePulse / samplingRate;
+
+        // The accoupling is substracted from the timeline by decreasing the
+        // mean of the gaussian noise which is added
+
         if (!fBaselineGain)
         {
-            (*fCamera)[i].AddGaussianNoise(rms, val);
+            (*fCamera)[i].AddGaussianNoise(rms, val - accouplingPerSlice);
             continue;
         }
@@ -250,5 +295,6 @@
         // FIXME: How stable is the offset?
         // FIXME: Should we write a container AppliedGain for MSImTrigger?
-        (*fCamera)[i].AddGaussianNoise(rms*gain, val*gain);
+
+        (*fCamera)[i].AddGaussianNoise(rms*gain, (val - accouplingPerSlice)*gain);
     }
 
Index: branches/Mars_MC/msimcamera/MSimCamera.h
===================================================================
--- branches/Mars_MC/msimcamera/MSimCamera.h	(revision 17010)
+++ branches/Mars_MC/msimcamera/MSimCamera.h	(revision 17011)
@@ -24,9 +24,10 @@
     MPedestalCam      *fElectronicNoise; //! Electronic noise (baseline and rms)
     MPedestalCam      *fGain;            //! Electronic noise (baseline and rms)
+    MPedestalCam      *fAccidentalPhotons;//! Accidental photon rates
 
     MAnalogChannels   *fCamera;          //! Output of the analog signals
     MMcEvt            *fMcEvt;           //! For information stored in MMcEvt
 
-    const MSpline3    *fSpline;          // Pulse Shape
+    const MSpline3    *fSpline;          // Pulse Shape    
 
     Bool_t fBaselineGain;  // Should the gain be applied to baseline and electronic noise?
Index: branches/Mars_MC/msimcamera/MSimReadout.cc
===================================================================
--- branches/Mars_MC/msimcamera/MSimReadout.cc	(revision 17010)
+++ branches/Mars_MC/msimcamera/MSimReadout.cc	(revision 17011)
@@ -145,4 +145,5 @@
     fData->InitRead(fRunHeader);
     fData->ResetPixels();
+    fData->InitStartCells();
     fData->SetIndices();
 
@@ -202,5 +203,5 @@
 
     // Check if the whole requested signal can be digitized
-    if (trig+nslices>=nsamp)
+    if (trig+nslices>nsamp)
     {
         *fLog << err << "ERROR - Trigger position beyond valid analog signal range." << endl;
