#include "G4RunManager.hh" #include "G4UImanager.hh" #include "Randomize.hh" #include "DetectorConstruction.hh" #include "PhysicsList.hh" #include "PrimaryGeneratorAction.hh" #include "RunAction.hh" #include "EventAction.hh" #include "TrackingAction.hh" #include "SteppingAction.hh" #include "SteppingVerbose.hh" #include "StackingAction.hh" #include "HistoManager.hh" //uprava #include "globals.hh" #include #include "G4S.hh" #include "G4Score_Export.h" //konec upravy //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // output params G4double y; G4double z; G4double energy; G4double theta; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // inner variables G4bool isInitialized = false; TrackingAction* trackingaction; G4RunManager* runManager; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // access functions G4Score_EXPORT G4double getPosY() // nm { return y; } G4Score_EXPORT G4double getPosZ() // nm { return z; } G4Score_EXPORT G4double getEnergy() // eV { return energy; } G4Score_EXPORT G4double getTheta() // deg { return theta; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Score_EXPORT G4bool traceOneElectron(G4String primaryEnergy) { // tbd: add parameters angle and pressure if (isInitialized) { // get the pointer to the User Interface manager G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/control/verbose 0"); UI->ApplyCommand("/gps/verbose 0"); UI->ApplyCommand("/tracking/verbose 0"); UI->ApplyCommand("/event/verbose 0"); UI->ApplyCommand("/process/verbose 0"); UI->ApplyCommand("/run/verbose 0"); UI->ApplyCommand("/cuts/verbose 0"); UI->ApplyCommand("/particle/verbose 0"); UI->ApplyCommand("/run/initialize"); UI->ApplyCommand("/gun/energy " + primaryEnergy + " eV"); UI->ApplyCommand("/run/beamOn 1"); // get particle data y = trackingaction->getYOut(); z = trackingaction->getZOut(); energy = trackingaction->getEnergyOut(); theta = trackingaction->getThetaOut(); return true; } else { return false; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void initializeRunManager() { G4cout << "Inside initializeRunManager().\n"; //choose the Random engine G4cout << "CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine)\n"; CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); //my Verbose output class G4cout << "G4VSteppingVerbose::SetInstance(new SteppingVerbose)\n"; G4VSteppingVerbose::SetInstance(new SteppingVerbose); // Construct the default run manager G4cout << "G4RunManager * runManager = new G4RunManager;\n"; runManager = new G4RunManager; G4cout << "Leaving initializeRunManager().\n"; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Score_EXPORT void initializeGeant() { G4cout << "Inside initializeGeant().\n"; initializeRunManager(); // set mandatory initialization classes G4cout << "set mandatory initialization classes\n"; DetectorConstruction* detector; detector = new DetectorConstruction; runManager->SetUserInitialization(detector); runManager->SetUserInitialization(new PhysicsList()); HistoManager* histo = new HistoManager(); // set user action classes // //primaryGenerator G4cout << "primaryGenerator\n"; PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector); runManager->SetUserAction(primary); //runAction G4cout << "runAction\n"; RunAction* runaction = new RunAction(detector, primary, histo); runManager->SetUserAction(runaction); //eventAction G4cout << "eventAction\n"; EventAction* eventaction = new EventAction(runaction, histo); runManager->SetUserAction(eventaction); //trackAction G4cout << "trackAction\n"; trackingaction = new TrackingAction(detector, runaction, eventaction, histo); runManager->SetUserAction(trackingaction); //stepAction G4cout << "stepAction\n"; SteppingAction* steppingaction = new SteppingAction(detector, runaction, eventaction, histo); runManager->SetUserAction(steppingaction); //stackAction G4cout << "stackAction\n"; StackingAction* stackingaction = new StackingAction(runaction, eventaction, histo); runManager->SetUserAction(stackingaction); // job termination // G4cout << "job termination\n"; delete histo; delete runManager; isInitialized = true; G4cout << "Leaving initializeGeant().\n"; }