Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6972)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6973)
@@ -21,4 +21,41 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2005/04/22 Markus Meyer
+
+    * mmuon/MMuonSetup[.h.cc]: 
+      - new container class for muon parameters
+        which are not changing from event to event
+        (setup parameters for the analysis). These
+        parameters were stored in MMuonCalibPar before
+      
+    * mmuon/MMuonCalibPar[.h.cc]:
+      - changed MCerPhotEvt and MCerphotPix to MSignalCam
+        and MSignalPix to read the new format
+      - removed the setup parameters (stored now in 
+        MMuonSetup)
+      - removed all the sanity checks
+      - removed pre-cuts
+      - cuts in process, to save only muon-like events
+      
+    * mmuon/MMuonCalibParCalc[.h.cc]:
+      - changed MCerPhotEvt and MCerphotPix to MSignalCam
+        and MSignalPix to read the new format
+      - removed pre-cuts
+      
+    * mmuon/MMuonSearchPar[.h.cc]:
+      - changed MCerPhotEvt and MCerphotPix to MSignalCam
+        and MSignalPix to read the new format
+      - 
+	
+    * mmuon/MMuonSearchParCalc[.h.cc]:
+      - changed MCerPhotEvt and MCerphotPix to MSignalCam
+        and MSignalPix to read the new format
+	
+    * mmuon/MHMuonPar[.h.cc]:
+      - new histgram class, plots different muon 
+        parameters
+
+
 
  2005/04/21 Daniela Dorner
