GooFit  v2.1.3
Public Member Functions | List of all members
GooFit::DalitzPlotter Class Reference

This class makes it easy to make plots over 3 body Dalitz PDFs. You can use ROOT style value access or bin numbers. More...

#include <DalitzPlotter.h>

Public Member Functions

 DalitzPlotter (GooPdf *overallSignal, DalitzPlotPdf *signalDalitz)
 
void fillDataSetMC (UnbinnedDataSet &dataset, size_t nTotal)
 Fill a dataset with MC events. More...
 
size_t getNumEvents () const
 
size_t getX (size_t event) const
 
size_t getY (size_t event) const
 
fptype getXval (size_t event) const
 
fptype getYval (size_t event) const
 
fptype getZval (size_t event) const
 
fptype getVal (size_t event, size_t num=0) const
 
UnbinnedDataSetgetDataSet ()
 
const ObservablegetM12 () const
 
const ObservablegetM13 () const
 

Detailed Description

This class makes it easy to make plots over 3 body Dalitz PDFs. You can use ROOT style value access or bin numbers.

Definition at line 19 of file DalitzPlotter.h.

Constructor & Destructor Documentation

◆ DalitzPlotter()

GooFit::DalitzPlotter::DalitzPlotter ( GooPdf overallSignal,
DalitzPlotPdf signalDalitz 
)
inline

Definition at line 30 of file DalitzPlotter.h.

References GooFit::UnbinnedDataSet::addEvent(), GooFit::Observable::getBinSize(), GooFit::Indexable::getLowerLimit(), GooFit::Observable::getNumBins(), GooFit::DataSet::getNumEvents(), GooFit::Indexable::getValue(), GooFit::inDalitz(), GooFit::Indexable::setValue(), and signalDalitz.

31  : m12(signalDalitz->_m12)
32  , m13(signalDalitz->_m13)
33  , eventNumber(signalDalitz->_eventNumber)
34  , data({m12, m13, eventNumber})
35  , mother(signalDalitz->decayInfo.motherMass) {
36  eventNumber.setValue(0);
37 
38  for(size_t i = 0; i < m12.getNumBins(); ++i) {
39  m12.setValue(m12.getLowerLimit() + m12.getBinSize() * (i + 0.5));
40  for(size_t j = 0; j < m13.getNumBins(); ++j) {
41  m13.setValue(m13.getLowerLimit() + m13.getBinSize() * (j + 0.5));
42  if(inDalitz(m12.getValue(),
43  m13.getValue(),
44  signalDalitz->decayInfo.motherMass,
45  signalDalitz->decayInfo.daug1Mass,
46  signalDalitz->decayInfo.daug2Mass,
47  signalDalitz->decayInfo.daug3Mass)) {
48  xbins.push_back(i);
49  ybins.push_back(j);
50  data.addEvent();
51  eventNumber.setValue(eventNumber.getValue() + 1);
52  }
53  }
54  }
55 
56  auto old = overallSignal->getData();
57  overallSignal->setData(&data);
58  signalDalitz->setDataSize(data.getNumEvents());
59  pdfValues = overallSignal->getCompProbsAtDataPoints();
60  overallSignal->setData(old);
61  }
size_t getNumEvents() const
Definition: DataSet.h:47
fptype getBinSize() const
Get the bin size, (upper-lower) / bins.
Definition: Variable.h:133
void setValue(fptype val)
Set the value.
Definition: Variable.h:70
size_t getNumBins() const
Get the number of bins.
Definition: Variable.h:130
TddpPdf * signalDalitz
__host__ __device__ bool inDalitz(const fptype &m12, const fptype &m13, const fptype &bigM, const fptype &dm1, const fptype &dm2, const fptype &dm3)
fptype getLowerLimit() const
Get the lower limit.
Definition: Variable.h:78
fptype getValue() const
Get the value.
Definition: Variable.h:68

Member Function Documentation

◆ fillDataSetMC()

void GooFit::DalitzPlotter::fillDataSetMC ( UnbinnedDataSet dataset,
size_t  nTotal 
)
inline

Fill a dataset with MC events.

Definition at line 64 of file DalitzPlotter.h.

References GooFit::UnbinnedDataSet::addEvent(), GooFit::Observable::getBinSize(), GooFit::UnbinnedDataSet::getValue(), and GooFit::Indexable::setValue().

