Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:41

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