G4DNAMolecularDecay.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id: G4DNAMolecularDecay.cc 64057 2012-10-30 15:04:49Z gcosmo $
00027 //
00028 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 
00029 //
00030 // WARNING : This class is released as a prototype.
00031 // It might strongly evolve or even disapear in the next releases.
00032 //
00033 // History:
00034 // -----------
00035 // 10 Oct 2011 M.Karamitros created
00036 //
00037 // -------------------------------------------------------------------
00038 
00039 #include "G4DNAMolecularDecay.hh"
00040 #include "G4SystemOfUnits.hh"
00041 #include "G4Track.hh"
00042 #include "G4Molecule.hh"
00043 #include "G4ITManager.hh"
00044 #include "G4ParticleChange.hh"
00045 
00046 using namespace std;
00047 
00048 G4DNAMolecularDecay::G4DNAMolecularDecay(const G4String& processName,
00049                                          G4ProcessType type) : G4VITRestProcess(processName, type)
00050 {
00051     // set Process Sub Type
00052     SetProcessSubType(59); // DNA sub-type
00053     enableAlongStepDoIt = false;
00054     enablePostStepDoIt = false;
00055     enableAtRestDoIt=true;
00056 
00057     fVerbose = 0 ;
00058 
00059 #ifdef G4VERBOSE
00060     if (verboseLevel>1)
00061     {
00062         G4cout << "G4MolecularDecayProcess constructor " << "  Name:" << processName << G4endl;
00063     }
00064 #endif
00065 
00066     pParticleChange = &aParticleChange;
00067 
00068     fDecayAtFixedTime = true ;
00069 }
00070 
00071 G4DNAMolecularDecay::~G4DNAMolecularDecay()
00072 {
00073     DecayDisplacementMap::iterator it = fDecayDisplacementMap.begin();
00074 
00075     for( ; it != fDecayDisplacementMap.end() ; it++)
00076     {
00077         if(it->second)
00078         {
00079             delete it->second;
00080             it->second = 0;
00081         }
00082     }
00083     fDecayDisplacementMap.clear();
00084 }
00085 
00086 G4DNAMolecularDecay::G4DNAMolecularDecay(const G4DNAMolecularDecay &right) :
00087     G4VITRestProcess(right)
00088 {
00089     fDecayAtFixedTime = right . fDecayAtFixedTime;
00090     fDecayDisplacementMap = right.fDecayDisplacementMap;
00091     fVerbose = right.fVerbose ;
00092 }
00093 
00094 G4bool G4DNAMolecularDecay::IsApplicable(const G4ParticleDefinition& aParticleType)
00095 {
00096     if(aParticleType.GetParticleType()=="Molecule")
00097     {
00098 #ifdef G4VERBOSE
00099         if(fVerbose>1)
00100         {
00101             G4cout<<"G4MolecularDecay::IsApplicable(";
00102             G4cout<<aParticleType.GetParticleName()<<",";
00103             G4cout<<aParticleType.GetParticleType()<<")"<<G4endl;
00104         }
00105 #endif
00106         return(true);
00107     }
00108     else
00109     {
00110         return false;
00111     }
00112 }
00113 
00114 G4double G4DNAMolecularDecay::GetMeanLifeTime(const G4Track& track  ,
00115                                               G4ForceCondition*)
00116 {
00117     G4double output = GetMolecule(track)-> GetDecayTime() - track.GetProperTime() ;
00118     return (output > 0 ? output : 0 );
00119 }
00120 
00121 G4VParticleChange* G4DNAMolecularDecay::DecayIt(
00122     const G4Track& track,
00123     const G4Step& )
00124 {
00125     // DEBUG
00126     //    G4cout << "Is calling G4MolecularDecayProcess::DecayIt" << G4endl;
00127 
00128     aParticleChange.Initialize(track);
00129     const G4Molecule * theMotherMolecule = GetMolecule(track);
00130     const G4MoleculeDefinition* moleculeDefinition = theMotherMolecule->GetDefinition();
00131 
00132     //    DEBUG
00133     //        G4cout <<"Calling G4MolecularDecayProcess::DecayIt"<<G4endl;
00134     //        G4cout << "The mother molecule state : " << G4endl;
00135     //        theMotherMolecule -> PrintState();
00136 
00137     if(moleculeDefinition-> GetDecayTable())
00138     {
00139         const vector<const G4MolecularDecayChannel*>* DecayVector =
00140                 (theMotherMolecule -> GetDecayChannel());
00141 
00142         if(DecayVector == 0)
00143         {
00144             G4ExceptionDescription exceptionDescription;
00145             theMotherMolecule->GetElectronOccupancy()->DumpInfo();
00146             exceptionDescription << "No decay channel was found for the molecule : " << theMotherMolecule-> GetName() << G4endl;
00147             G4Exception("G4DNAMolecularDecay::DecayIt", "G4DNAMolecularDecay::NoDecayChannel",FatalException,exceptionDescription);
00148             return &aParticleChange;
00149         }
00150 
00151         G4int DecayVectorSize = DecayVector-> size();
00152         //        DEBUG
00153         //            G4cout<< "Number of decay channels : " << DecayVectorSize<<G4endl;
00154         G4double RdmValue = G4UniformRand();
00155 
00156         const G4MolecularDecayChannel* decayChannel(0);
00157         G4int i=0;
00158         do
00159         {
00160             decayChannel = (*DecayVector)[i];
00161             if(RdmValue < decayChannel->GetProbability()) break;
00162             RdmValue -= decayChannel->GetProbability();
00163             i++;
00164         }
00165         while(i< DecayVectorSize);
00166 
00167         //        DEBUG
00168         //            G4cout<< "Selected Decay channel : " << decayChannel->GetName()<<G4endl;
00169 
00170         G4double decayEnergy = decayChannel->GetEnergy();
00171         G4int nbProducts = decayChannel->GetNbProducts();
00172 
00173         if(decayEnergy)
00174         {
00175             //            DEBUG
00176             //                G4cout<<"Deposit energy :" <<decayChannel->GetEnergy()/eV << " eV"<<G4endl;
00177 
00178             aParticleChange.ProposeLocalEnergyDeposit(decayChannel->GetEnergy());
00179         }
00180 
00181         if(nbProducts)
00182         {
00183 
00184             //            DEBUG
00185             //                G4cout<<"Number of products :" <<nbProducts<<G4endl;
00186 
00187             vector<G4ThreeVector> ProductsDisplacement(nbProducts);
00188             G4ThreeVector theMotherMoleculeDisplacement;
00189 
00190             DecayDisplacementMap::iterator it = fDecayDisplacementMap.find(moleculeDefinition);
00191 
00192             if(it!=fDecayDisplacementMap.end())
00193             {
00194                 G4VMolecularDecayDisplacer* displacer = it->second;
00195                 ProductsDisplacement = displacer->GetProductsDisplacement(decayChannel);
00196                 theMotherMoleculeDisplacement = displacer-> GetMotherMoleculeDisplacement(decayChannel);
00197             }
00198             else
00199             {
00200                 G4ExceptionDescription errMsg;
00201                 errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
00202                        << theMotherMolecule->GetName() +"]" ;
00203                 G4Exception("G4MolecularDecayProcess::DecayIt","DNAMolecularDecay001",FatalErrorInArgument, errMsg);
00204             }
00205 
00206             aParticleChange.SetNumberOfSecondaries(nbProducts);
00207 
00208 #ifdef G4VERBOSE
00209             if(fVerbose)
00210             {
00211                 G4cout<<"Decay Process : "
00212                      << theMotherMolecule->GetName()
00213                      << " (trackID :" << track.GetTrackID() << ") "
00214                      << decayChannel->GetName()
00215                      << G4endl;
00216             }
00217 #endif
00218 
00219             for (G4int j=0; j<nbProducts ; j++)
00220             {
00221                 G4Molecule* product = new G4Molecule(*decayChannel->GetProduct(j));
00222 
00223                 // create a new track object
00224                 // Be carefull as this processes is dedicated to be used in the DNA module
00225                 // The molecular decay will happen one picosecond after the start of the simulation.
00226                 // This may be seen as a bug and will be hopefully improve in the next releases
00227                 G4Track* secondary = product->BuildTrack(picosecond,track.GetPosition()
00228                                                          + theMotherMoleculeDisplacement + ProductsDisplacement[j]);
00229 
00230                 secondary-> SetTrackStatus(fAlive);
00231 #ifdef G4VERBOSE
00232                 if(fVerbose)
00233                 {
00234                     G4cout<<"Product : "<< product->GetName()<<G4endl;
00235                 }
00236 #endif
00237                 // add the secondary track in the List
00238                 aParticleChange.G4VParticleChange::AddSecondary(secondary);
00239                 G4ITManager<G4Molecule>::Instance()->Push(secondary);
00240             }
00241 #ifdef G4VERBOSE
00242             if(fVerbose)
00243                 G4cout<<"-------------"<<G4endl;
00244 #endif
00245         }
00246         //        DEBUG
00247         //        else if(decayEnergy)
00248         //        {
00249         //            G4cout << "No products for this channel" << G4endl ;
00250         //            G4cout<<"-------------"<<G4endl;
00251         //        }
00252         else if(!decayEnergy && !nbProducts)
00253         {
00254             G4ExceptionDescription errMsg;
00255             errMsg << "There is no products and no energy specified in the molecular decay channel";
00256             G4Exception("G4MolecularDecayProcess::DecayIt","DNAMolecularDecay002",FatalErrorInArgument, errMsg);
00257         }
00258     }
00259 
00260     aParticleChange.ProposeTrackStatus(fStopAndKill);
00261 
00262     return &aParticleChange;
00263 }
00264 
00265 void G4DNAMolecularDecay::SetDecayDisplacer (const G4ParticleDefinition* molDef, G4VMolecularDecayDisplacer* aDisplacer)
00266 {
00267     fDecayDisplacementMap[molDef] = aDisplacer;
00268 }
00269 
00270 G4VMolecularDecayDisplacer* G4DNAMolecularDecay::GetDecayDisplacer(const G4ParticleDefinition* molDef)
00271 {
00272     return fDecayDisplacementMap[molDef] ;
00273 }

Generated on Mon May 27 17:48:03 2013 for Geant4 by  doxygen 1.4.7