Scintillation light

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?

G4int photons = 0;
G4SteppingManager* fpSteppingManager = 
  G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager();
G4StepStatus stepStatus = fpSteppingManager->GetfStepStatus();
if (stepStatus != fAtRestDoItProc) {
  G4ProcessVector* procPost = fpSteppingManager->GetfPostStepDoItVector(); 
  size_t MAXofPostStepLoops = fpSteppingManager->GetMAXofPostStepLoops(); 
  for (size_t i3 = 0; i3 < MAXofPostStepLoops; i3++) {
    if ((*procPost)[i3]->GetProcessName() == "Scintillation") {
      G4Scintillation* proc1 = (G4Scintillation*) (*procPost)[i3];
      photons += proc1->GetNumPhotons();
    }
  }
}

edit: not helpful, unfortunately :frowning: