Skip to content
Snippets Groups Projects
  • Jonas Rembser's avatar
    1d919775
    [RF] Fix copy-paste error in RooAddModel constructor and modernization · 1d919775
    Jonas Rembser authored
    * replace wrong `dynamic_cast<RooAbsReal*>` with
      `dynamic_cast<RooAbsPdf*>` (presumably a copy-paste error)
    
    * use `TIter` and range-based loop instead of `TIterator*`
    
    * avoid C-style casts
    
    * replace `assert(0)` with `std::runtime_error`, as asserts only work in
      debug buils
    
    * replace one orrurence of `coef->GetName()` with `pdf->GetName()`,
      which was probably also a copy-paste error
    
    This fixes the following warning in gcc11:
    
    ```
    ../roofit/roofitcore/src/RooAddModel.cxx: In constructor ‘RooAddModel::RooAddModel(const char*, const char*, const RooArgList&, const RooArgList&, Bool_t)’:
    ../roofit/roofitcore/src/RooAddModel.cxx:125:106: warning: ‘this’ pointer is null [-Wnonnull]
      125 |       coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() << ") pdf " << pdf->GetName() << " is not of type RooAbsPdf, ignored" << endl ;
    ```
    1d919775
    History
    [RF] Fix copy-paste error in RooAddModel constructor and modernization
    Jonas Rembser authored
    * replace wrong `dynamic_cast<RooAbsReal*>` with
      `dynamic_cast<RooAbsPdf*>` (presumably a copy-paste error)
    
    * use `TIter` and range-based loop instead of `TIterator*`
    
    * avoid C-style casts
    
    * replace `assert(0)` with `std::runtime_error`, as asserts only work in
      debug buils
    
    * replace one orrurence of `coef->GetName()` with `pdf->GetName()`,
      which was probably also a copy-paste error
    
    This fixes the following warning in gcc11:
    
    ```
    ../roofit/roofitcore/src/RooAddModel.cxx: In constructor ‘RooAddModel::RooAddModel(const char*, const char*, const RooArgList&, const RooArgList&, Bool_t)’:
    ../roofit/roofitcore/src/RooAddModel.cxx:125:106: warning: ‘this’ pointer is null [-Wnonnull]
      125 |       coutE(InputArguments) << "RooAddModel::RooAddModel(" << GetName() << ") pdf " << pdf->GetName() << " is not of type RooAbsPdf, ignored" << endl ;
    ```
RooAddModel.cxx 30.89 KiB