Changeset 2250


Ignore:
Timestamp:
06/27/03 17:29:49 (22 years ago)
Author:
moralejo
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2247 r2250  
    11                                                 -*-*- END OF LINE -*-*-
     2
     3 2003/06/27: Abelardo Moralejo
     4
     5   * mmontecarlo/MMcCollectionAreaCalc.[h,cc]:
     6   * mhistmc/MHMcCollectionAreaCalc.[h,cc]:
     7
     8     - Adapted to allow their use with multiple files containing
     9       MC data generated with diffferent energy spectra, even with
     10       camera files which have only triggered events inside. Now the
     11       histogram containing all showers (before trigger) is filled
     12       in the ReInit function, and calculation of collection area
     13       is done by CalcEfficiency2(). Some simplifications and cleaning
     14       are still possible.
    215
    316 2003/06/27: Thomas Bretz
  • trunk/MagicSoft/Mars/mhistmc/MHMcCollectionArea.cc

    r2173 r2250  
    237237//  flag
    238238//
    239 void MHMcCollectionArea::CalcEfficiency(UInt_t numevts, Float_t emin, Float_t emax, Float_t index)
     239void MHMcCollectionArea::CalcEfficiency2()
    240240{
    241241    // Here we estimate the total number of showers in each energy bin
     
    244244
    245245    TH1D &histsel = *fHistSel->ProjectionX();
    246 
    247     TH1D histall;
     246    TH1D &histall = *fHistAll->ProjectionX();
    248247
    249248    TAxis &xaxis = *histsel.GetXaxis();
    250 
    251     MH::SetBinning(&histall, &xaxis);
    252249    MH::SetBinning(fHistCol, &xaxis);
    253 
    254     const Float_t expo = 1+index;
    255 
    256     const Float_t k = (Float_t)numevts / (pow(emax,expo) - pow(emin,expo));
    257 
    258250    const Int_t nbinx = xaxis.GetNbins();
    259 
    260     for (Int_t i=1; i<=nbinx; i++)
    261     {
    262         const Float_t e1 = histall.GetBinLowEdge(i);
    263         const Float_t e2 = histall.GetBinLowEdge(i+1);
    264 
    265         if (e1 < emin || e2 > emax)
    266             continue;
    267 
    268         const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
    269 
    270         histall.SetBinContent(i, events);
    271         histall.SetBinError(i, sqrt(events));
    272 
    273     }
    274251
    275252    // -----------------------------------------------------------
     
    282259
    283260    *fLog << warn << endl << dbginf << "WARNING! I will assume a maximum impact parameter of 300 meters for the MC events. Check that this is the true one!" <<endl<<endl;
    284     const Float_t area = TMath::Pi() * (r2*r2 - r1*r1);
     261    const Float_t total_area = TMath::Pi() * (r2*r2 - r1*r1);
    285262
    286263    for (Int_t ix=1; ix<=nbinx; ix++)
     
    303280
    304281        const Double_t efferr = sqrt((1.-eff)*Ns)/Na;
    305 
    306         fHistCol->SetBinContent(ix, eff*area);
    307         fHistCol->SetBinError(ix, efferr*area);
     282       
     283        const Float_t col_area  =  eff * total_area;
     284        const Float_t col_area_error =  efferr * total_area;
     285
     286        fHistCol->SetBinContent(ix, col_area);
     287        fHistCol->SetBinError(ix, col_area_error);
    308288    }
    309289
  • trunk/MagicSoft/Mars/mhistmc/MHMcCollectionArea.h

    r2036 r2250  
    3535    const TH1D *GetHist() const { return fHistCol; }
    3636
     37    TH2D *GetHistAll()    { return fHistAll; }
     38
    3739    void Draw(Option_t *option="");
    3840
    3941    void CalcEfficiency();
    40     void CalcEfficiency(UInt_t allevts, Float_t emin, Float_t emax, Float_t index);
     42    void CalcEfficiency2();
    4143
    4244    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
  • trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc

    r2237 r2250  
    6363    AddToBranchList("MMcEvt.fEnergy");
    6464    AddToBranchList("MMcEvt.fImpact");
     65
     66    fCorsikaVersion           =  0;
     67    fAllEvtsTriggered         =  kFALSE;
     68    fTotalNumSimulatedShowers =  0;
     69    fTheta                    = -1.;
     70
    6571}
    6672
     
    7682    }
    7783
    78     fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
    79     if (!fCollArea)
    80         return kFALSE;
    81 
    82     fTheta                    =  -1;
    83     fEmin                     =  -1;
    84     fEmax                     =  -1;
    85     fSlope                    =   0;
    86     fTotalNumSimulatedShowers =   0;
    87     fCorsikaVersion           =   0;
    88     fAllEvtsTriggered         = kFALSE;
    89 
    9084    return kTRUE;
    9185}
     
    108102
    109103    fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
    110 
    111104    *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
     105
    112106
    113107    if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
     
    116110        *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;
    117111    }
    118 
    119112    fTheta = runheader->GetTelesTheta();
     113
    120114
    121115    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
    122116        *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
    123 
    124117    fCorsikaVersion = runheader->GetCorsikaVersion();
    125118
    126     if ( fEmin > 0 &&
    127          (fEmin  != corrunheader->GetELowLim() ||
    128           fEmax  != corrunheader->GetEUppLim() ||
    129           fSlope != corrunheader->GetSlopeSpec()) )
    130       *fLog << warn << dbginf << "Warning - Read files have different energy distribution..." << endl;
    131 
    132     fEmin  = corrunheader->GetELowLim();
    133     fEmax  = corrunheader->GetEUppLim();
    134     fSlope = corrunheader->GetSlopeSpec();
    135119
    136120    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
    137 
    138121    *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
    139122
     123
     124    fCollArea = (MHMcCollectionArea*)plist->FindCreateObj("MHMcCollectionArea");
     125    if (!fCollArea)
     126        return kFALSE;
     127
    140128    if (fAllEvtsTriggered)
     129      {
     130        //
     131        // Calculate approximately the original number of events in each
     132        // energy bin:
     133        //
     134
     135        const Float_t emin = corrunheader->GetELowLim();
     136        const Float_t emax = corrunheader->GetEUppLim();
     137        const Float_t expo = 1 + corrunheader->GetSlopeSpec();
     138        const Float_t k = runheader->GetNumSimulatedShowers() /
     139          (pow(emax,expo) - pow(emin,expo)) ;
     140
     141        const Int_t nbinx = fCollArea->GetHistAll()->GetNbinsX();
     142
     143        for (Int_t i = 1; i <= nbinx; i++)
     144          {
     145            const Float_t e1 = fCollArea->GetHistAll()->GetXaxis()->GetBinLowEdge(i);
     146            const Float_t e2 = fCollArea->GetHistAll()->GetXaxis()->GetBinLowEdge(i+1);
     147
     148            if (e1 < emin || e2 > emax)
     149              continue;
     150
     151            const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
     152            //
     153            // We fill the ith energy bin, with the total number of events
     154            // Second argument of Fill would be impact parameter of each
     155            // event, but we don't really need it for the collection area,
     156            // so we just put a dummy value (1.)
     157            //
     158
     159            const Float_t energy = (e1+e2)/2.;
     160            fCollArea->GetHistAll()->Fill(energy, 1., events);
     161          }
     162
    141163        return kTRUE;
     164      }
    142165
    143166    fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
     
    190213    {
    191214        *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
    192         fCollArea->CalcEfficiency(fTotalNumSimulatedShowers, fEmin, fEmax, fSlope);
    193     }
    194 
    195     return kTRUE;
    196 }
    197 
     215        fCollArea->CalcEfficiency2();
     216    }
     217
     218    return kTRUE;
     219}
     220
  • trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h

    r2207 r2250  
    55#include "MTask.h"
    66#endif
     7
     8#include <TH2.h>
    79
    810class MParList;
     
    2325    UInt_t fTotalNumSimulatedShowers;
    2426    UInt_t fCorsikaVersion;
     27    Bool_t fAllEvtsTriggered;
    2528    Float_t fTheta;
    26     Float_t fEmin;
    27     Float_t fEmax;
    28     Float_t fSlope;
    29 
    30     Bool_t fAllEvtsTriggered;
    3129
    3230    Bool_t ReInit(MParList *plist);
Note: See TracChangeset for help on using the changeset viewer.