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4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/HGCal_testbeam/src/PrimaryGeneratorMessenger.cc (Version 11.3.0) and /examples/advanced/HGCal_testbeam/src/PrimaryGeneratorMessenger.cc (Version 10.7)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 #include "PrimaryGeneratorMessenger.hh"            26 #include "PrimaryGeneratorMessenger.hh"
 27 #include "PrimaryGeneratorAction.hh"               27 #include "PrimaryGeneratorAction.hh"
 28                                                    28 
 29 #include "G4UIcmdWithABool.hh"                     29 #include "G4UIcmdWithABool.hh"
 30 #include "G4UIcmdWithADouble.hh"                   30 #include "G4UIcmdWithADouble.hh"
 31 #include "G4UIcmdWithADoubleAndUnit.hh"            31 #include "G4UIcmdWithADoubleAndUnit.hh"
 32 #include "G4UIcmdWithAString.hh"                   32 #include "G4UIcmdWithAString.hh"
 33 #include "G4UIcmdWithAnInteger.hh"                 33 #include "G4UIcmdWithAnInteger.hh"
 34 #include "G4UIdirectory.hh"                        34 #include "G4UIdirectory.hh"
 35                                                    35 
 36 //....oooOO0OOooo........oooOO0OOooo........oo     36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 37                                                    37 
 38 PrimaryGeneratorMessenger::PrimaryGeneratorMes     38 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
 39     PrimaryGeneratorAction *aPrimaryGeneratorA     39     PrimaryGeneratorAction *aPrimaryGeneratorAction)
 40     : fPrimaryGenerator(aPrimaryGeneratorActio     40     : fPrimaryGenerator(aPrimaryGeneratorAction) {
 41   fDirectory = new G4UIdirectory("/HGCalTestbe     41   fDirectory = new G4UIdirectory("/HGCalTestbeam/generator/");
 42   fDirectory->SetGuidance("Primary generator c     42   fDirectory->SetGuidance("Primary generator control commands.");
 43                                                    43 
 44 #ifdef WITHROOT                                    44 #ifdef WITHROOT
 45   fReadInputCmd =                                  45   fReadInputCmd =
 46       new G4UIcmdWithABool("/HGCalTestbeam/gen     46       new G4UIcmdWithABool("/HGCalTestbeam/generator/readInputFile", this);
 47   fReadInputCmd->SetGuidance(                      47   fReadInputCmd->SetGuidance(
 48       "If instead of particle gun, particle da     48       "If instead of particle gun, particle data should be read from file.");
 49   fReadInputCmd->SetParameterName("ifInput", t     49   fReadInputCmd->SetParameterName("ifInput", true);
 50   fReadInputCmd->SetDefaultValue(false);           50   fReadInputCmd->SetDefaultValue(false);
 51                                                    51 
 52   fPathInputCmd =                                  52   fPathInputCmd =
 53       new G4UIcmdWithAString("/HGCalTestbeam/g     53       new G4UIcmdWithAString("/HGCalTestbeam/generator/pathInputFile", this);
 54   fPathInputCmd->SetGuidance("Path to input fi     54   fPathInputCmd->SetGuidance("Path to input file containing particle data.");
 55   fPathInputCmd->SetParameterName("path", true     55   fPathInputCmd->SetParameterName("path", true);
 56                                                    56 
 57   fStartFromEventCmd =                             57   fStartFromEventCmd =
 58       new G4UIcmdWithAnInteger("/HGCalTestbeam     58       new G4UIcmdWithAnInteger("/HGCalTestbeam/generator/startFromEvent", this);
 59   fStartFromEventCmd->SetGuidance(                 59   fStartFromEventCmd->SetGuidance(
 60       "From which event in the file HGCalTestb     60       "From which event in the file HGCalTestbeam should be started.");
 61   fStartFromEventCmd->SetParameterName("startF     61   fStartFromEventCmd->SetParameterName("startFrom", true);
 62   fStartFromEventCmd->SetDefaultValue(0);          62   fStartFromEventCmd->SetDefaultValue(0);
 63 #endif                                             63 #endif
 64   fMomentumSpreadCmd =                             64   fMomentumSpreadCmd =
 65       new G4UIcmdWithADouble("/HGCalTestbeam/g     65       new G4UIcmdWithADouble("/HGCalTestbeam/generator/momentumSpread", this);
 66   fMomentumSpreadCmd->SetGuidance("For particl     66   fMomentumSpreadCmd->SetGuidance("For particle gun generator:");
 67   fMomentumSpreadCmd->SetGuidance(                 67   fMomentumSpreadCmd->SetGuidance(
 68       "Gaussian momentum spread relative to gu     68       "Gaussian momentum spread relative to gun energy");
 69   fMomentumSpreadCmd->SetGuidance("(e.g. 0.05      69   fMomentumSpreadCmd->SetGuidance("(e.g. 0.05 means 5% * gun energy))");
 70   fMomentumSpreadCmd->SetParameterName("moment     70   fMomentumSpreadCmd->SetParameterName("momentumSpread", true);
 71   fMomentumSpreadCmd->SetRange("momentumSpread     71   fMomentumSpreadCmd->SetRange("momentumSpread>=0");
 72   fMomentumSpreadCmd->SetDefaultValue(0);          72   fMomentumSpreadCmd->SetDefaultValue(0);
 73                                                    73 
 74   fBeamSpreadTypeCmd =                             74   fBeamSpreadTypeCmd =
 75       new G4UIcmdWithAString("/HGCalTestbeam/g     75       new G4UIcmdWithAString("/HGCalTestbeam/generator/beamSpread", this);
 76   fBeamSpreadTypeCmd->SetGuidance("Type of bea     76   fBeamSpreadTypeCmd->SetGuidance("Type of beam profile spread.");
 77   fBeamSpreadTypeCmd->SetParameterName("beamSp     77   fBeamSpreadTypeCmd->SetParameterName("beamSpreadType", true);
 78   fBeamSpreadTypeCmd->SetCandidates("none Gaus     78   fBeamSpreadTypeCmd->SetCandidates("none Gaussian flat");
 79   fBeamSpreadTypeCmd->SetDefaultValue("none");     79   fBeamSpreadTypeCmd->SetDefaultValue("none");
 80                                                    80 
 81   fBeamSpreadXCmd = new G4UIcmdWithADoubleAndU     81   fBeamSpreadXCmd = new G4UIcmdWithADoubleAndUnit(
 82       "/HGCalTestbeam/generator/beamSpreadX",      82       "/HGCalTestbeam/generator/beamSpreadX", this);
 83   fBeamSpreadXCmd->SetGuidance("Defines sigma_     83   fBeamSpreadXCmd->SetGuidance("Defines sigma_X for Gaussian spread, or "
 84                                "half-side rang     84                                "half-side range for flat spread.");
 85   fBeamSpreadXCmd->SetParameterName("sigmaBeam     85   fBeamSpreadXCmd->SetParameterName("sigmaBeamX", true, true);
 86   fBeamSpreadXCmd->SetRange("sigmaBeamX>=0");      86   fBeamSpreadXCmd->SetRange("sigmaBeamX>=0");
 87   fBeamSpreadXCmd->SetDefaultUnit("cm");           87   fBeamSpreadXCmd->SetDefaultUnit("cm");
 88   fBeamSpreadXCmd->SetUnitCandidates("micron m     88   fBeamSpreadXCmd->SetUnitCandidates("micron mm cm m km");
 89                                                    89 
 90   fBeamSpreadYCmd = new G4UIcmdWithADoubleAndU     90   fBeamSpreadYCmd = new G4UIcmdWithADoubleAndUnit(
 91       "/HGCalTestbeam/generator/beamSpreadY",      91       "/HGCalTestbeam/generator/beamSpreadY", this);
 92   fBeamSpreadYCmd->SetGuidance("Defines sigma_     92   fBeamSpreadYCmd->SetGuidance("Defines sigma_Y for Gaussian spread, or "
 93                                "half-side rang     93                                "half-side range for flat spread.");
 94   fBeamSpreadYCmd->SetParameterName("sigmaBeam     94   fBeamSpreadYCmd->SetParameterName("sigmaBeamY", true, true);
 95   fBeamSpreadYCmd->SetRange("sigmaBeamY>=0");      95   fBeamSpreadYCmd->SetRange("sigmaBeamY>=0");
 96   fBeamSpreadYCmd->SetDefaultUnit("cm");           96   fBeamSpreadYCmd->SetDefaultUnit("cm");
 97   fBeamSpreadYCmd->SetUnitCandidates("micron m     97   fBeamSpreadYCmd->SetUnitCandidates("micron mm cm m km");
 98                                                    98 
 99   fBeamZ0Cmd =                                     99   fBeamZ0Cmd =
100       new G4UIcmdWithADoubleAndUnit("/HGCalTes    100       new G4UIcmdWithADoubleAndUnit("/HGCalTestbeam/generator/beamZ0", this);
101   fBeamZ0Cmd->SetGuidance(                        101   fBeamZ0Cmd->SetGuidance(
102       "Beam position along the beam line (defa    102       "Beam position along the beam line (default: edge of the world volume).");
103   fBeamZ0Cmd->SetParameterName("z0", true, tru    103   fBeamZ0Cmd->SetParameterName("z0", true, true);
104   fBeamZ0Cmd->SetDefaultUnit("cm");               104   fBeamZ0Cmd->SetDefaultUnit("cm");
105   fBeamZ0Cmd->SetUnitCandidates("micron mm cm     105   fBeamZ0Cmd->SetUnitCandidates("micron mm cm m km");
106 }                                                 106 }
107                                                   107 
108 //....oooOO0OOooo........oooOO0OOooo........oo    108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109                                                   109 
110 PrimaryGeneratorMessenger::~PrimaryGeneratorMe    110 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger() {
111   delete fDirectory;                              111   delete fDirectory;
112 #ifdef WITHROOT                                   112 #ifdef WITHROOT
113   delete fReadInputCmd;                           113   delete fReadInputCmd;
114   delete fPathInputCmd;                           114   delete fPathInputCmd;
115   delete fStartFromEventCmd;                      115   delete fStartFromEventCmd;
116 #endif                                            116 #endif
117   delete fMomentumSpreadCmd;                      117   delete fMomentumSpreadCmd;
118   delete fBeamSpreadTypeCmd;                      118   delete fBeamSpreadTypeCmd;
119   delete fBeamSpreadXCmd;                         119   delete fBeamSpreadXCmd;
120   delete fBeamSpreadYCmd;                         120   delete fBeamSpreadYCmd;
121   delete fBeamZ0Cmd;                              121   delete fBeamZ0Cmd;
122 }                                                 122 }
123                                                   123 
124 //....oooOO0OOooo........oooOO0OOooo........oo    124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125                                                   125 
126 void PrimaryGeneratorMessenger::SetNewValue(G4    126 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand *command,
127                                             G4    127                                             G4String newValues) {
128   if (command == fMomentumSpreadCmd) {            128   if (command == fMomentumSpreadCmd) {
129     fPrimaryGenerator->SetMomentumSpread(         129     fPrimaryGenerator->SetMomentumSpread(
130         fMomentumSpreadCmd->GetNewDoubleValue(    130         fMomentumSpreadCmd->GetNewDoubleValue(newValues));
131   } else if (command == fBeamSpreadTypeCmd) {     131   } else if (command == fBeamSpreadTypeCmd) {
132     fPrimaryGenerator->SetBeamSpreadType(newVa    132     fPrimaryGenerator->SetBeamSpreadType(newValues);
133   } else if (command == fBeamSpreadXCmd) {        133   } else if (command == fBeamSpreadXCmd) {
134     fPrimaryGenerator->SetBeamSpreadX(            134     fPrimaryGenerator->SetBeamSpreadX(
135         fBeamSpreadXCmd->GetNewDoubleValue(new    135         fBeamSpreadXCmd->GetNewDoubleValue(newValues));
136   } else if (command == fBeamSpreadYCmd) {        136   } else if (command == fBeamSpreadYCmd) {
137     fPrimaryGenerator->SetBeamSpreadY(            137     fPrimaryGenerator->SetBeamSpreadY(
138         fBeamSpreadYCmd->GetNewDoubleValue(new    138         fBeamSpreadYCmd->GetNewDoubleValue(newValues));
139   } else if (command == fBeamZ0Cmd) {             139   } else if (command == fBeamZ0Cmd) {
140     fPrimaryGenerator->SetBeamZ0(fBeamZ0Cmd->G    140     fPrimaryGenerator->SetBeamZ0(fBeamZ0Cmd->GetNewDoubleValue(newValues));
141   }                                               141   }
142 #ifdef WITHROOT                                   142 #ifdef WITHROOT
143   else if (command == fReadInputCmd) {            143   else if (command == fReadInputCmd) {
144     fPrimaryGenerator->SetIfUseInputFiles(        144     fPrimaryGenerator->SetIfUseInputFiles(
145         fReadInputCmd->GetNewBoolValue(newValu    145         fReadInputCmd->GetNewBoolValue(newValues));
146   } else if (command == fPathInputCmd) {          146   } else if (command == fPathInputCmd) {
147     fPrimaryGenerator->SetInputFiles(newValues    147     fPrimaryGenerator->SetInputFiles(newValues);
148   } else if (command == fStartFromEventCmd) {     148   } else if (command == fStartFromEventCmd) {
149     fPrimaryGenerator->SetStartFromEvent(         149     fPrimaryGenerator->SetStartFromEvent(
150         fStartFromEventCmd->GetNewIntValue(new    150         fStartFromEventCmd->GetNewIntValue(newValues));
151   }                                               151   }
152 #endif                                            152 #endif
153 }                                                 153 }
154                                                   154 
155 //....oooOO0OOooo........oooOO0OOooo........oo    155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
156                                                   156 
157 G4String PrimaryGeneratorMessenger::GetCurrent    157 G4String PrimaryGeneratorMessenger::GetCurrentValue(G4UIcommand *command) {
158   G4String cv;                                    158   G4String cv;
159   if (command == fMomentumSpreadCmd) {            159   if (command == fMomentumSpreadCmd) {
160     cv = fMomentumSpreadCmd->ConvertToString(     160     cv = fMomentumSpreadCmd->ConvertToString(
161         fPrimaryGenerator->GetMomentumSpread()    161         fPrimaryGenerator->GetMomentumSpread());
162   } else if (command == fBeamSpreadTypeCmd) {     162   } else if (command == fBeamSpreadTypeCmd) {
163     cv = fPrimaryGenerator->GetBeamSpreadType(    163     cv = fPrimaryGenerator->GetBeamSpreadType();
164   } else if (command == fBeamSpreadXCmd) {        164   } else if (command == fBeamSpreadXCmd) {
165     cv = fBeamSpreadXCmd->ConvertToString(fPri    165     cv = fBeamSpreadXCmd->ConvertToString(fPrimaryGenerator->GetBeamSpreadX());
166   } else if (command == fBeamSpreadYCmd) {        166   } else if (command == fBeamSpreadYCmd) {
167     cv = fBeamSpreadYCmd->ConvertToString(fPri    167     cv = fBeamSpreadYCmd->ConvertToString(fPrimaryGenerator->GetBeamSpreadY());
168   } else if (command == fBeamZ0Cmd) {             168   } else if (command == fBeamZ0Cmd) {
169     cv = fBeamZ0Cmd->ConvertToString(fPrimaryG    169     cv = fBeamZ0Cmd->ConvertToString(fPrimaryGenerator->GetBeamZ0());
170   }                                               170   }
171 #ifdef WITHROOT                                   171 #ifdef WITHROOT
172   else if (command == fReadInputCmd) {            172   else if (command == fReadInputCmd) {
173     cv =                                          173     cv =
174         fReadInputCmd->ConvertToString(fPrimar    174         fReadInputCmd->ConvertToString(fPrimaryGenerator->GetIfUseInputFiles());
175   } else if (command == fPathInputCmd) {          175   } else if (command == fPathInputCmd) {
176     cv = fPrimaryGenerator->GetInputFiles();      176     cv = fPrimaryGenerator->GetInputFiles();
177   }                                               177   }
178 #endif                                            178 #endif
179   return cv;                                      179   return cv;
180 }                                                 180 }
181                                                   181