G4AdjointSteppingAction.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: G4AdjointSteppingAction.cc 67009 2013-01-29 16:00:21Z gcosmo $
00027 //
00029 //      Class Name:     G4AdjointSteppingAction
00030 //      Author:         L. Desorgher
00031 //      Organisation:   SpaceIT GmbH
00032 //      Contract:       ESA contract 21435/08/NL/AT
00033 //      Customer:       ESA/ESTEC
00035 
00036 #include "G4AdjointSteppingAction.hh"
00037 #include "G4Track.hh"
00038 #include "G4PhysicalVolumeStore.hh"
00039 #include "G4AffineTransform.hh"
00040 #include "G4AdjointCrossSurfChecker.hh"
00042 //
00043 G4AdjointSteppingAction::G4AdjointSteppingAction()
00044   : ext_sourceEMax(0.), start_event(false),
00045     did_adj_part_reach_ext_source(false), last_ekin(0.), last_weight(0.),
00046     prim_weight(0.), last_part_def(0), theUserAdjointSteppingAction(0)
00047 { 
00048   theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
00049 }
00051 //
00052 G4AdjointSteppingAction::~G4AdjointSteppingAction()
00053 {;}
00054 
00056 //
00057 void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
00058 {
00059   //Apply first the user adjoint stepping action
00060   //---------------------------
00061   if (theUserAdjointSteppingAction) theUserAdjointSteppingAction->UserSteppingAction(aStep);
00062 
00063   G4Track* aTrack =aStep->GetTrack();
00064   G4double nb_nuc=1.;
00065   G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
00066  
00067   if (thePartDef->GetParticleType() == "adjoint_nucleus"){
00068         nb_nuc=double(thePartDef->GetBaryonNumber());
00069   }
00070   //Kill conditions for adjoint particles reaching the maximum energy
00071   //-----------------------------------------------------------------
00072   if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc){
00073         aTrack->SetTrackStatus(fStopAndKill);
00074         did_adj_part_reach_ext_source=false;
00075         return;
00076   }
00077 
00078   G4double weight_factor = aTrack->GetWeight()/prim_weight;
00079 
00080   if ( (weight_factor>0 && weight_factor<=0) || weight_factor<= 1e-290 || weight_factor>1.e200)
00081   {
00082         //std::cout<<"Weight_factor problem! Value = "<<weight_factor<<std::endl;
00083         aTrack->SetTrackStatus(fStopAndKill);
00084         did_adj_part_reach_ext_source=false;
00085         return; 
00086   }
00087   
00088   
00089   //Kill conditions for surface crossing
00090   //--------------------------------------
00091   
00092   G4String surface_name;
00093   G4double cos_to_surface;
00094   G4bool GoingIn;
00095   G4ThreeVector crossing_pos;
00096   if (theG4AdjointCrossSurfChecker->CrossingOneOfTheRegisteredSurface(aStep, surface_name, crossing_pos, cos_to_surface, GoingIn) ){
00097         
00098         //G4cout<<"Test_step11"<<std::endl;
00099         //G4cout<<surface_name<<std::endl;
00100         if (surface_name == "ExternalSource") {
00101                 //Registering still needed
00102                 did_adj_part_reach_ext_source=true;
00103                 aTrack->SetTrackStatus(fStopAndKill);
00104                 //now register the adjoint particles reaching the external surface
00105                 last_momentum =aTrack->GetMomentum();
00106                 last_ekin=aTrack->GetKineticEnergy();
00107                 last_weight = aTrack->GetWeight();
00108                 last_part_def = aTrack->GetDefinition();
00109                 last_pos = crossing_pos;
00110                 return;
00111         }       
00112         else if (surface_name == "AdjointSource" && GoingIn) {
00113                 did_adj_part_reach_ext_source=false;
00114                 aTrack->SetTrackStatus(fStopAndKill);
00115                 return;
00116         }  
00117   }
00118   //Check for reaching out of world
00119   if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary) {
00120           did_adj_part_reach_ext_source=true;
00121           last_momentum =aTrack->GetMomentum();
00122           last_ekin=aTrack->GetKineticEnergy();
00123           last_weight = aTrack->GetWeight();
00124           last_part_def = aTrack->GetDefinition();
00125           last_pos = crossing_pos;
00126                 return;
00127 
00128   }
00129   
00130 }
00131 

Generated on Mon May 27 17:47:38 2013 for Geant4 by  doxygen 1.4.7