JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
MELANCSplineFactory_2D.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 
7  RooAbsReal& XVar_, RooAbsReal& YVar_, TString appendName_,
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 {}
21  destroyPDF();
22 }
23 
24 void MELANCSplineFactory_2D::addUnique(std::vector<MELANCSplineCore::T>& list, MELANCSplineCore::T val){
25  for (unsigned int ip=0; ip<list.size(); ip++){ if (list.at(ip)==val) return; }
26  list.push_back(val);
27 }
28 const std::vector<splineTriplet_t> MELANCSplineFactory_2D::getPoints(
29  const std::vector<MELANCSplineCore::T>& XList,
30  const std::vector<MELANCSplineCore::T>& YList,
31  const std::vector<MELANCSplineCore::T>& FcnList
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 }
52 
53 void MELANCSplineFactory_2D::destroyPDF(){ delete PDF; PDF=0; delete fcn; fcn=0; }
54 void MELANCSplineFactory_2D::initPDF(const std::vector<splineTriplet_t>& pList){
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 }
94 
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 }
105 
109  const unsigned int direction
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 }
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::setEndConditions
void setEndConditions(MELANCSplineCore::BoundaryCondition const bcBegin, MELANCSplineCore::BoundaryCondition const bcEnd, const unsigned int direction)
Definition: MELANCSplineFactory_2D.cc:106
MELANCSplineCore::BoundaryCondition
BoundaryCondition
Definition: MELANCSplineCore.h:28
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::~MELANCSplineFactory_2D
~MELANCSplineFactory_2D()
Definition: MELANCSplineFactory_2D.cc:20
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::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: MELANCSplineFactory_2D.cc:6
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
MELANCSplineFactory_2D.h