Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 6459)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 6460)
@@ -86,4 +86,9 @@
    * mraw/MRawFileRead.cc:
      - return kERROR if ReInit fails
+
+   * mfilter/MFSoftwareTrigger.[h,cc]:  
+     - updated to allow using time coincidence
+     - changed default values
+     - added a pattern independant trigger algorithm
 
 
Index: /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc	(revision 6459)
+++ /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc	(revision 6460)
@@ -133,6 +133,6 @@
         return 0;
 
-    const Float_t tm1 = (*fTme)[idx];
-    if (fTimeWindow>0 && TMath::Abs(tm1-tm0)>fTimeWindow)
+    const Float_t tm1 = fTme ? (*fTme)[idx] : 0;
+    if (fTme && TMath::Abs(tm1-tm0)>fTimeWindow)
         return 0;
 
@@ -341,5 +341,5 @@
                 continue;
 
-            if (fTimeWindow>0)
+            if (fTme)
             {
                 const Float_t t0 = (*fTme)[pix0.GetPixId()];
@@ -377,11 +377,14 @@
     }
 
-    fTme = (MArrivalTime*)pList->FindObject("MArrivalTime");
-    if (!fTme)
-    {
-        *fLog << err << "MArrivalTime not found... aborting." << endl;
-        return kFALSE;
-    }
-
+    fTme = 0;
+    if (fTimeWindow>0)
+    {
+        fTme = (MArrivalTime*)pList->FindObject("MArrivalTime");
+        if (!fTme)
+        {
+            *fLog << err << "MArrivalTime not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
 
     memset(fCut, 0, sizeof(fCut));
@@ -437,6 +440,8 @@
     *fLog << (int)(fCut[0]*100/GetNumExecutions());
     *fLog << "%) Evts fullfilled" << type;
-    *fLog << " (Thresh>=" << fThreshold << ", Num>=";
-    *fLog << (int)fNumNeighbors << ", Win=" << fTimeWindow << ")" << endl;
+    *fLog << " (Thresh>=" << fThreshold << ", Num>=" << (int)fNumNeighbors;
+    if (fTimeWindow>0)
+        *fLog << ", Win=" << fTimeWindow;
+    *fLog << ")" << endl;
     *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
     *fLog << (int)(fCut[1]*100/GetNumExecutions());
Index: /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.h
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.h	(revision 6459)
+++ /trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.h	(revision 6460)
@@ -9,12 +9,23 @@
 class MGeomCam;
 class MCerPhotEvt;
+class MCerPhotPix;
+class MArrivalTime;
 
 class MFSoftwareTrigger : public MFilter
 {
+public:
+    enum TriggerType_t {
+        kSinglePixelNeighbors,
+        kAnyPattern/*,
+        kMagicLvl1*/
+    };
+
 private:
-    const MGeomCam    *fCam; // Camera Geometry
-    const MCerPhotEvt *fEvt; // Cerenkov Photon Event
+    const MGeomCam     *fCam; // Camera Geometry
+    const MCerPhotEvt  *fEvt; // Cerenkov Photon Event
+    const MArrivalTime *fTme;
 
-    Float_t     fNumMinPhotons; // nuber of minimum required photons
+    Float_t     fThreshold;     // nuber of minimum required photons
+    Float_t     fTimeWindow;    // Window for time coincidence
     Byte_t      fNumNeighbors;  // number of required neighbours
 
@@ -23,9 +34,24 @@
     Bool_t      fResult;
 
+    TriggerType_t fType;
+
+    enum {
+        kWasChecked     = BIT(21),
+        kAboveThreshold = BIT(22),
+        kIsCoincident   = BIT(23)
+    };
+
     Int_t PreProcess(MParList *pList);
     Int_t Process();
     Int_t PostProcess();
 
+    void ResetBits(Int_t bits) const;
+    Bool_t CheckPixel(const MCerPhotPix &pix) const;
     Bool_t SwTrigger() const;
+    Bool_t SwCoincidence() const;
+    //Int_t CheckCoincidence(Int_t idx, Float_t tm0) const;
+    //Bool_t MagicLvl1Trigger() const;
+    Int_t  CountPixels(Int_t idx, Float_t tm) const;
+    Bool_t ClusterTrigger() const;
 
     Bool_t IsExpressionTrue() const { return fResult; }
@@ -34,6 +60,10 @@
     MFSoftwareTrigger(const char *name=NULL, const char *title=NULL);
 
-    void SetNumMinPhotons(Float_t minphotons) { fNumMinPhotons = minphotons; }
-    void SetNumNeighbors(Byte_t num) { fNumNeighbors = num; }
+    void SetThreshold(Float_t min)          { fThreshold    = min; }
+    void SetNumNeighbors(Byte_t num)        { fNumNeighbors = num; }
+    void SetTimeWindow(Float_t win=-1)      { fTimeWindow   = win; }
+    void SetTriggerType(TriggerType_t type) { fType = type; }
+
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
     ClassDef(MFSoftwareTrigger, 0) // Filter for software trigger
