source: trunk/examples/advanced/Rich/RichTbSim.cc @ 1321

Last change on this file since 1321 was 1313, checked in by garnier, 14 years ago

geant4.9.4 beta rc0

File size: 5.4 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// Rich Test Beam Simulation   Main program
27// History:
28// Created: Sajan Easo (Sajan.Easo@cern.ch)
29// Revision and changes: Patricia Mendez (Patricia.Mendez@cern.ch)
30// ----------------------------------------------------------------
31#include <iostream>
32#include "RichTbRunAction.hh"
33#include "RichTbEventAction.hh"
34#include "RichTbDetectorConstruction.hh"
35#include "RichTbPrimaryGeneratorAction.hh"
36#include "RichTbStackingAction.hh"
37#include "RichTbSteppingAction.hh"
38#include "RichTbTrackingAction.hh"
39#include "RichTbPhysicsList.hh"
40#include "G4VPhysicalVolume.hh"
41#include "G4RunManager.hh"
42#include "RichTbRunConfig.hh"
43#include "RichTbIOData.hh"
44#include "G4UImanager.hh"
45#include "G4UIterminal.hh"
46#include "QGSP_BIC_EMY.hh"
47
48#ifdef G4UI_USE_XM
49#include "G4UIXm.hh"
50#endif
51
52#include "Randomize.hh"
53
54#ifdef G4VIS_USE
55#include "G4VisExecutive.hh"
56#endif
57
58#ifdef G4UI_USE
59#include "G4UIExecutive.hh"
60#endif
61
62#include "G4ios.hh"
63#include <stdlib.h>
64
65
66int main(int argc,char** argv) {
67
68  // Seed the random number generator manually
69  // ------------------------------------------
70
71  G4long myseed = 345354;
72
73  CLHEP::HepRandom::setTheSeed(myseed);
74
75  // Run manager
76
77   G4RunManager * runManager = new G4RunManager;
78   //Job and Run  options.
79   RichTbRunConfig* rConfig= new RichTbRunConfig();
80   // Datafile streams for input and output
81   RichTbIOData* rIOData = new  RichTbIOData( rConfig );
82   RichTbDetectorConstruction* RichTbDet
83     = new  RichTbDetectorConstruction(rConfig);
84   
85   runManager->SetUserInitialization(RichTbDet);
86   
87   //***LOOKHERE*** : Choose the Physics List
88   RichTbPhysicsList* RichTbPhy =new RichTbPhysicsList(rConfig);
89   runManager->SetUserInitialization(RichTbPhy);        // Use example's Physics List
90   //runManager->SetUserInitialization(new QGSP_BIC_EMY); // Use QGSP_BIC_EMY
91   
92
93// UserAction classes - optional
94
95 #ifdef G4VIS_USE
96  G4VisManager* visManager = new G4VisExecutive();
97  visManager->SetVerboseLevel(0);
98  visManager->Initialize();
99
100   G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
101   G4cout<<" PVVisManager "<<pVVisManager<<G4endl;
102   G4cout<<"VisManager "<<visManager<<G4endl;
103#endif
104
105   runManager->SetUserAction(new RichTbRunAction);
106
107   RichTbPrimaryGeneratorAction* PrimaryGenAction =
108     new RichTbPrimaryGeneratorAction(RichTbDet);
109
110   runManager->SetUserAction( PrimaryGenAction );
111
112 #ifdef G4VIS_USE
113   RichTbEventAction* eventAction=new RichTbEventAction(rConfig,visManager,rIOData);
114#endif
115
116 #ifndef G4VIS_USE
117   RichTbEventAction* eventAction=new RichTbEventAction(rConfig,0,rIOData);
118#endif
119
120   runManager->SetUserAction(eventAction);
121
122   runManager->SetUserAction(new RichTbStackingAction);
123
124   RichTbSteppingAction* StepAction= new RichTbSteppingAction(rConfig, PrimaryGenAction );
125   runManager->SetUserAction(StepAction);
126   
127   runManager->SetUserAction(new RichTbTrackingAction);
128
129   G4UImanager* UI = G4UImanager::GetUIpointer(); 
130
131   G4UIsession* session=0;
132
133   //Initialize G4 kernel
134   runManager -> Initialize();
135
136   if(argc==1){
137
138       session = new G4UIterminal;
139   }
140
141  if (session){    // Interactive mode 
142
143    UI->ApplyCommand("/run/verbose 0");
144    UI->ApplyCommand("/event/verbose 0");
145    UI->ApplyCommand("/tracking/verbose 0");
146    UI->ApplyCommand("/particle/process/verbose 0");
147
148    session->SessionStart();
149    delete session;
150
151  }
152  else    // Batch mode
153  {
154   G4UImanager * UI = G4UImanager::GetUIpointer();
155   G4String command = "/control/execute ";
156   G4String fileName = argv[1];
157   UI->ApplyCommand(command+fileName);
158  }
159#ifdef G4VIS_USE
160  delete visManager;
161  G4cout << "\nVisManager deleted..\n" <<G4endl;
162#endif
163
164#ifdef G4UI_USE
165      G4UIExecutive * ui = new G4UIExecutive(argc,argv);     
166      ui->SessionStart();
167      delete ui;
168#endif
169
170   delete runManager;
171
172  G4cout << "\nRunManager deleted..\n" <<G4endl;
173
174  return 0;
175}
176
177
178
179
180
181
Note: See TracBrowser for help on using the repository browser.