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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/advanced/CaTS/CaTS.cc (Version 11.3.0) and /examples/advanced/CaTS/CaTS.cc (Version 10.7.p1)


  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 //--------------------------------------------    
 27 //*            |\___/|                            
 28 //*            )     (                            
 29 //*           =\     /=                           
 30 //*             )===(                             
 31 //*            /     \     CaTS: Calorimeter a    
 32 //*            |     |     is a flexible and e    
 33 //*           /       \    for the simulation     
 34 //*       \       /    systems                    
 35 //*            \__  _/     https://github.com/    
 36 //*          ( (                                  
 37 //*           ) )                                 
 38 //*              (_(                              
 39 //* CaTS also serves as an example that demons    
 40 //* opticks from within Geant4 for the creatio    
 41 //* optical photons.                              
 42 //* see https://bitbucket.org/simoncblyth/opti    
 43 //* Ascii Art by Joan Stark: https://www.ascii    
 44 //--------------------------------------------    
 45 //                                                
 46 // *******************************************    
 47 //                                                
 48 //  CaTS (Calorimetry and Tracking Simulation)    
 49 //                                                
 50 //  Authors : Hans Wenzel                         
 51 //            Soon Yung Jun                       
 52 //            (Fermi National Accelerator Labo    
 53 //                                                
 54 // History                                        
 55 //   October 18th, 2021 : first implementation    
 56 //                                                
 57 // *******************************************    
 58 //                                                
 59 /// \file CaTS.cc                                 
 60 /// \brief main driver of CaTS                    
 61 //                                                
 62 // project headers:                               
 63 #include "ActionInitialization.hh"                
 64 #include "CaTSVersion.hh"                         
 65 #include "ConfigurationManager.hh"                
 66 #include "DetectorConstruction.hh"                
 67 #include "PhysicsConfigurator.hh"                 
 68 // Geant4 headers:                                
 69 #include "G4RunManager.hh"                        
 70 #include "G4RunManagerFactory.hh"                 
 71 #include "G4Timer.hh"                             
 72 #include "G4UIExecutive.hh"                       
 73 #include "G4UImanager.hh"                         
 74 #include "G4VModularPhysicsList.hh"               
 75 #include "G4VisExecutive.hh"                      
 76 #include <G4Threading.hh>                         
 77 #ifdef WITH_G4OPTICKS                             
 78 #  include "OPTICKS_LOG.hh"                       
 79 #endif                                            
 80 #include "TROOT.h"                                
 81 #include <thread>                                 
 82                                                   
 83 int main(int argc, char** argv)                   
 84 {                                                 
 85 #ifdef G4MULTITHREADED                            
 86   G4int nThreads = 0;                             
 87 #endif                                            
 88   G4bool interactive   = false;                   
 89   G4String physicsconf = "";                      
 90   G4String gdmlfile    = "";                      
 91   G4String macrofile   = "";                      
 92   G4UIExecutive* ui    = nullptr;                 
 93   for(G4int i = 1; i < argc; i = i + 2)           
 94   {                                               
 95     if(G4String(argv[i]) == "-g")                 
 96     {                                             
 97       gdmlfile = argv[i + 1];                     
 98     }                                             
 99     else if(G4String(argv[i]) == "-pl")           
100     {                                             
101       physicsconf = G4String(argv[i + 1]);        
102     }                                             
103     else if(G4String(argv[i]) == "-m")            
104     {                                             
105       macrofile = G4String(argv[i + 1]);          
106     }                                             
107 #ifdef G4MULTITHREADED                            
108     else if(G4String(argv[i]) == "-t")            
109     {                                             
110       nThreads = G4UIcommand::ConvertToInt(arg    
111     }                                             
112 #endif                                            
113   }                                               
114   if(gdmlfile == "")                              
115   {                                               
116     G4cout << "Error! Mandatory input file is     
117     G4cout << G4endl;                             
118     G4cout << G4endl;                             
119     G4cout << "Usage:  CaTS -g input_gdml_file    
120     G4cout << G4endl;                             
121     return -1;                                    
122   }                                               
123   G4cout                                          
124     << G4endl                                     
125     << "--------------------------------------    
126     << G4endl                                     
127     << "*            |\\___/|                     
128        "*"                                        
129     << G4endl                                     
130     << "*            )     (                      
131     << G4endl                                     
132     << "*           =\\     /=                    
133        "*"                                        
134     << G4endl                                     
135     << "*             )===(      Welcome to:      
136     << G4endl                                     
137     << "*            /     \\     CaTS: Calori    
138        "*"                                        
139     << G4endl                                     
140     << "*            |     |     a flexible an    
141     << G4endl                                     
142     << "*           /       \\    for the simu    
143        "*"                                        
144     << G4endl                                     
145     << "*     \\       /    systems               
146     << G4endl                                     
147     << "*            \\__  _/     https://gith    
148        "*"                                        
149     << G4endl                                     
150     << "*              ( (                        
151     << G4endl << "*         ) )      Version:     
152     << "                          *" << G4endl    
153     << "*              (_(       Date:    " <<    
154     << G4endl                                     
155     << "--------------------------------------    
156     << G4endl << G4endl;                          
157   if(physicsconf == "")                           
158   {                                               
159     G4cout << "Warning! no physics configurati    
160     G4cout << "Using default FTFP_BERT+OPTICAL    
161     physicsconf = "FTFP_BERT+OPTICAL+STEPLIMIT    
162     G4cout << "Usage:  CaTS -pl physicsconfigu    
163     G4cout << G4endl;                             
164   }                                               
165   if(macrofile == "")                             
166   {                                               
167     G4cout << "Warning! no macro specified!" <    
168     G4cout << "assume interactive mode" << G4e    
169     interactive = true;                           
170     ui          = new G4UIExecutive(argc, argv    
171     G4cout << G4endl;                             
172     G4cout << G4endl;                             
173     G4cout << "Usage:  CaTS -m macrofile" << G    
174     G4cout << G4endl;                             
175   }                                               
176   G4Timer* eventTimer = new G4Timer;              
177   eventTimer->Start();                            
178 #ifdef WITH_G4OPTICKS                             
179   OPTICKS_LOG(argc, argv);                        
180 #endif                                            
181   G4VModularPhysicsList* phys =                   
182     PhysicsConfigurator::getInstance()->Constr    
183   G4String DumpFilename = gdmlfile + "_G4";       
184   ConfigurationManager::getInstance()->setGDML    
185   DetectorConstruction* dc = new DetectorConst    
186   // Run manager                                  
187   auto* rm = G4RunManagerFactory::CreateRunMan    
188                                                   
189   // G4RunManagerFactory::CreateRunManager(G4R    
190 #ifdef G4MULTITHREADED                            
191   // number of threads not set so use number o    
192   if(nThreads == 0)                               
193   {                                               
194     nThreads = G4Threading::G4GetNumberOfCores    
195   }                                               
196   if(nThreads > 0)                                
197   {                                               
198     rm->SetNumberOfThreads(nThreads);             
199   }                                               
200 #endif                                            
201   rm->SetUserInitialization(dc);                  
202   rm->SetUserInitialization(phys);                
203   ActionInitialization* actionInitialization =    
204   rm->SetUserInitialization(actionInitializati    
205   G4UImanager* UImanager = G4UImanager::GetUIp    
206   if(interactive)                                 
207   {                                               
208     G4VisManager* visManager = new G4VisExecut    
209     visManager->Initialize();                     
210     UImanager->ApplyCommand("/control/execute     
211     ui->SessionStart();                           
212     delete ui;                                    
213     delete visManager;                            
214   }                                               
215   else                                            
216   {                                               
217     // batch mode                                 
218     G4String command = "/control/execute ";       
219     UImanager->ApplyCommand(command + macrofil    
220                                                   
221     delete ui;                                    
222   }                                               
223   eventTimer->Stop();                             
224   double totalCPUTime =                           
225     eventTimer->GetUserElapsed() + eventTimer-    
226   G4int precision_t          = G4cout.precisio    
227   std::ios::fmtflags flags_t = G4cout.flags();    
228   G4cout.setf(std::ios::fixed, std::ios::float    
229   G4cout << "TimeTotal> " << eventTimer->GetRe    
230          << G4endl;                               
231   G4cout.setf(flags_t);                           
232   G4cout.precision(precision_t);                  
233   delete eventTimer;                              
234   delete rm;                                      
235   return 0;                                       
236 }                                                 
237