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