Check duplicate issues.
Goal
In the EIC/ePIC simulations we have a far forward detector that consists of four stations. Since the stations are identical and the hits have a high degree of cohesion, we store the hits in the same collection. But since the stations are quite far apart and there is 'stuff' in between them, there are four <detector/> environments in the geometry plugin. (Details: https://github.com/eic/epic/blob/26.06.0/compact/far_forward/offM_tracker.xml)
In the following block:
|
for( const auto& iv : p->sensitives ) { |
|
SensitiveDetector sd = iv.first; |
|
std::string nam = sd.name(); |
|
auto iter = types.find(nam); |
|
std::string typ = (iter != types.end()) ? (*iter).second : dflt; |
|
G4VSensitiveDetector* g4sd = this->createSensitiveDetector(typ, nam); |
|
for( const TGeoVolume* vol : iv.second ) { |
|
G4LogicalVolume* g4v = p->g4Volumes[vol]; |
|
if( !g4v ) { |
|
except("ConstructSDandField: Failed to access G4LogicalVolume for SD %s of type %s.", |
|
nam.c_str(), typ.c_str()); |
|
} |
|
ctxt->setSensitiveDetector(g4v, g4sd); |
|
} |
|
} |
this appears to lead to non-determinism since the four
TGeoVolumes for the sensitive volumes are iterated in an order determined by their pointer values. This means that the hits in different planes are not consistently in the same order.
Our goal is for the output of the simulation to be independent of the running conditions (or, in the case of multi-threading, at least the only thing that can vary is the inter-event ordering but not the intra-event ordering inside collections).
Operating System and Version
Debian Trixie
compiler
gcc 14.2.0
ROOT Version
ROOT 6.38.04
DD4hep Version
v01-36
Reproducer
I don't have a minimal reproducer, but the issue is observed in our CI checks. In particular, when we compare the new artifact with the ref artifact we noticed the difference in the ordering of hits (eic/containers#297 (comment)).
$ root -l 'rec_dis_18x275_minQ2=1_epic_craterlake_ref.edm4eic.root' -q -e 'events->Scan("ForwardOffMTrackerHits.cellID","","colsize=20 col=x",1,5)'
Attaching file rec_dis_18x275_minQ2=1_epic_craterlake_ref.edm4eic.root as _file0...
(TFile *) 0x654653b13b20
**********************************************
* Row * Instance * ForwardOffMTrackerHi *
**********************************************
* 5 * 0 * 421a0 *
* 5 * 1 * 421a2 *
* 5 * 2 * 0 *
**********************************************
(long long) 3
$ root -l 'rec_dis_18x275_minQ2=1_epic_craterlake_new.edm4eic.root' -q -e 'events->Scan("ForwardOffMTrackerHits.cellID","","colsize=20 col=x",1,5)'
Attaching file rec_dis_18x275_minQ2=1_epic_craterlake_new.edm4eic.root as _file0...
(TFile *) 0x614ddeba55e0
**********************************************
* Row * Instance * ForwardOffMTrackerHi *
**********************************************
* 5 * 0 * 421a2 *
* 5 * 1 * 0 *
* 5 * 2 * 421a0 *
**********************************************
(long long) 3
Additional context
We do have a way to work around this, but I am (in part) reporting this to document the behavior. I've also stared at this for a while and can't really see a great way to fix it without moving away from a set entirely (and thus potentially breaking interfaces).
Check duplicate issues.
Goal
In the EIC/ePIC simulations we have a far forward detector that consists of four stations. Since the stations are identical and the hits have a high degree of cohesion, we store the hits in the same collection. But since the stations are quite far apart and there is 'stuff' in between them, there are four
<detector/>environments in the geometry plugin. (Details: https://github.com/eic/epic/blob/26.06.0/compact/far_forward/offM_tracker.xml)In the following block:
DD4hep/DDG4/plugins/Geant4DetectorSensitivesConstruction.cpp
Lines 87 to 101 in 7693cca
this appears to lead to non-determinism since the four
TGeoVolumes for the sensitive volumes are iterated in an order determined by their pointer values. This means that the hits in different planes are not consistently in the same order.Our goal is for the output of the simulation to be independent of the running conditions (or, in the case of multi-threading, at least the only thing that can vary is the inter-event ordering but not the intra-event ordering inside collections).
Operating System and Version
Debian Trixie
compiler
gcc 14.2.0
ROOT Version
ROOT 6.38.04
DD4hep Version
v01-36
Reproducer
I don't have a minimal reproducer, but the issue is observed in our CI checks. In particular, when we compare the new artifact with the ref artifact we noticed the difference in the ordering of hits (eic/containers#297 (comment)).
Additional context
We do have a way to work around this, but I am (in part) reporting this to document the behavior. I've also stared at this for a while and can't really see a great way to fix it without moving away from a
setentirely (and thus potentially breaking interfaces).