Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorised RooLandau #1

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba1a4fe
[RF] Change evaluatePartition interface for test statistics.
hageboeck Feb 5, 2019
0edc1cb
[RF] Initial cleanups before touching RooVectorDataStore.
hageboeck Feb 5, 2019
9aa6af2
Remove dead code in RooGaussian.
hageboeck Feb 6, 2019
7c3e29d
Fix some typos in docs.
hageboeck Feb 7, 2019
0fecdee
WIP before sed-ing RooFit::DataBatch to RooSpan.
hageboeck Feb 8, 2019
4897f28
Make pointees of span backport writable.
hageboeck Feb 15, 2019
3cd7efd
[RF] Add a RooSpan to enable batched function evaluations.
hageboeck Feb 15, 2019
4d6803a
Add vdt math function to vectorised Gaussian prototype.
hageboeck Feb 18, 2019
4852d12
Further cleanups.
hageboeck Feb 22, 2019
6f5946a
Change batch evaluation interface.
hageboeck Mar 7, 2019
f0e2732
Vectorise exponential, extend its analytical integral.
hageboeck Apr 4, 2019
07c0a77
Make Gaussian integral not return zero, but 1E-300 if it vanishes.
hageboeck Apr 4, 2019
9667252
Clean up RooAddition, RooConstraintSum of member iterators.
hageboeck Apr 4, 2019
2cedee6
Disable cout in ProdPdf, make RooUnitTest failures more informative.
hageboeck Apr 4, 2019
28ba4dd
Add `BatchMode` switch for fitTo to switch on BatchMode.
hageboeck Apr 4, 2019
8b44331
Hacky batch&vector version for RooAddPdf.
hageboeck Apr 8, 2019
39abfc0
Add Pdf-local batch storage.
hageboeck Apr 23, 2019
2183424
[Mathmore] Vectorise Kahan summation algorithm.
hageboeck May 2, 2019
4c4c36f
Fix computation errors in batch-local storage strategy.
hageboeck May 20, 2019
a6583a7
[RF] Add generic evaluateBatch to RooAbsReal.
hageboeck Jul 3, 2019
a1b489f
[RF] Change batch evaluation interface to begin+size indexing.
hageboeck Jul 8, 2019
581a13d
[RF] Vectorise error checking in RooAbsPdf.
hageboeck Jul 11, 2019
3a3c906
[RF] Prevent empty names for RooAbsArgs.
hageboeck Jul 11, 2019
2be0476
[RF] Vectorised Landau PDF
Jul 26, 2019
f2abe2d
[RF]
Jul 26, 2019
a2b8483
[RF] Merged header file into pdf source file
Jul 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up RooAddition, RooConstraintSum of member iterators.
Small cleanups and comments in RooSpan, RooAbsTestStatistic, RooAbsReal.
  • Loading branch information
