source: trunk/source/processes/hadronic/models/management/src/G4HadronicInteraction.cc @ 962

Last change on this file since 962 was 962, checked in by garnier, 15 years ago

update processes

File size: 7.5 KB
Line 
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: G4HadronicInteraction.cc,v 1.4 2009/01/24 11:56:27 vnivanch Exp $
27// GEANT4 tag $Name: geant4-09-02-ref-02 $
28//
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
36#include "G4HadronicInteraction.hh"
37#include "G4HadronicInteractionRegistry.hh"
38#include "G4HadronicException.hh"
39
40G4HadronicInteraction::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   
47G4HadronicInteraction::~G4HadronicInteraction()
48{
49  G4HadronicInteractionRegistry::Instance()->RemoveMe(this);
50}
51 
52G4double G4HadronicInteraction::GetMinEnergy(
53   const G4Material *aMaterial, const G4Element *anElement ) const
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 )
59    {
60      if( anElement == theMinEnergyListElements[i].second )
61        return theMinEnergyListElements[i].first;
62    }
63    for( i=0; i<theMinEnergyList.size(); ++i )
64    {
65      if( aMaterial == theMinEnergyList[i].second )
66        return theMinEnergyList[i].first;
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;
74}
75 
76void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
77                                         G4Element *anElement )
78{
79  if( IsBlocked(anElement) )
80    G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
81           << "    The model is not active for the Element  "
82           << anElement->GetName() << "." << G4endl;
83   
84  for( size_t i=0; i<theMinEnergyListElements.size(); ++i )
85    {
86      if( anElement == theMinEnergyListElements[i].second )
87      {
88        theMinEnergyListElements[i].first = anEnergy;
89        return;
90      }
91    }
92  theMinEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement));
93}
94 
95void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
96                                         G4Material *aMaterial )
97{
98  if( IsBlocked(aMaterial) )
99    G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
100           << "    The model is not active for the Material "
101           << aMaterial->GetName() << "." << G4endl;
102   
103  for( size_t i=0; i<theMinEnergyList.size(); ++i )
104    {
105      if( aMaterial == theMinEnergyList[i].second )
106        {
107          theMinEnergyList[i].first = anEnergy;
108          return;
109        }
110    }
111  theMinEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial));
112}
113 
114G4double 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 )
121    {
122      if( anElement == theMaxEnergyListElements[i].second )
123        return theMaxEnergyListElements[i].first;
124    }
125    for( i=0; i<theMaxEnergyList.size(); ++i )
126    {
127      if( aMaterial == theMaxEnergyList[i].second )
128        return theMaxEnergyList[i].first;
129    }
130    if(IsBlocked()) return 0.*GeV;
131    if( verboseLevel > 0 )
132      G4cout << "*** Warning from HadronicInteraction::GetMaxEnergy" << G4endl
133             << "    material " << aMaterial->GetName()
134             << " not found in min energy List" << G4endl;
135   
136    return theMaxEnergy;
137}
138 
139void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
140                                         G4Element *anElement ) 
141{
142  if( IsBlocked(anElement) )
143    G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
144           << "Warning: The model is not active for the Element  "
145           << anElement->GetName() << "." << G4endl;
146   
147  for( size_t i=0; i<theMaxEnergyListElements.size(); ++i )
148    {
149      if( anElement == theMaxEnergyListElements[i].second )
150      {
151        theMaxEnergyListElements[i].first = anEnergy;
152        return;
153      }
154    }
155  theMaxEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement));
156}
157
158void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
159                                         G4Material *aMaterial )
160{
161  if( IsBlocked(aMaterial) ) 
162    G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
163           << "Warning: The model is not active for the Material "
164           << aMaterial->GetName() << "." << G4endl;
165   
166  for( size_t i=0; i<theMaxEnergyList.size(); ++i )
167    {
168      if( aMaterial == theMaxEnergyList[i].second )
169        {
170        theMaxEnergyList[i].first = anEnergy;
171        return;
172        }
173    }
174  theMaxEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial));
175}
176
177void G4HadronicInteraction::DeActivateFor( G4Material *aMaterial )
178{
179  theBlockedList.push_back(aMaterial);
180}
181
182void G4HadronicInteraction::DeActivateFor( G4Element *anElement )
183{
184  theBlockedListElements.push_back(anElement);
185}
186
187G4bool G4HadronicInteraction::IsBlocked( const G4Material *aMaterial ) const
188{
189  for( size_t i=0; i<theBlockedList.size(); ++i )
190    {
191      if( aMaterial == theBlockedList[i] )
192        {
193          return true;
194        }
195    }
196  return false;
197}
198 
199G4bool G4HadronicInteraction::IsBlocked( const G4Element *anElement ) const
200{
201  for( size_t i=0; i<theBlockedListElements.size(); ++i )
202    {
203      if( anElement == theBlockedListElements[i] )
204        {
205          return true;
206        }
207    }
208  return false;
209}
210
211G4HadronicInteraction::G4HadronicInteraction(const G4HadronicInteraction &right )
212{ 
213  *this = right; 
214}
215   
216const G4HadronicInteraction& 
217G4HadronicInteraction::operator=(const G4HadronicInteraction &right )
218{ 
219  G4String text = "unintended use of G4HadronicInteraction::operator=";
220  throw G4HadronicException(__FILE__, __LINE__, text); 
221  return right;
222}
223 
224/* end of file */
225 
Note: See TracBrowser for help on using the repository browser.