ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ITTrackingInteractivity.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
36 
37 #include "ITTrackingInteractivity.hh"
38 #include "G4TrackingInformation.hh"
39 #include "G4VTrajectory.hh"
40 #include "G4Trajectory.hh"
41 #include "G4SmoothTrajectory.hh"
42 #include "G4RichTrajectory.hh"
43 #include "G4UserTrackingAction.hh"
44 #include "G4UserSteppingAction.hh"
45 #include "G4IT.hh"
46 #include "G4EventManager.hh"
47 #include "G4Event.hh"
48 #include "G4VSteppingVerbose.hh"
49 #include "G4VisManager.hh"
50 
52 {
54 
56  {;}
57 
59  {;}
60 
62 };
63 
65 {
66  fStoreTrajectory = 0;
67  fVerboseLevel = 0;
68 
71 
73  // In case you want to use same tracking/stepping action
74  // for normal and IT stepping
75  /*
76  fpUserTrackingAction =
77  trackingManager->GetUserTrackingAction();
78  fpUserSteppingAction =
79  G4EventManager::GetEventManager()->GetUserSteppingAction();
80  */
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  G4EventManager* eventManager =
90 
91  if (eventManager)
92  {
93  G4UserTrackingAction* std_trackAct =
94  eventManager->GetUserTrackingAction();
95  if(fpUserTrackingAction != std_trackAct && fpUserTrackingAction)
96  delete fpUserTrackingAction;
97 
98  G4UserSteppingAction* std_stepAct =
99  eventManager->GetUserSteppingAction();
100  if(fpUserSteppingAction != std_stepAct && fpUserSteppingAction)
101  delete fpUserSteppingAction;
102  }
103  else
104  {
106  {
107  delete fpUserSteppingAction;
108  }
109 
111  {
112  delete fpUserTrackingAction;
113  }
114  }
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
120 {
121  G4TrackingManager* trackingManager =
123  fStoreTrajectory = trackingManager->GetStoreTrajectory();
124  fVerboseLevel = trackingManager->GetVerboseLevel();
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128 
130 {
131 #ifdef G4VERBOSE
132  if(fVerboseLevel)
133  {
134  TrackBanner(track, "G4ITTrackingManager::StartTracking : ");
135  }
136 #endif
137 
139  TrackBanner(track);
140 
141  // Pre tracking user intervention process.
142  if( fpUserTrackingAction != 0 ) {
144  }
145 //#ifdef G4_STORE_TRAJECTORY
146  G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
147  G4Trajectory_Lock* trajectory_lock =
148  trackingInfo->GetTrajectory_Lock();
149 
150  // Construct a trajectory if it is requested
151  if(fStoreTrajectory&&(!trajectory_lock))
152  {
153  trajectory_lock = new G4Trajectory_Lock();
154  trackingInfo->SetTrajectory_Lock(trajectory_lock);
155  G4VTrajectory* trajectory = 0;
156  // default trajectory concrete class object
157  switch (fStoreTrajectory) {
158  default:
159  case 1: trajectory = new G4Trajectory(track); break;
160  case 2: trajectory = new G4SmoothTrajectory(track); break;
161  case 3: trajectory = new G4RichTrajectory(track); break;
162  }
163  trajectory_lock->fpTrajectory = trajectory;
164  }
165 //#endif
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
170 void
172 {
174  // If you want to use sensitive detector
175  /*
176  G4VPhysicalVolume* currentVolume =
177  step->GetPreStepPoint()->GetPhysicalVolume();
178  G4SteppingControl stepControlFlag = step->GetControlFlag();
179 
180  if( currentVolume != 0 && stepControlFlag != AvoidHitInvocation)
181  {
182  G4VSensitiveDetector* sensitive = step->GetPreStepPoint()->
183  GetSensitiveDetector();
184  if( sensitive != 0 )
185  {
186  sensitive->Hit(fpStep);
187  }
188  }
189  */
191 
194 
196  // If you want to use regional stepping action
197  /*
198  G4UserSteppingAction* regionalAction
199  = fpStep->GetPreStepPoint()->GetPhysicalVolume()->
200  GetLogicalVolume()->GetRegion()->
201  GetRegionalSteppingAction();
202  if( regionalAction ) regionalAction->UserSteppingAction(fpStep);
203  */
205 
206  if(fStoreTrajectory)
207  {
208  G4TrackingInformation* trackingInfo =
209  GetIT(track)->GetTrackingInfo();
210  G4Trajectory_Lock* trajectory_lock =
211  trackingInfo->GetTrajectory_Lock();
212  trajectory_lock->fpTrajectory->AppendStep(step);
213  }
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
219 {
220 #ifdef G4VERBOSE
221  if(fVerboseLevel)
222  {
223  TrackBanner(track, "G4ITTrackingManager::EndTracking : ");
224  }
225 #endif
226  // Post tracking user intervention process.
227  if( fpUserTrackingAction != 0 ) {
229  }
230 
231 //#ifdef G4_STORE_TRAJECTORY
232  G4TrackingInformation* trackingInfo =
233  GetIT(track)->GetTrackingInfo();
234  G4Trajectory_Lock* trajectory_lock =
235  trackingInfo->GetTrajectory_Lock();
236 
237  if(trajectory_lock)
238  {
239  G4VTrajectory*& trajectory = trajectory_lock->fpTrajectory;
240 
241  if(fStoreTrajectory && trajectory)
242  {
243 
244 #ifdef G4VERBOSE
245  if(fVerboseLevel>10) trajectory->ShowTrajectory();
246 #endif
247  G4TrackStatus istop = track->GetTrackStatus();
248 
249  if (trajectory && (istop != fStopButAlive) && (istop != fSuspend))
250  {
251  G4Event* currentEvent = G4EventManager::GetEventManager()
253 
254  if (currentEvent)
255  {
256  G4TrajectoryContainer* trajectoryContainer = currentEvent
258 
259  if (!trajectoryContainer)
260  {
261  trajectoryContainer = new G4TrajectoryContainer;
262  currentEvent->SetTrajectoryContainer(trajectoryContainer);
263  }
264  trajectoryContainer->insert(trajectory);
265  }
266  else
267  {
268  fTrajectories.push_back(trajectory);
269  }
270  }
271  }
272  // Destruct the trajectory if it was created
273  else if( (!fStoreTrajectory)&&trajectory ) {
274  delete trajectory;
275  trajectory = 0;
276  }
277  delete trajectory_lock;
278  trackingInfo->SetTrajectory_Lock(0);
279  }
280 //#endif
281 }
282 
284 {
285  for (std::vector<G4VTrajectory*>::iterator it = fTrajectories.begin();
286  it != fTrajectories.end(); it++)
287  {
289  }
290 }