How Cherenkov and Scintilation Physics is translated to code in Geant4?

Hi all, Can anyone share how the generation of optical photons is done in Scintillation in Geant4?

I mean what is the code mechanism that generates the optical photons and controls their number ?

I am not able to find it in Geant4 documentation as it mainly deals with how to implement the scintilation in Geant4.

Or can you share any material dealing with how the various complex physics is implemented in the code for generating optical photons in a scintilation event?