Changeset 1228 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
03/01/02 15:40:22 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1227 r1228  
    11                                                                  -*-*- END -*-*-
     2
     3 2002/03/01: Thomas Bretz
     4
     5   * mhist/MHMcEfficiencyEnergy.[h,cc], mhist/MHMcEfficiencyImpact.[h,cc],
     6     mhist/MHMcDifRate.[h,cc], mhist/MHMcIntRate.[h,cc]:
     7     - added
     8     
     9   * mhist/Makefile, mhist/HistLinkDef.h:
     10     - added MHMcEfficiencyEnergy and MHMcEfficiencyImpact
     11     - added MHMcDifRate and MHMcIntRate
     12
     13   * mhist/MHMcCollectionArea.[h,cc]:
     14     - changed instantiation of collection area histogram
     15     - added settings for the binning
     16     - replaced division by root function
     17     - added Calc-functions
     18     - added GetHist
     19
     20   * mhist/MHMcEfficiency.[h,cc]:
     21     - changed pointers in Calc functions to references
     22
     23
    224
    325 2002/02/28: Thomas Bretz
  • trunk/MagicSoft/Mars/mhist/HistLinkDef.h

    r1227 r1228  
    2525
    2626#pragma link C++ class MHMcRate+;
     27#pragma link C++ class MHMcDifRate+;
     28#pragma link C++ class MHMcIntRate+;
    2729#pragma link C++ class MHMcEfficiency+;
     30#pragma link C++ class MHMcEfficiencyImpact+;
     31#pragma link C++ class MHMcEfficiencyEnergy+;
    2832#pragma link C++ class MHMcEnergy+;
    2933#pragma link C++ class MHMcEnergyImpact+;
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc

    r1227 r1228  
    3131#include "MH.h"
    3232#include "MHMcEfficiency.h"
     33#include "MHMcEnergyImpact.h"
    3334
    3435ClassImp(MHMcCollectionArea);
     
    5253 
    5354    fName  = name  ? name  : "MHMcCollectionArea";
    54     fTitle = title ? title : "Data to Calculate Collection Area";
     55    fTitle = title ? title : "Collection Area vs. Energy";
    5556
    5657    const Int_t  nbins = 50;
     
    7071    fHistSel = new TH2D("SelectedEvents", "Selected showers - Radius vs Energy distribution",
    7172                        nbins, binsx, nbins, binsy);
    72     fHistCol = new TH1D("CollectionArea", "Collection Area vs. Energy",
    73                         nbins, binsx);
    7473
    7574    delete binsx;
    7675    delete binsy;
     76
     77    fHistCol = new TH1D;
     78    fHistCol->SetName(fName);
     79    fHistCol->SetTitle(fTitle);
    7780
    7881    fHistAll->SetDirectory(NULL);
     
    193196}
    194197
    195 void MHMcCollectionArea::Calc(MHMcEfficiency *heff)
     198void MHMcCollectionArea::Calc(const MHMcEfficiency &heff)
    196199{
    197200    //
     
    199202    //  energies
    200203    //
    201     TH2D &h = (TH2D&)*heff->GetHist();
     204    TH2D &h = (TH2D&)*heff.GetHist();
     205
     206    MH::SetBinning(fHistCol, h.GetXaxis());
    202207
    203208    const Int_t nbinx = h.GetXaxis()->GetNbins();
     
    228233        fHistCol->SetBinError(ix, sqrt(errA));
    229234    }
     235
     236    SetReadyToSave();
    230237}
    231238
     
    237244void MHMcCollectionArea::CalcEfficiency()
    238245{
    239     // Description!
    240 
    241     /*
    242     //
    243     //  first of all calculate the efficency
    244     //  do it here by hand to get the right error of efficency
    245     //
    246     const Int_t nbinx = fHistSel->GetXaxis()->GetNbins();
    247     const Int_t nbiny = fHistSel->GetYaxis()->GetNbins();
    248 
    249     for (Int_t ix=1; ix<=nbinx; ix++)
    250     {
    251         for (Int_t iy=1; iy<=nbiny; iy++)
    252         {
    253             const Float_t Na = fHistAll->GetCellContent(ix, iy);
    254 
    255             if (Na <= 0)
    256                 continue;
    257 
    258             const Float_t Ns = fHistSel->GetCellContent(ix, iy);
    259 
    260             const Double_t eff = Ns/Na;
    261             const Double_t err = sqrt((1.-eff)*Ns)/Na;
    262 
    263             // old calculation from Harald:
    264             //  const Double_t eff = Ns/Na;
    265             //  const Double_t err = sqrt(Na + Na*Ns - Ns*Ns - Ns) / (Na*Na);
    266 
    267             fHistSel->SetCellContent(ix, iy, eff);
    268             fHistSel->SetCellError(ix, iy, err);
    269         }
    270     }
    271 
    272     //
    273     //  now calculate the Collection area for different
    274     //  energies
    275     //
    276     for (Int_t ix=1; ix<=nbinx; ix++)
    277     {
    278         Double_t errA = 0;
    279         Double_t colA = 0;
    280 
    281         for (Int_t iy=1; iy<=nbiny; iy++)
    282         {
    283             TAxis *yaxis = fHistSel->GetYaxis();
    284 
    285             const Double_t r1  = yaxis->GetBinLowEdge(iy);
    286             const Double_t r2  = yaxis->GetBinLowEdge(iy+1);
    287 
    288             const Double_t A   = TMath::Pi() * (r2*r2 - r1*r1);
    289 
    290             const Double_t eff = fHistSel->GetCellContent(ix, iy);
    291             const Double_t err = fHistSel->GetCellError(ix, iy);
    292 
    293             colA += eff*A;
    294             errA += A*A * err*err;
    295         }
    296 
    297         fHistCol->SetBinContent(ix, colA);
    298         fHistCol->SetBinError(ix, sqrt(errA));
    299         }
    300         */
    301246    MHMcEfficiency heff;
    302     heff.Calc(fHistSel, fHistAll);
    303 
    304     Calc(&heff);
    305 
    306     SetReadyToSave();
    307 }
     247    heff.Calc(*fHistSel, *fHistAll);
     248
     249    Calc(heff);
     250}
     251
     252void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
     253{
     254    MHMcEfficiency heff;
     255    heff.Calc(*mcsel.GetHist(), *mcall.GetHist());
     256
     257    Calc(heff);
     258}
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h

    r1227 r1228  
    1010
    1111class MHMcEfficiency;
     12class MHMcEnergyImpact;
    1213
    1314class MHMcCollectionArea : public MParContainer
     
    3031    void DrawSel(Option_t *option="");
    3132
     33    const TH1D *GetHist()       { return fHistCol; }
     34    const TH1D *GetHist() const { return fHistCol; }
     35
    3236    void Draw(Option_t *option="");
    3337    TObject *DrawClone(Option_t *option="") const;
     
    3539    void CalcEfficiency();
    3640
    37     void Calc(MHMcEfficiency *eff);
     41    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
     42    void Calc(const MHMcEfficiency &heff);
    3843
    3944    ClassDef(MHMcCollectionArea, 1)  // Data Container to calculate Collection Area
  • trunk/MagicSoft/Mars/mhist/MHMcEfficiency.cc

    r1227 r1228  
    4141#include "MH.h"
    4242#include "MBinning.h"
     43
     44#include "MHMcEnergyImpact.h"
    4345
    4446ClassImp(MHMcEfficiency);
     
    133135}
    134136
    135 
    136 // --------------------------------------------------------------------------
    137 //
    138 //  Calculate the Efficiency and set the 'ReadyToSave' flag.
    139 //  The Efficiency is calculated as the number of selected showers
    140 //  (eg. triggered ones) divided by the number of all showers.
    141 //  For error calculation Binomial errors are computed.
    142 //
    143 void MHMcEfficiency::Calc(TH2D *hsel, TH2D *hall)
     137void MHMcEfficiency::Calc(const TH2D &hsel, const TH2D &hall)
    144138{
    145139    //
    146140    // Set the binning from the two axis of one of the two histograms
    147141    //
    148     MH::SetBinning(&fHist, hsel->GetXaxis(), hsel->GetYaxis());
     142    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
    149143
    150144    //
     
    161155    // calculation we assume a binomial error calculation.
    162156    //
    163     fHist.Divide(hsel, hall, 1, 1, "B");
     157    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
    164158
    165159    SetReadyToSave();
    166160}
     161
     162// --------------------------------------------------------------------------
     163//
     164//  Calculate the Efficiency and set the 'ReadyToSave' flag.
     165//  The Efficiency is calculated as the number of selected showers
     166//  (eg. triggered ones) divided by the number of all showers.
     167//  For error calculation Binomial errors are computed.
     168//
     169void MHMcEfficiency::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
     170{
     171    Calc(*mcsel.GetHist(), *mcall.GetHist());
     172
     173}
  • trunk/MagicSoft/Mars/mhist/MHMcEfficiency.h

    r1227 r1228  
    1010
    1111class MMcEvt;
     12class MHMcEnergyImpact;
    1213
    1314class MHMcEfficiency : public MParContainer
     
    3233    TObject *DrawClone(Option_t* option = "") const;
    3334
    34     void Calc(TH2D *hsel, TH2D *hall);
     35    void Calc(const TH2D &hsel, const TH2D &hall);
     36    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
    3537
    3638    ClassDef(MHMcEfficiency, 1)  // Histogram container for montecarlo energy threshold
  • trunk/MagicSoft/Mars/mhist/Makefile

    r1227 r1228  
    4747           MHMcEnergy.cc \
    4848           MHMcEfficiency.cc \
     49           MHMcEfficiencyImpact.cc \
     50           MHMcEfficiencyEnergy.cc \
    4951           MHMcEnergyImpact.cc \
    50            MHMcRate.cc
     52           MHMcRate.cc \
     53           MHMcIntRate.cc \
     54           MHMcDifRate.cc
    5155
    5256SRCS    = $(SRCFILES)
Note: See TracChangeset for help on using the changeset viewer.