Show process progress during the run

Hello, I’m trying to write a function tu show the percent of the running progress

  1. In the B1EventAction.cc I wrote:
    a.

       B1EventAction::B1EventAction(B1RunAction* runAction)
             : G4UserEventAction(),
               fRunAction(runAction),
               fEdep(0.)
               fPrintModulo(10000)
             {} 
    

b.
fPrintModulo= 10000;
c.

evtNb = evt->GetEventID();
    	NevTot=G4RunManager::GetRunManager()->GetCurrentRun()->GetNumberOfEventToBeProcessed();
    	if ((100/fPrintModulo*evtNb)%NevTot==0) G4cout <<"\n---> Begin of Event:"<<evtNb<<" of "<<NevTot<<" Progress % is "<<(100*evtNb)/NevTot<<G4endl;
  1. In the B1Eventaction.hh I wrote
    virtual void BeginOfEventAction(const G4Event* evt);
    G4int fPrintModulo;

but I get error

Notice that I assigned to fPrintModulo the number of events that I want to simulate

Hello,
I’m not sure I completely understand the Italian error message, but from what I get it might be as simple as putting a comma between fEdep(0.) and fPrintModulo(10000).

That being said, to print the progress I would usually just write something like

if( evt->GetEventID()%10000==0 ) G4cout << evt->GetEventID() << G4endl;

in the EventAction.cc.

Thank you @swagner

Yes, that was the bug!

Thank you! it is easier!

Hey. I am trying to make a progress bar for rdecay02. Has anyone here already done it? It is a little bit similar to B1.

/run/printProgress <modulus>

Thanks. Do I put this into the BeginOfEventAction function of EventAction?

It’s a macro command. Put it in your macro file, on the line before /run/beamOn.

Hey. I am getting this error when I put this command in my batch macro file.

Replace the placeholder string with a numerical modulus.

Thank you for your help, but it is still no working. However I found another method that is working fine now. My next step is trying to print it on the same place instead of having it span in bunch of lines like this. I have tried to use “\r”, but it is not working.