GooFit  v2.1.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GooFit::PdfBase Class Referenceabstract

#include <PdfBase.h>

Inheritance diagram for GooFit::PdfBase:
GooFit::GooPdf GooFit::AddPdf GooFit::ArgusPdf GooFit::BifurGaussPdf GooFit::BinTransformPdf GooFit::BWPdf GooFit::CompositePdf GooFit::ConvolutionPdf GooFit::CorrGaussianPdf GooFit::CrystalBallPdf GooFit::DalitzPlotPdf GooFit::DalitzVetoPdf GooFit::DPPdf GooFit::EventWeightedAddPdf GooFit::ExpGausPdf GooFit::ExpPdf GooFit::GaussianPdf GooFit::IncoherentSumPdf GooFit::InterHistPdf GooFit::JohnsonSUPdf GooFit::KinLimitBWPdf GooFit::LandauPdf GooFit::Lineshape GooFit::MappedPdf GooFit::NovosibirskPdf GooFit::PolynomialPdf GooFit::ProdPdf GooFit::ResonancePdf GooFit::ScaledGaussianPdf GooFit::SmoothHistogramPdf GooFit::SpinFactor GooFit::StepPdf GooFit::TDDP4 GooFit::TddpPdf GooFit::TrigThresholdPdf GooFit::VariableBinTransform1DPdf GooFit::VoigtianPdf

Public Types

enum  Specials { ForceSeparateNorm = 1, ForceCommonNorm = 2 }
 

Public Member Functions

template<typename... Args>
 PdfBase (std::string n, Args... args)
 
virtual ~PdfBase ()=default
 
virtual __host__ double calculateNLL () const =0
 
virtual __host__ fptype normalize () const =0
 
__host__ void initializeIndices (std::vector< unsigned int > pindices)
 
__host__ void addSpecialMask (int m)
 
__host__ void copyParams (const std::vector< double > &pars) const
 
__host__ void copyParams ()
 
__host__ void copyNormFactors () const
 
__host__ void generateNormRange ()
 
__host__ std::string getName () const
 
virtual __host__ std::vector< ObservablegetObservables () const
 
virtual __host__ std::vector< VariablegetParameters () const
 
__host__ VariablegetParameterByName (std::string n)
 
__host__ int getSpecialMask () const
 
__host__ void setData (DataSet *data)
 
__host__ DataSetgetData ()
 
virtual __host__ void setFitControl (std::shared_ptr< FitControl >)=0
 
virtual __host__ bool hasAnalyticIntegral () const
 
__host__ ROOT::Minuit2::FunctionMinimum fitTo (DataSet *data, int verbosity=3)
 RooFit style fitting shortcut. More...
 
__host__ unsigned int getFunctionIndex () const
 
__host__ unsigned int getParameterIndex () const
 
__host__ unsigned int registerParameter (Variable var)
 
__host__ unsigned int registerConstants (unsigned int amount)
 
virtual __host__ void recursiveSetNormalisation (fptype norm=1) const
 
__host__ void unregisterParameter (Variable var)
 
__host__ void registerObservable (Observable obs)
 
__host__ void setIntegrationFineness (int i)
 
__host__ void printProfileInfo (bool topLevel=true)
 
__host__ bool parametersChanged () const
 
__host__ void checkInitStatus (std::vector< std::string > &unInited) const
 
void clearCurrentFit ()
 
__host__ void SigGenSetIndices ()
 

Protected Member Functions

void setNumPerTask (PdfBase *p, const int &c)
 This needs to be set before a call to setData. More...
 

Protected Attributes

DataSetdata_ = nullptr
 
fptype numEvents {0}
 
unsigned int numEntries {0}
 
fptypenormRanges
 
unsigned int parameters {0}
 
unsigned int cIndex {1}
 
std::vector< Observableobservables
 
std::vector< VariableparameterList
 
std::shared_ptr< FitControlfitControl
 
std::vector< PdfBase * > components
 
int integrationBins {-1}
 
int specialMask {0}
 
bool properlyInitialised {true}
 
unsigned int functionIdx {0}
 
int m_iEventsPerTask {0}
 

Detailed Description

Definition at line 69 of file PdfBase.h.

Member Enumeration Documentation

◆ Specials

Enumerator
ForceSeparateNorm 
ForceCommonNorm 

Definition at line 82 of file PdfBase.h.

Constructor & Destructor Documentation

◆ PdfBase()

template<typename... Args>
GooFit::PdfBase::PdfBase ( std::string  n,
Args...  args 
)
inlineexplicit

Definition at line 72 of file PdfBase.h.

73  : name(std::move(n)) {
74  std::vector<Observable> obs;
75  filter_arguments(obs, args...);
76  for(auto &ob : obs)
78  }
__host__ void registerObservable(Observable obs)
Definition: PdfBase.cpp:134

