Ignore:
Timestamp:
10/11/06 08:55:36 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhflux
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc

    r7684 r8047  
    6464//
    6565MHCollectionArea::MHCollectionArea(const char *name, const char *title)
    66   : fMcEvt(0), /*fEnergy(0),*/ fMcAreaRadius(300.), fIsExtern(kFALSE)
     66  : fMcEvt(0), fMcAreaRadius(-1), fIsExtern(kFALSE)
    6767{
    6868    //   initialize the histogram for the distribution r vs E
     
    8282    fHistSel.SetDirectory(NULL);
    8383    fHistSel.UseCurrentStyle();
     84    fHistSel.SetLineColor(kBlue);
    8485
    8586    fHistAll.SetName("AllEvts");
     
    105106    MH::SetBinning(&fHistSel, &binst, &binse);
    106107    MH::SetBinning(&fHistAll, &binst, &binse);
     108
     109    // For some unknown reasons this must be called after
     110    // the binning has been initialized at least once
     111    fHistSel.Sumw2();
     112    fHistAll.Sumw2();
     113    fHEnergy.Sumw2();
    107114}
    108115
     
    114121void MHCollectionArea::CalcEfficiency()
    115122{
    116     TH1D *hsel = fHistSel.ProjectionY();
    117     TH1D *hall = fHistAll.ProjectionY();
    118 
    119     const Int_t nbinx = hsel->GetNbinsX();
    120 
    121     // -----------------------------------------------------------
    122     //
    123     // Impact parameter range:  TO BE FIXED! Impact parameter shoud be
    124     // read from run header, but it is not yet in!!
     123    TH1D *hsel = fHistSel.ProjectionY("Spy", -1, 9999, "E");;
     124    TH1D *hall = fHistAll.ProjectionY("Apy", -1, 9999, "E");
     125
     126    //
     127    // Impact parameter range.
    125128    //
    126129    const Float_t totalarea = GetCollectionAreaAbs();//TMath::Pi() * (r2*r2 - r1*r1);
    127130
    128     for (Int_t ix=1; ix<=nbinx; ix++)
    129     {
    130         const Float_t Na = hall->GetBinContent(ix);
    131 
    132         if (Na <= 0)
    133             continue;
    134 
    135         const Float_t Ns = hsel->GetBinContent(ix);
    136 
    137         // Since Na is an estimate of the total number of showers generated
    138         // in the energy bin, it may happen that Ns (triggered showers) is
    139         // larger than Na. In that case, the bin is skipped:
    140 
    141         if (Na < Ns)
    142             continue;
    143 
    144         const Double_t eff         = Ns/Na;
    145         const Double_t efferr      = TMath::Sqrt((1.-eff)*Ns)/Na;
    146        
    147         const Float_t colarea      =  eff    * totalarea;
    148         const Float_t colareaerror =  efferr * totalarea;
    149 
    150         fHEnergy.SetBinContent(ix, colarea);
    151         fHEnergy.SetBinError(ix,   colareaerror);
    152     }
     131    // "b" option: calculate binomial errors
     132    fHEnergy.Divide(hsel, hall, totalarea, 1, "b");
     133#if ROOT_VERSION_CODE < ROOT_VERSION(5,13,04)
     134    MH::SetBinomialErrors(fHEnergy, *hsel, *hall, totalarea, 1);
     135#endif
    153136
    154137    delete hsel;
    155138    delete hall;
    156139}
     140
    157141
    158142Bool_t MHCollectionArea::SetupFill(const MParList *pl)
     
    196180    MH::SetBinning(&fHistAll, &binst, &binse);
    197181
     182    fMcAreaRadius = -1;
     183
    198184    return kTRUE;
    199185}
     
    201187Bool_t MHCollectionArea::ReInit(MParList *plist)
    202188{
     189    MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
     190    if (!runheader)
     191    {
     192        *fLog << err << "MMcRunHeader not found... abort." << endl;
     193        return kFALSE;
     194    }
     195
     196    // FIXME: Does this need some weighting with the number of produced events?
     197    if (runheader->GetImpactMax()>fMcAreaRadius*100)
     198    {
     199        fMcAreaRadius = 0.01*runheader->GetImpactMax(); // cm->m
     200        *fLog << inf << "Maximum simulated impact: " << fMcAreaRadius << "m" << endl;
     201    }
     202
    203203    if (fIsExtern)
    204204        return kTRUE;
    205205
    206     MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
    207     if (!runheader)
    208     {
    209         *fLog << err << "MMcRunHeader not found... abort." << endl;
    210         return kFALSE;
    211     }
    212 
    213206    fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
    214207    *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
    215208
    216  /*
    217     if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
    218     {
    219         *fLog << warn << "Warning - Read files have different TelesTheta (";
    220         *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;
    221     }
    222     fTheta = runheader->GetTelesTheta();
    223   */
    224209    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
    225210        *fLog << warn << "Warning - Read files have different Corsika versions..." << endl;
     
    352337    if (h1 && h2 && h)
    353338    {
    354         h->Divide(h2, h1);
    355         h->SetMinimum(0);
     339            h->Divide(h2, h1, 1, 1, "b");
     340#if ROOT_VERSION_CODE < ROOT_VERSION(5,13,04)
     341            MH::SetBinomialErrors(*h, *h2, *h1);
     342#endif
     343            h->SetMinimum(0);
    356344    }
    357345
     
    433421        gPad->SetLogx();
    434422        h = h2->DrawCopy();
    435         h->Divide(h1);
     423        h->Divide(h2, h1, 1, 1, "b");
     424#if ROOT_VERSION_CODE < ROOT_VERSION(5,13,04)
     425        MH::SetBinomialErrors(*h, *h2, *h1);
     426#endif
    436427        h->SetNameTitle("Efficiency", "Combined cut and trigger efficiency");
    437428        h->SetDirectory(NULL);
     
    456447Bool_t MHCollectionArea::Fill(const MParContainer *par, const Stat_t weight)
    457448{
    458     const Double_t energy = fMcEvt->GetEnergy()/*fEnergy->GetVal()*/;
     449    const Double_t energy = fMcEvt->GetEnergy();
    459450    const Double_t theta  = fMcEvt->GetTelescopeTheta()*TMath::RadToDeg();
    460451
    461     //*fLog << energy << " " << theta << endl;
    462 
    463452    fHistSel.Fill(theta, energy, weight);
    464453
  • trunk/MagicSoft/Mars/mhflux/MHCollectionArea.h

    r7683 r8047  
    6060    Double_t GetCollectionAreaAbs() const { return TMath::Pi()*fMcAreaRadius*fMcAreaRadius; }
    6161
    62 /*
    63     void DrawAll(Option_t *option="");
    64     void DrawSel(Option_t *option="");
    65 
    66     const TH1D *GetHist()       { return fHistCol; }
    67     const TH1D *GetHist() const { return fHistCol; }
    68 
    69 
    70 
    71     void CalcEfficiency();
    72     void CalcEfficiency2();
    73 
    74     void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
    75     void Calc(const MHMcEfficiency &heff);
    76   */
    7762    void SetMcAreaRadius(Float_t x) { fMcAreaRadius = x; }
    7863
  • trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc

    r8021 r8047  
    9494    fHImpact.SetYTitle("E_{est}/E_{mc}-1");
    9595
    96     fHEnergy.Sumw2();
    97     fHImpact.Sumw2();
    98     fHResolution.Sumw2();
    99 
    10096    MBinning binsi, binse, binst, binsr;
    10197    binse.SetEdgesLog(25, 10, 1000000);
     
    107103    SetBinning(&fHImpact,     &binsi, &binsr);
    108104    SetBinning(&fHResolution, &binse, &binse, &binsr);
     105
     106    // For some unknown reasons this must be called after
     107    // the binning has been initialized at least once
     108    fHEnergy.Sumw2();
     109    fHResolution.Sumw2();
     110    fHImpact.Sumw2();
    109111}
    110112
     
    243245{
    244246    // Project into EnergyEst_ey
     247    // the "e" ensures that errors are calculated
    245248    TH1D *h1 = (TH1D*)fHEnergy.Project3D("rtlprmft_ex"); // E_Est
    246249    TH1D *h2 = (TH1D*)fHEnergy.Project3D("rtlprmft_ey"); // E_mc
  • trunk/MagicSoft/Mars/mhflux/MHThreshold.cc

    r7715 r8047  
    7979    fHEnergy.SetDirectory(NULL);
    8080    fHEnergy.UseCurrentStyle();
    81     fHEnergy.Sumw2();
    8281
    8382    MBinning binse(50, 20, 50000, "", "log");
    8483    binse.Apply(fHEnergy);
     84
     85    fHEnergy.Sumw2();
    8586}
    8687
  • trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc

    r8036 r8047  
    443443Int_t MMcSpectrumWeight::Process()
    444444{
    445     const Double_t e = fMcEvt->GetEnergy();
    446 
    447445    Double_t w = 1;
    448446
     
    459457    }
    460458
     459    const Double_t e = fMcEvt->GetEnergy();
    461460    fWeight->SetVal(fFunc->Eval(e)*w);
    462461
Note: See TracChangeset for help on using the changeset viewer.