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