Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new example21 which uses G4VTrackingManager #266

Merged
merged 13 commits into from
Nov 6, 2023

Conversation

WitekPokorski
Copy link
Contributor

New example21 demonstrates integration of AdePT into Geant4 using the G4VTrackingManager instead of Fast Simulation hook. In this case all e+,-, gammas are immediately handed over to AdePT (in the entire detector). No particles ever come back from AdePT. It seems to run OK with example21.mac, but certainly further polishing may be needed (and further bugs may be present due to limited testing so far).

@phsft-bot
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

@agheata agheata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some comments, in particular we are copying over data files that are common for example14,17 and now 21. I think we need to run the validation before merging, and a quick speed test, to see what changes compared to example17.

examples/Example21/data/data.2 Outdated Show resolved Hide resolved
examples/Example21/electrons.cuh Outdated Show resolved Hide resolved
examples/Example21/gammas.cuh Outdated Show resolved Hide resolved
examples/Example21/include/DetectorConstruction.hh Outdated Show resolved Hide resolved
examples/Example21/include/DetectorConstruction.hh Outdated Show resolved Hide resolved
examples/Example21/include/DetectorConstruction.hh Outdated Show resolved Hide resolved
examples/Example21/include/HepMC3G4AsciiReader.hh Outdated Show resolved Hide resolved
examples/Example21/include/SimpleHit.hh Outdated Show resolved Hide resolved
examples/Example21/macros/LHCb_Upgrade_fullLHCb.gdml Outdated Show resolved Hide resolved
examples/Example21/patches/geant4-adept.patch Outdated Show resolved Hide resolved
@agheata
Copy link
Contributor

agheata commented Oct 20, 2023

@WitekPokorski is there a way to enable/disable the integration, to be able to run the same app with G4 only?

@WitekPokorski
Copy link
Contributor Author

Yes, to run without AdePT you add the --no_AdePT argument when you call the example, like this:

/example21 -m example21.mac --no_AdePT

Comment on lines 14 to 17
if(NOT Geant4_flush_FOUND)
message(STATUS "Disabling example21 (needs G4VFastSimulationModel::Flush interface available starting with geant4-11-00-ref-01)")
return()
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn't use G4VFastSimulationModel::Flush but G4VTrackingManager, which is available since Geant4 11.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void AdePTTrackingManager::BuildPhysicsTable(const G4ParticleDefinition &part) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called once per particle type (e-/+/gamma); it needs a protection to only initialize once.

AdePTTrackingManager* trackingManager = nullptr;

if(useAdePT){
trackingManager = new AdePTTrackingManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example currently only works with one thread. The reason is that we need one tracking manager per thread (the same way we had one fast simulation model per thread)...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh... I new it was too easy... ;-) OK, I won't be able to look into it this week. If anybody has some time to touch this code, please go ahead. Otherwise, I am back next week...

  * Reduced the size of the scoring arrays to just the number of sensitive PVols
  * G4 Physical Volume ID to Hit mapping in geant4
  * VecGeom Placed Volume ID to Hit mapping + VecGeom PV to Geant4 PV ID mapping in AdePT
  * Removed unused code
  * Fixes for initialization issues in multithreaded mode
@agheata agheata merged commit 12253c0 into apt-sim:master Nov 6, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants