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2 ] [ 10.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/extended/eventgenerator/HepMC/HepMCEx01/src/HepMCG4PythiaMessenger.cc (Version 11.3.0) and /examples/extended/eventgenerator/HepMC/HepMCEx01/src/HepMCG4PythiaMessenger.cc (Version 8.1)


  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 /// \file eventgenerator/HepMC/HepMCEx01/src/H <<  26 // ====================================================================
 27 /// \brief Implementation of the HepMCG4Pythia << 
 28 //                                                 27 //
                                                   >>  28 //   HepMCG4PythiaMessenger.cc
                                                   >>  29 //   $Id: HepMCG4PythiaMessenger.cc,v 1.5 2006/06/29 17:06:45 gunter Exp $
 29 //                                                 30 //
 30                                                <<  31 // ====================================================================
 31 #ifdef G4LIB_USE_PYTHIA                        <<  32 #include "HepMCG4PythiaMessenger.hh"
 32                                                <<  33 #include "HepMCG4PythiaInterface.hh"
 33 #  include "HepMCG4PythiaMessenger.hh"         <<  34 
 34                                                <<  35 #include <sstream>
 35 #  include "HepMCG4PythiaInterface.hh"         <<  36 #include <fstream>
 36                                                <<  37 
 37 #  include "G4UIcmdWithAString.hh"             <<  38 #include "G4UIdirectory.hh"
 38 #  include "G4UIcmdWithAnInteger.hh"           <<  39 #include "G4UIcmdWithoutParameter.hh"
 39 #  include "G4UIcmdWithoutParameter.hh"        <<  40 #include "G4UIcmdWithAString.hh"
 40 #  include "G4UIdirectory.hh"                  <<  41 #include "G4UIcmdWithAnInteger.hh"
 41                                                <<  42 
 42 #  include <fstream>                           <<  43 ////////////////////////////////////////////////////////////////////////////
 43 #  include <sstream>                           <<  44 HepMCG4PythiaMessenger::HepMCG4PythiaMessenger(HepMCG4PythiaInterface* agen)
 44                                                <<  45   : gen(agen)
 45 //....oooOO0OOooo........oooOO0OOooo........oo <<  46 ////////////////////////////////////////////////////////////////////////////
 46 HepMCG4PythiaMessenger::HepMCG4PythiaMessenger << 
 47 {                                                  47 {
 48   dir = new G4UIdirectory("/generator/pythia/" <<  48   dir= new G4UIdirectory("/generator/pythia/");
 49   dir->SetGuidance("Commands for Pythia event  <<  49   dir-> SetGuidance("Commands for Pythia event generation");
 50                                                    50 
 51   verbose = new G4UIcmdWithAnInteger("/generat <<  51   verbose= new G4UIcmdWithAnInteger("/generator/pythia/verbose",this);
 52   verbose->SetGuidance("set verbose level");   <<  52   verbose-> SetGuidance("set verbose level");
 53   verbose->SetParameterName("verboseLevel", fa <<  53   verbose-> SetParameterName("verboseLevel", false, false);
 54   verbose->SetRange("verboseLevel>=0 && verbos <<  54   verbose-> SetRange("verboseLevel>=0 && verboseLevel<=2");
 55                                                <<  55 
 56   mpylist = new G4UIcmdWithAnInteger("/generat <<  56   mpylist= new G4UIcmdWithAnInteger("/generator/pythia/pylist",this);
 57   mpylist->SetGuidance("set argument of pylist <<  57   mpylist-> SetGuidance("set argument of pylist (not called if mlist=0)");
 58   mpylist->SetParameterName("mlist", false, fa <<  58   mpylist-> SetParameterName("mlist", false, false);
 59   mpylist->SetRange("mlist>=0 && mlist<=3");   <<  59   mpylist-> SetRange("mlist>=0 && mlist<=3");
 60                                                <<  60 
 61   print = new G4UIcmdWithoutParameter("/genera <<  61   print= new G4UIcmdWithoutParameter("/generator/pythia/print", this);
 62   print->SetGuidance("print user information." <<  62   print-> SetGuidance("print user information.");
 63                                                <<  63 
 64   cpyinit = new G4UIcommand("/generator/pythia <<  64   cpyinit= new G4UIcommand("/generator/pythia/pyinit", this);
 65   cpyinit->SetGuidance("call PYINIT");         <<  65   cpyinit-> SetGuidance("call PYINIT");
 66   G4UIparameter* frame = new G4UIparameter("fr <<  66   G4UIparameter* frame=
 67   cpyinit->SetParameter(frame);                <<  67     new G4UIparameter("frame of the experiment", 's', false);
 68   G4UIparameter* beam = new G4UIparameter("bea <<  68   cpyinit-> SetParameter(frame);
 69   cpyinit->SetParameter(beam);                 <<  69   G4UIparameter* beam= new G4UIparameter("beam particle", 's', false);
 70   G4UIparameter* target = new G4UIparameter("t <<  70   cpyinit-> SetParameter(beam);
 71   cpyinit->SetParameter(target);               <<  71   G4UIparameter* target= new G4UIparameter("target particle", 's', false);
 72   G4UIparameter* win = new G4UIparameter("ener <<  72   cpyinit-> SetParameter(target);
 73   cpyinit->SetParameter(win);                  <<  73   G4UIparameter* win= new G4UIparameter("energy of system (GeV)", 'd', false);
 74                                                <<  74   cpyinit-> SetParameter(win);
 75   cpystat = new G4UIcmdWithAnInteger("/generat <<  75 
 76   cpystat->SetGuidance("call PYSTAT");         <<  76   cpystat= new G4UIcmdWithAnInteger("/generator/pythia/pystat", this);
 77   cpystat->SetParameterName("mstat", false, fa <<  77   cpystat-> SetGuidance("call PYSTAT");
 78   cpystat->SetRange("mstat>=1 && mstat<=5");   <<  78   cpystat-> SetParameterName("mstat", false, false);
 79                                                <<  79   cpystat-> SetRange("mstat>=1 && mstat<=5");
 80   cpygive = new G4UIcommand("/generator/pythia <<  80 
 81   cpygive->SetGuidance("call PYGIVE");         <<  81   cpygive= new G4UIcommand("/generator/pythia/pygive",this);
 82   G4UIparameter* parameter = new G4UIparameter <<  82   cpygive-> SetGuidance("call PYGIVE");
 83   cpygive->SetParameter(parameter);            <<  83   G4UIparameter* parameter= new G4UIparameter ("Parameter", 's', false);
 84                                                <<  84   cpygive-> SetParameter(parameter);  
 85   setUserParameters = new G4UIcmdWithoutParame <<  85 
 86   setUserParameters->SetGuidance("Set user par <<  86   setUserParameters= 
 87                                                <<  87     new G4UIcmdWithoutParameter("/generator/pythia/setUserParameters",this);
 88   setSeed = new G4UIcmdWithAnInteger("/generat <<  88   setUserParameters-> 
 89   setSeed->SetGuidance("set initial seed.");   <<  89     SetGuidance("Set user parameters in the Pythia common blocks");
 90                                                <<  90 
 91   cpyrget = new G4UIcommand("/generator/pythia <<  91   setSeed= new G4UIcmdWithAnInteger("/generator/pythia/setSeed", this);
 92   cpyrget->SetGuidance("call PYRGET");         <<  92   setSeed-> SetGuidance("set initial seed.");
 93   G4UIparameter *lun, *move;                   <<  93 
 94   lun = new G4UIparameter("logical file number <<  94   cpyrget= new G4UIcommand("/generator/pythia/pyrget", this);
 95   cpyrget->SetParameter(lun);                  <<  95   cpyrget-> SetGuidance("call PYRGET");
 96   move = new G4UIparameter("choice of adding a <<  96   G4UIparameter* lun, *move;
 97   move->SetDefaultValue(-1);                   <<  97   lun= new G4UIparameter("logical file number", 'i', false);
 98   cpyrget->SetParameter(move);                 <<  98   cpyrget-> SetParameter(lun);
 99                                                <<  99   move= new G4UIparameter("choice of adding a new record", 'i', true);
100   cpyrset = new G4UIcommand("/generator/pythia << 100   move-> SetDefaultValue(-1);
101   cpyrset->SetGuidance("call PYRSET");         << 101   cpyrget-> SetParameter(move);
102   lun = new G4UIparameter("logical file number << 102 
103   cpyrset->SetParameter(lun);                  << 103   cpyrset= new G4UIcommand("/generator/pythia/pyrset", this);
104   move = new G4UIparameter("choice of adding a << 104   cpyrset-> SetGuidance("call PYRSET");
105   move->SetDefaultValue(0);                    << 105   lun= new G4UIparameter("logical file number", 'i', false);
106   cpyrset->SetParameter(move);                 << 106   cpyrset-> SetParameter(lun);
107                                                << 107   move= new G4UIparameter("choice of adding a new record", 'i', true);
108   printRandomStatus = new G4UIcmdWithAString(" << 108   move-> SetDefaultValue(0);
109   printRandomStatus->SetGuidance("print random << 109   cpyrset-> SetParameter(move);
110   printRandomStatus->SetParameterName("filenam << 110 
111   printRandomStatus->SetDefaultValue("std::cou << 111   printRandomStatus= 
                                                   >> 112     new G4UIcmdWithAString("/generator/pythia/printRandomStatus", this);
                                                   >> 113   printRandomStatus-> SetGuidance("print random number status.");
                                                   >> 114   printRandomStatus-> SetParameterName("filename", true, false);
                                                   >> 115   printRandomStatus-> SetDefaultValue("std::cout");
112 }                                                 116 }
113                                                   117 
114 //....oooOO0OOooo........oooOO0OOooo........oo << 118 /////////////////////////////////////////////////
115 HepMCG4PythiaMessenger::~HepMCG4PythiaMessenge    119 HepMCG4PythiaMessenger::~HepMCG4PythiaMessenger()
                                                   >> 120 /////////////////////////////////////////////////
116 {                                                 121 {
117   delete verbose;                                 122   delete verbose;
118   delete mpylist;                                 123   delete mpylist;
119   delete print;                                   124   delete print;
120   delete cpyinit;                                 125   delete cpyinit;
121   delete cpystat;                              << 126   delete cpystat;  
122   delete cpygive;                                 127   delete cpygive;
123   delete setUserParameters;                       128   delete setUserParameters;
124   delete setSeed;                                 129   delete setSeed;
125   delete cpyrget;                                 130   delete cpyrget;
126   delete cpyrset;                                 131   delete cpyrset;
127   delete printRandomStatus;                       132   delete printRandomStatus;
128                                                   133 
129   delete dir;                                     134   delete dir;
130 }                                                 135 }
131                                                   136 
132 //....oooOO0OOooo........oooOO0OOooo........oo << 137 //////////////////////////////////////////////////////////////
133 void HepMCG4PythiaMessenger::SetNewValue(G4UIc << 138 void HepMCG4PythiaMessenger::SetNewValue(G4UIcommand* command, 
                                                   >> 139            G4String newValues)
                                                   >> 140 //////////////////////////////////////////////////////////////
134 {                                                 141 {
135   if (command == verbose) {  // /verbose ...   << 142   if(command == verbose) {  // /verbose ...
136     G4int level = verbose->GetNewIntValue(newV << 143     G4int level= verbose-> GetNewIntValue(newValues);
137     gen->SetVerboseLevel(level);               << 144     gen-> SetVerboseLevel(level);
138   }                                            << 145 
139   else if (command == mpylist) {  // /mpylist  << 146   } else if (command == mpylist) { // /mpylist ...
140     G4int mlist = mpylist->GetNewIntValue(newV << 147     G4int mlist= mpylist-> GetNewIntValue(newValues);
141     gen->SetPylist(mlist);                     << 148     gen-> SetPylist(mlist);
142   }                                            << 149 
143   else if (command == print) {  // /print ...  << 150   } else if (command == print) { // /print ...
144     gen->Print();                              << 151     gen-> Print();
145   }                                            << 152 
146   else if (command == cpyinit) {  // /pyinit . << 153   } else if (command == cpyinit) { // /pyinit ...
147     const char* strvaluelist = newValues.c_str << 154     const char* strvaluelist= newValues.c_str();
148     std::istringstream is(strvaluelist);          155     std::istringstream is(strvaluelist);
149     G4String sframe, sbeam, starget;           << 156     G4String sframe, sbeam, starget; G4double dwin;
150     G4double dwin;                             << 
151     is >> sframe >> sbeam >> starget >> dwin;     157     is >> sframe >> sbeam >> starget >> dwin;
152     gen->CallPyinit(sframe, sbeam, starget, dw << 158     gen-> CallPyinit(sframe, sbeam, starget, dwin);
153   }                                            << 159 
154   else if (command == cpystat) {  // /pystat . << 160   } else if (command == cpystat) { // /pystat ...
155     G4int imod = cpystat->GetNewIntValue(newVa << 161     G4int imod= cpystat-> GetNewIntValue(newValues);
156     gen->CallPystat(imod);                     << 162     gen-> CallPystat(imod);
157   }                                            << 163 
158   else if (command == cpygive) {  // /pygive . << 164   } else if (command == cpygive) { // /pygive ...
159     G4String s = newValues;                    << 165     G4String s= newValues;
160     gen->CallPygive(s);                        << 166     gen-> CallPygive(s);
161   }                                            << 167 
162   else if (command == setUserParameters) {  // << 168   } else if (command == setUserParameters) { // /setUserParameters ...
163     gen->SetUserParameters();                  << 169     gen-> SetUserParameters();
164   }                                            << 170 
165   else if (command == setSeed) {  // /setSeed  << 171   } else if (command == setSeed) { // /setSeed ...
166     G4int iseed = setSeed->GetNewIntValue(newV << 172     G4int iseed= setSeed-> GetNewIntValue(newValues);
167     gen->SetRandomSeed(iseed);                 << 173     gen-> SetRandomSeed(iseed);
168   }                                            << 174 
169   else if (command == cpyrget) {  // /pyrget . << 175   } else if (command == cpyrget) { // /pyrget ...
170     const char* strvaluelist = newValues.c_str << 176     const char* strvaluelist= newValues.c_str();
171     std::istringstream is(strvaluelist);          177     std::istringstream is(strvaluelist);
172     G4int lun, move;                              178     G4int lun, move;
173     is >> lun >> move;                            179     is >> lun >> move;
174     gen->CallPyrget(lun, move);                << 180     gen-> CallPyrget(lun, move);
175   }                                            << 181 
176   else if (command == cpyrset) {  // /pyrset . << 182   } else if (command == cpyrset) { // /pyrset ...
177     const char* strvaluelist = newValues.c_str << 183     const char* strvaluelist= newValues.c_str();
178     std::istringstream is(strvaluelist);          184     std::istringstream is(strvaluelist);
179     G4int lun, move;                              185     G4int lun, move;
180     is >> lun >> move;                            186     is >> lun >> move;
181     gen->CallPyrset(lun, move);                << 187     gen-> CallPyrset(lun, move);
182   }                                            << 188 
183   else if (command == printRandomStatus) {  // << 189   } else if (command == printRandomStatus) { // /printRandomStatus ...
184     G4String s = newValues;                    << 190     G4String s= newValues;
185     if (newValues == "std::cout") {               191     if (newValues == "std::cout") {
186       gen->PrintRandomStatus();                << 192       gen-> PrintRandomStatus();
187     }                                          << 193     } else {
188     else {                                     << 
189       // to a file (overwrite mode)               194       // to a file (overwrite mode)
190       std::ofstream ofs;                          195       std::ofstream ofs;
191       ofs.open(s.c_str(), std::ios::out);      << 196       ofs.open(s.c_str(), std::ios::out);  
192       // ofs.open(randomStatusFileName.c_str() << 197       //ofs.open(randomStatusFileName.c_str(), std::ios::out|std::ios::app);
193       ofs.setf(std::ios::fixed | std::ios::sho    198       ofs.setf(std::ios::fixed | std::ios::showpoint);
194       gen->PrintRandomStatus(ofs);             << 199       gen-> PrintRandomStatus(ofs);
195       ofs.close();                                200       ofs.close();
196     }                                             201     }
197   }                                               202   }
198 }                                                 203 }
199                                                   204 
200 //....oooOO0OOooo........oooOO0OOooo........oo << 205 //////////////////////////////////////////////////////////////////////
201 G4String HepMCG4PythiaMessenger::GetCurrentVal    206 G4String HepMCG4PythiaMessenger::GetCurrentValue(G4UIcommand* command)
                                                   >> 207 //////////////////////////////////////////////////////////////////////
202 {                                                 208 {
203   G4String cv;                                    209   G4String cv;
204   if (command == verbose) {                       210   if (command == verbose) {
205     cv = verbose->ConvertToString(gen->GetVerb << 211     cv= verbose-> ConvertToString(gen->GetVerboseLevel());
206   }                                            << 212   } else  if (command == mpylist) {
207   else if (command == mpylist) {               << 213     cv= verbose-> ConvertToString(gen->GetPylist());
208     cv = verbose->ConvertToString(gen->GetPyli << 
209   }                                               214   }
210   return cv;                                      215   return cv;
211 }                                                 216 }
212                                                   217 
213 #endif                                         << 
214                                                   218