Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4TrackingManager class implementation << 23 // >> 24 // $Id: G4TrackingManager.cc,v 1.15 2003/11/18 18:39:39 asaim Exp $ >> 25 // GEANT4 tag $Name: geant4-06-00 $ >> 26 // >> 27 // >> 28 //--------------------------------------------------------------- >> 29 // >> 30 // G4TrackingManager.cc 27 // 31 // 28 // Contact: 32 // Contact: 29 // Questions and comments to this code shoul 33 // Questions and comments to this code should be sent to 30 // Katsuya Amako (e-mail: Katsuya.Amako@k 34 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) 31 // Takashi Sasaki (e-mail: Takashi.Sasaki@ 35 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) 32 // ------------------------------------------- << 36 // >> 37 //--------------------------------------------------------------- 33 38 34 #include "G4TrackingManager.hh" 39 #include "G4TrackingManager.hh" 35 << 36 #include "G4Trajectory.hh" 40 #include "G4Trajectory.hh" 37 #include "G4RichTrajectory.hh" << 38 #include "G4SmoothTrajectory.hh" << 39 #include "G4ios.hh" 41 #include "G4ios.hh" 40 42 41 ////////////////////////////////////// 43 ////////////////////////////////////// 42 G4TrackingManager::G4TrackingManager() 44 G4TrackingManager::G4TrackingManager() 43 ////////////////////////////////////// 45 ////////////////////////////////////// >> 46 : fpUserTrackingAction(NULL), fpTrajectory(NULL), >> 47 StoreTrajectory(false), verboseLevel(0), EventIsAborted(false) 44 { 48 { 45 messenger = new G4TrackingMessenger(this); << 46 fpSteppingManager = new G4SteppingManager(); 49 fpSteppingManager = new G4SteppingManager(); >> 50 messenger = new G4TrackingMessenger(this); 47 } 51 } 48 52 49 /////////////////////////////////////// 53 /////////////////////////////////////// 50 G4TrackingManager::~G4TrackingManager() 54 G4TrackingManager::~G4TrackingManager() 51 /////////////////////////////////////// 55 /////////////////////////////////////// 52 { 56 { 53 delete messenger; 57 delete messenger; 54 delete fpSteppingManager; 58 delete fpSteppingManager; 55 delete fpUserTrackingAction; << 59 if (fpUserTrackingAction) delete fpUserTrackingAction; 56 } 60 } 57 61 58 ////////////////////////////////////////////// 62 //////////////////////////////////////////////////////////////// 59 void G4TrackingManager::ProcessOneTrack(G4Trac 63 void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track) 60 ////////////////////////////////////////////// 64 //////////////////////////////////////////////////////////////// 61 { 65 { 62 // Receiving a G4Track from the EventManager << 63 // responsibility to trace the track till it << 64 66 >> 67 // Receiving a G4Track from the EventManager, this funciton has the >> 68 // responsibility to trace the track till it stops. 65 fpTrack = apValueG4Track; 69 fpTrack = apValueG4Track; 66 EventIsAborted = false; 70 EventIsAborted = false; 67 71 68 // Clear secondary particle vector << 72 // Clear 2ndary particle vector 69 // << 73 // GimmeSecondaries()->clearAndDestroy(); 70 for (auto& itr : *GimmeSecondaries()) { << 74 // std::vector<G4Track*>::iterator itr; 71 delete itr; << 75 size_t itr; >> 76 // for(itr=GimmeSecondaries()->begin();itr=GimmeSecondaries()->end();itr++){ >> 77 for(itr=0;itr<GimmeSecondaries()->size();itr++){ >> 78 delete (*GimmeSecondaries())[itr]; 72 } 79 } 73 GimmeSecondaries()->clear(); << 80 GimmeSecondaries()->clear(); 74 << 81 75 if (verboseLevel > 0 && (G4VSteppingVerbose: << 82 #ifdef G4VERBOSE >> 83 // !!!!! Verbose >> 84 if(verboseLevel>0) Verbose("ProcessOneTrack"); >> 85 #endif 76 86 77 // Give SteppingManger the pointer to the tr << 87 // Give SteppingManger the pointer to the track which will be tracked 78 // << 79 fpSteppingManager->SetInitialStep(fpTrack); 88 fpSteppingManager->SetInitialStep(fpTrack); 80 89 81 // Pre tracking user intervention process << 90 // Pre tracking user intervention process. 82 << 91 fpTrajectory = 0; 83 fpTrajectory = nullptr; << 92 if( fpUserTrackingAction != NULL ) { 84 if (fpUserTrackingAction != nullptr) { << 93 fpUserTrackingAction->PreUserTrackingAction(fpTrack); 85 fpUserTrackingAction->PreUserTrackingActio << 86 } 94 } 87 << 88 // we need this to scope the G4Track::Profil << 89 // the PreUserTrackingAction and PostUserTra << 90 { << 91 #ifdef G4_STORE_TRAJECTORY 95 #ifdef G4_STORE_TRAJECTORY 92 // Construct a trajectory if it is request << 96 // Construct a trajectory if it is requested 93 // << 97 if(StoreTrajectory&&(!fpTrajectory)) { 94 if ((StoreTrajectory != 0) && (fpTrajector << 98 fpTrajectory = new G4Trajectory(fpTrack); // default trajectory concrete class object 95 // default trajectory concrete class obj << 99 } 96 switch (StoreTrajectory) { << 97 default: << 98 case 1: << 99 fpTrajectory = new G4Trajectory(fpTr << 100 break; << 101 case 2: << 102 fpTrajectory = new G4SmoothTrajector << 103 break; << 104 case 3: << 105 fpTrajectory = new G4RichTrajectory( << 106 break; << 107 case 4: << 108 fpTrajectory = new G4RichTrajectory( << 109 break; << 110 } << 111 } << 112 #endif 100 #endif 113 101 114 // Give SteppingManger the maxmimum number << 102 // Give SteppingManger the maxmimum number of processes 115 fpSteppingManager->GetProcessNumber(); << 103 fpSteppingManager->GetProcessNumber(); 116 104 117 // Give track the pointer to the Step << 105 // Give track the pointer to the Step 118 fpTrack->SetStep(fpSteppingManager->GetSte << 106 fpTrack->SetStep(fpSteppingManager->GetStep()); 119 107 120 // Inform beginning of tracking to physics << 108 // Inform beginning of tracking to physics processes 121 fpTrack->GetDefinition()->GetProcessManage << 109 fpTrack->GetDefinition()->GetProcessManager()->StartTracking(); 122 110 123 // Track the particle Step-by-Step while i << 111 // Track the particle Step-by-Step while it is alive 124 // << 112 G4StepStatus stepStatus; 125 while ((fpTrack->GetTrackStatus() == fAliv << 113 126 fpTrack->IncrementCurrentStepNumber(); << 114 while( (fpTrack->GetTrackStatus() == fAlive) || 127 fpSteppingManager->Stepping(); << 115 (fpTrack->GetTrackStatus() == fStopButAlive) ){ >> 116 >> 117 fpTrack->IncrementCurrentStepNumber(); >> 118 stepStatus = fpSteppingManager->Stepping(); 128 #ifdef G4_STORE_TRAJECTORY 119 #ifdef G4_STORE_TRAJECTORY 129 if (StoreTrajectory != 0) { << 120 if(StoreTrajectory) fpTrajectory-> 130 fpTrajectory->AppendStep(fpSteppingMan << 121 AppendStep(fpSteppingManager->GetStep()); 131 } << 122 #endif 132 #endif << 123 if(EventIsAborted) { 133 if (EventIsAborted) { << 124 fpTrack->SetTrackStatus( fKillTrackAndSecondaries ); 134 fpTrack->SetTrackStatus(fKillTrackAndS << 135 } << 136 } 125 } 137 // Inform end of tracking to physics proce << 138 fpTrack->GetDefinition()->GetProcessManage << 139 } 126 } >> 127 // Inform end of tracking to physics processes >> 128 fpTrack->GetDefinition()->GetProcessManager()->EndTracking(); 140 129 141 // Post tracking user intervention process. 130 // Post tracking user intervention process. 142 if (fpUserTrackingAction != nullptr) { << 131 if( fpUserTrackingAction != NULL ) { 143 fpUserTrackingAction->PostUserTrackingActi << 132 fpUserTrackingAction->PostUserTrackingAction(fpTrack); 144 } 133 } 145 134 146 // Destruct the trajectory if it was created 135 // Destruct the trajectory if it was created 147 #ifdef G4VERBOSE 136 #ifdef G4VERBOSE 148 if ((StoreTrajectory != 0) && verboseLevel > << 137 if(StoreTrajectory&&verboseLevel>10) fpTrajectory->ShowTrajectory(); 149 fpTrajectory->ShowTrajectory(); << 150 } << 151 #endif 138 #endif 152 if ((StoreTrajectory == 0) && (fpTrajectory << 139 if( (!StoreTrajectory)&&fpTrajectory ) { 153 delete fpTrajectory; << 140 delete fpTrajectory; 154 fpTrajectory = nullptr; << 141 fpTrajectory = 0; 155 } 142 } 156 } 143 } 157 144 158 ////////////////////////////////////// << 159 void G4TrackingManager::SetTrajectory(G4VTraje 145 void G4TrackingManager::SetTrajectory(G4VTrajectory* aTrajectory) 160 ////////////////////////////////////// << 161 { 146 { 162 #ifndef G4_STORE_TRAJECTORY 147 #ifndef G4_STORE_TRAJECTORY 163 G4Exception("G4TrackingManager::SetTrajector << 148 G4Exception("G4TrackingManager::SetTrajectory is invoked without G4_STORE_TRAJECTORY compilor option"); 164 "Invoked without G4_STORE_TRAJECTORY optio << 165 #endif 149 #endif 166 fpTrajectory = aTrajectory; 150 fpTrajectory = aTrajectory; 167 } 151 } 168 152 169 ////////////////////////////////////// 153 ////////////////////////////////////// 170 void G4TrackingManager::EventAborted() 154 void G4TrackingManager::EventAborted() 171 ////////////////////////////////////// 155 ////////////////////////////////////// 172 { 156 { 173 fpTrack->SetTrackStatus(fKillTrackAndSeconda << 157 fpTrack->SetTrackStatus( fKillTrackAndSecondaries ); 174 EventIsAborted = true; 158 EventIsAborted = true; 175 } 159 } 176 160 177 ////////////////////////////////////// << 161 //************************************************************************ 178 void G4TrackingManager::TrackBanner() << 162 // 179 ////////////////////////////////////// << 163 // Private Member Functions 180 { << 164 // 181 G4cout << G4endl; << 165 //************************************************************************ 182 G4cout << "********************************* << 183 << "********************************* << 184 G4cout << "* G4Track Information: " << 185 << " Particle = " << fpTrack->GetDef << 186 << " Track ID = " << fpTrack->GetTr << 187 << " Parent ID = " << fpTrack->GetP << 188 G4cout << "********************************* << 189 << "********************************* << 190 G4cout << G4endl; << 191 } << 192 166 193 ////////////////////////////////////// << 167 194 void G4TrackingManager::SetStoreTrajectory(G4i << 168 //////////////////////////////////////////////// 195 ////////////////////////////////////// << 169 void G4TrackingManager::Verbose(G4String select) >> 170 //////////////////////////////////////////////// 196 { 171 { 197 StoreTrajectory = value; << 172 >> 173 // !!!!! Verbose >> 174 if( select == "ProcessOneTrack" ){ >> 175 #ifdef G4VERBOSE >> 176 if(verboseLevel >= 1) { >> 177 G4cout << G4endl; >> 178 G4cout << "*******************************************************" >> 179 << "**************************************************" >> 180 << G4endl; >> 181 G4cout << "* G4Track Information: " >> 182 << " Particle = " << fpTrack->GetDefinition()->GetParticleName() >> 183 << "," >> 184 << " Track ID = " << fpTrack->GetTrackID() >> 185 << "," >> 186 << " Parent ID = " << fpTrack->GetParentID() >> 187 << G4endl; >> 188 G4cout << "*******************************************************" >> 189 << "**************************************************" >> 190 << G4endl; >> 191 G4cout << G4endl; >> 192 >> 193 } >> 194 #endif >> 195 } 198 } 196 } >> 197 >> 198 >> 199 >> 200 >> 201 >> 202 >> 203 >> 204 199 205 200 206