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 electromagnetic/TestEm5/src/Tracking << 27 /// \brief Implementation of the TrackingActio << 28 // << 29 // 26 // >> 27 // $Id: TrackingAction.cc,v 1.18 2008-08-28 15:28:04 maire Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ 30 // 29 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 32 34 #include "TrackingAction.hh" 33 #include "TrackingAction.hh" 35 34 36 #include "DetectorConstruction.hh" 35 #include "DetectorConstruction.hh" >> 36 #include "RunAction.hh" 37 #include "EventAction.hh" 37 #include "EventAction.hh" 38 #include "HistoManager.hh" 38 #include "HistoManager.hh" 39 #include "Run.hh" << 40 39 41 #include "G4PhysicalConstants.hh" << 42 #include "G4RunManager.hh" << 43 #include "G4SystemOfUnits.hh" << 44 #include "G4Track.hh" 40 #include "G4Track.hh" 45 41 46 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 43 48 TrackingAction::TrackingAction(DetectorConstru << 44 TrackingAction::TrackingAction(DetectorConstruction* DET,RunAction* RA, 49 : fDetector(det), fEventAction(event) << 45 EventAction* EA, HistoManager* HM) 50 {} << 46 :detector(DET), runaction(RA), eventaction(EA), histoManager(HM) 51 << 47 { } >> 48 52 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 50 54 void TrackingAction::PreUserTrackingAction(con << 51 void TrackingAction::PreUserTrackingAction(const G4Track* aTrack ) 55 { 52 { 56 // few initialisations 53 // few initialisations 57 // 54 // 58 if (aTrack->GetTrackID() == 1) { 55 if (aTrack->GetTrackID() == 1) { 59 fXstartAbs = fDetector->GetxstartAbs(); << 56 xstartAbs = detector->GetxstartAbs(); 60 fXendAbs = fDetector->GetxendAbs(); << 57 xendAbs = detector->GetxendAbs(); 61 fPrimaryCharge = aTrack->GetDefinition()-> << 58 primaryCharge = aTrack->GetDefinition()->GetPDGCharge(); 62 fDirX = aTrack->GetMomentumDirection().x() << 63 } 59 } 64 } 60 } 65 61 66 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 63 68 void TrackingAction::PostUserTrackingAction(co 64 void TrackingAction::PostUserTrackingAction(const G4Track* aTrack) 69 { 65 { 70 G4AnalysisManager* analysisManager = G4Analy << 71 << 72 Run* run = static_cast<Run*>(G4RunManager::G << 73 << 74 G4ThreeVector position = aTrack->GetPosition 66 G4ThreeVector position = aTrack->GetPosition(); 75 G4ThreeVector vertex = aTrack->GetVertexPosi << 67 G4ThreeVector vertex = aTrack->GetVertexPosition(); 76 G4double charge = aTrack->GetDefinition()->G << 68 G4double charge = aTrack->GetDefinition()->GetPDGCharge(); 77 G4double energy = aTrack->GetKineticEnergy() << 69 78 << 70 G4bool transmit = ((position.x() >= xendAbs) && (vertex.x() < xendAbs)); 79 G4bool transmit = << 71 G4bool reflect = (position.x() <= xstartAbs); 80 (((fDirX >= 0.0 && position.x() >= fXendAb << 81 && energy > 0.0); << 82 G4bool reflect = << 83 (((fDirX >= 0.0 && position.x() <= fXstart << 84 && energy > 0.0); << 85 G4bool notabsor = (transmit || reflect); 72 G4bool notabsor = (transmit || reflect); 86 73 87 // transmitted + reflected particles counter << 74 //transmitted + reflected particles counter 88 // 75 // 89 G4int flag = 0; 76 G4int flag = 0; 90 if (charge == fPrimaryCharge) flag = 1; << 77 if (charge == primaryCharge) flag = 1; 91 if (aTrack->GetTrackID() == 1) flag = 2; 78 if (aTrack->GetTrackID() == 1) flag = 2; 92 if (transmit) fEventAction->SetTransmitFlag( << 79 if (transmit) eventaction->SetTransmitFlag(flag); 93 if (reflect) fEventAction->SetReflectFlag(fl << 80 if (reflect) eventaction->SetReflectFlag(flag); 94 << 81 95 // 82 // 96 // histograms << 83 //histograms 97 // 84 // 98 G4bool charged = (charge != 0.); << 85 G4bool charged = (charge != 0.); 99 G4bool neutral = !charged; 86 G4bool neutral = !charged; 100 87 101 // energy spectrum at exit << 88 //energy spectrum at exit 102 // zero energy charged particle are not take << 103 // 89 // 104 G4int id = 0; << 90 G4int id = 0; 105 if (transmit && charged) << 91 if (transmit && charged) id = 10; 106 id = 10; << 92 else if (transmit && neutral) id = 20; 107 else if (transmit && neutral) << 93 else if (reflect && charged) id = 30; 108 id = 20; << 94 else if (reflect && neutral) id = 40; 109 else if (reflect && charged) << 95 110 id = 30; << 96 if (id>0) 111 else if (reflect && neutral) << 97 histoManager->FillHisto(id, aTrack->GetKineticEnergy()); 112 id = 40; << 98 113 << 99 //energy leakage 114 if (id > 0) { << 115 analysisManager->FillH1(id, energy); << 116 } << 117 << 118 // energy leakage << 119 // 100 // 120 if (notabsor) { 101 if (notabsor) { 121 G4int trackID = aTrack->GetTrackID(); 102 G4int trackID = aTrack->GetTrackID(); 122 G4int index = 0; << 103 G4int index = 0; if (trackID > 1) index = 1; //primary=0, secondaries=1 123 if (trackID > 1) index = 1; // primary=0, << 124 G4double eleak = aTrack->GetKineticEnergy( 104 G4double eleak = aTrack->GetKineticEnergy(); 125 if ((aTrack->GetDefinition() == G4Positron 105 if ((aTrack->GetDefinition() == G4Positron::Positron()) && (trackID > 1)) 126 eleak += 2 * electron_mass_c2; << 106 eleak += 2*electron_mass_c2; 127 run->AddEnergyLeak(eleak, index); << 107 runaction->AddEnergyLeak(eleak,index); 128 } 108 } 129 109 130 // space angle distribution at exit : dN/dOm << 110 //space angle distribution at exit : dN/dOmega 131 // 111 // 132 G4ThreeVector direction = aTrack->GetMomentu << 112 G4ThreeVector direction = aTrack->GetMomentumDirection(); 133 id = 0; << 113 id = 0; 134 if (transmit && charged) << 114 if (transmit && charged) id = 12; 135 id = 12; << 115 else if (transmit && neutral) id = 22; 136 else if (transmit && neutral) << 116 else if (reflect && charged) id = 32; 137 id = 22; << 117 else if (reflect && neutral) id = 42; 138 else if (reflect && charged) << 118 139 id = 32; << 119 if (id>0) { 140 else if (reflect && neutral) << 120 G4double theta = std::acos(direction.x()); 141 id = 42; << 121 G4double dteta = histoManager->GetBinWidth(id); 142 << 122 G4double unit = histoManager->GetHistoUnit(id); 143 if (id > 0 && std::abs(direction.x()) < 1.0) << 123 G4double weight = (unit*unit)/(twopi*std::sin(theta)*dteta); 144 G4double theta = std::acos(direction.x()); << 124 histoManager->FillHisto(id,theta,weight); 145 if (theta > 0.0) { << 125 } 146 G4double dteta = analysisManager->GetH1W << 126 147 G4double unit = analysisManager->GetH1Un << 127 //energy fluence at exit : dE(MeV)/dOmega 148 G4double weight = unit / (twopi * std::s << 128 // 149 /* << 129 id = 0; 150 G4cout << "theta, dteta, unit, weight: " << 130 if (transmit && charged) id = 11; 151 << theta << " " << 131 else if (transmit && neutral) id = 21; 152 << dteta << " " << 132 else if (reflect && charged) id = 31; 153 << unit << " " << 133 else if (reflect && neutral) id = 41; 154 << weight << G4endl; << 134 155 */ << 135 if (id>0) { 156 analysisManager->FillH1(id, theta, weigh << 136 G4double theta = std::acos(direction.x()); 157 } << 137 G4double dteta = histoManager->GetBinWidth(id); 158 } << 138 G4double unit = histoManager->GetHistoUnit(id); 159 << 139 G4double weight = (unit*unit)/(twopi*std::sin(theta)*dteta); 160 // energy fluence at exit : dE(MeV)/dOmega << 140 weight *= (aTrack->GetKineticEnergy()/MeV); 161 // << 141 histoManager->FillHisto(id,theta,weight); 162 id = 0; << 142 } 163 if (transmit && charged) << 143 164 id = 11; << 144 //projected angles distribution at exit 165 else if (reflect && charged) << 145 // 166 id = 31; << 146 id = 0; 167 else if (transmit && neutral) << 147 if (transmit && charged) id = 13; 168 id = 21; << 148 else if (transmit && neutral) id = 23; 169 else if (reflect && neutral) << 149 else if (reflect && charged) id = 33; 170 id = 41; << 150 else if (reflect && neutral) id = 43; 171 << 151 172 if (id > 0 && std::abs(direction.x()) < 1.0) << 152 if(id>0) { 173 G4double theta = std::acos(direction.x()); << 153 G4double tet = std::atan(direction.y()/std::fabs(direction.x())); 174 if (theta > 0.0) { << 154 histoManager->FillHisto(id,tet); 175 G4double dteta = analysisManager->GetH1W << 155 if (transmit && (flag == 2)) runaction->AddMscProjTheta(tet); 176 G4double unit = analysisManager->GetH1Un << 156 177 G4double weight = unit / (twopi * std::s << 157 tet = std::atan(direction.z()/std::fabs(direction.x())); 178 weight *= (aTrack->GetKineticEnergy() / << 158 histoManager->FillHisto(id,tet); 179 analysisManager->FillH1(id, theta, weigh << 159 if (transmit && (flag == 2)) runaction->AddMscProjTheta(tet); 180 } << 160 } 181 } << 161 182 << 162 //projected position and radius at exit 183 // projected angles distribution at exit << 163 // 184 // << 164 id = 0; 185 id = 0; << 165 if (transmit && charged) id = 14; 186 if (transmit && charged) << 166 187 id = 13; << 167 if (id>0) { 188 else if (transmit && neutral) << 189 id = 23; << 190 else if (reflect && charged) << 191 id = 33; << 192 else if (reflect && neutral) << 193 id = 43; << 194 << 195 if (id > 0) { << 196 if (direction.x() != 0.0) { << 197 G4double tet = std::atan(direction.y() / << 198 analysisManager->FillH1(id, tet); << 199 if (transmit && (flag == 2)) run->AddMsc << 200 << 201 tet = std::atan(direction.z() / std::fab << 202 analysisManager->FillH1(id, tet); << 203 if (transmit && (flag == 2)) run->AddMsc << 204 } << 205 } << 206 << 207 // projected position and radius at exit << 208 // << 209 if (transmit && energy > 0.0) { << 210 G4double y = position.y(), z = position.z( 168 G4double y = position.y(), z = position.z(); 211 G4double r = std::sqrt(y * y + z * z); << 169 G4double r = std::sqrt(y*y + z*z); 212 analysisManager->FillH1(14, y); << 170 histoManager->FillHisto(id, y); 213 analysisManager->FillH1(14, z); << 171 histoManager->FillHisto(id, z); 214 analysisManager->FillH1(15, r); << 172 histoManager->FillHisto(id+1, r); 215 } 173 } 216 << 174 217 // x-vertex of charged secondaries << 175 //x-vertex of charged secondaries 218 // 176 // 219 if ((aTrack->GetParentID() == 1) && charged) 177 if ((aTrack->GetParentID() == 1) && charged) { 220 G4double xVertex = (aTrack->GetVertexPosit 178 G4double xVertex = (aTrack->GetVertexPosition()).x(); 221 analysisManager->FillH1(6, xVertex); << 179 histoManager->FillHisto(4, xVertex); 222 if (notabsor) analysisManager->FillH1(7, x << 180 if (notabsor) histoManager->FillHisto(5, xVertex); 223 } 181 } 224 } 182 } 225 183 226 //....oooOO0OOooo........oooOO0OOooo........oo 184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 185 227 186