Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silencing ZZ warnings #1007

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/CachingNLL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ cacheutils::CachingAddNLL::setIncludeZeroWeights(bool includeZeroWeights)
}
}

int orig2_stdout_fd = fileno(stdout);

Double_t
cacheutils::CachingAddNLL::evaluate() const
{
Expand Down Expand Up @@ -638,12 +640,13 @@ cacheutils::CachingAddNLL::evaluate() const
}
// get vals
//std::cout<<"Silence is gold!"<<std::endl;
int stdout_fd = dup(STDOUT_FILENO);
int stdout_fd = dup(fileno(stdout));
freopen("/dev/null", "w", stdout); // (bad) Fix RooFit warnings: [#0] WARNING:Eval -- Evaluating RooAddPdf without a defined normalization set.
const std::vector<Double_t> &pdfvals = itp->eval(*data_);
//freopen("/dev/tty", "w", stdout);
dup2(stdout_fd, STDOUT_FILENO);
stdout = fdopen(stdout_fd, "w");

close(fileno(stdout));
dup2(stdout_fd, orig2_stdout_fd);
stdout = fdopen(orig2_stdout_fd, "w");
close(stdout_fd);
//std::cout<<"I am alive!"<<std::endl;
if (basicIntegrals_) {
Expand Down
13 changes: 8 additions & 5 deletions src/ToyMCSamplerOpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ toymcoptutils::SinglePdfGenInfo::generatePseudoAsimov(RooRealVar *&weightVar, in
}
}

//global
int orig_stdout_fd = fileno(stdout);

RooDataSet *
toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool asimov, double weightScale, int verbose)
Expand All @@ -204,7 +206,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
RooCmdArg ay = (y ? RooFit::YVar(*y) : RooCmdArg::none());
RooCmdArg az = (z ? RooFit::ZVar(*z) : RooCmdArg::none());

int stdout_fd = dup(STDOUT_FILENO);
int stdout_fd = dup(fileno(stdout));
freopen("/dev/null", "w", stdout); // AMARINI
if (histoSpec_ == 0) {
histoSpec_ = pdf_->createHistogram("htemp", *x, ay, az);
Expand Down Expand Up @@ -267,10 +269,11 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
if (!keepHistoSpec_) { delete histoSpec_; histoSpec_ = 0; }
//std::cout << "Asimov dataset generated from " << pdf_->GetName() << " (sumw? " << data->sumEntries() << ", expected events " << expectedEvents << ")" << std::endl;
//utils::printRDH(data);
//freopen("/dev/tty", "w", stdout);
dup2(stdout_fd, STDOUT_FILENO);
stdout = fdopen(stdout_fd, "w");
close(stdout_fd);
//assert(orig_stdout_fd == fileno(stdout));
close(fileno(stdout));//de-associate dev/null from 1
dup2(stdout_fd, orig_stdout_fd);//re-associate stdout to 1
stdout = fdopen(orig_stdout_fd, "w");
close(stdout_fd); //de-associate the stdout_fd from stream
return data;
}

Expand Down
Loading