Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file runAndEvent/RE01/src/RE01SteppingAction.cc 27 /// \brief Implementation of the RE01SteppingAction class 28 // 29 // 30 31 #include "RE01SteppingAction.hh" 32 33 #include "RE01RegionInformation.hh" 34 #include "RE01TrackInformation.hh" 35 36 #include "G4LogicalVolume.hh" 37 #include "G4Region.hh" 38 #include "G4Step.hh" 39 #include "G4StepPoint.hh" 40 #include "G4SteppingManager.hh" 41 #include "G4Track.hh" 42 #include "G4TrackStatus.hh" 43 #include "G4VPhysicalVolume.hh" 44 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 RE01SteppingAction::RE01SteppingAction() : G4UserSteppingAction() 47 { 48 ; 49 } 50 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 RE01SteppingAction::~RE01SteppingAction() 53 { 54 ; 55 } 56 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 void RE01SteppingAction::UserSteppingAction(const G4Step* theStep) 59 { 60 // Suspend a track if it is entering into the calorimeter 61 62 // check if it is alive 63 G4Track* theTrack = theStep->GetTrack(); 64 if (theTrack->GetTrackStatus() != fAlive) { 65 return; 66 } 67 68 // get region information 69 G4StepPoint* thePrePoint = theStep->GetPreStepPoint(); 70 G4LogicalVolume* thePreLV = thePrePoint->GetPhysicalVolume()->GetLogicalVolume(); 71 RE01RegionInformation* thePreRInfo = 72 (RE01RegionInformation*)(thePreLV->GetRegion()->GetUserInformation()); 73 G4StepPoint* thePostPoint = theStep->GetPostStepPoint(); 74 G4LogicalVolume* thePostLV = thePostPoint->GetPhysicalVolume()->GetLogicalVolume(); 75 RE01RegionInformation* thePostRInfo = 76 (RE01RegionInformation*)(thePostLV->GetRegion()->GetUserInformation()); 77 78 // check if it is entering to the calorimeter volume 79 if (!(thePreRInfo->IsCalorimeter()) && (thePostRInfo->IsCalorimeter())) { 80 // if the track had already been suspended at the previous step, let it go. 81 RE01TrackInformation* trackInfo = 82 static_cast<RE01TrackInformation*>(theTrack->GetUserInformation()); 83 if (trackInfo->GetSuspendedStepID() > -1) { 84 if (fpSteppingManager->GetverboseLevel() > 0) { 85 G4cout << "++++ This track had already been suspended at step #" 86 << trackInfo->GetSuspendedStepID() << ". Tracking resumed." << G4endl; 87 } 88 } 89 else { 90 trackInfo->SetSuspendedStepID(theTrack->GetCurrentStepNumber()); 91 theTrack->SetTrackStatus(fSuspend); 92 } 93 } 94 } 95