JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
MELANCSplineFactory_2D Class Reference

#include <MELANCSplineFactory_2D.h>

Collaboration diagram for MELANCSplineFactory_2D:

Public Member Functions

 MELANCSplineFactory_2D (RooAbsReal &XVar_, RooAbsReal &YVar_, TString appendName_="", MELANCSplineCore::BoundaryCondition const bcBeginX_=MELANCSplineCore::bcNaturalSpline, MELANCSplineCore::BoundaryCondition const bcEndX_=MELANCSplineCore::bcNaturalSpline, MELANCSplineCore::BoundaryCondition const bcBeginY_=MELANCSplineCore::bcNaturalSpline, MELANCSplineCore::BoundaryCondition const bcEndY_=MELANCSplineCore::bcNaturalSpline)
 
 ~MELANCSplineFactory_2D ()
 
MELANCSpline_2D_fastgetFunc ()
 
MELAFuncPdfgetPDF ()
 
void setEndConditions (MELANCSplineCore::BoundaryCondition const bcBegin, MELANCSplineCore::BoundaryCondition const bcEnd, const unsigned int direction)
 
void setPoints (TTree *tree)
 
void setPoints (const std::vector< splineTriplet_t > &pList)
 
template<typename inType >
void setPoints (const std::vector< inType > &XList, const std::vector< inType > &YList, const std::vector< inType > &FcnList)
 

Protected Member Functions

const std::vector< splineTriplet_tgetPoints (const std::vector< MELANCSplineCore::T > &XList, const std::vector< MELANCSplineCore::T > &YList, const std::vector< MELANCSplineCore::T > &FcnList)
 
void destroyPDF ()
 
void initPDF (const std::vector< splineTriplet_t > &pList)
 
void addUnique (std::vector< MELANCSplineCore::T > &list, MELANCSplineCore::T val)
 

Protected Attributes

TString appendName
 
MELANCSplineCore::BoundaryCondition bcBeginX
 
MELANCSplineCore::BoundaryCondition bcEndX
 
MELANCSplineCore::BoundaryCondition bcBeginY
 
MELANCSplineCore::BoundaryCondition bcEndY
 
RooAbsReal * XVar
 
RooAbsReal * YVar
 
MELANCSpline_2D_fastfcn
 
MELAFuncPdfPDF
 

Detailed Description

Definition at line 14 of file MELANCSplineFactory_2D.h.

Constructor & Destructor Documentation

◆ MELANCSplineFactory_2D()

MELANCSplineFactory_2D::MELANCSplineFactory_2D ( RooAbsReal &  XVar_,
RooAbsReal &  YVar_,
TString  appendName_ = "",
MELANCSplineCore::BoundaryCondition const  bcBeginX_ = MELANCSplineCore::bcNaturalSpline,
MELANCSplineCore::BoundaryCondition const  bcEndX_ = MELANCSplineCore::bcNaturalSpline,
MELANCSplineCore::BoundaryCondition const  bcBeginY_ = MELANCSplineCore::bcNaturalSpline,
MELANCSplineCore::BoundaryCondition const  bcEndY_ = MELANCSplineCore::bcNaturalSpline 
)

Definition at line 6 of file MELANCSplineFactory_2D.cc.

12  :
13  appendName(appendName_),
14  bcBeginX(bcBeginX_), bcEndX(bcEndX_),
15  bcBeginY(bcBeginY_), bcEndY(bcEndY_),
16  XVar(&XVar_), YVar(&YVar_),
17  fcn(0),
18  PDF(0)
19 {}

◆ ~MELANCSplineFactory_2D()

MELANCSplineFactory_2D::~MELANCSplineFactory_2D ( )

Definition at line 20 of file MELANCSplineFactory_2D.cc.

20  {
21  destroyPDF();
22 }

Member Function Documentation

◆ addUnique()

void MELANCSplineFactory_2D::addUnique ( std::vector< MELANCSplineCore::T > &  list,
MELANCSplineCore::T  val 
)
protected

Definition at line 24 of file MELANCSplineFactory_2D.cc.

24  {
25  for (unsigned int ip=0; ip<list.size(); ip++){ if (list.at(ip)==val) return; }
26  list.push_back(val);
27 }

◆ destroyPDF()

void MELANCSplineFactory_2D::destroyPDF ( )
protected

Definition at line 53 of file MELANCSplineFactory_2D.cc.

53 { delete PDF; PDF=0; delete fcn; fcn=0; }

◆ getFunc()

MELANCSpline_2D_fast* MELANCSplineFactory_2D::getFunc ( )
inline

Definition at line 45 of file MELANCSplineFactory_2D.h.

45 { return fcn; }

◆ getPDF()

MELAFuncPdf* MELANCSplineFactory_2D::getPDF ( )
inline

Definition at line 46 of file MELANCSplineFactory_2D.h.

46 { return PDF; }

◆ getPoints()

