Back to home page

EIC code displayed by LXR

 
 

    


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

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 /// \file scavenger/include/ScoreSpecies.hh
0027 /// \brief Definition of the scavenger::ScoreSpecies class
0028 
0029 #ifndef SCAVENGER_ScoreSpecies_h
0030 #  define SCAVENGER_ScoreSpecies_h 1
0031 
0032 #  include "G4THitsMap.hh"
0033 #  include "G4UIcmdWithADoubleAndUnit.hh"
0034 #  include "G4UIcmdWithAString.hh"
0035 #  include "G4UIcmdWithAnInteger.hh"
0036 #  include "G4UImessenger.hh"
0037 #  include "G4VPrimitiveScorer.hh"
0038 
0039 #  include <set>
0040 
0041 class G4VAnalysisManager;
0042 
0043 class G4MolecularConfiguration;
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 namespace scavenger
0047 {
0048 
0049 /// \brief Primitive scorer class for scoring the radiolytic species
0050 /// produced after irradiation in a water volume
0051 ///
0052 /// This is a primitive scorer class for molecular species.
0053 /// The number of species is recorded for all times (predetermined or
0054 /// user chosen). It also scores the energy deposition in order to compute the
0055 /// radiochemical yields.
0056 
0057 class ScoreSpecies : public G4VPrimitiveScorer, public G4UImessenger
0058 {
0059   public:
0060     explicit ScoreSpecies(const G4String& name, const G4int& depth = 0);
0061 
0062     ~ScoreSpecies() override = default;
0063 
0064     /** Add a time at which the number of species should be recorded.
0065      Default times are set up to 1 microsecond.*/
0066     inline void AddTimeToRecord(const G4double& time) { fTimeToRecord.insert(time); }
0067 
0068     /**  Remove all times to record, must be reset by user.*/
0069     inline void ClearTimeToRecord() { fTimeToRecord.clear(); }
0070 
0071     /** Get number of recorded events*/
0072     [[nodiscard]] inline G4int GetNumberOfRecordedEvents() const { return fNEvent; }
0073 
0074     void Initialize(G4HCofThisEvent*) override;
0075 
0076     void EndOfEvent(G4HCofThisEvent*) override;
0077 
0078     void DrawAll() override {};
0079 
0080     void PrintAll() override;
0081 
0082     /** Method used in multithreading mode in order to merge
0083      the results*/
0084     void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer*);
0085 
0086     void OutputAndClear();
0087 
0088     void SetNewValue(G4UIcommand*, G4String) override;
0089 
0090     /** Write results to whatever chosen file format*/
0091     void WriteWithAnalysisManager(G4VAnalysisManager*);
0092 
0093     struct SpeciesInfo
0094     {
0095         SpeciesInfo() = default;
0096         SpeciesInfo(const SpeciesInfo& right) = default;
0097         SpeciesInfo& operator=(const SpeciesInfo& right) = default;
0098 
0099         G4int fNumber = 0;
0100         G4double fG = 0.;
0101         G4double fG2 = 0;
0102     };
0103 
0104   protected:
0105     G4bool ProcessHits(G4Step*, G4TouchableHistory*) override;
0106 
0107   private:
0108     typedef const G4MolecularConfiguration Species;
0109     typedef std::map<Species*, SpeciesInfo> InnerSpeciesMap;
0110     typedef std::map<G4double, InnerSpeciesMap> SpeciesMap;
0111     SpeciesMap fSpeciesInfoPerTime;
0112     std::set<G4double> fTimeToRecord;
0113     G4int fNEvent = 0;  // number of processed events
0114     G4double fEdep = 0;  // total energy deposition
0115     G4String fOutputType = "root";
0116     G4int fHCID = -1;
0117     G4THitsMap<G4double>* fEvtMap = nullptr;
0118     std::unique_ptr<G4UIdirectory> fpSpeciesdir;
0119     std::unique_ptr<G4UIcmdWithAnInteger> fpTimeBincmd;
0120     std::unique_ptr<G4UIcmdWithADoubleAndUnit> fpAddTimeToRecordcmd;
0121     std::unique_ptr<G4UIcmdWithAString> fpSetResultsFileNameCmd;
0122     G4String fRootFileName = "scorer.root";
0123 };
0124 
0125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0126 
0127 #endif
0128 }