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 //
29 
30 #include "ITTrackingInteractivity.hh"
31 #include "G4TrackingInformation.hh"
32 #include "G4VTrajectory.hh"
33 #include "G4Trajectory.hh"
34 #include "G4SmoothTrajectory.hh"
35 #include "G4RichTrajectory.hh"
36 #include "G4UserTrackingAction.hh"
37 #include "G4UserSteppingAction.hh"
38 #include "G4IT.hh"
39 #include "G4EventManager.hh"
40 #include "G4Event.hh"
41 #include "G4VSteppingVerbose.hh"
42 #include "G4VisManager.hh"
43 
45 {
46  friend class ITTrackingInteractivity;
48  : fpTrajectory(0)
49  {;}
50 
52  {;}
53 
55 };
56 
59  , fStoreTrajectory(0)
60 {
63  GetTrackingManager()->GetUserTrackingAction());
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 {}
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 {
75  G4TrackingManager* trackingManager =
77  fStoreTrajectory = trackingManager->GetStoreTrajectory();
78  fVerboseLevel = trackingManager->GetVerboseLevel();
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85 #ifdef G4VERBOSE
86  if(fVerboseLevel)
87  {
88  TrackBanner(track, "G4ITTrackingManager::StartTracking : ");
89  }
90 #endif
91 
92  if(fVerboseLevel>0 &&
94  {
95  TrackBanner(track);
96  }
97  if( fpUserTrackingAction != nullptr )
98  {
100  }
101 
102  G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
103  G4Trajectory_Lock* trajectory_lock = trackingInfo->GetTrajectory_Lock();
104 
105  if(fStoreTrajectory && (!trajectory_lock))
106  {
107  trajectory_lock = new G4Trajectory_Lock();
108  trackingInfo->SetTrajectory_Lock(trajectory_lock);
109  G4VTrajectory* trajectory = 0;
110  switch (fStoreTrajectory)
111  {
112  default:
113  case 1: trajectory = new G4Trajectory(track); break;
114  case 2: trajectory = new G4SmoothTrajectory(track); break;
115  case 3: trajectory = new G4RichTrajectory(track); break;
116  }
117  trajectory_lock->fpTrajectory = trajectory;
118  }
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122 
123 void
125 {
126  if(fpUserSteppingAction != nullptr)
127  {
129  }
130 
131  if(fStoreTrajectory)
132  {
133  G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
134  G4Trajectory_Lock* trajectory_lock = trackingInfo->GetTrajectory_Lock();
135  trajectory_lock->fpTrajectory->AppendStep(step);
136  }
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
140 
142 {
143 #ifdef G4VERBOSE
144  if(fVerboseLevel)
145  {
146  TrackBanner(track, "G4ITTrackingManager::EndTracking : ");
147  }
148 #endif
149  if( fpUserTrackingAction != nullptr )
150  {
152  }
153  G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
154  G4Trajectory_Lock* trajectory_lock = trackingInfo->GetTrajectory_Lock();
155 
156  if(trajectory_lock)
157  {
158  G4VTrajectory*& trajectory = trajectory_lock->fpTrajectory;
159 
160  if(fStoreTrajectory && trajectory)
161  {
162 #ifdef G4VERBOSE
163  if(fVerboseLevel>10)
164  {
165  trajectory->ShowTrajectory();
166  }
167 #endif
168  G4TrackStatus istop = track->GetTrackStatus();
169 
170  if(trajectory && (istop != fStopButAlive) &&
171  (istop != fSuspend))
172  {
173  G4Event* currentEvent = G4EventManager::GetEventManager()
175  if(currentEvent != nullptr)
176  {
177  G4TrajectoryContainer* trajectoryContainer =
178  currentEvent->GetTrajectoryContainer();
179  if (!trajectoryContainer)
180  {
181  trajectoryContainer = new G4TrajectoryContainer;
182  currentEvent->
183  SetTrajectoryContainer(trajectoryContainer);
184  }
185  trajectoryContainer->insert(trajectory);
186  }
187  else
188  {
189  fTrajectories.push_back(trajectory);
190  }
191  }
192  }
193  else if( (!fStoreTrajectory)&&trajectory )
194  {
195  delete trajectory;
196  trajectory = nullptr;
197  }
198  delete trajectory_lock;
199  trackingInfo->SetTrajectory_Lock(0);
200  }
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204 
206 {
207  for (std::vector<G4VTrajectory*>::iterator it =
208  fTrajectories.begin();
209  it != fTrajectories.end(); it++)
210  {
212  }
213 }