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/StackingActio << 26 // $Id: StackingAction.cc,v 1.2 2007/03/02 11:08:41 maire Exp $ 27 /// \brief Implementation of the StackingActio << 27 // GEANT4 tag $Name: geant4-08-03-patch-02 $ 28 // << 29 // 28 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 31 33 #include "StackingAction.hh" 32 #include "StackingAction.hh" 34 33 35 #include "DetectorConstruction.hh" 34 #include "DetectorConstruction.hh" 36 #include "HistoManager.hh" << 37 #include "Run.hh" << 38 #include "RunAction.hh" 35 #include "RunAction.hh" >> 36 #include "HistoManager.hh" 39 #include "StackingMessenger.hh" 37 #include "StackingMessenger.hh" 40 38 41 #include "G4EmCalculator.hh" << 42 #include "G4RunManager.hh" << 43 #include "G4Track.hh" 39 #include "G4Track.hh" >> 40 #include "G4EmCalculator.hh" 44 41 45 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 43 47 StackingAction::StackingAction(DetectorConstru << 44 StackingAction::StackingAction(DetectorConstruction* det, RunAction* run, >> 45 HistoManager* histo) >> 46 :detector(det),runAction(run),histoManager(histo) 48 { 47 { 49 fMatWall = 0; << 48 matWall = 0; 50 fZcav = 0.; << 49 Zcav = 0.; 51 fEmCal = 0; << 50 emCal = 0; 52 first = true; 51 first = true; 53 fKillTrack = true; << 52 killTrack = true; 54 << 53 55 // create a messenger for this class << 54 //create a messenger for this class 56 fStackMessenger = new StackingMessenger(this << 55 stackMessenger = new StackingMessenger(this); 57 } 56 } 58 57 59 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 60 59 61 StackingAction::~StackingAction() 60 StackingAction::~StackingAction() 62 { 61 { 63 delete fEmCal; << 62 delete emCal; 64 delete fStackMessenger; << 63 delete stackMessenger; 65 } 64 } 66 65 67 //....oooOO0OOooo........oooOO0OOooo........oo 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 67 69 G4ClassificationOfNewTrack StackingAction::Cla << 68 G4ClassificationOfNewTrack >> 69 StackingAction::ClassifyNewTrack(const G4Track* track) 70 { 70 { 71 // get fDetector informations << 71 //get detector informations 72 if (first) { << 72 if (first) { 73 fMatWall = fDetector->GetWallMaterial(); << 73 matWall = detector->GetWallMaterial(); 74 fZcav = 0.5 * (fDetector->GetCavityThickne << 74 Zcav = 0.5*(detector->GetCavityThickness()); 75 fEmCal = new G4EmCalculator(); << 75 emCal = new G4EmCalculator(); 76 first = false; << 76 first = false; 77 } << 77 } 78 << 78 79 G4ClassificationOfNewTrack status = fUrgent; << 79 G4ClassificationOfNewTrack status = fUrgent; 80 << 80 81 // keep primary particle or neutral << 81 //keep primary particle or neutral 82 // << 82 // 83 G4ParticleDefinition* particle = track->GetD << 83 G4ParticleDefinition* particle = track->GetDefinition(); 84 G4bool neutral = (particle->GetPDGCharge() = << 84 G4bool neutral = (particle->GetPDGCharge() == 0.); 85 if ((track->GetParentID() == 0) || neutral) << 85 if ((track->GetParentID() == 0) || neutral) return status; 86 << 86 87 Run* run = static_cast<Run*>(G4RunManager::G << 87 //energy spectrum of charged secondaries 88 << 88 // 89 // energy spectrum of charged secondaries << 89 G4double energy = track->GetKineticEnergy(); 90 // << 90 runAction->sumEsecond(energy); 91 G4double energy = track->GetKineticEnergy(); << 91 92 run->SumEsecond(energy); << 92 // kill e- which cannot reach Cavity 93 << 93 // 94 // kill e- which cannot reach Cavity << 94 G4double position = (track->GetPosition()).z(); 95 // << 95 G4double safe = std::abs(position) - Zcav; 96 G4double position = (track->GetPosition()).z << 96 G4double range = emCal->GetRangeFromRestricteDEDX(energy,particle,matWall); 97 G4double safe = std::abs(position) - fZcav; << 97 if (killTrack) { 98 G4double range = fEmCal->GetRangeFromRestric << 98 if (range < 0.8*safe) status = fKill; 99 if (fKillTrack) { << 99 } 100 if (range < 0.8 * safe) status = fKill; << 100 101 } << 101 //histograms 102 << 102 // 103 // histograms << 103 histoManager->FillHisto(1,position); 104 // << 104 histoManager->FillHisto(2,energy); 105 G4AnalysisManager* analysisManager = G4Analy << 105 G4ThreeVector direction = track->GetMomentumDirection(); 106 analysisManager->FillH1(1, position); << 106 histoManager->FillHisto(3,std::acos(direction.z())); 107 analysisManager->FillH1(2, energy); << 107 108 G4ThreeVector direction = track->GetMomentum << 108 return status; 109 analysisManager->FillH1(3, std::acos(directi << 110 << 111 return status; << 112 } 109 } 113 110 114 //....oooOO0OOooo........oooOO0OOooo........oo 111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 115 112