Skip to content

Commit da8895c

Browse files
committed
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
1 parent 4f84681 commit da8895c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

TEPEMGEN/TGenEpEmv1.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ TGenEpEmv1::~TGenEpEmv1()
109109
}
110110

111111
//____________________________________________________________
112-
void TGenEpEmv1::Init()
112+
bool TGenEpEmv1::Init()
113113
{
114114
// Initialisation:
115115
// 1) define a generator
@@ -124,9 +124,10 @@ void TGenEpEmv1::Init()
124124
double err = 0;
125125
fXSection = CalcXSection(fXSectionEps,fMinXSTest,fMaxXSTest,err);
126126
if (fXSection<=0 || err/fXSection>fXSectionEps) {
127-
abort();
127+
return false;
128128
}
129129
fXSectionEps = err/fXSection;
130+
return true;
130131
}
131132

132133
//____________________________________________________________

TEPEMGEN/TGenEpEmv1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class TGenEpEmv1 : public TEpEmGen {
2121

2222
public:
2323
TGenEpEmv1();
24-
virtual ~TGenEpEmv1();
24+
~TGenEpEmv1() override;
2525

26-
virtual void GenerateEvent();
27-
virtual void Init();
26+
void GenerateEvent() override; // interface of TGenerator
27+
bool Init(); // init function; returns true if successful; false otherwise
2828
void SetDebug(Int_t debug) {fDebug=debug;}
2929
void SetYRange(Double_t min, Double_t max) {fYMin = min; fYMax = max;};
3030
void SetPtRange(Double_t min, Double_t max) {fPtMin = min; fPtMax = max;};

0 commit comments

Comments
 (0)