Count the time and bounce in Integrating Sphere

Hello to everyone,

I am new to geant4 and am trying to create a simulation of an integrating sphere with liquid (currently water) and a detector inside it.

The structure of the geometry is almost fully completed. My idea is to fire a certain number of particles (fParticleGun already implemented) from the edge of one of the two conduits and count the number of bounces of the optical photon on the surface of the sphere, the number of photons reaching the yellow detector and the time it takes for the photon to reach that detector.

As far as the two surfaces (sphere and detector) are concerned, I think I have already made them sensitive:

  G4MultiFunctionalDetector* SferaIntegratrice_SD = new G4MultiFunctionalDetector("SferaIntegratrice_SD");
  G4SDManager::GetSDMpointer()->AddNewDetector(SferaIntegratrice_SD);
  //G4VPrimitiveScorer* primitiv1 = new G4PSDoseDeposit("dose");
  //SferaIntegratrice_SD->RegisterPrimitive(primitiv1);
  SetSensitiveDetector("SferaIntegratriceLV",SferaIntegratrice_SD);
  
  
  G4MultiFunctionalDetector* SiPM_SD = new G4MultiFunctionalDetector("SiPM_SD");
  G4SDManager::GetSDMpointer()->AddNewDetector(SiPM_SD);
  //G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose");
  //SiPM_SD->RegisterPrimitive(primitiv2);
  SetSensitiveDetector("SiPMLV",SiPM_SD);

Correct me if I am wrong. To count the number of bounces, for simplicity’s sake let’s consider firing a single optical photon, I think we need to use the class G4PSSphereSurfaceCurrent.hh (reading from the developer’s manual). I couldn’t find any examples on it unfortunately…

So I ask, how can I count the number of bounces, the number of photons that reach the yellow detector and then disappear, and the time it takes for the photon to reach that detector once it has been fired?

I also upload the “DetectorConstruction.cc” DetectorConstruction.cc (12.3 KB)

Thank you for your help.

1 Like

I was able to implement the right scorer:

  G4MultiFunctionalDetector* SferaIntegratrice_SD = new G4MultiFunctionalDetector("SferaIntegratrice_SD");
  G4SDManager::GetSDMpointer()->AddNewDetector(SferaIntegratrice_SD);
  SetSensitiveDetector("SferaIntegratriceLV",SferaIntegratrice_SD);
  G4VPrimitiveScorer* primitiv1 = new G4PSSphereSurfaceCurrent("number_of_bounce", fCurrent_Out);
  SferaIntegratrice_SD->RegisterPrimitive(primitiv1);
  
  G4cout<<"Created G4MultiFunctionalDetector named "

        <<SferaIntegratrice_SD->GetName()<<", and a G4PSSphereSurfaceCurrent scorer " <<"named "<<primitiv1->GetName()<<G4endl;
  
  
 
  G4MultiFunctionalDetector* SiPM_SD = new G4MultiFunctionalDetector("SiPM_SD");
  G4SDManager::GetSDMpointer()->AddNewDetector(SiPM_SD);
  SetSensitiveDetector("SiPMLV",SiPM_SD);
  G4VPrimitiveScorer* primitiv2 = new G4PSFlatSurfaceFlux("number_photon_SiPM", fFlux_In);
  SiPM_SD->RegisterPrimitive(primitiv2);
  
  
  G4cout<<"Created G4MultiFunctionalDetector named "

        <<SiPM_SD->GetName()<<", and a G4PSFlatSurfaceFlux scorer " <<"named "<<primitiv2->GetName()<<G4endl; 
  

Now the question is: how can i obtain the information about primitiv1 and primitiv2 after each run?

alternatively, you can attach the scorers via commands/macro. there you can also dump results after each run. think you will find suitable examples for that

Edit: sorry, missed that it is a sphere… not so sure about that then :frowning:

How can I do that? What changes if they are inside a sphere?

I tried with this command:

/score/create/boxMesh OpticalBoxMesh
/score/mesh/boxSize 10 10 10 cm
/score/mesh/nBin 1 1 1
/score/quantity/flatSurfaceFlux number_photon_SiPM
/run/beamOn 1000
/score/quantity/flatSurfaceFlux OpticalBoxMesh number_photon_SiPM Risult_Sim.txt
/score/close

but i get this error: G4WT0 > number_photon_SiPM: integer expected.

Of course the number that i expected is an integer but i don’t understand why this not happen…

/score/close before /run/beamOn 1000
after the run, you can dump:
/score/dumpAllQuantitiesToFile scorer filename.csv

or you make use of the histogram filler: Command-based scoring — Book For Application Developers 11.0 documentation

but as mentioned, the SphereSurfaceCurrent is not in the list of available primitive scorers for command based scoring, as you will see when you study that page :frowning:

an idea could be to define an additional hollow sphere, and attach the volumeFlux scorer to it?

1 Like

Mmm… Maybe i can… maybe, I’m not sure.Thanks for the reply.

By the way, I made this mac file:

/run/numberOfThreads 4
# Initialize kernel
/run/initialize
#
/control/verbose 2
/tracking/verbose 2
#
/score/create/boxMesh OpticalBoxMesh
/score/mesh/boxSize 10 10 10 cm
/score/mesh/nBin 1 1 1
/score/quantity/flatSurfaceFlux number_photon_SiPM
/run/beamOn 1000
/score/close
#/score/quantity/flatSurfaceFlux OpticalBoxMesh number_photon_SiPM Risult_Sim.txt
/score/dumpAllQuantitiesToFile OpticalBoxMesh Result_Sim.csv

and i get this file Result_Sim.csv:

# mesh name: OpticalBoxMesh
# primitive scorer name: number_photon_SiPM
# iX, iY, iZ, total(value) [percm2], total(val^2), entry
0,0,0,0,0,0

Seems that no info was stored…

1 Like

it seems that you do not close the scorer before you switch on the beam :wink:

I did it but nothing change…

# Macro file of "exampleB3.cc"
# Change the default number of workers (in multi-threading mode) 
/run/numberOfThreads 4
# Initialize kernel
/run/initialize
#
/control/verbose 2
/tracking/verbose 2
#
/score/create/boxMesh OpticalBoxMesh
/score/mesh/boxSize 10 10 10 cm
/score/mesh/nBin 1 1 1
/score/quantity/flatSurfaceFlux number_photon_SiPM
/score/close
/run/beamOn 5000
#/score/quantity/flatSurfaceFlux OpticalBoxMesh number_photon_SiPM Risult_Sim.txt
/score/dumpAllQuantitiesToFile OpticalBoxMesh Result_Sim.csv

Why?

1 Like

flatsurfaceflux is only measured in the -z plane of the cube. maybe there are no photons passing through? try to rotate the mesh accordingly

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/commandScore.html?highlight=flatsurfaceflux#id9