and what is values is n_proc when there is scintillation?
[/quote]
I tried to print G4cout << "n_proc==" <<n_proc<< G4endl;
both with and without the filter
in a post before (Scintillation light - #14 by faca87) you mentioned the issue that it did not print anything, as if n_proc was zero. that is weird now that it is always 10…
do you strictly copy paste the code from your program to your posts?
maybe simplify your code to the bare minimum, make it work there, slowly add more „complex“ things and check if things still work as they should.
you could also use the linked example as a start, from the filenames it looks like you took B1 instead of OpNovice2!?
Yes, I started from B1 example! This is because I’m implementing the scintillation to my simulation…I’m building the simulation step -by-step and my supervisor said me to start from B1
Searching on the forum, I found this @dsawkey 's message Track of optical photon - #5 by dsawkey he said that in the macro of the OpNovice2 there are some command lines needed to use the scintillation I guess the lines are:
the creation of photons is a statistical process, depending on type and energy of particles inside the scintillator volume, and also (very important) the geometry of the scintillator and the scintillating properties that you defined.
how many particles reach the scintillator when you don’t get any photons?
this is why I suggested to make the simulation as simple as possible, to be able to really understand what is happening.
to make things work in this case you really only need 1 volume with your scintillating material, and nothing else.
make the primary particles start right in front of the scintillator volume, point source, pencil beam, so all primaries make it into the scintillator.
for my personal taste, the stepping action should be empty except for the things you want to test…
played around with the code a little bit, especially with the stuff from OpNovice2 example, and must admit, I could not yet find out why this code in the stepping action does not produce any photon counts, even though photons are created and being stacked and traced:
// this demonstrates use of GetNumPhotons()
auto proc_man =
track->GetDynamicParticle()->GetParticleDefinition()->GetProcessManager();
G4ProcessVector* proc_vec = proc_man->GetPostStepProcessVector(typeDoIt);
G4int n_proc = proc_vec->entries();
G4int n_scint = 0;
for(G4int i = 0; i < n_proc; ++i)
{
G4String proc_name = (*proc_vec)[i]->GetProcessName();
if(proc_name.compare("Scintillation") == 0)
{
auto scint = (G4Scintillation*) (*proc_vec)[i];
n_scint = scint->GetNumPhotons();
}
}
probably only a single line of configuration missing / different than in the example!? Did you build the example and does it work in your installed geant4 version?
I found some presentation slides where a similar code snippet is slightly different, you could give it a try. Don’t know if that is supposed to work fine with the current version of geant4?
What version of geant4 are you using? Just switched the test simulation to version 11, and voila:
G4WT0 > In this step, 1 scintillation photons were produced.
G4WT0 > I am a photon :)
G4WT0 > I am a photon :)
G4WT0 > In this step, 1 scintillation photons were produced.
G4WT0 > I am a photon :)
G4WT0 > In this step, 1 scintillation photons were produced.
G4WT0 > I am a photon :)
G4WT0 > I am a photon :)
G4WT0 > I am a photon :)
G4WT0 > In this step, 1 scintillation photons were produced.
G4WT0 > I am a photon :)
G4WT0 > I am a photon :)
Hello @weller, thank you. I’m having problems with Geant4 11 …I will open a topic for it and then I will try your code!
EDIT : @weller did to you use my full code …or did you use your simulation? because I’m having problems to use my simulation by Geant4 11 because it can’t find g4analysis.hh as I wrote here Geant4 11 on cvmf
It was a very minimal simulation, that was in principle just the mandatory classes plus the stepping action. and there is only 1 G4Box in the whole world
I feel this file is extremely hard to debug, especially from outside… what are all these if(someFlag) doing there? how can you be sure that there is no logical mistake? how can the forum community verify that this is the case? → make it simple! copy the whole application to a new folder, and strip out everything that is not needed to debug the issue.
my bet now would be on: fPlastScintFlag == false, hence ScintMat = world_mat and there all these G4MaterialProperties are not defined.
on top: how many particles are passing through the scintillator? what is the thickness the particles effectively see? if it is only few particles and a thin thickness → maybe you need many more primaries to be lucky and see a photon…