hageboeck committed Jul 9, 2019
commit 96672523533c267aca6f12de3dec2d9f67ff84ee
1 change: 0 additions & 1 deletion roofit/roofitcore/inc/RooAddition.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class RooAddition : public RooAbsReal {

RooArgList _ownedList ; // List of owned components
RooListProxy _set ; // set of terms to be summed
mutable TIterator* _setIter ; //! Iterator over set

class CacheElem : public RooAbsCacheElement {
public:
Expand Down
1 change: 0 additions & 1 deletion roofit/roofitcore/inc/RooConstraintSum.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class RooConstraintSum : public RooAbsReal {

RooListProxy _set1 ; // Set of constraint terms
RooSetProxy _paramSet ; // Set of parameters to which constraints apply
TIterator* _setIter1 ; //! do not persist

Double_t evaluate() const;

Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/inc/RooSpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class RooSpan {

private:

/// If a class has does not own a contiguous block of memory, which
/// If a class does not own a contiguous block of memory, which
/// could be used to create a span, the memory has to be kept alive
/// until all referring spans are destroyed.
std::shared_ptr<std::vector<value_type>> _auxStorage;
Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/src/RooAbsReal.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4789,7 +4789,7 @@ void RooAbsReal::evaluateBatch(RooSpan<double> output,
std::vector<std::pair<std::size_t, RooAbsRealLValue*>> serverVars;
//First find out which values from the inputVars we need to set,
//because we depend on them.
for (int i = 0; i < inputVars.size(); ++i) {
for (unsigned int i = 0; i < inputVars.size(); ++i) {
const RooAbsArg* var = inputVars[i];
// std::cout << "\n\nVar #" << i << " coming in:\n";
// var->Print("v");
Expand Down
8 changes: 4 additions & 4 deletions roofit/roofitcore/src/RooAbsTestStatistic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ RooAbsTestStatistic::~RooAbsTestStatistic()


////////////////////////////////////////////////////////////////////////////////
/// Calculates and return value of test statistic. If the test statistic
/// is calculated from on a RooSimultaneous, the test statistic calculation
/// Calculate and return value of test statistic. If the test statistic
/// is calculated from a RooSimultaneous, the test statistic calculation
/// is performed separately on each simultaneous p.d.f component and associated
/// data and then combined. If the test statistic calculation is parallelized
/// partitions are calculated in nCPU processes and a posteriori combined.
/// data, and then combined. If the test statistic calculation is parallelized,
/// partitions are calculated in nCPU processes and combined a posteriori.

Double_t RooAbsTestStatistic::evaluate() const
{
Expand Down
49 changes: 17 additions & 32 deletions roofit/roofitcore/src/RooAddition.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
RooAddition calculates the sum of a set of RooAbsReal terms, or
when constructed with two sets, it sums the product of the terms
in the two sets. This class does not (yet) do any smart handling of integrals,
i.e. all integrals of the product are handled numerically
i.e. all integrals of the product are handled numerically.
**/


Expand Down Expand Up @@ -51,7 +51,6 @@ ClassImp(RooAddition);
////////////////////////////////////////////////////////////////////////////////
/// Empty constructor
RooAddition::RooAddition()
: _setIter( _set.createIterator() )
{
}

Expand All @@ -67,12 +66,9 @@ RooAddition::RooAddition()
RooAddition::RooAddition(const char* name, const char* title, const RooArgList& sumSet, Bool_t takeOwnership)
: RooAbsReal(name, title)
, _set("!set","set of components",this)
, _setIter( _set.createIterator() ) // yes, _setIter is defined _after_ _set ;-)
, _cacheMgr(this,10)
{
std::unique_ptr<TIterator> inputIter( sumSet.createIterator() );
RooAbsArg* comp ;
while((comp = (RooAbsArg*)inputIter->Next())) {
for (const auto comp : sumSet) {
if (!dynamic_cast<RooAbsReal*>(comp)) {
coutE(InputArguments) << "RooAddition::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
<< " is not of type RooAbsReal" << endl ;
Expand Down Expand Up @@ -105,7 +101,6 @@ RooAddition::RooAddition(const char* name, const char* title, const RooArgList&
RooAddition::RooAddition(const char* name, const char* title, const RooArgList& sumSet1, const RooArgList& sumSet2, Bool_t takeOwnership)
: RooAbsReal(name, title)
, _set("!set","set of components",this)
, _setIter( _set.createIterator() ) // yes, _setIter is defined _after_ _set ;-)
, _cacheMgr(this,10)
{
if (sumSet1.getSize() != sumSet2.getSize()) {
Expand Down Expand Up @@ -153,7 +148,6 @@ RooAddition::RooAddition(const char* name, const char* title, const RooArgList&
RooAddition::RooAddition(const RooAddition& other, const char* name)
: RooAbsReal(other, name)
, _set("!set",this,other._set)
, _setIter( _set.createIterator() ) // yes, _setIter is defined _after_ _set ;-)
, _cacheMgr(other._cacheMgr,this)
{
// Member _ownedList is intentionally not copy-constructed -- ownership is not transferred
Expand All @@ -164,7 +158,7 @@ RooAddition::RooAddition(const RooAddition& other, const char* name)

RooAddition::~RooAddition()
{ // Destructor
delete _setIter ;

}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -241,11 +235,8 @@ Double_t RooAddition::defaultErrorLevel() const

void RooAddition::enableOffsetting(Bool_t flag)
{
_setIter->Reset() ;

RooAbsReal* arg;
while((arg=(RooAbsReal*)_setIter->Next())) {
arg->enableOffsetting(flag) ;
for (auto arg : _set) {
static_cast<RooAbsReal*>(arg)->enableOffsetting(flag) ;
}
}

Expand All @@ -255,11 +246,8 @@ void RooAddition::enableOffsetting(Bool_t flag)

Bool_t RooAddition::setData(RooAbsData& data, Bool_t cloneData)
{
_setIter->Reset() ;

RooAbsReal* arg;
while((arg=(RooAbsReal*)_setIter->Next())) {
arg->setData(data,cloneData) ;
for (const auto arg : _set) {
static_cast<RooAbsReal*>(arg)->setData(data,cloneData) ;
}
return kTRUE ;
}
Expand All @@ -270,13 +258,12 @@ Bool_t RooAddition::setData(RooAbsData& data, Bool_t cloneData)

void RooAddition::printMetaArgs(ostream& os) const
{
_setIter->Reset() ;

Bool_t first(kTRUE) ;
RooAbsArg* arg;
while((arg=(RooAbsArg*)_setIter->Next())) {
if (!first) { os << " + " ;
} else { first = kFALSE ;
for (const auto arg : _set) {
if (!first) {
os << " + " ;
} else {
first = kFALSE ;
}
os << arg->GetName() ;
}
Expand All @@ -300,10 +287,8 @@ Int_t RooAddition::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars

// we don't, so we make it right here....
cache = new CacheElem;
_setIter->Reset();
RooAbsReal *arg(0);
while( (arg=(RooAbsReal*)_setIter->Next())!=0 ) { // checked in c'tor that this will work...
RooAbsReal *I = arg->createIntegral(analVars,rangeName);
for (const auto arg : _set) {// checked in c'tor that this will work...
RooAbsReal *I = static_cast<const RooAbsReal*>(arg)->createIntegral(analVars,rangeName);
cache->_I.addOwned(*I);
}

Expand All @@ -330,10 +315,10 @@ Double_t RooAddition::analyticalIntegral(Int_t code, const char* rangeName) cons
assert(cache!=0);

// loop over cache, and sum...
std::unique_ptr<TIterator> iter( cache->_I.createIterator() );
RooAbsReal *I;
double result(0);
while ( ( I=(RooAbsReal*)iter->Next() ) != 0 ) result += I->getVal();
for (auto I : cache->_I) {
result += static_cast<const RooAbsReal*>(I)->getVal();
}
return result;

}
Expand Down
27 changes: 9 additions & 18 deletions roofit/roofitcore/src/RooConstraintSum.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
RooConstraintSum calculates the sum of the -(log) likelihoods of
a set of RooAbsPfs that represent constraint functions. This class
is used to calculate the composite -log(L) of constraints to be
added the regular -log(L) in RooAbsPdf::fitTo() with Constrain(..)
arguments
added to the regular -log(L) in RooAbsPdf::fitTo() with Constrain(..)
arguments.
**/


Expand Down Expand Up @@ -53,7 +53,7 @@ ClassImp(RooConstraintSum);

RooConstraintSum::RooConstraintSum()
{
_setIter1 = _set1.createIterator() ;

}


Expand All @@ -67,12 +67,7 @@ RooConstraintSum::RooConstraintSum(const char* name, const char* title, const Ro
_set1("set1","First set of components",this),
_paramSet("paramSet","Set of parameters",this)
{

_setIter1 = _set1.createIterator() ;

TIterator* inputIter = constraintSet.createIterator() ;
RooAbsArg* comp ;
while((comp = (RooAbsArg*)inputIter->Next())) {
for (const auto comp : constraintSet) {
if (!dynamic_cast<RooAbsPdf*>(comp)) {
coutE(InputArguments) << "RooConstraintSum::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
<< " is not of type RooAbsPdf" << endl ;
Expand All @@ -82,8 +77,6 @@ RooConstraintSum::RooConstraintSum(const char* name, const char* title, const Ro
}

_paramSet.add(normSet) ;

delete inputIter ;
}


Expand All @@ -98,7 +91,7 @@ RooConstraintSum::RooConstraintSum(const RooConstraintSum& other, const char* na
_set1("set1",this,other._set1),
_paramSet("paramSet",this,other._paramSet)
{
_setIter1 = _set1.createIterator() ;

}


Expand All @@ -108,7 +101,7 @@ RooConstraintSum::RooConstraintSum(const RooConstraintSum& other, const char* na

RooConstraintSum::~RooConstraintSum()
{
if (_setIter1) delete _setIter1 ;

}


Expand All @@ -119,13 +112,11 @@ RooConstraintSum::~RooConstraintSum()
Double_t RooConstraintSum::evaluate() const
{
Double_t sum(0);
RooAbsReal* comp ;
RooFIter setIter1 = _set1.fwdIterator() ;

while((comp=(RooAbsReal*)setIter1.next())) {
sum -= ((RooAbsPdf*)comp)->getLogVal(&_paramSet) ;
for (const auto comp : _set1) {
sum -= static_cast<RooAbsPdf*>(comp)->getLogVal(&_paramSet);
}

return sum ;
return sum;
}