[827] | 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 | // |
---|
| 27 | // $Id: G4TrackingManager.cc,v 1.22 2006/11/14 10:58:47 tsasaki Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[827] | 29 | // |
---|
| 30 | //--------------------------------------------------------------- |
---|
| 31 | // |
---|
| 32 | // G4TrackingManager.cc |
---|
| 33 | // |
---|
| 34 | // Contact: |
---|
| 35 | // Questions and comments to this code should be sent to |
---|
| 36 | // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) |
---|
| 37 | // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) |
---|
| 38 | // |
---|
| 39 | //--------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | #include "G4TrackingManager.hh" |
---|
| 42 | #include "G4Trajectory.hh" |
---|
| 43 | #include "G4SmoothTrajectory.hh" |
---|
| 44 | #include "G4RichTrajectory.hh" |
---|
| 45 | #include "G4ios.hh" |
---|
| 46 | class G4VSteppingVerbose; |
---|
| 47 | |
---|
| 48 | ////////////////////////////////////// |
---|
| 49 | G4TrackingManager::G4TrackingManager() |
---|
| 50 | ////////////////////////////////////// |
---|
| 51 | : fpUserTrackingAction(NULL), fpTrajectory(NULL), |
---|
| 52 | StoreTrajectory(0), verboseLevel(0), EventIsAborted(false) |
---|
| 53 | { |
---|
| 54 | fpSteppingManager = new G4SteppingManager(); |
---|
| 55 | messenger = new G4TrackingMessenger(this); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | /////////////////////////////////////// |
---|
| 59 | G4TrackingManager::~G4TrackingManager() |
---|
| 60 | /////////////////////////////////////// |
---|
| 61 | { |
---|
| 62 | delete messenger; |
---|
| 63 | delete fpSteppingManager; |
---|
| 64 | if (fpUserTrackingAction) delete fpUserTrackingAction; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | //////////////////////////////////////////////////////////////// |
---|
| 68 | void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track) |
---|
| 69 | //////////////////////////////////////////////////////////////// |
---|
| 70 | { |
---|
| 71 | |
---|
| 72 | // Receiving a G4Track from the EventManager, this funciton has the |
---|
| 73 | // responsibility to trace the track till it stops. |
---|
| 74 | fpTrack = apValueG4Track; |
---|
| 75 | EventIsAborted = false; |
---|
| 76 | |
---|
| 77 | // Clear 2ndary particle vector |
---|
| 78 | // GimmeSecondaries()->clearAndDestroy(); |
---|
| 79 | // std::vector<G4Track*>::iterator itr; |
---|
| 80 | size_t itr; |
---|
| 81 | // for(itr=GimmeSecondaries()->begin();itr=GimmeSecondaries()->end();itr++){ |
---|
| 82 | for(itr=0;itr<GimmeSecondaries()->size();itr++){ |
---|
| 83 | delete (*GimmeSecondaries())[itr]; |
---|
| 84 | } |
---|
| 85 | GimmeSecondaries()->clear(); |
---|
| 86 | |
---|
| 87 | if(verboseLevel>0 && (G4VSteppingVerbose::GetSilent()!=1) ) TrackBanner(); |
---|
| 88 | |
---|
| 89 | // Give SteppingManger the pointer to the track which will be tracked |
---|
| 90 | fpSteppingManager->SetInitialStep(fpTrack); |
---|
| 91 | |
---|
| 92 | // Pre tracking user intervention process. |
---|
| 93 | fpTrajectory = 0; |
---|
| 94 | if( fpUserTrackingAction != NULL ) { |
---|
| 95 | fpUserTrackingAction->PreUserTrackingAction(fpTrack); |
---|
| 96 | } |
---|
| 97 | #ifdef G4_STORE_TRAJECTORY |
---|
| 98 | // Construct a trajectory if it is requested |
---|
| 99 | if(StoreTrajectory&&(!fpTrajectory)) { |
---|
| 100 | // default trajectory concrete class object |
---|
| 101 | switch (StoreTrajectory) { |
---|
| 102 | default: |
---|
| 103 | case 1: fpTrajectory = new G4Trajectory(fpTrack); break; |
---|
| 104 | case 2: fpTrajectory = new G4SmoothTrajectory(fpTrack); break; |
---|
| 105 | case 3: fpTrajectory = new G4RichTrajectory(fpTrack); break; |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | #endif |
---|
| 109 | |
---|
| 110 | // Give SteppingManger the maxmimum number of processes |
---|
| 111 | fpSteppingManager->GetProcessNumber(); |
---|
| 112 | |
---|
| 113 | // Give track the pointer to the Step |
---|
| 114 | fpTrack->SetStep(fpSteppingManager->GetStep()); |
---|
| 115 | |
---|
| 116 | // Inform beginning of tracking to physics processes |
---|
| 117 | fpTrack->GetDefinition()->GetProcessManager()->StartTracking(fpTrack); |
---|
| 118 | |
---|
| 119 | // Track the particle Step-by-Step while it is alive |
---|
| 120 | G4StepStatus stepStatus; |
---|
| 121 | |
---|
| 122 | while( (fpTrack->GetTrackStatus() == fAlive) || |
---|
| 123 | (fpTrack->GetTrackStatus() == fStopButAlive) ){ |
---|
| 124 | |
---|
| 125 | fpTrack->IncrementCurrentStepNumber(); |
---|
| 126 | stepStatus = fpSteppingManager->Stepping(); |
---|
| 127 | #ifdef G4_STORE_TRAJECTORY |
---|
| 128 | if(StoreTrajectory) fpTrajectory-> |
---|
| 129 | AppendStep(fpSteppingManager->GetStep()); |
---|
| 130 | #endif |
---|
| 131 | if(EventIsAborted) { |
---|
| 132 | fpTrack->SetTrackStatus( fKillTrackAndSecondaries ); |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | // Inform end of tracking to physics processes |
---|
| 136 | fpTrack->GetDefinition()->GetProcessManager()->EndTracking(); |
---|
| 137 | |
---|
| 138 | // Post tracking user intervention process. |
---|
| 139 | if( fpUserTrackingAction != NULL ) { |
---|
| 140 | fpUserTrackingAction->PostUserTrackingAction(fpTrack); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | // Destruct the trajectory if it was created |
---|
| 144 | #ifdef G4VERBOSE |
---|
| 145 | if(StoreTrajectory&&verboseLevel>10) fpTrajectory->ShowTrajectory(); |
---|
| 146 | #endif |
---|
| 147 | if( (!StoreTrajectory)&&fpTrajectory ) { |
---|
| 148 | delete fpTrajectory; |
---|
| 149 | fpTrajectory = 0; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | void G4TrackingManager::SetTrajectory(G4VTrajectory* aTrajectory) |
---|
| 154 | { |
---|
| 155 | #ifndef G4_STORE_TRAJECTORY |
---|
| 156 | G4Exception("G4TrackingManager::SetTrajectory is invoked without G4_STORE_TRAJECTORY compilor option"); |
---|
| 157 | #endif |
---|
| 158 | fpTrajectory = aTrajectory; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | ////////////////////////////////////// |
---|
| 162 | void G4TrackingManager::EventAborted() |
---|
| 163 | ////////////////////////////////////// |
---|
| 164 | { |
---|
| 165 | fpTrack->SetTrackStatus( fKillTrackAndSecondaries ); |
---|
| 166 | EventIsAborted = true; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | void G4TrackingManager::TrackBanner() |
---|
| 171 | { |
---|
| 172 | G4cout << G4endl; |
---|
| 173 | G4cout << "*******************************************************" |
---|
| 174 | << "**************************************************" |
---|
| 175 | << G4endl; |
---|
| 176 | G4cout << "* G4Track Information: " |
---|
| 177 | << " Particle = " << fpTrack->GetDefinition()->GetParticleName() |
---|
| 178 | << "," |
---|
| 179 | << " Track ID = " << fpTrack->GetTrackID() |
---|
| 180 | << "," |
---|
| 181 | << " Parent ID = " << fpTrack->GetParentID() |
---|
| 182 | << G4endl; |
---|
| 183 | G4cout << "*******************************************************" |
---|
| 184 | << "**************************************************" |
---|
| 185 | << G4endl; |
---|
| 186 | G4cout << G4endl; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | |
---|