Geant4  10.01.p01
EventAction.cc
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 // Delage et al. PDB4DNA: implementation of DNA geometry from the Protein Data
31 // Bank (PDB) description for Geant4-DNA Monte-Carlo
32 // simulations (submitted to Comput. Phys. Commun.)
33 // The Geant4-DNA web site is available at http://geant4-dna.org
34 //
35 // $Id$
36 //
39 
40 #include "EventAction.hh"
41 
42 #include "Analysis.hh"
43 #include "EventActionMessenger.hh"
44 #include "G4Event.hh"
45 #include "G4UnitsTable.hh"
46 #include "G4SystemOfUnits.hh"
47 #include "Randomize.hh"
48 
49 #include <algorithm>
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {
55  //default parameter values
56  //
57  fPrintModulo=100;
58  fThresEdepForSSB=8.22*eV;
61 
62  //create commands
63  //
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
71  delete fpEventMessenger;
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  G4int evtNb = evt->GetEventID();
79 
80  //printing survey
81  //
82  if (evtNb%fPrintModulo == 0)
83  {
84  G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
85  }
86 
87  // Initialization of parameters
88  //
90  fEdepStrand1.clear();
91  fEdepStrand2.clear();
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95 
97 {
98  // At the end of an event, compute the number of strand breaks
99  //
100  G4int sb[2] = {0,0};
102  // Fill histograms
103  //
104  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
105 
106  if ( fTotalEnergyDeposit>0. )
107  {
108  analysisManager->FillH1(1,fTotalEnergyDeposit);
109  }
110  if ( sb[0]>0 )
111  {
112  analysisManager->FillH1(2,sb[0]);
113  }
114  if ( sb[1]>0 )
115  {
116  analysisManager->FillH1(3,sb[1]);
117  }
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  // sb quantities
125  //
126  G4int ssb1=0;
127  G4int ssb2=0;
128  G4int dsb=0;
129 
130  // nucleotide id and energy deposit for each strand
131  G4int nucl1;
132  G4int nucl2;
133  G4double edep1;
134  G4double edep2;
135 
136  //Read strand1
137  //
138  while ( !fEdepStrand1.empty() )
139  {
140  nucl1 = fEdepStrand1.begin()->first;
141  edep1 = fEdepStrand1.begin()->second;
142  fEdepStrand1.erase( fEdepStrand1.begin() );
143 
144  // SSB in strand1
145  //
146  if ( edep1 >= fThresEdepForSSB/eV )
147  {
148  ssb1++;
149  }
150 
151  // Look at strand2
152  //
153  if ( !fEdepStrand2.empty() )
154  {
155  do
156  {
157  nucl2 = fEdepStrand2.begin()->first;
158  edep2 = fEdepStrand2.begin()->second;
159  if ( edep2 >= fThresEdepForSSB/eV )
160  {
161  ssb2++;
162  }
163  fEdepStrand2.erase( fEdepStrand2.begin() );
164  } while ( ((nucl1-nucl2)>fThresDistForDSB) && (!fEdepStrand2.empty()) );
165 
166  // no dsb
167  //
168  if ( nucl2-nucl1 > fThresDistForDSB )
169  {
170  fEdepStrand2[nucl2]=edep2;
171  if ( edep2 >= fThresEdepForSSB/eV )
172  {
173  ssb2--;
174  }
175  }
176 
177  // one dsb
178  //
179  if ( std::abs(nucl2-nucl1) <= fThresDistForDSB )
180  {
181  if ( ( edep2 >= fThresEdepForSSB/eV ) &&
182  ( edep1 >= fThresEdepForSSB/eV ) )
183  {
184  ssb1--;
185  ssb2--;
186  dsb++;
187  }
188  }
189  }
190  }
191 
192  // End with not processed data
193  //
194  while ( !fEdepStrand1.empty() )
195  {
196  nucl1 = fEdepStrand1.begin()->first;
197  edep1 = fEdepStrand1.begin()->second;
198  if ( edep1 >= fThresEdepForSSB/eV )
199  {
200  ssb1++;
201  }
202  fEdepStrand1.erase( fEdepStrand1.begin() );
203  }
204 
205  while ( !fEdepStrand2.empty() )
206  {
207  nucl2 = fEdepStrand2.begin()->first;
208  edep2 = fEdepStrand2.begin()->second;
209  if ( edep2 >= fThresEdepForSSB/eV )
210  {
211  ssb2++;
212  }
213  fEdepStrand2.erase( fEdepStrand2.begin() );
214  }
215 
216  sb[0]=ssb1+ssb2;
217  sb[1]=dsb;
218 }
G4int fPrintModulo
Definition: EventAction.hh:67
void BeginOfEventAction(const G4Event *)
Definition: EventAction.cc:61
G4int fThresDistForDSB
Definition: EventAction.hh:106
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:151
void EndOfEventAction(const G4Event *)
Definition: EventAction.cc:95
G4GLOB_DLL std::ostream G4cout
void ComputeStrandBreaks(G4int *)
Definition: EventAction.cc:122
std::map< G4int, G4double > fEdepStrand1
Definition: EventAction.hh:100
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:61
G4double fTotalEnergyDeposit
Definition: EventAction.hh:54
static const double eV
Definition: G4SIunits.hh:194
std::map< G4int, G4double > fEdepStrand2
Definition: EventAction.hh:102
#define G4endl
Definition: G4ios.hh:61
EventActionMessenger * fpEventMessenger
Definition: EventAction.hh:109
double G4double
Definition: G4Types.hh:76
G4double fThresEdepForSSB
Definition: EventAction.hh:104