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


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