G4ErrorTrackLengthTarget.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: G4ErrorTrackLengthTarget.cc 69766 2013-05-14 14:33:55Z gcosmo $
00027 //
00028 // ------------------------------------------------------------
00029 //      GEANT 4 class implementation file 
00030 // ------------------------------------------------------------
00031 //
00032 
00033 #include "G4ErrorTrackLengthTarget.hh"
00034 
00035 #include "G4ParticleTable.hh"
00036 #include "G4ParticleDefinition.hh"
00037 #include "G4VProcess.hh"
00038 #include "G4ProcessVector.hh"
00039 #include "G4ProcessManager.hh"
00040 
00041 #ifdef G4VERBOSE
00042 #include "G4ErrorPropagatorData.hh" //for verbosity checking
00043 #endif
00044 
00045 //----------------------------------------------------------------------------
00046 G4ErrorTrackLengthTarget::
00047 G4ErrorTrackLengthTarget(const G4double maxTrkLength )
00048   : G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
00049     theMaximumTrackLength( maxTrkLength )
00050 {
00051   theType = G4ErrorTarget_TrkL;
00052 
00053    G4ParticleTable::G4PTblDicIterator* theParticleIterator
00054      = G4ParticleTable::GetParticleTable()->GetIterator();
00055 
00056   // loop over all particles in G4ParticleTable
00057 
00058   theParticleIterator->reset();
00059   while( (*theParticleIterator)() )
00060   {
00061     G4ParticleDefinition* particle = theParticleIterator->value();
00062     G4ProcessManager* pmanager = particle->GetProcessManager();
00063     if (!particle->IsShortLived())
00064     {
00065       // Add transportation process for all particles other than  "shortlived"
00066       if ( pmanager == 0)
00067       {
00068         // Error !! no process manager
00069         G4String particleName = particle->GetParticleName();
00070         G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
00071                     "No process manager", RunMustBeAborted, particleName );
00072       }
00073       else
00074       {
00075         G4ProcessVector* procvec = pmanager->GetProcessList();
00076         size_t isiz = procvec->size();
00077 
00078         for( size_t ii=0; ii < isiz; ii++ )
00079         {
00080           if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
00081           {
00082             pmanager->RemoveProcess( (*procvec)[ii] );
00083           }
00084         }
00085         pmanager ->AddDiscreteProcess(this,4);
00086         isiz = procvec->size();
00087       }
00088     }
00089     else
00090     {
00091       // shortlived particle case
00092     }
00093   }
00094 }
00095 
00096 
00097 //-----------------------------------------------------------------------
00098 G4double G4ErrorTrackLengthTarget::
00099 PostStepGetPhysicalInteractionLength(const G4Track& track, G4double,
00100                                      G4ForceCondition* condition )
00101 {
00102   *condition = NotForced;
00103   return GetMeanFreePath( track, 0., condition );
00104 }
00105 
00106 
00107 //-----------------------------------------------------------------------
00108 G4double G4ErrorTrackLengthTarget::
00109 GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
00110 {
00111 #ifdef G4VERBOSE
00112   if(G4ErrorPropagatorData::verbose() >= 3 )
00113   { 
00114     G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
00115            << theMaximumTrackLength - track.GetTrackLength() << G4endl;
00116   }
00117 #endif
00118 
00119   return theMaximumTrackLength - track.GetTrackLength();
00120 }
00121 
00122 
00123 G4VParticleChange* G4ErrorTrackLengthTarget::
00124 PostStepDoIt(const G4Track& aTrack, const G4Step& )
00125 {
00126   theParticleChange.Initialize(aTrack);
00127   return &theParticleChange;
00128 }
00129 
00130 
00131 //-----------------------------------------------------------------------
00132 void G4ErrorTrackLengthTarget::Dump( const G4String& msg ) const
00133 {
00134   G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
00135          << theMaximumTrackLength << G4endl;
00136 }

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