Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 101354 2016-11-15 08:27:51Z 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 
51 G4DNAMolecularDissociation::
52 G4DNAMolecularDissociation(const G4String& processName,
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  DisplacementMap::iterator it = fDisplacementMap.begin();
83 
84  for(; it != fDisplacementMap.end(); it++)
85  {
86  if(it->second)
87  {
88  delete it->second;
89  it->second = 0;
90  }
91  }
92  fDisplacementMap.clear();
93 }
94 
95 //______________________________________________________________________________
96 
97 G4DNAMolecularDissociation::
98 G4DNAMolecularDissociation(const G4DNAMolecularDissociation &right) :
100 {
101  fDecayAtFixedTime = right.fDecayAtFixedTime;
102  fDisplacementMap = right.fDisplacementMap;
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  DisplacementMap::iterator it =
217  fDisplacementMap.find(moleculeDefinition);
218 
219  if(it != fDisplacementMap.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 =
263  displacement/(mag_displacement+1e-30);
264 
265  double prNewSafety = DBL_MAX;
266 
267  //double step =
268  navigator->CheckNextStep(track.GetPosition(),
269  displacement_direction,
270  mag_displacement,
271  prNewSafety);
272 
273  //if(prNewSafety < mag_displacement || step < mag_displacement)
274  mag_displacement = min(prNewSafety*0.8, mag_displacement);
275 
276  G4ThreeVector product_pos = track.GetPosition()
277  + displacement_direction * mag_displacement;
278 
279  const G4AffineTransform& transform = navigator
280  ->GetGlobalToLocalTransform();
281 
282  G4ThreeVector localPoint =
283  transform.TransformPoint(product_pos); //track.GetPosition());
284 
285  if(track.GetTouchable()->GetSolid()->Inside(localPoint) !=
287  {
288  G4cout << "Mother volume: "
289  << track.GetTouchable()->GetVolume()->GetName()
290  << G4endl;
291  G4Exception("G4DNAMolecularDissociation::DecayIt",
292  "OUTSIDE_OF_MOTHER_VOLUME",
294  "Product has been placed outside of the volume "
295  "containing the mother molecule");
296  }
297 
298  G4Track* secondary =
299  product->BuildTrack(track.GetGlobalTime(),
300  product_pos);
301 
302  secondary->SetTrackStatus(fAlive);
303 #ifdef G4VERBOSE
304  if(fVerbose)
305  {
306  G4cout << "Product : " << product->GetName() << G4endl;
307  }
308 #endif
309  // add the secondary track in the List
310  aParticleChange.G4VParticleChange::AddSecondary(secondary);
311  }
312 #ifdef G4VERBOSE
313  if(fVerbose) G4cout << "-------------" << G4endl;
314 #endif
315  }
316  //DEBUG
317  else if(fVerbose && decayEnergy)
318  {
319  G4cout << "No products for this channel" << G4endl;
320  G4cout<<"-------------"<<G4endl;
321  }
322  /*
323  else if(!decayEnergy && !nbProducts)
324  {
325  G4ExceptionDescription errMsg;
326  errMsg << "There is no products and no energy specified in the molecular "
327  "dissociation channel";
328  G4Exception("G4MolecularDissociationProcess::DecayIt",
329  "DNAMolecularDissociation002",
330  FatalErrorInArgument,
331  errMsg);
332  }
333  */
334  }
335 
337 
338  return &aParticleChange;
339 }
340 
341 //______________________________________________________________________________
342 
345  G4VMolecularDecayDisplacer* aDisplacer)
346 {
347  fDisplacementMap[molDef] = aDisplacer;
348 }
349 
350 //______________________________________________________________________________
351 
355 {
356  return fDisplacementMap[molDef];
357 }
358 
359 //______________________________________________________________________________
360 
363  G4VMolecularDecayDisplacer* aDisplacer)
364 {
365  fDisplacementMap[molDef] = aDisplacer;
366 }
367 
368 //______________________________________________________________________________
369 
373 {
374  return fDisplacementMap[molDef];
375 }
376 
377 //______________________________________________________________________________
378 
381  G4double,
383 {
384  return 0; //-1*(-log(1-G4UniformRand())*100*1e-15*s);
385 }
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:469
G4int verboseLevel
Definition: G4VProcess.hh:368
G4VMolecularDecayDisplacer * GetDecayDisplacer(const G4ParticleDefinition *)
G4VMolecularDecayDisplacer * GetDisplacer(const G4ParticleDefinition *)
virtual G4VSolid * GetSolid(G4int depth=0) const
Definition: G4VTouchable.cc:51
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetProperTime() const
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
Definition: G4Molecule.cc:356
static G4ITTransportationManager * GetTransportationManager()
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
void SetDisplacer(const G4ParticleDefinition *, G4VMolecularDecayDisplacer *)
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
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
tuple navigator
Definition: write_gdml.py:35
G4int GetTrackID() const
G4double GetGlobalTime() const
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:76
const G4MoleculeDefinition * GetDefinition() const
Definition: G4Molecule.cc:546
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:391
virtual void Initialize(const G4Track &)
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
void SetNumberOfSecondaries(G4int totSecondaries)
const G4VTouchable * GetTouchable() const
G4ITNavigator * GetNavigatorForTracking() const
void PrintState() const
Definition: G4Molecule.cc:384
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:283
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4bool fProposesTimeStep
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
#define G4endl
Definition: G4ios.hh:61
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:351
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
Definition: G4Molecule.cc:497
double mag() const
#define DBL_MAX
Definition: templates.hh:83
const G4MolecularDissociationTable * GetDecayTable() const
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4ProcessType