Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:12

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 "PulseAction.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 }
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 void TimeStepAction::UserPreTimeStepAction() {}
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 void TimeStepAction::UserPostTimeStepAction()
0058 {
0059   G4double T1 = 5 * CLHEP::ns;
0060   if (fpPulse != nullptr && fpPulse->IsActivedPulse()) {
0061     G4MoleculeCounter::Instance()->Use(false);
0062     // we don't count molecules during the pulse
0063     T1 = fpPulse->GetLonggestDelayedTime() + 5 * CLHEP::ns;
0064   }
0065   // T1: time to start mesoscopic model
0066   if (fScheduler->GetGlobalTime() >= T1) {
0067     CompartmentBased();
0068   }
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 void TimeStepAction::UserReactionAction(const G4Track& /*a*/, const G4Track& /*b*/,
0074                                         const std::vector<G4Track*>* /*products*/)
0075 {}
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 
0079 void TimeStepAction::EndProcessing() {}
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 void TimeStepAction::CompartmentBased()
0084 {
0085   SetInitialPixel();
0086   fpEventScheduler->SetVerbose(fScheduler->GetVerbose());
0087   fpEventScheduler->SetStartTime(fScheduler->GetGlobalTime());  // continue from globalTime
0088   fpEventScheduler->SetEndTime(fScheduler->GetEndTime() - 1 * ps);
0089   fpEventScheduler->SetChangeMesh(true);
0090   fpEventScheduler->Initialize(*fpChemWorld->GetChemistryBoundary(), fPixel);
0091   fpEventScheduler->Run();
0092   fScheduler->Stop();
0093 }
0094 
0095 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0096 
0097 G4DNAEventScheduler* TimeStepAction::GetEventScheduler() const
0098 {
0099   return fpEventScheduler.get();
0100 }
0101 
0102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0103 
0104 void TimeStepAction::SetInitialPixel()
0105 {
0106   auto pBoundingBox = fpChemWorld->GetChemistryBoundary();
0107   G4double Box = pBoundingBox->halfSideLengthInX();
0108   if (Box == 1.6 * um) {
0109     fPixel = 512;  // for CONV
0110   }
0111   else if (Box == 0.8 * um) {
0112     fPixel = 256;  // for FLASH
0113   }
0114   else {
0115     G4cout << "Box  : " << *pBoundingBox << "  Pixel : " << fPixel << G4endl;
0116     G4Exception("This chem volume is not optimized and the result may be incorrect.",
0117                 "TimeStepAction::TimeStepAction", FatalException, "");
0118   }
0119   // 512 : for conventional dose rate
0120   // 256 : for higher dose rate
0121 }
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0124 
0125 void TimeStepAction::StartProcessing()
0126 {
0127   auto currentEvent = G4EventManager::GetEventManager();
0128   if (currentEvent->GetConstCurrentEvent()->IsAborted()) {
0129     G4cout << "This event is fully aborted" << G4endl;
0130     fScheduler->Stop();
0131   }
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......