Commit 9120668a authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'hepmc3_20.10.21_QGSJET' into 'master'

Fix the crashes in QGSJET

See merge request atlas/athena!47420
parents 56bea546 6cd330c9
......@@ -53,6 +53,32 @@ extern "C"
// cross section info
void crmc_xsection_f_(double &xsigtot, double &xsigine, double &xsigela, double &xsigdd,
double &xsigsd, double &xsloela, double &xsigtotaa, double &xsigineaa, double &xsigelaaa);
#ifdef HEPMC3
extern struct eposhepevt
{
int nevhep;
int nhep;
int isthep[HEPEVT_EntriesAllocation];
int idhep [HEPEVT_EntriesAllocation];
int jmohep[HEPEVT_EntriesAllocation][2];
int jdahep[HEPEVT_EntriesAllocation][2];
double phep [HEPEVT_EntriesAllocation][5];
double vhep [HEPEVT_EntriesAllocation][4];
} hepevt_;
struct hepmc3hepevt
{
int nevhep;
int nhep;
int isthep[10000];
int idhep [10000];
int jmohep[10000][2];
int jdahep[10000][2];
double phep [10000][5];
double vhep [10000][4];
} localhepevt_;
#endif
}
extern "C"
{
......@@ -231,8 +257,8 @@ StatusCode QGSJet::genInitialize()
// setup HepMC
#ifdef HEPMC3
/* This ifdef is used for consistency */
/* HepMC3 Does not need a setup here */
/// Inlined
HepMC::HEPEVT_Wrapper::set_hepevt_address((char*)(&localhepevt_));
#else
HepMC::HEPEVT_Wrapper::set_sizeof_int(sizeof( int ));
HepMC::HEPEVT_Wrapper::set_sizeof_real( 8 );
......@@ -312,6 +338,30 @@ StatusCode QGSJet::fillEvt( HepMC::GenEvent* evt )
HepMC::HEPEVT_Wrapper::set_event_number(m_events);
#ifdef HEPMC3
///If HepMC3 has been compiled with different block size than is used in the interface,
/// only the inlined functions can be used without restrictions.
/// The convert functions are compiled and should operate on the block of matching size.
/// The best solution would be to define a single block sze for all Athena.
localhepevt_.nevhep = m_events;
localhepevt_.nhep = std::min(10000, hepevt_.nhep);
for (int i = 0; i < localhepevt_.nhep; i++ ) {
localhepevt_.isthep[i] = hepevt_.isthep[i];
localhepevt_.idhep [i] = hepevt_.idhep [i];
for (int k = 0; k < 2; k++) localhepevt_.jmohep[i][k] = hepevt_.jmohep[i][k];
for (int k = 0; k < 2; k++) localhepevt_.jdahep[i][k] = hepevt_.jdahep[i][k];
for (int k = 0; k < 5; k++) localhepevt_.phep [i][k] = hepevt_.phep [i][k];
for (int k = 0; k < 4; k++) localhepevt_.vhep [i][k] = hepevt_.vhep [i][k];
localhepevt_.jmohep[i][1] = std::max(localhepevt_.jmohep[i][0],localhepevt_.jmohep[i][1]);
localhepevt_.jdahep[i][1] = std::max(localhepevt_.jdahep[i][0],localhepevt_.jdahep[i][1]);
/// For some interesting reason EPOS marks beam particle parents as -1 -1
if (localhepevt_.jmohep[i][0] <= 0 && localhepevt_.jmohep[i][1] <= 0 )
{
localhepevt_.jmohep[i][0] = 0;
localhepevt_.jmohep[i][1] = 0;
localhepevt_.isthep[i] = 4;
}
}
/// Compiled!
HepMC::HEPEVT_Wrapper::HEPEVT_to_GenEvent(evt);
#else
HepMC::IO_HEPEVT hepio;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment