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] [ 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/medical/dna/neuron/neuron.cc (Version 11.3.0) and /examples/extended/medical/dna/neuron/neuron.cc (Version 10.4)


  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 // This example is provided by the Geant4-DNA      26 // This example is provided by the Geant4-DNA collaboration
 27 // Any report or published results obtained us     27 // Any report or published results obtained using the Geant4-DNA software
 28 // shall cite the following Geant4-DNA collabo     28 // shall cite the following Geant4-DNA collaboration publication:
 29 // Med. Phys. 37 (2010) 4692-4708                  29 // Med. Phys. 37 (2010) 4692-4708
 30 // and papers                                      30 // and papers
 31 // M. Batmunkh et al. J Radiat Res Appl Sci 8      31 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
 32 // O. Belov et al. Physica Medica 32 (2016) 15     32 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
 33 // The Geant4-DNA web site is available at htt     33 // The Geant4-DNA web site is available at http://geant4-dna.org
 34 //                                             <<  34 // 
 35 // -------------------------------------------     35 // -------------------------------------------------------------------
 36 // November 2016                                   36 // November 2016
 37 // -------------------------------------------     37 // -------------------------------------------------------------------
 38 //                                                 38 //
                                                   >>  39 // $ID$
 39 /// \file neuron.cc                                40 /// \file neuron.cc
 40 /// \brief Implementation of the neuron exampl     41 /// \brief Implementation of the neuron example
 41 //                                                 42 //
 42 //....oooOO0OOooo........oooOO0OOooo........oo     43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 43 #include "ActionInitialization.hh"             << 
 44 #include "CommandLineParser.hh"                << 
 45 #include "DetectorConstruction.hh"             << 
 46 #include "PhysicsList.hh"                      << 
 47                                                    44 
                                                   >>  45 #ifdef G4MULTITHREADED
                                                   >>  46   #include "G4MTRunManager.hh"
                                                   >>  47 #else
                                                   >>  48   #include "G4RunManager.hh"
                                                   >>  49 #endif
 48 #include "G4DNAChemistryManager.hh"                50 #include "G4DNAChemistryManager.hh"
 49 #include "G4RunManagerFactory.hh"              << 
 50 #include "G4Timer.hh"                              51 #include "G4Timer.hh"
 51 #include "G4Types.hh"                          << 
 52 #include "G4UIExecutive.hh"                    << 
 53 #include "G4UImanager.hh"                          52 #include "G4UImanager.hh"
                                                   >>  53 #include "G4UIExecutive.hh"
 54 #include "G4VisExecutive.hh"                       54 #include "G4VisExecutive.hh"
                                                   >>  55 #include "CommandLineParser.hh"
                                                   >>  56 #include "ActionInitialization.hh"
                                                   >>  57 #include "DetectorConstruction.hh"
                                                   >>  58 #include "PhysicsList.hh" 
 55                                                    59 
 56 //....oooOO0OOooo........oooOO0OOooo........oo     60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    61 
 58 using namespace std;                               62 using namespace std;
 59 using namespace G4DNAPARSER;                       63 using namespace G4DNAPARSER;
 60                                                << 
 61 CommandLineParser* parser(0);                      64 CommandLineParser* parser(0);
 62                                                    65 
 63 void Parse(int& argc, char** argv);                66 void Parse(int& argc, char** argv);
 64                                                    67 
 65 int main(int argc, char** argv)                <<  68 int main(int argc,char** argv) 
 66 {                                                  69 {
                                                   >>  70 
 67   // run time in Geant4                            71   // run time in Geant4
 68   G4Timer* timer = new G4Timer();              <<  72   G4Timer *timer = new G4Timer();
 69   timer->Start();                              <<  73   timer->Start();   
                                                   >>  74   
                                                   >>  75   // Choose the Random engine
                                                   >>  76   G4Random::setTheEngine(new CLHEP::RanecuEngine);
 70                                                    77 
 71   //////////                                       78   //////////
 72   // Parse options given in commandLine            79   // Parse options given in commandLine
 73   //                                               80   //
 74   Parse(argc, argv);                               81   Parse(argc, argv);
 75                                                    82 
 76   //////////                                       83   //////////
 77   // Construct the run manager according to wh     84   // Construct the run manager according to whether MT is activated or not
 78   //                                               85   //
 79   Command* commandLine(0);                         86   Command* commandLine(0);
 80                                                <<  87   
 81   auto* runManager = G4RunManagerFactory::Crea <<  88 #ifdef G4MULTITHREADED
 82                                                <<  89   G4MTRunManager* runManager= new G4MTRunManager;
 83   if ((commandLine = parser->GetCommandIfActiv <<  90   if ((commandLine = parser->GetCommandIfActive("-mt")))
 84     G4int nThreads = 2;                        <<  91   {
 85                                                <<  92     int nThreads = 2;
 86     if (commandLine->GetOption() == "NMAX") {  <<  93     if(commandLine->GetOption() == "NMAX")
 87       nThreads = G4Threading::G4GetNumberOfCor <<  94     {
                                                   >>  95      nThreads = G4Threading::G4GetNumberOfCores();
 88     }                                              96     }
 89     else {                                     <<  97     else
 90       nThreads = G4UIcommand::ConvertToInt(com <<  98     {
                                                   >>  99      nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
 91     }                                             100     }
                                                   >> 101     G4cout << "===== neuron is started with "
                                                   >> 102        << runManager->GetNumberOfThreads()
                                                   >> 103        << " threads of MT MODE =====" << G4endl;
                                                   >> 104  
 92     runManager->SetNumberOfThreads(nThreads);     105     runManager->SetNumberOfThreads(nThreads);
 93                                                << 
 94     G4cout << "===== neuron is started with "  << 
 95            << " threads of MT MODE =====" << G << 
 96   }                                               106   }
                                                   >> 107 #else
                                                   >> 108   G4RunManager* runManager = new G4RunManager();
                                                   >> 109   G4cout << "===== neuron is started with "
                                                   >> 110          << " SEQUENTIAL MODE =====" << G4endl;
                                                   >> 111 #endif
 97                                                   112 
 98   // Set mandatory user initialization classes    113   // Set mandatory user initialization classes
 99   DetectorConstruction* detector = new Detecto    114   DetectorConstruction* detector = new DetectorConstruction;
100   runManager->SetUserInitialization(detector);    115   runManager->SetUserInitialization(detector);
101   runManager->SetUserInitialization(new Physic << 116   runManager->SetUserInitialization(new PhysicsList);  
102                                                   117 
103   // User action initialization                << 118   // User action initialization  
104   runManager->SetUserInitialization(new Action    119   runManager->SetUserInitialization(new ActionInitialization(detector));
105                                                << 120   
106   // Initialize G4 kernel                      << 121   // Initialize G4 kernel  
107   runManager->Initialize();                       122   runManager->Initialize();
108                                                   123 
109   // Initialize visualization                     124   // Initialize visualization
110   G4VisManager* visManager = new G4VisExecutiv    125   G4VisManager* visManager = new G4VisExecutive;
111   visManager->Initialize();                       126   visManager->Initialize();
112                                                   127 
113   // Get the pointer to the User Interface man    128   // Get the pointer to the User Interface manager
114   G4UImanager* UImanager = G4UImanager::GetUIp    129   G4UImanager* UImanager = G4UImanager::GetUIpointer();
115   G4UIExecutive* ui(0);                           130   G4UIExecutive* ui(0);
116                                                   131 
117   // interactive mode : define UI session         132   // interactive mode : define UI session
118   if ((commandLine = parser->GetCommandIfActiv << 133   if ((commandLine = parser->GetCommandIfActive("-gui")))
119     ui = new G4UIExecutive(argc, argv, command << 134   {
                                                   >> 135     ui = new G4UIExecutive(argc, argv,
                                                   >> 136                            commandLine->GetOption());
120                                                   137 
121     if (ui->IsGUI()) UImanager->ApplyCommand(" << 138     if(ui->IsGUI())
                                                   >> 139        UImanager->ApplyCommand("/control/execute gui.mac");
122                                                   140 
123     if (parser->GetCommandIfActive("-novis") = << 141     if(parser->GetCommandIfActive("-novis") == 0)
124     // visualization is used by default           142     // visualization is used by default
125     {                                             143     {
126       if ((commandLine = parser->GetCommandIfA << 144       if((commandLine = parser->GetCommandIfActive("-vis")))
127       // select a visualization driver if need    145       // select a visualization driver if needed (e.g. HepFile)
128       {                                           146       {
129         UImanager->ApplyCommand(G4String("/vis << 147         UImanager->ApplyCommand(G4String("/vis/open ")+
                                                   >> 148                                 commandLine->GetOption());
130       }                                           149       }
131       else                                        150       else
132       // by default OGL is used                   151       // by default OGL is used
133       {                                           152       {
134         UImanager->ApplyCommand("/vis/open OGL    153         UImanager->ApplyCommand("/vis/open OGL 800x600-0+0");
135       }                                           154       }
136       UImanager->ApplyCommand("/control/execut    155       UImanager->ApplyCommand("/control/execute vis.mac");
137     }                                             156     }
138   }                                               157   }
139   else                                            158   else
140   // to be use visualization file (= store the    159   // to be use visualization file (= store the visualization into
141   // an external file:                            160   // an external file:
142   // ASCIITree ;  DAWNFILE ; HepRepFile ; VRML    161   // ASCIITree ;  DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
143   {                                               162   {
144     if ((commandLine = parser->GetCommandIfAct << 163     if ((commandLine = parser->GetCommandIfActive("-vis")))
145       UImanager->ApplyCommand(G4String("/vis/o << 164     {
                                                   >> 165       UImanager->ApplyCommand(G4String("/vis/open ")+commandLine->GetOption());
146       UImanager->ApplyCommand("/control/execut    166       UImanager->ApplyCommand("/control/execute vis.mac");
147     }                                             167     }
148   }                                               168   }
149                                                   169 
150   if ((commandLine = parser->GetCommandIfActiv << 170   if ((commandLine = parser->GetCommandIfActive("-mac")))
                                                   >> 171   {
151     G4String command = "/control/execute ";       172     G4String command = "/control/execute ";
152     UImanager->ApplyCommand(command + commandL    173     UImanager->ApplyCommand(command + commandLine->GetOption());
153   }                                               174   }
154   else {                                       << 175   else
155     UImanager->ApplyCommand("/control/execute  << 176   {
                                                   >> 177     UImanager->ApplyCommand("/control/execute "); //neuron.in
156   }                                               178   }
157                                                   179 
158   if ((commandLine = parser->GetCommandIfActiv << 180   if ((commandLine = parser->GetCommandIfActive("-gui")))
                                                   >> 181   {
159     ui->SessionStart();                           182     ui->SessionStart();
160     delete ui;                                    183     delete ui;
161   }                                               184   }
162                                                   185 
163   // calculation time                          << 186   // calculation time 
164   timer->Stop();                               << 187   timer->Stop();  
165   G4cout << " Calculation time                 << 188   G4cout << " Calculation time                      = " 
166          << G4endl;                            << 189          << timer->GetRealElapsed() << " s \n"<< G4endl;   
167                                                << 190    
168   delete visManager;                              191   delete visManager;
169   delete runManager;                              192   delete runManager;
170                                                   193 
171   return 0;                                       194   return 0;
172 }                                                 195 }
173                                                   196 
174 //....oooOO0OOooo........oooOO0OOooo........oo    197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
175                                                   198 
176 void GetNameAndPathOfExecutable(char** argv, G << 199 void GetNameAndPathOfExecutable(char** argv,
                                                   >> 200                                 G4String& executable,
                                                   >> 201                                 G4String& path)
177 {                                                 202 {
178   // Get the last position of '/'                 203   // Get the last position of '/'
179   std::string aux(argv[0]);                       204   std::string aux(argv[0]);
180                                                   205 
181   // get '/' or '\\' depending on unix/mac or     206   // get '/' or '\\' depending on unix/mac or windows.
182 #if defined(_WIN32) || defined(WIN32)             207 #if defined(_WIN32) || defined(WIN32)
183   int pos = aux.rfind('\\');                      208   int pos = aux.rfind('\\');
184 #else                                             209 #else
185   int pos = aux.rfind('/');                       210   int pos = aux.rfind('/');
186 #endif                                            211 #endif
187                                                   212 
188   // Get the path and the name                    213   // Get the path and the name
189   path = aux.substr(0, pos + 1);                  214   path = aux.substr(0, pos + 1);
190   executable = aux.substr(pos + 1);               215   executable = aux.substr(pos + 1);
191 }                                                 216 }
192                                                   217 
193 //....oooOO0OOooo........oooOO0OOooo........oo    218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194                                                   219 
195 void Parse(int& argc, char** argv)                220 void Parse(int& argc, char** argv)
196 {                                                 221 {
197   //////////                                      222   //////////
198   // Parse options given in commandLine           223   // Parse options given in commandLine
199   //                                              224   //
200   parser = CommandLineParser::GetParser();        225   parser = CommandLineParser::GetParser();
201                                                   226 
202   parser->AddCommand("-gui", Command::OptionNo << 227   parser->AddCommand("-gui",
203                      "Select geant4 UI or just << 228                      Command::OptionNotCompulsory,
204                                                << 229                     "Select geant4 UI or just launch a geant4 terminal session",
205   parser->AddCommand("-mac", Command::WithOpti << 230                     "qt");
206                                                << 231 
207   // You cann your own command, as for instanc << 232   parser->AddCommand("-mac",
208   //  parser->AddCommand("-seed",              << 233                      Command::WithOption,
209   //                     Command::WithOption,  << 234                      "Give a mac file to execute",
210   //                     "Give a seed value in << 235                      "macFile.mac");
211   // it is then up to you to manage this optio << 236 
212                                                << 237 // You cann your own command, as for instance:
213   parser->AddCommand("-mt", Command::WithOptio << 238 //  parser->AddCommand("-seed", 
214                      " NOT RECOMMANDED WITH CH << 239 //                     Command::WithOption,
                                                   >> 240 //                     "Give a seed value in argument to be tested", "seed");
                                                   >> 241 // it is then up to you to manage this option
                                                   >> 242 
                                                   >> 243 #ifdef G4MULTITHREADED
                                                   >> 244   parser->AddCommand("-mt",
                                                   >> 245                      Command::WithOption,
                                                   >> 246                      "Launch in MT mode (events computed in parallel)", 
                                                   >> 247       " NOT RECOMMANDED WITH CHEMISTRY)",
                                                   >> 248                      "2");
                                                   >> 249 #endif
215                                                   250 
216   parser->AddCommand("-sXY", Command::OptionNo    251   parser->AddCommand("-sXY", Command::OptionNotCompulsory,
217                      "Initial beam position un << 252                      "Initial beam position uniformly spread on a square!"); 
218   parser->AddCommand("-dXY", Command::OptionNo    253   parser->AddCommand("-dXY", Command::OptionNotCompulsory,
219                      "Initial beam position un << 254                      "Initial beam position uniformly spread on a disk!"); 
220                                                << 255           
221   parser->AddCommand("-dnaliv", Command::Optio << 256   parser->AddCommand("-dnaliv", Command::OptionNotCompulsory,
                                                   >> 257                      "Activate Livermore + DNAPhysics");
222   parser->AddCommand("-dnachemON", Command::Op    258   parser->AddCommand("-dnachemON", Command::OptionNotCompulsory,
223                      "Activate Livermore + DNA << 259                      "Activate Livermore + DNAPhysics + DNAChemistry");    
224   parser->AddCommand("-dnahad", Command::Optio    260   parser->AddCommand("-dnahad", Command::OptionNotCompulsory,
225                      "Activate Hadronic + Live    261                      "Activate Hadronic + Livermore + DNAPhysics");
226                                                   262 
227   parser->AddCommand("-swc", Command::WithOpti << 263   parser->AddCommand("-swc",
                                                   >> 264                      Command::WithOption,
                                                   >> 265                      "Give a SWC file to simulation",
                                                   >> 266                      "fileName.swc");
228                                                   267 
229   parser->AddCommand("-network",                  268   parser->AddCommand("-network",
230                      Command::WithOption,  //  << 269                      Command::WithOption, //OptionNotCompulsory,
231                      "Give a DAT file to simul << 270                      "Give a DAT file to simulation",
232                                                << 271                      "fileName.dat");
233   parser->AddCommand("-vis", Command::WithOpti << 272       
                                                   >> 273   parser->AddCommand("-vis",
                                                   >> 274                      Command::WithOption,
                                                   >> 275                      "Select a visualization driver",
234                      "OGL 600x600-0+0");          276                      "OGL 600x600-0+0");
235                                                   277 
236   parser->AddCommand("-novis", Command::Withou << 278   parser->AddCommand("-novis",
                                                   >> 279                      Command::WithoutOption,
                                                   >> 280                      "Deactivate visualization when using GUI");
237                                                   281 
238   G4String exec;                                  282   G4String exec;
239   G4String path;                                  283   G4String path;
240   GetNameAndPathOfExecutable(argv, exec, path) << 284   GetNameAndPathOfExecutable(argv,exec, path);
241                                                   285 
242   parser->AddCommand("-out", Command::OptionNo << 286   parser->AddCommand("-out",
                                                   >> 287                      Command::OptionNotCompulsory,
                                                   >> 288                      "Output files", 
                                                   >> 289                      exec);
243                                                   290 
244   //////////                                      291   //////////
245   // If -h or --help is given in option : prin    292   // If -h or --help is given in option : print help and exit
246   //                                              293   //
247   if (parser->Parse(argc, argv) != 0)  // help << 294   if (parser->Parse(argc, argv) != 0) // help is being printed
248   {                                               295   {
249     // if you are using ROOT, create a TApplic    296     // if you are using ROOT, create a TApplication in this condition in order
250     // to print the help from ROOT as well        297     // to print the help from ROOT as well
251     CommandLineParser::DeleteInstance();          298     CommandLineParser::DeleteInstance();
252     std::exit(0);                                 299     std::exit(0);
253   }                                               300   }
                                                   >> 301 
254   ///////////                                     302   ///////////
255   // Kill application if wrong argument in com    303   // Kill application if wrong argument in command line
256   //                                              304   //
257   if (parser->CheckIfNotHandledOptionsExists(a << 305   if (parser->CheckIfNotHandledOptionsExists(argc, argv))
                                                   >> 306   {
258     // if you are using ROOT, you should initi    307     // if you are using ROOT, you should initialise your TApplication
259     // before this condition                      308     // before this condition
260     abort();                                      309     abort();
261   }                                               310   }
262 }                                                 311 }
263                                                   312