![]() |
|
|||
File indexing completed on 2025-10-13 08:27:57
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 // The `molcounters` example(s) are provided as part of Geant4-DNA 0027 // and any report or published result obtained using it shall cite 0028 // the respective Geant4-DNA collaboration publications. 0029 // 0030 // Reports or results obtained using the spatially-aware `MoleculeCounter` 0031 // provided in this example, shall further cite: 0032 // 0033 // Velten & Tomé, Radiation Physics and Chemistry, 2023 (10.1016/j.radphyschem.2023.111194) 0034 // 0035 // 0036 // Author: Christian Velten (2025) 0037 // 0038 0039 #include "Run.hh" 0040 0041 #include "ScoreBasicMoleculeCounts.hh" 0042 #include "ScoreBasicReactionCounts.hh" 0043 0044 #include "G4MoleculeCounterManager.hh" 0045 #include "G4SDManager.hh" 0046 #include "G4VSensitiveDetector.hh" 0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0048 Run::Run() : G4Run() 0049 { 0050 auto mfdet = dynamic_cast<G4MultiFunctionalDetector*>( 0051 G4SDManager::GetSDMpointer()->FindSensitiveDetector("mfDetector")); 0052 0053 fScorerMoleculesBasic = mfdet->GetPrimitive( 0054 G4SDManager::GetSDMpointer()->GetCollectionID("mfDetector/BasicMoleculeCounts")); 0055 fScorerMoleculesBasicVariablePrecision = mfdet->GetPrimitive( 0056 G4SDManager::GetSDMpointer()->GetCollectionID("mfDetector/BasicCounter_VariablePrecision")); 0057 fScorerReactionsBasic = mfdet->GetPrimitive( 0058 G4SDManager::GetSDMpointer()->GetCollectionID("mfDetector/BasicReactionCounts")); 0059 } 0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0061 void Run::Merge(const G4Run* aRun) 0062 { 0063 if (aRun == nullptr || aRun == this) return; 0064 0065 // Ideally, merging of workers -> master counters is handled by the counter manager 0066 // as part of its EndOfEventAction and EndOfRunAction, if and when the manager it instructed 0067 // to reset the counters between events or runs. 0068 // In the case of resets between runs, the user has two options: 0069 // (1) ignore the master counter entries and merge results from sensitive detector workers; or 0070 // (2) do not trigger sensitive detectors in the workers and read out from the master, only 0071 // If the counter manager does not accumulate, only option (1) is feasible. 0072 // 0073 // In the case of resets between events, and the counter manager does not accumulate, the user 0074 // must: 0075 // (*) fill the scorers during the Event (or using G4VPrimitiveScorer::EndOfEvent); and 0076 // (*) merge the worker scorers at the end of the run 0077 // This is the "current" behavior, for example, when calculating G-values. 0078 // 0079 // The code below accumulates the scorers' workers into the respective master 0080 // in case the manager does not accumulate, or we reset between events or runs. 0081 0082 if (G4MoleculeCounterManager::Instance()->GetResetCountersBeforeEvent() 0083 || G4MoleculeCounterManager::Instance()->GetResetCountersBeforeRun() 0084 || !G4MoleculeCounterManager::Instance()->GetAccumulateCounterIntoMaster()) 0085 { 0086 { 0087 auto masterScorer = dynamic_cast<ScoreBasicMoleculeCounts*>(this->fScorerMoleculesBasic); 0088 auto localScorer = dynamic_cast<ScoreBasicMoleculeCounts*>( 0089 static_cast<const Run*>(aRun)->fScorerMoleculesBasic); 0090 masterScorer->AbsorbResultsFromWorkerScorer(localScorer); 0091 } 0092 0093 { 0094 auto masterScorer = 0095 dynamic_cast<ScoreBasicMoleculeCounts*>(this->fScorerMoleculesBasicVariablePrecision); 0096 auto localScorer = dynamic_cast<ScoreBasicMoleculeCounts*>( 0097 static_cast<const Run*>(aRun)->fScorerMoleculesBasicVariablePrecision); 0098 masterScorer->AbsorbResultsFromWorkerScorer(localScorer); 0099 } 0100 0101 { 0102 auto masterScorer = dynamic_cast<ScoreBasicReactionCounts*>(this->fScorerReactionsBasic); 0103 auto localScorer = dynamic_cast<ScoreBasicReactionCounts*>( 0104 static_cast<const Run*>(aRun)->fScorerReactionsBasic); 0105 masterScorer->AbsorbResultsFromWorkerScorer(localScorer); 0106 } 0107 } 0108 0109 G4Run::Merge(aRun); 0110 } 0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |