Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4DNASecondOrderReaction.cc
이 파일의 문서화 페이지로 가기
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: G4DNASecondOrderReaction.cc 101790 2016-11-28 15:33:44Z gcosmo $
27 //
29 
30 #include <G4VScheduler.hh>
31 #include "G4SystemOfUnits.hh"
32 #include "G4Molecule.hh"
35 #include "G4DNADamage.hh"
36 #include "G4UnitsTable.hh"
37 #include "G4TrackingInformation.hh"
38 
39 #ifndef State
40 #define State(theXInfo) (GetState<SecondOrderReactionState>()->theXInfo)
41 #endif
42 
44 {
46  enableAtRestDoIt = false;
47  enableAlongStepDoIt = false;
48  enablePostStepDoIt = true;
49 
51 
53  // meaning G4DNASecondOrderReaction contains a class inheriting from G4ProcessState
54 
55  fIsInitialized = false;
57  fpMaterial = 0;
58  fReactionRate = -1.;
59  fConcentration = -1.;
61  fProposesTimeStep = true;
64 
65  verboseLevel = 0;
66 }
67 
69  G4VITProcess(aName,type)
70 {
71  Create();
72 }
73 
75  G4VITProcess(rhs)
76 {
77  Create();
78 }
79 
81 {
82  ;
83 }
85 {
86  if (this == &rhs) return *this; // handle self assignment
87 
88  //assignment operator
89  return *this;
90 }
91 
93 {
95  fIsInGoodMaterial = false;
96 }
97 
99 {
102  fIsInitialized = true;
103 }
104 
105 void
107 {
111 }
112 
113 void
115  const G4Material* mat, double reactionRate)
116 {
117  if(fIsInitialized)
118  {
119  G4ExceptionDescription exceptionDescription ;
120  exceptionDescription << "G4DNASecondOrderReaction was already initialised. ";
121  exceptionDescription << "You cannot set a reaction after initialisation.";
122  G4Exception("G4DNASecondOrderReaction::SetReaction","G4DNASecondOrderReaction001",
123  FatalErrorInArgument,exceptionDescription);
124  }
125  fpMolecularConfiguration = molConf;
126  fpMaterial = mat;
127  fReactionRate = reactionRate;
128 }
129 
131  G4double /*previousStepSize*/,
132  G4ForceCondition* pForceCond)
133 {
134  // G4cout << "G4DNASecondOrderReaction::PostStepGetPhysicalInteractionLength" << G4endl;
135  // G4cout << "For reaction : " << fpMaterial->GetName() << " + " << fpMolecularConfiguration->GetName() << G4endl;
136 
137  //_______________________________________________________________________
138  // Check whether the track is in the good material (maybe composite material)
139  const G4Material* material = track.GetMaterial();
140 
141  G4Molecule* mol = GetMolecule(track);
142  if(!mol) return DBL_MAX;
144  {
145  // G4cout <<"mol->GetMolecularConfiguration() != fpMolecularConfiguration" << G4endl;
146  return DBL_MAX;
147  }
148 
149  G4double molDensity = (*fpMoleculeDensity)[material->GetIndex()];
150 
151  if(molDensity == 0.0) // ie : not found
152  {
153  if(State(fIsInGoodMaterial))
154  {
156  //State(fPreviousTimeAtPreStepPoint) = -1;
157  State(fIsInGoodMaterial) = false;
158  }
159 
160  // G4cout << " Material " << fpMaterial->GetName() << " not found "
161  // <<" | name of current material : " << material->GetName()
162  // << G4endl;
163 
164  return DBL_MAX; // Becareful return here !!
165  }
166 
167  // G4cout << " Va calculer le temps d'interaction " << G4endl;
168 
169  State(fIsInGoodMaterial) = true;
170 
171  // fConcentration = molDensity/fMolarMassOfMaterial;
172  fConcentration = molDensity/CLHEP::Avogadro;
173  // G4cout << "Concentration : " << fConcentration / (g/mole)<< G4endl;
174 
175  //_______________________________________________________________________
176  // Either initialize the lapse of time left
177  // meaning
178  // => the track enters for the first time in the material
179  // or substract the previous time step to the previously calculated lapse
180  // of time left
181  // meaning
182  // => the track has not left this material since the previous call
183  G4double previousTimeStep(-1.);
184 
185  if(State(fPreviousTimeAtPreStepPoint) != -1)
186  {
187  previousTimeStep = track.GetGlobalTime() -
188  State(fPreviousTimeAtPreStepPoint) ;
189  }
190 
191  State(fPreviousTimeAtPreStepPoint) = track.GetGlobalTime();
192 
193  // condition is set to "Not Forced"
194  *pForceCond = NotForced;
195 
196  if (
197  (previousTimeStep < 0.0) ||
198  (fpState->theNumberOfInteractionLengthLeft<=0.0)) {
199  // beggining of tracking (or just after DoIt of this process)
201  } else if ( previousTimeStep > 0.0) {
202  // get mean free path
203  // subtract NumberOfInteractionLengthLeft
204  SubtractNumberOfInteractionLengthLeft( previousTimeStep );
205  } else {
206  // zero time step
207  // Force trigerring the process
208  //*pForceCond = Forced;
209  }
210 
211  fpState->currentInteractionLength = 1/(fReactionRate*fConcentration);
212 
213  // G4cout << "fpState->currentInteractionLength = "
214  // << fpState->currentInteractionLength << G4endl;
215 
216  G4double value;
217  if (fpState->currentInteractionLength <DBL_MAX) {
218  value = fpState->theNumberOfInteractionLengthLeft
219  * (fpState->currentInteractionLength);
220  } else {
221  value = DBL_MAX;
222  }
223 #ifdef G4VERBOSE
224  if (verboseLevel>2) {
225  G4cout << "G4VITRestDiscreteProcess::PostStepGetPhysicalInteractionLength ";
226  G4cout << "[ " << GetProcessName() << "]" <<G4endl;
227  track.GetDynamicParticle()->DumpInfo();
228  G4cout << " in Material " << track.GetMaterial()->GetName() <<G4endl;
229  G4cout << "InteractionLength= " << value/cm <<"[cm] " <<G4endl;
230  }
231 #endif
232 
233 // G4cout << "currentInteractionLength : " << fpState->currentInteractionLength << G4endl;
234 // G4cout << "Material : " << fpMaterial->GetName()
235 // << "ID: " << track.GetTrackID()
236 // << " Returned time : " << G4BestUnit(value,"Time") << G4endl;
237 
238  if(value < fReturnedValue)
240 
241  return value*-1;
242  // multiple by -1 to indicate to the tracking system that we are returning a time
243 }
244 
246 {
247  G4Molecule* molecule = GetMolecule(track);
248 #ifdef G4VERBOSE
249  if(verboseLevel > 1)
250  {
251  G4cout << "___________" << G4endl;
252  G4cout << ">>> Beginning of G4DNASecondOrderReaction verbose" << G4endl;
253  G4cout << ">>> Returned value : " << G4BestUnit(fReturnedValue,"Time") << G4endl;
254  G4cout << ">>> Time Step : " << G4BestUnit(G4VScheduler::Instance()->GetTimeStep(),"Time") << G4endl;
255  G4cout << ">>> Reaction : " << molecule->GetName() << " + " << fpMaterial->GetName() << G4endl;
256  G4cout << ">>> End of G4DNASecondOrderReaction verbose <<<" << G4endl;
257  }
258 #endif
263  State(fPreviousTimeAtPreStepPoint) = -1;
264  return &fParticleChange;
265 }
266 
const std::vector< double > * fpMoleculeDensity
virtual void SubtractNumberOfInteractionLengthLeft(G4double previousStepSize)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4DNASecondOrderReaction(const G4String &aName="DNASecondOrderReaction", G4ProcessType type=fDecay)
void SetReaction(const G4MolecularConfiguration *, const G4Material *, double)
size_t GetIndex() const
Definition: G4Material.hh:262
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
Definition: G4Molecule.cc:360
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
void SetInstantiateProcessState(G4bool flag)
G4shared_ptr< G4ProcessState > fpState
G4bool enablePostStepDoIt
Definition: G4VProcess.hh:352
virtual void ResetNumberOfInteractionLengthLeft()
const std::vector< double > * GetNumMolPerVolTableFor(const G4Material *) const
Retrieve a table of molecular densities (number of molecules per unit volume) in the G4 unit system f...
#define State(theXInfo)
const G4String & GetName() const
Definition: G4Material.hh:179
G4bool enableAtRestDoIt
Definition: G4VProcess.hh:350
const G4MolecularConfiguration * fpMolecularConfiguration
virtual void StartTracking(G4Track *)
Definition: G4VProcess.cc:102
double G4double
Definition: G4Types.hh:76
static constexpr double Avogadro
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:283
const XML_Char int const XML_Char * value
Definition: expat.h:331
virtual void Initialize(const G4Track &)
G4ProcessType
static G4DNAMolecularMaterial * Instance()
static G4VScheduler * Instance()
Definition: G4VScheduler.cc:48
G4DNASecondOrderReaction & operator=(const G4DNASecondOrderReaction &)
G4double GetGlobalTime() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:411
const G4ThreeVector & GetPosition() const
Definition: G4Step.hh:76
Float_t mat
G4Material * GetMaterial() const
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:80
virtual void StartTracking(G4Track *)
Definition: G4VITProcess.cc:86
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4bool fProposesTimeStep
G4int verboseLevel
Definition: G4VProcess.hh:371
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:435
G4ForceCondition
static constexpr double cm
Definition: G4SIunits.hh:119
G4GLOB_DLL std::ostream G4cout
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:351
#define DBL_MAX
Definition: templates.hh:83
void DumpInfo(G4int mode=0) const
void ProposeTrackStatus(G4TrackStatus status)
static G4DNADamage * Instance()
Definition: G4DNADamage.cc:57
const G4DynamicParticle * GetDynamicParticle() const
virtual void AddIndirectDamage(const G4String &baseName, const G4Molecule *molecule, const G4ThreeVector &position, double time)
Definition: G4DNADamage.cc:96
G4double GetMassOfMolecule() const
Definition: G4Material.hh:243
G4MolecularConfiguration * GetMolecularConfiguration() const
Definition: G4Molecule.cc:580