Skip to content

Commit 1d41195

Browse files
committed
[RF] Fix Windows compiler warnings about mixing int and bool
Update the code to avoid the following compiler warnings: ``` C:\ROOT-CI\src\roofit\roofit\test\testFitPerf.cxx(571,26): warning C4805: '|=': unsafe mix of type 'int' and type 'bool' in operation [C:\ROOT-CI\build\roofit\roofit\test\testFitPerf.vcxproj] C:\ROOT-CI\src\roofit\roofit\test\testFitPerf.cxx(656,23): warning C4805: '|=': unsafe mix of type 'int' and type 'bool' in operation [C:\ROOT-CI\build\roofit\roofit\test\testFitPerf.vcxproj] C:\ROOT-CI\src\roofit\roofit\test\testRooFit.cxx(212,23): warning C4805: '|=': unsafe mix of type 'int' and type 'bool' in operation [C:\ROOT-CI\build\roofit\roofit\test\testRooFitExe.vcxproj] ```
1 parent 11897d0 commit 1d41195

2 files changed

Lines changed: 12 additions & 25 deletions

File tree

roofit/roofit/test/testFitPerf.cxx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,6 @@ int FitUsingRooFit(TH1 *hist, TF1 *func)
518518
// unbinned roo fit
519519
int FitUsingRooFit(TTree *tree, TF1 *func)
520520
{
521-
522-
int iret = 0;
523521
std::cout << "\n************************************************************\n";
524522
std::cout << "\tFit using RooFit (Likelihood Fit)\n";
525523
std::cout << "\twith function " << func->GetName() << "\n";
@@ -567,26 +565,21 @@ int FitUsingRooFit(TTree *tree, TF1 *func)
567565
std::cout << " Roofit status " << result->status() << std::endl;
568566
result->Print();
569567
#endif
570-
if (save)
571-
iret |= int(result == nullptr);
572-
573-
if (iret != 0) {
568+
if (save && result == nullptr) {
574569
std::cout << "Fit failed " << std::endl;
575-
return iret;
570+
return 1;
576571
}
577572
}
578573

579574
w.Stop();
580575
std::cout << "\nTime: \t" << w.RealTime() << " , " << w.CpuTime() << std::endl;
581576
std::cout << "\n************************************************************\n";
582-
return iret;
577+
return 0;
583578
}
584579

585580
// unbinned roo fit (large tree)
586581
int FitUsingRooFit2(TTree *tree)
587582
{
588-
589-
int iret = 0;
590583
std::cout << "\n************************************************************\n";
591584
std::cout << "\tFit using RooFit (Likelihood Fit)\n";
592585

@@ -647,23 +640,16 @@ int FitUsingRooFit2(TTree *tree)
647640
std::unique_ptr<RooFitResult> result{
648641
pdf[N - 1]->fitTo(data, RooFit::Minos(0), RooFit::Hesse(1), RooFit::PrintLevel(level), RooFit::Save(save))};
649642

650-
#ifdef DEBUG
651-
assert(result == nullptr);
652-
//std::cout << " Roofit status " << result->status() << std::endl;
653-
//result->Print();
654-
#endif
655-
656-
iret |= int(result != nullptr);
657-
658-
if (iret != 0)
659-
return iret;
660-
// assert(iret == 0);
643+
if (save && result == nullptr) {
644+
std::cout << "Fit failed " << std::endl;
645+
return 1;
646+
}
661647
}
662648

663649
w.Stop();
664650
std::cout << "\nTime: \t" << w.RealTime() << " , " << w.CpuTime() << std::endl;
665651
std::cout << "\n************************************************************\n";
666-
return iret;
652+
return 0;
667653
}
668654

669655
double poly2(const double *x, const double *p)

roofit/roofit/test/testRooFit.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ int FitUsingRooFit(TTree &tree, RooAbsPdf &pdf, RooArgSet &xvars)
209209
std::cout << " Roofit status " << result->status() << std::endl;
210210
result->Print();
211211
#endif
212-
iret |= int(result == nullptr);
212+
if (save && result == nullptr)
213+
iret = 1;
213214
}
214215

215216
w.Stop();
@@ -265,15 +266,15 @@ int FitUsingNewFitter(FitObj *fitobj, Func &func, bool useGrad = false)
265266
std::cout << "\tFit using new Fit::Fitter\n";
266267
std::cout << "\tMinimizer is " << MinType::name() << " " << MinType::name2() << std::endl;
267268

268-
int iret = 0;
269269
TStopwatch w;
270270
w.Start();
271271

272272
#ifdef DEBUG
273273
func.SetParameters(iniPar);
274-
iret |= DoFit<MinType>(fitobj, func, true, useGrad);
274+
int iret = DoFit<MinType>(fitobj, func, true, useGrad);
275275

276276
#else
277+
int iret = 0;
277278
for (int i = 0; i < nfit; ++i) {
278279
func.SetParameters(iniPar);
279280
iret = DoFit<MinType>(fitobj, func, false, useGrad);

0 commit comments

Comments
 (0)