Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooBarlowBeestonLL.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, George Lewis
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11//////////////////////////////////////////////////////////////////////////////
12/** \class RooStats::HistFactory::RooBarlowBeestonLL
13 * \ingroup HistFactory
14//
15// Class RooBarlowBeestonLL implements the profile likelihood estimator for
16// a given likelihood and set of parameters of interest. The value return by
17// RooBarlowBeestonLL is the input likelihood nll minimized w.r.t all nuisance parameters
18// (which are all parameters except for those listed in the constructor) minus
19// the -log(L) of the best fit. Note that this function is slow to evaluate
20// as a MIGRAD minimization step is executed for each function evaluation
21*/
22
23#include <stdexcept>
24#include <cmath>
25#include <iostream>
26
28#include "RooAbsReal.h"
29#include "RooMsgService.h"
30#include "RooRealVar.h"
31
33#include "RooCategory.h"
34#include "RooSimultaneous.h"
35#include "RooArgList.h"
36
39
40#include <TMath.h>
41
42using namespace std ;
43
45
46
47////////////////////////////////////////////////////////////////////////////////
48
50 RooAbsReal("RooBarlowBeestonLL","RooBarlowBeestonLL"),
51 _nll(),
52// _obs("paramOfInterest","Parameters of interest",this),
53// _par("nuisanceParam","Nuisance parameters",this,false,false),
54 _pdf(nullptr), _data(nullptr)
55{
56 // Default constructor
57 // Should only be used by proof.
58}
59
60
61////////////////////////////////////////////////////////////////////////////////
62
64 RooAbsReal& nllIn /*, const RooArgSet& observables*/) :
65 RooAbsReal(name,title),
66 _nll("input","-log(L) function",this,nllIn),
67 // _obs("paramOfInterest","Parameters of interest",this),
68 // _par("nuisanceParam","Nuisance parameters",this,false,false),
69 _pdf(nullptr), _data(nullptr)
70{
71 // Constructor of profile likelihood given input likelihood nll w.r.t
72 // the given set of variables. The input log likelihood is minimized w.r.t
73 // to all other variables of the likelihood at each evaluation and the
74 // value of the global log likelihood minimum is always subtracted.
75
76 // Determine actual parameters and observables
77 /*
78 RooArgSet* actualObs = nllIn.getObservables(observables) ;
79 RooArgSet* actualPars = nllIn.getParameters(observables) ;
80
81 _obs.add(*actualObs) ;
82 _par.add(*actualPars) ;
83
84 delete actualObs ;
85 delete actualPars ;
86 */
87}
88
89
90
91////////////////////////////////////////////////////////////////////////////////
92
94 RooAbsReal(other,name),
95 _nll("nll",this,other._nll),
96 // _obs("obs",this,other._obs),
97 // _par("par",this,other._par),
98 _pdf(nullptr), _data(nullptr),
99 _paramFixed(other._paramFixed)
100{
101 // Copy constructor
102
103 // _paramAbsMin.addClone(other._paramAbsMin) ;
104 // _obsAbsMin.addClone(other._obsAbsMin) ;
105
106}
107
108
109////////////////////////////////////////////////////////////////////////////////
110
112 for (auto const *var : static_range_cast<RooRealVar *>(*bin_center)) {
113 RooRealVar* target = (RooRealVar*) observables->find(var->GetName()) ;
114 target->setVal(var->getVal()) ;
115 }
116}
117
118
119////////////////////////////////////////////////////////////////////////////////
120
122 bool verbose=false;
123
124 if(!_data) {
125 std::cout << "Error: Must initialize data before initializing cache" << std::endl;
126 throw std::runtime_error("Uninitialized Data");
127 }
128 if(!_pdf) {
129 std::cout << "Error: Must initialize model pdf before initializing cache" << std::endl;
130 throw std::runtime_error("Uninitialized model pdf");
131 }
132
133 // Get the data bin values for all channels and bins
134 std::map< std::string, std::vector<double> > ChannelBinDataMap;
135 getDataValuesForObservables( ChannelBinDataMap, _data, _pdf );
136
137 // Get a list of constraint terms
138 RooArgList obsTerms;
139 RooArgList constraints;
140 RooArgSet* obsSet = std::unique_ptr<RooArgSet>{_pdf->getObservables(*_data)}.release();
141 FactorizeHistFactoryPdf(*obsSet, *_pdf, obsTerms, constraints);
142
143 if( obsTerms.empty() ) {
144 std::cout << "Error: Found no observable terms with pdf: " << _pdf->GetName()
145 << " using dataset: " << _data->GetName() << std::endl;
146 return;
147 }
148 if( constraints.empty() ) {
149 std::cout << "Error: Found no constraint terms with pdf: " << _pdf->GetName()
150 << " using dataset: " << _data->GetName() << std::endl;
151 return;
152 }
153
154 /*
155 // Get the channels for this pdf
156 RooArgSet* channels = new RooArgSet();
157 RooArgSet* channelsWithConstraints = new RooArgSet();
158 getChannelsFromModel( _pdf, channels, channelsWithConstraints );
159 */
160
161 // Loop over the channels
162 RooSimultaneous* simPdf = (RooSimultaneous*) _pdf;
163 RooCategory* channelCat = (RooCategory*) (&simPdf->indexCat());
164 for (const auto& nameIdx : *channelCat) {
165
166 // Warning: channel cat name is not necesarily the same name
167 // as the pdf's (for example, if someone does edits)
168 RooAbsPdf* channelPdf = simPdf->getPdf(nameIdx.first.c_str());
169 std::string channel_name = channelPdf->GetName();
170
171 // First, we check if this channel uses Stat Uncertainties:
172 RooArgList* gammas = new RooArgList();
173 ParamHistFunc* param_func=nullptr;
174 bool hasStatUncert = getStatUncertaintyFromChannel( channelPdf, param_func, gammas );
175 if( ! hasStatUncert ) {
176 if(verbose) {
177 std::cout << "Channel: " << channel_name
178 << " doesn't have statistical uncertainties"
179 << std::endl;
180 }
181 continue;
182 }
183 else {
184 if(verbose) std::cout << "Found ParamHistFunc: " << param_func->GetName() << std::endl;
185 }
186
187 // Now, loop over the bins in this channel
188 // To Do: Check that the index convention
189 // still works for 2-d (ie matches the
190 // convention in ParamHistFunc, etc)
191 int num_bins = param_func->numBins();
192
193 // Initialize the vector to the number of bins, allowing
194 // us to skip gamma's if they are constant
195
196 std::vector<BarlowCache> temp_cache( num_bins );
197 bool channel_has_stat_uncertainty=false;
198
199 for( Int_t bin_index = 0; bin_index < num_bins; ++bin_index ) {
200
201 // Create a cache object
202 BarlowCache cache;
203
204 // Get the gamma for this bin, and skip if it's constant
205 RooRealVar* gamma_stat = dynamic_cast<RooRealVar*>(&(param_func->getParameter(bin_index)));
206 if(!gamma_stat) throw std::runtime_error("ParamHistFunc contains non-RooRealVar, not supported in RooBarlowBeestonLL");
207 if( gamma_stat->isConstant() ) {
208 if(verbose) std::cout << "Ignoring constant gamma: " << gamma_stat->GetName() << std::endl;
209 continue;
210 }
211 else {
212 cache.hasStatUncert=true;
213 channel_has_stat_uncertainty=true;
214 cache.gamma = gamma_stat;
215 _statUncertParams.insert( gamma_stat->GetName() );
216 }
217
218 // Store a snapshot of the bin center
219 RooArgSet* bin_center = (RooArgSet*) param_func->get( bin_index )->snapshot();
220 cache.bin_center = bin_center;
221 cache.observables = obsSet;
222
223 cache.binVolume = param_func->binVolume();
224
225 // Delete this part, simply a comment
226 RooArgList obs_list( *(cache.bin_center) );
227
228 // Get the gamma's constraint term
229 RooAbsReal* pois_mean = nullptr;
230 RooRealVar* tau = nullptr;
231 getStatUncertaintyConstraintTerm( &constraints, gamma_stat, pois_mean, tau );
232 if( !tau || !pois_mean ) {
233 std::cout << "Failed to find pois mean or tau parameter for " << gamma_stat->GetName() << std::endl;
234 }
235 else {
236 if(verbose) std::cout << "Found pois mean and tau for parameter: " << gamma_stat->GetName()
237 << " tau: " << tau->GetName() << " " << tau->getVal()
238 << " pois_mean: " << pois_mean->GetName() << " " << pois_mean->getVal()
239 << std::endl;
240 }
241
242 cache.tau = tau;
243 cache.nom_pois_mean = pois_mean;
244
245 // Get the RooRealSumPdf
246 RooAbsPdf* sum_pdf = getSumPdfFromChannel( channelPdf );
247 if( sum_pdf == nullptr ) {
248 std::cout << "Failed to find RooRealSumPdf in channel " << channel_name
249 << ", therefor skipping this channel for analytic uncertainty minimization"
250 << std::endl;
251 channel_has_stat_uncertainty=false;
252 break;
253 }
254 cache.sumPdf = sum_pdf;
255
256 // And set the data value for this bin
257 if( ChannelBinDataMap.find(channel_name) == ChannelBinDataMap.end() ) {
258 std::cout << "Error: channel with name: " << channel_name
259 << " not found in BinDataMap" << std::endl;
260 throw runtime_error("BinDataMap");
261 }
262 double nData = ChannelBinDataMap[channel_name].at(bin_index);
263 cache.nData = nData;
264
265 temp_cache.at(bin_index) = cache;
266 //_barlowCache[channel_name].at(bin_index) = cache;
267
268 } // End: Loop over bins
269
270 if( channel_has_stat_uncertainty ) {
271 std::cout << "Adding channel: " << channel_name
272 << " to the barlow cache" << std::endl;
273 _barlowCache[channel_name] = temp_cache;
274 }
275
276
277 } // End: Loop over channels
278
279
280
281 // Successfully initialized the cache
282 // Printing some info
283 /*
284 std::map< std::string, std::vector< BarlowCache > >::iterator iter_cache;
285 for( iter_cache = _barlowCache.begin(); iter_cache != _barlowCache.end(); ++iter_cache ) {
286
287 std::string channel_name = (*iter_cache).first;
288 std::vector< BarlowCache >& channel_cache = (*iter_cache).second;
289
290
291 for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
292 BarlowCache& bin_cache = channel_cache.at(i);
293
294
295 RooRealVar* gamma = bin_cache.gamma;
296 RooRealVar* tau = bin_cache.tau;
297 RooAbsReal* pois_mean = bin_cache.nom_pois_mean;
298 RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
299 double binVolume = bin_cache.binVolume;
300
301
302 if( !bin_cache.hasStatUncert ) {
303 std::cout << "Barlow Cache for Channel: " << channel_name
304 << " Bin: " << i
305 << " NO STAT UNCERT"
306 << std::endl;
307 }
308 else {
309 std::cout << "Barlow Cache for Channel: " << channel_name
310 << " Bin: " << i
311 << " gamma: " << gamma->GetName()
312 << " tau: " << tau->GetName()
313 << " pois_mean: " << pois_mean->GetName()
314 << " sum_pdf: " << sum_pdf->GetName()
315 << " binVolume: " << binVolume
316 << std::endl;
317 }
318
319 }
320 }
321 */
322
323}
324
325
326////////////////////////////////////////////////////////////////////////////////
327
329 RooArgSet& outputSet,
330 bool stripDisconnected) const {
331 bool errorInBaseCall = RooAbsArg::getParameters( depList, outputSet, stripDisconnected );
332
333 RooArgSet toRemove;
334 toRemove.reserve( _statUncertParams.size());
335
336 for (auto const& arg : outputSet) {
337
338 // If there is a gamma in the name,
339 // strip it from the list of dependencies
340
341 if( _statUncertParams.find(arg->GetName()) != _statUncertParams.end() ) {
342 toRemove.add( *arg );
343 }
344 }
345
346 for( auto& arg : toRemove) outputSet.remove( *arg, true );
347
348 return errorInBaseCall || false;
349
350}
351
352
353/*
354////////////////////////////////////////////////////////////////////////////////
355
356const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitParams() const
357{
358 validateAbsMin() ;
359 return _paramAbsMin ;
360}
361
362
363////////////////////////////////////////////////////////////////////////////////
364
365const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitObs() const
366{
367 validateAbsMin() ;
368 return _obsAbsMin ;
369}
370*/
371
372
373
374////////////////////////////////////////////////////////////////////////////////
375/// Optimized implementation of createProfile for profile likelihoods.
376/// Return profile of original function in terms of stated parameters
377/// of interest rather than profiling recursively.
378
379/*
380RooAbsReal* RooStats::HistFactory::RooBarlowBeestonLL::createProfile(const RooArgSet& paramsOfInterest)
381{
382 return nll().createProfile(paramsOfInterest) ;
383}
384*/
385
386
387/*
388void RooStats::HistFactory::RooBarlowBeestonLL::FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) const {
389 // utility function to factorize constraint terms from a pdf
390 // (from G. Petrucciani)
391 const std::type_info & id = typeid(pdf);
392 if (id == typeid(RooProdPdf)) {
393 RooProdPdf *prod = dynamic_cast<RooProdPdf *>(&pdf);
394 RooArgList list(prod->pdfList());
395 for (int i = 0, n = list.getSize(); i < n; ++i) {
396 RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
397 FactorizePdf(observables, *pdfi, obsTerms, constraints);
398 }
399 } else if (id == typeid(RooSimultaneous) ) { //|| id == typeid(RooSimultaneousOpt)) {
400 RooSimultaneous *sim = dynamic_cast<RooSimultaneous *>(&pdf);
401 RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
402 for (int ic = 0, nc = cat->numBins((const char *)0); ic < nc; ++ic) {
403 cat->setBin(ic);
404 FactorizePdf(observables, *sim->getPdf(cat->getLabel()), obsTerms, constraints);
405 }
406 delete cat;
407 } else if (pdf.dependsOn(observables)) {
408 if (!obsTerms.contains(pdf)) obsTerms.add(pdf);
409 } else {
410 if (!constraints.contains(pdf)) constraints.add(pdf);
411 }
412}
413*/
414
415
416
417////////////////////////////////////////////////////////////////////////////////
418
420{
421 // Loop over the channels (keys to the map)
422 //clock_t time_before_setVal, time_after_setVal;
423 //time_before_setVal=clock();
424 std::map< std::string, std::vector< BarlowCache > >::iterator iter_cache;
425 for( iter_cache = _barlowCache.begin(); iter_cache != _barlowCache.end(); ++iter_cache ) {
426
427 std::string channel_name = (*iter_cache).first;
428 std::vector< BarlowCache >& channel_cache = (*iter_cache).second;
429
430 /* Slower way to find the channel vector:
431 // Get the vector of bin uncertainty caches for this channel
432 if( _barlowCache.find( channel_name ) == _barlowCache.end() ) {
433 std::cout << "Error: channel: " << channel_name
434 << " not found in barlow Cache" << std::endl;
435 throw runtime_error("Channel not in barlow cache");
436 }
437
438 std::vector< BarlowCache >& channel_cache = _barlowCache[ channel_name ];
439 */
440
441 // Loop over the bins in the cache
442 // Set all gamma's to 0
443 for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
444 BarlowCache& bin_cache = channel_cache.at(i);
445 if( !bin_cache.hasStatUncert ) continue;
446 RooRealVar* gamma = bin_cache.gamma;
447 gamma->setVal(0.0);
448 }
449 std::vector< double > nu_b_vec( channel_cache.size() );
450 for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
451 BarlowCache& bin_cache = channel_cache.at(i);
452 if( !bin_cache.hasStatUncert ) continue;
453
454 RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
455 RooArgSet* obsSet = bin_cache.observables;
456 double binVolume = bin_cache.binVolume;
457
458 bin_cache.SetBinCenter();
459 double nu_b = sum_pdf->getVal(*obsSet)*sum_pdf->expectedEvents(*obsSet)*binVolume;
460 nu_b_vec.at(i) = nu_b;
461 }
462
463 // Loop over the bins in the cache
464 // Set all gamma's to 1
465 for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
466 BarlowCache& bin_cache = channel_cache.at(i);
467 if( !bin_cache.hasStatUncert ) continue;
468 RooRealVar* gamma = bin_cache.gamma;
469 gamma->setVal(1.0);
470 }
471 std::vector< double > nu_b_stat_vec( channel_cache.size() );
472 for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
473 BarlowCache& bin_cache = channel_cache.at(i);
474 if( !bin_cache.hasStatUncert ) continue;
475
476 RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
477 RooArgSet* obsSet = bin_cache.observables;
478 double binVolume = bin_cache.binVolume;
479
480 bin_cache.SetBinCenter();
481 double nu_b_stat = sum_pdf->getVal(*obsSet)*sum_pdf->expectedEvents(*obsSet)*binVolume - nu_b_vec.at(i);
482 nu_b_stat_vec.at(i) = nu_b_stat;
483 }
484 //time_after_setVal=clock();
485
486 // Done with the first loops.
487 // Now evaluating the function
488
489 //clock_t time_before_eval, time_after_eval;
490
491 // Loop over the bins in the cache
492 //time_before_eval=clock();
493 for( unsigned int i = 0; i < channel_cache.size(); ++i ) {
494
495 BarlowCache& bin_cache = channel_cache.at(i);
496
497 if( !bin_cache.hasStatUncert ) {
498 //std::cout << "Bin: " << i << " of " << channel_cache.size()
499 // << " in channel: " << channel_name
500 // << " doesn't have stat uncertainties" << std::endl;
501 continue;
502 }
503
504 // Set the observable to the bin center
505 bin_cache.SetBinCenter();
506
507 // Get the cached objects
508 RooRealVar* gamma = bin_cache.gamma;
509 RooRealVar* tau = bin_cache.tau;
510 RooAbsReal* pois_mean = bin_cache.nom_pois_mean;
511 //RooAbsPdf* sum_pdf = (RooAbsPdf*) bin_cache.sumPdf;
512 //RooArgSet* obsSet = bin_cache.observables;
513 //double binVolume = bin_cache.binVolume;
514
515 // Get the values necessary for
516 // the analytic minimization
517 double nu_b = nu_b_vec.at(i);
518 double nu_b_stat = nu_b_stat_vec.at(i);
519
520 double tau_val = tau->getVal();
521 double nData = bin_cache.nData;
522 double m_val = pois_mean->getVal();
523
524 // Initialize the minimized value of gamma
525 double gamma_hat_hat = 1.0;
526
527 // Check that the quadratic term is > 0
528 if(nu_b_stat > 0.00000001) {
529
530 double A = nu_b_stat*nu_b_stat + tau_val*nu_b_stat;
531 double B = nu_b*tau_val + nu_b*nu_b_stat - nData*nu_b_stat - m_val*nu_b_stat;
532 double C = -1*m_val*nu_b;
533
534 double discrim = B*B-4*A*C;
535
536 if( discrim < 0 ) {
537 std::cout << "Warning: Discriminant (B*B - 4AC) < 0" << std::endl;
538 std::cout << "Warning: Taking B*B - 4*A*C == 0" << std::endl;
539 discrim=0;
540 //throw runtime_error("BarlowBeestonLL::evaluate() : B*B - 4AC < 0");
541 }
542 if( A <= 0 ) {
543 std::cout << "Warning: A <= 0" << std::endl;
544 throw runtime_error("BarlowBeestonLL::evaluate() : A < 0");
545 }
546
547 gamma_hat_hat = ( -1*B + TMath::Sqrt(discrim) ) / (2*A);
548 }
549
550 // If the quadratic term is 0, we simply
551 // use a linear equation
552 else {
553 gamma_hat_hat = m_val/tau_val;
554 }
555
556 // Check for NAN
557 if( TMath::IsNaN(gamma_hat_hat) ) {
558 std::cout << "ERROR: gamma hat hat is NAN" << std::endl;
559 throw runtime_error("BarlowBeestonLL::evaluate() : gamma hat hat is NAN");
560 }
561
562 if( gamma_hat_hat <= 0 ) {
563 std::cout << "WARNING: gamma hat hat <= 0. Setting to 0" << std::endl;
564 gamma_hat_hat = 0;
565 }
566
567 /*
568 std::cout << "n: " << bin_cache.nData << " "
569 << "nu_stat: " << nu_b_stat << " "
570 << "nu: " << nu_b << " "
571 << "tau: " << tau->getVal() << " "
572 << "m: " << pois_mean->getVal() << " "
573 << "A: " << A << " "
574 << "B: " << B << " "
575 << "C: " << C << " "
576 << "gamma hat hat: " << gamma_hat_hat
577 << std::endl;
578 */
579
580 gamma->setVal( gamma_hat_hat );
581
582 }
583
584 //time_after_eval=clock();
585
586 //float time_setVal = ((float) time_after_setVal - (float) time_before_setVal) / ((float) CLOCKS_PER_SEC);
587 //float time_eval = ((float) time_after_eval - (float) time_before_eval) / ((float) CLOCKS_PER_SEC);
588
589 /*
590 std::cout << "Barlow timing for channel: " << channel_name
591 << " SetVal: " << time_setVal
592 << " Eval: " << time_eval
593 << std::endl;
594 */
595 }
596
597
598 return _nll;
599
600}
601
602
603
604/*
605////////////////////////////////////////////////////////////////////////////////
606/// Check that parameters and likelihood value for 'best fit' are still valid. If not,
607/// because the best fit has never been calculated, or because constant parameters have
608/// changed value or parameters have changed const/float status, the minimum is recalculated
609
610void RooStats::HistFactory::RooBarlowBeestonLL::validateAbsMin() const
611{
612 // Check if constant status of any of the parameters have changed
613 if (_absMinValid) {
614 _piter->Reset() ;
615 RooAbsArg* par ;
616 while((par=(RooAbsArg*)_piter->Next())) {
617 if (_paramFixed[par->GetName()] != par->isConstant()) {
618 cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") constant status of parameter " << par->GetName() << " has changed from "
619 << (_paramFixed[par->GetName()]?"fixed":"floating") << " to " << (par->isConstant()?"fixed":"floating")
620 << ", recalculating absolute minimum" << endl ;
621 _absMinValid = false ;
622 break ;
623 }
624 }
625 }
626
627
628 // If we don't have the absolute minimum w.r.t all observables, calculate that first
629 if (!_absMinValid) {
630
631 cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") determining minimum likelihood for current configurations w.r.t all observable" << endl ;
632
633
634 // Save current values of non-marginalized parameters
635 RooArgSet* obsStart = (RooArgSet*) _obs.snapshot(false) ;
636
637 // Start from previous global minimum
638 if (_paramAbsMin.getSize()>0) {
639 const_cast<RooSetProxy&>(_par).assignValueOnly(_paramAbsMin) ;
640 }
641 if (_obsAbsMin.getSize()>0) {
642 const_cast<RooSetProxy&>(_obs).assignValueOnly(_obsAbsMin) ;
643 }
644
645 // Find minimum with all observables floating
646 const_cast<RooSetProxy&>(_obs).setAttribAll("Constant",false) ;
647 _minuit->migrad() ;
648
649 // Save value and remember
650 _absMin = _nll ;
651 _absMinValid = true ;
652
653 // Save parameter values at abs minimum as well
654 _paramAbsMin.removeAll() ;
655
656 // Only store non-constant parameters here!
657 RooArgSet* tmp = (RooArgSet*) _par.selectByAttrib("Constant",false) ;
658 _paramAbsMin.addClone(*tmp) ;
659 delete tmp ;
660
661 _obsAbsMin.addClone(_obs) ;
662
663 // Save constant status of all parameters
664 _piter->Reset() ;
665 RooAbsArg* par ;
666 while((par=(RooAbsArg*)_piter->Next())) {
667 _paramFixed[par->GetName()] = par->isConstant() ;
668 }
669
670 if (dologI(Minimization)) {
671 cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") minimum found at (" ;
672
673 RooAbsReal* arg ;
674 bool first=true ;
675 _oiter->Reset() ;
676 while ((arg=(RooAbsReal*)_oiter->Next())) {
677 ccxcoutI(Minimization) << (first?"":", ") << arg->GetName() << "=" << arg->getVal() ;
678 first=false ;
679 }
680 ccxcoutI(Minimization) << ")" << endl ;
681 }
682
683 // Restore original parameter values
684 const_cast<RooSetProxy&>(_obs) = *obsStart ;
685 delete obsStart ;
686
687 }
688}
689*/
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
char name[80]
Definition TGX11.cxx:110
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
const RooArgSet * get(Int_t masterIdx) const
Int_t numBins() const
RooAbsReal & getParameter() const
double binVolume() const
bool isConstant() const
Check if the "Constant" attribute is set.
Definition RooAbsArg.h:359
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void reserve(Storage_t::size_type count)
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:62
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:91
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition RooArgSet.h:178
RooCategory is an object to represent discrete states.
Definition RooCategory.h:28
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:40
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
Class RooBarlowBeestonLL implements the profile likelihood estimator for a given likelihood and set o...
double evaluate() const override
Optimized implementation of createProfile for profile likelihoods.
bool getParameters(const RooArgSet *depList, RooArgSet &outputSet, bool stripDisconnected=true) const override
Fills a list with leaf nodes in the arg tree starting with ourself as top node that don't match any o...
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
bool getStatUncertaintyFromChannel(RooAbsPdf *channel, ParamHistFunc *&paramfunc, RooArgList *gammaList)
void FactorizeHistFactoryPdf(const RooArgSet &, RooAbsPdf &, RooArgList &, RooArgList &)
void getDataValuesForObservables(std::map< std::string, std::vector< double > > &ChannelBinDataMap, RooAbsData *data, RooAbsPdf *simPdf)
RooAbsPdf * getSumPdfFromChannel(RooAbsPdf *channel)
int getStatUncertaintyConstraintTerm(RooArgList *constraints, RooRealVar *gamma_stat, RooAbsReal *&pois_mean, RooRealVar *&tau)
Bool_t IsNaN(Double_t x)
Definition TMath.h:890
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:660