Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0027 /// \file RE05/src/RE05EventAction.cc
0028 /// \brief Implementation of the RE05EventAction class
0029 //
0030 
0031 #include "RE05EventAction.hh"
0032 
0033 #include "RE05CalorimeterHit.hh"
0034 #include "RE05MuonHit.hh"
0035 #include "RE05TrackerHit.hh"
0036 
0037 #include "G4Event.hh"
0038 #include "G4EventManager.hh"
0039 #include "G4HCofThisEvent.hh"
0040 #include "G4SDManager.hh"
0041 #include "G4SystemOfUnits.hh"
0042 #include "G4Trajectory.hh"
0043 #include "G4TrajectoryContainer.hh"
0044 #include "G4UImanager.hh"
0045 #include "G4VHitsCollection.hh"
0046 #include "G4VVisManager.hh"
0047 #include "G4ios.hh"
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 RE05EventAction::RE05EventAction()
0052   : G4UserEventAction(), fTrackerCollID(-1), fCalorimeterCollID(-1), fMuonCollID(-1)
0053 {}
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 RE05EventAction::~RE05EventAction() {}
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 void RE05EventAction::BeginOfEventAction(const G4Event*)
0062 {
0063   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0064   if (fTrackerCollID < 0 || fCalorimeterCollID < 0 || fMuonCollID < 0) {
0065     G4String colNam;
0066     fTrackerCollID = SDman->GetCollectionID(colNam = "trackerCollection");
0067     fCalorimeterCollID = SDman->GetCollectionID(colNam = "calCollection");
0068     fMuonCollID = SDman->GetCollectionID(colNam = "muonCollection");
0069   }
0070 }
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 void RE05EventAction::EndOfEventAction(const G4Event* evt)
0075 {
0076   G4cout << ">>> Event " << evt->GetEventID() << G4endl;
0077 
0078   if (fTrackerCollID < 0 || fCalorimeterCollID < 0 || fMuonCollID < 0) return;
0079 
0080   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0081   RE05TrackerHitsCollection* THC = 0;
0082   RE05CalorimeterHitsCollection* CHC = 0;
0083   RE05MuonHitsCollection* MHC = 0;
0084   if (HCE) {
0085     THC = (RE05TrackerHitsCollection*)(HCE->GetHC(fTrackerCollID));
0086     CHC = (RE05CalorimeterHitsCollection*)(HCE->GetHC(fCalorimeterCollID));
0087     MHC = (RE05MuonHitsCollection*)(HCE->GetHC(fMuonCollID));
0088   }
0089 
0090   if (THC) {
0091     int n_hit = THC->entries();
0092     G4cout << "     " << n_hit << " hits are stored in RE05TrackerHitsCollection." << G4endl;
0093   }
0094   if (CHC) {
0095     int n_hit = CHC->entries();
0096     G4cout << "     " << n_hit << " hits are stored in RE05CalorimeterHitsCollection." << G4endl;
0097     G4double totE = 0;
0098     for (int i = 0; i < n_hit; i++) {
0099       totE += (*CHC)[i]->GetEdep();
0100     }
0101     G4cout << "     Total energy deposition in calorimeter : " << totE / GeV << " (GeV)" << G4endl;
0102   }
0103   if (MHC) {
0104     int n_hit = MHC->entries();
0105     G4cout << "     " << n_hit << " hits are stored in RE05MuonHitsCollection." << G4endl;
0106   }
0107 }
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......