What does /run/initialize do?

Can anyone please tell which function is called when ‘run/initialize’ is executed?
This is the output I get when running ‘/run/initialize’ in exampleB1, from which I can see it call B1DetectorConstruction::Construct() and probably G4VUserPhysicsList::Construct(). Not sure where they are called from.

userDetector->Construct() start.
Checking overlaps for volume Envelope (G4Box) … OK!
Checking overlaps for volume Shape1 (G4Cons) … OK!
Checking overlaps for volume Shape2 (G4Trd) … OK!
World is registered to the default region.
physicsList->Construct() start.
.### Adding tracking cuts for neutron TimeCut(ns)= 10000 KinEnergyCut(MeV)= 0
physicsList->CheckParticleList() start.
physicsList->setCut() start.

Another question is why ‘/run/initialize’ needs be executed at the beginning of program (in init_vis.mac). Isn’t the run initialization done by SetUserAction(new B1RunAction), which is called by SetUserInitialization(new B1ActionInitialization())?

The /run/initialize macro command triggers a call to G4RunManager::Initialize(). That function does all of the intialization needed before starting a run (geometry, phyics, materials/cuts couples, etc.).

The Set functions you mention do not run initialization. All they do is register your classes, so that /run/initialize can call the right functions when it is invokedd.

Thank you for the explanation. It greatly helps.