source: trunk/examples/advanced/raredecay_calorimetry/PhotIn.cc @ 1319

Last change on this file since 1319 was 807, checked in by garnier, 16 years ago

update

File size: 13.3 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//
27// $Id: PhotIn.cc,v 1.10 2006/11/22 09:46:02 gcosmo Exp $
28// GEANT4 tag $Name:  $
29//
30//
31// --------------------------------------------------------------
32//      GEANT 4 - example/advanced/Photon_inefficiency
33//
34// --------------------------------------------------------------
35// Comments
36//
37// --------------------------------------------------------------
38
39//#define debug
40
41#include "G4RunManager.hh"
42#include "G4UImanager.hh"
43#include "G4UIterminal.hh"
44#include "G4UItcsh.hh"
45
46#ifdef G4VIS_USE
47#include "G4VisExecutive.hh"
48#endif
49
50#include "PhotInDetectorConstruction.hh"
51#include "PhotInDetectorMessenger.hh"
52#include "PhotInPhysicsList.hh"
53#include "PhotInPrimaryGeneratorAction.hh"
54#include "PhotInRunAction.hh"
55#include "PhotInEventAction.hh"
56#include "PhotInStackingAction.hh"
57#include "PhotInSteppingAction.hh"
58
59// Uncomment it if you wish to use old external Reference Physics Lists (+ in GNUmakefile)
60//// === Old Reference Physics Lists (external) ===
61//#include "FTFC.hh"
62//#include "FTFP.hh"
63//#include "LBE.hh"
64//#include "LHEP.hh"
65//#include "LHEP_BERT.hh"
66//#include "LHEP_BERT_HP.hh"
67//#include "LHEP_BIC.hh"
68//#include "LHEP_BIC_HP.hh"
69//#include "LHEP_EMV.hh"
70////#include "LHEP_GN.hh"
71////#include "LHEP_HP.hh"
72//#include "LHEP_LEAD.hh"
73//#include "LHEP_LEAD_HP.hh"
74//#include "LHEP_PRECO.hh"
75//#include "LHEP_PRECO_HP.hh"
76//#include "QGSC.hh"
77//#include "QGSC_LEAD.hh"
78//#include "QGSC_LEAD_HP.hh"
79//#include "QGSP.hh"
80//#include "QGSP.hh"
81//#include "QGSP_BERT.hh"
82//#include "QGSP_BERT_HP.hh"
83//#include "QGSP_BIC.hh"
84//#include "QGSP_EMV.hh"
85////#include "QGSP_GN.hh"
86//#include "QGSP_HP.hh"
87
88// Uncomment it if you wish to use new internal Reference Physics Lists (+ in GNUmakefile)
89//#include "G4ModularPhysicsList.hh"
90//// === Corresponding New Reference Physics Lists (internal) ===
91//#include "G4PL_CHIPS_QGS.hh"
92//#include "G4PL_CHIPS_FTF.hh"
93//#include "G4PL_CHIPS_LHE.hh"
94//#include "G4PL_FTFC_CASP.hh"
95//#include "G4PL_FTFC_CASP_GN_HP.hh"
96//#include "G4PL_FTFP_CASP.hh"
97//#include "G4PL_FTFP_CASP_GN_HP.hh"
98//#include "G4PL_UNDERGROUND.hh"
99//#include "G4PL_LHEP_CASP.hh"
100//#include "G4PL_LHEP_CASP_GN.hh"
101//#include "G4PL_LHEP_CASP_HP.hh"
102//#include "G4PL_LHEP_CASP_GN_HP.hh"
103//#include "G4PL_LHEP_BERT.hh"
104//#include "G4PL_LHEP_BERT_HP.hh"
105//#include "G4PL_LHEP_BERT_GN_HP.hh"
106//#include "G4PL_LHEP_BINC.hh"
107//#include "G4PL_LHEP_BINC_HP.hh"
108//#include "G4PL_LHEP_BINC_GN_HP.hh"
109//#include "G4PL_LHEP_MARS.hh"
110//#include "G4PL_LHEP_MARS_HP.hh"
111//#include "G4PL_LHEP_MARS_GN_HP.hh"
112//#include "G4PL_LHEP_PREC.hh"
113//#include "G4PL_LHEP_PREC_HP.hh"
114//#include "G4PL_LHEP_PREC_GN_HP.hh"
115//#include "G4PL_QGSC_CASP.hh"
116//#include "G4PL_QGSC_CASP_GN_HP.hh"
117//#include "G4PL_QGSC_MARS.hh"
118//#include "G4PL_QGSC_MARS_HP.hh"
119//#include "G4PL_QGSC_MARS_GN_HP.hh"
120//#include "G4PL_QGSP_CASP.hh"
121//#include "G4PL_QGSP_CASP_GN_HP.hh"
122//#include "G4PL_QGSP_BERT.hh"
123//#include "G4PL_QGSP_BERT_GN_HP.hh"
124//#include "G4PL_QGSP_BINC.hh"
125//#include "G4PL_QGSP_BINC_GN_HP.hh"
126//#include "G4PL_QGSP_CASP_GN.hh"
127//#include "G4PL_QGSP_CASP_GN_HP.hh"
128
129int main(int argc,char** argv)
130{
131#ifdef debug
132  G4cout<<"PhotIn: Example is started"<<G4endl;
133#endif
134
135 // Construct the default run manager
136 G4RunManager* runManager = new G4RunManager; // Del? M.K.
137
138#ifdef debug
139  G4cout<<"PhotIn: Run manager is created"<<G4endl;
140#endif
141
142  PhotInPhysicsList* physList = new PhotInPhysicsList; // Del? M.K.
143
144#ifdef debug
145  G4cout<<"PhotIn: PhotIn Physics List is constructed"<<G4endl;
146#endif
147
148  runManager->SetUserInitialization(physList);
149
150#ifdef debug
151  G4cout<<"PhotIn: PhotIn Physics List is transfered to Run Manager"<<G4endl;
152#endif
153  //***LOOKHERE***CHOOSE THE REFERENCE PHYSICS LISTS INSTEAD OF THE PhotInPhysicsList above
154  // ==== Initialization of old RPL ====
155  //runManager->SetUserInitialization(new LHEP);         // external (ext) LHEP     
156  // ==== Initialization of new RPL ====
157  //runManager->SetUserInitialization(new G4PL_CHIPS_QGS); // GHIPS+QGSC
158  //runManager->SetUserInitialization(new G4PL_CHIPS_FTF); // CHIPS+FTFC
159  //runManager->SetUserInitialization(new G4PL_CHIPS_LHE); // CHIPS+LHEP
160  //
161  //runManager->SetUserInitialization(new G4PL_FTFC_CASP_GN_HP);// int _GN_HP list
162  //runManager->SetUserInitialization(new G4PL_FTFC_CASP);// int FTFC_CASP == ext FTFC
163  //runManager->SetUserInitialization(new FTFC); // ext FTFC
164  //
165  //runManager->SetUserInitialization(new G4PL_FTFP_CASP_GN_HP);// int _GN_HP list
166  //runManager->SetUserInitialization(new G4PL_FTFP_CASP);// int FTFP_CASP == ext FTFP
167  //runManager->SetUserInitialization(new FTFP); // ext FTFP
168  //
169  //runManager->SetUserInitialization(new G4PL_LHEP_BERT_GN_HP);// int _GN_HP list
170  //runManager->SetUserInitialization(new LHEP_BERT_HP); // ext LHEP_BERT_HP
171  //runManager->SetUserInitialization(new G4PL_LHEP_BERT);// int LHEP_BERT == ext LHEP_BERT
172  //runManager->SetUserInitialization(new LHEP_BERT); // ext LHEP_BERT
173  //
174  //runManager->SetUserInitialization(new G4PL_LHEP_BINC_GN_HP);// int _GN_HP list
175  //runManager->SetUserInitialization(new LHEP_BIC_HP); // ext LHEP_BIC_HP
176  //runManager->SetUserInitialization(new G4PL_LHEP_BINC);// int LHEP_BINC == ext LHEP_BIC
177  //runManager->SetUserInitialization(new LHEP_BIC); // ext LHEP_BIC
178  //
179  //runManager->SetUserInitialization(new G4PL_LHEP_CASP_GN_HP);//int _GN_HP (no ext _HP)
180  //runManager->SetUserInitialization(new G4PL_LHEP_CASP);// int LHEP_CASP == ext LHEP
181  //runManager->SetUserInitialization(new LHEP_EMV); // ext LHEP_EMV (EM_7.0)
182  //runManager->SetUserInitialization(new LHEP); // ext LHEP
183  //
184  //runManager->SetUserInitialization(new G4PL_LHEP_MARS_GN_HP);// int _GN_HP list
185  //runManager->SetUserInitialization(new LHEP_LEAD_HP); // ext LHEP_LEAD_HP
186  //runManager->SetUserInitialization(new G4PL_LHEP_MARS);// int LHEP_MARS == ext LHEP_LEAD
187  //runManager->SetUserInitialization(new LHEP_LEAD); // ext LHEP_LEAD
188  //
189  //runManager->SetUserInitialization(new G4PL_LHEP_PREC_GN_HP);// int _GN_HP list
190  //runManager->SetUserInitialization(new LHEP_PRECO_HP); // ext LHEP_PRECO
191  //runManager->SetUserInitialization(new G4PL_LHEP_PREC);//int LHEP_PREC == ext LHEP_PRECO
192  //runManager->SetUserInitialization(new LHEP_PRECO); // ext LHEP_PRECO
193  //
194  //runManager->SetUserInitialization(new G4PL_QGSC_CASP_GN_HP);// int _GN_HP list
195  //runManager->SetUserInitialization(new G4PL_QGSC_CASP);// int QGSC_CASP == ext QGSC
196  //runManager->SetUserInitialization(new QGSC); // ext QGSC
197  //
198  //runManager->SetUserInitialization(new G4PL_QGSC_MARS_GN_HP);// int _GN_HP list **BAD**
199  //runManager->SetUserInitialization(new QGSC_LEAD_HP); // ext QGSC_LEAD_HP
200  //runManager->SetUserInitialization(new G4PL_QGSC_MARS);// int QGSC_MARS == ext QGSC_LEAD
201  //runManager->SetUserInitialization(new QGSC_LEAD); // ext QGSC_LEAD
202  //
203  //runManager->SetUserInitialization(new G4PL_QGSP_BERT_GN_HP);// int _GN_HP list
204  //runManager->SetUserInitialization(new QGSP_BERT_HP); // ext QGSP_BERT_HP
205  //runManager->SetUserInitialization(new G4PL_QGSP_BERT);// int QGSP_BERT == ext QGSP_BERT
206  //runManager->SetUserInitialization(new QGSP_BERT); // ext QGSP_BERT
207  //
208  //runManager->SetUserInitialization(new G4PL_QGSP_BINC_GN_HP);// int _GN_HP lists
209  //runManager->SetUserInitialization(new G4PL_QGSP_BINC);// int QGSP_BINC == ext QGSP_BIC
210  //runManager->SetUserInitialization(new QGSP_BIC); // ext QGSP_BIC
211  //
212  //runManager->SetUserInitialization(new G4PL_QGSP_CASP_GN_HP);// int _GN_HP list
213  //runManager->SetUserInitialization(new QGSP_HP); // ext QGSP_HP
214  //runManager->SetUserInitialization(new G4PL_QGSP_CASP);// int QGSP_CASP == ext QGSP
215  //runManager->SetUserInitialization(new QGSP_EMV); // ext QGSP_EMV (EM_7.0)
216  //runManager->SetUserInitialization(new QGSP); // ext QGSP
217
218  // ==== Initialization of Modular Physics List ====
219  //runManager->SetUserInitialization(new G4ModularPhysicsList);     // MPL     
220  //***endLOOKHERE***
221
222#ifdef debug
223  //G4cout<<"PhotIn: Old/New Reference Physics List LHEP is initialized"<<G4endl;
224#endif
225
226  // ================= This is a debugging function =====================
227  //runManager->SetUserAction(new PhotInSteppingAction);
228
229  // set mandatory initialization classes
230                G4double hx=.5*m;
231                G4double hy=.5*m;
232                G4double hz= m;
233  PhotInDetectorConstruction* detector = new PhotInDetectorConstruction(hx,hy,hz); // Del?
234  //detector->SetSectionHalfDimensions(0.5*m,0.5*m,m);// This is how it could be changed(-)
235
236#ifdef debug
237  G4cout<<"PhotIn: Detector is created with hx="<<hx<<", hy="<<hy<<", hz="<<hz<<G4endl;
238#endif
239   
240  // set user action classes
241  PhotInPrimaryGeneratorAction* primaryGenerator = new PhotInPrimaryGeneratorAction;
242  runManager->SetUserAction(primaryGenerator);
243
244#ifdef debug
245  G4cout<<"PhotIn: Primary Generator is constructed"<<G4endl;
246#endif
247
248                //PhotInDetectorMessenger* detectorMessenger=
249  //                        new PhotInDetectorMessenger(detector, primaryGenerator);//Del?
250  new PhotInDetectorMessenger(detector, primaryGenerator);
251
252#ifdef debug
253  G4cout<<"PhotIn: Detector Messenger is constructed"<<G4endl;
254#endif
255
256  runManager->SetUserInitialization(detector);
257
258#ifdef debug
259  G4cout<<"PhotIn: Detector Messenger is constructed"<<G4endl;
260#endif
261 
262#ifdef G4VIS_USE
263  // visualization manager
264  G4VisManager* visManager = new G4VisExecutive;
265  visManager->Initialize();
266#ifdef debug
267  G4cout<<"PhotIn: Visualization Manager is constructed and initialized"<<G4endl;
268#endif
269
270#endif
271
272  //PhotInPrimaryGeneratorAction* gen = (PhotInPrimaryGeneratorAction*)
273  //                       G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction();
274  //if(gen) gen->SetDetector(detector);
275  //else G4cout<<"---Warning--- PhotIn: PhotInPrimaryGeneratorAction* ="<<gen<<G4endl;
276  // In the example detectorMessenger is created only for DetectorConstruction to change it
277
278  primaryGenerator->SetDetector(detector);
279
280#ifdef debug
281  G4cout<<"PhotIn: Detector is transfered to the primary generator"<<G4endl;
282#endif
283
284  runManager->SetUserAction(new PhotInRunAction);
285
286#ifdef debug
287  G4cout<<"PhotIn: Run is constructed"<<G4endl;
288#endif
289
290  runManager->SetUserAction(new PhotInEventAction);
291
292#ifdef debug
293  G4cout<<"PhotIn: Event List is constructed"<<G4endl;
294#endif
295
296  runManager->SetUserAction(new PhotInStackingAction);
297 
298#ifdef debug
299  G4cout<<"PhotIn: Stacking Actions are constructed"<<G4endl;
300#endif
301
302  // Initialize G4 kernel
303  // runManager->Initialize(); // (?) (M.K.)
304     
305  // get the pointer to the User Interface manager
306  G4UImanager* UI = G4UImanager::GetUIpointer();
307
308#ifdef debug
309  G4cout<<"PhotIn: Start UI initialization"<<G4endl;
310#endif 
311
312  if (argc==1)   // Define UI session for interactive mode.
313  {
314    G4UIsession* session=0;
315 
316    // G4UIterminal is a (dumb) terminal.
317#ifdef G4UI_USE_TCSH
318    session = new G4UIterminal(new G4UItcsh);     
319#else
320    session = new G4UIterminal();
321#endif   
322
323#ifdef debug
324    G4cout<<"PhotIn: UITerminal is constructed"<<G4endl;
325#endif
326     
327    UI->ApplyCommand("/control/execute vis.mac");   
328
329#ifdef debug
330    G4cout<<"PhotIn: First UI comand /control/execute vis.mac is sent"<<G4endl;
331#endif
332    session->SessionStart();
333
334#ifdef debug
335    G4cout<<"PhotIn: UI session is started"<<G4endl;
336#endif
337
338    delete session;
339
340#ifdef debug
341    G4cout<<"PhotIn: UI session is finished"<<G4endl;
342#endif
343
344  }
345  else           // Batch mode
346  { 
347    G4String command = "/control/execute ";
348    G4String fileName = argv[1];
349
350#ifdef debug
351    G4cout<<"PhotIn: Batch mode /control/execute "<<argv[1]<<" is started"<<G4endl;
352#endif
353
354    UI->ApplyCommand(command+fileName);
355  }
356
357  // job termination
358#ifdef G4VIS_USE
359  delete visManager;
360
361#ifdef debug
362  G4cout<<"PhotIn: Visualization Manager is deleted"<<G4endl;
363#endif
364
365#endif
366
367  //delete detectorMessenger; // ?
368
369#ifdef debug
370  G4cout<<"PhotIn: Detector Messenger is deleted"<<G4endl;
371#endif
372
373  delete runManager;
374
375#ifdef debug
376  G4cout<<"PhotIn: Run Manager is deleted"<<G4endl;
377#endif
378
379  return 0;
380}
381
Note: See TracBrowser for help on using the repository browser.