![]() |
|
|||
File indexing completed on 2025-10-20 08:05:22
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file electromagnetic/TestEm1/src/TrackingAction.cc 0027 /// \brief Implementation of the TrackingAction class 0028 // 0029 // 0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0032 0033 #include "TrackingAction.hh" 0034 0035 #include "EventAction.hh" 0036 #include "HistoManager.hh" 0037 #include "PrimaryGeneratorAction.hh" 0038 #include "Run.hh" 0039 0040 #include "G4Positron.hh" 0041 #include "G4PhysicalConstants.hh" 0042 #include "G4RunManager.hh" 0043 #include "G4StepStatus.hh" 0044 #include "G4SystemOfUnits.hh" 0045 #include "G4Track.hh" 0046 #include "G4UnitsTable.hh" 0047 0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0049 0050 TrackingAction::TrackingAction(PrimaryGeneratorAction* prim, EventAction* evt) 0051 : fPrimary(prim),fEventAction(evt) {} 0052 0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0054 0055 void TrackingAction::PreUserTrackingAction(const G4Track*) 0056 { 0057 /* 0058 //debug 0059 const G4DynamicParticle* dynamic = aTrack->GetDynamicParticle(); 0060 G4double dynamCharge = dynamic->GetCharge(); 0061 G4int occup = dynamic->GetTotalOccupancy(); 0062 G4double pdgMass = dynamic->GetParticleDefinition()->GetPDGMass(); 0063 G4double invarMass = dynamic->Get4Momentum().m(); 0064 G4double dynamMass = dynamic->GetMass(); 0065 G4double dif1 = invarMass - pdgMass; 0066 G4double dif2 = dynamMass - pdgMass; 0067 0068 G4cout 0069 << "\n Begin of track :" 0070 << "\n charge= " << dynamCharge << " occupancy= " << occup 0071 << "\n pdgMass= " << G4BestUnit (pdgMass , "Energy") 0072 /// << "\n invarMass= " << G4BestUnit (invarMass, "Energy") 0073 /// << " invar-pdg= " << G4BestUnit (dif1 , "Energy") 0074 << "\n dynamMass= " << G4BestUnit (dynamMass, "Energy") 0075 << " dynam-pdg= " << G4BestUnit (dif2 , "Energy") 0076 << G4endl; 0077 */ 0078 } 0079 0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0081 0082 void TrackingAction::PostUserTrackingAction(const G4Track* aTrack) 0083 { 0084 // increase nb of processed tracks 0085 // count nb of steps of this track 0086 G4int nbSteps = aTrack->GetCurrentStepNumber(); 0087 G4double Trleng = aTrack->GetTrackLength(); 0088 0089 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun()); 0090 0091 if (aTrack->GetDefinition()->GetPDGCharge() == 0.) { 0092 run->CountTraks0(1); 0093 run->CountSteps0(nbSteps); 0094 } 0095 else { 0096 run->CountTraks1(1); 0097 run->CountSteps1(nbSteps); 0098 } 0099 0100 // true and projected ranges for primary particle 0101 if (aTrack->GetTrackID() == 1) { 0102 run->AddTrueRange(Trleng); 0103 G4ThreeVector vertex = fPrimary->GetParticleGun()->GetParticlePosition(); 0104 G4ThreeVector position = aTrack->GetPosition() - vertex; 0105 run->AddProjRange(position.x()); 0106 run->AddTransvDev(position.y()); 0107 run->AddTransvDev(position.z()); 0108 0109 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 0110 analysisManager->FillH1(1, Trleng); 0111 analysisManager->FillH1(2, (float)nbSteps); 0112 } 0113 /* 0114 //debug 0115 const G4DynamicParticle* dynamic = aTrack->GetDynamicParticle(); 0116 G4double dynamCharge = dynamic->GetCharge(); 0117 G4int occup = dynamic->GetTotalOccupancy(); 0118 G4double pdgMass = dynamic->GetParticleDefinition()->GetPDGMass(); 0119 G4double invarMass = dynamic->Get4Momentum().m(); 0120 G4double dynamMass = dynamic->GetMass(); 0121 G4double dif1 = invarMass - pdgMass; 0122 G4double dif2 = dynamMass - pdgMass; 0123 0124 G4cout 0125 << "\n End of track :" 0126 << "\n charge= " << dynamCharge << " occupancy= " << occup 0127 << "\n pdgMass= " << G4BestUnit (pdgMass , "Energy") 0128 /// << "\n invarMass= " << G4BestUnit (invarMass, "Energy") 0129 /// << " invar-pdg= " << G4BestUnit (dif1 , "Energy") 0130 << "\n dynamMass= " << G4BestUnit (dynamMass, "Energy") 0131 << " dynam-pdg= " << G4BestUnit (dif2 , "Energy") 0132 << G4endl; 0133 */ 0134 0135 // energy leakage 0136 G4StepStatus status = aTrack->GetStep()->GetPostStepPoint()->GetStepStatus(); 0137 if (status == fWorldBoundary) { 0138 G4double eleak = aTrack->GetKineticEnergy(); 0139 if (aTrack->GetDefinition() == G4Positron::Positron()) { 0140 eleak += 2*electron_mass_c2; 0141 } 0142 fEventAction->AddEleak(eleak); 0143 } 0144 } 0145 0146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |