-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RF] Support RooBernstein in code generation for AD
Adding code generation and AD support for the final class in upstream RooFit that is used in the CMS Higgs discovery workspace: the RooBernstein. Also: * fix missing variable warning in `RooCBShape.cxx` * fix AD support for RooLandau by using code that clad can digest * implement test for RooLandau fits with AD
- Loading branch information
1 parent
44cff59
commit 50a1bdd
Showing
7 changed files
with
245 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,56 @@ | ||
/***************************************************************************** | ||
* Project: RooFit * | ||
* Package: RooFitModels * | ||
* File: $Id$ | ||
* Authors: * | ||
* Kyle Cranmer | ||
* * | ||
* * | ||
* Redistribution and use in source and binary forms, * | ||
* with or without modification, are permitted according to the terms * | ||
* listed in LICENSE (http://roofit.sourceforge.net/license.txt) * | ||
*****************************************************************************/ | ||
#ifndef ROO_BERNSTEIN | ||
#define ROO_BERNSTEIN | ||
|
||
#include "RooAbsPdf.h" | ||
#include "RooTemplateProxy.h" | ||
#include "RooRealVar.h" | ||
#include "RooListProxy.h" | ||
#include "RooAbsRealLValue.h" | ||
#include <string> | ||
/* | ||
* Project: RooFit | ||
* | ||
* Copyright (c) 2024, CERN | ||
* | ||
* Redistribution and use in source and binary forms, | ||
* with or without modification, are permitted according to the terms | ||
* listed in LICENSE (http://roofit.sourceforge.net/license.txt) | ||
*/ | ||
|
||
#ifndef RooFit_RooBernstein_h | ||
#define RooFit_RooBernstein_h | ||
|
||
#include <RooAbsPdf.h> | ||
#include <RooAbsRealLValue.h> | ||
#include <RooListProxy.h> | ||
#include <RooRealVar.h> | ||
#include <RooTemplateProxy.h> | ||
|
||
class RooRealVar; | ||
class RooArgList; | ||
#include <string> | ||
|
||
class RooBernstein : public RooAbsPdf { | ||
public: | ||
RooBernstein() = default; | ||
RooBernstein(const char *name, const char *title, RooAbsRealLValue &_x, const RooArgList &_coefList); | ||
|
||
RooBernstein() {} | ||
RooBernstein(const char *name, const char *title, | ||
RooAbsRealLValue& _x, const RooArgList& _coefList) ; | ||
RooBernstein(const RooBernstein &other, const char *name = nullptr); | ||
|
||
RooBernstein(const RooBernstein &other, const char *name = nullptr); | ||
TObject *clone(const char *newname) const override { return new RooBernstein(*this, newname); } | ||
|
||
TObject* clone(const char* newname) const override { return new RooBernstein(*this, newname); } | ||
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName = nullptr) const override; | ||
double analyticalIntegral(Int_t code, const char *rangeName = nullptr) const override; | ||
void selectNormalizationRange(const char *rangeName = nullptr, bool force = false) override; | ||
|
||
Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=nullptr) const override ; | ||
double analyticalIntegral(Int_t code, const char* rangeName=nullptr) const override ; | ||
void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ; | ||
void translate(RooFit::Detail::CodeSquashContext &ctx) const override; | ||
std::string buildCallToAnalyticIntegral(Int_t code, const char *rangeName, | ||
RooFit::Detail::CodeSquashContext &ctx) const override; | ||
|
||
private: | ||
void fillBuffer() const; | ||
inline double xmin() const { return _buffer[_coefList.size()]; } | ||
inline double xmax() const { return _buffer[_coefList.size() + 1]; } | ||
|
||
RooTemplateProxy<RooAbsRealLValue> _x ; | ||
RooListProxy _coefList ; | ||
std::string _refRangeName ; | ||
RooTemplateProxy<RooAbsRealLValue> _x; | ||
RooListProxy _coefList; | ||
std::string _refRangeName; | ||
mutable std::vector<double> _buffer; ///<! | ||
|
||
double evaluate() const override; | ||
void doEval(RooFit::EvalContext &) const override; | ||
inline bool canComputeBatchWithCuda() const override { return true; } | ||
double evaluate() const override; | ||
void doEval(RooFit::EvalContext &) const override; | ||
inline bool canComputeBatchWithCuda() const override { return true; } | ||
|
||
ClassDefOverride(RooBernstein,2) // Bernstein polynomial PDF | ||
ClassDefOverride(RooBernstein, 2) // Bernstein polynomial PDF | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.