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

Fix issue #346 #368

Merged

Conversation

m-dupont
Copy link
Contributor

This pull request aims to fix issue #346.

Implementation of IsApplicable in GateScintillation to get back behaviour of geant4 10.05.

IsApplicable has been changed between geant4 10.05 and geant4 10.06 which made Scintillation not applicable for gamma. Because gamma has a PDGCharge of 0.0. Here we go back to previous implementation until we find another solution (ie without bypassing geant4).

Code in geant4 10.05:

 G4bool G4Scintillation::IsApplicable(const G4ParticleDefinition& aParticleType)
 {
        if (aParticleType.GetParticleName() == "opticalphoton") return false;
        if (aParticleType.IsShortLived()) return false;

        return true;
 }

Code in geant4 10.06:

 G4bool G4Scintillation::IsApplicable(const G4ParticleDefinition& aParticleType)
 {
        return (aParticleType.GetPDGCharge() == 0.0 ||
 	       aParticleType.IsShortLived()) ? false : true;
 }

…iour of geant4 10.05.

 IsApplicable been changed between geant4 10.05 and geant4 10.06 which made Scintillation not applicable for gamma. Because gamma has a PDGCharge of 0.0. Here we go back to previous implementation until we find another solution (ie without bypassing geant4).

 Code in geant4 10.05:

 G4bool G4Scintillation::IsApplicable(const G4ParticleDefinition& aParticleType)
 {
        if (aParticleType.GetParticleName() == "opticalphoton") return false;
        if (aParticleType.IsShortLived()) return false;

        return true;
 }

 Code in geant4 10.06:

 G4bool G4Scintillation::IsApplicable(const G4ParticleDefinition& aParticleType)
 {
        return (aParticleType.GetPDGCharge() == 0.0 ||
 	       aParticleType.IsShortLived()) ? false : true;
 }
@hangyookang
Copy link

Thanks for your good advice.

The scintillation process works with the combination of GATEv9.0 and Geant4.9.05.p01.

Best regards,

Han Gyu Kang

@dsarrut dsarrut merged commit 42e158e into OpenGATE:develop Oct 23, 2020
@dsarrut
Copy link
Contributor

dsarrut commented Oct 23, 2020

thanks !

@vietvhnguyen
Copy link

vietvhnguyen commented Jun 22, 2022

Hello,
I am currently using GATE v9.0 with Geant4.10.6.p01.
I use gamma beam, LYSO scintillator, and detect optical photons emitted.
When I set up physics processes with /gate/physics/addProcess, I found optical photons (Hits Tree, PDG Encoding = 0).
When I used physics list builder /gate/physics/addPhysicsList with both emstandard_opt4, and emlivermore, I only found electron (PDG Encoding = 11).

Then I found this issue.
I checked out this commit, compiled GATE, and ran again.
When adding each physics process, I got much more optical photons.
When using physics list (emstandard_opt4), I still got the issue.

Isn't this fix applied for physics list builder?
I hope to get your suggestions or solutions.

Thank you so much,
Viet

@dsarrut
Copy link
Contributor

dsarrut commented Jun 22, 2022

Hi, thank you for the report. @wrzof can you please have a look ? Thanks!

@vietvhnguyen
Copy link

Hello,
Thank you for your response.

I am adding more details to my previous comment for easier tracking the issue.
My setup in the previous comment:

  • Ubuntu 18.04.6 under Windows Subsystem for Linux 1 (WSL 1)
  • Geant4.10.6.p01
  • GATE v9.0 checked out at this commit
    Yesterday, I tested with another setup:
  • Ubuntu 18.04.6 (actual Ubuntu OS, no WSL)
  • Geant4.10.6.p03
  • GATE v9.0 also checked out at this commit
    -> I still have the same issues for physics list builder (no optical photons).

I also attached my macro.
If you have time, please have a look.
I hope the issue is not because of me messing up with the commands.
From the GATE manual, Physics List Builder is recommended over the deprecated call of each physics process.
I am not sure in my setup (mainly gamma and electron interaction),
Do the two approaches really make any differences?
So sorry, I don't have much experience with Geant4 and GATE, so mainly I follow the suggestions in the manuals.
If for my setup, the two approaches should give the same results, I am fine to go with the deprecated one.

I will try to test with GATE v9.2.
But this option quite taking time, I got new issues with ROOT 6.24.06 installation.

I hope to get your suggestions or solutions soon.
Thank you so much for your help.
Viet

(My macro)

#===============================================================#
#	V I S U A L I Z A T I O N   &   V E R B O S E		#
#===============================================================#
#-------------------------------------------------------#
#	Visualization					#	
#-------------------------------------------------------#
/vis/disable

