NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcPsiDistrib Class Reference

Simple class to simulate Bayesian psi distributions. More...

#include "NcPsiDistrib.h"

Detailed Description

Simple class to simulate Bayesian psi distributions.


Copyright(c) 2008 NCFS/IIHE, All Rights Reserved. *
*
Authors: The Netherlands Center for Fundamental Studies (NCFS). *
The Inter-university Institute for High Energies (IIHE). *
Website : http://www.iihe.ac.be *
Contact : Nick van Eijndhoven (nickve.nl@gmail.com) *
*
Contributors are mentioned in the code where appropriate. *
*
No part of this software may be used, copied, modified or distributed *
by any means nor transmitted or translated into machine language for *
commercial purposes without written permission by the IIHE representative. *
Permission to use the software strictly for non-commercial purposes *
is hereby granted without fee, provided that the above copyright notice *
appears in all copies and that both the copyright notice and this *
permission notice appear in the supporting documentation. *
This software is provided "as is" without express or implied warranty. *
The authors make no claims that this software is free of error, or is *
consistent with any particular standard of merchantability, or that it *
will meet your requirements for any particular application, other than *
indicated in the corresponding documentation. *
This software should not be relied on for solving a problem whose *
incorrect solution could result in injury to a person or loss of property. *
If you do use this software in such a manner, it is at your own risk. *
The authors disclaim all liability for direct or consequential damage *
resulting from your use of this software. *

// Class NcPsiDistrib
// Tool to analyse the distribution of possibly observed psi values
// (see NcMath::PsiValue()) in the case of random background only
// or in the presence of a user-specified signal.
//
// Example: comparing two psi distributions for 60 observed events:
// 1) Under the hypothesis of background only
// 2) Under the hypothesis of a signal of 10 events in one bin
//
// Int_t ntrials=10000;
// Int_t nbins=1000;
// Int_t nsig=10;
// Int_t nbg=50;
//
// NcPsiDistrib pd;
// pd.SetNtrials(ntrials);
// pd.SetNoutcomes(nbins);
//
// // BG only
// pd.SetNevents(nbg+nsig);
// Int_t sig[nbins];
// for(Int_t i=0; i<nbins; i++) { sig[i]=0; }
// pd.SetSignal(sig);
// pd.Distribute(1);
// TH1D bgonly;
// pd.GetPsiHisto()->Copy(bgonly);
// Double_t meanbgonly=pd.GetPsiSample()->GetMean(1);
// Double_t spreadbgonly=pd.GetPsiSample()->GetSigma(1);
// Double_t medianbgonly=pd.GetPsiSample()->GetMedian(1);
//
// // Signal
// pd.SetNevents(nbg);
// sig[0]=nsig; // Add signal events
// pd.SetSignal(sig);
// pd.Distribute(1);
// TH1D bgplussig;
// pd.GetPsiHisto()->Copy(bgplussig);
// Double_t meansig=pd.GetPsiSample()->GetMean(1);
// Double_t spreadsig=pd.GetPsiSample()->GetSigma(1);
// Double_t mediansig=pd.GetPsiSample()->GetMedian(1);
//
// // Output
// cout << nbg << " background events, " << nsig << " signal events" << endl;
// cout << "Background only: psi = " << meanbgonly << " +/- " << spreadbgonly << ", median = " << medianbgonly << endl;
// cout << "Signal: psi = " << meansig << " +/- " << spreadsig << ", median = " << mediansig << endl;
//
// // Draw histograms
// bgonly.Draw();
// bgplussig.Draw("same");
//
//--- Author: Garmt de Vries-Uiterweerd 15-jun-2008 Utrecht University
//- Modified: NvE $Date: 2010-03-19 11:10:02 +0100 (Fri, 19 Mar 2010) $ NCFS

Definition at line 15 of file NcPsiDistrib.h.

Public Member Functions

 NcPsiDistrib ()
 
virtual ~NcPsiDistrib ()
 
void Distribute (Int_t storemode=0)
 
Double_t GetFracAbove ()
 
Double_t GetFracBelow ()
 
TH1D * GetPsiHisto ()
 
NcSampleGetPsiSample ()
 
void SetNevents (Int_t n)
 
void SetNoutcomes (Int_t n, Double_t *p=0)
 
void SetNtrials (Long_t n)
 
void SetPrintFreq (Int_t freq)
 
void SetProbabilities (Double_t *p)
 
void SetPsiRange (Int_t nb, Float_t low, Float_t high)
 
void SetReferencePsi (Double_t ref)
 
void SetSignal (Int_t *s)
 

Protected Member Functions

Float_t FindMaxPsi ()
 

Protected Attributes

Long_t fNabove
 
Long_t fNbelow
 
Int_t fNevents
 
Int_t fNoutcomes
 
Long_t fNtrials
 
Int_t fPrintFreq
 
Double_t * fProbs
 
TH1D * fPsiHisto
 
Bool_t fRangeSet
 
Double_t fRefPsi
 
NcSamplefSample
 
Int_t * fSignal
 

Constructor & Destructor Documentation

◆ NcPsiDistrib()

NcPsiDistrib::NcPsiDistrib ( )
// Default constructor.

Definition at line 97 of file NcPsiDistrib.cxx.

◆ ~NcPsiDistrib()

NcPsiDistrib::~NcPsiDistrib ( )
virtual
// Default destructor.

Definition at line 130 of file NcPsiDistrib.cxx.

