Index: trunk/MagicSoft/Mars/macros/triglvl2.C
===================================================================
--- trunk/MagicSoft/Mars/macros/triglvl2.C	(revision 2364)
+++ trunk/MagicSoft/Mars/macros/triglvl2.C	(revision 2365)
@@ -24,56 +24,4 @@
     parlist.AddToList(&tasklist);
 
-    MGeomCamMagic geocam;
-    parlist.AddToList(&geocam);
-
-    //    MHillas hillas;
-    // parlist.AddToList(&hillas);
-
-    // An instance of the class MMcTriggerLvl2 is created and added to the 
-    //  parameter list
-    MMcTriggerLvl2 cell;     
-    parlist.AddToList(&cell);
-
-    // Set the number of Next Neighbourhoods that define a compact pixel
-    //
-    cell.SetCompactNN(3);
-    //  USER:       --^
-
-    //
-    //  A filter to select events using the L2T parameters is created
-    //
-    MF lvl2filter("MMcTriggerLvl2.fLutPseudoSize > 8");
-
-    //
-    // A second filter is created using the class MFTriggerLvl2
-    //
-    MFTriggerLvl2 fTrig("MMcTriggerLvl2", '>', 8);
-    //      USER:       fValue to be compared --^
-
-    //
-    // A selection on the number and energy of the events 
-    //
-    MF energyfilter("MMcEvt.fEnergy > 100");
-    MFEventSelector selector;
-    //selector.SetNumSelectEvts(4000);
-
-
-    // Filter to select events according to a give slope
-    MFEnergySlope eslope;
-
-    eslope.SetMcMinEnergy(50.);
-    eslope.SetMcMaxEnergy(400.);
-    eslope.SetNewSlope(-3.91);
-
-    // 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(&eslope);
-       flist.AddToList(&fTrig);
-
-
     // 
     // Setup our tasks:
@@ -81,4 +29,6 @@
     //  - Then we can fill the efficiency histograms
     //
+    
+
     MReadMarsFile reader("Events", filename);
     reader.DisableAutoScheme();
@@ -89,4 +39,68 @@
     tasklist.AddToList(&reader);
 
+    MGeomCamMagic geocam;
+    parlist.AddToList(&geocam);
+
+    //    MHillas hillas;
+    // parlist.AddToList(&hillas);
+
+    // An instance of the class MMcTriggerLvl2 is created and added to the 
+    //  parameter list
+    MMcTriggerLvl2 cell;     
+    parlist.AddToList(&cell);
+
+    MMcEvt mevt;
+    parlist.AddToList(&mevt);
+
+    // Set the number of Next Neighbourhoods that define a compact pixel
+    //
+    cell.SetCompactNN(2);
+    //  USER:       --^
+
+    //
+    //  A filter to select events using the L2T parameters is created
+    //
+
+    // MF lvl2filter("MMcTriggerLvl2.fPseudoSize > 25 && MMcTriggerLvl2.fPseudoSize < 31");
+    MF lvl2filter("MMcTriggerLvl2.fPseudoSize > 15");
+ 
+    //
+    // A second filter is created using the class MFTriggerLvl2
+    //
+    MFTriggerLvl2 fTrig("MMcTriggerLvl2", '>', 8);
+    //      USER:       fValue to be compared --^
+
+    //
+    // A selection on the number and energy of the events 
+    //
+    MF energyfilter("MMcEvt.fEnergy > 100");
+    MFEventSelector selector;
+    //selector.SetNumSelectEvts(4000);
+
+
+    // Filter to select events according to a give slope
+    MFEnergySlope eslope;
+
+    eslope.SetMcMinEnergy(50.);
+    eslope.SetMcMaxEnergy(400.);
+    eslope.SetNewSlope(-.5);
+
+    // 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(&eslope);
+    //   flist.AddToList(&fTrig);
+
+
+    
+    //
+    // The task to calculate the L2T parameter is added to the task list
+    //
+    MMcTriggerLvl2Calc calcps("MMcTriggerLvl2","MMcTriggerLvl2");  
+    tasklist.AddToList(&calcps);
+
     //
     // The filter list is added to the task list
@@ -98,6 +112,5 @@
     //
     MMcCollectionAreaCalc effi;
-    tasklist.AddToList(&effi);
-
+    tasklist.AddToList(&effi);    
     //
     // The filter list selects events for the effective area calculation
@@ -105,9 +118,4 @@
     effi.SetFilter(&flist);
  
-    //
-    // The task to calculate the L2T parameter is added to the task list
-    //
-    MMcTriggerLvl2Calc fill("MMcTriggerLvl2","MMcTriggerLvl2");  
-    tasklist.AddToList(&fill);
 
     //
@@ -116,5 +124,11 @@
     MFillH hfill1("MHMcTriggerLvl2","MMcTriggerLvl2");
     tasklist.AddToList(&hfill1);
-
+    //hfill1.SetFilter(&flist);
+    //MFillH hfill2("MHMcTriggerLvl2", &mevt, &cell);
+    //tasklist.AddToList(&hfill2);
+    //hfill2.SetFilter(&flist);
+
+    
+    
     //
     // set up the loop for the processing
@@ -123,4 +137,5 @@
     magic.SetParList(&parlist);
 
+    
     //
     // Start to loop over all events
@@ -129,6 +144,29 @@
     magic.SetProgressBar(&bar);
 
+
     if (!magic.Eventloop())
       return;
+    /*
+    if (!magic.PreProcess())
+    return;
+    
+    while (tasklist.Process())
+      {
+	cout<< mevt.GetEnergy()<<endl;
+	
+	cell.Print();
+      }
+    */
+    //fMcEvt = (MMcEvt*)parlist->FindObject("MMcEvt");
+    //if (!fMcEvt)
+    //{
+    //cout << "MMcEvt not found... exit." << endl;
+    //*fLog << err << dbginf << "MMcEvt not found... exit." << endl;
+    //  return kFALSE;
+    //}
+    //   cout << "fMcEvt = " << fMcEvt << endl;
+
+    //parlist.FindObject("MHMcTriggerLvl2")->Fill((Double_t) fMcEvt->GetEnergy(), cell);
+
 
     tasklist.PrintStatistics();
@@ -140,10 +178,22 @@
     parlist.FindObject("MHMcCollectionArea")->DrawClone();
 
+    parlist.FindObject("MHMcTriggerLvl2")->DrawClone("sbc");
     parlist.FindObject("MHMcTriggerLvl2")->DrawClone("lps");
-    //     parlist.FindObject("MHMcTriggerLvl2")->DrawClone();
+    parlist.FindObject("MHMcTriggerLvl2")->DrawClone();
+    parlist.FindObject("MHMcTriggerLvl2")->DrawClone("energy");
 
     // Returns histogram of the class MHMcTriggerLvl2  
-    //   parlist.FindObject("MHMcTriggerLvl2")->GetHistByName("hfPseudoSize"));
-    
+
+    MHMcTriggerLvl2 *htrig = (MHMcTriggerLvl2 *)parlist.FindObject("MHMcTriggerLvl2");
+    TH1F *h1 = htrig->GetHistByName("fHistPseudoSize");
+    TH2D *h2 = htrig->GetHistPseudoSizeEnergy();
+
+    // h2->DrawClone();
+
+    hfile = new TFile("HistFileLUT.root", "RECREATE");
+    h1->Write();
+    h2->Write();
+    hfile->Close();
+
 }
 
