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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/chem3/chem3.cc (Version 11.3.0) and /examples/extended/medical/dna/chem3/chem3.cc (Version 10.6.p2)


  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 // J. Comput. Phys. 274 (2014) 841-882             30 // J. Comput. Phys. 274 (2014) 841-882
 31 // The Geant4-DNA web site is available at htt     31 // The Geant4-DNA web site is available at http://geant4-dna.org
 32 //                                                 32 //
 33 //                                                 33 //
 34 /// \file chem3.cc                                 34 /// \file chem3.cc
 35 /// \brief Chem3 example                           35 /// \brief Chem3 example
 36                                                    36 
 37 #include "ActionInitialization.hh"             << 
 38 #include "DetectorConstruction.hh"                 37 #include "DetectorConstruction.hh"
 39 #include "PhysicsList.hh"                          38 #include "PhysicsList.hh"
                                                   >>  39 #include "ActionInitialization.hh"
                                                   >>  40 
                                                   >>  41 #ifdef G4MULTITHREADED
                                                   >>  42 #include "G4MTRunManager.hh"
                                                   >>  43 #else
                                                   >>  44 #include "G4RunManager.hh"
                                                   >>  45 #endif
 40                                                    46 
 41 #include "G4DNAChemistryManager.hh"                47 #include "G4DNAChemistryManager.hh"
 42 #include "G4RunManagerFactory.hh"              << 
 43 #include "G4UIExecutive.hh"                    << 
 44 #include "G4UImanager.hh"                          48 #include "G4UImanager.hh"
                                                   >>  49 #include "G4UIExecutive.hh"
 45 #include "G4VisExecutive.hh"                       50 #include "G4VisExecutive.hh"
 46 #ifdef G4UI_USE_QT                                 51 #ifdef G4UI_USE_QT
 47 #  include "G4UIQt.hh"                         <<  52 #include "G4UIQt.hh"
 48 #endif                                             53 #endif
 49 #include "CommandLineParser.hh"                    54 #include "CommandLineParser.hh"
 50                                                    55 
 51 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 52                                                    57 
 53 /*                                                 58 /*
 54  * WARNING : Geant4 was initially not intended     59  * WARNING : Geant4 was initially not intended for this kind of application
 55  * This code is delivered as a prototype           60  * This code is delivered as a prototype
 56  * We will be happy to hear from you, do not h     61  * We will be happy to hear from you, do not hesitate to send your feedback and
 57  * communicate on the difficulties you may enc     62  * communicate on the difficulties you may encounter
 58  * The user interface may change in the next r     63  * The user interface may change in the next releases since a reiteration of the
 59  * code has started                                64  * code has started
 60  */                                                65  */
 61                                                    66 
 62 using namespace G4DNAPARSER;                       67 using namespace G4DNAPARSER;
 63 CommandLineParser* parser(0);                      68 CommandLineParser* parser(0);
 64                                                    69 
 65 void Parse(int& argc, char** argv);                70 void Parse(int& argc, char** argv);
 66                                                    71 
 67 int main(int argc, char** argv)                    72 int main(int argc, char** argv)
 68 {                                                  73 {
 69   //////////                                       74   //////////
 70   // Parse options given in commandLine            75   // Parse options given in commandLine
 71   //                                               76   //
 72   Parse(argc, argv);                               77   Parse(argc, argv);
 73                                                    78 
 74   //////////                                       79   //////////
 75   // Construct the run manager according to wh     80   // Construct the run manager according to whether MT is activated or not
 76   //                                               81   //
 77   Command* commandLine(0);                         82   Command* commandLine(0);
 78                                                    83 
 79   auto* runManager = G4RunManagerFactory::Crea <<  84 #ifdef G4MULTITHREADED
 80                                                <<  85   G4RunManager* runManager(0);
 81   if ((commandLine = parser->GetCommandIfActiv <<  86   if ((commandLine = parser->GetCommandIfActive("-mt")))
                                                   >>  87   {
                                                   >>  88     runManager = new G4MTRunManager;
 82     int nThreads = 2;                              89     int nThreads = 2;
 83     const G4String& option = commandLine->GetO     90     const G4String& option = commandLine->GetOption();
 84     if (option == "") {                        <<  91     if(option == "")
                                                   >>  92     {
 85       nThreads = G4UIcommand::ConvertToInt(com     93       nThreads = G4UIcommand::ConvertToInt(commandLine->GetDefaultOption());
 86     }                                              94     }
 87     else if (option == "NMAX") {               <<  95     else if(option == "NMAX")
 88       nThreads = G4Threading::G4GetNumberOfCor <<  96     {
                                                   >>  97      nThreads = G4Threading::G4GetNumberOfCores();
 89     }                                              98     }
 90     else {                                     <<  99     else
                                                   >> 100     {
 91       nThreads = G4UIcommand::ConvertToInt(opt    101       nThreads = G4UIcommand::ConvertToInt(option);
 92     }                                             102     }
 93                                                   103 
 94     runManager->SetNumberOfThreads(nThreads);  << 104     G4cout << "===== Chem3 is started with "
                                                   >> 105        << ((G4MTRunManager*) runManager)->GetNumberOfThreads()
                                                   >> 106        << " threads =====" << G4endl;
 95                                                   107 
 96     G4cout << "===== Chem3 is started with " < << 108     ((G4MTRunManager*) runManager)->SetNumberOfThreads(nThreads);
 97            << " threads =====" << G4endl;      << 
 98   }                                               109   }
                                                   >> 110   else
                                                   >> 111   {
                                                   >> 112     runManager = new G4RunManager();
                                                   >> 113   }
                                                   >> 114 #else
                                                   >> 115   G4RunManager* runManager = new G4RunManager();
                                                   >> 116 #endif
 99                                                   117 
100   //////////                                      118   //////////
101   // Set mandatory user initialization classes    119   // Set mandatory user initialization classes
102   //                                              120   //
103   DetectorConstruction* detector = new Detecto    121   DetectorConstruction* detector = new DetectorConstruction;
104   runManager->SetUserInitialization(new Physic    122   runManager->SetUserInitialization(new PhysicsList);
105   runManager->SetUserInitialization(detector);    123   runManager->SetUserInitialization(detector);
106   runManager->SetUserInitialization(new Action    124   runManager->SetUserInitialization(new ActionInitialization());
107                                                   125 
108   // Initialize G4 kernel                         126   // Initialize G4 kernel
109   runManager->Initialize();                       127   runManager->Initialize();
110                                                   128 
111   // Initialize visualization                     129   // Initialize visualization
112   G4VisManager* visManager = new G4VisExecutiv    130   G4VisManager* visManager = new G4VisExecutive;
113   // G4VisExecutive can take a verbosity argum    131   // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
114   // G4VisManager* visManager = new G4VisExecu    132   // G4VisManager* visManager = new G4VisExecutive("Quiet");
115   visManager->Initialize();                       133   visManager->Initialize();
116                                                   134 
117   // Get the pointer to the User Interface man    135   // Get the pointer to the User Interface manager
118   G4UImanager* UImanager = G4UImanager::GetUIp    136   G4UImanager* UImanager = G4UImanager::GetUIpointer();
119   G4UIExecutive* ui(0);                           137   G4UIExecutive* ui(0);
120                                                   138 
121   // interactive mode : define UI session         139   // interactive mode : define UI session
122   if ((commandLine = parser->GetCommandIfActiv << 140   if ((commandLine = parser->GetCommandIfActive("-gui")))
                                                   >> 141   {
123     ui = new G4UIExecutive(argc, argv, command    142     ui = new G4UIExecutive(argc, argv, commandLine->GetOption());
124                                                   143 
125     if (parser->GetCommandIfActive("-novis") =    144     if (parser->GetCommandIfActive("-novis") == 0)
126     // visualization is used by default           145     // visualization is used by default
127     {                                             146     {
128       if ((commandLine = parser->GetCommandIfA    147       if ((commandLine = parser->GetCommandIfActive("-vis")))
129       // select a visualization driver if need    148       // select a visualization driver if needed (e.g. HepFile)
130       {                                           149       {
131         UImanager->ApplyCommand(G4String("/vis << 150         UImanager->ApplyCommand(
                                                   >> 151             G4String("/vis/open ") + commandLine->GetOption());
132       }                                           152       }
133       else                                        153       else
134       // by default OGL is used                   154       // by default OGL is used
135       {                                           155       {
136         UImanager->ApplyCommand("/vis/open OGL    156         UImanager->ApplyCommand("/vis/open OGL 800x600-0+0");
137       }                                           157       }
138       UImanager->ApplyCommand("/control/execut    158       UImanager->ApplyCommand("/control/execute vis.mac");
139     }                                             159     }
140                                                   160 
141     if (ui->IsGUI()) UImanager->ApplyCommand("    161     if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac");
142   }                                               162   }
143   else                                            163   else
144   // to be use visualization file (= store the    164   // to be use visualization file (= store the visualization into
145   // an external file:                            165   // an external file:
146   // ASCIITree ;  DAWNFILE ; HepRepFile ; VRML    166   // ASCIITree ;  DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
147   {                                               167   {
148     if ((commandLine = parser->GetCommandIfAct << 168     if ((commandLine = parser->GetCommandIfActive("-vis")))
149       UImanager->ApplyCommand(G4String("/vis/o << 169     {
                                                   >> 170       UImanager->ApplyCommand(
                                                   >> 171           G4String("/vis/open ") + commandLine->GetOption());
150       UImanager->ApplyCommand("/control/execut    172       UImanager->ApplyCommand("/control/execute vis.mac");
151     }                                             173     }
152   }                                               174   }
153                                                   175 
154   if ((commandLine = parser->GetCommandIfActiv << 176   if ((commandLine = parser->GetCommandIfActive("-mac")))
                                                   >> 177   {
155     G4String command = "/control/execute ";       178     G4String command = "/control/execute ";
156     UImanager->ApplyCommand(command + commandL    179     UImanager->ApplyCommand(command + commandLine->GetOption());
157   }                                               180   }
158   else {                                       << 181   else
                                                   >> 182   {
159     UImanager->ApplyCommand("/control/execute     183     UImanager->ApplyCommand("/control/execute beam.in");
160   }                                               184   }
161                                                   185 
162   if ((commandLine = parser->GetCommandIfActiv << 186   if ((commandLine = parser->GetCommandIfActive("-gui")))
                                                   >> 187   {
163 #ifdef G4UI_USE_QT                                188 #ifdef G4UI_USE_QT
164     G4UIQt* UIQt = static_cast<G4UIQt*>(UImana << 189     G4UIQt* UIQt = static_cast<G4UIQt*> (UImanager->GetG4UIWindow());
165     if (UIQt) {                                << 190     if ( UIQt) {
166       UIQt->AddViewerTabFromFile("README", "RE << 191       UIQt->AddViewerTabFromFile("README", "README from "+ G4String(argv[0]));
167     }                                             192     }
168 #endif                                            193 #endif
169     ui->SessionStart();                           194     ui->SessionStart();
170     delete ui;                                    195     delete ui;
171   }                                               196   }
172                                                   197 
173   // Job termination                              198   // Job termination
174   // Free the store: user actions, physics_lis    199   // Free the store: user actions, physics_list and detector_description are
175   // owned and deleted by the run manager, so     200   // owned and deleted by the run manager, so they should not be deleted
176   // in the main() program !                      201   // in the main() program !
177                                                   202 
178   delete visManager;                              203   delete visManager;
179   delete runManager;                              204   delete runManager;
180                                                   205 
181   CommandLineParser::DeleteInstance();            206   CommandLineParser::DeleteInstance();
182                                                   207 
183   return 0;                                       208   return 0;
184 }                                                 209 }
185                                                   210 
186 void Parse(int& argc, char** argv)                211 void Parse(int& argc, char** argv)
187 {                                                 212 {
188   //////////                                      213   //////////
189   // Parse options given in commandLine           214   // Parse options given in commandLine
190   //                                              215   //
191   parser = CommandLineParser::GetParser();        216   parser = CommandLineParser::GetParser();
192                                                   217 
193   parser->AddCommand("-gui", Command::OptionNo << 218   parser->AddCommand(
194                      "Select geant4 UI or just << 219       "-gui", Command::OptionNotCompulsory,
195                                                << 220       "Select geant4 UI or just launch a geant4 terminal session", "qt");
196   parser->AddCommand("-mac", Command::WithOpti << 221 
197                                                << 222   parser->AddCommand("-mac", Command::WithOption, "Give a mac file to execute",
198   // You cann your own command, as for instanc << 223                      "macFile.mac");
199   //  parser->AddCommand("-seed",              << 224 
200   //                     Command::WithOption,  << 225 // You cann your own command, as for instance:
201   //                     "Give a seed value in << 226 //  parser->AddCommand("-seed", 
202   // it is then up to you to manage this optio << 227 //                     Command::WithOption,
                                                   >> 228 //                     "Give a seed value in argument to be tested", "seed");
                                                   >> 229 // it is then up to you to manage this option
203                                                   230 
                                                   >> 231 #ifdef G4MULTITHREADED
204   parser->AddCommand("-mt", Command::OptionNot    232   parser->AddCommand("-mt", Command::OptionNotCompulsory,
205                      "Launch in MT mode if ava << 233                      "Launch in MT mode (events computed in parallel,"
206                      " NOT RECOMMENDED WITH CH << 234                      " NOT RECOMMANDED WITH CHEMISTRY)",
207                      "2");                        235                      "2");
                                                   >> 236 #endif
208                                                   237 
209   parser->AddCommand("-chemOFF", Command::With << 238   parser->AddCommand("-chemOFF", Command::WithoutOption,
                                                   >> 239                      "Deactivate chemistry");
210                                                   240 
211   parser->AddCommand("-vis", Command::WithOpti << 241   parser->AddCommand("-vis", Command::WithOption,
212                      "OGL 600x600-0+0");       << 242                      "Select a visualization driver", "OGL 600x600-0+0");
213                                                   243 
214   parser->AddCommand("-novis", Command::Withou << 244   parser->AddCommand("-novis", Command::WithoutOption,
                                                   >> 245                      "Deactivate visualization when using GUI");
215                                                   246 
216   //////////                                      247   //////////
217   // If -h or --help is given in option : prin    248   // If -h or --help is given in option : print help and exit
218   //                                              249   //
219   if (parser->Parse(argc, argv) != 0)  // help << 250   if (parser->Parse(argc, argv) != 0) // help is being printed
220   {                                               251   {
221     // if you are using ROOT, create a TApplic    252     // if you are using ROOT, create a TApplication in this condition in order
222     // to print the help from ROOT as well        253     // to print the help from ROOT as well
223     CommandLineParser::DeleteInstance();          254     CommandLineParser::DeleteInstance();
224     std::exit(0);                                 255     std::exit(0);
225   }                                               256   }
226                                                   257 
227   ///////////                                     258   ///////////
228   // Kill application if wrong argument in com    259   // Kill application if wrong argument in command line
229   //                                              260   //
230   if (parser->CheckIfNotHandledOptionsExists(a << 261   if (parser->CheckIfNotHandledOptionsExists(argc, argv))
                                                   >> 262   {
231     // if you are using ROOT, you should initi    263     // if you are using ROOT, you should initialise your TApplication
232     // before this condition                      264     // before this condition
233     abort();                                      265     abort();
234   }                                               266   }
235 }                                                 267 }
236                                                   268