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3 ] [ 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/geometry/vecGeomNavigation/exampleVecGeomNav.cc (Version 11.3.0) and /examples/extended/geometry/vecGeomNavigation/exampleVecGeomNav.cc (Version 9.5.p2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //  Author: J. Apostolakis, S. Wenzel,  2018-2    
 27 //                                                
 28 //  Started from FullCMS Geant4 application by    
 29 //--------------------------------------------    
 30                                                   
 31 #include "FTFP_BERT.hh"                           
 32 #include "VG01ActionInitialization.hh"            
 33 #include "VG01DetectorConstruction.hh"            
 34 #include "VG01SteppingVerboseWithDir.hh"          
 35                                                   
 36 #include "G4RunManager.hh"                        
 37 #include "G4RunManagerFactory.hh"                 
 38 #include "G4StepLimiterPhysics.hh"                
 39 #include "G4UImanager.hh"                         
 40 #include "G4UIsession.hh"                         
 41 #include "G4UIterminal.hh"                        
 42 #include "G4VModularPhysicsList.hh"               
 43 #include "Randomize.hh"                           
 44                                                   
 45 #include <iomanip>                                
 46 #include <iostream>                               
 47                                                   
 48 // For interactivity                              
 49 #include "G4UIExecutive.hh"                       
 50 #include "G4VisExecutive.hh"                      
 51                                                   
 52 static G4bool parUseVecGeom = true;               
 53 static G4bool parCompareG4 = false;               
 54 static G4bool parInteractive = false;             
 55 static std::string parMacroFileName = "";         
 56 static std::string parGDMLFile = "TestNTST.gdm    
 57                                                   
 58 void GetInputArguments(int argc, char** argv);    
 59 void PrintUsage();                                
 60                                                   
 61 int main(int argc, char** argv)                   
 62 {                                                 
 63   //                                              
 64   // get input arguments                          
 65   GetInputArguments(argc, argv);                  
 66   G4cout << " ========== Running exampleVecGeo    
 67          << "   GDML geometry file          =     
 68          << "   Geant4 macro                =     
 69          << "   Use VecGeom (VG) navigation =     
 70          << "   Compare G4 vs VG navigation =     
 71          << " ================================    
 72                                                   
 73   // Use custom stepping verbosity                
 74   G4VSteppingVerbose::SetInstance(new VG01Step    
 75                                                   
 76   // Construct the run manager                    
 77   //                                              
 78   G4RunManager* runManager = G4RunManagerFacto    
 79   //  or G4RunManagerType::Default to get Task    
 80                                                   
 81   // set mandatory initialization classes         
 82   //                                              
 83   // 1. Detector construction                     
 84   //                                              
 85   VG01DetectorConstruction* detector = new VG0    
 86   detector->SetGDMLFileName(parGDMLFile);         
 87   detector->SetUseVecGeom(parUseVecGeom);         
 88   runManager->SetUserInitialization(detector);    
 89                                                   
 90   // 2. Physics list                              
 91   //                                              
 92   G4VModularPhysicsList* physicsList = new FTF    
 93   physicsList->RegisterPhysics(new G4StepLimit    
 94   runManager->SetUserInitialization(physicsLis    
 95                                                   
 96   // 3. User action                               
 97   //                                              
 98   runManager->SetUserInitialization(new VG01Ac    
 99                                                   
100   // 4. Run the simulation in batch mode, exce    
101   //                                              
102   G4UImanager* UImgr = G4UImanager::GetUIpoint    
103   G4String command = "/control/execute ";         
104   if (parMacroFileName != "-") UImgr->ApplyCom    
105                                                   
106   // 5. Run the simulation in Interactive mode    
107   //                                              
108   if (parInteractive) {                           
109     G4UIExecutive* uiExec = 0;                    
110     uiExec = new G4UIExecutive(argc, argv);       
111                                                   
112     // Initialize visualization                   
113     //                                            
114     G4VisManager* visManager = new G4VisExecut    
115     // G4VisExecutive can take a verbosity arg    
116     // G4VisManager* visManager = new G4VisExe    
117     visManager->Initialize();                     
118                                                   
119     // UImgr->ApplyCommand("/control/execute i    
120                                                   
121     // interactive mode                           
122     uiExec->SessionStart();                       
123                                                   
124     // Cleanup                                    
125     delete uiExec;                                
126     delete visManager;                            
127   }                                               
128   else {                                          
129     // Print out the final random number - for    
130     G4cout << G4endl                              
131            << " ==============================    
132            << " Final random number = " << G4U    
133            << " ==============================    
134            << G4endl;                             
135   }                                               
136   //                                              
137                                                   
138   // Delete the RunManager                        
139   delete runManager;                              
140   return 0;                                       
141 }                                                 
142                                                   
143 void horizontal_line(char c)                      
144 {                                                 
145   std::cout << "\n " << std::setw(100) << std:    
146 }                                                 
147                                                   
148 void PrintUsage()                                 
149 {                                                 
150   horizontal_line('=');                           
151   std::cout << "  Geant4 application to demons    
152             << std::endl                          
153             << "  Two modes: \n\n"                
154             << "   * 1 parameter this is treat    
155             << " \n"                              
156             << "   * Multiple Parameters: \n"     
157             << "      at least one of the foll    
158             << "       -m :   the standard Gea    
159             << "       -i :   interactive (aft    
160             << "      optionally one of the fo    
161             << "       -v :   flag  ==> run us    
162             << "       -o :   flag  ==> run us    
163             << "       -c :   flag  ==> compar    
164             << " (and report differences.) \n"    
165             << "      and other(s): \n"           
166             << "       -g :   GDML file with g    
167             << "\n"                               
168             << std::endl;                         
169   horizontal_line('=');                           
170 }                                                 
171                                                   
172 void GetInputArguments(int argc, char** argv)     
173 {                                                 
174   // process arguments                            
175   if (argc == 1) {                                
176     PrintUsage();                                 
177     exit(0);                                      
178   }                                               
179   if (argc == 2) {                                
180     parMacroFileName = argv[1];                   
181     G4cout << " argc = 2  -- Filename = " << p    
182     return;                                       
183   }                                               
184                                                   
185   // Adapted from examples/basic/B4/exampleB4a    
186   for (G4int i = 1; i < argc; ++i) {              
187     if (G4String(argv[i]) == "-m") {              
188       if (++i < argc) {                           
189         parMacroFileName = argv[i];               
190         G4cout << " arg-parsing:  Macro file n    
191       }                                           
192       else {                                      
193         G4cerr << " Parse Error: '-m' cannot b    
194         PrintUsage();                             
195         exit(1);                                  
196       }                                           
197     }                                             
198     else if (G4String(argv[i]) == "-g") {         
199       if (++i < argc) {                           
200         parGDMLFile = argv[i];                    
201         G4cout << " arg-parsing:  GDML file na    
202       }                                           
203       else {                                      
204         G4cerr << " Parse Error: '-m' cannot b    
205         PrintUsage();                             
206         exit(1);                                  
207       }                                           
208     }                                             
209     else if (G4String(argv[i]) == "-v") {         
210       parUseVecGeom = true;                       
211     }                                             
212     else if (G4String(argv[i]) == "-o") {         
213       parUseVecGeom = false;                      
214     }                                             
215     else if (G4String(argv[i]) == "-c") {         
216       parCompareG4 = true;                        
217       parUseVecGeom = true;                       
218     }                                             
219     else {                                        
220       G4cerr << "  Unknown argument : " << arg    
221       PrintUsage();                               
222       exit(1);                                    
223     }                                             
224   }                                               
225                                                   
226   // check if mandatory Geant4 macro file was     
227   if (parMacroFileName == "" && !parInteractiv    
228     G4cerr << "  *** ERROR : either interactiv    
229            << G4endl;                             
230     PrintUsage();                                 
231     exit(-1);                                     
232   }                                               
233 }                                                 
234