Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 953)
+++ trunk/MagicSoft/Mars/Changelog	(revision 954)
@@ -1,3 +1,26 @@
                                                                   -*-*- END -*-*-
+
+ 2001/09/28: Thomas Bretz
+
+   * macros/getRate.C:
+     - changed TObjArray to a non-pointer object
+     - added Printing of the result at the end of the macro
+     
+   * mhist/MHMcCollectionArea.[h,cc], mhist/MHMcEnergy.[h,cc]:
+     - added DrawClone
+     
+   * mhist/MHMcRate.[h,cc]:
+     - added a dummy for DrawClone
+     
+   * mmain/MMonteCarlo.[cc, h]:
+     - added Gui elements
+     - added CalculateCollectionArea (not yet tested)
+     - added CalculateTriggerRate (not yet tested)
+     - added Threshold (not yet tested)
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - removed output stuff from PostProcessing
+
+
 
  2001/09/27: Thomas Bretz
Index: trunk/MagicSoft/Mars/macros/getRate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/getRate.C	(revision 953)
+++ trunk/MagicSoft/Mars/macros/getRate.C	(revision 954)
@@ -61,10 +61,11 @@
     // macro yet)
     //
-    TObjArray *hists = new TObjArray(MParList::CreateObjList("MHMcRate", dim));
+    TObjArray hists(MParList::CreateObjList("MHMcRate", dim));
+    hists.SetOwner();
 
     //
     // Check if the list really contains the right number of histograms
     //
-    if (hists->GetEntriesFast() != dim)
+    if (hists.GetEntriesFast() != dim)
         return;
 
@@ -72,5 +73,5 @@
     // Add the histograms to the paramater list.
     //
-    parlist.AddToList(hists);
+    parlist.AddToList(&hists);
 
     //
@@ -99,5 +100,10 @@
     // Start to loop over all events
     //
-    magic.Eventloop();
+    if (!magic.Eventloop())
+        return;
 
+    TIter Next(&hists);
+    MHMcRate *rate=NULL;
+    while ((rate=(MHMcRate*)Next()))
+        rate->Print();
 }
Index: trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 953)
+++ trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 954)
@@ -109,4 +109,21 @@
 }
 
+TObject *MHMcCollectionArea::DrawClone(Option_t* option)
+{
+    TCanvas *c=new TCanvas(fHistCol->GetName(), fHistCol->GetTitle());
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHistCol->DrawClone(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
 void MHMcCollectionArea::Draw(Option_t* option)
 {
Index: trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h	(revision 953)
+++ trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h	(revision 954)
@@ -36,5 +36,7 @@
     void DrawAll(Option_t *option = "");
     void DrawSel(Option_t *option = "");
-    void Draw   (Option_t *option = "");
+
+    void Draw(Option_t *option = NULL);
+    TObject *DrawClone(Option_t *option = NULL);
 
     void CalcEfficiency();
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 953)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 954)
@@ -133,9 +133,5 @@
 }
 
-// ------------------------------------------------------------------------
-// 
-// Drawing function. It creates its own canvas.
-//
-void MHMcEnergy::Draw(Option_t *option)
+void MHMcEnergy::DrawLegend() const
 {
     char text[256];
@@ -144,8 +140,4 @@
     const Float_t max = fHist->GetMaximum();
     const Float_t sum = min+max;
-
-    TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
-
-    fHist->Draw(option);
 
     sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV",
@@ -157,7 +149,39 @@
     label->SetBit(kCanDelete);
     label->Draw();
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEnergy::Draw(Option_t *option)
+{
+    TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
+
+    fHist->Draw(option);
+
+    DrawLegend();
 
     c->Modified();
     c->Update();
+}
+
+TObject *MHMcEnergy::DrawClone(Option_t *option)
+{
+    TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHist->DrawClone(option);
+
+    DrawLegend();
+
+    c->Modified();
+    c->Update();
+
+    return c;
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergy.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergy.h	(revision 953)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergy.h	(revision 954)
@@ -29,4 +29,6 @@
     Float_t CalcGaussSigma(TF1 *gauss);
 
+    void DrawLegend() const;
+
 public:
 
@@ -47,4 +49,5 @@
 
     void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "");
     void Print(Option_t* option = NULL);
 
Index: trunk/MagicSoft/Mars/mhist/MHMcRate.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcRate.cc	(revision 953)
+++ trunk/MagicSoft/Mars/mhist/MHMcRate.cc	(revision 954)
@@ -27,4 +27,5 @@
 
 #include "MLog.h"
+#include "MLogManip.h"
 
 ClassImp(MHMcRate);
@@ -35,22 +36,22 @@
     *fTitle = title ? title : "Task to calc the collection area ";
 
-    fPartId=0;              // Type of particle
-
-    fEnergyMax=0.0;         // Maximum Energy in GeV
-    fEnergyMin=1000000.0;   // Minimum Energy in GeV
-
-    fThetaMax=0.0;          // Maximum theta angle of run
-    fThetaMin=370.0;        // Minimum theta angle of run
-    fPhiMax=0.0;            // Maximum phi angle of run
-    fPhiMin=370.0;          // Minimum phi angle of run
-
-    fImpactMax=0.0;         // Maximum impact parameter
-    fImpactMin=100000.0;    // Minimum impact parameter
-
-    fBackTrig=-1.0;         // Number of triggers from background
-    fBackSim=-1.0;          // Number of simulated showers for the background
-
-    fTriggerRate= -1.0;        // Trigger rate in Hz
-    fTriggerRateError= -1.0;   // Estimated error for the trigger rate in Hz
+    fPartId=0;               // Type of particle
+
+    fEnergyMax=0.0;          // Maximum Energy in GeV
+    fEnergyMin=1000000.0;    // Minimum Energy in GeV
+
+    fThetaMax=0.0;           // Maximum theta angle of run
+    fThetaMin=370.0;         // Minimum theta angle of run
+    fPhiMax=0.0;             // Maximum phi angle of run
+    fPhiMin=370.0;           // Minimum phi angle of run
+
+    fImpactMax=0.0;          // Maximum impact parameter
+    fImpactMin=100000.0;     // Minimum impact parameter
+
+    fBackTrig=-1.0;          // Number of triggers from background
+    fBackSim=-1.0;           // Number of simulated showers for the background
+
+    fTriggerRate= -1.0;      // Trigger rate in Hz
+    fTriggerRateError= -1.0; // Estimated error for the trigger rate in Hz
 }
 