◆ ~PdfBase()

virtual GooFit::PdfBase::~PdfBase ( )
virtualdefault

Member Function Documentation

◆ addSpecialMask()

__host__ void GooFit::PdfBase::addSpecialMask ( int  m)
inline

◆ calculateNLL()

virtual __host__ double GooFit::PdfBase::calculateNLL ( ) const
pure virtual

◆ checkInitStatus()

__host__ void GooFit::PdfBase::checkInitStatus ( std::vector< std::string > &  unInited) const

Definition at line 37 of file PdfBase.cpp.

References components, getName(), and properlyInitialised.

37  {
39  unInited.push_back(getName());
40 
41  for(auto component : components) {
42  component->checkInitStatus(unInited);
43  }
44 }
std::vector< PdfBase * > components
Definition: PdfBase.h:137
bool properlyInitialised
Definition: PdfBase.h:140
__host__ std::string getName() const
Definition: PdfBase.h:93

◆ clearCurrentFit()

void GooFit::PdfBase::clearCurrentFit ( )

◆ copyNormFactors()

__host__ void GooFit::PdfBase::copyNormFactors ( ) const

◆ copyParams() [1/2]

__host__ void GooFit::PdfBase::copyParams ( const std::vector< double > &  pars) const

◆ copyParams() [2/2]

__host__ void GooFit::PdfBase::copyParams ( )

◆ fitTo()

__host__ ROOT::Minuit2::FunctionMinimum GooFit::PdfBase::fitTo ( DataSet data,
int  verbosity = 3 
)

RooFit style fitting shortcut.

Definition at line 159 of file PdfBase.cpp.

References setData(), and GooFit::FitManagerMinuit2::setVerbosity().

159  {
160  setData(data);
161  FitManager fitter{this};
162  fitter.setVerbosity(verbosity);
163  return fitter.fit();
164 }
UnbinnedDataSet * data
void setVerbosity(int value)
Set the fitting verbosity.
__host__ void setData(DataSet *data)
GooFit::FitManagerMinuit2 FitManager
Definition: FitManager.h:9

◆ generateNormRange()

__host__ void GooFit::PdfBase::generateNormRange ( )

Referenced by setIntegrationFineness().

◆ getData()

__host__ DataSet* GooFit::PdfBase::getData ( )

Referenced by GooFit::fillDataSetMC1D().

◆ getFunctionIndex()

__host__ unsigned int GooFit::PdfBase::getFunctionIndex ( ) const
inline

Definition at line 110 of file PdfBase.h.

110 { return functionIdx; }
unsigned int functionIdx
Definition: PdfBase.h:142

◆ getName()

__host__ std::string GooFit::PdfBase::getName ( ) const
inline

◆ getObservables()

__host__ std::vector< Observable > GooFit::PdfBase::getObservables ( ) const
virtual

Definition at line 111 of file PdfBase.cpp.

References components, and observables.

Referenced by makeDalitzPlots().

111  {
112  std::vector<Observable> ret;
113  for(const Observable &obs : observables)
114  ret.push_back(obs);
115 
116  for(const PdfBase *comp : components) {
117  for(const Observable &sub_comp : comp->getObservables())
118  if(!find_in(ret, sub_comp))
119  ret.push_back(sub_comp);
120  }
121 
122  return ret;
123 }
std::vector< Observable > observables
Definition: PdfBase.h:134
std::vector< PdfBase * > components
Definition: PdfBase.h:137
PdfBase(std::string n, Args... args)
Definition: PdfBase.h:72

◆ getParameterByName()

__host__ Variable * GooFit::PdfBase::getParameterByName ( std::string  n)

Definition at line 95 of file PdfBase.cpp.

References components, and parameterList.

Referenced by runCanonicalFit().

95  {
96  for(Variable &p : parameterList) {
97  if(p.getName() == n)
98  return &p;
99  }
100 
101  for(auto component : components) {
102  Variable *cand = component->getParameterByName(n);
103 
104  if(cand != nullptr)
105  return cand;
106  }
107 
108  return nullptr;
109 }
std::vector< PdfBase * > components
Definition: PdfBase.h:137
std::vector< Variable > parameterList
Definition: PdfBase.h:135

◆ getParameterIndex()

__host__ unsigned int GooFit::PdfBase::getParameterIndex ( ) const
inline

Definition at line 111 of file PdfBase.h.

111 { return parameters; }
unsigned int parameters
Definition: PdfBase.h:132

◆ getParameters()

__host__ std::vector< Variable > GooFit::PdfBase::getParameters ( ) const
virtual

Definition at line 81 of file PdfBase.cpp.

References components, and parameterList.

