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