Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2267)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2268)
@@ -1,3 +1,15 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/07/06: Abelardo Moralejo
+
+   * mhistmc/MHMcCT1CollectionArea.[h,cc]
+     - Added possibility of using a logarithmic or linear scale in
+       energy. The function MHMcCT1CollectionArea::SetEaxis sets
+       what should be filled in the energy axis (either the energy 
+       or its decimal logarithm).
+
+   * macros/CT1collarea.C
+     - Added example on how to use the new function 
+       MHMcCT1CollectionArea::SetEaxis
 
  2003/07/06: Thomas Bretz
Index: trunk/MagicSoft/Mars/macros/CT1collarea.C
===================================================================
--- trunk/MagicSoft/Mars/macros/CT1collarea.C	(revision 2267)
+++ trunk/MagicSoft/Mars/macros/CT1collarea.C	(revision 2268)
@@ -24,7 +24,9 @@
 \* ======================================================================== */
 
+#include "/home/magic/Mars/mhistmc/MHMcCT1CollectionArea.h"
 
 void CT1collarea(TString filename="MC_SC4.root", TString outname="")
 { 
+
     //
     // first we have to create our empty lists
@@ -47,14 +49,21 @@
     MBinning binsx("BinningE");
 
-    //    binsx.SetEdges(30,2.,5.);
-    //    Double_t xedge[10] =
-    //    {2.50515, 2.69897, 2.89763, 3.09691, 3.30103, 3.49969, 3.69984, 3.89982, 4.10003, 4.29994};
-
-
+    /*
     Double_t xedge[15] = {2.47712, 2.64345, 2.82607, 3., 3.17609, 3.35218, 3.52892, 3.70415, 3.88024, 4.05652, 4.23274, 4.40875, 4.58478, 4.76080, 4.90309};
-
     const TArrayD xed;
     xed.Set(15,xedge);
     binsx.SetEdges(xed);
+    collarea->SetEaxis(kLog10Energy);
+    */
+
+    //
+    // SetEaxis tells MHMcCT1CollectionArea whether the variable to histogram
+    // is the Energy (argument is kEnergy) or its decimal logarithm 
+    // (kLog10Energy). Of course this depends on how the energy binning is 
+    // defined via the object binsx. 
+    //
+    binsx.SetEdgesLog(14,300,1.e5);
+    collarea->SetEaxis(kEnergy);
+
 
     MBinning binsy("BinningTheta");
Index: trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc	(revision 2267)
+++ trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc	(revision 2268)
@@ -66,4 +66,6 @@
   fTitle = title ? title : "Collection Area vs. log10 Energy";
 
+  fEaxis = kLog10Energy;
+
   fHistAll = new TH2D;
   fHistSel = new TH2D;
@@ -93,4 +95,5 @@
   fHistCol->SetYTitle("theta [deg]");
   fHistCol->SetZTitle("A [m^{2}]");
+
 }
 
@@ -130,4 +133,15 @@
     fHistCol->Sumw2();
 
+    if (fEaxis == kEnergy)
+      {
+	fTitle = "Collection Area vs. Energy";
+	fHistCol->SetTitle(fTitle);
+	fHistAll->SetTitle("All showers - Theta vs Energy distribution");
+	fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
+	fHistCol->SetXTitle("E [GeV]");
+	fHistAll->SetXTitle("E [GeV]");
+	fHistSel->SetXTitle("E [GeV]");
+      }
+
     return kTRUE;
 }
@@ -142,5 +156,9 @@
   MMcEvt &mcevt = *(MMcEvt*)par;
 
-  fHistSel->Fill(log10(mcevt.GetEnergy()), kRad2Deg*mcevt.GetTelescopeTheta(), w);
+  if (fEaxis == kLog10Energy)
+    fHistSel->Fill(log10(mcevt.GetEnergy()), kRad2Deg*mcevt.GetTelescopeTheta(), w);
+  else
+    fHistSel->Fill(mcevt.GetEnergy(), kRad2Deg*mcevt.GetTelescopeTheta(), w);
+
   return kTRUE;
 }
@@ -193,12 +211,18 @@
 
   c.cd(1);
+  if (fEaxis == kEnergy)
+    gPad->SetLogx();
   fHistCol->SetDirectory(NULL);
   fHistCol->DrawCopy(option);
 
   c.cd(2);
+  if (fEaxis == kEnergy)
+    gPad->SetLogx();
   fHistSel->SetDirectory(NULL);
   fHistSel->DrawCopy(option);
 
   c.cd(3);
+  if (fEaxis == kEnergy)
+    gPad->SetLogx();
   fHistAll->SetDirectory(NULL);
   fHistAll->DrawCopy(option);
@@ -435,6 +459,17 @@
       for (Int_t i=1; i <= fHistAll->GetNbinsX(); i++)
 	{
-	  Float_t e1 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i));
-	  Float_t e2 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i+1));
+	  Float_t e1;
+	  Float_t e2;
+
+	  if (fEaxis == kLog10Energy)
+	    {
+	      e1 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i));
+	      e2 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i+1));
+	    }
+	  else
+	    {
+	      e1 = fHistAll->GetXaxis()->GetBinLowEdge(i);
+	      e2 = fHistAll->GetXaxis()->GetBinLowEdge(i+1);
+	    }
 
 	  Float_t events = 0.;
Index: trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h
===================================================================
--- trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h	(revision 2267)
+++ trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h	(revision 2268)
@@ -5,4 +5,9 @@
 #include "MH.h"
 #endif
+
+enum {
+  kLog10Energy,
+  kEnergy
+};
 
 class TH2D;
@@ -15,4 +20,6 @@
     TH2D *fHistCol; //  the collection area
 
+    Byte_t  fEaxis;
+
 public:
     MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL);
@@ -24,4 +31,6 @@
     void DrawAll(Option_t *option="");
     void DrawSel(Option_t *option="");
+
+    void SetEaxis(Byte_t x) { fEaxis = x; }
 
     const TH2D *GetHist() const { return fHistCol; }