Index: trunk/MagicSoft/Mars/mmuon/MHMuonPar.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MHMuonPar.cc	(revision 6973)
+++ trunk/MagicSoft/Mars/mmuon/MHMuonPar.cc	(revision 6973)
@@ -0,0 +1,222 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Wolfgang Wittek, 03/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Markus Meyer, 02/2005 <mailto:meyer@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHMuonPar
+// This class is a histogram class for displaying muonparameters.
+// The folowing histgrams will be plotted:
+// - Radius (TH1F)
+// - ArcWidth (TH1F)
+// - ArcWidth/Radius vs Radius (TProfile) (it is the energy dependent
+//   relative broadening of the muon ring)
+// - Size Vs Radius
+//
+// Inputcontainer:
+// MMuonSearchPar
+// MMuonCalibPar
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMuonPar.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TCanvas.h>
+#include <TProfile.h>
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MHMuonPar.h"
+#include "MMuonSearchPar.h"
+#include "MMuonCalibPar.h"
+
+ClassImp(MHMuonPar);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms 
+//
+MHMuonPar::MHMuonPar(const char *name, const char *title):fGeomCam(NULL), fMuonSearchPar(NULL),
+    fMuonCalibPar(NULL)
+{
+    fName  = name  ? name  : "MHMuonPar";
+    fTitle = title ? title : "Histograms of muon parameters";
+
+    fHistRadius.SetName("Radius");
+    fHistRadius.SetTitle("Radius");
+    fHistRadius.SetXTitle("Radius[deg]");
+    fHistRadius.SetYTitle("Counts");
+    fHistRadius.SetDirectory(NULL);
+    fHistRadius.UseCurrentStyle();
+    fHistRadius.SetFillStyle(4000);
+
+    fHistArcWidth.SetName("ArcWidth");
+    fHistArcWidth.SetTitle("ArcWidth");
+    fHistArcWidth.SetXTitle("ArcWidth[deg]");
+    fHistArcWidth.SetYTitle("Counts");
+    fHistArcWidth.SetDirectory(NULL);
+    fHistArcWidth.UseCurrentStyle();
+    fHistArcWidth.SetFillStyle(4000);
+
+    fHistBroad.SetName("Ringbroadening");
+    fHistBroad.SetTitle("Ringbroadening");
+    fHistBroad.SetXTitle("Radius[deg]");
+    fHistBroad.SetYTitle("ArcWidth/Radius");
+    fHistBroad.SetDirectory(NULL);
+    fHistBroad.UseCurrentStyle();
+    fHistBroad.SetFillStyle(4000);
+
+    fHistSize.SetName("SizeVsRadius");
+    fHistSize.SetXTitle("Radius");
+    fHistSize.SetYTitle("MuonSize");
+    fHistSize.SetDirectory(NULL);
+    fHistSize.UseCurrentStyle();
+    fHistSize.SetFillStyle(4000);
+
+    MBinning bins;
+
+    bins.SetEdges(20, 0.5, 1.5);
+    bins.Apply(fHistRadius);
+
+    bins.SetEdges(60, 0., 0.3);
+    bins.Apply(fHistArcWidth);
+
+    bins.SetEdges(20, 0.5, 1.5);
+    bins.Apply(fHistBroad);
+
+    bins.SetEdges(20, 0.5, 1.5);
+    bins.Apply(fHistSize);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning
+//
+Bool_t MHMuonPar::SetupFill(const MParList *plist)
+{
+    fGeomCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fGeomCam)
+    {
+        *fLog << warn << "MGeomCam not found... abort." << endl;
+        return kFALSE;
+    }
+    fMuonSearchPar = (MMuonSearchPar*)plist->FindObject("MMuonSearchPar");
+    if (!fMuonSearchPar)
+    {
+        *fLog << warn << "MMuonSearchPar not found... abort." << endl;
+        return kFALSE;
+    }
+    fMuonCalibPar = (MMuonCalibPar*)plist->FindObject("MMuonCalibPar");
+    if (!fMuonCalibPar)
+    {
+        *fLog << warn << "MMuonCalibPar not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = fGeomCam->GetConvMm2Deg();
+
+    ApplyBinning(*plist, "Radius", &fHistRadius);
+
+    ApplyBinning(*plist, "ArcWidth",  &fHistArcWidth);
+
+    ApplyBinning(*plist, "Ringbroadening",  &fHistBroad);
+
+    ApplyBinning(*plist, "SizeVsRadius",  &fHistSize);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MMuonCalibPar and
+// MMuonSearchPar container.
+//
+Bool_t MHMuonPar::Fill(const MParContainer *par, const Stat_t w)
+{
+    fHistRadius.Fill(fMm2Deg*fMuonSearchPar->GetRadius(), w);
+
+    fHistArcWidth.Fill(fMuonCalibPar->GetArcWidth(), w);
+
+    fHistBroad.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
+                    fMuonCalibPar->GetArcWidth()/(fMm2Deg*fMuonSearchPar->GetRadius()), w);
+
+    fHistSize.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
+                   fMuonCalibPar->GetMuonSize(), w);
+
+    return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the two histograms into it.
+// Be careful: The histograms belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHMuonPar::Draw(Option_t *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fHistRadius.Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fHistArcWidth.Draw();
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fHistSize.Draw();
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fHistBroad.Draw();
+}
+
+TH1 *MHMuonPar::GetHistByName(const TString name)
+{
+    if (name.Contains("Radius", TString::kIgnoreCase))
+        return &fHistRadius;
+    if (name.Contains("ArcWidth", TString::kIgnoreCase))
+        return &fHistArcWidth;
+    return NULL;
+}
+
Index: trunk/MagicSoft/Mars/mmuon/MHMuonPar.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MHMuonPar.h	(revision 6973)
+++ trunk/MagicSoft/Mars/mmuon/MHMuonPar.h	(revision 6973)
@@ -0,0 +1,61 @@
+#ifndef MARS_MHMuonPar
+#define MARS_MHMuonPar
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef ROOT_TProfile
+#include <TProfile.h>
+#endif
+
+class MHillas;
+class MMuonSearchPar;
+class MMuonCalibPar;
+class MGeomCam;
+
+class MHMuonPar : public MH
+{
+private:
+    TH1F fHistRadius;  //
+
+    TH1F fHistArcWidth;   //
+
+    TProfile fHistBroad;  // Area of used pixels
+
+    TProfile fHistSize;      // [ratio] concentration ratio: sum of the two highest pixels / fSize
+
+    MGeomCam *fGeomCam; //! Camera geometry for plots (for the moment this is a feature for a loop only!)
+
+    MMuonSearchPar *fMuonSearchPar;//!
+
+    MMuonCalibPar *fMuonCalibPar;//!
+
+    Float_t fMm2Deg;
+
+public:
+    MHMuonPar(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F &GetHistRadius()  { return fHistRadius; }
+
+    TH1F &GetHistArcWidth()   { return fHistArcWidth; }
+
+    TProfile &GetHistBroad()  { return fHistBroad; }
+
+    TProfile &GetHistSize()      { return fHistSize; }
+
+    void Draw(Option_t *opt="");
+
+    ClassDef(MHMuonPar, 1) // Histograms of new image parameters
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.cc	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.cc	(revision 6973)
@@ -38,5 +38,5 @@
 //  Input Containers:
 //   [MGeomCam]
-//   [MCerPhotEvt]
+//   [MSignalCam]
 //   [MMuonSearchPar]
 //
@@ -48,6 +48,6 @@
 #include "MLog.h"
 #include "MLogManip.h"
-#include "MCerPhotEvt.h"
-#include "MCerPhotPix.h"
+#include "MSignalCam.h"
+#include "MSignalPix.h"
 #include "MMuonSearchPar.h"
 #include "MBinning.h"
@@ -85,13 +85,4 @@
     fHistWidth->UseCurrentStyle();
 
-    fMargin = 60.;  // in mm
-    fArcPhiThres  = 100.;
-    fArcWidthThres  = 100.;
-    fArcPhiBinNum = 20;
-    fArcPhiHistStartVal = -180.; // deg.
-    fArcPhiHistEndVal   = 180.;  // deg.
-    fArcWidthBinNum = 28;
-    fArcWidthHistStartVal = 0.3; // deg.
-    fArcWidthHistEndVal   = 1.7; // deg.
 }
 
@@ -137,5 +128,2 @@
 }
 
