Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1823)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1824)
@@ -1,3 +1,13 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/03/18: Abelardo Moralejo
+
+    * mhist/MHMcCT1CollectionArea.[h,cc]
+      - Added arguments in constructor: number of bins and ranges of the 
+	x-axis (energy) of the 2-d histograms.
+
+    * macros/CT1collarea.C
+      - The MHMcCT1CollectionArea object is now created and added to the 
+       	parlist so that  we can choose the binning.
 
  2003/03/13: Abelardo moralejo
Index: trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.cc	(revision 1823)
+++ trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.cc	(revision 1824)
@@ -46,56 +46,69 @@
 //   - collection area (result)
 //
-MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title)
+MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title, Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy)
 { 
-    //   initialize the histogram for the distribution r vs E
-    //
-    //   we set the energy range from 10 Gev to 30000 GeV (in log 4.5 orders
-    //   of magnitude) and for each order we take 10 subdivision --> 45 xbins
-    //   we set the theta range from 12.5 to 48 deg, with 6 bins.
-    //
-    fName  = name  ? name  : "MHMcCT1CollectionArea";
-    fTitle = title ? title : "Collection Area vs. Energy";
-
-    MBinning binsx;
-    MBinning binsy;
-
-    binsx.SetEdgesLog(45, 10, 30000);
-    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);
-
-    fHistAll = new TH2D;
-    fHistSel = new TH2D;
-    fHistCol = new TH2D;
-
-    MH::SetBinning(fHistAll, &binsx, &binsy);
-    MH::SetBinning(fHistSel, &binsx, &binsy);
-    MH::SetBinning(fHistCol, &binsx, &binsy);
-
-
-    fHistCol->SetName(fName);
-    fHistAll->SetName("AllEvents");
-    fHistSel->SetName("SelectedEvents");
-
-    fHistCol->SetTitle(fTitle);
-    fHistAll->SetTitle("All showers - Theta vs Energy distribution");
-    fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
-
-    fHistAll->SetDirectory(NULL);
-    fHistSel->SetDirectory(NULL);
-    fHistCol->SetDirectory(NULL);
-
-    fHistAll->SetXTitle("E [GeV]");
-    fHistAll->SetYTitle("theta [deg]");
-    fHistAll->SetZTitle("N");
-
-    fHistSel->SetXTitle("E [GeV]");
-    fHistSel->SetYTitle("theta [deg]");
-    fHistSel->SetYTitle("N");
-
-    fHistCol->SetXTitle("E [GeV]");
-    fHistCol->SetYTitle("theta [deg]");
-    fHistCol->SetZTitle("A [m^{2}]");
-}
+  //
+  //   nbins, minEnergy, maxEnergy defaults:
+  //   we set the energy range from 100 Gev to 30000 GeV (in log, 3.5 orders
+  //   of magnitude) and for each order we take 10 subdivisions --> 35 xbins
+  //   we set the theta range from 12.5 to 48 deg, with 6 bins (the latter
+  //   choice has been done to make the bin centers as close as possible to 
+  //   the actual zenith angles in the CT1 MC sample).
+  //
+
+  fName  = name  ? name  : "MHMcCT1CollectionArea";
+  fTitle = title ? title : "Collection Area vs. Energy";
+
+  fHistAll = new TH2D;
+  fHistSel = new TH2D;
+  fHistCol = new TH2D;
+
+  SetBins(nbins, minEnergy, maxEnergy);
+
+  fHistCol->SetName(fName);
+  fHistAll->SetName("AllEvents");
+  fHistSel->SetName("SelectedEvents");
+
+  fHistCol->SetTitle(fTitle);
+  fHistAll->SetTitle("All showers - Theta vs Energy distribution");
+  fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
+
+  fHistAll->SetDirectory(NULL);
+  fHistSel->SetDirectory(NULL);
+  fHistCol->SetDirectory(NULL);
+
+  fHistAll->SetXTitle("E [GeV]");
+  fHistAll->SetYTitle("theta [deg]");
+  fHistAll->SetZTitle("N");
+
+  fHistSel->SetXTitle("E [GeV]");
+  fHistSel->SetYTitle("theta [deg]");
+  fHistSel->SetYTitle("N");
+
+  fHistCol->SetXTitle("E [GeV]");
+  fHistCol->SetYTitle("theta [deg]");
+  fHistCol->SetZTitle("A [m^{2}]");
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.SetEdgesLog(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);
+}
+
 
 // --------------------------------------------------------------------------