Referenced by main().

64  {
65  // Setup random numbers
66  std::random_device rd;
67  std::mt19937 gen(rd());
68 
69  // Uniform distribution
70  std::uniform_real_distribution<> unihalf(-.5, .5);
71  std::uniform_real_distribution<> uniwhole(0.0, 1.0);
72 
73  // CumSum in other languages
74  std::vector<double> integral(pdfValues[0].size());
75  std::partial_sum(pdfValues[0].begin(), pdfValues[0].end(), integral.begin());
76 
77  // Make this a 0-1 fraction by dividing by the end value
78  std::for_each(integral.begin(), integral.end(), [&integral](double &val) { val /= integral.back(); });
79 
80  for(size_t i = 0; i < nTotal; i++) {
81  double r = uniwhole(gen);
82 
83  // Binary search for integral[cell-1] < r < integral[cell]
84  size_t j = std::lower_bound(integral.begin(), integral.end(), r) - integral.begin();
85 
86  // Fill in the grid square randomly
87  double currm12 = data.getValue(m12, j) + m12.getBinSize() * unihalf(gen);
88  double currm13 = data.getValue(m13, j) + m13.getBinSize() * unihalf(gen);
89 
90  m12.setValue(currm12);
91  m13.setValue(currm13);
92  eventNumber.setValue(i);
93  dataset.addEvent();
94  }
95  }
fptype getBinSize() const
Get the bin size, (upper-lower) / bins.
Definition: Variable.h:133
void setValue(fptype val)
Set the value.
Definition: Variable.h:70
fptype getValue(const Observable &var, size_t idx) const
Get the value at a specific variable and event number.

◆ getDataSet()

UnbinnedDataSet* GooFit::DalitzPlotter::getDataSet ( )
inline

Definition at line 111 of file DalitzPlotter.h.

111 { return &data; }

◆ getM12()

const Observable& GooFit::DalitzPlotter::getM12 ( ) const
inline

Definition at line 113 of file DalitzPlotter.h.

113 { return m12; }

◆ getM13()

const Observable& GooFit::DalitzPlotter::getM13 ( ) const
inline

◆ getNumEvents()

size_t GooFit::DalitzPlotter::getNumEvents ( ) const
inline

Definition at line 97 of file DalitzPlotter.h.

References GooFit::DataSet::getNumEvents().

Referenced by getM13().

97 { return data.getNumEvents(); }
size_t getNumEvents() const
Definition: DataSet.h:47

◆ getVal()

fptype GooFit::DalitzPlotter::getVal ( size_t  event,
size_t  num = 0 
) const
inline

Definition at line 109 of file DalitzPlotter.h.

Referenced by getM13().

109 { return pdfValues.at(num).at(event); }

◆ getX()

size_t GooFit::DalitzPlotter::getX ( size_t  event) const
inline

Definition at line 99 of file DalitzPlotter.h.

Referenced by getM13().

99 { return xbins.at(event); }

◆ getXval()

fptype GooFit::DalitzPlotter::getXval ( size_t  event) const
inline

Definition at line 103 of file DalitzPlotter.h.

References GooFit::UnbinnedDataSet::getValue().

Referenced by getZval().

103 { return data.getValue(m12, event); }
fptype getValue(const Observable &var, size_t idx) const
Get the value at a specific variable and event number.

◆ getY()

size_t GooFit::DalitzPlotter::getY ( size_t  event) const
inline

Definition at line 101 of file DalitzPlotter.h.

Referenced by getM13().

101 { return ybins.at(event); }

◆ getYval()

fptype GooFit::DalitzPlotter::getYval ( size_t  event) const
inline

Definition at line 105 of file DalitzPlotter.h.

References GooFit::UnbinnedDataSet::getValue().

Referenced by getZval().

105 { return data.getValue(m13, event); }
fptype getValue(const Observable &var, size_t idx) const
Get the value at a specific variable and event number.

◆ getZval()

fptype GooFit::DalitzPlotter::getZval ( size_t  event) const
inline

Definition at line 107 of file DalitzPlotter.h.

References getXval(), getYval(), and POW2.

107 { return POW2(mother) - POW2(getXval(event)) - POW2(getYval(event)); }
fptype getXval(size_t event) const
#define POW2(x)
fptype getYval(size_t event) const

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