Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:47

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file biasing/ReverseMC01/src/RMC01AnalysisManagerMessenger.cc
0027 /// \brief Implementation of the RMC01AnalysisManagerMessenger class
0028 //
0029 //
0030 //////////////////////////////////////////////////////////////
0031 //      Class Name:        RMC01AnalysisManagerMessenger
0032 //        Author:               L. Desorgher
0033 //         Organisation:         SpaceIT GmbH
0034 //        Contract:        ESA contract 21435/08/NL/AT
0035 //         Customer:             ESA/ESTEC
0036 //////////////////////////////////////////////////////////////
0037 
0038 #include "RMC01AnalysisManagerMessenger.hh"
0039 
0040 #include "RMC01AnalysisManager.hh"
0041 
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4UIcmdWithADouble.hh"
0044 #include "G4UIdirectory.hh"
0045 #include "G4UnitsTable.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 RMC01AnalysisManagerMessenger::RMC01AnalysisManagerMessenger(RMC01AnalysisManager* analysisManager)
0050   : G4UImessenger(),
0051     fAnalysisManager(analysisManager),
0052     fAnalysisDir(0),
0053     fSetPrecisionForConvergenceTestCmd(0),
0054     fSetExpSpectrumToNormaliseAdjResCmd(0),
0055     fSetPowerLawSpectrumToNormaliseAdjResCmd(0)
0056 {
0057   fAnalysisDir = new G4UIdirectory("/RMC01/analysis/");
0058   fAnalysisDir->SetGuidance("Analysis commands");
0059 
0060   G4UIparameter* fluence_par = new G4UIparameter("Fluence", 'd', true);
0061   fluence_par->SetParameterRange("Fluence > 0");
0062   fluence_par->SetGuidance("Omnidirectional fluence for primary spectrum");
0063 
0064   G4UIparameter* fluence_unit_par = new G4UIparameter("Fluence_unit", 's', true);
0065   fluence_unit_par->SetParameterCandidates("1/cm2 1/m2 cm-2 m-2");
0066 
0067   G4UIparameter* alpha_par = new G4UIparameter("alpha", 'd', true);
0068 
0069   G4UIparameter* e0_par = new G4UIparameter("E0", 'd', true);
0070   e0_par->SetParameterRange("E0 > 0");
0071 
0072   G4UIparameter* e1_par = new G4UIparameter("E1", 'd', true);
0073   e1_par->SetParameterRange("E1 > 0");
0074 
0075   G4UIparameter* e2_par = new G4UIparameter("E2", 'd', true);
0076   e2_par->SetParameterRange("E2 > 0");
0077 
0078   G4UIparameter* e_unit_par = new G4UIparameter("E_unit", 's', true);
0079   e_unit_par->SetParameterCandidates("eV keV MeV GeV TeV");
0080 
0081   G4UIparameter* part_name_par = new G4UIparameter("particle_name", 's', true);
0082   part_name_par->SetParameterCandidates("e- gamma proton ");
0083 
0084   fSetPowerLawSpectrumToNormaliseAdjResCmd =
0085     new G4UIcommand("/RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim", this);
0086   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetGuidance(
0087     "Set the primary spectrum to which adjoint simulation "
0088     "results will be normalised as a power law (Ekin^-alpha).");
0089   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(part_name_par);
0090   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_par);
0091   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_unit_par);
0092   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(alpha_par);
0093   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e1_par);
0094   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e2_par);
0095   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e_unit_par);
0096   fSetPowerLawSpectrumToNormaliseAdjResCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0097 
0098   fSetExpSpectrumToNormaliseAdjResCmd = new G4UIcommand(
0099     "/RMC01/analysis/"
0100     "SetExponentialSpectrumForAdjointSim",
0101     this);
0102   fSetExpSpectrumToNormaliseAdjResCmd->SetGuidance(
0103     "Set the primary spectrum to which adjoint simulation results"
0104     "will be normalised as exponential (exp(-Ekin/E0)).");
0105   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*part_name_par));
0106   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*fluence_par));
0107   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*fluence_unit_par));
0108   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*e0_par));
0109   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*e1_par));
0110   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*e2_par));
0111   fSetExpSpectrumToNormaliseAdjResCmd->SetParameter(new G4UIparameter(*e_unit_par));
0112   fSetExpSpectrumToNormaliseAdjResCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0113 
0114   fSetPrecisionForConvergenceTestCmd = new G4UIcmdWithADouble(
0115     "/RMC01/analysis/"
0116     "SetExpectedPrecisionOfResults",
0117     this);
0118   fSetPrecisionForConvergenceTestCmd->SetGuidance(
0119     "Set the precision in % that the computed energy deposited "
0120     "in the sensitive volume should reached. If this precision is reached"
0121     " before the end of the run, the run is aborted and the results are "
0122     "registered.");
0123   fSetPrecisionForConvergenceTestCmd->SetParameterName("Precision", true);
0124   fSetPrecisionForConvergenceTestCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0125 }
0126 
0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0128 
0129 RMC01AnalysisManagerMessenger::~RMC01AnalysisManagerMessenger()
0130 {
0131   delete fAnalysisDir;
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0135 
0136 void RMC01AnalysisManagerMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0137 {
0138   if (command == fSetPowerLawSpectrumToNormaliseAdjResCmd) {
0139     G4double alpha, e1, e2, fluence;
0140     G4String f_unit, e_unit, part_name;
0141     const char* nv = (const char*)newValue;
0142     std::istringstream is(nv);
0143     is >> part_name >> fluence >> f_unit >> alpha >> e1 >> e2 >> e_unit;
0144 
0145     G4double factor_f_unit = 1 / cm2;
0146     if (f_unit == "1/m2" || f_unit == "m-2") factor_f_unit = 1 / m2;
0147     fluence *= factor_f_unit;
0148     e1 *= G4UnitDefinition::GetValueOf(e_unit);
0149     e2 *= G4UnitDefinition::GetValueOf(e_unit);
0150     fAnalysisManager->SetPrimaryPowerLawSpectrumForAdjointSim(part_name, fluence, alpha, e1, e2);
0151   }
0152   else if (command == fSetExpSpectrumToNormaliseAdjResCmd) {
0153     G4double e0, e1, e2, fluence;
0154     G4String f_unit, e_unit, part_name;
0155     const char* nv = (const char*)newValue;
0156     std::istringstream is(nv);
0157     is >> part_name >> fluence >> f_unit >> e0 >> e1 >> e2 >> e_unit;
0158 
0159     G4double factor_f_unit = 1 / cm2;
0160     if (f_unit == "1/m2" || f_unit == "m-2") factor_f_unit = 1 / m2;
0161 
0162     fluence *= factor_f_unit;
0163     e0 *= G4UnitDefinition::GetValueOf(e_unit);
0164     e1 *= G4UnitDefinition::GetValueOf(e_unit);
0165     e2 *= G4UnitDefinition::GetValueOf(e_unit);
0166 
0167     fAnalysisManager->SetPrimaryExpSpectrumForAdjointSim(part_name, fluence, e0, e1, e2);
0168   }
0169   else if (command == fSetPrecisionForConvergenceTestCmd) {
0170     fAnalysisManager->SetPrecision(fSetPrecisionForConvergenceTestCmd->GetNewDoubleValue(newValue));
0171   }
0172 }
0173 
0174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......