Index: /trunk/MagicSoft/Mars/mflux/MFHadAlpha.cc
===================================================================
--- /trunk/MagicSoft/Mars/mflux/MFHadAlpha.cc	(revision 6605)
+++ /trunk/MagicSoft/Mars/mflux/MFHadAlpha.cc	(revision 6605)
@@ -0,0 +1,149 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Marcos Lopez  2/2005 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFHadAlpha                                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFHadAlpha.h"
+
+
+#include <fstream>
+#include <TFile.h>
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MHillasSrc.h"
+#include "MHadAlphaCut.h"
+#include "MEnergyEst.h"
+#include "MHadronness.h"
+#include "MPointingPos.h"
+
+ClassImp(MFHadAlpha);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+MFHadAlpha::MFHadAlpha(const char *name, const char *title)
+    : fFilterType(kHadAlphaCut), fFileName("")
+{
+    fName  = name  ? name  : "MFHadAlpha";
+    fTitle = title ? title : "Filter to apply hadroness and alpha cuts for each size and theta bin";
+}
+
+
+// --------------------------------------------------------------------------
+//
+Int_t MFHadAlpha::PreProcess(MParList *pList)
+{
+   
+    fHillas = (MHillas*)pList->FindObject("MHillas");
+    if (!fHillas)
+    {
+        *fLog << dbginf << "MHillas not found... aborting." << endl;
+        return kFALSE;
+    } 
+
+    fPointingPos = (MPointingPos*)pList->FindObject("MPointingPos");
+    if (!fPointingPos)
+    {
+        *fLog << dbginf << "MPointingPos not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHadronness = (MHadronness*)pList->FindObject("MHadronness");
+    if (!fHadronness)
+    {
+        *fLog << dbginf << "MHadronness not found... aborting." << endl;
+        return kFALSE;
+    } 
+
+    fHillasSrc = (MHillasSrc*)pList->FindObject("MHillasSrc");
+    if (!fHillasSrc)
+    {
+        *fLog << dbginf << "MHillasSrc not found... aborting." << endl;
+        return kFALSE;
+    } 
+
+    fEnergyEst = (MEnergyEst*)pList->FindObject("MEnergyEst");
+    if (!fEnergyEst)
+    {
+        *fLog << dbginf << "MEnergyEst not found... aborting." << endl;
+        return kFALSE;
+    } 
+
+   
+    fHadAlphaCut = (MHadAlphaCut*)pList->FindCreateObj("MHadAlphaCut");
+    if (!fHadAlphaCut)
+    {
+	*fLog << dbginf << "MHadAlphaCut not found... aborting." << endl;
+	return kFALSE;
+    }
+ 
+    if(fFileName!="")
+    {
+	TFile f(fFileName);
+	fHadAlphaCut->Read("MHadAlphaCut");
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFHadAlpha::Process()
+{
+    //const Float_t size = fHillas->GetSize();
+    const Float_t energy = fEnergyEst->GetEnergy();
+    const Float_t zd = fPointingPos->GetZd();
+    const Float_t alpha = TMath::Abs(fHillasSrc->GetAlpha());
+    const Float_t had = fHadronness->GetHadronness();
+
+    const Float_t alphacut = fHadAlphaCut->GetAlphaCut(energy,zd);
+    const Float_t hadcut = fHadAlphaCut->GetHadCut(energy,zd);
+    
+    switch(fFilterType)
+    {
+	case MFHadAlpha::kAlphaCut:
+	    fResult = ( alpha <= alphacut );
+	    break;
+	case MFHadAlpha::kHadCut:
+	    fResult = ( had <= hadcut ); 
+	    break;
+	case MFHadAlpha::kHadAlphaCut:
+	    fResult = ( (alpha <= alphacut)  && (had <= hadcut) );
+	    break;
+	default:
+	    fResult = kTRUE;
+    }
+
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mflux/MFHadAlpha.h
===================================================================
--- /trunk/MagicSoft/Mars/mflux/MFHadAlpha.h	(revision 6605)
+++ /trunk/MagicSoft/Mars/mflux/MFHadAlpha.h	(revision 6605)
@@ -0,0 +1,57 @@
+#ifndef MARS_MFHadAlpha
+#define MARS_MFHadAlpha
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+#ifndef ROOT_TString
+#include "TString.h"
+#endif
+
+class MParList;
+class MHadAlphaCut;
+class MHadronness;
+class MHillas;
+class MHillasSrc;
+class MPointingPos;
+class MEnergyEst;
+
+class MFHadAlpha : public MFilter
+{
+
+ public:
+
+   typedef enum { kHadCut, kAlphaCut, kHadAlphaCut } FilterType_t;
+    FilterType_t fFilterType;
+
+ private:
+   
+    MHadronness*  fHadronness;
+    MHillas*      fHillas; 
+    MHillasSrc*   fHillasSrc;
+    MHadAlphaCut* fHadAlphaCut;
+    MPointingPos* fPointingPos;
+    MEnergyEst*   fEnergyEst;
+
+    TString fFileName;
+
+    Bool_t  fResult; //!
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+
+    MFHadAlpha( const char *name=NULL, const char *title=NULL);
+  
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    void SetInputCutsFile(const char* fname) { fFileName = fname; }
+
+    void SetCutType(FilterType_t type) { fFilterType = type; }
+
+    ClassDef(MFHadAlpha, 1) // A Filter for cuts in fabs(alpha)
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mflux/MHadAlphaCut.cc
===================================================================
--- /trunk/MagicSoft/Mars/mflux/MHadAlphaCut.cc	(revision 6605)
+++ /trunk/MagicSoft/Mars/mflux/MHadAlphaCut.cc	(revision 6605)
@@ -0,0 +1,139 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Marcos Lopez  2/2005 <mailto:marcos@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHadAlphaCut
+//
+//  Container for Hadronness and Alpha cut for each Estimated Energy and theta
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHadAlphaCut.h"
+
+
+#include <TH2F.h>
+#include <TCanvas.h>
+
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHadAlphaCut);
+
+using namespace std;
+
+
+// ------------------------------------------------------------------------
+//
+//
+MHadAlphaCut::MHadAlphaCut(const char* name, const char* title)
+{
+    fName  = name  ? name  : "MHadAlphaCut";
+    fTitle = title ? title : "Container of Hadronness and Alpha cuts";
+    
+
+    fHistHadCut = new TH2F;
+    fHistHadCut->UseCurrentStyle();
+    fHistHadCut->SetNameTitle("HadCut","HadCut");
+    fHistHadCut->SetXTitle("Energy");
+    fHistHadCut->SetYTitle("Theta");
+    fHistHadCut->SetZTitle("Hadronness Cut");
+
+    fHistAlphaCut = new TH2F; 
+    fHistAlphaCut->UseCurrentStyle();
+    fHistAlphaCut->SetNameTitle("AlphaCut","AlphaCut");
+    fHistAlphaCut->SetXTitle("Energy");
+    fHistAlphaCut->SetYTitle("Theta");
+    fHistAlphaCut->SetZTitle("Alpha Cut");
+  
+
+    MBinning binsx;
+    MBinning binsy;
+    
+    binsx.SetEdgesLog(8, 50., 2000);  // Est. Energy binning
+    binsy.SetEdges(2,14,31);          // Theta binning
+
+    MH::SetBinning(fHistHadCut, &binsx, &binsy);
+    MH::SetBinning(fHistAlphaCut, &binsx, &binsy);
+    
+
+    for(int ix=1; ix<=fHistHadCut->GetNbinsX(); ix++)
+	for(int iy=1; iy<=fHistHadCut->GetNbinsY(); iy++)
+	{
+	    fHistAlphaCut->SetBinContent(ix,iy,10);
+	    fHistHadCut->SetBinContent(ix,iy,0.3);
+	}
+}
+
+
+Float_t MHadAlphaCut::GetAlphaCut(Float_t energy, Float_t zd)
+{
+    Int_t bin = fHistAlphaCut->FindBin(energy,zd);
+    return fHistAlphaCut->GetBinContent(bin);
+}
+
+Float_t MHadAlphaCut::GetHadCut(Float_t energy, Float_t zd)
+{ 
+    Int_t bin = fHistHadCut->FindBin(energy,zd);
+    return fHistHadCut->GetBinContent(bin);
+} 
+
+
+//------------------------------------------------------------------------
+//
+//
+void MHadAlphaCut::Print(Option_t *o) const
+{
+
+    // *fLog << " Size bin \t HadCut \t AlphaCut" << endl;
+    for(Int_t ix=1; ix<=fHistHadCut->GetNbinsX(); ix++)
+    {
+	for(Int_t iy=1; iy<=fHistHadCut->GetNbinsY(); iy++)
+	{	
+	    *fLog <<"(" <<ix << ", " << iy << ") = " 
+		  << fHistHadCut->GetBinContent(ix,iy) << " " << 
+		fHistAlphaCut->GetBinContent(ix,iy) << endl;
+	}
+    }
+}
+
+
+// -------------------------------------------------------------------------
+//
+//
+void MHadAlphaCut::Draw(Option_t *o)
+{
+    TCanvas *c1 = new TCanvas;
+    c1->SetLogx();
+    fHistAlphaCut->Draw("lego");
+
+    TCanvas *c2 = new TCanvas;
+    c2->SetLogx();
+    fHistHadCut->Draw("lego");
+}
+
+
+
+
Index: /trunk/MagicSoft/Mars/mflux/MHadAlphaCut.h
===================================================================
--- /trunk/MagicSoft/Mars/mflux/MHadAlphaCut.h	(revision 6605)
+++ /trunk/MagicSoft/Mars/mflux/MHadAlphaCut.h	(revision 6605)
@@ -0,0 +1,35 @@
+#ifndef MARS_MHadAlphaCut
+#define MARS_MHadAlphaCut
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH2F;
+
+class MHadAlphaCut : public MH
+{
+ private:
+
+    TH2F*  fHistHadCut;
+    TH2F*  fHistAlphaCut;
+  
+
+ public:
+    
+    MHadAlphaCut(const char* name=NULL, const char* title=NULL);
+
+    Float_t GetAlphaCut(Float_t energy, Float_t zd);
+    Float_t GetHadCut(Float_t energy, Float_t zd);
+    
+    void Print(Option_t *o="") const;
+    void Draw(Option_t *o="");
+    
+    TH2F* GetHistHadCut() const   { return fHistHadCut; }
+    TH2F* GetHistAlphaCut() const { return fHistAlphaCut; }
+
+
+    ClassDef(MHadAlphaCut, 1)	// Container for Hadronness and Alpha cut for each estimated energy and theta bin
+};
+
+#endif
