Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/medical/dna/UHDR/src/TimeStepAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 #include "TimeStepAction.hh"
0028 
0029 #include "InterPulseAction.hh"
0030 
0031 #include "G4DNAEventScheduler.hh"
0032 #include "G4DNAGillespieDirectMethod.hh"
0033 #include "G4DNAMolecularReactionTable.hh"
0034 #include "G4EventManager.hh"
0035 #include "G4ITLeadingTracks.hh"
0036 #include "G4MoleculeCounter.hh"
0037 #include "G4Scheduler.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4Track.hh"
0040 #include "G4UnitsTable.hh"
0041 #include "G4VChemistryWorld.hh"
0042 #include "G4VPrimitiveScorer.hh"
0043 
0044 TimeStepAction::TimeStepAction(const G4VChemistryWorld* pChemWorld, PulseAction* pPulse)
0045   : G4UserTimeStepAction(), fpPulse(pPulse), fpChemWorld(pChemWorld)
0046 {
0047   fpEventScheduler = std::make_unique<G4DNAEventScheduler>();
0048   fScheduler = G4Scheduler::Instance();
0049   if (dynamic_cast<InterPulseAction*>(fpPulse) != nullptr) {
0050     fPulsePeriod = dynamic_cast<InterPulseAction*>(fpPulse)->GetPulsePeriod();
0051     fNumberOfPulse = dynamic_cast<InterPulseAction*>(fpPulse)->GetNumberOfPulse();
0052   }
0053 }
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 void TimeStepAction::UserPreTimeStepAction()
0057 {
0058   fpEventScheduler->ParticleBasedCounter();
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 void TimeStepAction::UserPostTimeStepAction()
0064 {
0065   G4double T1 = 5 * CLHEP::ns;
0066   if (fpPulse != nullptr && fpPulse->IsActivedPulse()) {
0067     T1 = fpPulse->GetPulseLarger() + 5 * CLHEP::ns;
0068     if (fNumberOfPulse != 0) {
0069       fPulseID = (floor)(fScheduler->GetGlobalTime() / fPulsePeriod);
0070       T1 = fPulseID * fPulsePeriod + fpPulse->GetPulseLarger() + 5 * CLHEP::ns;
0071     }
0072   }
0073   // T1: time to start mesoscopic model
0074   if (fScheduler->GetGlobalTime() >= T1) {
0075     CompartmentBased();
0076   }
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 void TimeStepAction::UserReactionAction(const G4Track& /*a*/, const G4Track& /*b*/,
0082                                         const std::vector<G4Track*>* /*products*/)
0083 {}
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 void TimeStepAction::EndProcessing()
0088 {
0089   fpEventScheduler->Reset();
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 void TimeStepAction::CompartmentBased()
0095 {
0096   fpEventScheduler->SetStartTime(fScheduler->GetGlobalTime());  // continue from globalTime
0097   fpEventScheduler->SetChangeMesh(true);
0098   fpEventScheduler->Initialize(*fpChemWorld->GetChemistryBoundary(), fPixel);
0099   fpEventScheduler->Run();
0100 }
0101 
0102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0103 
0104 G4DNAEventScheduler* TimeStepAction::GetEventScheduler() const
0105 {
0106   return fpEventScheduler.get();
0107 }
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0110 
0111 void TimeStepAction::SetInitialPixel()
0112 {
0113   auto pBoundingBox = fpChemWorld->GetChemistryBoundary();
0114   G4double Box = pBoundingBox->halfSideLengthInX();
0115   if (Box == 4 * 1.6 * um) {
0116     fPixel = 4 * 512;  // for CONV
0117   }
0118   else if (Box == 2 * 1.6 * um) {
0119     fPixel = 2 * 512;  // for CONV
0120   }
0121   else if (Box == 1.6 * um) {
0122     fPixel = 512;  // for CONV
0123   }
0124   else if (Box == 0.8 * um) {
0125     fPixel = 256;  // for FLASH
0126   }
0127   else if (Box == 0.4 * um) {
0128     fPixel = 256 / 2;  // for FLASH
0129   }
0130   else if (Box == 0.2 * um) {
0131     fPixel = 256 / 4;  // for FLASH
0132   }
0133   else {
0134     G4cout << "Box  : " << *pBoundingBox << "  Pixel : " << fPixel << G4endl;
0135     G4Exception("This chem volume is not optimized and the result may be incorrect.",
0136                 "TimeStepAction::TimeStepAction", FatalException, "");
0137   }
0138 }
0139 
0140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0141 
0142 void TimeStepAction::StartProcessing()
0143 {
0144   auto currentEvent = G4EventManager::GetEventManager();
0145   if (currentEvent->GetConstCurrentEvent()->IsAborted()) {
0146     G4cout << "This event is fully aborted" << G4endl;
0147     fScheduler->Stop();
0148   }
0149   fpEventScheduler->SetVerbose(G4Scheduler::Instance()->GetVerbose());
0150   SetInitialPixel();
0151   fPulseID = 0;
0152 }
0153 
0154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......