Some problems in G4AnalysisManager

Hello everyone. I made some bugs in the .mac file.
I am asking for help how to solve it.

/run/initialize

/gun/particle e-
#
/gun/energy 12 eV
/run/beamOn 100000

/gun/energy 62 eV
/run/beamOn 100000

If I call the /run/beamOn twice times, it would come out a warning that wouldn’t happen when I call the /run/beamOn just for once.

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : Analysis_W001
      issued by : G4TNtupleManager<NT,FT>::FillNtupleTColumn
Ntuple 0 does not exist.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

Here copy my RunAction code

RunAction::RunAction()
{
	CreateRoot();
}

void RunAction::CreateRoot()
{
	G4AnalysisManager* man = G4AnalysisManager::Instance();

	man->OpenFile("output.root");

	man->CreateNtuple("Benchmark", "Benchmark");
	man->CreateNtupleIColumn("fEvent");
        ......
	man->FinishNtuple(0);


	man->CreateNtuple("array", "array");
	man->CreateNtupleIColumn("X");
        ......
	man->FinishNtuple(1);
}
void RunAction::EndOfRunAction(const G4Run* run)
{
	G4AnalysisManager* man = G4AnalysisManager::Instance();

	man->Write();
	man->CloseFile();
}

If I should add something more to determine when to close the File?
Thank you for your attention!

By the way, I learn this kind of mac command which “/run/beamOn” for twice from the DNA example like range,spower and so on, but I don’t know why it can’t work here.

Hello everyone, I find out the reason that once I run the EndofRun, the analysismanager should be end. One of the correct methods is that you should learn from the example to make a run class to merge the counters and write it into .txt file. Thank you for your watching!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.