[819] | 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 | // |
---|
[962] | 26 | // $Id: G4HadronicInteraction.cc,v 1.4 2009/01/24 11:56:27 vnivanch Exp $ |
---|
| 27 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
[819] | 28 | // |
---|
[962] | 29 | // Hadronic Interaction base class |
---|
| 30 | // original by H.P. Wellisch |
---|
| 31 | // modified by J.L. Chuma, TRIUMF, 21-Mar-1997 |
---|
| 32 | // Last modified: 04-Apr-1997 |
---|
| 33 | // reimplemented 1.11.2003 JPW. |
---|
| 34 | // 23-Jan-2009 V.Ivanchenko move constructor and destructor to the body |
---|
| 35 | |
---|
[819] | 36 | #include "G4HadronicInteraction.hh" |
---|
[962] | 37 | #include "G4HadronicInteractionRegistry.hh" |
---|
| 38 | #include "G4HadronicException.hh" |
---|
| 39 | |
---|
| 40 | G4HadronicInteraction::G4HadronicInteraction(const G4String& modelName) : |
---|
| 41 | verboseLevel(0), theMinEnergy(0.0*GeV), theMaxEnergy(25.0*GeV), |
---|
| 42 | isBlocked(false), theModelName(modelName) |
---|
| 43 | { |
---|
| 44 | G4HadronicInteractionRegistry::Instance()->RegisterMe(this); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | G4HadronicInteraction::~G4HadronicInteraction() |
---|
| 48 | { |
---|
| 49 | G4HadronicInteractionRegistry::Instance()->RemoveMe(this); |
---|
| 50 | } |
---|
[819] | 51 | |
---|
[962] | 52 | G4double G4HadronicInteraction::GetMinEnergy( |
---|
[819] | 53 | const G4Material *aMaterial, const G4Element *anElement ) const |
---|
[962] | 54 | { |
---|
| 55 | size_t i; |
---|
| 56 | if( IsBlocked(aMaterial) )return 0.*GeV; |
---|
| 57 | if( IsBlocked(anElement) )return 0.*GeV; |
---|
| 58 | for( i=0; i<theMinEnergyListElements.size(); ++i ) |
---|
[819] | 59 | { |
---|
[962] | 60 | if( anElement == theMinEnergyListElements[i].second ) |
---|
| 61 | return theMinEnergyListElements[i].first; |
---|
[819] | 62 | } |
---|
| 63 | for( i=0; i<theMinEnergyList.size(); ++i ) |
---|
| 64 | { |
---|
[962] | 65 | if( aMaterial == theMinEnergyList[i].second ) |
---|
| 66 | return theMinEnergyList[i].first; |
---|
[819] | 67 | } |
---|
| 68 | if(IsBlocked()) return 0.*GeV; |
---|
| 69 | if( verboseLevel > 0 ) |
---|
| 70 | G4cout << "*** Warning from HadronicInteraction::GetMinEnergy" << G4endl |
---|
| 71 | << " material " << aMaterial->GetName() |
---|
| 72 | << " not found in min energy List" << G4endl; |
---|
| 73 | return theMinEnergy; |
---|
[962] | 74 | } |
---|
[819] | 75 | |
---|
[962] | 76 | void G4HadronicInteraction::SetMinEnergy(G4double anEnergy, |
---|
| 77 | G4Element *anElement ) |
---|
| 78 | { |
---|
| 79 | if( IsBlocked(anElement) ) |
---|
| 80 | G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl |
---|
[819] | 81 | << " The model is not active for the Element " |
---|
| 82 | << anElement->GetName() << "." << G4endl; |
---|
| 83 | |
---|
[962] | 84 | for( size_t i=0; i<theMinEnergyListElements.size(); ++i ) |
---|
[819] | 85 | { |
---|
| 86 | if( anElement == theMinEnergyListElements[i].second ) |
---|
| 87 | { |
---|
| 88 | theMinEnergyListElements[i].first = anEnergy; |
---|
| 89 | return; |
---|
| 90 | } |
---|
| 91 | } |
---|
[962] | 92 | theMinEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement)); |
---|
| 93 | } |
---|
[819] | 94 | |
---|
[962] | 95 | void G4HadronicInteraction::SetMinEnergy(G4double anEnergy, |
---|
| 96 | G4Material *aMaterial ) |
---|
| 97 | { |
---|
| 98 | if( IsBlocked(aMaterial) ) |
---|
| 99 | G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl |
---|
[819] | 100 | << " The model is not active for the Material " |
---|
| 101 | << aMaterial->GetName() << "." << G4endl; |
---|
| 102 | |
---|
[962] | 103 | for( size_t i=0; i<theMinEnergyList.size(); ++i ) |
---|
[819] | 104 | { |
---|
| 105 | if( aMaterial == theMinEnergyList[i].second ) |
---|
[962] | 106 | { |
---|
| 107 | theMinEnergyList[i].first = anEnergy; |
---|
| 108 | return; |
---|
| 109 | } |
---|
[819] | 110 | } |
---|
[962] | 111 | theMinEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial)); |
---|
| 112 | } |
---|
[819] | 113 | |
---|
[962] | 114 | G4double G4HadronicInteraction::GetMaxEnergy(const G4Material *aMaterial, |
---|
| 115 | const G4Element *anElement ) const |
---|
| 116 | { |
---|
| 117 | size_t i; |
---|
| 118 | if( IsBlocked(aMaterial) )return 0.0*GeV; |
---|
| 119 | if( IsBlocked(anElement) )return 0.0*GeV; |
---|
| 120 | for( i=0; i<theMaxEnergyListElements.size(); ++i ) |
---|
[819] | 121 | { |
---|
[962] | 122 | if( anElement == theMaxEnergyListElements[i].second ) |
---|
| 123 | return theMaxEnergyListElements[i].first; |
---|
[819] | 124 | } |
---|
| 125 | for( i=0; i<theMaxEnergyList.size(); ++i ) |
---|
| 126 | { |
---|
[962] | 127 | if( aMaterial == theMaxEnergyList[i].second ) |
---|
| 128 | return theMaxEnergyList[i].first; |
---|
[819] | 129 | } |
---|
| 130 | if(IsBlocked()) return 0.*GeV; |
---|
| 131 | if( verboseLevel > 0 ) |
---|
| 132 | G4cout << "*** Warning from HadronicInteraction::GetMaxEnergy" << G4endl |
---|
[962] | 133 | << " material " << aMaterial->GetName() |
---|
| 134 | << " not found in min energy List" << G4endl; |
---|
[819] | 135 | |
---|
| 136 | return theMaxEnergy; |
---|
[962] | 137 | } |
---|
[819] | 138 | |
---|
[962] | 139 | void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy, |
---|
| 140 | G4Element *anElement ) |
---|
| 141 | { |
---|
| 142 | if( IsBlocked(anElement) ) |
---|
| 143 | G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl |
---|
[819] | 144 | << "Warning: The model is not active for the Element " |
---|
| 145 | << anElement->GetName() << "." << G4endl; |
---|
| 146 | |
---|
[962] | 147 | for( size_t i=0; i<theMaxEnergyListElements.size(); ++i ) |
---|
[819] | 148 | { |
---|
| 149 | if( anElement == theMaxEnergyListElements[i].second ) |
---|
| 150 | { |
---|
| 151 | theMaxEnergyListElements[i].first = anEnergy; |
---|
| 152 | return; |
---|
| 153 | } |
---|
| 154 | } |
---|
[962] | 155 | theMaxEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement)); |
---|
| 156 | } |
---|
[819] | 157 | |
---|
[962] | 158 | void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy, |
---|
| 159 | G4Material *aMaterial ) |
---|
| 160 | { |
---|
| 161 | if( IsBlocked(aMaterial) ) |
---|
| 162 | G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl |
---|
[819] | 163 | << "Warning: The model is not active for the Material " |
---|
| 164 | << aMaterial->GetName() << "." << G4endl; |
---|
| 165 | |
---|
[962] | 166 | for( size_t i=0; i<theMaxEnergyList.size(); ++i ) |
---|
[819] | 167 | { |
---|
| 168 | if( aMaterial == theMaxEnergyList[i].second ) |
---|
[962] | 169 | { |
---|
[819] | 170 | theMaxEnergyList[i].first = anEnergy; |
---|
| 171 | return; |
---|
[962] | 172 | } |
---|
[819] | 173 | } |
---|
[962] | 174 | theMaxEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial)); |
---|
| 175 | } |
---|
[819] | 176 | |
---|
[962] | 177 | void G4HadronicInteraction::DeActivateFor( G4Material *aMaterial ) |
---|
| 178 | { |
---|
| 179 | theBlockedList.push_back(aMaterial); |
---|
| 180 | } |
---|
[819] | 181 | |
---|
[962] | 182 | void G4HadronicInteraction::DeActivateFor( G4Element *anElement ) |
---|
| 183 | { |
---|
| 184 | theBlockedListElements.push_back(anElement); |
---|
| 185 | } |
---|
[819] | 186 | |
---|
[962] | 187 | G4bool G4HadronicInteraction::IsBlocked( const G4Material *aMaterial ) const |
---|
| 188 | { |
---|
| 189 | for( size_t i=0; i<theBlockedList.size(); ++i ) |
---|
[819] | 190 | { |
---|
| 191 | if( aMaterial == theBlockedList[i] ) |
---|
[962] | 192 | { |
---|
| 193 | return true; |
---|
| 194 | } |
---|
[819] | 195 | } |
---|
[962] | 196 | return false; |
---|
| 197 | } |
---|
[819] | 198 | |
---|
[962] | 199 | G4bool G4HadronicInteraction::IsBlocked( const G4Element *anElement ) const |
---|
| 200 | { |
---|
| 201 | for( size_t i=0; i<theBlockedListElements.size(); ++i ) |
---|
[819] | 202 | { |
---|
| 203 | if( anElement == theBlockedListElements[i] ) |
---|
[962] | 204 | { |
---|
| 205 | return true; |
---|
| 206 | } |
---|
[819] | 207 | } |
---|
[962] | 208 | return false; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | G4HadronicInteraction::G4HadronicInteraction(const G4HadronicInteraction &right ) |
---|
| 212 | { |
---|
| 213 | *this = right; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | const G4HadronicInteraction& |
---|
| 217 | G4HadronicInteraction::operator=(const G4HadronicInteraction &right ) |
---|
| 218 | { |
---|
| 219 | G4String text = "unintended use of G4HadronicInteraction::operator="; |
---|
| 220 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
| 221 | return right; |
---|
| 222 | } |
---|
[819] | 223 | |
---|
[962] | 224 | /* end of file */ |
---|
[819] | 225 | |
---|