Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-31 07:49:53

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 "RunAction.hh"
0033 
0034 #include "G4Event.hh"
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 EventAction::EventAction(RunAction* RA) : fRunAction(RA) {}
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 void EventAction::BeginOfEventAction(const G4Event*)
0043 {
0044   // initialisation per event
0045   fEdepPrimary = fEdepSecondary = 0.;
0046 }
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 void EventAction::SumEnergyDeposited(G4int trackID, G4double edep)
0051 {
0052   if (trackID == 1)
0053     fEdepPrimary += edep;
0054   else
0055     fEdepSecondary += edep;
0056 }
0057 
0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0059 
0060 void EventAction::SumEnergyTransfered(const G4VProcess* process, G4double energy)
0061 {
0062   G4String procName = process->GetProcessName();
0063   std::map<G4String, G4double>::iterator it = fEnergyTransfered.find(procName);
0064   if (it == fEnergyTransfered.end()) {
0065     fEnergyTransfered[procName] = energy;
0066   }
0067   else {
0068     fEnergyTransfered[procName] += energy;
0069   }
0070 
0071   G4int subtype = process->GetProcessSubType();
0072   fProcessSubType[procName] = subtype;
0073 }
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0076 
0077 void EventAction::EndOfEventAction(const G4Event*)
0078 {
0079   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0080 
0081   G4double EtransferedTotal = 0.;
0082   std::map<G4String, G4double>::iterator it;
0083   for (it = fEnergyTransfered.begin(); it != fEnergyTransfered.end(); it++) {
0084     G4String procName = it->first;
0085     G4double energy = it->second;
0086     fRunAction->EnergyTransferedByProcess(procName, energy);
0087     EtransferedTotal += energy;
0088     //
0089     G4int ih = 0;
0090     if (fProcessSubType[procName] == 2)
0091       ih = 3;
0092     else if (fProcessSubType[procName] == 3)
0093       ih = 4;
0094     else if (fProcessSubType[procName] == 4)
0095       ih = 5;
0096     if (ih > 0) analysisManager->FillH1(ih, energy);
0097   }
0098 
0099   fRunAction->EnergyDeposited(fEdepPrimary, fEdepSecondary);
0100   if (EtransferedTotal > 0.) fRunAction->EnergyTransfered(EtransferedTotal);
0101   G4double energyLostTotal = fEdepPrimary + EtransferedTotal;
0102   fRunAction->TotalEnergyLost(energyLostTotal);
0103   G4double energyDepositTotal = fEdepPrimary + fEdepSecondary;
0104   fRunAction->TotalEnergyDeposit(energyDepositTotal);
0105 
0106   analysisManager->FillH1(2, fEdepPrimary);
0107   analysisManager->FillH1(6, EtransferedTotal);
0108   analysisManager->FillH1(7, energyLostTotal);
0109   analysisManager->FillH1(9, fEdepSecondary);
0110   analysisManager->FillH1(10, energyDepositTotal);
0111 
0112   fEnergyTransfered.clear();
0113   fProcessSubType.clear();
0114 }
0115 
0116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......