Geant4 Cross Reference |
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 /// \file eventgenerator/particleGun/src/Track 26 /// \file eventgenerator/particleGun/src/TrackingAction.cc 27 /// \brief Implementation of the TrackingActio 27 /// \brief Implementation of the TrackingAction class 28 // 28 // 29 // 29 // 30 // << 30 // $Id: TrackingAction.cc 89707 2015-04-28 07:38:57Z gcosmo $ >> 31 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 34 34 #include "TrackingAction.hh" 35 #include "TrackingAction.hh" 35 << 36 #include "HistoManager.hh" << 37 #include "PrimaryGeneratorAction.hh" 36 #include "PrimaryGeneratorAction.hh" 38 #include "PrimaryGeneratorAction2.hh" 37 #include "PrimaryGeneratorAction2.hh" 39 #include "PrimaryGeneratorAction3.hh" 38 #include "PrimaryGeneratorAction3.hh" 40 #include "PrimaryGeneratorAction4.hh" 39 #include "PrimaryGeneratorAction4.hh" 41 #include "RunAction.hh" 40 #include "RunAction.hh" >> 41 #include "HistoManager.hh" 42 42 43 #include "G4PhysicalConstants.hh" << 44 #include "G4Track.hh" 43 #include "G4Track.hh" >> 44 #include "G4PhysicalConstants.hh" 45 45 46 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 47 48 TrackingAction::TrackingAction(PrimaryGenerato << 48 TrackingAction::TrackingAction(PrimaryGeneratorAction* prim) 49 { << 49 :G4UserTrackingAction(), fPrimary(prim) 50 // parameters for generator action #3 << 50 { >> 51 // parameters for generator action #3 51 fNewUz = fPrimary->GetAction3()->GetNewUz(); 52 fNewUz = fPrimary->GetAction3()->GetNewUz(); 52 } 53 } 53 54 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 56 56 void TrackingAction::PreUserTrackingAction(con 57 void TrackingAction::PreUserTrackingAction(const G4Track* track) 57 { << 58 { 58 G4int selectedGeneratorAction = fPrimary->Ge << 59 G4int selectedGeneratorAction = fPrimary->GetSelectedAction(); 59 G4AnalysisManager* analysis = G4AnalysisMana << 60 G4AnalysisManager* analysis = G4AnalysisManager::Instance(); 60 G4int id = 0; << 61 G4int id = 0; 61 << 62 62 if (selectedGeneratorAction == 2) { << 63 if(selectedGeneratorAction==2) 63 // energy spectrum << 64 { 64 // << 65 //energy spectrum 65 id = 1; << 66 // 66 analysis->FillH1(id, track->GetKineticEner << 67 id = 1; 67 } << 68 analysis->FillH1(id, track->GetKineticEnergy()); 68 << 69 } 69 else if (selectedGeneratorAction == 0) { << 70 70 // particle direction: cos(alpha) << 71 else if(selectedGeneratorAction==0) 71 // << 72 { 72 id = 5; << 73 //particle direction: cos(alpha) 73 G4ThreeVector um = track->GetMomentumDirec << 74 // 74 G4double cosalpha = um.z(); << 75 id = 5; 75 analysis->FillH1(id, cosalpha); << 76 G4ThreeVector um = track->GetMomentumDirection(); 76 << 77 G4double cosalpha = um.z(); 77 // particle direction: psi << 78 analysis->FillH1(id, cosalpha); 78 // << 79 79 id = 6; << 80 //particle direction: psi 80 G4double psi = std::atan2(um.y(), um.x()); << 81 // 81 if (psi < 0.) psi += twopi; << 82 id = 6; 82 analysis->FillH1(id, psi); << 83 G4double psi = std::atan2(um.y(), um.x()); 83 } << 84 if (psi < 0.) psi += twopi; 84 else if (selectedGeneratorAction == 3) { << 85 analysis->FillH1(id, psi); 85 // particle direction in local frame: cos( << 86 } 86 // << 87 else if(selectedGeneratorAction==3) 87 id = 5; << 88 { 88 G4ThreeVector um = track->GetMomentumDirec << 89 //particle direction in local frame: cos(alpha) 89 G4double cosalpha = fNewUz * um; << 90 // 90 analysis->FillH1(id, cosalpha); << 91 id = 5; 91 << 92 G4ThreeVector um = track->GetMomentumDirection(); 92 // particle direction in local frame: psi << 93 G4double cosalpha = fNewUz*um; 93 // << 94 analysis->FillH1(id, cosalpha); 94 id = 6; << 95 95 // complete local frame << 96 //particle direction in local frame: psi 96 G4ThreeVector u1(1., 0., 0.); << 97 // 97 u1.rotateUz(fNewUz); << 98 id = 6; 98 G4ThreeVector u2(0., 1., 0.); << 99 // complete local frame 99 u2.rotateUz(fNewUz); << 100 G4ThreeVector u1(1.,0.,0.); u1.rotateUz(fNewUz); 100 // << 101 G4ThreeVector u2(0.,1.,0.); u2.rotateUz(fNewUz); 101 G4double psi = std::atan2(u2 * um, u1 * um << 102 // 102 if (psi < 0.) psi += twopi; << 103 G4double psi = std::atan2(u2*um, u1*um); 103 analysis->FillH1(id, psi); << 104 if (psi < 0.) psi += twopi; 104 } << 105 analysis->FillH1(id, psi); 105 << 106 } 106 else if (selectedGeneratorAction == 4) { << 107 107 G4ThreeVector vertex = track->GetVertexPos << 108 else if(selectedGeneratorAction==4) 108 G4double r = vertex.mag(); << 109 { 109 if (r <= 0.0) return; << 110 G4ThreeVector vertex = track->GetVertexPosition(); 110 // local frame : new uz = ur << 111 G4double r = vertex.mag(); 111 G4ThreeVector ur = vertex / r; << 112 if (r <= 0.0) return; 112 << 113 //local frame : new uz = ur 113 // vertex position. radial distribution dN << 114 G4ThreeVector ur = vertex/r; 114 // << 115 115 id = 2; << 116 //vertex position. radial distribution dN/dv = f(r) 116 G4double dr = analysis->GetH1Width(id); << 117 // 117 G4double dv = 2 * twopi * r * r * dr; << 118 id = 2; 118 if (dv > 0.) analysis->FillH1(id, r, 1. / << 119 G4double dr = analysis->GetH1Width(id); 119 << 120 G4double dv = 2*twopi*r*r*dr; 120 // vertex position: cos(theta) << 121 if (dv > 0.) analysis->FillH1(id, r, 1./dv); 121 // << 122 122 id = 3; << 123 //vertex position: cos(theta) 123 G4double costheta = ur.z(); << 124 // 124 analysis->FillH1(id, costheta); << 125 id = 3; 125 << 126 G4double costheta = ur.z(); 126 // vertex position: phi << 127 analysis->FillH1(id, costheta); 127 // << 128 128 id = 4; << 129 //vertex position: phi 129 G4double phi = std::atan2(ur.y(), ur.x()); << 130 // 130 if (phi < 0.) phi += twopi; << 131 id = 4; 131 analysis->FillH1(id, phi); << 132 G4double phi = std::atan2(ur.y(), ur.x()); 132 << 133 if (phi < 0.) phi += twopi; 133 // particle direction in local frame: cos( << 134 analysis->FillH1(id, phi); 134 // << 135 135 id = 5; << 136 //particle direction in local frame: cos(alpha) 136 G4ThreeVector um = track->GetMomentumDirec << 137 // 137 G4double cosalpha = ur * um; << 138 id = 5; 138 analysis->FillH1(id, cosalpha); << 139 G4ThreeVector um = track->GetMomentumDirection(); 139 << 140 G4double cosalpha = ur*um; 140 // particle direction in local frame: psi << 141 analysis->FillH1(id, cosalpha); 141 // << 142 142 id = 6; << 143 //particle direction in local frame: psi 143 // complete local frame << 144 // 144 G4ThreeVector u1(1., 0., 0.); << 145 id = 6; 145 u1.rotateUz(ur); << 146 // complete local frame 146 G4ThreeVector u2(0., 1., 0.); << 147 G4ThreeVector u1(1.,0.,0.); u1.rotateUz(ur); 147 u2.rotateUz(ur); << 148 G4ThreeVector u2(0.,1.,0.); u2.rotateUz(ur); 148 // << 149 // 149 G4double psi = std::atan2(u2 * um, u1 * um << 150 G4double psi = std::atan2(u2*um, u1*um); 150 if (psi < 0.) psi += twopi; << 151 if (psi < 0.) psi += twopi; 151 analysis->FillH1(id, psi); << 152 analysis->FillH1(id, psi); 152 } << 153 } 153 } 154 } 154 155 155 //....oooOO0OOooo........oooOO0OOooo........oo 156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 156 157 157 void TrackingAction::PostUserTrackingAction(co << 158 void TrackingAction::PostUserTrackingAction(const G4Track*) >> 159 { } 158 160 159 //....oooOO0OOooo........oooOO0OOooo........oo 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 162 160 163