@@ -67,6 +68,6 @@
     fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
 
-    fShowerRate= -1.0;        // Showers rate in Hz
-    fShowerRateError=0.0;     // Estimated error of shower rate in Hz
+    fShowerRate= -1.0;      // Showers rate in Hz
+    fShowerRateError=0.0;   // Estimated error of shower rate in Hz
 }
 
@@ -82,9 +83,9 @@
     Init(name, title);
 
-    fSpecIndex=0.0;         // dn/dE = k * e^{- fSpecIndex}
-    fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
-
-    fShowerRate= showrate;               // Showers rate in Hz
-    fShowerRateError=sqrt(showrate);     // Estimated error of shower rate in Hz
+    fSpecIndex=0.0;                  // dn/dE = k * e^{- fSpecIndex}
+    fFlux0=-1.0;                     // dn/dE = fFlux0 * E^{-a}
+
+    fShowerRate= showrate;           // Showers rate in Hz
+    fShowerRateError=sqrt(showrate); // Estimated error of shower rate in Hz
 }
 
@@ -133,18 +134,17 @@
                                 Float_t phi, Float_t impact)
 { 
-  // It updates the limit values 
-
-  if (fThetaMax<theta) fThetaMax=theta;
-  if (fThetaMin>theta) fThetaMin=theta;
-
-  if (fPhiMax<phi) fPhiMax=phi;
-  if (fPhiMin>phi) fPhiMin=phi;
-
-  if (fImpactMax<impact) fImpactMax=impact;
-  if (fImpactMin>impact) fImpactMin=impact;
-
-  if (fEnergyMax<energy) fEnergyMax=energy;
-  if (fEnergyMin>energy) fEnergyMin=energy;
-
+    // It updates the limit values
+
+    if (fThetaMax<theta) fThetaMax=theta;
+    if (fThetaMin>theta) fThetaMin=theta;
+
+    if (fPhiMax<phi) fPhiMax=phi;
+    if (fPhiMin>phi) fPhiMin=phi;
+
+    if (fImpactMax<impact) fImpactMax=impact;
+    if (fImpactMin>impact) fImpactMin=impact;
+
+    if (fEnergyMax<energy) fEnergyMax=energy;
+    if (fEnergyMin>energy) fEnergyMin=energy;
 } 
 
@@ -180,10 +180,10 @@
     if(fBackTrig<0){
         fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
-                              (anal2*anal2*1/(fBackSim*back2*back2)));
+                                 (anal2*anal2*1/(fBackSim*back2*back2)));
         fBackTrig=0;
     }
     else
         fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
-                              (anal2*anal2*fBackTrig/(back2*back2)));
+                                 (anal2*anal2*fBackTrig/(back2*back2)));
 
     fTriggerRate = trig*fShowerRate/simu + anal2*fBackTrig/back2;
@@ -205,5 +205,11 @@
 //
 void MHMcRate::Draw(Option_t *)
-{ 
-  *fLog << "To be iplemented" << endl;
+{
+    *fLog << dbginf << "To be iplemented" << endl;
+}
+
+TObject *MHMcRate::DrawClone(Option_t *)
+{
+    *fLog << dbginf << "To be iplemented" << endl;
+    return NULL;
 } 
Index: trunk/MagicSoft/Mars/mhist/MHMcRate.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcRate.h	(revision 953)
+++ trunk/MagicSoft/Mars/mhist/MHMcRate.h	(revision 954)
@@ -56,5 +56,7 @@
 
     void Print(Option_t *o=NULL);
+
     void Draw(Option_t *o=NULL);
+    TObject *DrawClone(Option_t *o=NULL);
 
     ClassDef(MHMcRate, 1)  //  Data Container to calculate Collection Area
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
 
 #------------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 953)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 954)
@@ -158,5 +158,5 @@
 //  MHMcRate container.
 //
-Bool_t MMcTriggerRateCalc::Process ()
+Bool_t MMcTriggerRateCalc::Process()
 {
     //  Counting analysed and simulated showers
@@ -189,19 +189,16 @@
 //  The PostProcess-function calculates and shows the trigger rate
 //
-Bool_t MMcTriggerRateCalc::PostProcess ()
+Bool_t MMcTriggerRateCalc::PostProcess()
 {
     // Computing trigger rate and showing it
-    for(int i=0; i<fDimension; i++)
+    for (int i=0; i<fDimension; i++)
     {
         MHMcRate &rate = *GetRate(i);
 
         rate.CalcRate(fTrigger[i], fAnalShow, fShowers);
-        rate.Print();
-        rate.Draw("S");
+        // rate.Print();
+        // rate.Draw("S");
     }
 
     return kTRUE;
 }
-
-
-
