ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RooNDKeysPdf.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitModels *
4  * File: $Id: RooNDKeysPdf.h 44368 2012-05-30 15:38:44Z axel $
5  * Authors: *
6  * Max Baak, CERN, mbaak@cern.ch *
7  * *
8  * Copyright (c) 2000-2005, Regents of the University of California *
9  * and Stanford University. All rights reserved. *
10  * *
11  * Redistribution and use in source and binary forms, *
12  * with or without modification, are permitted according to the terms *
13  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
14  *****************************************************************************/
15 #ifndef ROO_NDKEYS_PDF
16 #define ROO_NDKEYS_PDF
17 
18 #include "RooAbsPdf.h"
19 #include "RooRealProxy.h"
20 #include "RooSetProxy.h"
21 #include "RooRealConstant.h"
22 #include "TVectorD.h"
23 #include "TMatrixD.h"
24 #include "TMatrixDSym.h"
25 #include <map>
26 #include <vector>
27 #include <string>
28 
29 class RooRealVar;
30 class RooArgList;
31 class RooArgSet;
32 
33 
34 #ifndef __CINT__
35 class VecVecDouble : public std::vector<std::vector<Double_t> > { } ;
36 class VecTVecDouble : public std::vector<TVectorD> { } ;
37 typedef std::pair<Int_t, VecVecDouble::iterator > iiPair;
38 typedef std::vector< iiPair > iiVec;
39 typedef std::pair<Int_t, VecTVecDouble::iterator > itPair;
40 typedef std::vector< itPair > itVec;
41 #else
42 class itPair ;
43 #endif
44 
45 class RooNDKeysPdf : public RooAbsPdf {
46 
47 public:
48 
49 
54 
55  RooNDKeysPdf(const char *name, const char *title,
56  const RooArgList& varList, RooDataSet& data,
57  TString options="a", Double_t rho=1, Double_t nSigma=3, Bool_t rotate=kTRUE) ;
58 
59  RooNDKeysPdf(const char *name, const char *title,
60  const RooArgList& varList, RooDataSet& data, const TVectorD& rho,
61  TString options="a", Double_t nSigma=3, Bool_t rotate=kTRUE) ;
62 
63  RooNDKeysPdf(const char *name, const char *title,
64  RooAbsReal& x, RooDataSet& data,
65  Mirror mirror= NoMirror, Double_t rho=1, Double_t nSigma=3, Bool_t rotate=kTRUE) ;
66 
67  RooNDKeysPdf(const char *name, const char *title,
68  RooAbsReal& x, RooAbsReal &y, RooDataSet& data,
69  TString options="a", Double_t rho = 1.0, Double_t nSigma=3, Bool_t rotate=kTRUE);
70 
71  RooNDKeysPdf(const RooNDKeysPdf& other, const char* name=0);
72  virtual ~RooNDKeysPdf();
73 
74  virtual TObject* clone(const char* newname) const { return new RooNDKeysPdf(*this,newname); }
75 
76  Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=0) const ;
77  Double_t analyticalIntegral(Int_t code, const char* rangeName=0) const ;
78 
79  inline void fixShape(Bool_t fix) {
81  _fixedShape=fix;
82  }
83 
84  struct BoxInfo {
89  std::vector<Double_t> xVarLo, xVarHi;
90  std::vector<Double_t> xVarLoM3s, xVarLoP3s, xVarHiM3s, xVarHiP3s;
91  std::map<Int_t,Bool_t> bpsIdcs;
92  std::vector<Int_t> sIdcs;
93  std::vector<Int_t> bIdcs;
94  std::vector<Int_t> bmsIdcs;
95  } ;
96 
97 protected:
98 
100  TIterator* _varItr ; //! do not persist
101 
102  Double_t evaluate() const;
103 
104 
105  void createPdf(Bool_t firstCall=kTRUE) const;
106  void setOptions() const;
107  void initialize() const;
108  void loadDataSet(Bool_t firstCall) const;
109  void mirrorDataSet() const;
110  void loadWeightSet() const;
111  void calculateShell(BoxInfo* bi) const;
112  void calculatePreNorm(BoxInfo* bi) const;
113  void sortDataIndices(BoxInfo* bi=0) const;
114  void calculateBandWidth() const;
115  Double_t gauss(std::vector<Double_t>& x, std::vector<std::vector<Double_t> >& weights) const;
116  void loopRange(std::vector<Double_t>& x, std::map<Int_t,Bool_t>& ibMap) const;
117  void boxInfoInit(BoxInfo* bi, const char* rangeName, Int_t code) const;
118 
120  mutable TString _options;
122  mutable Double_t _nSigma;
123 
125  mutable Bool_t _mirror;
126  mutable Bool_t _debug;
127  mutable Bool_t _verbose;
128 
130  mutable Int_t _nDim;
131  mutable Int_t _nEvents;
132  mutable Int_t _nEventsM;
134  mutable Double_t _d;
135  mutable Double_t _n;
136 
137  // cached info on variable
138 
139  mutable std::vector<std::vector<Double_t> > _dataPts;
140  mutable std::vector<TVectorD> _dataPtsR;
141  mutable std::vector<std::vector<Double_t> > _weights0;
142  mutable std::vector<std::vector<Double_t> > _weights1;
143  mutable std::vector<std::vector<Double_t> >* _weights; //!
144 
145 #ifndef __CINT__
146  mutable std::vector<iiVec> _sortIdcs; //!
147  mutable std::vector<itVec> _sortTVIdcs; //!
148 #endif
149 
150  mutable std::vector<std::string> _varName;
151  mutable std::vector<Double_t> _rho;
153  mutable std::vector<Double_t> _x;
154  mutable std::vector<Double_t> _x0, _x1, _x2;
155  mutable std::vector<Double_t> _mean, _sigma;
156  mutable std::vector<Double_t> _xDatLo, _xDatHi;
157  mutable std::vector<Double_t> _xDatLo3s, _xDatHi3s;
158 
159  mutable Bool_t _netFluxZ;
162  mutable std::vector<Double_t> _xVarLo, _xVarHi;
163  mutable std::vector<Double_t> _xVarLoM3s, _xVarLoP3s, _xVarHiM3s, _xVarHiP3s;
164  mutable std::map<Int_t,Bool_t> _bpsIdcs;
165  mutable std::vector<Int_t> _sIdcs;
166  mutable std::vector<Int_t> _bIdcs;
167  mutable std::vector<Int_t> _bmsIdcs;
168 
169  mutable std::map<std::pair<std::string,int>,BoxInfo*> _rangeBoxInfo ;
171 
172  mutable std::vector<Int_t> _idx;
175  mutable std::map<Int_t,Double_t> _wMap;
176 
177  mutable TMatrixDSym* _covMat;
179  mutable TMatrixD* _rotMat;
180  mutable TVectorD* _sigmaR;
181  mutable TVectorD* _dx;
183 
184  mutable Bool_t _rotate;
185 
186  /// sorter function
187  struct SorterTV_L2H {
189 
190  SorterTV_L2H (Int_t index) : idx(index) {}
191  bool operator() (const itPair& a, const itPair& b) {
192  const TVectorD& aVec = *(a.second);
193  const TVectorD& bVec = *(b.second);
194  return (aVec[idx]<bVec[idx]);
195  }
196  };
197 
198  ClassDef(RooNDKeysPdf,1) // General N-dimensional non-parametric kernel estimation p.d.f
199 };
200 
201 #endif
Double_t _n
Definition: RooNDKeysPdf.h:135
Bool_t _rotate
Definition: RooNDKeysPdf.h:184
std::vector< itPair > itVec
Definition: RooNDKeysPdf.h:40
std::vector< iiPair > iiVec
Definition: RooNDKeysPdf.h:38
RooListProxy _varList
Definition: RooNDKeysPdf.h:99
std::vector< Double_t > xVarHi
Definition: RooNDKeysPdf.h:89
std::vector< Double_t > _xVarLo
Definition: RooNDKeysPdf.h:162
Double_t _nEventsW
Definition: RooNDKeysPdf.h:133
TMatrixDSym * _corrMat
Definition: RooNDKeysPdf.h:178
Double_t _nSigma
Definition: RooNDKeysPdf.h:122
std::vector< std::string > _varName
Definition: RooNDKeysPdf.h:150
std::vector< Int_t > bIdcs
Definition: RooNDKeysPdf.h:93
void boxInfoInit(BoxInfo *bi, const char *rangeName, Int_t code) const
TVectorD * _dx
Definition: RooNDKeysPdf.h:181
virtual TObject * clone(const char *newname) const
Definition: RooNDKeysPdf.h:74
Bool_t _netFluxZ
Definition: RooNDKeysPdf.h:159
std::vector< Int_t > _bIdcs
Definition: RooNDKeysPdf.h:166
Basic string class.
Definition: TString.h:137
std::vector< Double_t > _xDatLo
Definition: RooNDKeysPdf.h:156
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
Double_t evaluate() const
do not persist
RooDataSet & _data
Definition: RooNDKeysPdf.h:119
TMatrixD * _rotMat
Definition: RooNDKeysPdf.h:179
virtual ~RooNDKeysPdf()
std::vector< Double_t > _x1
Definition: RooNDKeysPdf.h:154
Double_t _widthFactor
Definition: RooNDKeysPdf.h:121
Iterator abstract base class.
Definition: TIterator.h:32
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported...
Bool_t _verbose
Definition: RooNDKeysPdf.h:127
std::vector< Double_t > _xDatHi
Definition: RooNDKeysPdf.h:156
std::vector< Double_t > _xVarLoM3s
Definition: RooNDKeysPdf.h:163
std::vector< std::vector< Double_t > > _weights1
Definition: RooNDKeysPdf.h:142
std::vector< Double_t > _xVarHiM3s
Definition: RooNDKeysPdf.h:163
Double_t x[n]
Definition: legend1.C:17
std::pair< Int_t, VecVecDouble::iterator > iiPair
Definition: RooNDKeysPdf.h:37
#define ClassDef(name, id)
Definition: Rtypes.h:254
void loopRange(std::vector< Double_t > &x, std::map< Int_t, Bool_t > &ibMap) const
determine closest points to x, to loop over in evaluate()
std::map< Int_t, Double_t > _wMap
Definition: RooNDKeysPdf.h:175
void calculateBandWidth() const
std::map< std::pair< std::string, int >, BoxInfo * > _rangeBoxInfo
Definition: RooNDKeysPdf.h:169
void fixShape(Bool_t fix)
Definition: RooNDKeysPdf.h:79
TVectorD * _sigmaR
Definition: RooNDKeysPdf.h:180
std::vector< Double_t > _xDatLo3s
Definition: RooNDKeysPdf.h:157
std::vector< std::vector< Double_t > > * _weights
Definition: RooNDKeysPdf.h:143
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
void sortDataIndices(BoxInfo *bi=0) const
sort entries, as needed for loopRange()
std::vector< Double_t > xVarHiP3s
Definition: RooNDKeysPdf.h:90
void calculatePreNorm(BoxInfo *bi) const
bi->nEventsBMSW=0.
std::vector< Double_t > _x
Definition: RooNDKeysPdf.h:153
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
std::vector< itVec > _sortTVIdcs
Definition: RooNDKeysPdf.h:147
void setOptions() const
set the configuration
Double_t _maxWeight
Definition: RooNDKeysPdf.h:174
void createPdf(Bool_t firstCall=kTRUE) const
evaluation order of constructor.
Double_t _minWeight
Definition: RooNDKeysPdf.h:173
Double_t _sigmaAvgR
Definition: RooNDKeysPdf.h:182
TMatrixDSym * _covMat
Definition: RooNDKeysPdf.h:177
std::vector< Double_t > xVarHiM3s
Definition: RooNDKeysPdf.h:90
RooNDKeysPdf(const char *name, const char *title, const RooArgList &varList, RooDataSet &data, TString options="a", Double_t rho=1, Double_t nSigma=3, Bool_t rotate=kTRUE)
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
std::vector< Double_t > _x0
Definition: RooNDKeysPdf.h:154
Generic N-dimensional implementation of a kernel estimation p.d.f.
Definition: RooNDKeysPdf.h:45
Double_t _nEventsBW
Definition: RooNDKeysPdf.h:160
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:26
TString _options
Definition: RooNDKeysPdf.h:120
BoxInfo _fullBoxInfo
Definition: RooNDKeysPdf.h:170
std::vector< Double_t > _mean
Definition: RooNDKeysPdf.h:155
std::vector< Double_t > _xVarHiP3s
Definition: RooNDKeysPdf.h:163
Double_t _nEventsBMSW
Definition: RooNDKeysPdf.h:161
RooArgSet _dataVars
Definition: RooNDKeysPdf.h:152
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
std::map< Int_t, Bool_t > _bpsIdcs
Definition: RooNDKeysPdf.h:164
std::vector< Int_t > sIdcs
Definition: RooNDKeysPdf.h:92
void mirrorDataSet() const
determine mirror dataset.
std::vector< Double_t > xVarLoP3s
Definition: RooNDKeysPdf.h:90
Double_t y[n]
Definition: legend1.C:17
std::vector< Double_t > _xVarHi
Definition: RooNDKeysPdf.h:162
std::vector< Int_t > _idx
Definition: RooNDKeysPdf.h:172
std::pair< Int_t, VecTVecDouble::iterator > itPair
Definition: RooNDKeysPdf.h:39
bool operator()(const itPair &a, const itPair &b)
Definition: RooNDKeysPdf.h:191
std::vector< Double_t > _xDatHi3s
Definition: RooNDKeysPdf.h:157
std::vector< Int_t > _sIdcs
Definition: RooNDKeysPdf.h:165
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
std::map< Int_t, Bool_t > bpsIdcs
Definition: RooNDKeysPdf.h:91
std::vector< Int_t > bmsIdcs
Definition: RooNDKeysPdf.h:94
std::vector< Double_t > _rho
Definition: RooNDKeysPdf.h:151
void initialize() const
initialization
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral. ...
Bool_t _fixedShape
Definition: RooNDKeysPdf.h:124
void calculateShell(BoxInfo *bi) const
determine points in +/- nSigma shell around the box determined by the variable ranges.
Double_t _sqrt2pi
Definition: RooNDKeysPdf.h:129
std::vector< TVectorD > _dataPtsR
Definition: RooNDKeysPdf.h:140
std::vector< std::vector< Double_t > > _dataPts
Definition: RooNDKeysPdf.h:139
std::vector< std::vector< Double_t > > _weights0
Definition: RooNDKeysPdf.h:141
void loadWeightSet() const
TIterator * _varItr
Definition: RooNDKeysPdf.h:100
void loadDataSet(Bool_t firstCall) const
copy the dataset and calculate some useful variables
const Bool_t kTRUE
Definition: Rtypes.h:91
std::vector< Double_t > _xVarLoP3s
Definition: RooNDKeysPdf.h:163
Bool_t _mirror
Definition: RooNDKeysPdf.h:125
std::vector< Double_t > _sigma
Definition: RooNDKeysPdf.h:155
std::vector< Double_t > xVarLo
Definition: RooNDKeysPdf.h:89
std::vector< Int_t > _bmsIdcs
Definition: RooNDKeysPdf.h:167
Double_t gauss(std::vector< Double_t > &x, std::vector< std::vector< Double_t > > &weights) const
loop over all closest point to x, as determined by loopRange()
std::vector< Double_t > xVarLoM3s
Definition: RooNDKeysPdf.h:90
std::vector< iiVec > _sortIdcs
Definition: RooNDKeysPdf.h:146
Double_t _d
Definition: RooNDKeysPdf.h:134
std::vector< Double_t > _x2
Definition: RooNDKeysPdf.h:154