Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScoreSpecies.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // J. Comput. Phys. 274 (2014) 841-882
31 // The Geant4-DNA web site is available at http://geant4-dna.org
32 //
33 // $Id$
34 //
35 #ifndef CHEM4_ScoreSpecies_h
36 #define CHEM4_ScoreSpecies_h 1
37 
38 #include "G4VPrimitiveScorer.hh"
39 #include "G4THitsMap.hh"
40 #include <set>
41 
42 class G4VAnalysisManager;
44 
45 //#define _ScoreSpecies_FOR_ALL_EVENTS
46 
49 // Description:
50 // This is a primitive scorer class for scoring the radiolitic species
51 // produced after irradiation in a water volume
52 //
53 // Created: 2015-10-27 by M. Karamitros,
54 // modified: 2016-03-16 by P. Piersimoni
55 
57 {
58 public:
59  ScoreSpecies(G4String name, G4int depth=0);
60 
61  virtual ~ScoreSpecies();
62 
65  inline void AddTimeToRecord(double time)
66  {
67  fTimeToRecord.insert(time);
68  }
69 
71  inline void ClearTimeToRecord()
72  {
73  fTimeToRecord.clear();
74  }
75 
77  inline int GetNumberOfRecordedEvents() const
78  {
79  return fNEvent;
80  }
81 
83  void ASCII();
84 
87 
88  struct SpeciesInfo
89  {
91  {
92  fNumber = 0;
93  fG = 0.;
94  fG2 = 0.;
95  }
96  SpeciesInfo(const SpeciesInfo& right) // Species A(B);
97  {
98  fNumber = right.fNumber;
99  fG = right.fG;
100  fG2 = right.fG2;
101  }
103  {
104  if(&right == this) return *this;
105  fNumber = right.fNumber;
106  fG = right.fG;
107  fG2 = right.fG2;
108  return *this;
109  }
110  int fNumber;
111  double fG;
112  double fG2;
113  };
114 
115 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
116  struct SpeciesInfoSOA
117  {
119  {
120  //fNumber = 0;
121  //fG = 0.;
122  //fG2 = 0.;
123  }
124  SpeciesInfoSOA(const SpeciesInfoSOA& right) // Species A(B);
125  {
126  fNumber = right.fNumber;
127  fG = right.fG;
128  fG2 = right.fG2;
129  fEventID = right.fEventID;
130  }
131  SpeciesInfoSOA& operator=(const SpeciesInfoSOA& right) // A = B
132  {
133  if(&right == this) return *this;
134  fNumber = right.fNumber;
135  fG = right.fG;
136  fG2 = right.fG2;
137  fEventID = right.fEventID;
138  return *this;
139  }
140  std::vector<int> fNumber;
141  std::vector<double> fG;
142  std::vector<double> fG2;
143  std::vector<int> fEventID;
144  };
145 #endif
146 
147 private:
148  typedef G4MolecularConfiguration* Species;
149  typedef std::map<Species, SpeciesInfo> InnerSpeciesMap;
150  typedef std::map<double, InnerSpeciesMap> SpeciesMap;
151  SpeciesMap fSpeciesInfoPerTime;
152 
153 #ifdef _ScoreSpecies_FOR_ALL_EVENTS
154  typedef std::map<Species, SpeciesInfoSOA> InnerSpeciesMapPerEvent;
155  typedef std::map<double, InnerSpeciesMapPerEvent> SpeciesMapPerEvent;
156  SpeciesMapPerEvent fSpeciesInfoPerEvent;
157 #endif
158 
159  std::set<G4double> fTimeToRecord;
160 
161  int fNEvent; // number of processed events
162  double fEdep; // total energy deposition
163  G4bool fOutputToRoot; // flag to output to a ROOT file
164  G4bool fOutputToXml; // flag to output to a XML file
165  G4bool fOutputToCsv; // flag to output to a CSV file (text)
166 
167 protected:
169 
170 public:
171  virtual void Initialize(G4HCofThisEvent*);
172  virtual void EndOfEvent(G4HCofThisEvent*);
173  virtual void clear();
174  virtual void DrawAll();
175  virtual void PrintAll();
179  virtual void OutputAndClear();
180 
181  SpeciesMap GetSpeciesInfo() {return fSpeciesInfoPerTime;}
182 
183 private:
184  G4int fHCID;
185  G4THitsMap<G4double>* fEvtMap;
186 };
187 #endif
void WriteWithAnalysisManager(G4VAnalysisManager *)
const XML_Char * name
Definition: expat.h:151
int GetNumberOfRecordedEvents() const
Definition: ScoreSpecies.hh:77
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
Definition: ScoreSpecies.cc:89
virtual void PrintAll()
SpeciesInfo(const SpeciesInfo &right)
Definition: ScoreSpecies.hh:96
virtual void Initialize(G4HCofThisEvent *)
void ClearTimeToRecord()
Definition: ScoreSpecies.hh:71
virtual void DrawAll()
int G4int
Definition: G4Types.hh:78
virtual void clear()
bool G4bool
Definition: G4Types.hh:79
SpeciesInfo & operator=(const SpeciesInfo &right)
void AddTimeToRecord(double time)
Definition: ScoreSpecies.hh:65
Definition: G4Step.hh:76
virtual ~ScoreSpecies()
Definition: ScoreSpecies.cc:84
virtual void EndOfEvent(G4HCofThisEvent *)
virtual void OutputAndClear()
virtual void AbsorbResultsFromWorkerScorer(G4VPrimitiveScorer *)
SpeciesMap GetSpeciesInfo()
ScoreSpecies(G4String name, G4int depth=0)
Definition: ScoreSpecies.cc:62
std::vector< double > fG
Definition: plotG.cc:149