G4HadFinalState.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // Modifications:
00027 // 20110810  M. Kelsey -- Store secondaries by value, not by pointer.
00028 //              Improve constness of argument passing.  Fix up some
00029 //              functions to avoid creating temporaries.
00030 
00031 #include "G4HadFinalState.hh"
00032 #include "G4HadronicException.hh"
00033 
00034 
00035 G4HadFinalState::G4HadFinalState()
00036   : theDirection(0,0,1), theEnergy(-1), theStat(isAlive), 
00037     theW(1.), theEDep(0.) {}
00038 
00039 
00040 G4int G4HadFinalState::GetNumberOfSecondaries() const {return theSecs.size();}
00041 
00042 void G4HadFinalState::SetEnergyChange(G4double anEnergy) 
00043 {
00044   theEnergy=anEnergy;
00045   if(theEnergy<0) 
00046     {
00047       std::cout << "Final state energy was: E = "<<theEnergy<<G4endl;
00048       throw G4HadronicException(__FILE__, __LINE__, "G4HadFinalState: fatal - negative energy");
00049     }
00050 }
00051 
00052 G4double G4HadFinalState::GetEnergyChange() const {return theEnergy;}
00053 
00054 void G4HadFinalState::SetMomentumChange(const G4ThreeVector& aV) {
00055   theDirection=aV;
00056 }
00057 
00058 void G4HadFinalState::SetMomentumChange(G4double x, G4double y, G4double z) 
00059 {
00060   theDirection.set(x,y,z);
00061   if(std::fabs(theDirection.mag()-1)>0.001) 
00062     {
00063       G4cout <<"We have negative theDirection.mag() = "<<theDirection.mag()<<G4endl;
00064       throw G4HadronicException(__FILE__, __LINE__, "G4HadFinalState: fatal - negative direction.mag().");
00065     }
00066 }
00067 
00068 const G4ThreeVector& G4HadFinalState::GetMomentumChange() const {return theDirection;}
00069 
00070 void G4HadFinalState::AddSecondary(G4DynamicParticle *aP) {
00071   // NOTE:  In-situ constructor will be optimized away (no copying)
00072   if (aP) theSecs.push_back(G4HadSecondary(aP));
00073 }
00074 
00075 // Concatenate lists efficiently
00076 void G4HadFinalState::AddSecondaries(const std::vector<G4HadSecondary>& addSecs)
00077 {
00078   theSecs.insert(theSecs.end(),addSecs.begin(),addSecs.end());
00079 }
00080 
00081 void G4HadFinalState::SetStatusChange(G4HadFinalStateStatus aS){theStat=aS;}
00082 
00083 G4HadFinalStateStatus G4HadFinalState::GetStatusChange() const {return theStat;}
00084 
00085 void G4HadFinalState::ClearSecondaries() { 
00086   theSecs.clear();
00087 }
00088 
00089 void G4HadFinalState::Clear()
00090 {
00091   theDirection.set(0,0,1);
00092   theEnergy = -1;
00093   theStat = isAlive;
00094   theW = 1.;
00095   theEDep = 0.;
00096   ClearSecondaries();
00097 }
00098 
00099 void G4HadFinalState::SecondariesAreStale() { /*DEPRECATED*/ }
00100 
00101 const G4LorentzRotation& G4HadFinalState::GetTrafoToLab() const {return theT;}
00102 
00103 void G4HadFinalState::SetTrafoToLab(const G4LorentzRotation & aT) {theT = aT;}
00104 
00105 void G4HadFinalState::SetWeightChange(G4double aW){ theW=aW;}
00106 
00107 G4double G4HadFinalState::GetWeightChange() const {return theW;}
00108 
00109 G4HadSecondary * G4HadFinalState::GetSecondary(size_t i) 
00110 {
00111   if(i>theSecs.size())
00112     {
00113       throw G4HadronicException(__FILE__, __LINE__, 
00114                                 "Trying direct access to secondary beyond end of list");
00115     }
00116   return &theSecs[i];
00117 }
00118 
00119 const G4HadSecondary* G4HadFinalState::GetSecondary(size_t i) const
00120 {
00121   if(i>theSecs.size())
00122     {
00123       throw G4HadronicException(__FILE__, __LINE__, 
00124                                 "Trying direct access to secondary beyond end of list");
00125     }
00126   return &theSecs[i];
00127 }
00128 
00129 void G4HadFinalState::SetLocalEnergyDeposit(G4double aE) {theEDep=aE;}
00130 
00131 G4double G4HadFinalState::GetLocalEnergyDeposit() const {return theEDep;}

Generated on Mon May 27 17:48:25 2013 for Geant4 by  doxygen 1.4.7