Index: trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc	(revision 9346)
+++ trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc	(revision 9359)
@@ -19,5 +19,5 @@
 !   Author(s): Harald Kornmayer 1/2001
 !
-!   Copyright: MAGIC Software Development, 2000-2008
+!   Copyright: MAGIC Software Development, 2000-2009
 !
 !
@@ -67,5 +67,5 @@
 //
 MHCollectionArea::MHCollectionArea(const char *name, const char *title)
-  : fMcEvt(0), fMcAreaRadius(-1), fIsExtern(kFALSE)
+  : fMcEvt(0), fHeader(0), fMcAreaRadius(-1), fIsExtern(kFALSE)
 { 
     //   initialize the histogram for the distribution r vs E
@@ -148,6 +148,6 @@
     MH::SetBinomialErrors(fHEnergy, *hsel, *hall);
 #endif
-
-    fHEnergy.Scale(totalarea);
+    if (fMcAreaRadius>0)
+        fHEnergy.Scale(totalarea);
 
     delete hsel;
@@ -161,4 +161,11 @@
     if (!fIsExtern)
         fHistAll.Reset();
+
+    fHeader = (MMcRunHeader*)pl->FindObject("MMcRunHeader");
+    if (!fHeader)
+    {
+        *fLog << err << "MMcRunHeader not found... abort." << endl;
+        return kFALSE;
+    }
 
     fMcEvt = (MMcEvt*)pl->FindObject("MMcEvt");
@@ -202,34 +209,32 @@
 }
 
+void MHCollectionArea::GetImpactMax()
+{
+    if (fHeader->GetImpactMax()<=fMcAreaRadius*100)
+        return;
+
+    fMcAreaRadius = 0.01*fHeader->GetImpactMax(); // cm->m
+    *fLog << inf << "Maximum simulated impact: " << fMcAreaRadius << "m" << endl;
+}
+
 Bool_t MHCollectionArea::ReInit(MParList *plist)
 {
-    MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
-    if (!runheader)
-    {
-        *fLog << err << "MMcRunHeader not found... abort." << endl;
-        return kFALSE;
-    }
-
-    if (runheader->GetImpactMax()>fMcAreaRadius*100)
-    {
-        fMcAreaRadius = 0.01*runheader->GetImpactMax(); // cm->m
-        *fLog << inf << "Maximum simulated impact: " << fMcAreaRadius << "m" << endl;
-    }
-
-    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
+    GetImpactMax();
+
+    if (fCorsikaVersion!=0 && fCorsikaVersion!=fHeader->GetCorsikaVersion())
     {
         *fLog << warn;
         *fLog << "Warning - Read files have different Corsika versions..." << endl;
-        *fLog << "          Last file=" << fCorsikaVersion << "   New file=" << runheader->GetCorsikaVersion() << endl;
-    }
-    fCorsikaVersion = runheader->GetCorsikaVersion();
+        *fLog << "          Last file=" << fCorsikaVersion << "   New file=" << fHeader->GetCorsikaVersion() << endl;
+    }
+    fCorsikaVersion = fHeader->GetCorsikaVersion();
 
     if (fIsExtern)
         return kTRUE;
 
-    fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
+    fTotalNumSimulatedShowers += fHeader->GetNumSimulatedShowers();
     *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
 
-    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
+    fAllEvtsTriggered |= fHeader->GetAllEvtsTriggered();
     *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
 
@@ -248,5 +253,5 @@
     const Float_t emax = crh->GetEUppLim();
     const Float_t expo = 1 + crh->GetSlopeSpec();
-    const Float_t k = runheader->GetNumSimulatedShowers() /
+    const Float_t k = fHeader->GetNumSimulatedShowers() /
         (pow(emax,expo) - pow(emin,expo));
 
@@ -271,5 +276,6 @@
 
         const Float_t energy = (e1+e2)/2.;
-        fHistAll.Fill(20, energy, events);
+        for (int j=0; j<TMath::Nint(events); j++)
+            fHistAll.Fill(0., energy);
         // you have  MMcRunHeader.fShowerThetaMin and MMcRunHeader.fShowerThetaMax
     }
@@ -280,25 +286,6 @@
 void MHCollectionArea::Paint(Option_t *option)
 {
-    if (TString(option)=="paint3")
-    {
-        /*
-        TH1 *h = dynamic_cast<TH1*>(gPad->FindObject("Efficiency"));
-        if (h)
-        {
-            const TString txt = Form("N/N_{0}=%.2f",
-                                 GetCollectionAreaEff(),
-                                 GetCollectionAreaAbs(), fMcAreaRadius);
-
-        TLatex text(0.31, 0.95, txt);
-        text.SetBit(TLatex::kTextNDC);
-        text.SetTextSize(0.04);
-        text.Paint();*/
-        return;
-    }
-    if (TString(option)=="paint4")
-    {
-        //const TString txt = Form("A_{eff}=%.0fm^{2}  A_{abs}=%.0fm^{2}  r=%.0fm",
-        //                         GetCollectionAreaEff(),
-        //                         GetCollectionAreaAbs(), fMcAreaRadius);
+    if (TString(option)=="paint4" && fMcAreaRadius>0)
+    {
         const TString txt = MString::Format("r_{max}=%.0fm --> A_{max}=%.0fm^{2}",
                                             fMcAreaRadius, GetCollectionAreaAbs());
@@ -445,7 +432,7 @@
         MH::SetBinomialErrors(*h, *h2, *h1);
 #endif
-        h->SetNameTitle("Efficiency", "Combined cut and trigger efficiency");
+        h->SetNameTitle("Efficiency", "Efficiency");
         h->SetDirectory(NULL);
-        AppendPad("paint3");
+        //AppendPad("paint3");
     }
     else
@@ -477,4 +464,6 @@
 Bool_t MHCollectionArea::Finalize()
 {
+    GetImpactMax();
+
     *fLog << all << "Maximum simulated impact found: " << fMcAreaRadius << "m" << endl;
 
Index: trunk/MagicSoft/Mars/mhflux/MHCollectionArea.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHCollectionArea.h	(revision 9346)
+++ trunk/MagicSoft/Mars/mhflux/MHCollectionArea.h	(revision 9359)
@@ -16,4 +16,5 @@
 class MMcEvt;
 class MParameterD;
+class MMcRunHeader;
 
 class MHCollectionArea : public MH
@@ -21,4 +22,5 @@
 private:
     MMcEvt *fMcEvt;             //!
+    MMcRunHeader *fHeader;      //!
     //MParameterD *fEnergy;     //!
 
@@ -35,4 +37,5 @@
     Bool_t fIsExtern;
 
+    void GetImpactMax();
     void Calc(TH2D &hsel, TH2D &hall);
     void CalcEfficiency();