-
-
-
Index: trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.h	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.h	(revision 6973)
@@ -10,5 +10,5 @@
 #endif
 
-class MCerPhotEvt;
+class MSignalCam;
 class MMuonSearchPar;
 
@@ -23,9 +23,6 @@
   Float_t fMuonSize;      // A SIZE of muon which is defined as a SIZE around the estimated circle
   Float_t fEstImpact;     // An estimated impact parameter from the photon distribution along the arc image
-  Float_t fMargin;        // margin to evaluate muons [mm]. The defaut value is 60 mm, corresponding to 0.2 deg. This value can be changed by using the function of SetMargin
   Bool_t  fUseUnmap;      // This is a flag to know the Unmapped pixels are used. Refer to the class of MImgCleanStd
   Float_t fPeakPhi;       // The angle which indicates the peak position in the estimated circle
-  Float_t fArcPhiThres;   // The threshold value to define arc phi
-  Float_t fArcWidthThres; // The threshold value to define arc width
 
 public:
@@ -33,11 +30,4 @@
   ~MMuonCalibPar();
   
-  Int_t   fArcPhiBinNum;         // The bin number for the histogram of arc phi. You may change this value. However, if you change this, YOU ALSO HAVE TO CHANGE THE THRESHOLD VALUE TO GET ARC LENGTH.
-  Int_t   fArcWidthBinNum;       // The bin number for the histogram of arc wid
-  Float_t fArcPhiHistStartVal;   // The starting value for the histogram of arc phi
-  Float_t fArcPhiHistEndVal;     // The end value for the histogram of arc phi
-  Float_t fArcWidthHistStartVal; // The starting value for the histogram of arc width
-  Float_t fArcWidthHistEndVal;   // The end value for the histogram of arc width
-
   TH1F *fHistPhi;   // Histogram of photon distribution along the arc.
   TH1F *fHistWidth; // Histogram of radial photon distribution of the arc.
@@ -50,13 +40,8 @@
   Float_t GetChiArcPhi()      const { return fChiArcPhi; }
   Float_t GetChiArcWidth()    const { return fChiArcWidth; }
-  Float_t GetMargin()         const { return fMargin; }
   Float_t GetMuonSize()       const { return fMuonSize; }
   Float_t GetEstImpact()      const { return fEstImpact; }
   Bool_t  IsUseUnmap()        const { return fUseUnmap; }
   Float_t GetPeakPhi()        const { return fPeakPhi; }
-  Float_t GetArcPhiThres()    const { return fArcPhiThres; }
-  Float_t GetArcWidthThres()  const { return fArcWidthThres; }
-  Float_t GetArcPhiBinNum()   const { return fArcPhiBinNum; }
-  Float_t GetArcWidthBinNum() const { return fArcWidthBinNum; }
   TH1F    *GetHistPhi()       { return fHistPhi; }
   TH1F    *GetHistWidth()     { return fHistWidth; }
@@ -67,13 +52,8 @@
   void    SetChiArcPhi(Float_t chi)       { fChiArcPhi = chi; }
   void    SetChiArcWidth(Float_t chi)     { fChiArcWidth = chi; }
-  void    SetMargin(Float_t margin)       { fMargin = margin; }
   void    SetMuonSize(Float_t size)       { fMuonSize = size; }
   void    SetEstImpact(Float_t impact)    { fEstImpact = impact; }
   void    SetUseUnmap()                   { fUseUnmap = kTRUE; }
   void    SetPeakPhi(Float_t phi)         { fPeakPhi = phi; }
-  void    SetArcPhiThres(Float_t thres)   { fArcPhiThres = thres; }
-  void    SetArcWidthThres(Float_t thres) { fArcWidthThres = thres; }
-  void    SetArcPhiBinNum(Int_t num)      { fArcPhiBinNum = num; }
-  void    SetArcWidthBinNum(Int_t num)    { fArcWidthBinNum = num; }
   
   void    Print(Option_t *opt=NULL) const;
Index: trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.cc	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.cc	(revision 6973)
@@ -99,5 +99,5 @@
 //  Input Containers:
 //   [MGeomCam]
-//   [MCerPhotEvt]
+//   [MSignalCam]
 //   [MMuonSearchPar]
 //
@@ -120,7 +120,8 @@
 #include "MGeomPix.h"
 #include "MSrcPosCam.h"
-#include "MCerPhotEvt.h"
+#include "MSignalCam.h"
 #include "MMuonSearchPar.h"
 #include "MMuonCalibPar.h"
+#include "MMuonSetup.h"
 #include "MLog.h"
 #include "MLogManip.h"
@@ -139,21 +140,9 @@
 //
 MMuonCalibParCalc::MMuonCalibParCalc(const char *name, const char *title)
