Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-11 08:04:39

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 // Delage et al. PDB4DNA: implementation of DNA geometry from the Protein Data
0031 //                  Bank (PDB) description for Geant4-DNA Monte-Carlo
0032 //                  simulations (submitted to Comput. Phys. Commun.)
0033 // The Geant4-DNA web site is available at http://geant4-dna.org
0034 //
0035 //
0036 /// \file EventAction.cc
0037 /// \brief Implementation of the EventAction class
0038 
0039 #include "EventAction.hh"
0040 
0041 #include "EventActionMessenger.hh"
0042 
0043 #include "G4AnalysisManager.hh"
0044 #include "G4Event.hh"
0045 #include "G4SystemOfUnits.hh"
0046 #include "G4UnitsTable.hh"
0047 #include "Randomize.hh"
0048 
0049 #include <algorithm>
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 EventAction::EventAction() : G4UserEventAction()
0054 {
0055   // default parameter values
0056   //
0057   fThresEdepForSSB = 8.22 * eV;
0058   fThresDistForDSB = 10;
0059   fTotalEnergyDeposit = 0;
0060 
0061   // create commands
0062   //
0063   fpEventMessenger = new EventActionMessenger(this);
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 EventAction::~EventAction()
0069 {
0070   delete fpEventMessenger;
0071 }
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0074 
0075 void EventAction::BeginOfEventAction(const G4Event*)
0076 {
0077   // Initialization of parameters
0078   //
0079   fTotalEnergyDeposit = 0.;
0080   fEdepStrand1.clear();
0081   fEdepStrand2.clear();
0082 }
0083 
0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0085 
0086 void EventAction::EndOfEventAction(const G4Event*)
0087 {
0088   // At the end of an event, compute the number of strand breaks
0089   //
0090   G4int sb[2] = {0, 0};
0091   ComputeStrandBreaks(sb);
0092   // Fill histograms
0093   //
0094   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0095 
0096   if (fTotalEnergyDeposit > 0.) {
0097     analysisManager->FillH1(1, fTotalEnergyDeposit);
0098   }
0099   if (sb[0] > 0) {
0100     analysisManager->FillH1(2, sb[0]);
0101   }
0102   if (sb[1] > 0) {
0103     analysisManager->FillH1(3, sb[1]);
0104   }
0105 }
0106 
0107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0108 
0109 void EventAction::ComputeStrandBreaks(G4int* sb)
0110 {
0111   // sb quantities
0112   //
0113   G4int ssb1 = 0;
0114   G4int ssb2 = 0;
0115   G4int dsb = 0;
0116 
0117   // nucleotide id and energy deposit for each strand
0118   G4int nucl1;
0119   G4int nucl2;
0120   G4double edep1;
0121   G4double edep2;
0122 
0123   // Read strand1
0124   //
0125   while (!fEdepStrand1.empty()) {
0126     nucl1 = fEdepStrand1.begin()->first;
0127     edep1 = fEdepStrand1.begin()->second;
0128     fEdepStrand1.erase(fEdepStrand1.begin());
0129 
0130     // SSB in strand1
0131     //
0132     if (edep1 >= fThresEdepForSSB / eV) {
0133       ssb1++;
0134     }
0135 
0136     // Look at strand2
0137     //
0138     if (!fEdepStrand2.empty()) {
0139       do {
0140         nucl2 = fEdepStrand2.begin()->first;
0141         edep2 = fEdepStrand2.begin()->second;
0142         if (edep2 >= fThresEdepForSSB / eV) {
0143           ssb2++;
0144         }
0145         fEdepStrand2.erase(fEdepStrand2.begin());
0146       } while (((nucl1 - nucl2) > fThresDistForDSB) && (!fEdepStrand2.empty()));
0147 
0148       // no dsb
0149       //
0150       if (nucl2 - nucl1 > fThresDistForDSB) {
0151         fEdepStrand2[nucl2] = edep2;
0152         if (edep2 >= fThresEdepForSSB / eV) {
0153           ssb2--;
0154         }
0155       }
0156 
0157       // one dsb
0158       //
0159       if (std::abs(nucl2 - nucl1) <= fThresDistForDSB) {
0160         if ((edep2 >= fThresEdepForSSB / eV) && (edep1 >= fThresEdepForSSB / eV)) {
0161           ssb1--;
0162           ssb2--;
0163           dsb++;
0164         }
0165       }
0166     }
0167   }
0168 
0169   // End with not processed data
0170   //
0171   while (!fEdepStrand1.empty()) {
0172     nucl1 = fEdepStrand1.begin()->first;
0173     edep1 = fEdepStrand1.begin()->second;
0174     if (edep1 >= fThresEdepForSSB / eV) {
0175       ssb1++;
0176     }
0177     fEdepStrand1.erase(fEdepStrand1.begin());
0178   }
0179 
0180   while (!fEdepStrand2.empty()) {
0181     nucl2 = fEdepStrand2.begin()->first;
0182     edep2 = fEdepStrand2.begin()->second;
0183     if (edep2 >= fThresEdepForSSB / eV) {
0184       ssb2++;
0185     }
0186     fEdepStrand2.erase(fEdepStrand2.begin());
0187   }
0188 
0189   sb[0] = ssb1 + ssb2;
0190   sb[1] = dsb;
0191 }