Skip to content
Snippets Groups Projects
Commit 1bb8a192 authored by Vangelis Kourlitis's avatar Vangelis Kourlitis
Browse files

init devs to write out steps statistics. create root file

parent 19650e25
Branches
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ class MyRunAction: public G4UserRunAction {
public:
MyRunAction(bool isGeantino, G4String geantinoMapsFileName="geantinoMaps.root");
MyRunAction(bool isGeantino, G4String geantinoMapsFileName="geantinoMaps.root", bool isStepStats=false, G4String stepStatsFilename="stepStats.root");
virtual ~MyRunAction();
virtual G4Run* GenerateRun();
......@@ -28,9 +28,11 @@ public:
private:
G4bool fIsPerformance;
G4bool fIsGeantino;
G4bool fIsStepStats;
MyRun* fRun;
G4Timer* fTimer;
G4String fGeantinoMapsFilename;
G4String fStepStatsFilename;
//TO DO: make private and add Get methods
......@@ -45,6 +47,8 @@ public:
int fEtaRad_id;
// ID of the Eta IntLen 1D Profile
int fEtaInt_id;
// ID of the ZRSteps 2D Histogram
int fStepHeatMap_id;
};
#endif
......@@ -18,12 +18,12 @@
G4AnalysisManager* MyRunAction::fMasterAnalysisManager = nullptr;
MyRunAction::MyRunAction(bool isGeantino, G4String geantinoMapFilename) : G4UserRunAction(), fIsPerformance(false), fIsGeantino(isGeantino), fRun(nullptr), fTimer(nullptr), fGeantinoMapsFilename(geantinoMapFilename){
MyRunAction::MyRunAction(bool isGeantino, G4String geantinoMapFilename, bool isStepStats, G4String stepStatsFilename) : G4UserRunAction(), fIsPerformance(false), fIsGeantino(isGeantino), fIsStepStats(isStepStats), fRun(nullptr), fTimer(nullptr), fGeantinoMapsFilename(geantinoMapFilename), fStepStatsFilename(stepStatsFilename){
}
MyRunAction::~MyRunAction() {
if(fIsGeantino)
if(fIsGeantino || fIsStepStats)
delete G4AnalysisManager::Instance();
}
......@@ -98,6 +98,39 @@ void MyRunAction::BeginOfRunAction(const G4Run* /*aRun*/){
}
}
if(fIsStepStats)
{
// Create analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if (isMaster) {
fMasterAnalysisManager = analysisManager;
//G4cout<<"MyRunAction::BeginOfRunAction, created MASTER istance of the G4AnalysisManager: "<<fMasterAnalysisManager<<G4endl;
}
//else
// G4cout<<"MyRunAction::BeginOfRunAction, created WORKER istance of the G4AnalysisManager: "<<analysisManager<<G4endl;
G4cout << "Using G4AnalysisManager type: " << analysisManager->GetType() << G4endl;
analysisManager->SetVerboseLevel(1);
// Open output root file
G4cout<<"\n\nBeginOfRunAction: \n...create a root file using the G4AnalysisManager" << G4endl;
if (!analysisManager->OpenFile(fStepStatsFilename)){
G4cout<<"\nBeginOfRunAction ERROR: File cannot be opened!"<<G4endl;
exit(-1);
} else
G4cout<<"\n...output File "<<fStepStatsFilename<<" opened!"<<G4endl;
const char* stepHeatMapName = "ZRSteps";
if(analysisManager->GetH2Id(stepHeatMapName, false) < 0) {
fStepHeatMap_id = analysisManager->CreateH2(stepHeatMapName,stepHeatMapName,1000,-25000.,25000.,2000,0.,15000.);
// G4cout<<"MyRunAction::BeginOfRunAction: G4AnalysisManager Created ZRSteps 2DHistogram with name: "<<stepHeatMapName<< " and with id: "<<fStepHeatMap_id<<G4endl;
analysisManager->SetH2XAxisTitle(fStepHeatMap_id,"Z[mm]");
analysisManager->SetH2YAxisTitle(fStepHeatMap_id,"R[mm]");
analysisManager->SetH2ZAxisTitle(fStepHeatMap_id,"NumberOfSteps");
}
}
if (isMaster) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment