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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.5.p1)


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