Skip to content

Commit d31ba4e

Browse files
committed
[RF] Replace some usage of Form with standard C++
1 parent 799063f commit d31ba4e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

roofit/roofitcore/src/RooMinimizer.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,9 @@ RooFit::OwningPtr<RooFitResult> RooMinimizer::save(const char *userName, const c
536536
return nullptr;
537537
}
538538

539-
TString name = userName ? userName : Form("%s", _fcn->getFunctionName().c_str());
540-
TString title = userTitle ? userTitle : Form("%s", _fcn->getFunctionTitle().c_str());
541-
auto fitRes = std::make_unique<RooFitResult>(name, title);
539+
std::string name = userName ? std::string{userName} : _fcn->getFunctionName();
540+
std::string title = userTitle ? std::string{userTitle} : _fcn->getFunctionTitle();
541+
auto fitRes = std::make_unique<RooFitResult>(name.c_str(), title.c_str());
542542

543543
fitRes->setConstParList(_fcn->constParams());
544544

@@ -682,7 +682,9 @@ RooPlot *RooMinimizer::contour(RooRealVar &var1, RooRealVar &var2, double n1, do
682682
ycoor[npoints] = ycoor[0];
683683
TGraph *graph = new TGraph(npoints + 1, xcoor.data(), ycoor.data());
684684

685-
graph->SetName(Form("contour_%s_n%f", _fcn->getFunctionName().c_str(), n[ic]));
685+
std::stringstream name;
686+
name << "contour_" << _fcn->getFunctionName() << "_n" << n[ic];
687+
graph->SetName(name.str().c_str());
686688
graph->SetLineStyle(ic + 1);
687689
graph->SetLineWidth(2);
688690
graph->SetLineColor(kBlue);

roofit/roofitcore/test/testRooDataSet.cxx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,15 @@ TEST(RooDataSet, ReducingData)
169169

170170
for (int i = 0; i < 3; ++i) {
171171
// Check with root:
172-
TH1F test_hist(Form("h%i", i), "histo", 10, massmin, massmax);
172+
TH1F test_hist(("h" + std::to_string(i)).c_str(), "histo", 10, massmin, massmax);
173173
chi2cutval += 0.5;
174174

175-
TCut chi2_test_cut = Form("max(track0_chi2,track1_chi2)<%f", chi2cutval);
175+
std::stringstream cutString;
176+
cutString << "max(track0_chi2,track1_chi2)<" << chi2cutval;
177+
TCut chi2_test_cut = cutString.str().c_str();
176178

177-
Long64_t drawnEvents = mytree.Draw(Form("mass>>h%i", i), chi2_test_cut /*&& mass_cut*/);
179+
std::string drawString = std::string{"mass>>"} + test_hist.GetName();
180+
Long64_t drawnEvents = mytree.Draw(drawString.c_str(), chi2_test_cut /*&& mass_cut*/);
178181
ASSERT_NE(drawnEvents, 0l);
179182
ASSERT_EQ(test_hist.Integral(), drawnEvents);
180183

0 commit comments

Comments
 (0)