Logo ROOT   6.08/07
Reference Guide
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 
50  enum Mirror {NoMirror, MirrorLeft, MirrorRight, MirrorBoth,
51  MirrorAsymLeft, MirrorAsymLeftRight,
52  MirrorAsymRight, MirrorLeftAsymRight,
53  MirrorAsymBoth };
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,
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,
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) {
80  createPdf(kFALSE);
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 > _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
TVectorD * _dx
Definition: RooNDKeysPdf.h:181
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
RooDataSet & _data
Definition: RooNDKeysPdf.h:119
TMatrixD * _rotMat
Definition: RooNDKeysPdf.h:179
Double_t _widthFactor
Definition: RooNDKeysPdf.h:121
Iterator abstract base class.
Definition: TIterator.h:32
void evaluate(typename Architecture_t::Matrix_t &A, EActivationFunction f)
Apply the given activation function to each value in the given matrix A.
Definition: Functions.h:85
Bool_t _verbose
Definition: RooNDKeysPdf.h:127
std::vector< std::vector< Double_t > > _weights1
Definition: RooNDKeysPdf.h:142
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
std::map< Int_t, Double_t > _wMap
Definition: RooNDKeysPdf.h:175
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
std::vector< Double_t > _x
Definition: RooNDKeysPdf.h:153
std::vector< itVec > _sortTVIdcs
Definition: RooNDKeysPdf.h:147
Double_t _maxWeight
Definition: RooNDKeysPdf.h:174
Double_t _minWeight
Definition: RooNDKeysPdf.h:173
Double_t _sigmaAvgR
Definition: RooNDKeysPdf.h:182
TMatrixDSym * _covMat
Definition: RooNDKeysPdf.h:177
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
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
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
std::vector< Double_t > xVarLoP3s
Definition: RooNDKeysPdf.h:90
Double_t y[n]
Definition: legend1.C:17
std::vector< Int_t > _idx
Definition: RooNDKeysPdf.h:172
std::pair< Int_t, VecTVecDouble::iterator > itPair
Definition: RooNDKeysPdf.h:39
std::vector< Int_t > _sIdcs
Definition: RooNDKeysPdf.h:165
Mother of all ROOT objects.
Definition: TObject.h:37
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
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Bool_t _fixedShape
Definition: RooNDKeysPdf.h:124
Double_t _sqrt2pi
Definition: RooNDKeysPdf.h:129
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
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
TIterator * _varItr
Definition: RooNDKeysPdf.h:100
const Bool_t kTRUE
Definition: Rtypes.h:91
std::vector< Double_t > _xVarLoP3s
Definition: RooNDKeysPdf.h:163
Bool_t _mirror
Definition: RooNDKeysPdf.h:125
void initialize(typename Architecture_t::Matrix_t &A, EInitialization m)
Definition: Functions.h:257
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
char name[80]
Definition: TGX11.cxx:109
virtual TObject * clone(const char *newname) const
Definition: RooNDKeysPdf.h:74
std::vector< iiVec > _sortIdcs
Definition: RooNDKeysPdf.h:146
Double_t _d
Definition: RooNDKeysPdf.h:134
std::vector< Double_t > _x2
Definition: RooNDKeysPdf.h:154