File indexing completed on 2025-01-31 09:22:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include "PurgMagRunAction.hh"
0038
0039 #include "G4Run.hh"
0040 #include "G4UnitsTable.hh"
0041 #include "G4AnalysisManager.hh"
0042 #include "Randomize.hh"
0043
0044
0045
0046 PurgMagRunAction::PurgMagRunAction()
0047 {
0048 saveRndm = 1;
0049 }
0050
0051
0052
0053 PurgMagRunAction::~PurgMagRunAction()
0054 {}
0055
0056
0057
0058 void PurgMagRunAction::BeginOfRunAction(const G4Run* aRun)
0059 {
0060
0061 Book();
0062
0063 if (IsMaster())
0064 G4cout << "---> Run " << aRun->GetRunID() << " (master) start."
0065 << G4endl;
0066 else
0067 G4cout << "---> Run " << aRun->GetRunID() << " (worker) start."
0068 << G4endl;
0069
0070
0071
0072 if (saveRndm > 0 && IsMaster())
0073 {
0074 G4Random::showEngineStatus();
0075 G4Random::saveEngineStatus("beginOfRun.rndm");
0076 }
0077
0078 }
0079
0080
0081
0082
0083 void PurgMagRunAction::EndOfRunAction(const G4Run* aRun)
0084 {
0085 if (IsMaster())
0086 G4cout << "Total number of event = " << aRun->GetNumberOfEvent() << G4endl;
0087 else
0088 G4cout << "Partial number of event in this worker = "
0089 << aRun->GetNumberOfEvent() << G4endl;
0090
0091
0092 if (IsMaster())
0093 {
0094
0095 if (saveRndm == 1)
0096 {
0097 G4Random::showEngineStatus();
0098 G4Random::saveEngineStatus("endOfRun.rndm");
0099 }
0100 }
0101 }
0102
0103
0104
0105 void PurgMagRunAction::Book()
0106 {
0107
0108 G4AnalysisManager* man = G4AnalysisManager::Instance();
0109 man->SetDefaultFileType("csv");
0110
0111
0112 man->OpenFile("purgmag");
0113 man->SetFirstNtupleId(1);
0114
0115
0116
0117 man->CreateNtuple("n101", "Electron");
0118 man->CreateNtupleDColumn("ex");
0119 man->CreateNtupleDColumn("ey");
0120 man->CreateNtupleDColumn("ez");
0121 man->CreateNtupleDColumn("ee");
0122 man->CreateNtupleDColumn("epx");
0123 man->CreateNtupleDColumn("epy");
0124 man->CreateNtupleDColumn("epz");
0125 man->FinishNtuple();
0126 G4cout << "Ntuple-1 created" << G4endl;
0127
0128
0129
0130 man->CreateNtuple("n102", "Gamma");
0131 man->CreateNtupleDColumn("gx");
0132 man->CreateNtupleDColumn("gy");
0133 man->CreateNtupleDColumn("gz");
0134 man->CreateNtupleDColumn("ge");
0135 man->CreateNtupleDColumn("gpx");
0136 man->CreateNtupleDColumn("gpy");
0137 man->CreateNtupleDColumn("gpz");
0138 man->FinishNtuple();
0139 G4cout << "Ntuple-2 created" << G4endl;
0140
0141
0142
0143 man->CreateNtuple("n103", "Positron");
0144 man->CreateNtupleDColumn("px");
0145 man->CreateNtupleDColumn("py");
0146 man->CreateNtupleDColumn("pz");
0147 man->CreateNtupleDColumn("pe");
0148 man->CreateNtupleDColumn("ppx");
0149 man->CreateNtupleDColumn("ppy");
0150 man->CreateNtupleDColumn("ppz");
0151 man->FinishNtuple();
0152 G4cout << "Ntuple-3 created" << G4endl;
0153
0154 return;
0155 }
0156
0157
0158