Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-15 07:54:06

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 /// \file EventAction.cc
0027 /// \brief Implementation of the EventAction class
0028 
0029 #include "EventAction.hh"
0030 
0031 #include "HistoManager.hh"
0032 #include "Run.hh"
0033 
0034 #include "G4Event.hh"
0035 #include "G4RunManager.hh"
0036 #include "G4UnitsTable.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 void EventAction::BeginOfEventAction(const G4Event*)
0041 {
0042   fEdep1 = fEdep2 = fWeight1 = fWeight2 = 0.;
0043   fTime0 = -1 * s;
0044 }
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 void EventAction::AddEdep(G4int iVol, G4double edep, G4double time, G4double weight)
0049 {
0050   // initialize t0
0051   if (fTime0 < 0.) fTime0 = time;
0052 
0053   // out of time window ?
0054   const G4double TimeWindow(1 * microsecond);
0055   if (std::fabs(time - fTime0) > TimeWindow) return;
0056 
0057   if (iVol == 1) {
0058     fEdep1 += edep;
0059     fWeight1 += edep * weight;
0060   }
0061   if (iVol == 2) {
0062     fEdep2 += edep;
0063     fWeight2 += edep * weight;
0064   }
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 void EventAction::EndOfEventAction(const G4Event*)
0070 {
0071   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0072 
0073   G4double Etot = fEdep1 + fEdep2;
0074   G4double Wtot = (fWeight1 + fWeight2) / Etot;
0075 
0076   // pulse height in target
0077   //
0078   if (fEdep1 > 0.) {
0079     fWeight1 /= fEdep1;
0080     analysisManager->FillH1(0, fEdep1, fWeight1);
0081   }
0082 
0083   // pulse height in detector
0084   //
0085   if (fEdep2 > 0.) {
0086     fWeight2 /= fEdep2;
0087     analysisManager->FillH1(1, fEdep2, fWeight2);
0088   }
0089 
0090   // total
0091   //
0092   analysisManager->FillH1(2, Etot, Wtot);
0093 
0094   // threshold in target and detector
0095   const G4double Threshold1(10 * keV), Threshold2(10 * keV);
0096 
0097   // coincidence, anti-coincidences
0098   //
0099   G4bool coincidence = ((fEdep1 >= Threshold1) && (fEdep2 >= Threshold2));
0100   G4bool anti_coincidence1 = ((fEdep1 >= Threshold1) && (fEdep2 < Threshold2));
0101   G4bool anti_coincidence2 = ((fEdep1 < Threshold1) && (fEdep2 >= Threshold2));
0102 
0103   if (coincidence) analysisManager->FillH1(3, fEdep2, fWeight2);
0104   if (anti_coincidence1) analysisManager->FillH1(4, fEdep1, fWeight1);
0105   if (anti_coincidence2) analysisManager->FillH1(5, fEdep2, fWeight2);
0106 
0107   // pass energies to Run
0108   //
0109   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0110 
0111   run->AddEdep(fEdep1, fEdep2);
0112 }
0113 
0114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......