Index: trunk/MagicSoft/Mars/mmain/MAnalysis.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 953)
+++ trunk/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 954)
@@ -165,5 +165,4 @@
 // ======================================================================
 
-#include "MLog.h"
 #include "MParList.h"
 #include "MTaskList.h"
@@ -179,5 +178,5 @@
 #include "MEvtLoop.h"
 #include "MHillas.h"
-#include <iostream.h>
+
 void MAnalysis::CalculateHillas() const
 {
@@ -212,5 +211,4 @@
     MTaskList tlist;
     plist.AddToList(&tlist);
-
 
     //
Index: trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 953)
+++ trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 954)
@@ -26,11 +26,128 @@
 #include "MMonteCarlo.h"
 
+#include <stdlib.h>
+#include <iostream.h>
+
+#include <TGLabel.h>        // TGLabel
 #include <TGButton.h>       // TGTextButton
+#include <TGTextEntry.h>    // TGTextEntry
+#include <TGButtonGroup.h>  // TGVButtonGroup
 
 ClassImp(MMonteCarlo)
 
 enum {
-    M_BUTTON_ACTION
+    M_BUTTON_COLAREA,
+    M_BUTTON_RATE,
+    M_BUTTON_THRESHOLD
 };
+
+void MMonteCarlo::AddButtons()
+{
+    TGTextButton *carea = new TGTextButton(fTop1, "Collection Area", M_BUTTON_COLAREA);
+    TGTextButton *trate = new TGTextButton(fTop1, "Trigger Rate",    M_BUTTON_RATE);
+    TGTextButton *thold = new TGTextButton(fTop1, "Threshold",       M_BUTTON_THRESHOLD);
+
+    fList->Add(carea);
+    fList->Add(trate);
+    fList->Add(thold);
+
+    carea->Associate(this);
+    trate->Associate(this);
+    thold->Associate(this);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 5, 5, 10, 10);
+    fList->Add(laybut);
+
+    fTop1->AddFrame(carea, laybut);
+    fTop1->AddFrame(trate, laybut);
+    fTop1->AddFrame(thold, laybut);
+}
+
+void MMonteCarlo::AddSetupTab()
+{
+    //
+    // Create Setup Tab
+    //
+    TGCompositeFrame *frame = CreateNewTab("Setup");
+
+    //
+    // Create a button group (it alignes the buttons and make
+    // them automatic radio buttons)
+    //
+    TGVButtonGroup *group = new TGVButtonGroup(frame);
+    fList->Add(group);
+
+    //
+    // Create three (auto) radio buttons in the button group
+    //
+    fRadioButton1 = new TGRadioButton(group, "Use unnumbered trigger condition olny.");
+    fRadioButton2 = new TGRadioButton(group, "Use only one trigger condition (specify number below).");
+    fRadioButton3 = new TGRadioButton(group, "Use a number of trigger conditions (1..n).");
+
+    fList->Add(fRadioButton1);
+    fList->Add(fRadioButton2);
+    fList->Add(fRadioButton3);
+
+    //
+    // Add the button group (all buttons) as first line
+    //
+    frame->AddFrame(group);
+
+    //
+    // Create entry fields and labels for line 3 and 4
+    //
+
+    /*
+     * --> use with root >=3.02 <--
+     *
+
+     TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+     TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+
+     */
+
+    //
+    // Align the lines:
+    //  - top, left
+    //  - padding: top=20, bottom=0, left=20, right=0
+    //
+    TGLayoutHints *layline = new TGLayoutHints(kLHintsNormal, 20, 0, 20);
+    fList->Add(layline);
+
+
+    //
+    // Create a frame for line 3 and 4 to be able
+    // to align entry field and label in one line
+    //
+    TGHorizontalFrame *f = new TGHorizontalFrame(frame, 0, 0);
+    fNumEntry = new TGTextEntry(f, "****");
+    fNumEntry->SetText("1");
+    fList->Add(fNumEntry);
+
+    // --- doesn't work like expected --- fNumEntry1->SetAlignment(kTextRight);
+    // --- doesn't work like expected --- fNumEntry2->SetAlignment(kTextRight);
+
+    TGLabel *l = new TGLabel(f, "Trigger Condition Setup.");
+    l->SetTextJustify(kTextLeft);
+    fList->Add(l);
+
+    //
+    // Align the text of the label centered, left in the row
+    // with a left padding of 10
+    //
+    TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10); //, 10); //, 5, 5);
+    fList->Add(laylabel);
+
+    //
+    // Add one entry field and the corresponding label to each line
+    //
+    f->AddFrame(fNumEntry);
+    f->AddFrame(l, laylabel);
+
+    //
+    // Add line 3 and 4 to tab
+    //
+    frame->AddFrame(f, layline);
+}
 
 MMonteCarlo::MMonteCarlo(const TGWindow *main, const TGWindow *p,
@@ -38,12 +155,6 @@
 : MBrowser(main, p, w, h)
 {
-    TGTextButton *action = new TGTextButton(fTop1, "ACTION", M_BUTTON_ACTION);
-    fList->Add(action);
-    action->Associate(this);
-
-    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
-    fList->Add(laybut);
-
-    fTop1->AddFrame(action, laybut);
+    AddButtons();
+    AddSetupTab();
 
     MapSubwindows();
@@ -58,14 +169,257 @@
 
 // ======================================================================
+#include <TObjArray.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MReadTree.h"
+
+#include "MHMcRate.h"
+#include "MHMcEnergy.h"
+
+#include "MMcTriggerRateCalc.h"
+#include "MMcThresholdCalc.h"
+#include "MMcCollectionAreaCalc.h"
+
+Int_t MMonteCarlo::GetDim() const
+{
+    Int_t dim = atoi(fNumEntry->GetText());
+
+    if (dim<0)
+    {
+        dim=0;
+        fNumEntry->SetText("0");
+    }
+
+    if (fRadioButton1->GetState())
+        dim = 0;
+
+    if (fRadioButton2->GetState())
+        dim = -dim;
+
+    return dim;
+}
+
+void MMonteCarlo::CalculateCollectionArea() const
+{
+    //
+    // first we have to create our empty lists
+    //
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can fill the efficiency histograms
+    //
+    MReadTree reader("Events", fInputFile);
+    tlist.AddToList(&reader);
+
+    MMcCollectionAreaCalc effi;
+    tlist.AddToList(&effi);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Start to loop over all events
+    //
+    if (!magic.Eventloop())
+        return;
+
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayd
+    //
+    plist.FindObject("MHMcCollectionArea")->DrawClone();
+}
+
+void MMonteCarlo::CalculateTriggerRate() const
+{
+    // This macro has two input parameter:
+    // dim : = 0 -> root file with 1 trigger condition.
+    //       > 0 -> number of trigger condition to be analised 
+    //              in multi conditon file.
+    //       < 0 -> selects the -dim trigger condition.
+    //
+    // first we have to create our empty lists
+    //
+    const Int_t dim = GetDim();
+
+    MParList plist;
+    MTaskList tlist;
+
+    //
+    // Setup the parameter list.
+    //  - we do not need to create any other container. All of them
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //
+    //  - we need to create MHMcRate only. The other containers
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //  - MHMcRate must be created by us because we need the pointer
+    //    to it and if it would get created automatically it would also be
+    //    deleted automatically
+    //  - Actually, depending on using a single trigger option MonteCarlo
+    //    file or a multyple trigger option, a MHMcRate or an array of 
+    //    MHMcRate are needed.
+    //
+    plist.AddToList(&tlist);
+
+    //
+    // You don't have to add the MHMcRate container here by hand.
+    // But if you want to print or display these containers later on
+    // it is necessary (Rem: No printing or displaying is done in this
+    // macro yet)
+    //
+    TObjArray hists(MParList::CreateObjList("MHMcRate", dim));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != dim)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    plist.AddToList(&hists);
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can calculate rates, for what the number of
+    //    triggered showers from a empty reflector file for the
+    //    analised trigger conditions should be set (BgR[])
+    //
+    MReadTree reader("Events", fInputFile);
+    tlist.AddToList(&reader);
+
+    Float_t BgR[10]={660,4,0,0,0,0,0,0,0,0};
+
+    MMcTriggerRateCalc crate(dim, 14, BgR, 100000, 2.75, 10.91e-2);
+    tlist.AddToList(&crate);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Start to loop over all events
+    //
+    if (!magic.Eventloop())
+        return;
+
+    TIter Next(&hists);
+    MHMcRate *rate=NULL;
+    while ((rate=(MHMcRate*)Next()))
+        rate->Print();
+}
+
+void MMonteCarlo::CalculateThreshold() const
+{
+    const Int_t dim = GetDim();
+
+    //
+    // This macro fill the container MHMcEnergies using the task
+    // MMcThresholdCalc and shows the results.
+    //
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Setup the parameter list
+    // - You need create the container MHMcEnergies.
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MHMcEnergies
+    //    + If you don't put any dimension to MHMcEnergies it works
+    //      taking only the trigger information from MMcTrig
+    //
+
+    //
+    // Create numtriggerconditions histograms of type MHMcEnergy
+    // and store the histograms in an TObjArray
+    //
+    TObjArray hists(MParList::CreateObjList("MHMcEnergy", dim));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != dim)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    plist.AddToList(&hists);
+
+    //
+    // Setup the task list
+    // - You need the read and the MMcThresholdCalc tasks
+    // - You have to fill the histograms for the Energy threshold
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MMcThresholdCalc
+    //    + If you don't put any dimension to MMcThresholdCalc it works
+    //      like one dimension MMcThresholdCalc
+    //
+    MReadTree        read("Events", fInputFile);
+    MMcThresholdCalc calc(dim);
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&calc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Begin the loop (if the loop wasn't succesfull
+    // don't try to draw the results
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // Now you can display the results
+    //
+    TIter Next(&hists);
+    MHMcRate *hist=NULL;
+    while ((hist=(MHMcRate*)Next()))
+        hist->DrawClone();
+}
+
+// ======================================================================
 
 Bool_t MMonteCarlo::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
-{     
-    if (GET_MSG(msg) == kC_COMMAND &&
-        GET_SUBMSG(msg) == kCM_BUTTON &&
-        parm1 == M_BUTTON_ACTION)
-    {
-        DisplInfo("Put Intelligence here!");
-        return kTRUE;
-    }
+{
+    if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON)
+        switch (parm1)
+        {
+        case M_BUTTON_COLAREA:
+            CalculateCollectionArea();
+            return kTRUE;
+
+        case M_BUTTON_RATE:
+            CalculateTriggerRate();
+            return kTRUE;
+
+        case M_BUTTON_THRESHOLD:
+            CalculateThreshold();
+            return kTRUE;
+        }
 
     return MBrowser::ProcessMessage(msg, parm1, parm2);
Index: trunk/MagicSoft/Mars/mmain/MMonteCarlo.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMonteCarlo.h	(revision 953)
+++ trunk/MagicSoft/Mars/mmain/MMonteCarlo.h	(revision 954)
@@ -10,6 +10,25 @@
 #endif
 
+class TGTextEntry;
+class TGRadioButton;
+
 class MMonteCarlo : public MBrowser
-{ 
+{
+private:
+    TGRadioButton *fRadioButton1;
+    TGRadioButton *fRadioButton2;
+    TGRadioButton *fRadioButton3;
+
+    TGTextEntry   *fNumEntry;
+
+    Int_t GetDim() const;
+
+    void CalculateCollectionArea() const;
+    void CalculateTriggerRate() const;
+    void CalculateThreshold() const;
+
+    void AddButtons();
+    void AddSetupTab();
+
 public:
     MMonteCarlo(const TGWindow *main=NULL, const TGWindow *p=NULL,
Index: trunk/MagicSoft/Mars/mmain/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmain/Makefile	(revision 953)
+++ trunk/MagicSoft/Mars/mmain/Makefile	(revision 954)
@@ -23,5 +23,5 @@
 #
 INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../meventdisp \
-	   -I../mgui -I../mhist
+	   -I../mgui -I../mhist -I../mmontecarlo
 
 #------------------------------------------------------------------------------
