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


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