Index: /trunk/Mars/melectronics/Afterpulse.cc
===================================================================
--- /trunk/Mars/melectronics/Afterpulse.cc	(revision 17201)
+++ /trunk/Mars/melectronics/Afterpulse.cc	(revision 17201)
@@ -0,0 +1,29 @@
+#include "Afterpulse.h"
+
+#include <TRandom.h>
+
+#include "MMath.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(Afterpulse);
+
+using namespace std;
+
+Float_t Afterpulse::Process(APD &apd)
+{
+    // Do not process afterpulses twice (e.g. HitRelative + IncreaseTime)
+    // This should not happen anyway
+    //        if (fAmplitude>0)
+    //            return fAmplitude;
+
+    const UInt_t nx  = apd.GetNumCellsX()+2;
+
+    const UInt_t x = fCellIndex%nx;
+    const UInt_t y = fCellIndex/nx;
+
+    fAmplitude = apd.HitCellImp(x, y, fTime);
+
+    return fAmplitude;
+}
Index: /trunk/Mars/melectronics/Afterpulse.h
===================================================================
--- /trunk/Mars/melectronics/Afterpulse.h	(revision 17201)
+++ /trunk/Mars/melectronics/Afterpulse.h	(revision 17201)
@@ -0,0 +1,58 @@
+#ifndef MARS_Afterpulse
+#define MARS_Afterpulse
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+#ifndef ROOT_TSortedList
+#include <TSortedList.h>
+#endif
+
+#ifndef MARS_MAvalanchePhotoDiode
+#include <MAvalanchePhotoDiode.h>
+#endif
+
+class Afterpulse : public TObject
+{
+private:
+    UInt_t  fCellIndex;  // Index of G-APD cell the afterpulse belongs to
+
+    Float_t fTime;       // Time at which the afterpulse avalanch broke through
+    Float_t fAmplitude;  // Amplitude (crosstalk!) the pulse produced
+
+    Int_t Compare(const TObject *obj) const
+    {
+        return static_cast<const Afterpulse*>(obj)->fTime>fTime ? -1 : 1;
+    }
+
+    Bool_t IsSortable() const { return kTRUE; }
+
+public:
+    Afterpulse(UInt_t idx, Float_t t) : fCellIndex(idx), fTime(t), fAmplitude(0) { }
+
+    UInt_t GetCellIndex() const { return fCellIndex; }
+
+    Float_t GetTime() const { return fTime; }
+    Float_t GetAmplitude() const { return fAmplitude; }
+
+    Float_t Process(APD &apd);
+    //~ {
+        //~ // Do not process afterpulses twice (e.g. HitRelative + IncreaseTime)
+        //~ // This should not happen anyway
+        //~ //        if (fAmplitude>0)
+        //~ //            return fAmplitude;
+//~ 
+        //~ const UInt_t nx  = apd.GetNumCellsX()+2;
+//~ 
+        //~ const UInt_t x = fCellIndex%nx;
+        //~ const UInt_t y = fCellIndex/nx;
+//~ 
+        //~ fAmplitude = apd.HitCellImp(x, y, fTime);
+//~ 
+        //~ return fAmplitude;
+    //~ }
+    ClassDef(Afterpulse, 1) // An object representing an Afterpulse
+};
+
+#endif