Member Function Documentation

◆ Distribute()

void NcPsiDistrib::Distribute ( Int_t storemode = 0)
// Make distribution.
// The parameter storemode is the mode to be used for the NcSample of the
// psi distribution. In case storemode=1, entered data will be stored in the
// sample, allowing the user to find the median of the psi distribution.
// Setting mode=1 can be memory-intensive, and is not advised when dealing
// with large number of trials. The default is storemode=0, meaning no storage
// of entered data.

Definition at line 298 of file NcPsiDistrib.cxx.

◆ FindMaxPsi()

Float_t NcPsiDistrib::FindMaxPsi ( )
protected
// Find the maximum possible psi value with the given signal, probabilities and number of events.

Definition at line 424 of file NcPsiDistrib.cxx.

◆ GetFracAbove()

Double_t NcPsiDistrib::GetFracAbove ( )
// Get fraction of trials in which a psi larger than the reference psi is observed.

Definition at line 413 of file NcPsiDistrib.cxx.

◆ GetFracBelow()

Double_t NcPsiDistrib::GetFracBelow ( )
// Get fraction of trials in which a psi smaller than the reference psi is observed.

Definition at line 402 of file NcPsiDistrib.cxx.

◆ GetPsiHisto()

TH1D * NcPsiDistrib::GetPsiHisto ( )
// Get histogram with psi distribution.

Definition at line 380 of file NcPsiDistrib.cxx.

◆ GetPsiSample()

NcSample * NcPsiDistrib::GetPsiSample ( )
// Get the sample containing information on the psi distribution.

Definition at line 391 of file NcPsiDistrib.cxx.

◆ SetNevents()

void NcPsiDistrib::SetNevents ( Int_t n)
// Set number of background events to simulate.

Definition at line 171 of file NcPsiDistrib.cxx.

◆ SetNoutcomes()

void NcPsiDistrib::SetNoutcomes ( Int_t n,
Double_t * p = 0 )
// Set number of possible outcomes.
// The optional argument p is an array containing the respective probabilities
// of the outcomes. Its length must be equal to the number of outcomes. In
// case no probabilities are specified, a flat distribution is assumed.
// Setting the number of outcomes resets any signal that may be present.

Definition at line 182 of file NcPsiDistrib.cxx.

◆ SetNtrials()

void NcPsiDistrib::SetNtrials ( Long_t n)
// Set number of trials.

Definition at line 160 of file NcPsiDistrib.cxx.

◆ SetPrintFreq()

void NcPsiDistrib::SetPrintFreq ( Int_t freq)
// Set print frequency.

Definition at line 287 of file NcPsiDistrib.cxx.

◆ SetProbabilities()

void NcPsiDistrib::SetProbabilities ( Double_t * p)
// Set probabilities of the possible outcomes.
// The length of the array passed as an argument must be equal to the number
// of outcomes. In case p=0, a flat distribution is made.

Definition at line 211 of file NcPsiDistrib.cxx.

◆ SetPsiRange()

void NcPsiDistrib::SetPsiRange ( Int_t nb,
Float_t low,
Float_t high )
// Set number of bins and range of the psi histogram.

Definition at line 264 of file NcPsiDistrib.cxx.

◆ SetReferencePsi()

void NcPsiDistrib::SetReferencePsi ( Double_t ref)
// Set reference psi.

Definition at line 276 of file NcPsiDistrib.cxx.

◆ SetSignal()

void NcPsiDistrib::SetSignal ( Int_t * s)
// Set signal counts for each outcome.
// The length of the array passed as an argument must be equal to the number of outcomes.
// In case s=0, the signal is set to 0 for all outcomes.

Definition at line 238 of file NcPsiDistrib.cxx.

Member Data Documentation

◆ fNabove

Long_t NcPsiDistrib::fNabove
protected

Definition at line 46 of file NcPsiDistrib.h.

◆ fNbelow

Long_t NcPsiDistrib::fNbelow
protected

Definition at line 45 of file NcPsiDistrib.h.

◆ fNevents

Int_t NcPsiDistrib::fNevents
protected

Definition at line 39 of file NcPsiDistrib.h.

◆ fNoutcomes

Int_t NcPsiDistrib::fNoutcomes
protected

Definition at line 40 of file NcPsiDistrib.h.

◆ fNtrials

Long_t NcPsiDistrib::fNtrials
protected

Definition at line 38 of file NcPsiDistrib.h.

◆ fPrintFreq

Int_t NcPsiDistrib::fPrintFreq
protected

Definition at line 49 of file NcPsiDistrib.h.

◆ fProbs

Double_t* NcPsiDistrib::fProbs
protected

Definition at line 41 of file NcPsiDistrib.h.

◆ fPsiHisto

TH1D* NcPsiDistrib::fPsiHisto
protected

Definition at line 47 of file NcPsiDistrib.h.

◆ fRangeSet

Bool_t NcPsiDistrib::fRangeSet
protected

Definition at line 43 of file NcPsiDistrib.h.

◆ fRefPsi

Double_t NcPsiDistrib::fRefPsi
protected

Definition at line 44 of file NcPsiDistrib.h.

◆ fSample

NcSample* NcPsiDistrib::fSample
protected

Definition at line 48 of file NcPsiDistrib.h.

◆ fSignal

Int_t* NcPsiDistrib::fSignal
protected

Definition at line 42 of file NcPsiDistrib.h.


The documentation for this class was generated from the following files: