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 medical/fanoCavity/src/SteppingActio 26 /// \file medical/fanoCavity/src/SteppingAction.cc 27 /// \brief Implementation of the SteppingActio 27 /// \brief Implementation of the SteppingAction class 28 // 28 // >> 29 // $Id: SteppingAction.cc 98764 2016-08-09 14:12:17Z gcosmo $ 29 // 30 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 33 33 #include "SteppingAction.hh" 34 #include "SteppingAction.hh" 34 << 35 #include "DetectorConstruction.hh" 35 #include "DetectorConstruction.hh" 36 #include "HistoManager.hh" << 37 #include "Run.hh" << 38 #include "RunAction.hh" 36 #include "RunAction.hh" 39 #include "TrackingAction.hh" 37 #include "TrackingAction.hh" 40 << 38 #include "HistoManager.hh" 41 #include "G4Gamma.hh" << 39 #include "Run.hh" 42 #include "G4RunManager.hh" 40 #include "G4RunManager.hh" >> 41 43 #include "G4SteppingManager.hh" 42 #include "G4SteppingManager.hh" >> 43 #include "G4Gamma.hh" 44 #include "G4UnitsTable.hh" 44 #include "G4UnitsTable.hh" 45 45 46 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 47 48 SteppingAction::SteppingAction(DetectorConstru << 48 SteppingAction::SteppingAction(DetectorConstruction* det,TrackingAction* TrAct) 49 : fDetector(det), fTrackAction(TrAct), fWall << 49 :fDetector(det), fTrackAction(TrAct), 50 { << 50 fWall(0), fCavity(0) >> 51 { 51 first = true; 52 first = true; 52 fTrackSegm = 0.; 53 fTrackSegm = 0.; 53 fDirectionIn = G4ThreeVector(0., 0., 0.); << 54 fDirectionIn = G4ThreeVector(0.,0.,0.); 54 } 55 } 55 56 56 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 58 58 SteppingAction::~SteppingAction() {} << 59 SteppingAction::~SteppingAction() >> 60 { } 59 61 60 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 63 62 void SteppingAction::UserSteppingAction(const 64 void SteppingAction::UserSteppingAction(const G4Step* step) 63 { 65 { 64 // get fDetector pointers << 66 //get fDetector pointers 65 if (first) { << 67 if (first) { 66 fWall = fDetector->GetWall(); << 68 fWall = fDetector->GetWall(); 67 fCavity = fDetector->GetCavity(); << 69 fCavity = fDetector->GetCavity(); 68 first = false; << 70 first = false; 69 } << 71 } 70 << 72 71 // histograms << 73 //histograms 72 G4AnalysisManager* analysisManager = G4Analy << 74 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 73 << 75 74 // get volume << 76 //get volume 75 // << 77 // 76 G4StepPoint* point1 = step->GetPreStepPoint( << 78 G4StepPoint* point1 = step->GetPreStepPoint(); 77 G4VPhysicalVolume* volume = point1->GetTouch << 79 G4VPhysicalVolume* volume = point1->GetTouchableHandle()->GetVolume(); 78 << 80 79 Run* run = static_cast<Run*>(G4RunManager::G << 81 Run* run = static_cast<Run*>( 80 // count processes << 82 G4RunManager::GetRunManager()->GetNonConstCurrentRun()); 81 // << 83 // count processes 82 G4StepPoint* point2 = step->GetPostStepPoint << 84 // 83 const G4VProcess* process = point2->GetProce << 85 G4StepPoint* point2 = step->GetPostStepPoint(); 84 if (process) run->CountProcesses(process->Ge << 86 const G4VProcess* process = point2->GetProcessDefinedStep(); 85 << 87 if (process) run->CountProcesses(process->GetProcessName()); 86 // energy deposit in cavity << 88 87 // << 89 //energy deposit in cavity 88 if (volume == fCavity) { << 90 // 89 G4double edep = step->GetTotalEnergyDeposi << 91 if (volume == fCavity) { 90 if (edep > 0.) fTrackAction->AddEdepCavity << 92 G4double edep = step->GetTotalEnergyDeposit(); 91 } << 93 if (edep > 0.) fTrackAction->AddEdepCavity(edep); 92 << 94 } 93 // keep only charged particles << 95 94 // << 96 //keep only charged particles 95 if (step->GetTrack()->GetDefinition() == G4G << 97 // 96 << 98 if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return; 97 // step size of charged particles << 99 98 // << 100 //step size of charged particles 99 G4int id; << 101 // 100 G4double steplen = step->GetStepLength(); << 102 G4int id; 101 if (volume == fWall) { << 103 G4double steplen = step->GetStepLength(); 102 run->StepInWall(steplen); << 104 if (volume == fWall) {run->StepInWall (steplen); id = 9;} 103 id = 9; << 105 else {run->StepInCavity(steplen); id = 10;} 104 } << 106 analysisManager->FillH1(id,steplen); 105 else { << 107 106 run->StepInCavity(steplen); << 108 //last step before hitting the cavity 107 id = 10; << 109 // 108 } << 110 if ((volume == fWall) && (point2->GetStepStatus() == fGeomBoundary)) { 109 analysisManager->FillH1(id, steplen); << 111 fDirectionIn = point1->GetMomentumDirection(); 110 << 112 } 111 // last step before hitting the cavity << 113 112 // << 114 //keep only charged particles within cavity 113 if ((volume == fWall) && (point2->GetStepSta << 115 // 114 fDirectionIn = point1->GetMomentumDirectio << 116 if (volume == fWall) return; 115 } << 117 116 << 118 G4double ekin1 = point1->GetKineticEnergy(); 117 // keep only charged particles within cavity << 119 G4double ekin2 = point2->GetKineticEnergy(); 118 // << 120 119 if (volume == fWall) return; << 121 //first step in cavity 120 << 122 // 121 G4double ekin1 = point1->GetKineticEnergy(); << 123 if (point1->GetStepStatus() == fGeomBoundary) { 122 G4double ekin2 = point2->GetKineticEnergy(); << 124 fTrackSegm = 0.; 123 << 125 G4ThreeVector vertex = step->GetTrack()->GetVertexPosition(); 124 // first step in cavity << 126 analysisManager->FillH1(4,vertex.z()); 125 // << 127 run->FlowInCavity(0,ekin1); 126 if (point1->GetStepStatus() == fGeomBoundary << 128 analysisManager->FillH1(5,ekin1); 127 fTrackSegm = 0.; << 129 if (steplen>0.) { 128 G4ThreeVector vertex = step->GetTrack()->G << 130 G4ThreeVector directionOut = 129 analysisManager->FillH1(4, vertex.z()); << 131 (point2->GetPosition() - point1->GetPosition()).unit(); 130 run->FlowInCavity(0, ekin1); << 132 G4ThreeVector normal = point1->GetTouchableHandle()->GetSolid() 131 analysisManager->FillH1(5, ekin1); << 133 ->SurfaceNormal(point1->GetPosition()); 132 if (steplen > 0.) { << 134 analysisManager->FillH1(6,std::acos(-fDirectionIn*normal)); 133 G4ThreeVector directionOut = (point2->Ge << 135 analysisManager->FillH1(7,std::acos(-directionOut*normal)); 134 G4ThreeVector normal = << 136 } 135 point1->GetTouchableHandle()->GetSolid << 137 } 136 analysisManager->FillH1(6, std::acos(-fD << 138 137 analysisManager->FillH1(7, std::acos(-di << 139 //within cavity 138 } << 140 // 139 } << 141 if (step->GetTrack()->GetCurrentStepNumber() == 1) fTrackSegm = 0.; 140 << 142 fTrackSegm += steplen; 141 // within cavity << 143 if (ekin2 <= 0.) { 142 // << 144 run->AddTrakCavity(fTrackSegm); 143 if (step->GetTrack()->GetCurrentStepNumber() << 145 analysisManager->FillH1(8,fTrackSegm); 144 fTrackSegm += steplen; << 146 } 145 if (ekin2 <= 0.) { << 147 146 run->AddTrakCavity(fTrackSegm); << 148 //exit cavity 147 analysisManager->FillH1(8, fTrackSegm); << 149 // 148 } << 150 if (point2->GetStepStatus() == fGeomBoundary) { 149 << 151 run->FlowInCavity(1,ekin2); 150 // exit cavity << 152 run->AddTrakCavity(fTrackSegm); 151 // << 153 analysisManager->FillH1(8,fTrackSegm); 152 if (point2->GetStepStatus() == fGeomBoundary << 154 } 153 run->FlowInCavity(1, ekin2); << 154 run->AddTrakCavity(fTrackSegm); << 155 analysisManager->FillH1(8, fTrackSegm); << 156 } << 157 } 155 } 158 156 159 //....oooOO0OOooo........oooOO0OOooo........oo 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 158 160 159