Skip to content

Commit

Permalink
add DoubleSidedGausssian pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
hjkwon260 committed Nov 14, 2023
1 parent bed1eed commit c62ced7
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
60 changes: 60 additions & 0 deletions interface/DoubleSidedGaussian.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*****************************************************************************
* Project: RooFit *
* *
* This code was autogenerated by RooClassFactory *
*****************************************************************************/

#ifndef MY_DOUBLE_Gaussian
#define MY_DOUBLE_Gaussian

#include "RooAbsPdf.h"
#include "RooRealProxy.h"
#include "RooCategoryProxy.h"
#include "RooAbsReal.h"
#include "RooAbsCategory.h"
#include "RooGlobalFunc.h"

#include "RooArgusBG.h"
#include "RooRealVar.h"
#include "RooDataSet.h"

#include "RooGaussian.h"
#include "RooCBShape.h"
#include "RooExponential.h"
#include "RooBreitWigner.h"

#include "RooConstVar.h"
#include "RooDataHist.h"
#include "RooFitResult.h"
#include "RooMinuit.h"
#include "RooPlot.h"

class DoubleSidedGaussian : public RooAbsPdf {
public:
DoubleSidedGaussian() {} ;
DoubleSidedGaussian(const char *name, const char *title,
RooAbsReal& _x,
RooAbsReal& _mean,
RooAbsReal& _sig1,
RooAbsReal& _sig2,
Double_t _yMax);
DoubleSidedGaussian(const DoubleSidedGaussian& other, const char* name=0) ;
virtual TObject* clone(const char* newname) const { return new DoubleSidedGaussian(*this,newname); }
inline virtual ~DoubleSidedGaussian() { }

protected:

RooRealProxy x ;
RooRealProxy mean ;
RooRealProxy sig1 ;
RooRealProxy sig2 ;
Double_t evaluate() const ;

private:

Double_t yMax;
ClassDef(DoubleSidedGaussian,1) // Your description goes here...
};

#endif

59 changes: 59 additions & 0 deletions src/DoubleSidedGaussian.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*****************************************************************************
* Project: RooFit *
* *
* This code was autogenerated by RooClassFactory *
*****************************************************************************/

// Your description goes here...

#include "../interface/DoubleSidedGaussian.h"
#include "RooAbsReal.h"
#include "RooAbsCategory.h"
#include <math.h>
#include "TMath.h"
#include "RooGaussian.h"

ClassImp(DoubleSidedGaussian)

DoubleSidedGaussian::DoubleSidedGaussian(const char *name, const char *title,
RooAbsReal& _x,
RooAbsReal& _mean,
RooAbsReal& _sig1,
RooAbsReal& _sig2,
Double_t _yMax) :
RooAbsPdf(name,title),
x("x","x",this,_x),
mean("mean","mean",this,_mean),
sig1("sig1","sig1",this,_sig1),
sig2("sig2","sig2",this,_sig2),
yMax(_yMax)
{
}


DoubleSidedGaussian::DoubleSidedGaussian(const DoubleSidedGaussian& other, const char* name) :
RooAbsPdf(other,name),
x("x",this,other.x),
mean("mean",this,other.mean),
sig1("sig1",this,other.sig1),
sig2("sig2",this,other.sig2),
yMax(other.yMax)
{
}



Double_t DoubleSidedGaussian::evaluate() const
{
// From wikipedia
double result = -1;
double sqrt2OverPi = TMath::Sqrt(2. / TMath::Pi());
double mode = mean; // redefine mean to mode
double A = sqrt2OverPi / (sig2+sig1);
if (x < mode)
result = A * TMath::Exp( -1 * (x-mode)*(x-mode) / (2*sig1*sig1) );
else
result = A * TMath::Exp( -1 * (x-mode)*(x-mode) / (2*sig2*sig2) );
return result;
}

1 change: 1 addition & 0 deletions src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@
#include "HiggsAnalysis/CombinedLimit/interface/CMSExternalMorph.h"
#include "HiggsAnalysis/CombinedLimit/interface/CMSInterferenceFunc.h"
#include "HiggsAnalysis/CombinedLimit/interface/RooEFTScalingFunction.h"
#include "HiggsAnalysis/CombinedLimit/interface/DoubleSidedGaussian.h"
1 change: 1 addition & 0 deletions src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,5 @@
<class name="CMSExternalMorph" />
<class name="CMSInterferenceFunc" />
<class name="RooEFTScalingFunction" />
<class name="DoubleSidedGaussian" />
</lcgdict>

0 comments on commit c62ced7

Please sign in to comment.