Ignore:
Timestamp:
04/25/02 11:21:46 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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*/
Note: See TracChangeset for help on using the changeset viewer.