source: MEMPHYS/HEAD/applications/MEMPHYS_batch.cxx @ 68

Last change on this file since 68 was 68, checked in by campagne, 18 years ago

Introduction of the MEMPHYS namespace

File size: 2.8 KB
Line 
1// Geant4:
2#include "G4ios.hh"
3#include "G4RunManager.hh"
4#include "G4UImanager.hh"
5
6//MEMPHYS:
7#include "MEMPHYS/MEMPHYSAnalysis.hh"
8#include "MEMPHYS/MEMPHYSDetectorConstruction.hh"
9#include "MEMPHYS/MEMPHYSPhysicsList.hh"
10#include "MEMPHYS/MEMPHYSPhysicsMessenger.hh"
11#include "MEMPHYS/MEMPHYSPrimaryGeneratorAction.hh"
12#include "MEMPHYS/MEMPHYSEventAction.hh"
13#include "MEMPHYS/MEMPHYSRunAction.hh"
14#include "MEMPHYS/MEMPHYSStackingAction.hh"
15#include "MEMPHYS/MEMPHYSTrackingAction.hh"
16#include "MEMPHYS/MEMPHYSSteppingAction.hh"
17
18
19//JEC AIDA :
20#include <AIDA/IAnalysisFactory.h>
21
22// std::
23#include <iostream>
24
25//JEC Lib :
26#include <Lib/System.h>
27
28/////////////////////////////////////////////////////////////////
29int main(
30         int //aArgc
31         , char** //aArgv
32         )
33{
34  //AIDA Analysis factory
35  AIDA::IAnalysisFactory* aida = AIDA_createAnalysisFactory();
36  if(!aida) {
37    std::cout << "MEMPHYS_batch :"
38              << " AIDA not found." << std::endl;
39    return 0;
40  }
41  //Book all the histo, tuple
42  MEMPHYS::MEMPHYSAnalysis* analysis = new MEMPHYS::MEMPHYSAnalysis(*aida);
43
44
45  // Construct the default run manager
46  G4RunManager* runManager = new G4RunManager;
47
48  // UserInitialization classes (mandatory)
49
50
51
52  //JEC 18/11/05 give the "analysis" to fill geometry ITuple
53  MEMPHYS::MEMPHYSDetectorConstruction* MEMPHYSdetector = 
54    new MEMPHYS::MEMPHYSDetectorConstruction(*analysis); 
55
56  runManager->SetUserInitialization(MEMPHYSdetector);
57
58  runManager->SetUserInitialization(new MEMPHYS::MEMPHYSPhysicsList);
59
60  G4UImanager* UI = G4UImanager::GetUIpointer();
61  if (UI) {
62    std::string file = 
63      Lib::System::getenv("MEMPHYSROOT")+"/scripts/Geant4/jobOptions.mac"; //JEC FIXME this comes from JHF
64    UI->ApplyCommand("/control/execute "+file); 
65  }
66
67
68
69  // Set user action classes
70  MEMPHYS::MEMPHYSPrimaryGeneratorAction* myGeneratorAction = new MEMPHYS::MEMPHYSPrimaryGeneratorAction(MEMPHYSdetector);
71  runManager->SetUserAction(myGeneratorAction);
72
73  MEMPHYS::MEMPHYSRunAction* myRunAction = new MEMPHYS::MEMPHYSRunAction();
74
75  runManager->SetUserAction(myRunAction);
76
77
78  runManager->SetUserAction(new MEMPHYS::MEMPHYSEventAction(*analysis,
79                                                   myRunAction, 
80                                                   MEMPHYSdetector,
81                                                   myGeneratorAction));
82  runManager->SetUserAction(new MEMPHYS::MEMPHYSTrackingAction);
83
84  runManager->SetUserAction(new MEMPHYS::MEMPHYSStackingAction);
85  runManager->SetUserAction(new MEMPHYS::MEMPHYSSteppingAction); //JEC 15/12/05 Add user SteppingAction
86
87  // Initialize G4 kernel
88  runManager->Initialize();
89
90  if (UI) {
91    std::string file = 
92      Lib::System::getenv("MEMPHYSROOT")+"/scripts/Geant4/init.g4m"; //JEC FIXME this comes from JHF
93    UI->ApplyCommand("/control/execute "+file); 
94  }
95
96  runManager->BeamOn(1);
97
98
99  //JEC interactive session  delete visManager;
100
101  delete runManager;
102  delete analysis;
103  delete aida;
104  return 0;
105}
106
107
Note: See TracBrowser for help on using the repository browser.