Index: trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.cc	(revision 1821)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.cc	(revision 1821)
@@ -0,0 +1,114 @@
+/* ======================================================================== *\
+!
+! *
+! * 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.fImpact");
+    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;
+    fAllEvtsAtSameTheta       = kTRUE;
+    fTelescopeTheta           = -1.;
+
+    return kTRUE;
+}
+
+Bool_t MMcCT1CollectionAreaCalc::Process()
+{
+    const Double_t energy = fMcEvt->GetEnergy();
+    const Double_t impact = fMcEvt->GetImpact()/100.;
+
+    if (fTelescopeTheta < 0.)
+      fTelescopeTheta = fMcEvt->GetTelescopeTheta();
+
+    if (fTelescopeTheta != fMcEvt->GetTelescopeTheta())
+      {
+	fAllEvtsAtSameTheta = kFALSE;
+      }
+
+    fCollArea->FillSel(energy, impact);
+
+    return kTRUE;
+}
+
+Bool_t MMcCT1CollectionAreaCalc::PostProcess()
+{ 
+  if ( ! fAllEvtsAtSameTheta )
+    {
+        *fLog << err << dbginf << "ERROR: input data contain events at different zenith angles (not supported)... exiting." << endl;
+	return kFALSE;
+    }
+  //
+  //   do the calculation of the effective area
+  //
+  *fLog << inf << "Calculation Collection Area..." << endl;
+  
+  fCollArea->CalcEfficiency(fTelescopeTheta);
+
+  return kTRUE;
+}
+
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.h	(revision 1821)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcCT1CollectionAreaCalc.h	(revision 1821)
@@ -0,0 +1,37 @@
+#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;
+    Bool_t fAllEvtsAtSameTheta;
+    Float_t fTelescopeTheta;
+
+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 1800)
+++ trunk/MagicSoft/Mars/mmontecarlo/Makefile	(revision 1821)
@@ -31,5 +31,6 @@
 	   MMcThresholdCalc.cc \
            MMcTimeGenerate.cc \
-	   MMcTriggerRateCalc.cc
+	   MMcTriggerRateCalc.cc \
+	   MMcCT1CollectionAreaCalc.cc
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 1800)
+++ trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 1821)
@@ -9,4 +9,5 @@
 #pragma link C++ class MMcCollectionAreaCalc+;
 #pragma link C++ class MMcTriggerRateCalc+;
+#pragma link C++ class MMcCT1CollectionAreaCalc+;
 
 #endif
