Calling variables from another .cc file

Dear G4 users, I am new to geant4 and my programming skils with c++ are scarse.

I am modifying the example B1. I am trying to get the values of the total number of events to be run and the energy of the particles generated in the file B1EventAction.cc.

For the energy of the particles I have tried #include B1PrimaryGeneratorAction.hh and #include G4ParticleGun and getting the energy with something like fParticle->GetParticleEnergy()

And for the number of envents to be run I tried something simmilar getting the variable from the B1RunAction.cc.

No luck so far, any tips are more than wellcomed. And I am sorry for my lack of c++ control.