JuliaPhysics / SolidStateDetectors.jl

Solid state detector field and charge drift simulation in Julia
Other
77 stars 29 forks source link

Integration of the electric field in Geant4 #397

Open hervasa2 opened 1 month ago

hervasa2 commented 1 month ago

Full integration of SSD and geant4 could include the use of the electric field calculated by SSD. Particle propagation in Geant4 can then occur in the presence of this field. Field dependent spectrum effects (i.e. shift of single escape peak) could thus be simulated. This would also require switching to G4EmStandardPhysics_option4 https://github.com/JuliaPhysics/SolidStateDetectors.jl/blob/30584dc6abab01085e47bcb21ad6672a7fe3896c/ext/Geant4/g4jl_application.jl#L5 which should then also include doppler broadening effects (not captured by StandardPhysics). We would need some speed tests for this change.

I see two possible ways of passing the field to Geant4.

  1. Following the guidance in this thread a non-uniform electric field can be created in Geant4 in the following manner.
    
    fFieldMessenger(nullptr)
    {
    // fEMfield = new G4UniformElectricField(G4ThreeVector(0.0,-1.0kilovolt/cm,0.0));
    G4double zOffset = 0.0 * mm;
    fEMfield = new PurgMagTabulatedEField3D(“PurgMag3D.TABLE”, zOffset);
    fEquation = new G4EqMagElectricField(fEMfield);

fFieldManager = GetGlobalFieldManager();

UpdateIntegrator(); fFieldMessenger = new F02FieldMessenger(this); }


- `PurgMag3D.TABLE` is just a text file with a field vector in each row: `x y z Ex Ey Ez`
- A `/field/getField` function needs to be defined to interpolate at any point, this can just be ported from the current methods in SSD

2. Create virtual volumes (given by grid size) of uniform electric field and use 
```c
fEMfield = new G4UniformElectricField(G4ThreeVector(0.0,100000.0*kilovolt/cm,0.0));
fEquation = new G4EqMagElectricField(fEMfield)
hervasa2 commented 1 month ago

Looks like G4EmStandardPhysics_option4 works well and only causes a modest slowdown ~ 1.5-2 times slower

window = 0.002
bw = 0.00025
plot(stephist(sum.(events.edep), bins = 1593.002-window:bw:1593.002+window),
    stephist(sum.(events.edep), bins = 2104.001-window:bw:2104.001+window),
    size = (1500,500)
    )

Double and single escape peaks with with G4EmStandardPhysics_option4 Screenshot 2024-08-08 at 14 54 12

Double and single escape peaks with with G4EmStandardPhysics Screenshot 2024-08-08 at 14 58 33

oschulz commented 1 month ago

Having doppler broadening in would be very useful when simulating calibration spectra, for example.

oschulz commented 1 month ago

As for the electrical field effects on particle propagation, can you estimate if this will result in non-negligible corrections?

oschulz commented 1 month ago

We should also be able it easy for the user to select the physics model with an option, right?

hervasa2 commented 1 month ago

As for the electrical field effects on particle propagation, can you estimate if this will result in non-negligible corrections?

Yes I was wondering about this. We know that the shift of the single escape peak is about 0.1keV (source) which is definitely observable. However I think we can ignore it for practical purposes. As for any other effects (i.e. shift of positron annihilation position due to drift, charged particle tracks...) its hard to say a priori.

oschulz commented 1 month ago

Let's split this - user selectable physics lists should be easy to do, while incorporating the electrical field will be more involved (are you interested in pursuing this @hervasa2 ?).

hervasa2 commented 1 month ago

Yes, I will work on selectable physics lists next week! See you at volleyball!

oschulz commented 1 month ago

@hervasa2 don't worry about the physics lists, @fhagemann will do this over the weekend or so, it's quick thing.

Incorporating the electrical field seems like a different best though, someone will need to contribute this.