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 | // |
---|
28 | // |
---|
29 | // ---------- EventAction ------------- |
---|
30 | // |
---|
31 | // Modified: 05.04.01 Vladimir Ivanchenko new design of IBREM |
---|
32 | // |
---|
33 | // ------------------------------------------------------------- |
---|
34 | |
---|
35 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
36 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
37 | |
---|
38 | #include "EventAction.hh" |
---|
39 | #include "Histo.hh" |
---|
40 | #include "EventActionMessenger.hh" |
---|
41 | |
---|
42 | #include "G4UImanager.hh" |
---|
43 | #include "G4TrajectoryContainer.hh" |
---|
44 | #include "G4Trajectory.hh" |
---|
45 | #include "G4VVisManager.hh" |
---|
46 | #include "G4ios.hh" |
---|
47 | |
---|
48 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
49 | |
---|
50 | EventAction::EventAction(): |
---|
51 | nEvt(0), |
---|
52 | verbose(0), |
---|
53 | printModulo(100), |
---|
54 | nSelected(0), |
---|
55 | // drawFlag("all") |
---|
56 | drawFlag("charged") |
---|
57 | // drawFlag("neutral") |
---|
58 | { |
---|
59 | // drawFlags = all, charged, neutral, charged+n |
---|
60 | eventMessenger = new EventActionMessenger(this); |
---|
61 | UI = G4UImanager::GetUIpointer(); |
---|
62 | selectedEvents.clear(); |
---|
63 | } |
---|
64 | |
---|
65 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
66 | |
---|
67 | EventAction::~EventAction() |
---|
68 | {} |
---|
69 | |
---|
70 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
71 | |
---|
72 | void EventAction::BeginOfEventAction(const G4Event*) |
---|
73 | { |
---|
74 | // New event |
---|
75 | nEvt++; |
---|
76 | (Histo::GetPointer())->AddEvent(); |
---|
77 | |
---|
78 | if(nSelected>0) { |
---|
79 | for(G4int i=0; i<nSelected; i++) { |
---|
80 | if(nEvt == selectedEvents[i]) { |
---|
81 | UI->ApplyCommand("/random/saveThisEvent"); |
---|
82 | } |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | // Switch on verbose mode |
---|
87 | /* |
---|
88 | if(hi->GetFirstEventToDebug() == nEvt) { |
---|
89 | verbose = 2; |
---|
90 | hi->SetVerbose(2); |
---|
91 | (G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 2"); |
---|
92 | |
---|
93 | const G4ProcessManager* pm = G4Gamma::Gamma()->GetProcessManager(); |
---|
94 | const G4ProcessVector* pv = pm->GetProcessList(); |
---|
95 | G4int np = pm->GetProcessListLength(); |
---|
96 | for(G4int i=0; i<np; i++) { |
---|
97 | ((*pv)[i])->SetVerboseLevel(2); |
---|
98 | } |
---|
99 | |
---|
100 | } |
---|
101 | |
---|
102 | // Switch off verbose mode |
---|
103 | if(hi->GetLastEventToDebug() == nEvt-1) { |
---|
104 | verbose = 0; |
---|
105 | hi->SetVerbose(0); |
---|
106 | (G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 0"); |
---|
107 | } |
---|
108 | */ |
---|
109 | |
---|
110 | // Initialize user actions |
---|
111 | if(verbose > 0) { |
---|
112 | G4cout << "EventAction: Event # " |
---|
113 | << nEvt << " started" << G4endl; |
---|
114 | } |
---|
115 | |
---|
116 | } |
---|
117 | |
---|
118 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
119 | |
---|
120 | void EventAction::EndOfEventAction(const G4Event* evt) |
---|
121 | { |
---|
122 | (Histo::GetPointer())->SaveEvent(); |
---|
123 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); |
---|
124 | |
---|
125 | if(pVVisManager) { |
---|
126 | G4TrajectoryContainer* trjc = evt->GetTrajectoryContainer(); |
---|
127 | G4int n_trajectories = 0; |
---|
128 | if (trjc) n_trajectories = trjc->entries(); |
---|
129 | |
---|
130 | for(G4int i=0; i<n_trajectories; i++) { |
---|
131 | G4Trajectory* t = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]); |
---|
132 | if (drawFlag == "all") t->DrawTrajectory(1000); |
---|
133 | else if ((drawFlag == "charged")&&(t->GetCharge() != 0.)) |
---|
134 | t->DrawTrajectory(1000); |
---|
135 | else if ((drawFlag == "neutral")&&(t->GetCharge() == 0.)) |
---|
136 | t->DrawTrajectory(1000); |
---|
137 | else if ((drawFlag == "charged+n")&&((t->GetCharge() != 0.)|| |
---|
138 | (t->GetCharge()==0.&&t->GetParticleName()=="neutron"))) |
---|
139 | t->DrawTrajectory(1000); |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | if(verbose > 0) { |
---|
144 | G4cout << "EventAction: Event # " |
---|
145 | << nEvt << " ended" << G4endl; |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|