Geant4 Cross Reference |
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 // 36 /// \file EventAction.cc 37 /// \brief Implementation of the EventAction class 38 39 #include "EventAction.hh" 40 41 #include "EventActionMessenger.hh" 42 43 #include "G4AnalysisManager.hh" 44 #include "G4Event.hh" 45 #include "G4SystemOfUnits.hh" 46 #include "G4UnitsTable.hh" 47 #include "Randomize.hh" 48 49 #include <algorithm> 50 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 53 EventAction::EventAction() : G4UserEventAction() 54 { 55 // default parameter values 56 // 57 fThresEdepForSSB = 8.22 * eV; 58 fThresDistForDSB = 10; 59 fTotalEnergyDeposit = 0; 60 61 // create commands 62 // 63 fpEventMessenger = new EventActionMessenger(this); 64 } 65 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 68 EventAction::~EventAction() 69 { 70 delete fpEventMessenger; 71 } 72 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 75 void EventAction::BeginOfEventAction(const G4Event*) 76 { 77 // Initialization of parameters 78 // 79 fTotalEnergyDeposit = 0.; 80 fEdepStrand1.clear(); 81 fEdepStrand2.clear(); 82 } 83 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 85 86 void EventAction::EndOfEventAction(const G4Event*) 87 { 88 // At the end of an event, compute the number of strand breaks 89 // 90 G4int sb[2] = {0, 0}; 91 ComputeStrandBreaks(sb); 92 // Fill histograms 93 // 94 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 95 96 if (fTotalEnergyDeposit > 0.) { 97 analysisManager->FillH1(1, fTotalEnergyDeposit); 98 } 99 if (sb[0] > 0) { 100 analysisManager->FillH1(2, sb[0]); 101 } 102 if (sb[1] > 0) { 103 analysisManager->FillH1(3, sb[1]); 104 } 105 } 106 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 108 109 void EventAction::ComputeStrandBreaks(G4int* sb) 110 { 111 // sb quantities 112 // 113 G4int ssb1 = 0; 114 G4int ssb2 = 0; 115 G4int dsb = 0; 116 117 // nucleotide id and energy deposit for each strand 118 G4int nucl1; 119 G4int nucl2; 120 G4double edep1; 121 G4double edep2; 122 123 // Read strand1 124 // 125 while (!fEdepStrand1.empty()) { 126 nucl1 = fEdepStrand1.begin()->first; 127 edep1 = fEdepStrand1.begin()->second; 128 fEdepStrand1.erase(fEdepStrand1.begin()); 129 130 // SSB in strand1 131 // 132 if (edep1 >= fThresEdepForSSB / eV) { 133 ssb1++; 134 } 135 136 // Look at strand2 137 // 138 if (!fEdepStrand2.empty()) { 139 do { 140 nucl2 = fEdepStrand2.begin()->first; 141 edep2 = fEdepStrand2.begin()->second; 142 if (edep2 >= fThresEdepForSSB / eV) { 143 ssb2++; 144 } 145 fEdepStrand2.erase(fEdepStrand2.begin()); 146 } while (((nucl1 - nucl2) > fThresDistForDSB) && (!fEdepStrand2.empty())); 147 148 // no dsb 149 // 150 if (nucl2 - nucl1 > fThresDistForDSB) { 151 fEdepStrand2[nucl2] = edep2; 152 if (edep2 >= fThresEdepForSSB / eV) { 153 ssb2--; 154 } 155 } 156 157 // one dsb 158 // 159 if (std::abs(nucl2 - nucl1) <= fThresDistForDSB) { 160 if ((edep2 >= fThresEdepForSSB / eV) && (edep1 >= fThresEdepForSSB / eV)) { 161 ssb1--; 162 ssb2--; 163 dsb++; 164 } 165 } 166 } 167 } 168 169 // End with not processed data 170 // 171 while (!fEdepStrand1.empty()) { 172 nucl1 = fEdepStrand1.begin()->first; 173 edep1 = fEdepStrand1.begin()->second; 174 if (edep1 >= fThresEdepForSSB / eV) { 175 ssb1++; 176 } 177 fEdepStrand1.erase(fEdepStrand1.begin()); 178 } 179 180 while (!fEdepStrand2.empty()) { 181 nucl2 = fEdepStrand2.begin()->first; 182 edep2 = fEdepStrand2.begin()->second; 183 if (edep2 >= fThresEdepForSSB / eV) { 184 ssb2++; 185 } 186 fEdepStrand2.erase(fEdepStrand2.begin()); 187 } 188 189 sb[0] = ssb1 + ssb2; 190 sb[1] = dsb; 191 } 192