Changeset 1824 for trunk/MagicSoft


Ignore:
Timestamp:
03/18/03 11:06:49 (22 years ago)
Author:
moralejo
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1823 r1824  
    11                                                 -*-*- END OF LINE -*-*-
     2
     3 2003/03/18: Abelardo Moralejo
     4
     5    * mhist/MHMcCT1CollectionArea.[h,cc]
     6      - Added arguments in constructor: number of bins and ranges of the
     7        x-axis (energy) of the 2-d histograms.
     8
     9    * macros/CT1collarea.C
     10      - The MHMcCT1CollectionArea object is now created and added to the
     11        parlist so that  we can choose the binning.
    212
    313 2003/03/13: Abelardo moralejo
  • trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.cc

    r1823 r1824  
    4646//   - collection area (result)
    4747//
    48 MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title)
     48MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title, Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy)
    4949{
    50     //   initialize the histogram for the distribution r vs E
    51     //
    52     //   we set the energy range from 10 Gev to 30000 GeV (in log 4.5 orders
    53     //   of magnitude) and for each order we take 10 subdivision --> 45 xbins
    54     //   we set the theta range from 12.5 to 48 deg, with 6 bins.
    55     //
    56     fName  = name  ? name  : "MHMcCT1CollectionArea";
    57     fTitle = title ? title : "Collection Area vs. Energy";
    58 
    59     MBinning binsx;
    60     MBinning binsy;
    61 
    62     binsx.SetEdgesLog(45, 10, 30000);
    63     const Double_t yedge[7] = {12.5, 17.5, 23.5, 29.5, 35.5, 42., 48.};
    64     const TArrayD yed(7,yedge);
    65     binsy.SetEdges(yed);
    66 
    67     fHistAll = new TH2D;
    68     fHistSel = new TH2D;
    69     fHistCol = new TH2D;
    70 
    71     MH::SetBinning(fHistAll, &binsx, &binsy);
    72     MH::SetBinning(fHistSel, &binsx, &binsy);
    73     MH::SetBinning(fHistCol, &binsx, &binsy);
    74 
    75 
    76     fHistCol->SetName(fName);
    77     fHistAll->SetName("AllEvents");
    78     fHistSel->SetName("SelectedEvents");
    79 
    80     fHistCol->SetTitle(fTitle);
    81     fHistAll->SetTitle("All showers - Theta vs Energy distribution");
    82     fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
    83 
    84     fHistAll->SetDirectory(NULL);
    85     fHistSel->SetDirectory(NULL);
    86     fHistCol->SetDirectory(NULL);
    87 
    88     fHistAll->SetXTitle("E [GeV]");
    89     fHistAll->SetYTitle("theta [deg]");
    90     fHistAll->SetZTitle("N");
    91 
    92     fHistSel->SetXTitle("E [GeV]");
    93     fHistSel->SetYTitle("theta [deg]");
    94     fHistSel->SetYTitle("N");
    95 
    96     fHistCol->SetXTitle("E [GeV]");
    97     fHistCol->SetYTitle("theta [deg]");
    98     fHistCol->SetZTitle("A [m^{2}]");
    99 }
     50  //
     51  //   nbins, minEnergy, maxEnergy defaults:
     52  //   we set the energy range from 100 Gev to 30000 GeV (in log, 3.5 orders
     53  //   of magnitude) and for each order we take 10 subdivisions --> 35 xbins
     54  //   we set the theta range from 12.5 to 48 deg, with 6 bins (the latter
     55  //   choice has been done to make the bin centers as close as possible to
     56  //   the actual zenith angles in the CT1 MC sample).
     57  //
     58
     59  fName  = name  ? name  : "MHMcCT1CollectionArea";
     60  fTitle = title ? title : "Collection Area vs. Energy";
     61
     62  fHistAll = new TH2D;
     63  fHistSel = new TH2D;
     64  fHistCol = new TH2D;
     65
     66  SetBins(nbins, minEnergy, maxEnergy);
     67
     68  fHistCol->SetName(fName);
     69  fHistAll->SetName("AllEvents");
     70  fHistSel->SetName("SelectedEvents");
     71
     72  fHistCol->SetTitle(fTitle);
     73  fHistAll->SetTitle("All showers - Theta vs Energy distribution");
     74  fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
     75
     76  fHistAll->SetDirectory(NULL);
     77  fHistSel->SetDirectory(NULL);
     78  fHistCol->SetDirectory(NULL);
     79
     80  fHistAll->SetXTitle("E [GeV]");
     81  fHistAll->SetYTitle("theta [deg]");
     82  fHistAll->SetZTitle("N");
     83
     84  fHistSel->SetXTitle("E [GeV]");
     85  fHistSel->SetYTitle("theta [deg]");
     86  fHistSel->SetYTitle("N");
     87
     88  fHistCol->SetXTitle("E [GeV]");
     89  fHistCol->SetYTitle("theta [deg]");
     90  fHistCol->SetZTitle("A [m^{2}]");
     91}
     92
     93// --------------------------------------------------------------------------
     94//
     95// Set binning of histograms. Binning of energy axis can be changed, that
     96//   of theta axis is always the same (to match the CT1 MC sample theta dist):
     97//
     98void MHMcCT1CollectionArea::SetBins(Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy)
     99{
     100  MBinning binsx;
     101  binsx.SetEdgesLog(nbins, minEnergy, maxEnergy);
     102
     103  MBinning binsy;
     104  const Double_t yedge[7] = {12.5, 17.5, 23.5, 29.5, 35.5, 42., 48.};
     105  const TArrayD yed(7,yedge);
     106  binsy.SetEdges(yed);
     107
     108  MH::SetBinning(fHistAll, &binsx, &binsy);
     109  MH::SetBinning(fHistSel, &binsx, &binsy);
     110  MH::SetBinning(fHistCol, &binsx, &binsy);
     111}
     112
    100113
    101114// --------------------------------------------------------------------------
     
    105118MHMcCT1CollectionArea::~MHMcCT1CollectionArea()
    106119{
    107     delete fHistAll;
    108     delete fHistSel;
    109     delete fHistCol;
     120  delete fHistAll;
     121  delete fHistSel;
     122  delete fHistCol;
    110123}
    111124
     
    116129void MHMcCT1CollectionArea::FillSel(Double_t energy, Double_t theta)
    117130{
    118     fHistSel->Fill(energy, theta);
     131  fHistSel->Fill(energy, theta);
    119132}
    120133
     
    125138void MHMcCT1CollectionArea::DrawAll(Option_t* option)
    126139{
    127     if (!gPad)
    128         MH::MakeDefCanvas(fHistAll);
    129 
    130     fHistAll->Draw(option);
    131 
    132     gPad->SetLogx();
    133 
    134     gPad->Modified();
    135     gPad->Update();
     140  if (!gPad)
     141    MH::MakeDefCanvas(fHistAll);
     142
     143  fHistAll->Draw(option);
     144
     145  gPad->SetLogx();
     146
     147  gPad->Modified();
     148  gPad->Update();
    136149}
    137150
     
    142155void MHMcCT1CollectionArea::DrawSel(Option_t* option)
    143156{
    144     if (!gPad)
    145         MH::MakeDefCanvas(fHistSel);
    146 
    147     fHistSel->Draw(option);
    148 
    149     gPad->SetLogx();
    150 
    151     gPad->Modified();
    152     gPad->Update();
     157  if (!gPad)
     158    MH::MakeDefCanvas(fHistSel);
     159
     160  fHistSel->Draw(option);
     161
     162  gPad->SetLogx();
     163
     164  gPad->Modified();
     165  gPad->Update();
    153166}
    154167
     
    161174TObject *MHMcCT1CollectionArea::DrawClone(Option_t* option) const
    162175{
    163     TCanvas *c = MH::MakeDefCanvas(fHistCol);
    164 
    165     //
    166     // This is necessary to get the expected behaviour of DrawClone
    167     //
    168     gROOT->SetSelectedPad(NULL);
    169 
    170     fHistCol->DrawCopy(option);
    171 
    172     gPad->SetLogx();
    173 
    174     c->Modified();
    175     c->Update();
    176 
    177     return c;
     176  TCanvas *c = MH::MakeDefCanvas(fHistCol);
     177
     178  //
     179  // This is necessary to get the expected behaviour of DrawClone
     180  //
     181  gROOT->SetSelectedPad(NULL);
     182
     183  fHistCol->DrawCopy(option);
     184
     185  gPad->SetLogx();
     186
     187  c->Modified();
     188  c->Update();
     189
     190  return c;
    178191}
    179192
    180193void MHMcCT1CollectionArea::Draw(Option_t* option)
    181194{
    182     if (!gPad)
    183         MH::MakeDefCanvas(fHistCol);
    184 
    185     fHistCol->Draw(option);
    186 
    187     gPad->SetLogx();
    188 
    189     gPad->Modified();
    190     gPad->Update();
     195  if (!gPad)
     196    MH::MakeDefCanvas(fHistCol);
     197
     198  fHistCol->Draw(option);
     199
     200  gPad->SetLogx();
     201
     202  gPad->Modified();
     203  gPad->Update();
    191204}
    192205
     
    344357    }
    345358
    346     SetReadyToSave();
    347 }
    348 
     359  SetReadyToSave();
     360}
  • trunk/MagicSoft/Mars/mhist/MHMcCT1CollectionArea.h

    r1823 r1824  
    66#endif
    77
    8 class TH1D;
    98class TH2D;
    109
     
    1615    TH2D *fHistSel; //! the selected showers
    1716    TH2D *fHistCol; //  the collection area
     17    void SetBins(Int_t nbins, Axis_t minEnergy, Axis_t maxEnergy);
    1818
    1919public:
    20     MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL);
     20    MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL, Int_t nbins=45, Axis_t minEnergy=100., Axis_t maxEnergy=30000.);
    2121    ~MHMcCT1CollectionArea();
    2222
     
    3939
    4040
     41
     42
Note: See TracChangeset for help on using the changeset viewer.