Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 08:29:17

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 RMC01AnalysisManagerMessenger.cc
0027 /// \brief Implementation of the RMC01AnalysisManagerMessenger class
0028 
0029 //      Class Name:        RMC01AnalysisManagerMessenger
0030 //        Author:               L. Desorgher
0031 //         Organisation:         SpaceIT GmbH
0032 //        Contract:        ESA contract 21435/08/NL/AT
0033 //         Customer:             ESA/ESTEC
0034 //////////////////////////////////////////////////////////////
0035 
0036 #include "RMC01AnalysisManagerMessenger.hh"
0037 
0038 #include "RMC01AnalysisManager.hh"
0039 
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4UIcmdWithADouble.hh"
0042 #include "G4UIdirectory.hh"
0043 #include "G4UnitsTable.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 RMC01AnalysisManagerMessenger::RMC01AnalysisManagerMessenger(RMC01AnalysisManager* analysisManager)
0048   : G4UImessenger(),
0049     fAnalysisManager(analysisManager),
0050     fAnalysisDir(0),
0051     fSetPrecisionForConvergenceTestCmd(0),
0052     fSetExpSpectrumToNormaliseAdjResCmd(0),
0053     fSetPowerLawSpectrumToNormaliseAdjResCmd(0)
0054 {
0055   fAnalysisDir = new G4UIdirectory("/RMC01/analysis/");
0056   fAnalysisDir->SetGuidance("Analysis commands");
0057 
0058   G4UIparameter* fluence_par = new G4UIparameter("Fluence", 'd', true);
0059   fluence_par->SetParameterRange("Fluence > 0");
0060   fluence_par->SetGuidance("Omnidirectional fluence for primary spectrum");
0061 
0062   G4UIparameter* fluence_unit_par = new G4UIparameter("Fluence_unit", 's', true);
0063   fluence_unit_par->SetParameterCandidates("1/cm2 1/m2 cm-2 m-2");
0064 
0065   G4UIparameter* alpha_par = new G4UIparameter("alpha", 'd', true);
0066 
0067   G4UIparameter* e0_par = new G4UIparameter("E0", 'd', true);
0068   e0_par->SetParameterRange("E0 > 0");
0069 
0070   G4UIparameter* e1_par = new G4UIparameter("E1", 'd', true);
0071   e1_par->SetParameterRange("E1 > 0");
0072 
0073   G4UIparameter* e2_par = new G4UIparameter("E2", 'd', true);
0074   e2_par->SetParameterRange("E2 > 0");
0075 
0076   G4UIparameter* e_unit_par = new G4UIparameter("E_unit", 's', true);
0077   e_unit_par->SetParameterCandidates("eV keV MeV GeV TeV");
0078 
0079   G4UIparameter* part_name_par = new G4UIparameter("particle_name", 's', true);
0080   part_name_par->SetParameterCandidates("e- gamma proton ");
0081 
0082   fSetPowerLawSpectrumToNormaliseAdjResCmd =
0083     new G4UIcommand("/RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim", this);
0084   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetGuidance(
0085     "Set the primary spectrum to which adjoint simulation "
0086     "results will be normalised as a power law (Ekin^-alpha).");
0087   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(part_name_par);
0088   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_par);
0089   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_unit_par);
0090   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(alpha_par);
0091   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e1_par);
0092   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e2_par);
0093   fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e_unit_par);
0094   fSetPowerLawSpectrumToNormaliseAdjResCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0095 
0096   fSetExpSpectrumToNormaliseAdjResCmd = new G4UIcommand("/RMC01/analysis/"
0097     "SetExponentialSpectrumForAdjointSim", this);
0098   fSetExpSpectrumToNormaliseAdjResCmd->SetGuidance(
0099     "Set the primary spectrum to which adjoint simulation results"
0100     "will be normalised as exponential (exp(-Ekin/E0)).");
0101   fSetExpSpectrumToNormaliseAdjResCmd
0102     ->SetParameter(new G4UIparameter(*part_name_par));
0103   fSetExpSpectrumToNormaliseAdjResCmd
0104     ->SetParameter(new G4UIparameter(*fluence_par));
0105   fSetExpSpectrumToNormaliseAdjResCmd
0106     ->SetParameter(new G4UIparameter(*fluence_unit_par));
0107   fSetExpSpectrumToNormaliseAdjResCmd
0108     ->SetParameter(new G4UIparameter(*e0_par));
0109   fSetExpSpectrumToNormaliseAdjResCmd
0110     ->SetParameter(new G4UIparameter(*e1_par));
0111   fSetExpSpectrumToNormaliseAdjResCmd
0112     ->SetParameter(new G4UIparameter(*e2_par));
0113   fSetExpSpectrumToNormaliseAdjResCmd
0114     ->SetParameter(new G4UIparameter(*e_unit_par));
0115   fSetExpSpectrumToNormaliseAdjResCmd
0116     ->AvailableForStates(G4State_PreInit, G4State_Idle);
0117   
0118   fSetUserDefinedSpectrumToNormaliseAdjResCmd
0119     = new G4UIcommand("/RMC01/analysis/" "SetTableSpectrumForAdjointSim",this);
0120   fSetUserDefinedSpectrumToNormaliseAdjResCmd
0121     ->SetParameter(new G4UIparameter(*part_name_par));
0122   fSetUserDefinedSpectrumToNormaliseAdjResCmd
0123     ->SetParameter(new G4UIparameter(*fluence_par));
0124   fSetUserDefinedSpectrumToNormaliseAdjResCmd
0125     ->SetParameter(new G4UIparameter(*fluence_unit_par));
0126 
0127   G4UIparameter* is_arbritray_point_wise_par
0128     = new G4UIparameter("Arb",'b',true);
0129   fSetUserDefinedSpectrumToNormaliseAdjResCmd
0130     ->SetParameter(is_arbritray_point_wise_par);
0131 
0132   fSetPrecisionForConvergenceTestCmd
0133     = new G4UIcmdWithADouble("/RMC01/analysis/"
0134     "SetExpectedPrecisionOfResults", this);
0135   fSetPrecisionForConvergenceTestCmd->SetGuidance(
0136     "Set the precision in % that the computed energy deposited "
0137     "in the sensitive volume should reached. If this precision is reached"
0138     " before the end of the run, the run is aborted and the results are "
0139     "registered.");
0140   fSetPrecisionForConvergenceTestCmd->SetParameterName("Precision", true);
0141   fSetPrecisionForConvergenceTestCmd->AvailableForStates(G4State_PreInit,
0142                                                          G4State_Idle);
0143 }
0144 
0145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0146 
0147 RMC01AnalysisManagerMessenger::~RMC01AnalysisManagerMessenger()
0148 { if (fAnalysisDir) delete fAnalysisDir;
0149 }
0150 
0151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0152 
0153 void RMC01AnalysisManagerMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0154 {
0155   if (command == fSetPowerLawSpectrumToNormaliseAdjResCmd)
0156   {
0157     G4double alpha, e1, e2, fluence;
0158     G4String f_unit, e_unit, part_name;
0159     const char* nv = (const char*)newValue;
0160     std::istringstream is(nv);
0161     is >> part_name >> fluence >> f_unit >> alpha >> e1 >> e2 >> e_unit;
0162 
0163     G4double factor_f_unit = 1 / cm2;
0164     if (f_unit == "1/m2" || f_unit == "m-2") factor_f_unit = 1 / m2;
0165     fluence *= factor_f_unit;
0166     e1 *= G4UnitDefinition::GetValueOf(e_unit);
0167     e2 *= G4UnitDefinition::GetValueOf(e_unit);
0168     fAnalysisManager->SetPrimaryPowerLawSpectrumForAdjointSim(part_name, fluence, alpha, e1, e2);
0169   }
0170   else if (command == fSetExpSpectrumToNormaliseAdjResCmd)
0171   {
0172     G4double e0, e1, e2, fluence;
0173     G4String f_unit, e_unit, part_name;
0174     const char* nv = (const char*)newValue;
0175     std::istringstream is(nv);
0176     is >> part_name >> fluence >> f_unit >> e0 >> e1 >> e2 >> e_unit;
0177 
0178     G4double factor_f_unit = 1 / cm2;
0179     if (f_unit == "1/m2" || f_unit == "m-2") factor_f_unit = 1 / m2;
0180 
0181     fluence *= factor_f_unit;
0182     e0 *= G4UnitDefinition::GetValueOf(e_unit);
0183     e1 *= G4UnitDefinition::GetValueOf(e_unit);
0184     e2 *= G4UnitDefinition::GetValueOf(e_unit);
0185 
0186     fAnalysisManager
0187       ->SetPrimaryExpSpectrumForAdjointSim(part_name, fluence, e0, e1, e2);
0188   }
0189   else if( command == fSetUserDefinedSpectrumToNormaliseAdjResCmd)
0190   {
0191     G4double  fluence;
0192     G4String  part_name,f_unit;
0193     G4bool is_arbitrary_point_wise;
0194     const char* nv = (const char*)newValue;
0195     std::istringstream is(nv);
0196     is >> part_name>>fluence>>f_unit>>is_arbitrary_point_wise;
0197     G4cout<< is_arbitrary_point_wise<<std::endl;
0198     G4cout<< nv<<std::endl;
0199 
0200     G4double factor_f_unit=1/cm2;
0201     if (f_unit == "1/m2" || f_unit =="m-2")
0202       factor_f_unit=1/m2;
0203 
0204     fluence*=factor_f_unit;
0205     fAnalysisManager
0206       ->SetUserDefinedSpectrumPointForAdjointSim(part_name, fluence,
0207                                                  is_arbitrary_point_wise);
0208    }
0209   else if (command == fSetPrecisionForConvergenceTestCmd)
0210   {
0211     fAnalysisManager
0212       ->SetPrecision(fSetPrecisionForConvergenceTestCmd
0213                      ->GetNewDoubleValue(newValue));
0214   }
0215 }
0216 
0217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......