Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
chem3/src/ITTrackingInteractivity.cc
이 파일의 문서화 페이지로 가기
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 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // J. Comput. Phys. 274 (2014) 841-882
31 // The Geant4-DNA web site is available at http://geant4-dna.org
32 //
33 // $Id$
34 //
37 
38 #include "ITTrackingInteractivity.hh"
39 #include "G4TrackingInformation.hh"
40 #include "G4VTrajectory.hh"
41 #include "G4Trajectory.hh"
42 #include "G4SmoothTrajectory.hh"
43 #include "G4RichTrajectory.hh"
44 #include "G4UserTrackingAction.hh"
45 #include "G4UserSteppingAction.hh"
46 #include "G4IT.hh"
47 #include "G4EventManager.hh"
48 #include "G4Event.hh"
49 #include "G4VSteppingVerbose.hh"
50 #include "G4VisManager.hh"
51 
53 {
55 
57  {;}
58 
60  {;}
61 
63 };
64 
66 {
67  fStoreTrajectory = 0;
68  fVerboseLevel = 0;
69 
72 
74  // In case you want to use same tracking/stepping action
75  // for normal and IT stepping
76  /*
77  fpUserTrackingAction =
78  trackingManager->GetUserTrackingAction();
79  fpUserSteppingAction =
80  G4EventManager::GetEventManager()->GetUserSteppingAction();
81  */
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
89  G4EventManager* eventManager =
91 
92  if (eventManager)
93  {
94  G4UserTrackingAction* std_trackAct =
95  eventManager->GetUserTrackingAction();
96  if(fpUserTrackingAction != std_trackAct && fpUserTrackingAction)
97  delete fpUserTrackingAction;
98 
99  G4UserSteppingAction* std_stepAct =
100  eventManager->GetUserSteppingAction();
101  if(fpUserSteppingAction != std_stepAct && fpUserSteppingAction)
102  delete fpUserSteppingAction;
103  }
104  else
105  {
107  {
108  delete fpUserSteppingAction;
109  }
110 
112  {
113  delete fpUserTrackingAction;
114  }
115  }
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
121 {
122  G4TrackingManager* trackingManager =
124  fStoreTrajectory = trackingManager->GetStoreTrajectory();
125  fVerboseLevel = trackingManager->GetVerboseLevel();
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129 
131 {
132 #ifdef G4VERBOSE
133  if(fVerboseLevel)
134  {
135  TrackBanner(track, "G4ITTrackingManager::StartTracking : ");
136  }
137 #endif
138 
140  TrackBanner(track);
141 
142  // Pre tracking user intervention process.
143  if( fpUserTrackingAction != 0 ) {
145  }
146 //#ifdef G4_STORE_TRAJECTORY
147  G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
148  G4Trajectory_Lock* trajectory_lock =
149  trackingInfo->GetTrajectory_Lock();
150 
151  // Construct a trajectory if it is requested
152  if(fStoreTrajectory&&(!trajectory_lock))
153  {
154  trajectory_lock = new G4Trajectory_Lock();
155  trackingInfo->SetTrajectory_Lock(trajectory_lock);
156  G4VTrajectory* trajectory = 0;
157  // default trajectory concrete class object
158  switch (fStoreTrajectory) {
159  default:
160  case 1: trajectory = new G4Trajectory(track); break;
161  case 2: trajectory = new G4SmoothTrajectory(track); break;
162  case 3: trajectory = new G4RichTrajectory(track); break;
163  }
164  trajectory_lock->fpTrajectory = trajectory;
165  }
166 //#endif
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170 
171 void
173 {
175  // If you want to use sensitive detector
176  /*
177  G4VPhysicalVolume* currentVolume =
178  step->GetPreStepPoint()->GetPhysicalVolume();
179  G4SteppingControl stepControlFlag = step->GetControlFlag();
180 
181  if( currentVolume != 0 && stepControlFlag != AvoidHitInvocation)
182  {
183  G4VSensitiveDetector* sensitive = step->GetPreStepPoint()->
184  GetSensitiveDetector();
185  if( sensitive != 0 )
186  {
187  sensitive->Hit(fpStep);
188  }
189  }
190  */
192 
195 
197  // If you want to use regional stepping action
198  /*
199  G4UserSteppingAction* regionalAction
200  = fpStep->GetPreStepPoint()->GetPhysicalVolume()->
201  GetLogicalVolume()->GetRegion()->
202  GetRegionalSteppingAction();
203  if( regionalAction ) regionalAction->UserSteppingAction(fpStep);
204  */
206 
207  if(fStoreTrajectory)
208  {
209  G4TrackingInformation* trackingInfo =
210  GetIT(track)->GetTrackingInfo();
211  G4Trajectory_Lock* trajectory_lock =
212  trackingInfo->GetTrajectory_Lock();
213  trajectory_lock->fpTrajectory->AppendStep(step);
214  }
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218 
220 {
221 #ifdef G4VERBOSE
222  if(fVerboseLevel)
223  {
224  TrackBanner(track, "G4ITTrackingManager::EndTracking : ");
225  }
226 #endif
227  // Post tracking user intervention process.
228  if( fpUserTrackingAction != 0 ) {
230  }
231 
232 //#ifdef G4_STORE_TRAJECTORY
233  G4TrackingInformation* trackingInfo =
234  GetIT(track)->GetTrackingInfo();
235  G4Trajectory_Lock* trajectory_lock =
236  trackingInfo->GetTrajectory_Lock();
237 
238  if(trajectory_lock)
239  {
240  G4VTrajectory*& trajectory = trajectory_lock->fpTrajectory;
241 
242  if(fStoreTrajectory && trajectory)
243  {
244 
245 #ifdef G4VERBOSE
246  if(fVerboseLevel>10) trajectory->ShowTrajectory();
247 #endif
248  G4TrackStatus istop = track->GetTrackStatus();
249 
250  if (trajectory && (istop != fStopButAlive) && (istop != fSuspend))
251  {
252  G4Event* currentEvent = G4EventManager::GetEventManager()
254 
255  if (currentEvent)
256  {
257  G4TrajectoryContainer* trajectoryContainer = currentEvent
259 
260  if (!trajectoryContainer)
261  {
262  trajectoryContainer = new G4TrajectoryContainer;
263  currentEvent->SetTrajectoryContainer(trajectoryContainer);
264  }
265  trajectoryContainer->insert(trajectory);
266  }
267  else
268  {
269  fTrajectories.push_back(trajectory);
270  }
271  }
272  }
273  // Destruct the trajectory if it was created
274  else if( (!fStoreTrajectory)&&trajectory ) {
275  delete trajectory;
276  trajectory = 0;
277  }
278  delete trajectory_lock;
279  trackingInfo->SetTrajectory_Lock(0);
280  }
281 //#endif
282 }
283 
285 {
286  for (std::vector<G4VTrajectory*>::iterator it = fTrajectories.begin();
287  it != fTrajectories.end(); it++)
288  {
290  }
291 }
G4Event * GetNonconstCurrentEvent()
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
void SetTrajectory_Lock(G4Trajectory_Lock *trajLock)
G4int GetStoreTrajectory() const
virtual void AppendStep(G4Track *track, G4Step *step)
std::vector< G4VTrajectory * > fTrajectories
virtual void ShowTrajectory(std::ostream &os=G4cout) const
virtual void AppendStep(const G4Step *aStep)=0
virtual void PostUserTrackingAction(const G4Track *)
virtual void TrackBanner(G4Track *, const G4String &message="")
void SetTrajectoryContainer(G4TrajectoryContainer *value)
Definition: G4Event.hh:121
static G4VVisManager * GetConcreteInstance()
G4int GetVerboseLevel() const
virtual void PreUserTrackingAction(const G4Track *)
G4TrackingManager * GetTrackingManager() const
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:189
static G4EventManager * GetEventManager()
Definition: G4Step.hh:76
G4UserSteppingAction * GetUserSteppingAction()
static G4int GetSilent()
G4bool insert(G4VTrajectory *p)
G4Trajectory_Lock * GetTrajectory_Lock()
G4TrackStatus GetTrackStatus() const
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
G4TrackingInformation * GetTrackingInfo()
Definition: G4IT.hh:144
virtual void UserSteppingAction(const G4Step *)
G4TrackStatus
G4UserTrackingAction * GetUserTrackingAction()