Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1985)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1986)
@@ -1,3 +1,20 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/04/23: Abelardo Moralejo
+
+    * mhistmc/MHMcCT1CollectionArea.[h,cc]
+      - Now the class inherits from MH instead of directly from 
+       	MParContainer. Implemented SetupFill, so that the binning
+	definitions are read from the parlist.
+
+    * mmontecarlo/MMcCT1CollectionAreaCalc.[h,cc]
+      - Removed. This class was superfluous, since the same job 
+ 	can be done using MFillH.
+
+    * mmontecarlo/Makefile, MontecarloLinkDef.h
+      - removed class MMcCT1CollectionAreaCalc.
+
+    * macros/CT1collarea.C
+      - adapted to changes above.
 
  2003/04/23: Antonio Stamerra
Index: trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc	(revision 1985)
+++ trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc	(revision 1986)
@@ -34,6 +34,11 @@
 #include <TCanvas.h>
 
+#include "MMcEvt.hxx"
 #include "MH.h"
 #include "MBinning.h"
+#include "MParList.h"
+#include "MLog.h"
+#include "MLogManip.h"
+
 
 ClassImp(MHMcCT1CollectionArea);
@@ -46,5 +51,5 @@
 //   - collection area (result)
 //
-MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title, Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy)
+MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title)
 { 
   //
@@ -64,6 +69,4 @@
   fHistCol = new TH2D;
 
-  SetBins(nbins, minEnergy, maxEnergy);
-
   fHistCol->SetName(fName);
   fHistAll->SetName("AllEvents");
@@ -93,25 +96,4 @@
 // --------------------------------------------------------------------------
 //
-// Set binning of histograms. Binning of energy axis can be changed, that
-//   of theta axis is always the same (to match the CT1 MC sample theta dist):
-//
-void MHMcCT1CollectionArea::SetBins(Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy)
-{
-  MBinning binsx;
-  binsx.SetEdges(nbins, minEnergy, maxEnergy);
-
-  MBinning binsy;
-  const Double_t yedge[7] = {12.5, 17.5, 23.5, 29.5, 35.5, 42., 48.};
-  const TArrayD yed(7,yedge);
-  binsy.SetEdges(yed);
-
-  MH::SetBinning(fHistAll, &binsx, &binsy);
-  MH::SetBinning(fHistSel, &binsx, &binsy);
-  MH::SetBinning(fHistCol, &binsx, &binsy);
-}
-
-
-// --------------------------------------------------------------------------
-//
 // Delete the three histograms
 //
@@ -125,9 +107,40 @@
 // --------------------------------------------------------------------------
 //
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHMcCT1CollectionArea::SetupFill(const MParList *plist)
+{
+    const MBinning* binsenergy = (MBinning*)plist->FindObject("MBinningE");
+    const MBinning* binstheta  = (MBinning*)plist->FindObject("MBinningTheta");
+
+    if (!binsenergy || !binstheta)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting."
+ << endl;
+        return kFALSE;
+    }
+
+    SetBinning(fHistAll, binsenergy, binstheta);
+    SetBinning(fHistSel, binsenergy, binstheta);
+    SetBinning(fHistCol, binsenergy, binstheta);
+
+    fHistAll->Sumw2();
+    fHistSel->Sumw2();
+    fHistCol->Sumw2();
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
 // Fill data into the histogram which contains the selected showers
 //
-void MHMcCT1CollectionArea::FillSel(Double_t energy, Double_t theta)
-{
-  fHistSel->Fill(log10(energy), theta);
+Bool_t MHMcCT1CollectionArea::Fill(const MParContainer *par)
+{ 
+  MMcEvt &mcevt = *(MMcEvt*)par;
+
+  fHistSel->Fill(log10(mcevt.GetEnergy()), kRad2Deg*mcevt.GetTelescopeTheta());
+  return kTRUE;
 }
 
@@ -209,5 +222,5 @@
   // set here by hand, so make sure that the MC sample you are using is the 
   // right one (check all these quantities in your files and compare with
-  // is written below. In some theta bins, there are two different 
+  // what is written below. In some theta bins, there are two different 
   // productions, with different energy limits but with the same spectral 
   // slope. We account for this when calculating the original number of 
@@ -354,5 +367,5 @@
 
 	  const Double_t eff = Ns/Na;
-	  const Double_t err = sqrt((1.-eff)*Ns)/Na;
+	  const Double_t efferr = sqrt((1.-eff)*Ns)/Na;
 
 
@@ -360,5 +373,5 @@
 
 	  fHistCol->SetBinContent(ix, thetabin, eff*area);
-	  fHistCol->SetBinError(ix, thetabin, err*area);
+	  fHistCol->SetBinError(ix, thetabin, efferr*area);
 
 	}
Index: trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h
===================================================================
--- trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h	(revision 1985)
+++ trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h	(revision 1986)
@@ -2,12 +2,11 @@
 #define MARS_MHMcCT1CollectionArea
 
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
+#ifndef MARS_MH
+#include "MH.h"
 #endif
 
 class TH2D;
 
-
-class MHMcCT1CollectionArea : public MParContainer
+class MHMcCT1CollectionArea : public MH
 {
 private:
@@ -15,11 +14,11 @@
     TH2D *fHistSel; //  the selected showers
     TH2D *fHistCol; //  the collection area
-    void SetBins(Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy);
 
 public:
-    MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL, Int_t nbins=30, Axis_t minEnergy=2., Axis_t maxEnergy=5.);
+    MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL);
     ~MHMcCT1CollectionArea();
 
