@@ -92,10 +92,10 @@ RooFitResult::RooFitResult(const RooFitResult &other)
9292
9393 other._finalPars ->snapshot (*_finalPars);
9494 if (other._randomPars ) {
95- _randomPars = new RooArgList;
95+ _randomPars = std::make_unique< RooArgList>() ;
9696 other._randomPars ->snapshot (*_randomPars);
9797 }
98- if (other._Lt ) _Lt = new TMatrix (*other._Lt );
98+ if (other._Lt ) _Lt = std::make_unique< TMatrix> (*other._Lt );
9999 if (other._VM ) _VM = new TMatrixDSym (*other._VM ) ;
100100 if (other._CM ) _CM = new TMatrixDSym (*other._CM ) ;
101101 if (other._GC ) _GC = new TVectorD (*other._GC ) ;
@@ -114,9 +114,6 @@ RooFitResult::~RooFitResult()
114114 if (_constPars) delete _constPars ;
115115 if (_initPars) delete _initPars ;
116116 if (_finalPars) delete _finalPars ;
117- if (_globalCorr) delete _globalCorr;
118- if (_randomPars) delete _randomPars;
119- if (_Lt) delete _Lt;
120117 if (_CM) delete _CM ;
121118 if (_VM) delete _VM ;
122119 if (_GC) delete _GC ;
@@ -334,10 +331,10 @@ RooPlot *RooFitResult::plotOn(RooPlot *frame, const char *parName1, const char *
334331const RooArgList& RooFitResult::randomizePars () const
335332{
336333 Int_t nPar= _finalPars->size ();
337- if (nullptr == _randomPars) { // first-time initialization
334+ if (! _randomPars) { // first-time initialization
338335 assert (nullptr != _finalPars);
339336 // create the list of random values to fill
340- _randomPars = new RooArgList;
337+ _randomPars = std::make_unique< RooArgList>() ;
341338 _finalPars->snapshot (*_randomPars);
342339 // calculate the elements of the upper-triangular matrix L that gives Lt*L = C
343340 // where Lt is the transpose of L (the "square-root method")
@@ -360,7 +357,7 @@ const RooArgList& RooFitResult::randomizePars() const
360357 }
361358 }
362359 // remember Lt
363- _Lt= new TMatrix (TMatrix::kTransposed ,L);
360+ _Lt= std::make_unique< TMatrix> (TMatrix::kTransposed ,L);
364361 }
365362 else {
366363 // reset to the final fit values
@@ -455,7 +452,7 @@ const RooArgList* RooFitResult::globalCorr()
455452 fillLegacyCorrMatrix () ;
456453 }
457454
458- return _globalCorr ;
455+ return _globalCorr. get () ;
459456}
460457
461458
@@ -622,39 +619,28 @@ void RooFitResult::fillLegacyCorrMatrix() const
622619 if (!_CM) return ;
623620
624621 // Delete eventual previous correlation data holders
625- if (_globalCorr) delete _globalCorr ;
626622 _corrMatrix.Delete ();
627623
628624 // Build holding arrays for correlation coefficients
629- _globalCorr = new RooArgList (" globalCorrelations" ) ;
625+ _globalCorr = std::make_unique< RooArgList> (" globalCorrelations" ) ;
630626
631627 for (RooAbsArg* arg : *_initPars) {
632628 // Create global correlation value holder
633- TString gcName (" GC[" ) ;
634- gcName.Append (arg->GetName ()) ;
635- gcName.Append (" ]" ) ;
636- TString gcTitle (arg->GetTitle ()) ;
637- gcTitle.Append (" Global Correlation" ) ;
638- _globalCorr->addOwned (std::make_unique<RooRealVar>(gcName.Data (),gcTitle.Data (),0 .));
629+ std::string argName = arg->GetName ();
630+ std::string argTitle = arg->GetTitle ();
631+ std::string gcName = " GC[" + argName + " ]" ;
632+ std::string gcTitle = argTitle + " Global Correlation" ;
633+ _globalCorr->addOwned (std::make_unique<RooRealVar>(gcName.c_str (),gcTitle.c_str (),0 .));
639634
640635 // Create array with correlation holders for this parameter
641- TString name (" C[" ) ;
642- name.Append (arg->GetName ()) ;
643- name.Append (" ,*]" ) ;
644- RooArgList* corrMatrixRow = new RooArgList (name.Data ()) ;
636+ RooArgList* corrMatrixRow = new RooArgList ((" C[" + argName + " ,*]" ).c_str ()) ;
645637 _corrMatrix.Add (corrMatrixRow) ;
646638 for (RooAbsArg* arg2 : *_initPars) {
647639
648- TString cName (" C[" ) ;
649- cName.Append (arg->GetName ()) ;
650- cName.Append (" ," ) ;
651- cName.Append (arg2->GetName ()) ;
652- cName.Append (" ]" ) ;
653- TString cTitle (" Correlation between " ) ;
654- cTitle.Append (arg->GetName ()) ;
655- cTitle.Append (" and " ) ;
656- cTitle.Append (arg2->GetName ()) ;
657- corrMatrixRow->addOwned (std::make_unique<RooRealVar>(cName.Data (),cTitle.Data (),0 .));
640+ std::string arg2Name = arg2->GetName ();
641+ std::string cName = " C[" + argName + " ," + arg2Name + " ]" ;
642+ std::string cTitle = " Correlation between " + argName + " and " + arg2Name;
643+ corrMatrixRow->addOwned (std::make_unique<RooRealVar>(cName.c_str (),cTitle.c_str (),0 .));
658644 }
659645 }
660646
@@ -1315,7 +1301,9 @@ void RooFitResult::Streamer(TBuffer &R__b)
13151301 R__b >> _constPars;
13161302 R__b >> _initPars;
13171303 R__b >> _finalPars;
1318- R__b >> _globalCorr;
1304+ RooArgList* globalCorr;
1305+ R__b >> globalCorr;
1306+ _globalCorr.reset (globalCorr);
13191307 _corrMatrix.Streamer (R__b);
13201308 R__b.CheckByteCount (R__s, R__c, RooFitResult::IsA ());
13211309
0 commit comments