Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ml2.cc File Reference
#include "ML2Main.hh"
#include "ML2PrimaryGenerationAction.hh"
#include "ML2WorldConstruction.hh"
#include "ML2PhysicsList.hh"
#include "ML2SteppingAction.hh"
#include "ML2EventAction.hh"
#include "ML2TrackingAction.hh"
#include "G4UImanager.hh"
#include "G4Timer.hh"
Include dependency graph for ml2.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 82 of file ml2.cc.

83 {
84  // instantiate the world class
86 
87  G4RunManager *runManager=new G4RunManager();
88  ML2PhysicsList *physics=new ML2PhysicsList();
89  runManager->SetUserInitialization(physics);
90 
91  // build the primary generator
94 
95  // build the main messenger class for the input data
96  CML2CInputData *myInputData;
97  myInputData=new CML2CInputData();
98 
99  // initialize the primary generator variables
100  gun->inizialize(&myInputData->inputData.primaryParticleData);
101 
102  // according to the number of the launching line
103  if (argc==1)
104  {
105  myInputData->inputData.generalData.seed=1;
106  myInputData->inputData.generalData.StartFileInputData="ml2.mac";
107  }
108  if (argc==2)
109  {
110  myInputData->inputData.generalData.seed=1;
111  myInputData->inputData.generalData.StartFileInputData=(G4String)argv[1];
112  }
113  if (argc==3)
114  {
115  sscanf(argv[2],"%d", &myInputData->inputData.generalData.seed);
116  myInputData->inputData.generalData.StartFileInputData=(G4String)argv[1];
117  }
118 
119  // read the main mac file and execute the commands
120  G4UImanager* UImanager = G4UImanager::GetUIpointer();
121  G4String command = "/control/execute ";
122  UImanager->ApplyCommand(command+myInputData->inputData.generalData.StartFileInputData);
123 
124 
125  // set and initialize the random generator
128 
129  // create the world class
130  if (!myWorld->create(&myInputData->inputData, myInputData->getbOnlyVisio()))
131  {
132  return 1; // if it fails to create the world
133  }
134  else
135  {
136  // initialize the primary generator according to the choosen particle source
138  }
139 
140  // instantiate the convergence control class and assign it to myStepAction
142 
143 
144  // build the ML2RunAction to assign the single phantom name at each run
145  CML2RunAction *myRunAction=new CML2RunAction(convergence, myInputData->inputData.generalData.nBeam, myInputData->bOnlyVisio);
146 
147  CML2SteppingAction *myStepAction=new CML2SteppingAction(convergence);
148  CML2EventAction *ML2EventAction = new CML2EventAction();
149 
150  runManager->SetUserInitialization(myWorld);
151  runManager->SetUserAction(myRunAction);
152  runManager->SetUserAction(gun);
153  runManager->SetUserAction(myStepAction);
154  runManager->SetUserAction(ML2EventAction);
155  runManager->SetUserAction(new CML2TrackingAction);
156  runManager->Initialize();
157 
158  // performances info
159  int nLoop=0;
160  G4Timer MyFullTime;
161  G4double loopElapsedTime;
162  G4bool bStopRun=false;
163  G4bool bNewGeometry=true;
164  if (myInputData->bOnlyVisio)
165  {
166 #ifdef G4VIS_USE
167  // visualization
168  myWorld->newGeometry();
169  convergence->setNewGeometry();
170  visio(argc, argv);
171 #endif
172  }
173  else
174  {
175  MyFullTime.Start();
176  // compute
177  while (bNewGeometry)
178  {
179  bNewGeometry=myWorld->newGeometry();
180  convergence->setNewGeometry();
181  if (bNewGeometry)
182  {
183  if (CML2PhantomConstruction::GetInstance()->getPhantomName()!="Dicom1")
185  std::cout<<"################ START NEW GEOMETRY ########################"<<'\n';
186  myRunAction->setActualLoop(nLoop);
187  while (!bStopRun)
188  {
189  runManager->BeamOn(myInputData->inputData.generalData.nBeam);
190  // check if the run has to be reapeted
191  bStopRun=convergence->stopRun();
192  }
193  nLoop=0;
194  std::cout<<"################ END NEW GEOMETRY ########################"<<'\n';
195  }
196  bStopRun=false;
197  }
198  MyFullTime.Stop();
199  loopElapsedTime=MyFullTime.GetUserElapsed();
200  std::cout << "loop elapsed time [s] : "<< loopElapsedTime << '\n';
201  std::cout <<'\n';
202  }
203  delete runManager;
204  return 0;
205 }
G4String fileExperimentalData
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
bool create(SInputData *inputData, bool bOnlyVisio)
CML2AcceleratorConstruction * getCML2AcceleratorConstruction()
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
static CML2WorldConstruction * GetInstance(void)
G4bool bCompareExp
G4String StartFileInputData
static void setTheSeed(long seed, int lux=3)
Definition: Random.cc:231
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
void design(G4double accTargetZPosition)
void inizialize(SPrimaryParticle *primaryParticleData)
G4int maxNumberOfEvents
bool G4bool
Definition: G4Types.hh:79
G4double GetUserElapsed() const
Definition: G4Timer.cc:130
int saving_in_Selected_Voxels_every_events
SPrimaryParticle primaryParticleData
SGeneralData generalData
G4bool getbOnlyVisio()
void Stop()
SInputData inputData
virtual void Initialize()
static CML2PrimaryGenerationAction * GetInstance(void)
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
void Start()
double G4double
Definition: G4Types.hh:76
G4String fileExperimentalDataOut
static CML2PhantomConstruction * GetInstance(void)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function: