Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:56

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