Geant4  10.01.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 85244 2014-10-27 08:24:13Z 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"
44 
45 using namespace std;
46 
48  G4ProcessType type) :
49  G4VITRestProcess(processName, type)
50 {
51  // set Process Sub Type
52  SetProcessSubType(59); // DNA sub-type
53  enableAlongStepDoIt = false;
54  enablePostStepDoIt = false;
55  enableAtRestDoIt = true;
56 
57  fVerbose = 0;
58 
59 #ifdef G4VERBOSE
60  if (verboseLevel > 1)
61  {
62  G4cout << "G4MolecularDecayProcess constructor " << " Name:" << processName
63  << G4endl;
64  }
65 #endif
66 
68 
69  fDecayAtFixedTime = true;
70 }
71 
73 {
74  DecayDisplacementMap::iterator it = fDecayDisplacementMap.begin();
75 
76  for (; it != fDecayDisplacementMap.end(); it++)
77  {
78  if (it->second)
79  {
80  delete it->second;
81  it->second = 0;
82  }
83  }
84  fDecayDisplacementMap.clear();
85 }
86 
88  G4VITRestProcess(right)
89 {
92  fVerbose = right.fVerbose;
93 }
94 
96 {
97  if (aParticleType.GetParticleType() == "Molecule")
98  {
99 #ifdef G4VERBOSE
100 
101  if (fVerbose > 1)
102  {
103  G4cout << "G4MolecularDecay::IsApplicable(";
104  G4cout << aParticleType.GetParticleName() << ",";
105  G4cout << aParticleType.GetParticleType() << ")" << G4endl;
106  }
107 #endif
108  return (true);
109  }
110  else
111  {
112  return false;
113  }
114 }
115 
118 {
119  G4double output = GetMolecule(track)->GetDecayTime() - track.GetProperTime();
120  return (output > 0 ? output : 0);
121 }
122 
124  const G4Step&)
125 {
126  // DEBUG
127  // G4cout << "Is calling G4MolecularDecayProcess::DecayIt" << G4endl;
128 
130  const G4Molecule * theMotherMolecule = GetMolecule(track);
131  const G4MoleculeDefinition* moleculeDefinition = theMotherMolecule
132  ->GetDefinition();
133 
134  // DEBUG
135  // G4cout <<"Calling G4MolecularDecayProcess::DecayIt"<<G4endl;
136  // G4cout << "The mother molecule state : " << G4endl;
137  // theMotherMolecule -> PrintState();
138 
139  if (moleculeDefinition->GetDecayTable())
140  {
141  const vector<const G4MolecularDissociationChannel*>* DecayVector =
142  (theMotherMolecule->GetDecayChannel());
143 
144  if (DecayVector == 0)
145  {
146  G4ExceptionDescription exceptionDescription;
147  theMotherMolecule->GetElectronOccupancy()->DumpInfo();
148  exceptionDescription << "No decay channel was found for the molecule : "
149  << theMotherMolecule->GetName() << G4endl;
150  G4Exception("G4DNAMolecularDissociation::DecayIt",
151  "G4DNAMolecularDissociation::NoDecayChannel", FatalException,
152  exceptionDescription);
153  return &aParticleChange;
154  }
155 
156  G4int DecayVectorSize = DecayVector->size();
157  // DEBUG
158  // G4cout<< "Number of decay channels : " << DecayVectorSize<<G4endl;
159  G4double RdmValue = G4UniformRand();
160 
161  const G4MolecularDissociationChannel* decayChannel(0);
162  G4int i = 0;
163  do
164  {
165  decayChannel = (*DecayVector)[i];
166  if (RdmValue < decayChannel->GetProbability()) break;
167  RdmValue -= decayChannel->GetProbability();
168  i++;
169  }
170  while (i < DecayVectorSize);
171 
172  // DEBUG
173  // G4cout<< "Selected Decay channel : " << decayChannel->GetName()<<G4endl;
174 
175  G4double decayEnergy = decayChannel->GetEnergy();
176  G4int nbProducts = decayChannel->GetNbProducts();
177 
178  if (decayEnergy)
179  {
180  // DEBUG
181  // G4cout<<"Deposit energy :" <<decayChannel->GetEnergy()/eV << " eV"<<G4endl;
182 
184  }
185 
186  if (nbProducts)
187  {
188 
189  // DEBUG
190  // G4cout<<"Number of products :" <<nbProducts<<G4endl;
191 
192  vector<G4ThreeVector> ProductsDisplacement(nbProducts);
193  G4ThreeVector theMotherMoleculeDisplacement;
194 
195  DecayDisplacementMap::iterator it = fDecayDisplacementMap.find(
196  moleculeDefinition);
197 
198  if (it != fDecayDisplacementMap.end())
199  {
200  G4VMolecularDecayDisplacer* displacer = it->second;
201  ProductsDisplacement = displacer->GetProductsDisplacement(decayChannel);
202  theMotherMoleculeDisplacement =
203  displacer->GetMotherMoleculeDisplacement(decayChannel);
204  }
205  else
206  {
207  G4ExceptionDescription errMsg;
208  errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
209  << theMotherMolecule->GetName() + "]";
210  G4Exception("G4MolecularDecayProcess::DecayIt", "DNAMolecularDecay001",
211  FatalErrorInArgument, errMsg);
212  }
213 
215 
216 #ifdef G4VERBOSE
217  if (fVerbose)
218  {
219  G4cout << "Decay Process : " << theMotherMolecule->GetName()
220  << " (trackID :" << track.GetTrackID() << ") "
221  << decayChannel->GetName() << G4endl;
222  }
223 #endif
224 
225  for (G4int j = 0; j < nbProducts; j++)
226  {
227  G4Molecule* product = new G4Molecule(*decayChannel->GetProduct(j));
228 
229  // create a new track object
230  // Be carefull as this processes is dedicated to be used in the DNA module
231  // The molecular decay will happen one picosecond after the start of the simulation.
232  // This may be seen as a bug and will be hopefully improve in the next releases
233  G4Track* secondary = product->BuildTrack(
234  picosecond,
235  track.GetPosition() + theMotherMoleculeDisplacement
236  + ProductsDisplacement[j]);
237 
238  secondary->SetTrackStatus(fAlive);
239 #ifdef G4VERBOSE
240  if (fVerbose)
241  {
242  G4cout << "Product : " << product->GetName() << G4endl;
243  }
244 #endif
245  // add the secondary track in the List
246  aParticleChange.G4VParticleChange::AddSecondary(secondary);
247  }
248 #ifdef G4VERBOSE
249  if (fVerbose) G4cout << "-------------" << G4endl;
250 #endif
251  }
252  //DEBUG
253  else if(fVerbose && decayEnergy)
254  {
255  G4cout << "No products for this channel" << G4endl;
256  G4cout<<"-------------"<<G4endl;
257  }
258  else if(!decayEnergy && !nbProducts)
259  {
260  G4ExceptionDescription errMsg;
261  errMsg << "There is no products and no energy specified in the molecular decay channel";
262  G4Exception("G4MolecularDecayProcess::DecayIt","DNAMolecularDecay002",FatalErrorInArgument, errMsg);
263  }
264  }
265 
267 
268  return &aParticleChange;
269 }
270 
272  G4VMolecularDecayDisplacer* aDisplacer)
273 {
274  fDecayDisplacementMap[molDef] = aDisplacer;
275 }
276 
278 {
279  return fDecayDisplacementMap[molDef];
280 }
void SetTrackStatus(const G4TrackStatus aTrackStatus)
virtual G4double GetMeanLifeTime(const G4Track &, G4ForceCondition *)
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannel() const
Definition: G4Molecule.cc:400
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
Identical to G4VRestProcess with dependency from G4VITProcess.
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:303
#define G4UniformRand()
Definition: Randomize.hh:93
G4GLOB_DLL std::ostream G4cout
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
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:67
const G4MoleculeDefinition * GetDefinition() const
Get molecule definition.
Definition: G4Molecule.cc:455
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:328
virtual void Initialize(const G4Track &)
void SetNumberOfSecondaries(G4int totSecondaries)
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:283
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
#define G4endl
Definition: G4ios.hh:61
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:351
const G4Molecule * GetProduct(int) const
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:93
static const double picosecond
Definition: G4SIunits.hh:142
void SetDecayDisplacer(const G4ParticleDefinition *, G4VMolecularDecayDisplacer *)
virtual G4ThreeVector GetMotherMoleculeDisplacement(const G4MolecularDissociationChannel *) const =0
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)
const G4ElectronOccupancy * GetElectronOccupancy() const
Returns the object ElectronOccupancy describing the electronic configuration of the molecule...
Definition: G4Molecule.cc:450
G4ForceCondition
G4double GetDecayTime() const
Returns the decay time of the molecule.
Definition: G4Molecule.cc:420
const G4MolecularDissociationTable * GetDecayTable() const
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4ProcessType