-  : fNameCerPhot("MCerPhotEvt")
 {
     fName  = name  ? name  : gsDefName.Data();
     fTitle = title ? title : gsDefTitle.Data();
 
-    fPreCuts[0]     = 180.;
-    fPreCuts[1]     = 400.;
-    fPreCuts[2]     = 50.;
-    fPreCuts[3]     = 2000.;
-    fPreCuts[4]     = 150.;
-
-    fMargin = 60.;
-    fArcPhiThres = 100.;
-    fArcWidthThres = 100.;
-
     fEnableImpactCalc = kFALSE; // By default the calculation of impact parameter is skipped.
-    fDisablePreCuts =   kFALSE; // By default the pre cuts will be applied.
 }
 
@@ -162,8 +151,8 @@
 Int_t MMuonCalibParCalc::PreProcess(MParList *pList)
 {
-  fCerPhotEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber(fNameCerPhot), "MCerPhotEvt");
-  if (!fCerPhotEvt)
-    {
-      *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+  fSignalCam = (MSignalCam*)pList->FindObject("MSignalCam");
+  if (!fSignalCam)
+    {
+      *fLog << dbginf << "MSignalCam not found... aborting." << endl;
       return kFALSE;
     }
@@ -178,15 +167,13 @@
   fMuonCalibPar = (MMuonCalibPar*)pList->FindCreateObj("MMuonCalibPar", "MMuonCalibPar");
   if (!fMuonCalibPar)
-    {
-      *fLog << dbginf << "MMuonCalibPar missing in Parameter List... aborting." << endl;
       return kFALSE;
-    }
   
   fMuonSearchPar = (MMuonSearchPar*)pList->FindCreateObj("MMuonSearchPar", "MMuonSearchPar");
   if (!fMuonSearchPar)
-    {
-      *fLog << dbginf << "MMuonSearchPar missing in Parameter List... aborting." << endl;
       return kFALSE;
-    }
+
+  fMuonSetup = (MMuonSetup*)pList->FindCreateObj("MMuonSetup", "MMuonSetup");
+  if (!fMuonSetup)
+      return kFALSE;
   
   return kTRUE;
@@ -203,21 +190,21 @@
   Float_t MuonSize = 0.;
 
-  Int_t binnumphi = fMuonCalibPar->fArcPhiBinNum;
-  Int_t binnumwid = fMuonCalibPar->fArcWidthBinNum;
+  Int_t binnumphi = fMuonSetup->fArcPhiBinNum;
+  Int_t binnumwid = fMuonSetup->fArcWidthBinNum;
 
   // preparation for a histgram
   MBinning binsphi;
   binsphi.SetEdges(binnumphi, 
-		   fMuonCalibPar->fArcPhiHistStartVal, 
-		   fMuonCalibPar->fArcPhiHistEndVal);
+		   fMuonSetup->fArcPhiHistStartVal,
+		   fMuonSetup->fArcPhiHistEndVal);
   binsphi.Apply(*(fMuonCalibPar->fHistPhi));
 
   MBinning binswid;
   binswid.SetEdges(binnumwid, 
-		   fMuonCalibPar->fArcWidthHistStartVal, 
-		   fMuonCalibPar->fArcWidthHistEndVal);
+		   fMuonSetup->fArcWidthHistStartVal,
+		   fMuonSetup->fArcWidthHistEndVal);
   binswid.Apply(*(fMuonCalibPar->fHistWidth));
 
-  const Int_t entries = (*fCerPhotEvt).GetNumPixels();
+  const Int_t entries = (*fSignalCam).GetNumPixels();
 
   // the position of the center of a muon ring