Referenced by GooFit::abort(), GooFit::Params::Params(), GooFit::readFromFile(), and GooFit::writeToFile().

81  {
82  std::vector<Variable> ret;
83  for(const Variable &param : parameterList)
84  ret.push_back(param);
85 
86  for(const PdfBase *comp : components) {
87  for(const Variable &sub_comp : comp->getParameters())
88  if(!find_in(ret, sub_comp))
89  ret.push_back(sub_comp);
90  }
91 
92  return ret;
93 }
std::vector< PdfBase * > components
Definition: PdfBase.h:137
std::vector< Variable > parameterList
Definition: PdfBase.h:135
PdfBase(std::string n, Args... args)
Definition: PdfBase.h:72

◆ getSpecialMask()

__host__ int GooFit::PdfBase::getSpecialMask ( ) const
inline

Definition at line 99 of file PdfBase.h.

References data, and getData().

99 { return specialMask; }

◆ hasAnalyticIntegral()

virtual __host__ bool GooFit::PdfBase::hasAnalyticIntegral ( ) const
inlinevirtual

◆ initializeIndices()

__host__ void GooFit::PdfBase::initializeIndices ( std::vector< unsigned int >  pindices)

◆ normalize()

virtual __host__ fptype GooFit::PdfBase::normalize ( ) const
pure virtual

◆ parametersChanged()

__host__ bool GooFit::PdfBase::parametersChanged ( ) const

Definition at line 147 of file PdfBase.cpp.

References GooFit::Variable::getChanged(), and parameterList.

147  {
148  return std::any_of(
149  std::begin(parameterList), std::end(parameterList), [](const Variable &v) { return v.getChanged(); });
150 }
std::vector< Variable > parameterList
Definition: PdfBase.h:135

◆ printProfileInfo()

__host__ void GooFit::PdfBase::printProfileInfo ( bool  topLevel = true)

Referenced by runCanonicalFit().

◆ recursiveSetNormalisation()

__host__ void GooFit::PdfBase::recursiveSetNormalisation ( fptype  norm = 1) const
virtual

Definition at line 46 of file PdfBase.cpp.

References components, and parameters.

46  {
48 
49  for(auto component : components) {
50  component->recursiveSetNormalisation(norm);
51  }
52 }
std::vector< PdfBase * > components
Definition: PdfBase.h:137
unsigned int parameters
Definition: PdfBase.h:132
fptype host_normalisation[maxParams]
Definition: PdfBase.cpp:29

◆ registerConstants()

__host__ unsigned int GooFit::PdfBase::registerConstants ( unsigned int  amount)

Definition at line 125 of file PdfBase.cpp.

References cIndex, GooFit::maxParams, and GooFit::totalConstants.

125  {
126  if(totalConstants + amount >= maxParams)
127  throw GooFit::GeneralError(
128  "totalConstants {} + amount {} can not be more than {}", totalConstants, amount, maxParams);
130  totalConstants += amount;
131  return cIndex;
132 }
Thrown when a general error is encountered.
Definition: Error.h:10
int totalConstants
Definition: PdfBase.cpp:35
unsigned int cIndex
Definition: PdfBase.h:133
const int maxParams
Definition: PdfBase.h:38

◆ registerObservable()

void GooFit::PdfBase::registerObservable ( Observable  obs)

Definition at line 134 of file PdfBase.cpp.

References GooFit::Indexable::getName(), getName(), GOOFIT_DEBUG, and observables.

134  {
135  if(find_in(observables, obs))
136  return;
137 
138  GOOFIT_DEBUG("{}: Registering o:{} for {}", getName(), observables.size(), obs.getName());
139  observables.push_back(obs);
140 }
std::vector< Observable > observables
Definition: PdfBase.h:134
#define GOOFIT_DEBUG(...)
Definition: Log.h:96
__host__ std::string getName() const
Definition: PdfBase.h:93

◆ registerParameter()

__host__ unsigned int GooFit::PdfBase::registerParameter ( Variable  var)

Definition at line 54 of file PdfBase.cpp.

References GooFit::Indexable::getIndex(), GooFit::Indexable::getName(), getName(), GOOFIT_DEBUG, parameterList, and GooFit::Indexable::setIndex().

54  {
55  static int unique_param = 0;
56 
57  if(find_in(parameterList, var))
58  return static_cast<unsigned int>(var.getIndex());
59 
60  if(var.getIndex() < 0) {
61  GOOFIT_DEBUG("{}: Registering p:{} for {}", getName(), unique_param, var.getName());
62  var.setIndex(unique_param++);
63  }
64 
65  parameterList.push_back(var);
66  return static_cast<unsigned int>(var.getIndex());
67 }
std::vector< Variable > parameterList
Definition: PdfBase.h:135
#define GOOFIT_DEBUG(...)
Definition: Log.h:96
__host__ std::string getName() const
Definition: PdfBase.h:93

