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

Last change on this file since 1228 was 807, checked in by garnier, 17 years ago

update

File size: 4.9 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#ifdef G4UI_USE_XM
47#include "G4UIXm.hh"
48#endif
49#include "Randomize.hh"
50#ifdef G4VIS_USE
51#include "G4VisExecutive.hh"
52#endif
53
54#include "G4ios.hh"
55#include <stdlib.h>
56
57
58int main(int argc,char** argv) {
59
60 // Seed the random number generator manually
61 // ------------------------------------------
62
63 G4long myseed = 345354;
64
65 CLHEP::HepRandom::setTheSeed(myseed);
66
67 // Run manager
68
69 G4RunManager * runManager = new G4RunManager;
70 //Job and Run options.
71 RichTbRunConfig* rConfig= new RichTbRunConfig();
72 // Datafile streams for input and output
73 RichTbIOData* rIOData = new RichTbIOData( rConfig );
74 RichTbDetectorConstruction* RichTbDet
75 = new RichTbDetectorConstruction(rConfig);
76
77 runManager->SetUserInitialization(RichTbDet);
78
79 RichTbPhysicsList* RichTbPhy
80 =new RichTbPhysicsList(rConfig);
81
82 runManager-> SetUserInitialization(RichTbPhy);
83
84
85
86// UserAction classes - optional
87
88 G4VisManager* visManager = new G4VisExecutive();
89 visManager->SetVerboseLevel(0);
90 visManager->Initialize();
91
92 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
93 G4cout<<" PVVisManager "<<pVVisManager<<G4endl;
94 G4cout<<"VisManager "<<visManager<<G4endl;
95
96 runManager->SetUserAction(new RichTbRunAction);
97
98 RichTbPrimaryGeneratorAction* PrimaryGenAction =
99 new RichTbPrimaryGeneratorAction(RichTbDet);
100
101 runManager->SetUserAction( PrimaryGenAction );
102
103 RichTbEventAction* eventAction=
104 new RichTbEventAction(rConfig,visManager,
105 rIOData);
106
107 runManager->SetUserAction(eventAction);
108
109 runManager->SetUserAction(new RichTbStackingAction);
110
111 RichTbSteppingAction* StepAction= new RichTbSteppingAction(rConfig, PrimaryGenAction );
112 runManager->SetUserAction(StepAction);
113
114 runManager->SetUserAction(new RichTbTrackingAction);
115
116 G4UImanager* UI = G4UImanager::GetUIpointer();
117
118 G4UIsession* session=0;
119
120 //Initialize G4 kernel
121 runManager -> Initialize();
122
123 if(argc==1){
124
125 session = new G4UIterminal;
126 }
127
128 if (session){ // Interactive mode
129
130 UI->ApplyCommand("/run/verbose 0");
131 UI->ApplyCommand("/event/verbose 0");
132 UI->ApplyCommand("/tracking/verbose 0");
133 UI->ApplyCommand("/particle/process/verbose 0");
134
135 session->SessionStart();
136 delete session;
137
138 }
139 else // Batch mode
140 {
141 G4UImanager * UI = G4UImanager::GetUIpointer();
142 G4String command = "/control/execute ";
143 G4String fileName = argv[1];
144 UI->ApplyCommand(command+fileName);
145 }
146#ifdef G4VIS_USE
147 delete visManager;
148#endif
149
150 G4cout << "\nVisManager deleted..\n" <<G4endl;
151
152 delete runManager;
153
154 G4cout << "\nRunManager deleted..\n" <<G4endl;
155
156 return 0;
157}
158
159
160
161
162
163
Note: See TracBrowser for help on using the repository browser.