From 890a21d8d32039e0dcda733910099d9700b6e4ad Mon Sep 17 00:00:00 2001 From: Andrea Carlo Marini Date: Thu, 19 Sep 2024 11:06:13 +0200 Subject: [PATCH 1/4] silencing ZZ complains --- src/CachingNLL.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CachingNLL.cc b/src/CachingNLL.cc index 9623b998c9d..d7ce0411570 100644 --- a/src/CachingNLL.cc +++ b/src/CachingNLL.cc @@ -637,7 +637,11 @@ cacheutils::CachingAddNLL::evaluate() const sumCoeff += coeff; } // get vals + //std::cout<<"Silence is gold!"< &pdfvals = itp->eval(*data_); + freopen("/dev/tty", "w", stdout); + //std::cout<<"I am alive!"< 1) ? vectorized::dot_product(pdfvals.size(), &pdfvals[0], &binWidths_[0]) : From bed8a1791f622677516dcf4a20bc8b728afc1988 Mon Sep 17 00:00:00 2001 From: Andrea Carlo Marini Date: Fri, 20 Sep 2024 15:00:04 +0200 Subject: [PATCH 2/4] silencing ZZ complains on Asimov --- src/ToyMCSamplerOpt.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ToyMCSamplerOpt.cc b/src/ToyMCSamplerOpt.cc index 63e7e4499af..a411599f606 100644 --- a/src/ToyMCSamplerOpt.cc +++ b/src/ToyMCSamplerOpt.cc @@ -204,6 +204,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool RooCmdArg ay = (y ? RooFit::YVar(*y) : RooCmdArg::none()); RooCmdArg az = (z ? RooFit::ZVar(*z) : RooCmdArg::none()); + freopen("/dev/null", "w", stdout); // AMARINI if (histoSpec_ == 0) { histoSpec_ = pdf_->createHistogram("htemp", *x, ay, az); histoSpec_->SetDirectory(0); @@ -265,6 +266,7 @@ 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); return data; } From 80b49e45f9a7d52a435696bc9809a95aa86c93a2 Mon Sep 17 00:00:00 2001 From: Andrea Carlo Marini Date: Mon, 23 Sep 2024 17:12:43 +0200 Subject: [PATCH 3/4] trying to dup the file descriptors. this should work on condor and on local. --- src/CachingNLL.cc | 6 +++++- src/ToyMCSamplerOpt.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CachingNLL.cc b/src/CachingNLL.cc index d7ce0411570..04e91c4eca4 100644 --- a/src/CachingNLL.cc +++ b/src/CachingNLL.cc @@ -638,9 +638,13 @@ cacheutils::CachingAddNLL::evaluate() const } // get vals //std::cout<<"Silence is gold!"< &pdfvals = itp->eval(*data_); - freopen("/dev/tty", "w", stdout); + //freopen("/dev/tty", "w", stdout); + dup2(stdout_fd, STDOUT_FILENO); + stdout = fdopen(stdout_fd, "w"); + close(stdout_fd); //std::cout<<"I am alive!"< 1) ? diff --git a/src/ToyMCSamplerOpt.cc b/src/ToyMCSamplerOpt.cc index a411599f606..20a6db9a6f8 100644 --- a/src/ToyMCSamplerOpt.cc +++ b/src/ToyMCSamplerOpt.cc @@ -204,6 +204,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); freopen("/dev/null", "w", stdout); // AMARINI if (histoSpec_ == 0) { histoSpec_ = pdf_->createHistogram("htemp", *x, ay, az); @@ -266,7 +267,10 @@ 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); + //freopen("/dev/tty", "w", stdout); + dup2(stdout_fd, STDOUT_FILENO); + stdout = fdopen(stdout_fd, "w"); + close(stdout_fd); return data; } From 59914ef0f78421e28d092c7573120f1345301951 Mon Sep 17 00:00:00 2001 From: Andrea Carlo Marini Date: Wed, 25 Sep 2024 18:13:43 +0200 Subject: [PATCH 4/4] fixing freopen --- src/CachingNLL.cc | 11 +++++++---- src/ToyMCSamplerOpt.cc | 13 ++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/CachingNLL.cc b/src/CachingNLL.cc index 04e91c4eca4..ae00bc27e6a 100644 --- a/src/CachingNLL.cc +++ b/src/CachingNLL.cc @@ -611,6 +611,8 @@ cacheutils::CachingAddNLL::setIncludeZeroWeights(bool includeZeroWeights) } } +int orig2_stdout_fd = fileno(stdout); + Double_t cacheutils::CachingAddNLL::evaluate() const { @@ -638,12 +640,13 @@ cacheutils::CachingAddNLL::evaluate() const } // get vals //std::cout<<"Silence is gold!"< &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!"<createHistogram("htemp", *x, ay, az); @@ -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; }