Ignore:
Timestamp:
11/18/04 15:35:43 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc

    r5366 r5429  
    150150//     variable(s) of interest and the binnings)
    151151//
    152 
    153152MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title)
    154153: fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
    155154  fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')),
    156   fDataZ(hist.GetRule('z')), fNumMax(-1)
     155  fDataZ(hist.GetRule('z')), fNumMax(-1), fHistIsProbability(kFALSE)
    157156{
    158157    fName  = name  ? (TString)name  : gsDefName;
     
    384383    }
    385384
    386     MRead *read = (MRead*)tasklist->FindObject("MRead");
    387     if (!read)
    388     {
    389         *fLog << err << "MRead not found... abort." << endl;
    390         return kFALSE;
    391     }
    392 
    393385    if (!PreProcessData(parlist))
    394386        return kFALSE;
     387
     388    fHistNom->SetTitle(fHistIsProbability ? "ProbabilityDistribution" : "Users Nominal Distribution");
     389
     390    if (fHistIsProbability)
     391        return kTRUE;
    395392
    396393    InitHistogram(fHistOrig);
    397394    InitHistogram(fHistRes);
    398395
    399     fHistNom->SetTitle("Users Nominal Distribution");
    400396    fHistOrig->SetTitle("Primary Distribution");
    401397    fHistRes->SetTitle("Resulting Distribution");
     
    407403
    408404    // Generate primary distribution
     405    MRead *read = (MRead*)tasklist->FindObject("MRead");
     406    if (!read)
     407    {
     408        *fLog << err << "MRead not found... abort." << endl;
     409        return kFALSE;
     410    }
     411
    409412    if (!ReadDistribution(*read))
    410413        return kFALSE;
     
    445448
    446449    return rc;
     450}
     451
     452Bool_t MFEventSelector2::SelectProb(Int_t ibin) const
     453{
     454    //
     455    // If value is outside histogram range, accept event
     456    //
     457    return ibin<0 ? kTRUE : fHistNom->GetHist().GetBinContent(ibin) > gRandom->Uniform();
    447458}
    448459
     
    462473    const Double_t valz=fDataZ.GetValue();
    463474
     475    const Int_t ibin = fHistNom->FindFixBin(valx, valy, valz)-1;
     476
    464477    // Get corresponding bin number and check
    465478    // whether a selection should be made
    466     fResult = Select(fHistNom->FindFixBin(valx, valy, valz)-1);
     479    fResult = fHistIsProbability ? Select(ibin) : SelectProb(ibin);
    467480
    468481    fCounter[fResult ? 1 : 0]++;
     
    481494    if (GetNumExecutions()>0)
    482495    {
    483       *fLog << inf << endl;
    484       *fLog << GetDescriptor() << " execution statistics:" << endl;
    485       *fLog << dec << setfill(' ');
    486       *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
    487             << (int)(fCounter[0]*100/GetNumExecutions())
    488             << "%) Events not selected" << endl;
    489 
    490       *fLog << " " << fCounter[0] << " ("
    491             << (int)(fCounter[1]*100/GetNumExecutions())
    492             << "%) Events selected" << endl;
    493       *fLog << endl;
     496        *fLog << inf << endl;
     497        *fLog << GetDescriptor() << " execution statistics:" << endl;
     498        *fLog << dec << setfill(' ');
     499        *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
     500              << (int)(fCounter[0]*100/GetNumExecutions())
     501              << "%) Events not selected" << endl;
     502
     503        *fLog << " " << fCounter[0] << " ("
     504              << (int)(fCounter[1]*100/GetNumExecutions())
     505              << "%) Events selected" << endl;
     506        *fLog << endl;
    494507    }
    495508
  • trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h

    r3330 r5429  
    4242
    4343    Bool_t fResult;
     44    Bool_t fHistIsProbability;
    4445    Int_t  fCounter[2];
    4546
     
    4950    Bool_t PreProcessData(MParList *parlist);
    5051    Bool_t Select(Int_t bin);
     52    Bool_t SelectProb(Int_t bin) const;
    5153
    5254    Int_t PreProcess(MParList *parlist);
     
    6163
    6264    void SetNumMax(Long_t max=-1) { fNumMax = max; }
     65    void SetHistIsProbability(Bool_t b=kTRUE) { fHistIsProbability=b; }
    6366    Bool_t IsExpressionTrue() const { return fResult; }
    6467
Note: See TracChangeset for help on using the changeset viewer.