@@ -105,7 +118,7 @@
 MHMcCT1CollectionArea::~MHMcCT1CollectionArea()
 {
-    delete fHistAll;
-    delete fHistSel;
-    delete fHistCol;
+  delete fHistAll;
+  delete fHistSel;
+  delete fHistCol;
 }
 
@@ -116,5 +129,5 @@
 void MHMcCT1CollectionArea::FillSel(Double_t energy, Double_t theta)
 {
-    fHistSel->Fill(energy, theta);
+  fHistSel->Fill(energy, theta);
 }
 
@@ -125,13 +138,13 @@
 void MHMcCT1CollectionArea::DrawAll(Option_t* option)
 {
-    if (!gPad)
-        MH::MakeDefCanvas(fHistAll);
-
-    fHistAll->Draw(option);
-
-    gPad->SetLogx();
-
-    gPad->Modified();
-    gPad->Update();
+  if (!gPad)
+    MH::MakeDefCanvas(fHistAll);
+
+  fHistAll->Draw(option);
+
+  gPad->SetLogx();
+
+  gPad->Modified();
+  gPad->Update();
 }
 
@@ -142,13 +155,13 @@
 void MHMcCT1CollectionArea::DrawSel(Option_t* option)
 {
-    if (!gPad)
-        MH::MakeDefCanvas(fHistSel);
-
-    fHistSel->Draw(option);
-
-    gPad->SetLogx();
-
-    gPad->Modified();
-    gPad->Update();
+  if (!gPad)
+    MH::MakeDefCanvas(fHistSel);
+
+  fHistSel->Draw(option);
+
+  gPad->SetLogx();
+
+  gPad->Modified();
+  gPad->Update();
 }
 
@@ -161,32 +174,32 @@
 TObject *MHMcCT1CollectionArea::DrawClone(Option_t* option) const
 {
-    TCanvas *c = MH::MakeDefCanvas(fHistCol);
-
-    //
-    // This is necessary to get the expected behaviour of DrawClone
-    //
-    gROOT->SetSelectedPad(NULL);
-
-    fHistCol->DrawCopy(option);
-
-    gPad->SetLogx();
-
-    c->Modified();
-    c->Update();
-
-    return c;
+  TCanvas *c = MH::MakeDefCanvas(fHistCol);
+
+  //
+  // This is necessary to get the expected behaviour of DrawClone
+  //
+  gROOT->SetSelectedPad(NULL);
+
+  fHistCol->DrawCopy(option);
+
+  gPad->SetLogx();
+
+  c->Modified();
+  c->Update();
+
+  return c;
 }
 
 void MHMcCT1CollectionArea::Draw(Option_t* option)
 {
-    if (!gPad)
-        MH::MakeDefCanvas(fHistCol);
-
-    fHistCol->Draw(option);
-
-    gPad->SetLogx();
-
-    gPad->Modified();
-    gPad->Update();
+  if (!gPad)
+    MH::MakeDefCanvas(fHistCol);
+
+  fHistCol->Draw(option);
+
+  gPad->SetLogx();
+
+  gPad->Modified();
+  gPad->Update();
 }
 
@@ -344,5 +357,4 @@
     }
 
-    SetReadyToSave();
-}
-
+  SetReadyToSave();
+}
Index: trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.h	(revision 1823)
+++ trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.h	(revision 1824)
@@ -6,5 +6,4 @@
 #endif
 
-class TH1D;
 class TH2D;
 
@@ -16,7 +15,8 @@
     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);
+    MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL, Int_t nbins=45, Axis_t minEnergy=100., Axis_t maxEnergy=30000.);
     ~MHMcCT1CollectionArea();
 
@@ -39,2 +39,4 @@
 
 
+
+
