Ignore:
Timestamp:
11/28/03 08:08:53 (21 years ago)
Author:
wittek
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfilter
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h

    r2521 r2574  
    2424
    2525#pragma link C++ class MFEnergySlope+;
     26#pragma link C++ class MFRandomSplit+;
     27#pragma link C++ class MFAntiFilter+;
    2628
    2729#endif
  • trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc

    r2357 r2574  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz,   01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!              Wolfgang Wittek 11/2003 <mailto:wittek@mppmu.mpg.de>
    1920!
    2021!   Copyright: MAGIC Software Development, 2000-2003
     
    135136//     would result in redistributing cos(Theta).
    136137//
     138//  If 'fUseOrigDistribution' is set to kTRUE (by SetUseOrigDistribution())
     139//     the original distribution will be used as the nominal distribution;
     140//     note that also in this case a dummy nominal distribution has to be
     141//     provided in the first argument (the dummy distribution defines the
     142//     variable(s) of interest and the binnings)
     143//
     144
    137145MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title)
    138146: fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
     
    142150    fName  = name  ? (TString)name  : gsDefName;
    143151    fTitle = title ? (TString)title : gsDefTitle;
    144 }
    145 
    146 // --------------------------------------------------------------------------
    147 //
    148 // Destructor. Deletes fHistRes if allocated.
     152 
     153    fUseOrigDistribution = kFALSE;
     154}
     155
     156// --------------------------------------------------------------------------
     157//
     158//
    149159//
    150160MFEventSelector2::~MFEventSelector2()
    151161{
    152     if (fHistRes)
    153         delete fHistRes;
    154 }
    155 
    156 // --------------------------------------------------------------------------
     162  if (fHistRes)
     163    delete fHistRes;
     164}
     165
     166// --------------------------------------------------------------------------
     167//
     168//
     169//
     170void MFEventSelector2::SetUseOrigDistribution(Bool_t b)
     171{
     172  fUseOrigDistribution = b;
     173 
     174  *fLog << "MFEventSelector2 : use the distribution from the input file as the target distribution"
     175        << endl;
     176}
     177
     178//---------------------------------------------------------------------------
    157179//
    158180// Recreate a MH3 from fHistNom used as a template. Copy the Binning
     
    189211
    190212    *fLog << "-------------------------" << endl;
    191     *fLog << "MFEventSelector2::ReadDistribution; read input file to generate the original distribution" << endl;
     213    *fLog << "MFEventSelector2 : Start of eventloop to generate the original distribution"
     214          << endl;
    192215
    193216    MEvtLoop run(GetName());
     
    214237    if (!run.Eventloop())
    215238    {
    216         *fLog << err << dbginf << "Evtloop failed." << endl;
     239        *fLog << err << dbginf << "Evtloop in MFEventSelector2::ReadDistribution failed." << endl;
    217240        return kFALSE;
    218241    }
     
    222245    *fLog << "MFEventSelector2::ReadDistribution; Original distribution has "
    223246          << fHistOrig->GetHist().GetEntries() << " entries" << endl;
     247    *fLog << "MFEventSelector2 : End of eventloop to generate the original distribution"
     248          << endl;
    224249    *fLog << "-------------------------" << endl;
    225250
     
    229254// --------------------------------------------------------------------------
    230255//
    231 // After reading the histograms and arrays used for the random event
     256// After reading the histograms the arrays used for the random event
    232257// selction are created. If a MStatusDisplay is set the histograms are
    233258// displayed there.
     
    236261{
    237262    TH1 &ho = fHistOrig->GetHist();
    238     TH1 &hn = fHistNom->GetHist();
    239 
    240     fHistNom->SetTitle("Users Nominal Distribution");
    241     fHistRes->SetTitle("Resulting Distribution");
     263
     264    //-------------------
     265    // if requested
     266    // set the nominal distribution equal to the original distribution
     267
     268    TH1 *hnp;
     269    if (fUseOrigDistribution)
     270      hnp = (TH1*)(fHistOrig->GetHist()).Clone();
     271    else
     272      hnp = &fHistNom->GetHist();
     273
     274    TH1 &hn = *hnp;
     275    //--------------------
    242276
    243277    // normalize to number of counts in primary distribution
     
    268302    if (fNumMax>0)
    269303    {
    270         *fLog << "MFEventSelector2::PrepareHistograms; SCALE : fNumMax = "
    271               << fNumMax << ",  hn.Integral() = "      << hn.Integral()
    272               << ",  fNumMax/hn.Integral() = " << fNumMax/hn.Integral()
    273               << endl;
    274 
    275         hn.Scale(fNumMax/hn.Integral());
     304        *fLog << "MFEventSelector2::PrepareHistograms; requested no.of events = "
     305              << fNumMax << ",  maximum no.of events possible = "     
     306              << hn.Integral() << endl;
     307
     308        if (fNumMax > hn.Integral())
     309        {
     310          *fLog << "MFEventSelector2::PrepareHistograms; requested no.of events ("
     311                << fNumMax << ") is too high" << endl;
     312          *fLog << "                                     reduce it to "
     313                << hn.Integral() << endl;
     314        }
     315
     316        else
     317          hn.Scale(fNumMax/hn.Integral());
    276318    }
    277319
     
    297339        fNom[i] = (Long_t)(hn.GetBinContent(i+1)+0.5);
    298340    }
     341
     342    if (fUseOrigDistribution)
     343      delete hnp;
    299344}
    300345
     
    362407    InitHistogram(fHistRes);
    363408
     409    fHistNom->SetTitle("Users Nominal Distribution");
    364410    fHistOrig->SetTitle("Primary Distribution");
     411    fHistRes->SetTitle("Resulting Distribution");
    365412
    366413    // Initialize online display if requested
     
    369416        fHistOrig->Draw();
    370417
    371     // Read primary distribution
     418    // Generate primary distribution
    372419    if (!ReadDistribution(*read))
    373420        return kFALSE;
     
    467514    return kTRUE;
    468515}
     516
     517
     518
     519
     520
     521
     522
     523
     524
  • trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h

    r2357 r2574  
    4141    TCanvas   *fCanvas;   //! canvas for online display
    4242
     43    Bool_t fUseOrigDistribution;
     44
    4345    Bool_t fResult;
    4446    Int_t fErrors[2];
     
    5759    ~MFEventSelector2();
    5860
     61    void SetUseOrigDistribution(Bool_t b=kTRUE);
     62    MH3 *GetHistOrig()                       { return fHistOrig; }
     63
    5964    void SetNumMax(Long_t max=-1) { fNumMax = max; }
    6065    Bool_t IsExpressionTrue() const { return fResult; }
     
    6469
    6570#endif
     71
     72
     73
  • trunk/MagicSoft/Mars/mfilter/Makefile

    r2521 r2574  
    4848           MFCT1SelStandard.cc \
    4949           MFCT1SelFinal.cc \
    50            MFEnergySlope.cc
     50           MFEnergySlope.cc \
     51           MFRandomSplit.cc \
     52           MFAntiFilter.cc
    5153
    5254SRCS    = $(SRCFILES)
Note: See TracChangeset for help on using the changeset viewer.