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

Diff markup

Differences between /examples/extended/medical/dna/wholeNuclearDNA/wholeNuclearDNA.cc (Version 11.3.0) and /examples/extended/medical/dna/wholeNuclearDNA/wholeNuclearDNA.cc (Version 10.3.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 // The Geant4-DNA web site is available at htt     30 // The Geant4-DNA web site is available at http://geant4-dna.org
 31 //                                                 31 //
                                                   >>  32 // $ID$
 32 /// \file wholeNuclearDNA.cc                       33 /// \file wholeNuclearDNA.cc
 33 /// \brief Implementation of the microdosimetr     34 /// \brief Implementation of the microdosimetry example
 34 //                                                 35 //
 35 //....oooOO0OOooo........oooOO0OOooo........oo     36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 36 #include "G4RunManagerFactory.hh"              <<  37 
 37 #include "G4Types.hh"                          <<  38 #ifdef G4MULTITHREADED
 38 #include "G4UIExecutive.hh"                    <<  39   #include "G4MTRunManager.hh"
                                                   >>  40 #else
                                                   >>  41   #include "G4RunManager.hh"
                                                   >>  42 #endif
                                                   >>  43 
 39 #include "G4UImanager.hh"                          44 #include "G4UImanager.hh"
 40 #include "G4UItcsh.hh"                         <<  45 #include "G4UIExecutive.hh"
 41 #include "G4UIterminal.hh"                         46 #include "G4UIterminal.hh"
                                                   >>  47 #include "G4UItcsh.hh"
 42 #include "G4VisExecutive.hh"                       48 #include "G4VisExecutive.hh"
 43 #ifdef G4UI_USE_QT                                 49 #ifdef G4UI_USE_QT
 44 #  include "G4UIQt.hh"                         <<  50 #include "G4UIQt.hh"
 45 #endif                                             51 #endif
 46                                                    52 
 47 #include "ActionInitialization.hh"                 53 #include "ActionInitialization.hh"
 48 #include "CommandLineParser.hh"                << 
 49 #include "DetectorConstruction.hh"                 54 #include "DetectorConstruction.hh"
 50 #include "PhysicsList.hh"                          55 #include "PhysicsList.hh"
                                                   >>  56 #include "CommandLineParser.hh"
 51                                                    57 
 52 //....oooOO0OOooo........oooOO0OOooo........oo     58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 53                                                    59 
 54 using namespace G4DNAPARSER;                       60 using namespace G4DNAPARSER;
 55 CommandLineParser* parser(0);                      61 CommandLineParser* parser(0);
 56                                                    62 
 57 void Parse(int& argc, char** argv);                63 void Parse(int& argc, char** argv);
 58                                                    64 
 59 int main(int argc, char** argv)                <<  65 int main(int argc,char** argv) 
 60 {                                                  66 {
                                                   >>  67   // Choose the Random engine
                                                   >>  68   
                                                   >>  69   G4Random::setTheEngine(new CLHEP::RanecuEngine);
                                                   >>  70 
 61   //////////                                       71   //////////
 62   // Parse options given in commandLine            72   // Parse options given in commandLine
 63   //                                               73   //
 64   Parse(argc, argv);                               74   Parse(argc, argv);
 65                                                    75 
 66   //////////                                       76   //////////
 67   // Construct the run manager according to wh     77   // Construct the run manager according to whether MT is activated or not
 68   //                                               78   //
 69   Command* commandLine(0);                         79   Command* commandLine(0);
 70                                                    80 
 71   auto* runManager = G4RunManagerFactory::Crea <<  81 #ifdef G4MULTITHREADED
 72   if ((commandLine = parser->GetCommandIfActiv <<  82   G4MTRunManager* runManager= new G4MTRunManager;
                                                   >>  83   if ((commandLine = parser->GetCommandIfActive("-mt")))
                                                   >>  84   {
 73     int nThreads = 2;                              85     int nThreads = 2;
 74     if (commandLine->GetOption() == "NMAX") {  <<  86     if(commandLine->GetOption() == "NMAX")
 75       nThreads = G4Threading::G4GetNumberOfCor <<  87     {
                                                   >>  88      nThreads = G4Threading::G4GetNumberOfCores();
 76     }                                              89     }
 77     else {                                     <<  90     else
 78       nThreads = G4UIcommand::ConvertToInt(com <<  91     {
                                                   >>  92      nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
 79     }                                              93     }
 80                                                <<  94     G4cout << "===== WholeNuclearDNA is started with "
                                                   >>  95        << runManager->GetNumberOfThreads()
                                                   >>  96        << " threads =====" << G4endl;
                                                   >>  97  
 81     runManager->SetNumberOfThreads(nThreads);      98     runManager->SetNumberOfThreads(nThreads);
 82                                                << 
 83     G4cout << "===== WholeNuclearDNA is starte << 
 84            << " threads =====" << G4endl;      << 
 85   }                                                99   }
                                                   >> 100 #else
                                                   >> 101   G4RunManager* runManager = new G4RunManager();
                                                   >> 102 #endif
 86                                                   103 
 87   // Set mandatory user initialization classes    104   // Set mandatory user initialization classes
 88   DetectorConstruction* detector = new Detecto    105   DetectorConstruction* detector = new DetectorConstruction;
 89   runManager->SetUserInitialization(detector);    106   runManager->SetUserInitialization(detector);
 90   runManager->SetUserInitialization(new Physic    107   runManager->SetUserInitialization(new PhysicsList);
 91   runManager->SetUserInitialization(new Action    108   runManager->SetUserInitialization(new ActionInitialization());
 92                                                << 109   
 93   // Initialize G4 kernel                         110   // Initialize G4 kernel
 94   runManager->Initialize();                       111   runManager->Initialize();
 95                                                   112 
 96   // Initialize visualization                     113   // Initialize visualization
 97   G4VisManager* visManager = new G4VisExecutiv    114   G4VisManager* visManager = new G4VisExecutive;
 98   // G4VisExecutive can take a verbosity argum    115   // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
 99   // G4VisManager* visManager = new G4VisExecu    116   // G4VisManager* visManager = new G4VisExecutive("Quiet");
100   visManager->Initialize();                       117   visManager->Initialize();
101                                                   118 
102   // Get the pointer to the User Interface man    119   // Get the pointer to the User Interface manager
103   G4UImanager* UImanager = G4UImanager::GetUIp    120   G4UImanager* UImanager = G4UImanager::GetUIpointer();
104   G4UIExecutive* ui(0);                           121   G4UIExecutive* ui(0);
105                                                   122 
106   // interactive mode : define UI session         123   // interactive mode : define UI session
107   if ((commandLine = parser->GetCommandIfActiv << 124   if ((commandLine = parser->GetCommandIfActive("-gui")))
108     ui = new G4UIExecutive(argc, argv, command << 125   {
                                                   >> 126     ui = new G4UIExecutive(argc, argv,
                                                   >> 127                            commandLine->GetOption());
109                                                   128 
110     if (ui->IsGUI()) UImanager->ApplyCommand(" << 129     if(ui->IsGUI())
                                                   >> 130        UImanager->ApplyCommand("/control/execute gui.mac");
111                                                   131 
112     if (parser->GetCommandIfActive("-novis") = << 132     if(parser->GetCommandIfActive("-novis") == 0)
113     // visualization is used by default           133     // visualization is used by default
114     {                                             134     {
115       if ((commandLine = parser->GetCommandIfA << 135       if((commandLine = parser->GetCommandIfActive("-vis")))
116       // select a visualization driver if need    136       // select a visualization driver if needed (e.g. HepFile)
117       {                                           137       {
118         UImanager->ApplyCommand(G4String("/vis << 138         UImanager->ApplyCommand(G4String("/vis/open ")+
                                                   >> 139                                 commandLine->GetOption());
119       }                                           140       }
120       else                                        141       else
121       // by default OGL is used                   142       // by default OGL is used
122       {                                           143       {
123         UImanager->ApplyCommand("/vis/open OGL    144         UImanager->ApplyCommand("/vis/open OGL 800x600-0+0");
124       }                                           145       }
125       UImanager->ApplyCommand("/control/execut    146       UImanager->ApplyCommand("/control/execute vis.mac");
126     }                                             147     }
127   }                                               148   }
128   else                                            149   else
129   // to be use visualization file (= store the    150   // to be use visualization file (= store the visualization into
130   // an external file:                            151   // an external file:
131   // ASCIITree ;  DAWNFILE ; HepRepFile ; VRML    152   // ASCIITree ;  DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
132   {                                               153   {
133     if ((commandLine = parser->GetCommandIfAct << 154     if ((commandLine = parser->GetCommandIfActive("-vis")))
134       UImanager->ApplyCommand(G4String("/vis/o << 155     {
                                                   >> 156       UImanager->ApplyCommand(G4String("/vis/open ")+commandLine->GetOption());
135       UImanager->ApplyCommand("/control/execut    157       UImanager->ApplyCommand("/control/execute vis.mac");
136     }                                             158     }
137   }                                               159   }
138                                                   160 
139   if ((commandLine = parser->GetCommandIfActiv << 161   if ((commandLine = parser->GetCommandIfActive("-mac")))
                                                   >> 162   {
140     G4String command = "/control/execute ";       163     G4String command = "/control/execute ";
141     UImanager->ApplyCommand(command + commandL    164     UImanager->ApplyCommand(command + commandLine->GetOption());
142   }                                               165   }
143   else {                                       << 166   else
                                                   >> 167   {
144     UImanager->ApplyCommand("/control/execute     168     UImanager->ApplyCommand("/control/execute wholeNuclearDNA.in");
145   }                                               169   }
146                                                   170 
147   if ((commandLine = parser->GetCommandIfActiv << 171   if ((commandLine = parser->GetCommandIfActive("-gui")))
                                                   >> 172   { 
148 #ifdef G4UI_USE_QT                                173 #ifdef G4UI_USE_QT
149     G4UIQt* UIQt = static_cast<G4UIQt*>(UImana << 174     G4UIQt* UIQt = static_cast<G4UIQt*> (UImanager->GetG4UIWindow());
150     if (UIQt) {                                << 175     if ( UIQt) {
151       UIQt->AddViewerTabFromFile("README", "RE << 176       UIQt->AddViewerTabFromFile("README", "README from "+ G4String(argv[0]));
152     }                                             177     }
153 #endif                                            178 #endif
154     ui->SessionStart();                           179     ui->SessionStart();
155     delete ui;                                    180     delete ui;
156   }                                               181   }
157                                                   182 
158   delete visManager;                              183   delete visManager;
159   delete runManager;                              184   delete runManager;
160                                                   185 
161   return 0;                                       186   return 0;
162 }                                                 187 }
163                                                   188 
164 //....oooOO0OOooo........oooOO0OOooo........oo    189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165                                                   190 
166 void GetNameAndPathOfExecutable(char** argv, G << 191 void GetNameAndPathOfExecutable(char** argv,
                                                   >> 192                                 G4String& executable,
                                                   >> 193                                 G4String& path)
167 {                                                 194 {
168   // Get the last position of '/'                 195   // Get the last position of '/'
169   std::string aux(argv[0]);                       196   std::string aux(argv[0]);
170                                                   197 
171   // get '/' or '\\' depending on unix/mac or     198   // get '/' or '\\' depending on unix/mac or windows.
172 #if defined(_WIN32) || defined(WIN32)             199 #if defined(_WIN32) || defined(WIN32)
173   int pos = aux.rfind('\\');                      200   int pos = aux.rfind('\\');
174 #else                                             201 #else
175   int pos = aux.rfind('/');                       202   int pos = aux.rfind('/');
176 #endif                                            203 #endif
177                                                   204 
178   // Get the path and the name                    205   // Get the path and the name
179   path = aux.substr(0, pos + 1);                  206   path = aux.substr(0, pos + 1);
180   executable = aux.substr(pos + 1);               207   executable = aux.substr(pos + 1);
181 }                                                 208 }
182                                                   209 
183 //....oooOO0OOooo........oooOO0OOooo........oo    210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184                                                   211 
185 void Parse(int& argc, char** argv)                212 void Parse(int& argc, char** argv)
186 {                                                 213 {
187   //////////                                      214   //////////
188   // Parse options given in commandLine           215   // Parse options given in commandLine
189   //                                              216   //
190   parser = CommandLineParser::GetParser();        217   parser = CommandLineParser::GetParser();
191                                                   218 
192   parser->AddCommand("-gui", Command::OptionNo << 219   parser->AddCommand("-gui",
193                      "Select geant4 UI or just << 220                      Command::OptionNotCompulsory,
194                                                << 221                     "Select geant4 UI or just launch a geant4 terminal session",
195   parser->AddCommand("-mac", Command::WithOpti << 222                     "qt");
196                                                << 223 
197   // You cann your own command, as for instanc << 224   parser->AddCommand("-mac",
198   //  parser->AddCommand("-seed",              << 225                      Command::WithOption,
199   //                     Command::WithOption,  << 226                      "Give a mac file to execute",
200   //                     "Give a seed value in << 227                      "macFile.mac");
201   // it is then up to you to manage this optio << 228 
202                                                << 229 // You cann your own command, as for instance:
203   parser->AddCommand("-mt", Command::WithOptio << 230 //  parser->AddCommand("-seed", 
                                                   >> 231 //                     Command::WithOption,
                                                   >> 232 //                     "Give a seed value in argument to be tested", "seed");
                                                   >> 233 // it is then up to you to manage this option
                                                   >> 234 
                                                   >> 235 #ifdef G4MULTITHREADED
                                                   >> 236   parser->AddCommand("-mt",
                                                   >> 237                      Command::WithOption,
                                                   >> 238                      "Launch in MT mode (events computed in parallel)", 
204                      "2");                        239                      "2");
                                                   >> 240 #endif
205                                                   241 
206   parser->AddCommand("-vis", Command::WithOpti << 242   parser->AddCommand("-vis",
                                                   >> 243                      Command::WithOption,
                                                   >> 244                      "Select a visualization driver",
207                      "OGL 600x600-0+0");          245                      "OGL 600x600-0+0");
208                                                   246 
209   parser->AddCommand("-novis", Command::Withou << 247   parser->AddCommand("-novis",
                                                   >> 248                      Command::WithoutOption,
                                                   >> 249                      "Deactivate visualization when using GUI");
210                                                   250 
211   G4String exec;                                  251   G4String exec;
212   G4String path;                                  252   G4String path;
213   GetNameAndPathOfExecutable(argv, exec, path)    253   GetNameAndPathOfExecutable(argv, exec, path);
214                                                   254 
215   parser->AddCommand("-out", Command::OptionNo << 255   parser->AddCommand("-out",
                                                   >> 256                      Command::OptionNotCompulsory,
                                                   >> 257                      "Output files (ROOT is used by default)", 
216                      exec);                       258                      exec);
217                                                   259 
218   //////////                                      260   //////////
219   // If -h or --help is given in option : prin    261   // If -h or --help is given in option : print help and exit
220   //                                              262   //
221   if (parser->Parse(argc, argv) != 0)  // help << 263   if (parser->Parse(argc, argv) != 0) // help is being printed
222   {                                               264   {
223     // if you are using ROOT, create a TApplic    265     // if you are using ROOT, create a TApplication in this condition in order
224     // to print the help from ROOT as well        266     // to print the help from ROOT as well
225     CommandLineParser::DeleteInstance();          267     CommandLineParser::DeleteInstance();
226     std::exit(0);                                 268     std::exit(0);
227   }                                               269   }
228                                                   270 
229   ///////////                                     271   ///////////
230   // Kill application if wrong argument in com    272   // Kill application if wrong argument in command line
231   //                                              273   //
232   if (parser->CheckIfNotHandledOptionsExists(a << 274   if (parser->CheckIfNotHandledOptionsExists(argc, argv))
                                                   >> 275   {
233     // if you are using ROOT, you should initi    276     // if you are using ROOT, you should initialise your TApplication
234     // before this condition                      277     // before this condition
235     abort();                                      278     abort();
236   }                                               279   }
237 }                                                 280 }
                                                   >> 281 
                                                   >> 282 
238                                                   283