const std::vector< splineTriplet_t > MELANCSplineFactory_2D::getPoints ( const std::vector< MELANCSplineCore::T > &  XList,
const std::vector< MELANCSplineCore::T > &  YList,
const std::vector< MELANCSplineCore::T > &  FcnList 
)
protected

Definition at line 28 of file MELANCSplineFactory_2D.cc.

32  {
33  const unsigned int nX = XList.size();
34  const unsigned int nY = YList.size();
35  const unsigned int n = FcnList.size();
36  if (nX*nY!=n){
37  cerr << "MELANCSplineFactory_2D::getPoints: nX=" << nX << " x nY=" << nY << " != nFcn=" << n << endl;
38  assert(0);
39  }
40 
41  std::vector<splineTriplet_t> pList; pList.reserve(n);
42  for (unsigned int ix=0; ix<nX; ix++){
43  MELANCSplineCore::T xval = XList.at(ix);
44  for (unsigned int iy=0; iy<nY; iy++){
45  unsigned int ip = nY*ix + iy;
46  MELANCSplineCore::T yval = YList.at(iy);
47  pList.push_back(splineTriplet_t(xval, yval, FcnList.at(ip)));
48  }
49  }
50  return pList;
51 }

◆ initPDF()

void MELANCSplineFactory_2D::initPDF ( const std::vector< splineTriplet_t > &  pList)
protected

Definition at line 54 of file MELANCSplineFactory_2D.cc.

54  {
55  destroyPDF();
56 
57  const unsigned int n = pList.size();
58  vector<MELANCSplineCore::T> XList;
59  vector<MELANCSplineCore::T> YList;
60  vector<vector<MELANCSplineCore::T>> FcnList;
61  for (unsigned int ip=0; ip<n; ip++){
62  addUnique(XList, (pList.at(ip))[0]);
63  addUnique(YList, (pList.at(ip))[1]);
64  }
65  FcnList.reserve(YList.size());
66  for (unsigned int iy=0; iy<YList.size(); iy++){
67  vector<MELANCSplineCore::T> dum; dum.reserve(XList.size());
68  for (unsigned int ix=0; ix<XList.size(); ix++){
69  unsigned int ip = YList.size()*ix + iy;
70  dum.push_back((pList.at(ip))[2]); // Do not use unique here
71  }
72  FcnList.push_back(dum);
73  }
74 
75  TString name = "Func";
76  if (appendName!="") name = Form("%s_%s", name.Data(), appendName.Data());
77  TString title=name;
79  name.Data(),
80  title.Data(),
81  *XVar, *YVar,
82  XList, YList, FcnList,
85  );
86 
87  name.Prepend("PDF_"); title=name;
88  PDF = new MELAFuncPdf(
89  name.Data(),
90  title.Data(),
91  *fcn
92  );
93 }

◆ setEndConditions()

void MELANCSplineFactory_2D::setEndConditions ( MELANCSplineCore::BoundaryCondition const  bcBegin,
MELANCSplineCore::BoundaryCondition const  bcEnd,
const unsigned int  direction 
)

Definition at line 106 of file MELANCSplineFactory_2D.cc.

110  {
111  switch (direction){
112  case 0:
113  bcBeginX=bcBegin;
114  bcEndX=bcEnd;
115  break;
116  case 1:
117  bcBeginY=bcBegin;
118  bcEndY=bcEnd;
119  break;
120  default:
121  // Do nothing
122  break;
123  }
124 }

◆ setPoints() [1/3]

template<typename inType >
void MELANCSplineFactory_2D::setPoints ( const std::vector< inType > &  XList,
const std::vector< inType > &  YList,
const std::vector< inType > &  FcnList 
)
inline

Definition at line 56 of file MELANCSplineFactory_2D.h.

56  {
57  std::vector<MELANCSplineCore::T> transXList;
58  std::vector<MELANCSplineCore::T> transYList;
59  std::vector<MELANCSplineCore::T> transFcnList;
60  for (unsigned int ip=0; ip<XList.size(); ip++) transXList.push_back((MELANCSplineCore::T)XList.at(ip));
61  for (unsigned int ip=0; ip<YList.size(); ip++) transYList.push_back((MELANCSplineCore::T)YList.at(ip));
62  for (unsigned int ip=0; ip<FcnList.size(); ip++) transFcnList.push_back((MELANCSplineCore::T)FcnList.at(ip));
63  const std::vector<splineTriplet_t> pList = getPoints(transXList, transYList, transFcnList);
64  setPoints(pList);
65  }

◆ setPoints() [2/3]

void MELANCSplineFactory_2D::setPoints ( const std::vector< splineTriplet_t > &  pList)
inline

Definition at line 55 of file MELANCSplineFactory_2D.h.

55 { initPDF(pList); }

◆ setPoints() [3/3]

void MELANCSplineFactory_2D::setPoints ( TTree *  tree)