-    void FillSel(Double_t energy, Double_t radius);
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
 
     void DrawAll(Option_t *option="");
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.cc	(revision 1985)
+++ 	(revision )
@@ -1,99 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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>
-!   Author(s): Harald Kornmayer 1/2001
-!
-!   Copyright: MAGIC Software Development, 2000-2002
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  MHMcCT1CollectionAreaCalc
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include "MMcCT1CollectionAreaCalc.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MMcEvt.hxx"
-
-#include "MHMcCT1CollectionArea.h"
-
-ClassImp(MMcCT1CollectionAreaCalc);
-
-MMcCT1CollectionAreaCalc::MMcCT1CollectionAreaCalc(const char *input,
-                                             const char *name, const char *title)
-{
-    fName  = name  ? name  : "MMcCT1CollectionAreaCalc";
-    fTitle = title ? title : "Task to calculate the collection area";
-
-    AddToBranchList("MMcEvt.fEnergy");
-    AddToBranchList("MMcEvt.fTelescopeTheta");
-} 
-
-Bool_t MMcCT1CollectionAreaCalc::PreProcess (MParList *pList)
-{
-    // connect the raw data with this task
-
-    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
-    if (!fMcEvt)
-    {
-        *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
-        return kFALSE;
-    }
-
-    fCollArea = (MHMcCT1CollectionArea*)pList->FindCreateObj("MHMcCT1CollectionArea");
-    if (!fCollArea)
-        return kFALSE;
-
-    fTotalNumSimulatedShowers =  0;
-    fAllEvtsTriggered         = kTRUE;
-
-    return kTRUE;
-}
-
-Bool_t MMcCT1CollectionAreaCalc::Process()
-{
-    const Double_t energy = fMcEvt->GetEnergy();
-
-    Double_t TelescopeTheta = 180.*fMcEvt->GetTelescopeTheta()/TMath::Pi();
-
-    fCollArea->FillSel(energy, TelescopeTheta);
-
-    return kTRUE;
-}
-
-Bool_t MMcCT1CollectionAreaCalc::PostProcess()
-{ 
-  //
-  //   do the calculation of the effective area
-  //
-  *fLog << inf << "Calculation Collection Area..." << endl;
-  
-  fCollArea->CalcEfficiency();
-
-  return kTRUE;
-}
-
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.h	(revision 1985)
+++ 	(revision )
@@ -1,35 +1,0 @@
-#ifndef MARS_MMcCT1CollectionAreaCalc
-#define MARS_MMcCT1CollectionAreaCalc
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MParList;
-class MMcEvt;
-class MHMcCT1CollectionArea;
-
-class MMcCT1CollectionAreaCalc : public MTask
-{
-private:
-    const MMcEvt  *fMcEvt;
-
-    MHMcCT1CollectionArea *fCollArea;
-
-    TString fObjName;
-
-    UInt_t fTotalNumSimulatedShowers;
-    Bool_t fAllEvtsTriggered;
-
-public:
-    MMcCT1CollectionAreaCalc(const char *input=NULL,
-                          const char *name=NULL, const char *title=NULL);
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
-
-    ClassDef(MMcCT1CollectionAreaCalc, 0) // Task to calculate the collection area histogram
-};
-
-#endif 
Index: trunk/MagicSoft/Mars/mmontecarlo/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/Makefile	(revision 1985)
+++ trunk/MagicSoft/Mars/mmontecarlo/Makefile	(revision 1986)
@@ -32,5 +32,4 @@
            MMcTimeGenerate.cc \
 	   MMcTriggerRateCalc.cc \
-	   MMcCT1CollectionAreaCalc.cc \
 	   MMcEnergyEst.cc
 
Index: trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 1985)
+++ trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 1986)
@@ -9,5 +9,4 @@
 #pragma link C++ class MMcCollectionAreaCalc+;
 #pragma link C++ class MMcTriggerRateCalc+;
-#pragma link C++ class MMcCT1CollectionAreaCalc+;
 #pragma link C++ class MMcEnergyEst+;
 #endif
