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