/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSTerminatorSD.cc

00001 /* BDSIM
00002    Author: L. Nevay,
00003    Last modified 15/04/2014
00004    Copyright (c) 2014.  ALL RIGHTS RESERVED.
00005 */
00006 
00007 #include "BDSExecOptions.hh"
00008 #include "BDSDebug.hh"
00009 #include "BDSGlobalConstants.hh"
00010 
00011 #include "BDSTerminatorSD.hh"
00012 
00013 #include "G4ios.hh"
00014 #include "G4TouchableHistory.hh"
00015 #include "G4VTouchable.hh"
00016 #include "G4Step.hh"
00017 
00018 
00019 BDSTerminatorSD::BDSTerminatorSD(G4String name)
00020   :G4VSensitiveDetector(name)
00021 {
00022   verbose  = BDSExecOptions::Instance()->GetVerbose();
00023 }
00024 
00025 BDSTerminatorSD::~BDSTerminatorSD()
00026 {;}
00027 
00028 void BDSTerminatorSD::Initialize(G4HCofThisEvent* /*HCE*/)
00029 {
00030   BDSGlobalConstants::Instance()->ResetTurnNumber();
00031   //we don't actually use HCE here as we don't need to log any of the particle info
00032 }
00033 
00034 G4bool BDSTerminatorSD::ProcessHits(G4Step*aStep, G4TouchableHistory*)
00035 {
00036   G4int turnstaken = BDSGlobalConstants::Instance()->GetTurnsTaken();
00037   // feedback info but only every 10 turns to avoid slow down and output bloat
00038   if (turnstaken % 10 == 0)
00039     {
00040       G4cout << "Turn: " << std::right << std::setw(4) << std::fixed
00041              << turnstaken << " / " << std::left 
00042              << BDSGlobalConstants::Instance()->GetTurnsToTake() << G4endl;
00043     }
00044 #ifdef BDSDEBUG
00045   G4cout << "Incrementing turn number " << G4endl;
00046 #endif
00047   G4Track* theTrack = aStep->GetTrack();
00048   if ((theTrack->GetParentID() == 0) && (theTrack->GetTrackLength()/CLHEP::m > 1*CLHEP::m)){
00049     //this is a primary track
00050     //should only increment turn number for primaries
00051 #ifdef BDSDEBUG
00052     G4cout << __METHOD_NAME__ << " primary particle - incrementing turn number" << G4endl;
00053     G4cout << __METHOD_NAME__ << " track length is: " << theTrack->GetTrackLength()/CLHEP::m << G4endl;
00054     G4cout << __METHOD_NAME__ << " turn number is : " << BDSGlobalConstants::Instance()->GetTurnsTaken() << G4endl;
00055 #endif   
00056     BDSGlobalConstants::Instance()->IncrementTurnNumber();
00057 #ifdef BDSDEBUG
00058     G4cout << __METHOD_NAME__ << " new turn number : " << BDSGlobalConstants::Instance()->GetTurnsTaken() << G4endl;
00059 #endif
00060   }
00061   #ifdef BDSDEBUG
00062   else
00063     {G4cout << __METHOD_NAME__ << " secondary particle - not incrementing turn number" << G4endl;}
00064   #endif
00065   return true;
00066 }
00067 
00068 
00069 void BDSTerminatorSD::EndOfEvent(G4HCofThisEvent* /*HCE*/)
00070 {
00071   BDSGlobalConstants::Instance()->ResetTurnNumber();
00072 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7