Hello all,
I am trying to simulate an experiment with a proton beam, a water phantom and I would like to change a detector position between runs to measure the dose profile.
To do that I realized the simple cycle in a Main.cpp to change detector position between runs:
for(int i = 0; i<40; i++)
{
runManager->BeamOn(60000);
G4ThreeVector pos = det->GetSensorPosition();
pos.setZ(pos.z() + 5. * CLHEP::mm);
det->SetSensorPosition(pos);
det->UpdateGeometry();
}
to save the useful data I used Csv:
using G4AnalysisManager = G4CsvAnalysisManager;
and the following code in RunAction:
RunAction::RunAction()
{
…
// Get/create analysis manager: need to do that in the master and in the workers
// The choice of analysis technology is done via selectin of a namespace
// in Analysis.hh
auto man = G4AnalysisManager::Instance();
man->SetVerboseLevel(1);
G4cout << "Using " << man->GetType() << G4endl;
//Enable activation managment
man->SetActivation(true);
//Set index of the first histogramm
man->SetFirstHistoId(1);
// Book histograms
man->CreateH1(“opt_Angle”,“Angle distribution of light”, 180, 0., 180.);
…
etc…
void RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << “RunAction::BeginOfRunAction. Run " << aRun->GetRunID() << " start.” << G4endl;
//define output filename
auto man = G4AnalysisManager::Instance();
std::stringstream stm(“”);
stm << “RUN” << std::setw(5) << std::setfill(‘0’) << aRun->GetRunID();
man->OpenFile(stm.str());
…
etc…
and
void RunAction::EndOfRunAction(const G4Run* aRun)
{
//stop timer
timer->Stop();
G4cout << *timer << G4endl;
G4cout << "RunAction::EndOfRunAction. number of event = " << aRun->GetNumberOfEvent() << G4endl;
// Write histograms to file.
//The call to Write() triggers writing remaining data to all open files and the call to CloseFile() closing all files
//and automatic resetting histograms and ntuples data.
auto man = G4AnalysisManager::Instance();
man->Write();
man->CloseFile();
…
etc…
if I run the cycle more than 1 times I see a strange thing: at each BeamOn all old histograms are disappear!!! It means when histograms with names RUN00001_.csv are accumulated, the histograms with RUN00000_.csv automatically removed.
Could anybody give me an advice how to save histograms between runs or how to prevent auto-delete
of the saved data?
Many thanks in advance,
Vyacheslav