Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:48

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 // This example is provided by the Geant4-DNA collaboration
0027 // Any report or published results obtained using the Geant4-DNA software
0028 // shall cite the following Geant4-DNA collaboration publication:
0029 // Med. Phys. 37 (2010) 4692-4708
0030 // J. Comput. Phys. 274 (2014) 841-882
0031 // The Geant4-DNA web site is available at http://geant4-dna.org
0032 //
0033 //
0034 #ifndef CHEM4_ScoreSpecies_h
0035 #define CHEM4_ScoreSpecies_h 1
0036 
0037 #include "G4THitsMap.hh"
0038 #include "G4VPrimitiveScorer.hh"
0039 
0040 #include <set>
0041 
0042 class G4VAnalysisManager;
0043 class G4MolecularConfiguration;
0044 
0045 // #define _ScoreSpecies_FOR_ALL_EVENTS
0046 
0047 /** \file ScoreSpecies.hh*/
0048 
0049 // Description:
0050 //   This is a primitive scorer class for scoring the radiolitic species
0051 // produced after irradiation in a water volume
0052 //
0053 // Created: 2015-10-27  by M. Karamitros,
0054 // modified: 2016-03-16 by P. Piersimoni
0055 
0056 class ScoreSpecies : public G4VPrimitiveScorer
0057 {
0058   public:
0059     ScoreSpecies(G4String name, G4int depth = 0);
0060 
0061     virtual ~ScoreSpecies();
0062 
0063     /** Add a time at which the number of species should be recorded.
0064         Default times are set up to 1 microsecond.*/
0065     inline void AddTimeToRecord(double time) { fTimeToRecord.insert(time); }
0066 
0067     /**  Remove all times to record, must be reset by user.*/
0068     inline void ClearTimeToRecord() { fTimeToRecord.clear(); }
0069 
0070     /** Get number of recorded events*/
0071     inline int GetNumberOfRecordedEvents() const { return fNEvent; }
0072 
0073     /** Write results to an text file*/
0074     void ASCII();
0075 
0076     /** Write results to whatever chosen file format*/
0077     void WriteWithAnalysisManager(G4VAnalysisManager*);
0078 
0079     struct SpeciesInfo
0080     {
0081         SpeciesInfo()
0082         {
0083           fNumber = 0;
0084           fG = 0.;
0085           fG2 = 0.;
0086         }
0087         SpeciesInfo(const SpeciesInfo& right)  // Species A(B);
0088         {
0089           fNumber = right.fNumber;
0090           fG = right.fG;
0091           fG2 = right.fG2;
0092         }
0093         SpeciesInfo& operator=(const SpeciesInfo& right)  // A = B
0094         {
0095           if (&right == this) return *this;
0096           fNumber = right.fNumber;
0097           fG = right.fG;
0098           fG2 = right.fG2;
0099           return *this;
0100         }
0101         int fNumber;
0102         double fG;
0103         double fG2;
0104     };
0105 
0106 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
0107     struct SpeciesInfoSOA
0108     {
0109         SpeciesInfoSOA()
0110         {
0111           // fNumber = 0;
0112           // fG = 0.;
0113           // fG2 = 0.;
0114         }
0115         SpeciesInfoSOA(const SpeciesInfoSOA& right)  // Species A(B);
0116         {
0117           fNumber = right.fNumber;
0118           fG = right.fG;
0119           fG2 = right.fG2;
0120           fEventID = right.fEventID;
0121         }
0122         SpeciesInfoSOA& operator=(const SpeciesInfoSOA& right)  // A = B
0123         {
0124           if (&right == this) return *this;
0125           fNumber = right.fNumber;
0126           fG = right.fG;
0127           fG2 = right.fG2;
0128           fEventID = right.fEventID;
0129           return *this;
0130         }
0131         std::vector<int> fNumber;
0132         std::vector<double> fG;
0133         std::vector<double> fG2;
0134         std::vector<int> fEventID;
0135     };
0136 #endif
0137 
0138   private:
0139     typedef const G4MolecularConfiguration Species;
0140     typedef std::map<Species*, SpeciesInfo> InnerSpeciesMap;
0141     typedef std::map<double, InnerSpeciesMap> SpeciesMap;
0142     SpeciesMap fSpeciesInfoPerTime;
0143 
0144 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
0145     typedef std::map<Species, SpeciesInfoSOA> InnerSpeciesMapPerEvent;
0146     typedef std::map<double, InnerSpeciesMapPerEvent> SpeciesMapPerEvent;
0147     SpeciesMapPerEvent fSpeciesInfoPerEvent;
0148 #endif
0149 
0150     std::set<G4double> fTimeToRecord;
0151 
0152     int fNEvent;  // number of processed events
0153     double fEdep;  // total energy deposition
0154     G4String fOutputType;  // output type
0155 
0156   protected:
0157     virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
0158 
0159   public:
0160     virtual void Initialize(G4HCofThisEvent*);
0161     virtual void EndOfEvent(G4HCofThisEvent*);
0162     virtual void DrawAll();
0163     virtual void PrintAll();
0164     /** Method used in multithreading mode in order to merge
0165         the results*/
0166     virtual void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer*);
0167     virtual void OutputAndClear();
0168 
0169     SpeciesMap GetSpeciesInfo() { return fSpeciesInfoPerTime; }
0170 
0171   private:
0172     G4int fHCID;
0173     G4THitsMap<G4double>* fEvtMap;
0174 };
0175 #endif