Skip to content

Commit

Permalink
Example17 EventAction, restore IO settings after output of energy dep…
Browse files Browse the repository at this point in the history
…osits
  • Loading branch information
JuanGonzalezCaminero committed Jul 5, 2023
1 parent d3a6a75 commit e4cb315
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/Example17/src/EventAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ void EventAction::EndOfEventAction(const G4Event *aEvent)
G4cout << "EndOfEventAction " << eventId << ": real time " << fTimer.GetRealElapsed() << G4endl;
}

// Store the original IO precission and width
auto aOriginalPrecission = std::cout.precision();
auto aOriginalWidth = std::cout.width();

auto &groups = fDetector->GetSensitiveGroups();
int ngroups = groups.size();
double *edep_groups = nullptr;
Expand Down Expand Up @@ -169,4 +173,7 @@ void EventAction::EndOfEventAction(const G4Event *aEvent)
G4cout << "EndOfEventAction " << eventId << "Total energy deposited: " << totalEnergy / MeV << " MeV" << G4endl;
}
delete[] edep_groups;

// Restore the original IO precission
G4cout << std::setprecision(aOriginalPrecission) << std::setw(aOriginalWidth) << std::defaultfloat;
}

0 comments on commit e4cb315

Please sign in to comment.