Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7298)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7301)
@@ -18,4 +18,11 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2005/08/24 Thomas Bretz
+
+   * macros/tutorials/threshold.C:
+     - added new example how to calculate the threshold
+
+
 
  2005/08/22 Thomas Bretz
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7298)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7301)
@@ -3,4 +3,6 @@
  *** Version <cvs>
 
+   * general: added new tutorial macro macros/tutorials/threshold.C:
+     how to calculate the threshold
 
 
Index: trunk/MagicSoft/Mars/macros/dohtml.C
===================================================================
--- trunk/MagicSoft/Mars/macros/dohtml.C	(revision 7298)
+++ trunk/MagicSoft/Mars/macros/dohtml.C	(revision 7301)
@@ -133,4 +133,5 @@
     html.Convert("tutorials/pixfirerate.C",     "MARS - Example how to plot the firerate of a pixel (times above threshold)");
     html.Convert("tutorials/pixsatrate.C",      "MARS - Example how to plot the saturation rate of a pixel");
+    html.Convert("tutorials/threshold.C",       "MARS - Example how to calculate the threshold");
     //html.Convert("calibration.C",   "MARS - Example how to use the calibrationa camera ");
     //html.Convert("bootcampstandardanalysis.C", "MARS - Example of the status of the standard analysis at the bootcamp");
Index: trunk/MagicSoft/Mars/macros/tutorials/threshold.C
===================================================================
--- trunk/MagicSoft/Mars/macros/tutorials/threshold.C	(revision 7301)
+++ trunk/MagicSoft/Mars/macros/tutorials/threshold.C	(revision 7301)
@@ -0,0 +1,89 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+
+void threshold()
+{
+    //
+    // This macro fill the container MHMcEnergies using the task
+    // MMcThresholdCalc and shows the results.
+    //
+    MParList parlist;
+
+    MTaskList tasklist;
+    parlist.AddToList(&tasklist);
+
+    // Setup reading task
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+
+    // Setup files to read or monte carlo dataset to be read
+    MDataSet set("~/Software/montecarlo-onoff-lza.txt");
+    set.AddFilesOn(read);
+
+    // If you want to get the threshold after cuts setup your cuts
+    TArrayD cuts(8);
+    cuts[0]=  1.3245;
+    cuts[1]=  0.2087;
+    cuts[2]=  0.2292;
+    cuts[3]=  5.2552;
+    cuts[4]=  0.09893;
+    cuts[5]= -0.08295;
+    cuts[6]=  8.2957;
+    cuts[7]=  0.8677;
+
+    MFMagicCuts mcuts;
+    mcuts.SetThetaCut(MFMagicCuts::kOn);
+    mcuts.SetVariables(cuts);
+
+    MContinue cont(&mcuts);
+    cont.SetInverted();
+
+    // Setup the threshold histogram to be filled
+    MFillH fill("MHThreshold", "", "FillThreshold");
+    fill.SetNameTab("Threshold");
+
+    // If you like to change your input spectrum use this...
+    MMcSpectrumWeight weight;
+    weight.SetNewSlope(-3.5);
+    fill.SetWeight();
+
+    // Setup your tasklist
+    tasklist.AddToList(&read);     // read data
+    tasklist.AddToList(&cont);     // skip background events
+    tasklist.AddToList(&weight);   // caluclate spectral weight
+    tasklist.AddToList(&fill);     // fill histogram
+
+    // Setup the display
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // Setup your eventloop
+    MEvtLoop loop("Threshold");
+    loop.SetParList(&parlist);
+    loop.SetDisplay(d);
+
+    // Start your analysis
+    if (!loop.Eventloop())
+        return;
+}
Index: trunk/MagicSoft/Mars/mhflux/MHThreshold.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHThreshold.cc	(revision 7298)
+++ trunk/MagicSoft/Mars/mhflux/MHThreshold.cc	(revision 7301)
@@ -16,8 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
-!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Thomas Bretz  12/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2005
 !
 !
@@ -27,4 +26,10 @@
 //
 //  MHThreshold
+//
+// Class to calculate the threshold of your analysis.
+//
+// It fills a histogram dN/dE vs E with a fine binning. The threshold is
+// determined as the logarithmic center of the bin with the maximum
+// content.
 //
 //////////////////////////////////////////////////////////////////////////////
