Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMultiVarGaussian.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooMultiVarGaussian.cxx
19\class RooMultiVarGaussian
20\ingroup Roofitcore
21
22Multivariate Gaussian p.d.f. with correlations
23**/
24
25#include "Riostream.h"
26#include <cmath>
27
28#include "RooMultiVarGaussian.h"
29#include "RooAbsReal.h"
30#include "RooRealVar.h"
31#include "RooRandom.h"
32#include "RooMath.h"
33#include "RooGlobalFunc.h"
34#include "RooConstVar.h"
35#include "TDecompChol.h"
36#include "RooFitResult.h"
37
38using std::string, std::list, std::map, std::vector, std::cout, std::endl;
39
41
42////////////////////////////////////////////////////////////////////////////////
43
44RooMultiVarGaussian::RooMultiVarGaussian(const char *name, const char *title,
45 const RooArgList& xvec, const RooArgList& mu, const TMatrixDBase& cov) :
46 RooAbsPdf(name,title),
47 _x("x","Observables",this,true,false),
48 _mu("mu","Offset vector",this,true,false),
49 _cov{cov.GetNrows()},
50 _covI{cov.GetNrows()},
51 _z(4)
52{
53 if(!cov.IsSymmetric()) {
54 std::stringstream errorMsg;
55 errorMsg << "RooMultiVarGaussian::RooMultiVarGaussian(" << GetName()
56 << ") input covariance matrix is not symmetric!";
57 coutE(InputArguments) << errorMsg.str() << std::endl;
58 throw std::invalid_argument(errorMsg.str().c_str());
59 }
60
61 _cov.SetSub(0, cov);
62 _covI.SetSub(0, cov);
63
64 _x.add(xvec) ;
65
66 _mu.add(mu) ;
67
69
70 // Invert covariance matrix
71 _covI.Invert() ;
72}
73
74
75////////////////////////////////////////////////////////////////////////////////
76
77RooMultiVarGaussian::RooMultiVarGaussian(const char *name, const char *title, const RooArgList &xvec,
78 const RooFitResult &fr, bool reduceToConditional)
79 : RooAbsPdf(name, title),
80 _x("x", "Observables", this, true, false),
81 _mu("mu", "Offset vector", this, true, false),
82 _cov(reduceToConditional ? fr.conditionalCovarianceMatrix(xvec) : fr.reducedCovarianceMatrix(xvec)),
83 _covI(_cov),
84 _det(_cov.Determinant()),
85 _z(4)
86{
87
88 // Fill mu vector with constant RooRealVars
89 list<string> munames ;
90 const RooArgList& fpf = fr.floatParsFinal() ;
91 for (std::size_t i=0 ; i<fpf.size() ; i++) {
92 if (xvec.find(fpf.at(i)->GetName())) {
93 std::unique_ptr<RooRealVar> parclone{static_cast<RooRealVar*>(fpf.at(i)->Clone(Form("%s_centralvalue",fpf.at(i)->GetName())))};
94 parclone->setConstant(true) ;
95 _mu.addOwned(std::move(parclone));
96 munames.push_back(fpf.at(i)->GetName()) ;
97 }
98 }
99
100 // Fill X vector in same order as mu vector
101 for (list<string>::iterator iter=munames.begin() ; iter!=munames.end() ; ++iter) {
102 RooRealVar* xvar = static_cast<RooRealVar*>(xvec.find(iter->c_str())) ;
103 _x.add(*xvar) ;
104 }
105
106 // Invert covariance matrix
107 _covI.Invert() ;
108
109}
110
111namespace {
112
113RooArgList muFromVector(TVectorD const &mu)
114{
115 RooArgList out;
116 for (int i = 0; i < mu.GetNrows(); i++) {
117 out.add(RooFit::RooConst(mu(i)));
118 }
119 return out;
120}
121
122RooArgList muConstants(std::size_t n)
123{
125 for (std::size_t i = 0; i < n; i++) {
126 out.add(RooFit::RooConst(0));
127 }
128 return out;
129}
130
131} // namespace
132
133
134////////////////////////////////////////////////////////////////////////////////
135
136RooMultiVarGaussian::RooMultiVarGaussian(const char *name, const char *title, const RooArgList &xvec,
137 const TVectorD &mu, const TMatrixDBase &cov)
138 : RooMultiVarGaussian{name, title, xvec, muFromVector(mu), cov}
139{
140}
141
142////////////////////////////////////////////////////////////////////////////////
143
144RooMultiVarGaussian::RooMultiVarGaussian(const char *name, const char *title, const RooArgList &xvec,
145 const TMatrixDBase &cov)
146 : RooMultiVarGaussian{name, title, xvec, muConstants(xvec.size()), cov}
147{
148}
149
150
151////////////////////////////////////////////////////////////////////////////////
152
154 RooAbsPdf(other,name), _aicMap(other._aicMap), _x("x",this,other._x), _mu("mu",this,other._mu),
155 _cov(other._cov), _covI(other._covI), _det(other._det), _z(other._z)
156{
157}
158
159
160
161////////////////////////////////////////////////////////////////////////////////
162
164{
166 for (std::size_t i=0 ; i<_mu.size() ; i++) {
167 _muVec[i] = static_cast<RooAbsReal*>(_mu.at(i))->getVal() ;
168 }
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Represent observables as vector
174
176{
177 TVectorD x(_x.size()) ;
178 for (std::size_t i=0 ; i<_x.size() ; i++) {
179 x[i] = static_cast<RooAbsReal*>(_x.at(i))->getVal() ;
180 }
181
182 // Calculate return value
183 syncMuVec() ;
184 TVectorD x_min_mu = x - _muVec ;
185
186 double alpha = x_min_mu * (_covI * x_min_mu) ;
187 return exp(-0.5*alpha) ;
188}
189
191{
192 std::span<const double> covISpan{_covI.GetMatrixArray(), static_cast<size_t>(_covI.GetNoElements())};
193 ctx.addResult(this, ctx.buildCall("RooFit::Detail::MathFuncs::multiVarGaussian", _x.size(), _x, _mu, covISpan));
194}
195
196////////////////////////////////////////////////////////////////////////////////
197
198Int_t RooMultiVarGaussian::getAnalyticalIntegral(RooArgSet& allVarsIn, RooArgSet& analVars, const char* rangeName) const
199{
200 RooArgSet allVars(allVarsIn) ;
201
202 // If allVars contains x_i it cannot contain mu_i
203 for (std::size_t i=0 ; i<_x.size() ; i++) {
204 if (allVars.contains(*_x.at(i))) {
205 allVars.remove(*_mu.at(i),true,true) ;
206 }
207 }
208
209
210 // Analytical integral known over all observables
211 if (allVars.size()==_x.size() && !rangeName) {
212 analVars.add(allVars) ;
213 return -1 ;
214 }
215
216 Int_t code(0) ;
217
218 Int_t nx = _x.size() ;
219 if (nx>127) {
220 // Warn that analytical integration is only provided for the first 127 observables
221 coutW(Integration) << "RooMultiVarGaussian::getAnalyticalIntegral(" << GetName() << ") WARNING: p.d.f. has " << _x.size()
222 << " observables, analytical integration is only implemented for the first 127 observables" << endl ;
223 nx=127 ;
224 }
225
226 // Advertise partial analytical integral over all observables for which is wide enough to
227 // use asymptotic integral calculation
228 BitBlock bits ;
229 bool anyBits(false) ;
230 syncMuVec() ;
231 for (std::size_t i=0 ; i<_x.size() ; i++) {
232
233 // Check if integration over observable #i is requested
234 if (allVars.find(_x.at(i)->GetName())) {
235 // Check if range is wider than Z sigma
236 RooRealVar* xi = static_cast<RooRealVar*>(_x.at(i)) ;
237 if (xi->getMin(rangeName)<_muVec(i)-_z*sqrt(_cov(i,i)) && xi->getMax(rangeName) > _muVec(i)+_z*sqrt(_cov(i,i))) {
238 cxcoutD(Integration) << "RooMultiVarGaussian::getAnalyticalIntegral(" << GetName()
239 << ") Advertising analytical integral over " << xi->GetName() << " as range is >" << _z << " sigma" << endl ;
240 bits.setBit(i) ;
241 anyBits = true ;
242 analVars.add(*allVars.find(_x.at(i)->GetName())) ;
243 } else {
244 cxcoutD(Integration) << "RooMultiVarGaussian::getAnalyticalIntegral(" << GetName() << ") Range of " << xi->GetName() << " is <"
245 << _z << " sigma, relying on numeric integral" << endl ;
246 }
247 }
248
249 // Check if integration over parameter #i is requested
250 if (allVars.find(_mu.at(i)->GetName())) {
251 // Check if range is wider than Z sigma
252 RooRealVar* pi = static_cast<RooRealVar*>(_mu.at(i)) ;
253 if (pi->getMin(rangeName)<_muVec(i)-_z*sqrt(_cov(i,i)) && pi->getMax(rangeName) > _muVec(i)+_z*sqrt(_cov(i,i))) {
254 cxcoutD(Integration) << "RooMultiVarGaussian::getAnalyticalIntegral(" << GetName()
255 << ") Advertising analytical integral over " << pi->GetName() << " as range is >" << _z << " sigma" << endl ;
256 bits.setBit(i) ;
257 anyBits = true ;
258 analVars.add(*allVars.find(_mu.at(i)->GetName())) ;
259 } else {
260 cxcoutD(Integration) << "RooMultiVarGaussian::getAnalyticalIntegral(" << GetName() << ") Range of " << pi->GetName() << " is <"
261 << _z << " sigma, relying on numeric integral" << endl ;
262 }
263 }
264
265
266 }
267
268 // Full numeric integration over requested observables maps always to code zero
269 if (!anyBits) {
270 return 0 ;
271 }
272
273 // Map BitBlock into return code
274 for (UInt_t i=0 ; i<_aicMap.size() ; i++) {
275 if (_aicMap[i]==bits) {
276 code = i+1 ;
277 }
278 }
279 if (code==0) {
280 _aicMap.push_back(bits) ;
281 code = _aicMap.size() ;
282 }
283
284 return code ;
285}
286
287
288
289////////////////////////////////////////////////////////////////////////////////
290/// Handle full integral here
291
292double RooMultiVarGaussian::analyticalIntegral(Int_t code, const char* /*rangeName*/) const
293{
294 if (code==-1) {
295 return pow(2*3.14159268,_x.size()/2.)*sqrt(std::abs(_det)) ;
296 }
297
298 // Handle partial integrals here
299
300 // Retrieve |S22|, S22bar from cache
301 AnaIntData& aid = anaIntData(code) ;
302
303 // Fill position vector for non-integrated observables
304 syncMuVec() ;
305 TVectorD u(aid.pmap.size()) ;
306 for (UInt_t i=0 ; i<aid.pmap.size() ; i++) {
307 u(i) = (static_cast<RooAbsReal*>(_x.at(aid.pmap[i])))->getVal() - _muVec(aid.pmap[i]) ;
308 }
309
310 // Calculate partial integral
311 double ret = pow(2*3.14159268,aid.nint/2.)/sqrt(std::abs(aid.S22det))*exp(-0.5*u*(aid.S22bar*u)) ;
312
313 return ret ;
314}
315
316
317std::string RooMultiVarGaussian::buildCallToAnalyticIntegral(Int_t code, const char *rangeName,
318 RooFit::Detail::CodeSquashContext & /*ctx*/) const
319{
320 if (code != -1) {
321 std::stringstream errorMsg;
322 errorMsg << "Partial integrals over RooMultiVarGaussian are not supported.";
323 coutE(Minimization) << errorMsg.str() << std::endl;
324 throw std::runtime_error(errorMsg.str().c_str());
325 }
326
327 return std::to_string(analyticalIntegral(code, rangeName));
328}
329
330
331////////////////////////////////////////////////////////////////////////////////
332/// Check if cache entry was previously created
333
335{
336 map<int,AnaIntData>::iterator iter = _anaIntCache.find(code) ;
337 if (iter != _anaIntCache.end()) {
338 return iter->second ;
339 }
340
341 // Calculate cache contents
342
343 // Decode integration code
344 vector<int> map1;
345 vector<int> map2;
346 decodeCode(code,map1,map2) ;
347
348 // Rearrage observables so that all non-integrated observables
349 // go first (preserving relative order) and all integrated observables
350 // go last (preserving relative order)
351 TMatrixDSym S11;
352 TMatrixDSym S22;
353 TMatrixD S12;
354 TMatrixD S21;
355 blockDecompose(_covI,map1,map2,S11,S12,S21,S22) ;
356
357 // Begin calculation of partial integrals
358 // ___
359 // sqrt(2pi)^(#intObs) (-0.5 * u1T S22 u1 )
360 // I = ------------------- * e
361 // sqrt(|det(S22)|)
362 // ___
363 // Where S22 is the sub-matrix of covI for the integrated observables and S22
364 // is the Schur complement of S22
365 // ___ -1
366 // S22 = S11 - S12 * S22 * S21
367 //
368 // and u1 is the vector of non-integrated observables
369
370 // Calculate Schur complement S22bar
371 TMatrixD S22inv(S22) ;
372 S22inv.Invert() ;
373 TMatrixD S22bar = S11 - S12*S22inv*S21 ;
374
375 // Create new cache entry
376 AnaIntData& cacheData = _anaIntCache[code] ;
377 cacheData.S22bar.ResizeTo(S22bar) ;
378 cacheData.S22bar=S22bar ;
379 cacheData.S22det= S22.Determinant() ;
380 cacheData.pmap = map1 ;
381 cacheData.nint = map2.size() ;
382
383 return cacheData ;
384}
385
386
387
388////////////////////////////////////////////////////////////////////////////////
389/// Special case: generate all observables
390
391Int_t RooMultiVarGaussian::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool /*staticInitOK*/) const
392{
393 if (directVars.size()==_x.size()) {
394 generateVars.add(directVars) ;
395 return -1 ;
396 }
397
398 Int_t nx = _x.size() ;
399 if (nx>127) {
400 // Warn that analytical integration is only provided for the first 127 observables
401 coutW(Integration) << "RooMultiVarGaussian::getGenerator(" << GetName() << ") WARNING: p.d.f. has " << _x.size()
402 << " observables, partial internal generation is only implemented for the first 127 observables" << endl ;
403 nx=127 ;
404 }
405
406 // Advertise partial generation over all permutations of observables
407 Int_t code(0) ;
408 BitBlock bits ;
409 for (std::size_t i=0 ; i<_x.size() ; i++) {
410 RooAbsArg* arg = directVars.find(_x.at(i)->GetName()) ;
411 if (arg) {
412 bits.setBit(i) ;
413// code |= (1<<i) ;
414 generateVars.add(*arg) ;
415 }
416 }
417
418 // Map BitBlock into return code
419 for (UInt_t i=0 ; i<_aicMap.size() ; i++) {
420 if (_aicMap[i]==bits) {
421 code = i+1 ;
422 }
423 }
424 if (code==0) {
425 _aicMap.push_back(bits) ;
426 code = _aicMap.size() ;
427 }
428
429
430 return code ;
431}
432
433
434
435////////////////////////////////////////////////////////////////////////////////
436/// Clear the GenData cache as its content is not invariant under changes in
437/// the mu vector.
438
440{
441 _genCache.clear() ;
442
443}
444
445
446
447
448////////////////////////////////////////////////////////////////////////////////
449/// Retrieve generator config from cache
450
452{
453 GenData& gd = genData(code) ;
454 TMatrixD& TU = gd.UT ;
455 Int_t nobs = TU.GetNcols() ;
456 vector<int>& omap = gd.omap ;
457
458 while(true) {
459
460 // Create unit Gaussian vector
461 TVectorD xgen(nobs);
462 for(Int_t k= 0; k <nobs; k++) {
463 xgen(k)= RooRandom::gaussian();
464 }
465
466 // Apply transformation matrix
467 xgen *= TU ;
468
469 // Apply shift
470 if (code == -1) {
471
472 // Simple shift if we generate all observables
473 xgen += gd.mu1 ;
474
475 } else {
476
477 // Non-generated observable dependent shift for partial generations
478
479 // mubar = mu1 + S12 S22Inv ( x2 - mu2)
480 TVectorD mubar(gd.mu1) ;
481 TVectorD x2(gd.pmap.size()) ;
482 for (UInt_t i=0 ; i<gd.pmap.size() ; i++) {
483 x2(i) = (static_cast<RooAbsReal*>(_x.at(gd.pmap[i])))->getVal() ;
484 }
485 mubar += gd.S12S22I * (x2 - gd.mu2) ;
486
487 xgen += mubar ;
488
489 }
490
491 // Transfer values and check if values are in range
492 bool ok(true) ;
493 for (int i=0 ; i<nobs ; i++) {
494 RooRealVar* xi = static_cast<RooRealVar*>(_x.at(omap[i])) ;
495 if (xgen(i)<xi->getMin() || xgen(i)>xi->getMax()) {
496 ok = false ;
497 break ;
498 } else {
499 xi->setVal(xgen(i)) ;
500 }
501 }
502
503 // If all values are in range, accept event and return
504 // otherwise retry
505 if (ok) {
506 break ;
507 }
508 }
509
510 return;
511}
512
513
514
515////////////////////////////////////////////////////////////////////////////////
516/// WVE -- CHECK THAT GENDATA IS VALID GIVEN CURRENT VALUES OF _MU
517
519{
520 // Check if cache entry was previously created
521 map<int,GenData>::iterator iter = _genCache.find(code) ;
522 if (iter != _genCache.end()) {
523 return iter->second ;
524 }
525
526 // Create new entry
527 GenData& cacheData = _genCache[code] ;
528
529 if (code==-1) {
530
531 // Do eigen value decomposition
532 TDecompChol tdc(_cov) ;
533 tdc.Decompose() ;
534 TMatrixD U = tdc.GetU() ;
536
537 // Fill cache data
538 cacheData.UT.ResizeTo(TU) ;
539 cacheData.UT = TU ;
540 cacheData.omap.resize(_x.size()) ;
541 for (std::size_t i=0 ; i<_x.size() ; i++) {
542 cacheData.omap[i] = i ;
543 }
544 syncMuVec() ;
545 cacheData.mu1.ResizeTo(_muVec) ;
546 cacheData.mu1 = _muVec ;
547
548 } else {
549
550 // Construct observables: map1 = generated, map2 = given
551 vector<int> map1;
552 vector<int> map2;
553 decodeCode(code,map2,map1) ;
554
555 // Do block decomposition of covariance matrix
556 TMatrixDSym S11;
557 TMatrixDSym S22;
558 TMatrixD S12;
559 TMatrixD S21;
560 blockDecompose(_cov,map1,map2,S11,S12,S21,S22) ;
561
562 // Constructed conditional matrix form
563 // -1
564 // F(X1|X2) --> CovI --> S22bar = S11 - S12 S22 S21
565 // -1
566 // --> mu --> mubar = mu1 + S12 S22 ( x2 - mu2)
567
568 // Do eigenvalue decomposition
569 TMatrixD S22Inv(TMatrixD::kInverted,S22) ;
570 TMatrixD S22bar = S11 - S12 * (S22Inv * S21) ;
571
572 // Do eigen value decomposition of S22bar
573 TDecompChol tdc(S22bar) ;
574 tdc.Decompose() ;
575 TMatrixD U = tdc.GetU() ;
577
578 // Split mu vector into mu1 and mu2
579 TVectorD mu1(map1.size());
580 TVectorD mu2(map2.size());
581 syncMuVec() ;
582 for (UInt_t i=0 ; i<map1.size() ; i++) {
583 mu1(i) = _muVec(map1[i]) ;
584 }
585 for (UInt_t i=0 ; i<map2.size() ; i++) {
586 mu2(i) = _muVec(map2[i]) ;
587 }
588
589 // Calculate rotation matrix for mu vector
590 TMatrixD S12S22Inv = S12 * S22Inv ;
591
592 // Fill cache data
593 cacheData.UT.ResizeTo(TU) ;
594 cacheData.UT = TU ;
595 cacheData.omap = map1 ;
596 cacheData.pmap = map2 ;
597 cacheData.mu1.ResizeTo(mu1) ;
598 cacheData.mu2.ResizeTo(mu2) ;
599 cacheData.mu1 = mu1 ;
600 cacheData.mu2 = mu2 ;
601 cacheData.S12S22I.ResizeTo(S12S22Inv) ;
602 cacheData.S12S22I = S12S22Inv ;
603
604 }
605
606
607 return cacheData ;
608}
609
610
611
612
613////////////////////////////////////////////////////////////////////////////////
614/// Decode analytical integration/generation code into index map of integrated/generated (map2)
615/// and non-integrated/generated observables (map1)
616
617void RooMultiVarGaussian::decodeCode(Int_t code, vector<int>& map1, vector<int>& map2) const
618{
619 if (code<0 || code> (Int_t)_aicMap.size()) {
620 cout << "RooMultiVarGaussian::decodeCode(" << GetName() << ") ERROR don't have bit pattern for code " << code << endl ;
621 throw string("RooMultiVarGaussian::decodeCode() ERROR don't have bit pattern for code") ;
622 }
623
624 BitBlock b = _aicMap[code-1] ;
625 map1.clear() ;
626 map2.clear() ;
627 for (std::size_t i=0 ; i<_x.size() ; i++) {
628 if (b.getBit(i)) {
629 map2.push_back(i) ;
630 } else {
631 map1.push_back(i) ;
632 }
633 }
634}
635
636
637////////////////////////////////////////////////////////////////////////////////
638/// Block decomposition of covI according to given maps of observables
639
640void RooMultiVarGaussian::blockDecompose(const TMatrixD& input, const vector<int>& map1, const vector<int>& map2, TMatrixDSym& S11, TMatrixD& S12, TMatrixD& S21, TMatrixDSym& S22)
641{
642 // Allocate and fill reordered covI matrix in 2x2 block structure
643
644 S11.ResizeTo(map1.size(),map1.size()) ;
645 S12.ResizeTo(map1.size(),map2.size()) ;
646 S21.ResizeTo(map2.size(),map1.size()) ;
647 S22.ResizeTo(map2.size(),map2.size()) ;
648
649 for (UInt_t i=0 ; i<map1.size() ; i++) {
650 for (UInt_t j=0 ; j<map1.size() ; j++)
651 S11(i,j) = input(map1[i],map1[j]) ;
652 for (UInt_t j=0 ; j<map2.size() ; j++)
653 S12(i,j) = input(map1[i],map2[j]) ;
654 }
655 for (UInt_t i=0 ; i<map2.size() ; i++) {
656 for (UInt_t j=0 ; j<map1.size() ; j++)
657 S21(i,j) = input(map2[i],map1[j]) ;
658 for (UInt_t j=0 ; j<map2.size() ; j++)
659 S22(i,j) = input(map2[i],map2[j]) ;
660 }
661
662}
663
664
666{
667 if (ibit<32) { b0 |= (1<<ibit) ; return ; }
668 if (ibit<64) { b1 |= (1<<(ibit-32)) ; return ; }
669 if (ibit<96) { b2 |= (1<<(ibit-64)) ; return ; }
670 if (ibit<128) { b3 |= (1<<(ibit-96)) ; return ; }
671}
672
674{
675 if (ibit<32) return (b0 & (1<<ibit)) ;
676 if (ibit<64) return (b1 & (1<<(ibit-32))) ;
677 if (ibit<96) return (b2 & (1<<(ibit-64))) ;
678 if (ibit<128) return (b3 & (1<<(ibit-96))) ;
679 return false ;
680}
681
683{
684 if (lhs.b0 != rhs.b0)
685 return false;
686 if (lhs.b1 != rhs.b1)
687 return false;
688 if (lhs.b2 != rhs.b2)
689 return false;
690 if (lhs.b3 != rhs.b3)
691 return false;
692 return true;
693}
#define b(i)
Definition RSha256.hxx:100
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define cxcoutD(a)
#define coutW(a)
#define coutE(a)
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char x2
char name[80]
Definition TGX11.cxx:110
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
Definition RooAbsArg.h:91
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
void setConstant(bool value=true)
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
bool operator==(double value) const
Equality operator comparing to a double.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
bool addOwned(RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::addOwned() method insert object into owning set and registers object as s...
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
A class to maintain the context for squashing of RooFit models into code.
std::string buildCall(std::string const &funcname, Args_t const &...args)
Build the code to call the function with name funcname, passing some arguments.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
Multivariate Gaussian p.d.f.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Handle full integral here.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
void decodeCode(Int_t code, std::vector< int > &map1, std::vector< int > &map2) const
Decode analytical integration/generation code into index map of integrated/generated (map2) and non-i...
std::vector< BitBlock > _aicMap
!
static void blockDecompose(const TMatrixD &input, const std::vector< int > &map1, const std::vector< int > &map2, TMatrixDSym &S11, TMatrixD &S12, TMatrixD &S21, TMatrixDSym &S22)
Block decomposition of covI according to given maps of observables.
AnaIntData & anaIntData(Int_t code) const
Check if cache entry was previously created.
double evaluate() const override
Do not persist.
std::map< int, GenData > _genCache
!
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Special case: generate all observables.
void initGenerator(Int_t code) override
Clear the GenData cache as its content is not invariant under changes in the mu vector.
std::string buildCallToAnalyticIntegral(Int_t code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override
This function defines the analytical integral translation for the class.
GenData & genData(Int_t code) const
WVE – CHECK THAT GENDATA IS VALID GIVEN CURRENT VALUES OF _MU.
std::map< int, AnaIntData > _anaIntCache
!
void generateEvent(Int_t code) override
Retrieve generator config from cache.
static double gaussian(TRandom *generator=randomGenerator())
Return a Gaussian random variable with mean 0 and variance 1.
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setVal(double value) override
Set value of variable to 'value'.
Cholesky Decomposition class.
Definition TDecompChol.h:25
Bool_t Decompose() override
Matrix A is decomposed in component U so that A = U^T * U If the decomposition succeeds,...
const TMatrixD & GetU() const
Definition TDecompChol.h:45
Int_t GetNoElements() const
Int_t GetNcols() const
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixTSym< Element > & SetSub(Int_t row_lwb, const TMatrixTBase< Element > &source)
Insert matrix source starting at [row_lwb][row_lwb], thereby overwriting the part [row_lwb....
Double_t Determinant() const override
TMatrixTSym< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant Notice that the LU decomposition is used instead of B...
const Element * GetMatrixArray() const override
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixT< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
Definition TVectorT.cxx:294
Int_t GetNrows() const
Definition TVectorT.h:73
RooConstVar & RooConst(double val)
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16