Ignore:
Timestamp:
04/25/02 11:21:46 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r1283 r1300  
    5050
    5151#include <TH1.h>
     52#include <TH2.h>
     53#include <TH3.h>
    5254#include <TCanvas.h>
    5355
     
    136138}
    137139
    138 void MH::SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy)
     140void MH::SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy)
    139141{
    140142    TAxis &x = *h->GetXaxis();
     
    169171}
    170172
    171 void MH::SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz)
     173void MH::SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz)
    172174{
    173175    //
     
    214216}
    215217
    216 void MH::SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy)
     218void MH::SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy)
    217219{
    218220    MBinning bx;
     
    223225}
    224226
    225 void MH::SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)
     227void MH::SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)
    226228{
    227229    MBinning bx;
     
    245247}
    246248
    247 void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy)
     249void MH::SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy)
    248250{
    249251    const Int_t nx = binsx->GetNbins();
     
    260262}
    261263
    262 void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
     264void MH::SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
    263265{
    264266    const Int_t nx = binsx->GetNbins();
     
    281283void MH::SetBinning(TH1 *h, TH1 *x)
    282284{
    283     SetBinning(h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis());
    284 }
     285    if (h->InheritsFrom(TH3::Class()) && x->InheritsFrom(TH3::Class()))
     286    {
     287        SetBinning((TH3*)h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis());
     288        return;
     289    }
     290    if (h->InheritsFrom(TH2::Class()) && x->InheritsFrom(TH2::Class()))
     291    {
     292        SetBinning((TH2*)h, x->GetXaxis(), x->GetYaxis());
     293        return;
     294    }
     295    if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class()))
     296    {
     297        SetBinning(h, x->GetXaxis());
     298        return;
     299    }
     300}
  • trunk/MagicSoft/Mars/mhist/MH.h

    r1283 r1300  
    77
    88class TH1;
     9class TH2;
     10class TH3;
    911class TAxis;
    1012class TArrayD;
     
    2830
    2931    static void SetBinning(TH1 *h, const MBinning *binsx);
    30     static void SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy);
    31     static void SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
     32    static void SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy);
     33    static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
    3234
    3335    static void SetBinning(TH1 *h, const TArrayD *binsx);
    34     static void SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy);
    35     static void SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);
     36    static void SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy);
     37    static void SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);
    3638
    3739    static void SetBinning(TH1 *h, const TAxis *binsx);
    38     static void SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy);
    39     static void SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz);
     40    static void SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy);
     41    static void SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz);
    4042
    4143    static void SetBinning(TH1 *h, TH1 *x);
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1299 r1300  
    229229    case 2:
    230230        fHist->SetTitle(title+" (2D)");
    231         SetBinning(fHist, binsx, binsy);
     231        SetBinning((TH2*)fHist, binsx, binsy);
    232232        return kTRUE;
    233233    case 3:
    234234        fHist->SetTitle(title+" (3D)");
    235         SetBinning(fHist, binsx, binsy, binsz);
     235        SetBinning((TH3*)fHist, binsx, binsy, binsz);
    236236        return kTRUE;
    237237    }
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc

    r1228 r1300  
    196196}
    197197
     198// --------------------------------------------------------------------------
     199//
     200//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
     201//  flag
     202//
     203void MHMcCollectionArea::CalcEfficiency()
     204{
     205    MHMcEfficiency heff;
     206    heff.Calc(*fHistSel, *fHistAll);
     207
     208    Calc(heff);
     209}
     210
     211void MHMcCollectionArea::CalcEfficiency(UInt_t numevts, Float_t angle)
     212{
     213    // Here we estimate the total number of showers in each energy bin
     214    // known the energy range and spectral index of the generated showers
     215    // (set now by hand since the info is not available in the header!)
     216
     217    TH1D &histsel = *fHistSel->ProjectionX();
     218
     219    TH1D histall;
     220
     221    TAxis &xaxis = *histsel.GetXaxis();
     222
     223    MH::SetBinning(&histall, &xaxis);
     224    MH::SetBinning(fHistCol, &xaxis);
     225
     226    const Float_t emin  = 10.;
     227    const Float_t emax  = 30000.;  // Energies in GeV.
     228    const Float_t index = 2.6;     // Differential spectral Index.
     229
     230    const Float_t expo = 1.-index;
     231
     232    const Float_t k = (Float_t)numevts / (pow(emax,expo) - pow(emin,expo));
     233
     234    const Int_t nbinx = xaxis.GetNbins();
     235
     236    for (Int_t i=1; i<=nbinx; i++)
     237    {
     238        const Float_t e1 = histall.GetBinLowEdge(i);
     239        const Float_t e2 = histall.GetBinLowEdge(i+1);
     240
     241        if (e1 < emin || e2 > emax)
     242            continue;
     243
     244        const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
     245
     246        histall.SetBinContent(i, events);
     247        histall.SetBinError(i, sqrt(events));
     248
     249    }
     250
     251    // -----------------------------------------------------------
     252
     253    // Impact parameter range:
     254    const Float_t r1 = 0;
     255    const Float_t r2 = 400;
     256
     257    const Float_t dr = TMath::Pi() * (r2*r2 - r1*r1);
     258
     259    angle *= TMath::Pi()/180;
     260
     261    for (Int_t ix=1; ix<=nbinx; ix++)
     262    {
     263        const Float_t Na = histall.GetBinContent(ix);
     264
     265        if (Na <= 0)
     266            continue;
     267
     268        const Float_t Ns = histsel.GetBinContent(ix);
     269
     270        // Since Na is an estimate of the total number of showers generated
     271        // in the energy bin, it may happen that Ns (triggered showers) is
     272        // larger than Na. In that case, the bin is skipped:
     273
     274        if (Na < Ns)
     275            continue;
     276
     277        const Double_t eff = Ns/Na;
     278
     279        const Double_t err = sqrt((1.-eff)*Ns)/Na;
     280
     281        const Float_t area = dr * cos(angle);
     282
     283        fHistCol->SetBinContent(ix, eff*area);
     284        fHistCol->SetBinError(ix, err*area);
     285    }
     286
     287    delete &histsel;
     288
     289    SetReadyToSave();
     290}
     291
     292void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
     293{
     294    MHMcEfficiency heff;
     295    heff.Calc(*mcsel.GetHist(), *mcall.GetHist());
     296
     297    Calc(heff);
     298}
     299
    198300void MHMcCollectionArea::Calc(const MHMcEfficiency &heff)
    199301{
     
    242344//  flag
    243345//
    244 void MHMcCollectionArea::CalcEfficiency()
    245 {
    246     MHMcEfficiency heff;
    247     heff.Calc(*fHistSel, *fHistAll);
    248 
    249     Calc(heff);
    250 }
    251 
    252 void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
    253 {
    254     MHMcEfficiency heff;
    255     heff.Calc(*mcsel.GetHist(), *mcall.GetHist());
    256 
    257     Calc(heff);
    258 }
     346/*
     347void MHMcCollectionArea::Calc(MHMcEnergyImpact &mcsel, UInt_t numevents, Float_t angle)
     348{
     349}
     350*/
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h

    r1228 r1300  
    3838
    3939    void CalcEfficiency();
     40    void CalcEfficiency(UInt_t allevts, Float_t theta);
    4041
    4142    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
Note: See TracChangeset for help on using the changeset viewer.