Index: trunk/MagicSoft/Mars/macros/triglvl2.C
===================================================================
--- trunk/MagicSoft/Mars/macros/triglvl2.C	(revision 1767)
+++ trunk/MagicSoft/Mars/macros/triglvl2.C	(revision 1777)
@@ -1,26 +1,8 @@
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
-void triglvl2(char *filename = "../../Mars-0.8/gamma_new.root")
+//   triglvl2.C
+//  Macro to use the class MMcTriggerLvl2, which calculates the 
+//   2nd level trigger (L2T) selection parameters.
+//  Filters to select events using these parameter are also created.
+//
+void triglvl2(char *filename = "Gamma.root")
 { 
     //
@@ -30,26 +12,68 @@
     MTaskList tasklist;
 
-    MTrigLvl2 cell;
-      
-    parlist.AddToList(&cell);
     parlist.AddToList(&tasklist);
 
+    // An instance of the class MMcTriggerLvl2 is created and added to the 
+    //  parameter list
+    MMcTriggerLvl2 cell;      
+    parlist.AddToList(&cell);
+
     //
-    // Setup out tasks:
+    //  A filter to select events using the L2T parameters is created
+    //
+    //    MF lvl2filter("MMcTriggerLvl2.fLutPseudoSize > 6");
+    MF lvl2filter("MMcTriggerLvl2.fSizeBiggerCell > 16");
+    // A second filter is created using the class MFTriggerLvl2
+    MFTriggerLvl2 fTrig1("MMcTriggerLvl2", '>', 6);
+    //       this is the value to be compared --^
+
+    //
+    // A selection on the number and energy of the events 
+    //
+    MF energyfilter("MMcEvt.fEnergy > 10");
+    MFEventSelector selector;
+    selector.SetNumSelectEvts(4000);
+
+    // A filter list is created; the filters created can be added to the list
+    //
+    MFilterList flist;
+    flist.AddToList(&energyfilter);
+    flist.AddToList(&lvl2filter);
+    flist.AddToList(&selector);
+    flist.AddToList(&fTrig1);
+
+    // 
+    // Setup our tasks:
     //  - First we have to read the events
     //  - Then we can fill the efficiency histograms
     //
     MReadMarsFile reader("Events", filename);
-    reader.EnableBranch("fEnergy");
-    reader.EnableBranch("fImpact"); reader.EnableBranch("fTimeFirst[4]");
-    reader.EnableBranch("fPixelsFirst[73][4]");
+    reader.DisableAutoScheme();
+     //  reader.EnableBranch("fEnergy");
+     //  reader.EnableBranch("fImpact"); reader.EnableBranch("fTimeFirst[4]");
+     //  reader.EnableBranch("fPixelsFirst[73][4]");
    
-   
-   
-    MTrigLvl2FillTask fill("MTrigLvl2FillTask","MTrigLvl2FillTask");  
-  
     tasklist.AddToList(&reader);
-      tasklist.AddToList(&fill);
 
+    //
+    // The task to calculate the L2T parameter is added to the task list
+    //
+    MMcTriggerLvl2Calc fill("MMcTriggerLvl2","MMcTriggerLvl2");  
+    tasklist.AddToList(&fill);
+
+    //
+    //  Task to calculate and plot the effective area
+    //
+    MMcCollectionAreaCalc effi;
+    tasklist.AddToList(&effi);
+    //
+    // The filter list selects events for the effective area calculation
+    //
+    effi.SetFilter(&flist);
+
+    //
+    // The filter list is added to the task list
+    //
+    tasklist.AddToList(&flist);
 
     //
@@ -65,34 +89,18 @@
     magic.SetProgressBar(&bar);
 
-
-   //  if (!magic.Eventloop())
-   //         return;
-
-
     if (!magic.PreProcess())
       return;
 
-
-
-    while (tasklist.Process())
-      {
-        cout << "Event #" << reader.GetEventNum() ":" << endl;
-
-	cell.DrawLv1();
-      
-	//if (!HandleInput())
-	 // break;
-    } 
-
-
-
-    magic.PostProcess();
+    if (!magic.Eventloop())
+      return;
 
     tasklist.PrintStatistics();
-
     //
     // Now the histogram we wanted to get out of the data is
     // filled and can be displayd
     //
-  // parlist.FindObject("MHMcCollectionArea")->DrawClone();
+    parlist.FindObject("MHMcCollectionArea")->DrawClone();
+
+    magic.PostProcess();
+
 }
