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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 11.2.2)


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