@@ -227,7 +214,7 @@
   for (Int_t i=0; i<entries; i++ )
     {
-      MCerPhotPix &pix = (*fCerPhotEvt)[i];
-      
-      const MGeomPix &gpix = (*fGeomCam)[pix.GetPixId()];
+      MSignalPix &pix = (*fSignalCam)[i];
+      
+      const MGeomPix &gpix = (*fGeomCam)[i/*pix.GetPixId()*/];
       
       const Float_t dx = gpix.GetX() - cenx;
@@ -241,6 +228,6 @@
       
       // if the signal is not near the estimated circle, it is ignored.
-      if(dist < (*fMuonSearchPar).GetRadius() + fMuonCalibPar->GetMargin() 
-	 && dist > (*fMuonSearchPar).GetRadius() - fMuonCalibPar->GetMargin())
+      if(dist < (*fMuonSearchPar).GetRadius() + fMuonSetup->GetMargin()
+	 && dist > (*fMuonSearchPar).GetRadius() - fMuonSetup->GetMargin())
 	{
 	  // check whether ummapped pixel is used or not.
@@ -257,5 +244,5 @@
       // use only the inner pixles. This is geometry dependent. This has to
       // be fixed!
-      if(pix.GetPixId()>397)
+      if(i>397)
 	continue;  
       
@@ -298,8 +285,8 @@
 void MMuonCalibParCalc::CalcPhi()
 {
-  Float_t thres = fMuonCalibPar->GetArcPhiThres();
-  Float_t startval = fMuonCalibPar->fArcPhiHistStartVal;
-  Float_t endval = fMuonCalibPar->fArcPhiHistEndVal;
-  Int_t   binnum = fMuonCalibPar->fArcPhiBinNum;
+  Float_t thres = fMuonSetup->GetArcPhiThres();
+  Float_t startval = fMuonSetup->fArcPhiHistStartVal;
+  Float_t endval = fMuonSetup->fArcPhiHistEndVal;
+  Int_t   binnum = fMuonSetup->fArcPhiBinNum;
 
   Float_t convbin2val = (endval-startval)/(Float_t)binnum;
@@ -458,8 +445,8 @@
 Float_t MMuonCalibParCalc::CalcWidth()
 {
-  Float_t startval = fMuonCalibPar->fArcWidthHistStartVal;
-  Float_t endval = fMuonCalibPar->fArcWidthHistEndVal;
-  Int_t   binnum = fMuonCalibPar->fArcWidthBinNum;
-  Float_t thres = fMuonCalibPar->GetArcWidthThres();
+  Float_t startval = fMuonSetup->fArcWidthHistStartVal;
+  Float_t endval = fMuonSetup->fArcWidthHistEndVal;
+  Int_t   binnum = fMuonSetup->fArcWidthBinNum;
+  Float_t thres = fMuonSetup->GetArcWidthThres();
 
   Float_t convbin2val = (endval - startval)
@@ -500,4 +487,8 @@
     TF1 f1("f1","gaus",startfitval,endfitval);
 
+    // options : N  do not store the function, do not draw
+    //           I  use integral of function in bin rather than value at bin center
+    //           R  use the range specified in the function range
+    //           Q  quiet mode
     fMuonCalibPar->fHistWidth->Fit("f1","QR","",startfitval,endfitval);
     
@@ -515,29 +506,6 @@
 //  Calculation of muon parameters
 //
-Int_t MMuonCalibParCalc::Calc(const Float_t *cuts)
-{
-  // sanity check
-  if((*fCerPhotEvt).GetNumPixels() < 3)
-    return kCONTINUE;
-
-  // If an event does not seem to be like muon, the calculation will be skipped.
-  if((*fMuonSearchPar).IsNoMuon()) 
-    return kCONTINUE; 
-
-  // Pre Cuts 1
-  if(!fDisablePreCuts)
-    {
-      if((*fMuonSearchPar).GetRadius() < cuts[0] || (*fMuonSearchPar).GetRadius() > cuts[1])
-	{
-	  (*fMuonSearchPar).SetNoMuon();
-	  return kCONTINUE;
-	}
-      if((*fMuonSearchPar).GetDeviation() > cuts[2])
-	{
-	  (*fMuonSearchPar).SetNoMuon();
-	  return kCONTINUE;
-	}
-    }
-
+Int_t MMuonCalibParCalc::Calc()
+{
   // initialization
   (*fMuonCalibPar).Reset();
@@ -549,45 +517,21 @@
   CalcPhi();
 
-  // Pre Cuts 2
-  if(!fDisablePreCuts)
-    {
-      if(fMuonCalibPar->GetMuonSize() < cuts[3] 
-	 || fMuonCalibPar->GetArcPhi() < cuts[4])
-	{
-	  (*fMuonSearchPar).SetNoMuon();
-	  return kCONTINUE;
-	}
-    }
-
   // Calculation of Arc Width etc...
-  fMuonCalibPar->SetArcWidth(CalcWidth()); 
+  fMuonCalibPar->SetArcWidth(CalcWidth());
+
+  if(fMuonCalibPar->GetArcPhi()>160 && fMuonSearchPar->GetRadius()>170 &&
+     fMuonSearchPar->GetRadius()<400 && fMuonSearchPar->GetDeviation()<50)
+      fMuonCalibPar->SetReadyToSave();
   
   return kTRUE;
 } 
 
-
 // -------------------------------------------------------------------------
 //
 Int_t MMuonCalibParCalc::Process()
 {
-  fMuonCalibPar->SetMargin(fMargin);
-  fMuonCalibPar->SetArcPhiThres(fArcPhiThres);
-  fMuonCalibPar->SetArcWidthThres(fArcWidthThres);
-
-  if(!Calc(fPreCuts))
-    return kCONTINUE;
+
+  Calc();
 
   return kTRUE;
 }
-
-void MMuonCalibParCalc::SetPreCuts
-(Float_t radcutlow, Float_t radcuthigh, Float_t devcuthigh,
- Float_t musizecutlow, Float_t arcphicutlow)
-{
-  fPreCuts[0] = radcutlow;
-  fPreCuts[1] = radcuthigh;
-  fPreCuts[2] = devcuthigh;
-  fPreCuts[3] = musizecutlow;
-  fPreCuts[4] = arcphicutlow;
-}
-
Index: trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.h	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonCalibParCalc.h	(revision 6973)
@@ -10,5 +10,6 @@
 class MSrcPosCam;
 class MGeomCam;
-class MCerPhotEvt;
+class MSignalCam;
+class MMuonSetup;
 
 class MMuonCalibParCalc : public MTask
@@ -16,33 +17,18 @@
 private:
     MGeomCam       *fGeomCam;
-    MCerPhotEvt    *fCerPhotEvt;
+    MSignalCam     *fSignalCam;
     MMuonCalibPar  *fMuonCalibPar;  
     MMuonSearchPar *fMuonSearchPar; 
+    MMuonSetup     *fMuonSetup;
 
-    Float_t fMargin;           // margin to evaluate muons [mm]. The defaut value is 60 mm, corresponding to 0.2 deg. This value can be changed by using the function of SetMargin
-    Float_t fArcPhiThres;     // The threshold value to define arc phi
-    Float_t fArcWidthThres;   // The threshold value to define arc width
     Bool_t fEnableImpactCalc; // If true, the impact calculation will be done, which consumes a lot of time.
-    Bool_t fDisablePreCuts;   // If true, the pre cuts to select muons for the calibration will be disabled.
-
-    Float_t fPreCuts[5];  // The values for pre cuts.
 
     Int_t PreProcess(MParList *plist);
     Int_t Process();
 
-    TString fNameCerPhot;
-
 public:
     MMuonCalibParCalc(const char *name=NULL, const char *title=NULL);
 
-    void SetMargin(Float_t margin)       { fMargin = margin; }
-    void SetArcPhiThres(Float_t thres)   { fArcPhiThres = thres; }
-    void SetArcWidthThres(Float_t thres) { fArcWidthThres = thres; }
     void EnableImpactCalc()              { fEnableImpactCalc = kTRUE; }
-    void DisablePreCuts()                { fDisablePreCuts = kTRUE; }
-    void SetPreCuts(Float_t radcutlow, Float_t radcuthigh, Float_t devcuthigh,
-		    Float_t musizecutlow, Float_t arcphicutlow);
-
-    void SetNameCerPhotEvt(const char *name) { fNameCerPhot = name; }
 
     void FillHist();
@@ -50,5 +36,5 @@
     void CalcImpact(Int_t effbinnum, Float_t startfitval, Float_t endfitval);
     Float_t CalcWidth();
-    Int_t   Calc(const Float_t *cuts);
+    Int_t   Calc();
 
     ClassDef(MMuonCalibParCalc, 0) // task to calculate muon parameters
@@ -56,3 +42,2 @@
 
 #endif
-
Index: trunk/MagicSoft/Mars/mmuon/MMuonSearchPar.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonSearchPar.cc	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonSearchPar.cc	(revision 6973)
@@ -71,5 +71,5 @@
 //   [MGeomCam]
 //   [MHillas]
-//   [MCerPhotEvt]
+//   [MSignalCam]
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -83,6 +83,6 @@
 #include "MGeomCam.h"
 #include "MGeomPix.h"
-#include "MCerPhotEvt.h"
-#include "MCerPhotPix.h"
+#include "MSignalPix.h"
+#include "MSignalCam.h"
 
 using namespace std;
@@ -108,5 +108,4 @@
   fCenterX = 0.;
   fCenterY = 0.;
-  fNoMuon = kFALSE;
 }
 
@@ -138,5 +137,5 @@
 //  and its RMS for the input position.
 //
-Bool_t MMuonSearchPar::CalcRadius(const MGeomCam &geom, const MCerPhotEvt &evt,
+Bool_t MMuonSearchPar::CalcRadius(const MGeomCam &geom, const MSignalCam &evt,
       Float_t x, Float_t y, Float_t &r, Float_t &sigma)
 {
@@ -146,10 +145,10 @@
 
   for (Int_t i=0; i<entries; i++ ){
-    const MCerPhotPix &pix = evt[i];
+    const MSignalPix &pix = evt[i];
 
     if (!pix.IsPixelUsed())
       continue;
 
-    const MGeomPix &gpix = geom[pix.GetPixId()];
+    const MGeomPix &gpix = geom[i/*pix.GetPixId()*/];
 
     tmp=TMath::Sqrt((gpix.GetX()-x)*(gpix.GetX()-x)
@@ -180,5 +179,5 @@
 //
 void MMuonSearchPar::CalcMinimumDeviation
-( const MGeomCam &geom, const MCerPhotEvt &evt, Float_t x, Float_t y, 
+( const MGeomCam &geom, const MSignalCam &evt, Float_t x, Float_t y,
  Float_t xcog, Float_t ycog, Float_t sigma, Float_t &opt_rad, 
  Float_t &new_sigma, Float_t &newx, Float_t &newy )
@@ -198,5 +197,4 @@
 	  newx=x; 
 	  newy=y;
-	  fNoMuon = kTRUE;
 	  break;
       }
@@ -253,5 +251,5 @@
 //
 void MMuonSearchPar::Calc
-(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hillas)
+(const MGeomCam &geom, const MSignalCam &evt, const MHillas &hillas)
 {
   Reset();
@@ -283,5 +281,5 @@
   fCenterY = newy;
   
-  SetReadyToSave();
+  //SetReadyToSave();
 } 
 
Index: trunk/MagicSoft/Mars/mmuon/MMuonSearchPar.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonSearchPar.h	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonSearchPar.h	(revision 6973)
@@ -8,5 +8,5 @@
 class MHillas;
 class MGeomCam;
-class MCerPhotEvt;
+class MSignalCam;
 
 class MMuonSearchPar : public MParContainer
@@ -17,5 +17,4 @@
     Float_t fCenterX;   // An estimated center position in X of the muon ring [mm]
     Float_t fCenterY;   // An estimated center position in Y of the muon ring [mm]
-    Bool_t  fNoMuon;    // if the radius is estimated above 600 mm (2 deg.), assumed it's not muon. Later on, at the stage of MMuonCalibParCalc, this flag will be changed if the task judge the event as no muon.
 
 public:
@@ -28,16 +27,14 @@
     Float_t GetCenterX()   const { return fCenterX; }
     Float_t GetCenterY()   const { return fCenterY; }
-    Bool_t  IsNoMuon()     const { return fNoMuon; }
-    void    SetNoMuon()          { fNoMuon = kTRUE; }
 
     void   CalcTempCenter(const MHillas &hillas, Float_t &xtmp1, 
 			  Float_t &ytmp1, Float_t &xtmp2, Float_t &ytmp2);
-    Bool_t CalcRadius(const MGeomCam &geom, const MCerPhotEvt &evt, Float_t x,
+    Bool_t CalcRadius(const MGeomCam &geom, const MSignalCam &evt, Float_t x,
 		      Float_t y, Float_t &r, Float_t &sigma);
-    void   CalcMinimumDeviation(const MGeomCam &geom, const MCerPhotEvt &evt, 
+    void   CalcMinimumDeviation(const MGeomCam &geom, const MSignalCam &evt,
 			     Float_t x, Float_t y, Float_t xcog, 
 			     Float_t ycog, Float_t sigma, Float_t &opt_rad, 
 			     Float_t &new_sigma, Float_t &newx, Float_t &newy);
-    void   Calc(const MGeomCam &geom, const MCerPhotEvt &evt,
+    void   Calc(const MGeomCam &geom, const MSignalCam &evt,
 		const MHillas &hillas);
 
Index: trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.cc	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.cc	(revision 6973)
@@ -43,5 +43,5 @@
 //   [MGeomCam]
 //   [MHillas]
-//   [MCerPhotEvt]
+//   [MSignalCam]
 //
 //  Output Containers:
@@ -55,5 +55,5 @@
 #include "MParList.h"
 #include "MGeomCam.h"
-#include "MCerPhotEvt.h"
+#include "MSignalCam.h"
 #include "MMuonSearchPar.h"
 #include "MLog.h"
@@ -73,5 +73,5 @@
 MMuonSearchParCalc::MMuonSearchParCalc
 (const char *mupar, const char *name, const char *title)
-  : fHillas(NULL), fMuonPar(NULL), fCerPhotName("MCerPhotEvt")
+  : fHillas(NULL), fMuonPar(NULL)
 {
     fName  = name  ? name  : gsDefName.Data();
@@ -93,8 +93,8 @@
     }
 
-    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber(fCerPhotName), "MCerPhotEvt");
-    if (!fCerPhotEvt)
+    fSignalCam = (MSignalCam*)pList->FindObject("MSignalCam");
+    if (!fSignalCam)
     {
-        *fLog << err << fCerPhotName << " [MCerPhotEvt] not found... aborting." << endl;
+        *fLog << err << "MSignalCam not found... aborting." << endl;
         return kFALSE;
     }
@@ -119,5 +119,5 @@
 {
 
-  fMuonPar->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
+  fMuonPar->Calc(*fGeomCam, *fSignalCam, *fHillas);
 
   return kTRUE;
Index: trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.h	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MMuonSearchParCalc.h	(revision 6973)
@@ -9,5 +9,5 @@
 class MMuonSearchPar;
 class MGeomCam;
-class MCerPhotEvt;
+class MSignalCam;
 
 class MMuonSearchParCalc : public MTask
@@ -15,5 +15,5 @@
 private:
     MGeomCam    *fGeomCam;
-    MCerPhotEvt *fCerPhotEvt;
+    MSignalCam  *fSignalCam;
     MHillas     *fHillas;      //! Pointer to the source independent hillas parameters
     MMuonSearchPar *fMuonPar;  //! Pointer to the output container for the new image parameters
@@ -21,5 +21,4 @@
     TString fMuparName;
     TString fHillasInput;
-    TString fCerPhotName;
 
     Int_t PreProcess(MParList *plist);
@@ -32,6 +31,4 @@
     void SetInput(TString hilname) { fHillasInput = hilname; }
 
-    void SetNameCerPhotEvt(const char *name) { fCerPhotName = name; }
-
     ClassDef(MMuonSearchParCalc, 0) // task to calculate muon parameters
 };
Index: trunk/MagicSoft/Mars/mmuon/MMuonSetup.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonSetup.cc	(revision 6973)
+++ trunk/MagicSoft/Mars/mmuon/MMuonSetup.cc	(revision 6973)
@@ -0,0 +1,71 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Keiichi Mase 10/2004 <mailto:mase@mppmu.mpg.de>
+!              Markus Meyer 10/2004 <mailto:meyer@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMuonSetup
+//
+// Storage Container for parameter for the muon analysis
+//
+//
+//  Input Containers:
+//   [MSignalCam]
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMuonSetup.h"
+
+#include <fstream>
+
+#include "MLog.h"
+
+using namespace std;
+
+ClassImp(MMuonSetup);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMuonSetup::MMuonSetup(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMuonSetup";
+    fTitle = title ? title : "Muon calibration parameters";
+
+    fMargin = 60.;  // in mm
+    fArcPhiThres  = 30.;
+    fArcWidthThres  = 30.;
+    fArcPhiBinNum = 20;
+    fArcPhiHistStartVal = -180.; // deg.
+    fArcPhiHistEndVal   = 180.;  // deg.
+    fArcWidthBinNum = 28;
+    fArcWidthHistStartVal = 0.3; // deg.
+    fArcWidthHistEndVal   = 1.7; // deg.
+}
+
+// --------------------------------------------------------------------------
+//
+MMuonSetup::~MMuonSetup()
+{
+}
Index: trunk/MagicSoft/Mars/mmuon/MMuonSetup.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonSetup.h	(revision 6973)
+++ trunk/MagicSoft/Mars/mmuon/MMuonSetup.h	(revision 6973)
@@ -0,0 +1,42 @@
+#ifndef MARS_MMuonSetup
+#define MARS_MMuonSetup
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MMuonSetup : public MParContainer
+{
+private:
+  Float_t fMargin;        // margin to evaluate muons [mm]. The defaut value is 60 mm, corresponding to 0.2 deg. This value can be changed by using the function of SetMargin
+  Float_t fArcPhiThres;   // The threshold value to define arc phi
+  Float_t fArcWidthThres; // The threshold value to define arc width
+
+
+public:
+  MMuonSetup(const char *name=NULL, const char *title=NULL);
+  ~MMuonSetup();
+  
+  Int_t   fArcPhiBinNum;         // The bin number for the histogram of arc phi. You may change this value. However, if you change this, YOU ALSO HAVE TO CHANGE THE THRESHOLD VALUE TO GET ARC LENGTH.
+  Int_t   fArcWidthBinNum;       // The bin number for the histogram of arc wid
+  Float_t fArcPhiHistStartVal;   // The starting value for the histogram of arc phi
+  Float_t fArcPhiHistEndVal;     // The end value for the histogram of arc phi
+  Float_t fArcWidthHistStartVal; // The starting value for the histogram of arc width
+  Float_t fArcWidthHistEndVal;   // The end value for the histogram of arc width
+
+  Float_t GetMargin()         const { return fMargin; }
+  Float_t GetArcPhiThres()    const { return fArcPhiThres; }
+  Float_t GetArcWidthThres()  const { return fArcWidthThres; }
+  Float_t GetArcPhiBinNum()   const { return fArcPhiBinNum; }
+  Float_t GetArcWidthBinNum() const { return fArcWidthBinNum; }
+  
+  void    SetMargin(Float_t margin)       { fMargin = margin; }
+  void    SetArcPhiThres(Float_t thres)   { fArcPhiThres = thres; }
+  void    SetArcWidthThres(Float_t thres) { fArcWidthThres = thres; }
+  void    SetArcPhiBinNum(Int_t num)      { fArcPhiBinNum = num; }
+  void    SetArcWidthBinNum(Int_t num)    { fArcWidthBinNum = num; }
+  
+  ClassDef(MMuonSetup, 1) // Container to hold muon parameters for the whole sample
+};
+    
+#endif
Index: trunk/MagicSoft/Mars/mmuon/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmuon/Makefile	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/Makefile	(revision 6973)
@@ -28,5 +28,7 @@
            MMuonSearchParCalc.cc \
            MMuonCalibPar.cc \
-           MMuonCalibParCalc.cc 
+           MMuonCalibParCalc.cc \
+           MHMuonPar.cc \
+           MMuonSetup.cc
 
 ############################################################
Index: trunk/MagicSoft/Mars/mmuon/MuonLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MuonLinkDef.h	(revision 6972)
+++ trunk/MagicSoft/Mars/mmuon/MuonLinkDef.h	(revision 6973)
@@ -9,4 +9,6 @@
 #pragma link C++ class MMuonCalibPar+;
 #pragma link C++ class MMuonCalibParCalc+;
+#pragma link C++ class MHMuonPar+;
+#pragma link C++ class MMuonSetup+;
 
 #endif