Definition at line 95 of file MELANCSplineFactory_2D.cc.

95  {
96  vector<splineTriplet_t> pList;
98  tree->SetBranchAddress("X", &x);
99  tree->SetBranchAddress("Y", &y);
100  tree->SetBranchAddress("Fcn", &fcn);
101  int n = tree->GetEntries();
102  for (int ip=0; ip<n; ip++){ tree->GetEntry(ip); pList.push_back(splineTriplet_t(x, y, fcn)); }
103  setPoints(pList);
104 }

Member Data Documentation

◆ appendName

TString MELANCSplineFactory_2D::appendName
protected

Definition at line 16 of file MELANCSplineFactory_2D.h.

◆ bcBeginX

MELANCSplineCore::BoundaryCondition MELANCSplineFactory_2D::bcBeginX
protected

Definition at line 18 of file MELANCSplineFactory_2D.h.

◆ bcBeginY

MELANCSplineCore::BoundaryCondition MELANCSplineFactory_2D::bcBeginY
protected

Definition at line 20 of file MELANCSplineFactory_2D.h.

◆ bcEndX

MELANCSplineCore::BoundaryCondition MELANCSplineFactory_2D::bcEndX
protected

Definition at line 19 of file MELANCSplineFactory_2D.h.

◆ bcEndY

MELANCSplineCore::BoundaryCondition MELANCSplineFactory_2D::bcEndY
protected

Definition at line 21 of file MELANCSplineFactory_2D.h.

◆ fcn

MELANCSpline_2D_fast* MELANCSplineFactory_2D::fcn
protected

Definition at line 25 of file MELANCSplineFactory_2D.h.

◆ PDF

MELAFuncPdf* MELANCSplineFactory_2D::PDF
protected

Definition at line 26 of file MELANCSplineFactory_2D.h.

◆ XVar

RooAbsReal* MELANCSplineFactory_2D::XVar
protected

Definition at line 23 of file MELANCSplineFactory_2D.h.

◆ YVar

RooAbsReal* MELANCSplineFactory_2D::YVar
protected

Definition at line 24 of file MELANCSplineFactory_2D.h.


The documentation for this class was generated from the following files:
MELANCSplineCore::T
Float_t T
Definition: MELANCSplineCore.h:18
MELANCSplineFactory_2D::initPDF
void initPDF(const std::vector< splineTriplet_t > &pList)
Definition: MELANCSplineFactory_2D.cc:54
MELANCSplineFactory_2D::destroyPDF
void destroyPDF()
Definition: MELANCSplineFactory_2D.cc:53
MELANCSplineFactory_2D::bcEndX
MELANCSplineCore::BoundaryCondition bcEndX
Definition: MELANCSplineFactory_2D.h:19
MELANCSplineFactory_2D::bcBeginX
MELANCSplineCore::BoundaryCondition bcBeginX
Definition: MELANCSplineFactory_2D.h:18
MELANCSplineFactory_2D::appendName
TString appendName
Definition: MELANCSplineFactory_2D.h:16
MELANCSplineFactory_2D::fcn
MELANCSpline_2D_fast * fcn
Definition: MELANCSplineFactory_2D.h:25
MELANCSplineFactory_2D::bcBeginY
MELANCSplineCore::BoundaryCondition bcBeginY
Definition: MELANCSplineFactory_2D.h:20
MELANCSplineFactory_2D::setPoints
void setPoints(TTree *tree)
Definition: MELANCSplineFactory_2D.cc:95
MELANCSplineFactory_2D::XVar
RooAbsReal * XVar
Definition: MELANCSplineFactory_2D.h:23
MELANCSplineFactory_2D::PDF
MELAFuncPdf * PDF
Definition: MELANCSplineFactory_2D.h:26
MELANCSplineFactory_2D::getPoints
const std::vector< splineTriplet_t > getPoints(const std::vector< MELANCSplineCore::T > &XList, const std::vector< MELANCSplineCore::T > &YList, const std::vector< MELANCSplineCore::T > &FcnList)
Definition: MELANCSplineFactory_2D.cc:28
MELAFuncPdf
Definition: MELAFuncPdf.h:7
MELANCSpline_2D_fast
Definition: MELANCSpline_2D_fast.h:11
MELANCSplineFactory_2D::YVar
RooAbsReal * YVar
Definition: MELANCSplineFactory_2D.h:24
splineTriplet_t
TNumericUtil::triplet< MELANCSplineCore::T > splineTriplet_t
Definition: MELANCSplineFactory_2D.h:12
MELANCSplineFactory_2D::bcEndY
MELANCSplineCore::BoundaryCondition bcEndY
Definition: MELANCSplineFactory_2D.h:21
MELANCSplineFactory_2D::addUnique
void addUnique(std::vector< MELANCSplineCore::T > &list, MELANCSplineCore::T val)
Definition: MELANCSplineFactory_2D.cc:24