From da8895c202e0fb11113f2b18e15cb7ebe1cd598b Mon Sep 17 00:00:00 2001 From: swenzel Date: Tue, 6 Jun 2023 13:52:17 +0200 Subject: [PATCH] TGenEpEmv1: Return bool to indicate init success Currently TGenEpEmv1 fails when the initialization fails (sampling of X-section). This is sub-optimal since such abort will bring down complete MC jobs the GRID. This commit allows the caller to react to such error condition. The caller may decide what to do (give it another go or to exit). Relates to https://alice.its.cern.ch/jira/browse/O2-3825 --- TEPEMGEN/TGenEpEmv1.cxx | 5 +++-- TEPEMGEN/TGenEpEmv1.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TEPEMGEN/TGenEpEmv1.cxx b/TEPEMGEN/TGenEpEmv1.cxx index 3cc3e49..4041d54 100644 --- a/TEPEMGEN/TGenEpEmv1.cxx +++ b/TEPEMGEN/TGenEpEmv1.cxx @@ -109,7 +109,7 @@ TGenEpEmv1::~TGenEpEmv1() } //____________________________________________________________ -void TGenEpEmv1::Init() +bool TGenEpEmv1::Init() { // Initialisation: // 1) define a generator @@ -124,9 +124,10 @@ void TGenEpEmv1::Init() double err = 0; fXSection = CalcXSection(fXSectionEps,fMinXSTest,fMaxXSTest,err); if (fXSection<=0 || err/fXSection>fXSectionEps) { - abort(); + return false; } fXSectionEps = err/fXSection; + return true; } //____________________________________________________________ diff --git a/TEPEMGEN/TGenEpEmv1.h b/TEPEMGEN/TGenEpEmv1.h index 3a4df9e..7e4ce51 100644 --- a/TEPEMGEN/TGenEpEmv1.h +++ b/TEPEMGEN/TGenEpEmv1.h @@ -21,10 +21,10 @@ class TGenEpEmv1 : public TEpEmGen { public: TGenEpEmv1(); - virtual ~TGenEpEmv1(); + ~TGenEpEmv1() override; - virtual void GenerateEvent(); - virtual void Init(); + void GenerateEvent() override; // interface of TGenerator + bool Init(); // init function; returns true if successful; false otherwise void SetDebug(Int_t debug) {fDebug=debug;} void SetYRange(Double_t min, Double_t max) {fYMin = min; fYMax = max;}; void SetPtRange(Double_t min, Double_t max) {fPtMin = min; fPtMax = max;};