Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:09

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 #ifndef G4DNASCAVENGERMATERIAL_HH
0028 #define G4DNASCAVENGERMATERIAL_HH
0029 #include "globals.hh"
0030 #include "G4ios.hh"
0031 #include <map>
0032 #include <vector>
0033 #include "G4MoleculeCounter.hh"
0034 #include "G4VScavengerMaterial.hh"
0035 #include "G4MoleculeTable.hh"
0036 
0037 class G4Material;
0038 class G4MolecularConfiguration;
0039 class G4VChemistryWorld;
0040 
0041 class G4DNAScavengerMaterial : public G4VScavengerMaterial
0042 {
0043  public:
0044   using NbMoleculeInTime =
0045     std::map<G4double, int64_t, G4::MoleculeCounter::TimePrecision>;
0046   using MolType            = const G4MolecularConfiguration*;
0047   using MaterialMap        = std::map<MolType, int64_t>;
0048   using ReactantList       = std::vector<MolType>;
0049   using CounterMapType     = std::map<MolType, NbMoleculeInTime>;
0050   G4DNAScavengerMaterial() = default;
0051   explicit G4DNAScavengerMaterial(G4VChemistryWorld*);
0052   ~G4DNAScavengerMaterial() override                          = default;
0053   G4DNAScavengerMaterial(const G4DNAScavengerMaterial& right) = delete;
0054   G4DNAScavengerMaterial& operator=(const G4DNAScavengerMaterial&) = delete;
0055   void Initialize();
0056 
0057   void ReduceNumberMoleculePerVolumeUnitForMaterialConf(MolType, G4double);
0058   void AddNumberMoleculePerVolumeUnitForMaterialConf(MolType, G4double);
0059   G4double GetNumberMoleculePerVolumeUnitForMaterialConf(MolType) const;
0060 
0061   void AddAMoleculeAtTime(MolType, G4double time,
0062                           const G4ThreeVector* position = nullptr,
0063                           G4int number                  = 1);
0064   void RemoveAMoleculeAtTime(MolType, G4double time,
0065                              const G4ThreeVector* position = nullptr,
0066                              G4int number                  = 1);
0067 
0068   void Reset() override;
0069 
0070   void PrintInfo();
0071 
0072   MaterialMap::iterator end() { return fScavengerTable.end(); }
0073   MaterialMap::iterator begin() { return fScavengerTable.begin(); }
0074   size_t size() { return fScavengerTable.size(); }
0075 
0076   G4bool find(MolType type)
0077   {
0078     auto it = fScavengerTable.find(type);
0079     if(it != fScavengerTable.end())
0080     {
0081       return it->second > 0;
0082     }
0083     
0084     return false;
0085    
0086   }
0087 
0088   void SetCounterAgainstTime() { fCounterAgainstTime = true; }
0089   void SetpH(const G4int& ph);
0090   G4double GetpH();
0091 
0092   std::vector<MolType> GetScavengerList() const
0093   {
0094     std::vector<MolType> output;
0095     for(const auto& it : fScavengerTable)
0096     {
0097       output.push_back(it.first);
0098     }
0099     return output;
0100   }
0101 
0102   void Dump();
0103   int64_t GetNMoleculesAtTime(MolType molecule, G4double time);
0104   G4bool SearchTimeMap(MolType molecule);
0105   int64_t SearchUpperBoundTime(G4double time, G4bool sameTypeOfMolecule);
0106 
0107  private:
0108   G4VChemistryWorld* fpChemistryInfo;
0109   G4bool fIsInitialized;
0110   MaterialMap fScavengerTable;
0111   CounterMapType fCounterMap;
0112   G4bool fCounterAgainstTime;
0113   G4int fVerbose;
0114   MolType fH3Op = G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)");
0115   MolType fH2O = G4MoleculeTable::Instance()->GetConfiguration("H2O");
0116   MolType fHOm = G4MoleculeTable::Instance()->GetConfiguration("OHm(B)");
0117   struct Search
0118   {
0119     Search() { fLowerBoundSet = false; }
0120     CounterMapType::iterator fLastMoleculeSearched;
0121     NbMoleculeInTime::iterator fLowerBoundTime;
0122     G4bool fLowerBoundSet;
0123   };
0124 
0125   std::unique_ptr<Search> fpLastSearch;
0126   void WaterEquilibrium();
0127 
0128 };
0129 #endif  // G4DNASCAVENGERMATERIAL_HH