Geant4  10.02.p02
G4DNAMolecularDissociation.cc
Go to the documentation of this file.
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: G4DNAMolecularDissociation.cc 93936 2015-11-04 09:37:59Z gcosmo $
27 //
28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29 //
30 // WARNING : This class is released as a prototype.
31 // It might strongly evolve or even disapear in the next releases.
32 //
33 // History:
34 // -----------
35 // 10 Oct 2011 M.Karamitros created
36 //
37 // -------------------------------------------------------------------
38 
40 #include "G4SystemOfUnits.hh"
41 #include "G4Track.hh"
42 #include "G4Molecule.hh"
43 #include "G4ParticleChange.hh"
45 #include "G4ITNavigator.hh"
46 
47 using namespace std;
48 
49 //______________________________________________________________________________
50 
53  G4ProcessType type) :
54  G4VITRestDiscreteProcess(processName, type)
55 {
56  // set Process Sub Type
57  SetProcessSubType(59); // DNA sub-type
58  enableAlongStepDoIt = false;
59  enablePostStepDoIt = true;
60  enableAtRestDoIt = true;
61 
62  fVerbose = 0;
63 
64 #ifdef G4VERBOSE
65  if(verboseLevel > 1)
66  {
67  G4cout << "G4MolecularDissociationProcess constructor " << " Name:"
68  << processName << G4endl;
69  }
70 #endif
71 
73 
74  fDecayAtFixedTime = true;
75  fProposesTimeStep = true;
76 }
77 
78 //______________________________________________________________________________
79 
81 {
82  DecayDisplacementMap::iterator it = fDecayDisplacementMap.begin();
83 
84  for(; it != fDecayDisplacementMap.end(); it++)
85  {
86  if(it->second)
87  {
88  delete it->second;
89  it->second = 0;
90  }
91  }
92  fDecayDisplacementMap.clear();
93 }
94 
95 //______________________________________________________________________________
96 
100 {
103  fVerbose = right.fVerbose;
104 }
105 
106 //______________________________________________________________________________
107 
109 IsApplicable(const G4ParticleDefinition& aParticleType)
110 {
111  if(aParticleType.GetParticleType() == "Molecule")
112  {
113 #ifdef G4VERBOSE
114 
115  if(fVerbose > 1)
116  {
117  G4cout << "G4MolecularDissociation::IsApplicable(";
118  G4cout << aParticleType.GetParticleName() << ",";
119  G4cout << aParticleType.GetParticleType() << ")" << G4endl;
120  }
121 #endif
122  return (true);
123  }
124  else
125  {
126  return false;
127  }
128 }
129 
130 //______________________________________________________________________________
131 
134 {
135  G4double output = GetMolecule(track)->GetDecayTime() - track.GetProperTime();
136  return (output > 0 ? output : 0);
137 }
138 
139 //______________________________________________________________________________
140 
142  const G4Step&)
143 {
144  // DEBUG
145  // G4cout << "Is calling G4MolecularDecayProcess::DecayIt" << G4endl;
146 
148  const G4Molecule * theMotherMolecule = GetMolecule(track);
149  const G4MoleculeDefinition* moleculeDefinition = theMotherMolecule
150  ->GetDefinition();
151 
152  // DEBUG
153  // G4cout <<"Calling G4MolecularDecayProcess::DecayIt"<<G4endl;
154  // G4cout << "The mother molecule state : " << G4endl;
155  // theMotherMolecule -> PrintState();
156 
157  if(moleculeDefinition->GetDecayTable())
158  {
159  const vector<const G4MolecularDissociationChannel*>* DecayVector =
160  (theMotherMolecule->GetDecayChannel());
161 
162  if(DecayVector == 0)
163  {
164  G4ExceptionDescription exceptionDescription;
165  theMotherMolecule->PrintState();
166  exceptionDescription << "No decay channel was found for the molecule : "
167  << theMotherMolecule->GetName() << G4endl;
168  G4Exception("G4DNAMolecularDissociation::DecayIt",
169  "G4DNAMolecularDissociation::NoDecayChannel",
171  exceptionDescription);
172  return &aParticleChange;
173  }
174 
175  G4int DecayVectorSize = DecayVector->size();
176  // DEBUG
177  // G4cout<< "Number of decay channels : " << DecayVectorSize <<G4endl;
178  G4double RdmValue = G4UniformRand();
179 
180  const G4MolecularDissociationChannel* decayChannel(0);
181  G4int i = 0;
182  do
183  {
184  decayChannel = (*DecayVector)[i];
185  if(RdmValue < decayChannel->GetProbability()) break;
186  RdmValue -= decayChannel->GetProbability();
187  i++;
188  }
189  while(i < DecayVectorSize);
190 
191  // DEBUG
192  // G4cout << "Selected Decay channel : "
193  // << decayChannel->GetName() << G4endl;
194 
195  G4double decayEnergy = decayChannel->GetEnergy();
196  G4int nbProducts = decayChannel->GetNbProducts();
197 
198  if(decayEnergy)
199  {
200  // DEBUG
201  // G4cout << "Deposit energy :"
202  // << decayChannel->GetEnergy()/eV << " eV" << G4endl;
203 
205  }
206 
207  if(nbProducts)
208  {
209 
210  // DEBUG
211  // G4cout << "Number of products :" << nbProducts << G4endl;
212 
213  vector<G4ThreeVector> ProductsDisplacement(nbProducts);
214  G4ThreeVector theMotherMoleculeDisplacement;
215 
216  DecayDisplacementMap::iterator it =
217  fDecayDisplacementMap.find(moleculeDefinition);
218 
219  if(it != fDecayDisplacementMap.end())
220  {
221  G4VMolecularDecayDisplacer* displacer = it->second;
222  ProductsDisplacement = displacer->GetProductsDisplacement(decayChannel);
223  theMotherMoleculeDisplacement =
224  displacer->GetMotherMoleculeDisplacement(decayChannel);
225  }
226  else
227  {
228  G4ExceptionDescription errMsg;
229  errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
230  << theMotherMolecule->GetName() + "]";
231  G4Exception("G4MolecularDecayProcess::DecayIt",
232  "DNAMolecularDecay001",
234  errMsg);
235  }
236 
238 
239 // G4cout << " nbProducts = " << nbProducts << G4endl;
240 // theMotherMolecule->PrintState();
241 
242 #ifdef G4VERBOSE
243  if(fVerbose)
244  {
245  G4cout << "Decay Process : " << theMotherMolecule->GetName()
246  << " (trackID :" << track.GetTrackID() << ") "
247  << decayChannel->GetName() << G4endl;
248  }
249 #endif
250 
251  G4ITNavigator* navigator =
254 
255  for(G4int j = 0; j < nbProducts; j++)
256  {
257  G4Molecule* product = new G4Molecule(decayChannel->GetProduct(j));
258 
259  G4ThreeVector displacement = theMotherMoleculeDisplacement
260  + ProductsDisplacement[j];
261  double mag_displacement = displacement.mag();
262  G4ThreeVector displacement_direction = displacement / mag_displacement;
263 
264  double prNewSafety = DBL_MAX;
265 
266  navigator->CheckNextStep(track.GetPosition(),
267  displacement_direction,
268  mag_displacement,
269  prNewSafety); // returns a value
270 
271  if(prNewSafety < mag_displacement) mag_displacement = prNewSafety;
272 
273 // const G4AffineTransform& transform = navigator
274 // ->GetGlobalToLocalTransform();
275 //
276 // G4ThreeVector localPoint =
277 // transform.TransformPoint(track.GetPosition());
278 //
279 // if(track.GetTouchable()->GetSolid()->Inside(localPoint) != EInside::kInside)
280 // {
281 // G4Exception("G4DNAMolecularDissociation::DecayIt",
282 // "OUTSIDE_OF_MOTHER_VOLUME",
283 // FatalException,
284 // "Product has been placed outside of the volume "
285 // "containing the mother molecule");
286 // }
287 
288  G4Track* secondary =
289  product->BuildTrack(track.GetGlobalTime(),
290  track.GetPosition() + displacement_direction
291  * mag_displacement);
292 
293  secondary->SetTrackStatus(fAlive);
294 #ifdef G4VERBOSE
295  if(fVerbose)
296  {
297  G4cout << "Product : " << product->GetName() << G4endl;
298  }
299 #endif
300  // add the secondary track in the List
301  aParticleChange.G4VParticleChange::AddSecondary(secondary);
302  }
303 #ifdef G4VERBOSE
304  if(fVerbose) G4cout << "-------------" << G4endl;
305 #endif
306  }
307  //DEBUG
308  else if(fVerbose && decayEnergy)
309  {
310  G4cout << "No products for this channel" << G4endl;
311  G4cout<<"-------------"<<G4endl;
312  }
313  /*
314  else if(!decayEnergy && !nbProducts)
315  {
316  G4ExceptionDescription errMsg;
317  errMsg << "There is no products and no energy specified in the molecular "
318  "dissociation channel";
319  G4Exception("G4MolecularDissociationProcess::DecayIt",
320  "DNAMolecularDissociation002",
321  FatalErrorInArgument,
322  errMsg);
323  }
324  */
325  }
326 
328 
329  return &aParticleChange;
330 }
331 
332 //______________________________________________________________________________
333 
336  G4VMolecularDecayDisplacer* aDisplacer)
337 {
338  fDecayDisplacementMap[molDef] = aDisplacer;
339 }
340 
341 //______________________________________________________________________________
342 
346 {
347  return fDecayDisplacementMap[molDef];
348 }
349 
350 //______________________________________________________________________________
351 
354  G4double,
356 {
357  return 0; //-1*(-log(1-G4UniformRand())*100*1e-15*s);
358 }
void SetTrackStatus(const G4TrackStatus aTrackStatus)
virtual G4double GetMeanLifeTime(const G4Track &, G4ForceCondition *)
Identical to G4VRestDiscreteProcess with dependency from G4VITProcess.
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:458
G4int verboseLevel
Definition: G4VProcess.hh:368
G4VMolecularDecayDisplacer * GetDecayDisplacer(const G4ParticleDefinition *)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetProperTime() const
CLHEP::Hep3Vector G4ThreeVector
const G4ThreeVector & GetPosition() const
G4bool enableAtRestDoIt
Definition: G4VProcess.hh:350
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:345
static G4ITTransportationManager * GetTransportationManager()
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
G4MolecularConfiguration * GetProduct(int) const
bool G4bool
Definition: G4Types.hh:79
virtual G4VParticleChange * DecayIt(const G4Track &, const G4Step &)
virtual std::vector< G4ThreeVector > GetProductsDisplacement(const G4MolecularDissociationChannel *) const =0
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:432
const G4String & GetParticleType() const
Definition: G4Step.hh:76
G4bool enablePostStepDoIt
Definition: G4VProcess.hh:352
G4int GetTrackID() const
G4double GetGlobalTime() const
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:69
const G4MoleculeDefinition * GetDefinition() const
Get molecule definition.
Definition: G4Molecule.cc:535
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:380
virtual void Initialize(const G4Track &)
void SetNumberOfSecondaries(G4int totSecondaries)
G4ITNavigator * GetNavigatorForTracking() const
void PrintState() const
Show the electronic state of the molecule.
Definition: G4Molecule.cc:373
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:283
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
G4bool fProposesTimeStep
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
#define G4endl
Definition: G4ios.hh:61
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:351
G4DNAMolecularDissociation should be called only for molecules.
Class Description The dynamic molecule holds all the data that change for a molecule It has a pointer...
Definition: G4Molecule.hh:94
void SetDecayDisplacer(const G4ParticleDefinition *, G4VMolecularDecayDisplacer *)
virtual G4ThreeVector GetMotherMoleculeDisplacement(const G4MolecularDissociationChannel *) const =0
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)
G4ForceCondition
G4double GetDecayTime() const
Returns the decay time of the molecule.
Definition: G4Molecule.cc:486
#define DBL_MAX
Definition: templates.hh:83
const G4MolecularDissociationTable * GetDecayTable() const
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4ProcessType