Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:31:31

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 #ifndef scorer_h
0027 #define scorer_h 1
0028 
0029 #include "G4DNAMesh.hh"
0030 #include "G4THitsMap.hh"
0031 #include "G4UIcmdWith3VectorAndUnit.hh"
0032 #include "G4UIcmdWithADoubleAndUnit.hh"
0033 #include "G4UIcmdWithAString.hh"
0034 #include "G4UIcmdWithAnInteger.hh"
0035 #include "G4UIdirectory.hh"
0036 #include "G4UImessenger.hh"
0037 #include "G4VPrimitiveScorer.hh"
0038 #include "G4DNAMolecularReactionTable.hh"
0039 #include <memory>
0040 #include <set>
0041 #include "G4MoleculeTable.hh"
0042 class G4DNAEventScheduler;
0043 
0044 class G4VAnalysisManager;
0045 
0046 class G4MolecularConfiguration;
0047 
0048 class G4VChemistryWorld;
0049 
0050 class InterPulseAction;
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0052 
0053 struct Dose : public G4UImessenger
0054 {
0055     Dose();
0056 
0057     ~Dose() override = default;
0058 
0059     void SetNewValue(G4UIcommand*, G4String) final;
0060 
0061     std::unique_ptr<G4UIdirectory> fpDoseDir;
0062     std::unique_ptr<G4UIcmdWithADoubleAndUnit> fpAddDoseCutOff;
0063     std::unique_ptr<G4UIcmdWithADoubleAndUnit> fpAddDoseToAbort;
0064     std::unique_ptr<G4UIcmdWithADoubleAndUnit> fpAddDoseCutOffPerPulse;
0065     G4double fDosesCutOff = 0;
0066     G4double fDosesToAbort = 0;
0067     G4double fCumulatedDose = 0;
0068     G4double fPulseMax = 0;
0069 };
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0072 
0073 struct Gvalues : public G4UImessenger
0074 {
0075     Gvalues();
0076 
0077     ~Gvalues() override = default;
0078 
0079     void SetNewValue(G4UIcommand*, G4String) final;
0080 
0081     G4int fHCID = -1;
0082     G4double fTimeLimit;
0083     std::unique_ptr<G4UIdirectory> fSpeciesdir;
0084     std::unique_ptr<G4UIcmdWithAnInteger> fTimeBincmd;
0085     std::unique_ptr<G4UIcmdWithADoubleAndUnit> fAddTimeToRecordcmd;
0086 
0087     G4int fNEvent = 0;
0088     G4double fEdep = 0;
0089     G4double fTotalDose = 0;
0090     G4double fTotalDose2 = 0;
0091     G4double fTotalDoseRate = 0;
0092     G4double fTotalDoseRate2 = 0;
0093     G4double fPulseMax = 0;
0094 
0095     inline void AddTimeToRecord(double time) { fTimeToRecord.insert(time); }
0096 
0097     void WriteWithAnalysisManager(G4VAnalysisManager*, const std::string& out);
0098     void WriteInfo(G4VAnalysisManager* analysisManager, const std::string& out);
0099     void WriteGvalues(G4VAnalysisManager* analysisManager);
0100 
0101     struct SpeciesInfo
0102     {
0103         SpeciesInfo() = default;
0104 
0105         SpeciesInfo(const SpeciesInfo& right) = default;
0106 
0107         SpeciesInfo& operator=(const SpeciesInfo& right) = default;
0108 
0109         int64_t fNumber = 0;
0110         G4double fG = 0;
0111         G4double fG2 = 0;
0112     };
0113 
0114     inline auto GetNumberOfRecordedEvents() const { return fNEvent; }
0115 
0116     using Species = const G4MolecularConfiguration;
0117     using InnerSpeciesMap = std::map<Species*, SpeciesInfo>;
0118     using SpeciesMap = std::map<G4double, InnerSpeciesMap>;
0119     SpeciesMap fSpeciesInfoPerTime;
0120     std::set<G4double> fTimeToRecord;
0121     G4int fRunID = 1;
0122 
0123     inline auto GetSpeciesInfo() const { return fSpeciesInfoPerTime; }
0124 };
0125 
0126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0127 
0128 template<typename TR>
0129 class Scorer : public G4VPrimitiveScorer
0130 {
0131   public:  // with description
0132     Scorer();
0133 
0134     ~Scorer() override = default;
0135 
0136     void Initialize(G4HCofThisEvent*) override;
0137 
0138     void EndOfEvent(G4HCofThisEvent*) override;
0139 
0140     void clear() override;
0141 
0142     G4bool ProcessHits(G4Step*, G4TouchableHistory*) override;
0143 
0144     G4THitsMap<G4double>* GetEventMap() const;
0145 
0146     void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer*);
0147 
0148     void OutputAndClear(const std::string& out);
0149 
0150     TR* GetpScorer();
0151 
0152     void SetChemistryWorld(G4VChemistryWorld*);
0153 
0154     G4VChemistryWorld* GetChemistryWorld() const;
0155 
0156     void SaveScavengerChange();
0157 
0158     void SaveMoleculeCounter();
0159 
0160     void SetEventScheduler(G4DNAEventScheduler* pEventScheduler)
0161     {
0162       fpEventScheduler = pEventScheduler;
0163     }
0164 
0165 private:
0166   std::unique_ptr<TR> fpScorer;
0167   G4int fHCID = -1;
0168   G4THitsMap<G4double> *fpEvtMap = nullptr;
0169   G4VChemistryWorld *fpChemistryWorld = nullptr;
0170   G4DNAEventScheduler *fpEventScheduler = nullptr;
0171   const InterPulseAction*  fPulseActionInfo = nullptr;
0172   const G4MolecularConfiguration* fH3Op = nullptr;
0173   const G4MolecularConfiguration* fOHm = nullptr;
0174   const G4MolecularConfiguration* fH2O = nullptr;
0175   const G4MolecularConfiguration* fO2 = nullptr;
0176 
0177 };
0178 
0179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0180 
0181 template<typename TR>
0182 Scorer<TR>::Scorer() : G4VPrimitiveScorer(typeid(TR).name()), fpScorer(new TR)
0183 {
0184   fH3Op = G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)");
0185   fOHm = G4MoleculeTable::Instance()->GetConfiguration("OHm(B)");
0186   fH2O = G4MoleculeTable::Instance()->GetConfiguration("H2O");
0187   fO2 =   G4MoleculeTable::Instance()->GetConfiguration("O2");
0188 }
0189 
0190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0191 
0192 template<typename TR>
0193 TR* Scorer<TR>::GetpScorer()
0194 {
0195   return fpScorer.get();
0196 }
0197 
0198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0199 
0200 template<typename TR>
0201 G4THitsMap<G4double>* Scorer<TR>::GetEventMap() const
0202 {
0203   return fpEvtMap;
0204 }
0205 
0206 #endif