# /vis/open				OGLIQt
# # OGL -> OpenGL,
# # I -> Immediate or S -> Store
# # X -> X11 (Xming) or Qt

# /vis/viewer/update
# /vis/viewer/panTo			0.	0.	cm
# # Translate viewer window	+(right)/-(left)	+(up)/-(left)

# /vis/viewer/set/viewpointThetaPhi	0	0
# # /vis/viewer/set/upThetaPhi		0	0
# # /vis/viewer/set/viewpointVector	0	1	0
# # /vis/viewer/set/upVector		0	0	1

# /vis/viewer/zoom			1
# /vis/drawVolume

# /tracking/storeTrajectory	1	# 1->store, 0->not store
# /vis/scene/add/trajectories
# /vis/scene/endOfEventAction	accumulate    10
# # Requests viewer to refresh hits, tracks, etc., at end of event.
# # Or to accumulate drawings. Detector remains or is redrawn.

# /vis/scene/add/axes		0. 0. 0. 20. mm
# # (x,y,z) -> color (R,G,B)



#-------------------------------------------------------#
#	Verbose						#	
#-------------------------------------------------------#
/gate/verbose Physic			0
/gate/verbose Cuts			0
/gate/verbose SD			0
/gate/verbose Actions			0
/gate/verbose Actor			0
/gate/verbose Step			0
/gate/verbose Error			0
/gate/verbose Warning			1
/gate/verbose Output			1
/gate/verbose Beam			0
/gate/verbose Volume			0
/gate/verbose Image			0
/gate/verbose Geometry			0
/gate/verbose Core			0

/run/verbose  				0
/event/verbose				0
/tracking/verbose			0




#===============================================================#
# G E O M E T R Y						#
#===============================================================#
#-------------------------------------------------------#
# Material database:					#	
#-------------------------------------------------------#
/gate/geometry/setMaterialDatabase	./GateMaterials.db
# GateMaterials.db & Materials.xml should be in the directory


#-------------------------------------------------------#
# World volume:						#
#-------------------------------------------------------#
/gate/world/geometry/setXLength		1000. mm
/gate/world/geometry/setYLength		1000. mm
/gate/world/geometry/setZLength		1000. mm
/gate/world/setMaterial			G4_AIR
/gate/world/vis/setVisible		0


#-------------------------------------------------------#
# 0th level:	scanner					#
#-------------------------------------------------------#
/gate/world/daughters/name		scanner
/gate/world/daughters/insert 		box
/gate/scanner/geometry/setXLength	600. mm
/gate/scanner/geometry/setYLength	600. mm
/gate/scanner/geometry/setZLength	600. mm
/gate/scanner/placement/setTranslation	0. 0. 0. mm
# Respect to the center of the mother volume 'world'
/gate/scanner/setMaterial 		G4_AIR
/gate/scanner/vis/setColor		white
/gate/scanner/vis/forceWireframe
/gate/scanner/vis/setVisible		0



#-------------------------------------------------------#
# crystal						#
#-------------------------------------------------------#
# This v3 simulates the exact size of the crystal
/gate/scanner/daughters/name		crystal
/gate/scanner/daughters/insert          box
/gate/crystal/geometry/setXLength	26. mm
/gate/crystal/geometry/setYLength	26. mm
/gate/crystal/geometry/setZLength	3.0 mm
/gate/crystal/placement/setTranslation	0. 0. 0. mm
/gate/crystal/setMaterial		LYSO
/gate/crystal/vis/setColor		gray
/gate/crystal/vis/forceSolid



#-------------------------------------------------------#
# 1st level: module (at 4 sides)			#
#-------------------------------------------------------#
/gate/scanner/daughters/name		module
/gate/scanner/daughters/insert          box
/gate/module/geometry/setXLength	0.6 mm
/gate/module/geometry/setYLength	26. mm
/gate/module/geometry/setZLength	3.0 mm
/gate/module/placement/setTranslation	13.3 0. 0. mm
/gate/module/setMaterial		G4_AIR
/gate/module/vis/setColor		green
/gate/module/vis/forceWireframe


#-------------------------------------------------------#
# 2nd level: package (SiPM package)			#
#-------------------------------------------------------#
/gate/module/daughters/name		package
/gate/module/daughters/insert		box
/gate/package/geometry/setXLength	0.6 mm
/gate/package/geometry/setYLength	8.9 mm
/gate/package/geometry/setZLength	3.0 mm
/gate/package/placement/setTranslation	0. 0. 0. mm
/gate/package/setMaterial		G4_AIR
/gate/package/vis/setColor		cyan
/gate/package/vis/forceWireframe



#-------------------------------------------------------#
# 3rd level: pixel					#
#-------------------------------------------------------#
/gate/package/daughters/name		pixel
/gate/package/daughters/insert		box
/gate/pixel/geometry/setXLength		0.6 mm
/gate/pixel/geometry/setYLength		6. mm
/gate/pixel/geometry/setZLength		3. mm
/gate/pixel/placement/setTranslation	0. 0. 0. mm
/gate/pixel/setMaterial			G4_AIR

/gate/pixel/vis/setColor		blue
/gate/pixel/vis/forceSolid




#-------------------------------------------------------#
# Repeat package: 2 each side				#
#-------------------------------------------------------#
/gate/package/repeaters/insert			cubicArray
/gate/package/cubicArray/setRepeatNumberX	1
/gate/package/cubicArray/setRepeatNumberY	2
/gate/package/cubicArray/setRepeatNumberZ	1
/gate/package/cubicArray/setRepeatVector	0. 8.9 0. mm
## y of RepeatVector = package width = 8.9

#-------------------------------------------------------#
# Repeat module : 4 sides				#
#-------------------------------------------------------#
/gate/module/repeaters/insert		ring
/gate/module/ring/setRepeatNumber	4


#-------------------------------------------------------#
# Attach volumes to the System				#
# Attach the volume as a Sensitive Detector 		#
#-------------------------------------------------------#
/gate/systems/scanner/level1/attach	module
/gate/systems/scanner/level2/attach	package
/gate/systems/scanner/level3/attach	pixel

/gate/pixel/attachCrystalSD

/gate/systems/scanner/describe



#===============================================================#
#	S Y S T E M	M O V E M E N T:	ORBITING	#
#===============================================================#
# None



#===============================================================#
#	P H A N T O M						#
#===============================================================#
# None



#===============================================================#
#	P H Y S I C S						#
#===============================================================#
#-------------------------------------------------------#
#	Electromagnetic Processes			#
#-------------------------------------------------------#
# /gate/physics/addProcess			PhotoElectric
# /gate/physics/processes/PhotoElectric/setModel	StandardModel

# /gate/physics/addProcess 			Compton
# /gate/physics/processes/Compton/setModel 	StandardModel

# /gate/physics/addProcess		RayleighScattering
# /gate/physics/processes/RayleighScattering/setModel	PenelopeModel

# /gate/physics/addProcess		ElectronIonisation
# /gate/physics/processes/ElectronIonisation/setModel StandardModel e-
# /gate/physics/processes/ElectronIonisation/setModel StandardModel e+

# /gate/physics/addProcess		Bremsstrahlung
# /gate/physics/processes/Bremsstrahlung/setModel StandardModel e- 
# /gate/physics/processes/Bremsstrahlung/setModel StandardModel e+


# # /gate/physics/addProcess 	PositronAnnihilation e+
# # No need model selection

# /gate/physics/addProcess 	eMultipleScattering 
# /gate/physics/processes/eMultipleScattering/setModel UrbanModel e-
# /gate/physics/processes/eMultipleScattering/setModel UrbanModel e+


#/gate/physics/addPhysicsList	emstandard_opt4
/gate/physics/addPhysicsList	emlivermore




#-------------------------------------------------------#
#	Optical Physics Processes			#
#-------------------------------------------------------#
# /gate/physics/addProcess	Scintillation
# /gate/physics/addProcess	OpticalAbsorption
# /gate/physics/addProcess	OpticalRayleigh
# /gate/physics/addProcess	OpticalMie
# /gate/physics/addProcess	OpticalBoundary
# /gate/physics/addProcess	OpticalWLS

/gate/physics/addPhysicsList	optical 
/gate/physics/addProcess	Scintillation

/gate/physics/processList	Enabled
/gate/physics/processList 	Initialized

#-----------#
# Cuts
#-----------#
/gate/physics/displayCuts

#===============================================================#
#	A C T O R						#
#===============================================================#


#===============================================================#
#	I N I T I A L I Z A T I O N				#
#===============================================================#
/gate/run/initialize
/geometry/test/run	# detects volume overlapping.



#===============================================================#
# Opt. Photons Det. Surf (must define after Initialization)	#
#===============================================================#
## crystal <-> scanner
/gate/crystal/surfaces/name			crys_sys
/gate/crystal/surfaces/insert			scanner
/gate/crystal/surfaces/crys_sys/setSurface	Polished1_AirESR_R0p95


## crystal <-> module
/gate/crystal/surfaces/name			crys_mod
/gate/crystal/surfaces/insert			module
/gate/crystal/surfaces/crys_mod/setSurface	Polished1_AirPTFE_R0p95


## crystal <-> package
/gate/crystal/surfaces/name			crys_pack
/gate/crystal/surfaces/insert			package
/gate/crystal/surfaces/crys_pack/setSurface	Polished1_R1


## crystal <-> pixel   
/gate/crystal/surfaces/name			crys_pixel
/gate/crystal/surfaces/insert			pixel
/gate/crystal/surfaces/crys_pixel/setSurface	Det_Smooth_R0_varyEff



#===============================================================#
#	D I G I T I Z E R:  Detector Electronic Response	#
#===============================================================# 
# Digitizer for Optical Photons
/gate/digitizer/Singles/insert			opticaladder 
/gate/digitizer/Singles/insert			readout
/gate/digitizer/Singles/readout/setDepth	3	# for pixel



#===============================================================#
#	C O I N C I D E N C E    S O R T E R			#
#===============================================================#
# N/A



#===============================================================#
#	P A R T I C L E   S O U R C E				#
#===============================================================#
/gate/source/addSource			monoEgamma gps
/gate/source/monoEgamma/gps/particle	gamma
/gate/source/monoEgamma/setActivity	200000 becquerel

/gate/source/monoEgamma/gps/ene/type	Mono
/gate/source/monoEgamma/gps/ene/mono	662. keV

/gate/source/monoEgamma/gps/pos/type	Point
/gate/source/monoEgamma/gps/pos/centre	0. 0. 100. mm

/gate/source/monoEgamma/gps/direction	0. 0. -1.
/gate/source/monoEgamma/visualize	red
#/gate/source/list


#===============================================================#
#	D A T A   O U T P U T   				#
#===============================================================#
#-------------------------------------------------------#
# Output Data .root format	 			#
#-------------------------------------------------------#
/gate/output/analysis/disable
/gate/output/fastanalysis/enable
# -> speed up analysis process because of numerous optical photons


/gate/output/root/enable
#/gate/output/root/setFileName		output/1Layer_sq8SiPM_v3_emstandard_opt4
/gate/output/root/setFileName		output/1Layer_sq8SiPM_v3_emlivermore
#/gate/output/root/setFileName		output/1Layer_sq8SiPM_v3_separatePhys

/gate/output/root/setRootHitFlag	1
/gate/output/root/setRootSinglesFlag	0
/gate/output/root/setRootOpticalFlag	0



#===============================================================#
#	R A N D O M   E N G I N E   &   S E E D			#
#===============================================================#
/gate/random/setEngineName		MersenneTwister
/gate/random/setEngineSeed		123456789
/gate/random/verbose			0



#===============================================================#
#	M E A S U R E M E N T   S E T T I N G S			#
#===============================================================#
# Using source with a specific activity
# -> Don't need to set event per slice

# Using time slice approach
/gate/application/setTimeSlice   1 s
/gate/application/setTimeStart   0 s
/gate/application/setTimeStop    1 s

# Start DAQ
/gate/application/startDAQ

@vietvhnguyen
Copy link

vietvhnguyen commented Jun 27, 2022

Hello,
I have some updates.

I used the macro file above to test with GATE v9.2.
This time, none of the two approaches generated optical photons.
For the physics list approach, tested with emstarndard_opt4 and emlivermore.
Things get more confused now.

With this situation, I think I will go with the deprecated way in GATE v9.0.

Thank you,
Viet

@vietvhnguyen
Copy link

Hi,
Sorry to bring up this topic again.

I am currently using Gate v9.0 + g4.10.6.1 (and Gate v9.0 + g4.10.6.3 on another PC) with this fix for scintillation process.
I mentioned in my previous comments that calling each Physics process allowing the generation of optical photons.
Recently, I found this GATE/Geant4 combination had an issue with non-reflector surface, i.e., no Snell's reflection at the surface.

If someone still works on Gate v9.0, could you make a check about this?
I attached some file below to reproduce the issue and a brief issue report in pdf.

If possible, can someone suggest which GATE and Geant4 version work best for optical simulation?
I feel quite confused about this.

Thank you so much,
Viet

v0.zip
2023-06-07-Issue-GATE-surface.pdf

@vietvhnguyen
Copy link

Hello,

About the issue,
I think I find the reason.
I think I have misunderstood some optical simulation notes so I used G4_AIR and did not define the air material in GateMaterials.db (just defined in the Materials.xml).
This caused the issue.
I thought GATE could take the material information from Geant4.
When I define "Air" in the .db and .xml files and change G4_AIR to Air, the result is as expected.

Thank you if you have spent your time for my issue.
Viet

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.

None yet

4 participants