Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
neuron/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 // and papers
31 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
32 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
33 // The Geant4-DNA web site is available at http://geant4-dna.org
34 //
35 // -------------------------------------------------------------------
36 // November 2016
37 // -------------------------------------------------------------------
38 //
39 // $Id$
40 //
43 
44 #include "ITTrackingInteractivity.hh"
45 #include "G4TrackingInformation.hh"
46 #include "G4VTrajectory.hh"
47 #include "G4Trajectory.hh"
48 #include "G4SmoothTrajectory.hh"
49 #include "G4RichTrajectory.hh"
50 #include "G4UserTrackingAction.hh"
51 #include "G4UserSteppingAction.hh"
52 #include "G4IT.hh"
53 #include "G4EventManager.hh"
54 #include "G4Event.hh"
55 #include "G4VSteppingVerbose.hh"
56 #include "G4VisManager.hh"
57 
59 {
60  friend class ITTrackingInteractivity;
61 
63  {;}
64 
66  {;}
67 
69 };
70 
72 {
73  fStoreTrajectory = 0;
74  fVerboseLevel = 0;
75 
78 
80  // In case you want to use same tracking/stepping action
81  // for normal and IT stepping
82  /*
83  fpUserTrackingAction =
84  trackingManager->GetUserTrackingAction();
85  fpUserSteppingAction =
86  G4EventManager::GetEventManager()->GetUserSteppingAction();
87  */
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94 {
95  G4EventManager* eventManager =
97 
98  if (eventManager)
99  {
100  G4UserTrackingAction* std_trackAct =
101  eventManager->GetUserTrackingAction();
102  if(fpUserTrackingAction != std_trackAct && fpUserTrackingAction)
103  delete fpUserTrackingAction;
104 
105  G4UserSteppingAction* std_stepAct =
106  eventManager->GetUserSteppingAction();
107  if(fpUserSteppingAction != std_stepAct && fpUserSteppingAction)
108  delete fpUserSteppingAction;
109  }
110  else
111  {
113  {
114  delete fpUserSteppingAction;
115  }
116 
118  {
119  delete fpUserTrackingAction;
120  }
121  }
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 
127 {
128  G4TrackingManager* trackingManager =
130  fStoreTrajectory = trackingManager->GetStoreTrajectory();
131  fVerboseLevel = trackingManager->GetVerboseLevel();
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
137 {
138 #ifdef G4VERBOSE
139  if(fVerboseLevel)
140  {
141  TrackBanner(track, "G4ITTrackingManager::StartTracking : ");
142  }
143 #endif
144 
146  TrackBanner(track);
147 
148  // Pre tracking user intervention process.
149  if( fpUserTrackingAction != 0 ) {
151  }
152 //#ifdef G4_STORE_TRAJECTORY
153  G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
154  G4Trajectory_Lock* trajectory_lock =
155  trackingInfo->GetTrajectory_Lock();
156 
157  // Construct a trajectory if it is requested
158  if(fStoreTrajectory&&(!trajectory_lock))
159  {
160  trajectory_lock = new G4Trajectory_Lock();
161  trackingInfo->SetTrajectory_Lock(trajectory_lock);
162  G4VTrajectory* trajectory = 0;
163  // default trajectory concrete class object
164  switch (fStoreTrajectory) {
165  default:
166  case 1: trajectory = new G4Trajectory(track); break;
167  case 2: trajectory = new G4SmoothTrajectory(track); break;
168  case 3: trajectory = new G4RichTrajectory(track); break;
169  }
170  trajectory_lock->fpTrajectory = trajectory;
171  }
172 //#endif
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 
177 void
179 {
181  // If you want to use sensitive detector
182  /*
183  G4VPhysicalVolume* currentVolume =
184  step->GetPreStepPoint()->GetPhysicalVolume();
185  G4SteppingControl stepControlFlag = step->GetControlFlag();
186 
187  if( currentVolume != 0 && stepControlFlag != AvoidHitInvocation)
188  {
189  G4VSensitiveDetector* sensitive = step->GetPreStepPoint()->
190  GetSensitiveDetector();
191  if( sensitive != 0 )
192  {
193  sensitive->Hit(fpStep);
194  }
195  }
196  */
198 
201 
203  // If you want to use regional stepping action
204  /*
205  G4UserSteppingAction* regionalAction
206  = fpStep->GetPreStepPoint()->GetPhysicalVolume()->
207  GetLogicalVolume()->GetRegion()->
208  GetRegionalSteppingAction();
209  if( regionalAction ) regionalAction->UserSteppingAction(fpStep);
210  */
212 
213  if(fStoreTrajectory)
214  {
215  G4TrackingInformation* trackingInfo =
216  GetIT(track)->GetTrackingInfo();
217  G4Trajectory_Lock* trajectory_lock =
218  trackingInfo->GetTrajectory_Lock();
219  trajectory_lock->fpTrajectory->AppendStep(step);
220  }
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 
226 {
227 #ifdef G4VERBOSE
228  if(fVerboseLevel)
229  {
230  TrackBanner(track, "G4ITTrackingManager::EndTracking : ");
231  }
232 #endif
233  // Post tracking user intervention process.
234  if( fpUserTrackingAction != 0 ) {
236  }
237 
238 //#ifdef G4_STORE_TRAJECTORY
239  G4TrackingInformation* trackingInfo =
240  GetIT(track)->GetTrackingInfo();
241  G4Trajectory_Lock* trajectory_lock =
242  trackingInfo->GetTrajectory_Lock();
243 
244  if(trajectory_lock)
245  {
246  G4VTrajectory*& trajectory = trajectory_lock->fpTrajectory;
247 
248  if(fStoreTrajectory && trajectory)
249  {
250 
251 #ifdef G4VERBOSE
252  if(fVerboseLevel>10) trajectory->ShowTrajectory();
253 #endif
254  G4TrackStatus istop = track->GetTrackStatus();
255 
256  if (trajectory && (istop != fStopButAlive) && (istop != fSuspend))
257  {
258  G4Event* currentEvent = G4EventManager::GetEventManager()
260 
261  if (currentEvent)
262  {
263  G4TrajectoryContainer* trajectoryContainer = currentEvent
265 
266  if (!trajectoryContainer)
267  {
268  trajectoryContainer = new G4TrajectoryContainer;
269  currentEvent->SetTrajectoryContainer(trajectoryContainer);
270  }
271  trajectoryContainer->insert(trajectory);
272  }
273  else
274  {
275  fTrajectories.push_back(trajectory);
276  }
277  }
278  }
279  // Destruct the trajectory if it was created
280  else if( (!fStoreTrajectory)&&trajectory ) {
281  delete trajectory;
282  trajectory = 0;
283  }
284  delete trajectory_lock;
285  trackingInfo->SetTrajectory_Lock(0);
286  }
287 //#endif
288 }
289 
291 {
292  for (std::vector<G4VTrajectory*>::iterator it = fTrajectories.begin();
293  it != fTrajectories.end(); it++)
294  {
296  }
297 }
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()