◆ setData()

__host__ void GooFit::PdfBase::setData ( DataSet data)

◆ setFitControl()

virtual __host__ void GooFit::PdfBase::setFitControl ( std::shared_ptr< FitControl )
pure virtual

Implemented in GooFit::GooPdf.

◆ setIntegrationFineness()

__host__ void GooFit::PdfBase::setIntegrationFineness ( int  i)

Definition at line 142 of file PdfBase.cpp.

References generateNormRange(), and integrationBins.

142  {
143  integrationBins = i;
145 }
int integrationBins
Definition: PdfBase.h:138
__host__ void generateNormRange()

◆ setNumPerTask()

__host__ void GooFit::PdfBase::setNumPerTask ( PdfBase p,
const int &  c 
)
protected

This needs to be set before a call to setData.

Definition at line 152 of file PdfBase.cpp.

References m_iEventsPerTask.

152  {
153  if(p == nullptr)
154  return;
155 
156  m_iEventsPerTask = c;
157 }
int m_iEventsPerTask
Definition: PdfBase.h:144

◆ SigGenSetIndices()

__host__ void GooFit::PdfBase::SigGenSetIndices ( )
inline

Definition at line 124 of file PdfBase.h.

124 { setIndices(); }

◆ unregisterParameter()

__host__ void GooFit::PdfBase::unregisterParameter ( Variable  var)

Definition at line 69 of file PdfBase.cpp.

References components, GooFit::Indexable::getName(), getName(), GOOFIT_DEBUG, and GooFit::Indexable::setIndex().

69  {
70  GOOFIT_DEBUG("{}: Removing {}", getName(), var.getName());
71 
72  for(PdfBase *comp : components) {
73  comp->unregisterParameter(var);
74  }
75 
76  var.setIndex(-1);
77  // Once copies are used, this might able to be unregistred from a lower PDF only
78  // For now, it gets completely cleared.
79 }
std::vector< PdfBase * > components
Definition: PdfBase.h:137
#define GOOFIT_DEBUG(...)
Definition: Log.h:96
PdfBase(std::string n, Args... args)
Definition: PdfBase.h:72
__host__ std::string getName() const
Definition: PdfBase.h:93

Member Data Documentation

◆ cIndex

unsigned int GooFit::PdfBase::cIndex {1}
protected

Definition at line 133 of file PdfBase.h.

Referenced by registerConstants().

◆ components

std::vector<PdfBase *> GooFit::PdfBase::components
protected

◆ data_

DataSet* GooFit::PdfBase::data_ = nullptr
protected

Definition at line 127 of file PdfBase.h.

◆ fitControl

std::shared_ptr<FitControl> GooFit::PdfBase::fitControl
protected

Definition at line 136 of file PdfBase.h.

◆ functionIdx

unsigned int GooFit::PdfBase::functionIdx {0}
protected

Definition at line 142 of file PdfBase.h.

◆ integrationBins

int GooFit::PdfBase::integrationBins {-1}
protected

Definition at line 138 of file PdfBase.h.

Referenced by setIntegrationFineness().

◆ m_iEventsPerTask

int GooFit::PdfBase::m_iEventsPerTask {0}
protected

Definition at line 144 of file PdfBase.h.

Referenced by setNumPerTask().

◆ normRanges

fptype* GooFit::PdfBase::normRanges
protected
Initial value:
{
nullptr}

Definition at line 130 of file PdfBase.h.

◆ numEntries

unsigned int GooFit::PdfBase::numEntries {0}
protected

Definition at line 129 of file PdfBase.h.

◆ numEvents

fptype GooFit::PdfBase::numEvents {0}
protected

Definition at line 128 of file PdfBase.h.

Referenced by GooFit::DPPdf::setGenerationOffset(), and GooFit::TDDP4::setMaxWeight().

◆ observables

std::vector<Observable> GooFit::PdfBase::observables
protected

Definition at line 134 of file PdfBase.h.

Referenced by getObservables(), and registerObservable().

◆ parameterList

std::vector<Variable> GooFit::PdfBase::parameterList
protected

Definition at line 135 of file PdfBase.h.

Referenced by getParameterByName(), getParameters(), parametersChanged(), and registerParameter().

◆ parameters

unsigned int GooFit::PdfBase::parameters {0}
protected

◆ properlyInitialised

bool GooFit::PdfBase::properlyInitialised {true}
protected

Definition at line 140 of file PdfBase.h.

Referenced by checkInitStatus().

◆ specialMask

int GooFit::PdfBase::specialMask {0}
protected

Definition at line 139 of file PdfBase.h.


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