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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/dna/chem3/src/ITTrackingInteractivity.cc (Version 11.3.0) and /examples/extended/medical/dna/chem3/src/ITTrackingInteractivity.cc (Version 10.1.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // This example is provided by the Geant4-DNA      26 // This example is provided by the Geant4-DNA collaboration
 27 // Any report or published results obtained us     27 // Any report or published results obtained using the Geant4-DNA software
 28 // shall cite the following Geant4-DNA collabo     28 // shall cite the following Geant4-DNA collaboration publication:
 29 // Med. Phys. 37 (2010) 4692-4708                  29 // Med. Phys. 37 (2010) 4692-4708
 30 // J. Comput. Phys. 274 (2014) 841-882             30 // J. Comput. Phys. 274 (2014) 841-882
 31 // The Geant4-DNA web site is available at htt     31 // The Geant4-DNA web site is available at http://geant4-dna.org
 32 //                                                 32 //
                                                   >>  33 // $Id$
 33 //                                                 34 //
 34 /// \file ITTrackingInteractivity.hh               35 /// \file ITTrackingInteractivity.hh
 35 /// \brief Implementation of the ITTrackingInt     36 /// \brief Implementation of the ITTrackingInteractivity class
 36                                                    37 
 37 #include "ITTrackingInteractivity.hh"              38 #include "ITTrackingInteractivity.hh"
 38                                                << 
 39 #include "G4Event.hh"                          << 
 40 #include "G4EventManager.hh"                   << 
 41 #include "G4IT.hh"                             << 
 42 #include "G4RichTrajectory.hh"                 << 
 43 #include "G4SmoothTrajectory.hh"               << 
 44 #include "G4TrackingInformation.hh"                39 #include "G4TrackingInformation.hh"
                                                   >>  40 #include "G4VTrajectory.hh"
 45 #include "G4Trajectory.hh"                         41 #include "G4Trajectory.hh"
 46 #include "G4UserSteppingAction.hh"             <<  42 #include "G4SmoothTrajectory.hh"
                                                   >>  43 #include "G4RichTrajectory.hh"
 47 #include "G4UserTrackingAction.hh"                 44 #include "G4UserTrackingAction.hh"
                                                   >>  45 #include "G4UserSteppingAction.hh"
                                                   >>  46 #include "G4IT.hh"
                                                   >>  47 #include "G4EventManager.hh"
                                                   >>  48 #include "G4Event.hh"
 48 #include "G4VSteppingVerbose.hh"                   49 #include "G4VSteppingVerbose.hh"
 49 #include "G4VTrajectory.hh"                    << 
 50 #include "G4VisManager.hh"                         50 #include "G4VisManager.hh"
 51                                                    51 
 52 class G4Trajectory_Lock                            52 class G4Trajectory_Lock
 53 {                                                  53 {
 54     friend class ITTrackingInteractivity;      <<  54   friend class ITTrackingInteractivity;
 55                                                    55 
 56     G4Trajectory_Lock() : fpTrajectory(0) { ;  <<  56   G4Trajectory_Lock(): fpTrajectory(0)
                                                   >>  57   {;}
 57                                                    58 
 58     ~G4Trajectory_Lock() { ; }                 <<  59   ~G4Trajectory_Lock()
                                                   >>  60   {;}
 59                                                    61 
 60     G4VTrajectory* fpTrajectory;               <<  62   G4VTrajectory* fpTrajectory;
 61 };                                                 63 };
 62                                                    64 
 63 ITTrackingInteractivity::ITTrackingInteractivi     65 ITTrackingInteractivity::ITTrackingInteractivity()
 64 {                                                  66 {
 65   fStoreTrajectory = 0;                            67   fStoreTrajectory = 0;
 66   fVerboseLevel = 0;                               68   fVerboseLevel = 0;
 67                                                    69 
 68   fpUserTrackingAction = 0;                    <<  70   fpUserTrackingAction  = 0;
 69   fpUserSteppingAction = 0;                        71   fpUserSteppingAction = 0;
 70                                                    72 
 71   ////////////////////////////                     73   ////////////////////////////
 72   // In case you want to use same tracking/ste     74   // In case you want to use same tracking/stepping action
 73   // for normal and IT stepping                    75   // for normal and IT stepping
 74   /*                                               76   /*
 75     fpUserTrackingAction =                         77     fpUserTrackingAction =
 76       trackingManager->GetUserTrackingAction()     78       trackingManager->GetUserTrackingAction();
 77     fpUserSteppingAction =                         79     fpUserSteppingAction =
 78       G4EventManager::GetEventManager()->GetUs     80       G4EventManager::GetEventManager()->GetUserSteppingAction();
 79    */                                              81    */
 80   ////////////////////////////                     82   ////////////////////////////
 81 }                                                  83 }
 82                                                    84 
 83 //....oooOO0OOooo........oooOO0OOooo........oo     85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 84                                                    86 
 85 ITTrackingInteractivity::~ITTrackingInteractiv     87 ITTrackingInteractivity::~ITTrackingInteractivity()
 86 {                                                  88 {
 87   G4EventManager* eventManager = G4EventManage <<  89   G4EventManager* eventManager =
 88                                                <<  90       G4EventManager::GetEventManager();
 89   if (eventManager) {                          << 
 90     G4UserTrackingAction* std_trackAct = event << 
 91     if (fpUserTrackingAction != std_trackAct & << 
 92                                                    91 
 93     G4UserSteppingAction* std_stepAct = eventM <<  92   if (eventManager)
 94     if (fpUserSteppingAction != std_stepAct && <<  93   {
 95   }                                            <<  94   G4UserTrackingAction* std_trackAct =
 96   else {                                       <<  95       eventManager->GetUserTrackingAction();
 97     if (fpUserSteppingAction) {                <<  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   {
                                                   >> 106     if(fpUserSteppingAction)
                                                   >> 107     {
 98       delete fpUserSteppingAction;                108       delete fpUserSteppingAction;
 99     }                                             109     }
100                                                << 110     
101     if (fpUserTrackingAction) {                << 111     if(fpUserTrackingAction)
                                                   >> 112     {
102       delete fpUserTrackingAction;                113       delete fpUserTrackingAction;
103     }                                             114     }
104   }                                               115   }
105 }                                                 116 }
106                                                   117 
107 //....oooOO0OOooo........oooOO0OOooo........oo    118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108                                                   119 
109 void ITTrackingInteractivity::Initialize()        120 void ITTrackingInteractivity::Initialize()
110 {                                                 121 {
111   G4TrackingManager* trackingManager = G4Event << 122   G4TrackingManager* trackingManager = 
                                                   >> 123     G4EventManager::GetEventManager()->GetTrackingManager();
112   fStoreTrajectory = trackingManager->GetStore    124   fStoreTrajectory = trackingManager->GetStoreTrajectory();
113   fVerboseLevel = trackingManager->GetVerboseL    125   fVerboseLevel = trackingManager->GetVerboseLevel();
114 }                                                 126 }
115                                                   127 
116 //....oooOO0OOooo........oooOO0OOooo........oo    128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117                                                   129 
118 void ITTrackingInteractivity::StartTracking(G4    130 void ITTrackingInteractivity::StartTracking(G4Track* track)
119 {                                                 131 {
120 #ifdef G4VERBOSE                                  132 #ifdef G4VERBOSE
121   if (fVerboseLevel) {                         << 133   if(fVerboseLevel)
                                                   >> 134   {
122     TrackBanner(track, "G4ITTrackingManager::S    135     TrackBanner(track, "G4ITTrackingManager::StartTracking : ");
123   }                                               136   }
124 #endif                                            137 #endif
125                                                   138 
126   if (fVerboseLevel > 0 && (G4VSteppingVerbose << 139   if(fVerboseLevel>0 && (G4VSteppingVerbose::GetSilent()!=1) )
                                                   >> 140     TrackBanner(track);
127                                                   141 
128   // Pre tracking user intervention process.      142   // Pre tracking user intervention process.
129   if (fpUserTrackingAction != 0) {             << 143   if( fpUserTrackingAction != 0 ) {
130     fpUserTrackingAction->PreUserTrackingActio    144     fpUserTrackingAction->PreUserTrackingAction(track);
131   }                                               145   }
132   // #ifdef G4_STORE_TRAJECTORY                << 146 //#ifdef G4_STORE_TRAJECTORY
133   G4TrackingInformation* trackingInfo = GetIT(    147   G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo();
134   G4Trajectory_Lock* trajectory_lock = trackin << 148   G4Trajectory_Lock* trajectory_lock =
                                                   >> 149       trackingInfo->GetTrajectory_Lock();
135                                                   150 
136   // Construct a trajectory if it is requested    151   // Construct a trajectory if it is requested
137   if (fStoreTrajectory && (!trajectory_lock))  << 152   if(fStoreTrajectory&&(!trajectory_lock))
                                                   >> 153   {
138     trajectory_lock = new G4Trajectory_Lock();    154     trajectory_lock = new G4Trajectory_Lock();
139     trackingInfo->SetTrajectory_Lock(trajector    155     trackingInfo->SetTrajectory_Lock(trajectory_lock);
140     G4VTrajectory* trajectory = 0;                156     G4VTrajectory* trajectory = 0;
141     // default trajectory concrete class objec    157     // default trajectory concrete class object
142     switch (fStoreTrajectory) {                   158     switch (fStoreTrajectory) {
143       default:                                    159       default:
144       case 1:                                  << 160       case 1: trajectory = new G4Trajectory(track); break;
145         trajectory = new G4Trajectory(track);  << 161       case 2: trajectory = new G4SmoothTrajectory(track); break;
146         break;                                 << 162       case 3: trajectory = new G4RichTrajectory(track); break;
147       case 2:                                  << 
148         trajectory = new G4SmoothTrajectory(tr << 
149         break;                                 << 
150       case 3:                                  << 
151         trajectory = new G4RichTrajectory(trac << 
152         break;                                 << 
153     }                                             163     }
154     trajectory_lock->fpTrajectory = trajectory    164     trajectory_lock->fpTrajectory = trajectory;
155   }                                               165   }
156   // #endif                                    << 166 //#endif
157 }                                                 167 }
158                                                   168 
159 //....oooOO0OOooo........oooOO0OOooo........oo    169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160                                                   170 
161 void ITTrackingInteractivity::AppendStep(G4Tra << 171 void
                                                   >> 172 ITTrackingInteractivity::AppendStep(G4Track* track, G4Step* step)
162 {                                                 173 {
163   ////////////////////////////                    174   ////////////////////////////
164   // If you want to use sensitive detector        175   // If you want to use sensitive detector
165   /*                                              176   /*
166     G4VPhysicalVolume* currentVolume =            177     G4VPhysicalVolume* currentVolume =
167     step->GetPreStepPoint()->GetPhysicalVolume    178     step->GetPreStepPoint()->GetPhysicalVolume();
168     G4SteppingControl stepControlFlag =  step-    179     G4SteppingControl stepControlFlag =  step->GetControlFlag();
169                                                   180 
170     if( currentVolume  != 0 && stepControlFlag    181     if( currentVolume  != 0 && stepControlFlag != AvoidHitInvocation)
171     {                                             182     {
172         G4VSensitiveDetector* sensitive = step    183         G4VSensitiveDetector* sensitive = step->GetPreStepPoint()->
173                 GetSensitiveDetector();           184                 GetSensitiveDetector();
174         if( sensitive != 0 )                      185         if( sensitive != 0 )
175         {                                         186         {
176             sensitive->Hit(fpStep);               187             sensitive->Hit(fpStep);
177         }                                         188         }
178     }                                             189     }
179    */                                             190    */
180   ////////////////////////////                    191   ////////////////////////////
181                                                   192 
182   if (fpUserSteppingAction) fpUserSteppingActi << 193   if(fpUserSteppingAction)
                                                   >> 194     fpUserSteppingAction->UserSteppingAction(step);
183                                                   195 
184   ////////////////////////////                    196   ////////////////////////////
185   // If you want to use regional stepping acti    197   // If you want to use regional stepping action
186   /*                                              198   /*
187     G4UserSteppingAction* regionalAction          199     G4UserSteppingAction* regionalAction
188             = fpStep->GetPreStepPoint()->GetPh    200             = fpStep->GetPreStepPoint()->GetPhysicalVolume()->
189                   GetLogicalVolume()->GetRegio    201                   GetLogicalVolume()->GetRegion()->
190                   GetRegionalSteppingAction();    202                   GetRegionalSteppingAction();
191     if( regionalAction ) regionalAction->UserS    203     if( regionalAction ) regionalAction->UserSteppingAction(fpStep);
192    */                                             204    */
193   ////////////////////////////                    205   ////////////////////////////
194                                                   206 
195   if (fStoreTrajectory) {                      << 207   if(fStoreTrajectory)
196     G4TrackingInformation* trackingInfo = GetI << 208   {
197     G4Trajectory_Lock* trajectory_lock = track << 209     G4TrackingInformation* trackingInfo =
                                                   >> 210         GetIT(track)->GetTrackingInfo();
                                                   >> 211     G4Trajectory_Lock* trajectory_lock =
                                                   >> 212         trackingInfo->GetTrajectory_Lock();
198     trajectory_lock->fpTrajectory->AppendStep(    213     trajectory_lock->fpTrajectory->AppendStep(step);
199   }                                               214   }
200 }                                                 215 }
201                                                   216 
202 //....oooOO0OOooo........oooOO0OOooo........oo    217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203                                                   218 
204 void ITTrackingInteractivity::EndTracking(G4Tr    219 void ITTrackingInteractivity::EndTracking(G4Track* track)
205 {                                                 220 {
206 #ifdef G4VERBOSE                                  221 #ifdef G4VERBOSE
207   if (fVerboseLevel) {                         << 222   if(fVerboseLevel)
                                                   >> 223   {
208     TrackBanner(track, "G4ITTrackingManager::E    224     TrackBanner(track, "G4ITTrackingManager::EndTracking : ");
209   }                                               225   }
210 #endif                                            226 #endif
211   // Post tracking user intervention process.     227   // Post tracking user intervention process.
212   if (fpUserTrackingAction != 0) {             << 228   if( fpUserTrackingAction != 0 ) {
213     fpUserTrackingAction->PostUserTrackingActi    229     fpUserTrackingAction->PostUserTrackingAction(track);
214   }                                               230   }
215                                                   231 
216   // #ifdef G4_STORE_TRAJECTORY                << 232 //#ifdef G4_STORE_TRAJECTORY
217   G4TrackingInformation* trackingInfo = GetIT( << 233   G4TrackingInformation* trackingInfo =
218   G4Trajectory_Lock* trajectory_lock = trackin << 234       GetIT(track)->GetTrackingInfo();
                                                   >> 235   G4Trajectory_Lock* trajectory_lock =
                                                   >> 236       trackingInfo->GetTrajectory_Lock();
219                                                   237 
220   if (trajectory_lock) {                       << 238   if(trajectory_lock)
                                                   >> 239   {
221     G4VTrajectory*& trajectory = trajectory_lo    240     G4VTrajectory*& trajectory = trajectory_lock->fpTrajectory;
222                                                   241 
223     if (fStoreTrajectory && trajectory) {      << 242     if(fStoreTrajectory && trajectory)
                                                   >> 243     {
                                                   >> 244 
224 #ifdef G4VERBOSE                                  245 #ifdef G4VERBOSE
225       if (fVerboseLevel > 10) trajectory->Show << 246       if(fVerboseLevel>10) trajectory->ShowTrajectory();
226 #endif                                            247 #endif
227       G4TrackStatus istop = track->GetTrackSta    248       G4TrackStatus istop = track->GetTrackStatus();
228                                                   249 
229       if (trajectory && (istop != fStopButAliv << 250       if (trajectory && (istop != fStopButAlive) && (istop != fSuspend))
230         G4Event* currentEvent = G4EventManager << 251       {
                                                   >> 252         G4Event* currentEvent = G4EventManager::GetEventManager()
                                                   >> 253             ->GetNonconstCurrentEvent();
231                                                   254 
232         if (currentEvent) {                    << 255         if (currentEvent)
233           G4TrajectoryContainer* trajectoryCon << 256         {
                                                   >> 257           G4TrajectoryContainer* trajectoryContainer = currentEvent
                                                   >> 258               ->GetTrajectoryContainer();
234                                                   259 
235           if (!trajectoryContainer) {          << 260           if (!trajectoryContainer)
                                                   >> 261           {
236             trajectoryContainer = new G4Trajec    262             trajectoryContainer = new G4TrajectoryContainer;
237             currentEvent->SetTrajectoryContain    263             currentEvent->SetTrajectoryContainer(trajectoryContainer);
238           }                                       264           }
239           trajectoryContainer->insert(trajecto    265           trajectoryContainer->insert(trajectory);
240         }                                         266         }
241         else {                                 << 267         else
                                                   >> 268         {
242           fTrajectories.push_back(trajectory);    269           fTrajectories.push_back(trajectory);
243         }                                         270         }
244       }                                           271       }
245     }                                             272     }
246     // Destruct the trajectory if it was creat    273     // Destruct the trajectory if it was created
247     else if ((!fStoreTrajectory) && trajectory << 274     else if( (!fStoreTrajectory)&&trajectory ) {
248       delete trajectory;                          275       delete trajectory;
249       trajectory = 0;                             276       trajectory = 0;
250     }                                             277     }
251     delete trajectory_lock;                       278     delete trajectory_lock;
252     trackingInfo->SetTrajectory_Lock(0);          279     trackingInfo->SetTrajectory_Lock(0);
253   }                                               280   }
254   // #endif                                    << 281 //#endif
255 }                                                 282 }
256                                                   283 
257 void ITTrackingInteractivity::Finalize()          284 void ITTrackingInteractivity::Finalize()
258 {                                                 285 {
259   for (std::vector<G4VTrajectory*>::iterator i << 286   for (std::vector<G4VTrajectory*>::iterator it = fTrajectories.begin();
260        it++)                                   << 287       it != fTrajectories.end(); it++)
261   {                                               288   {
262     G4VisManager::GetConcreteInstance()->Draw(    289     G4VisManager::GetConcreteInstance()->Draw(**it);
263   }                                               290   }
264 }                                                 291 }
265                                                   292