Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 08:31:17

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 RE06SteppingVerbose.cc
0027 /// \brief Implementation of the RE06SteppingVerbose class
0028 
0029 #include "RE06SteppingVerbose.hh"
0030 
0031 #include "G4Electron.hh"
0032 #include "G4Positron.hh"
0033 #include "G4Region.hh"
0034 #include "G4RegionStore.hh"
0035 #include "G4RunManagerKernel.hh"
0036 #include "G4SteppingManager.hh"
0037 #include "G4TrackingManager.hh"
0038 #include "G4UnitsTable.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 RE06SteppingVerbose::RE06SteppingVerbose()
0043   : G4VSteppingVerbose(), fTimers(), fNofTimers(0), fRegIdx(-1), fEp(false)
0044 {}
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 RE06SteppingVerbose::~RE06SteppingVerbose()
0049 {
0050   for (G4int j = 0; j < fNofTimers; j++) {
0051     delete fTimers[j];
0052   }
0053   fTimers.clear();
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 void RE06SteppingVerbose::InitializeTimers()
0059 {
0060   G4RegionStore* regionStore = G4RegionStore::GetInstance();
0061   fNofRegions = regionStore->size();
0062   fNofTimers = 2 * fNofRegions;
0063   G4int nEnt = fTimers.size();
0064   if (nEnt < fNofTimers) {
0065     for (G4int i = nEnt; i < fNofTimers; i++) {
0066       fTimers.push_back(new G4SliceTimer);
0067     }
0068   }
0069   for (G4int j = 0; j < fNofTimers; j++) {
0070     fTimers[j]->Clear();
0071   }
0072   fRegIdx = -1;
0073   fEp = false;
0074 
0075   // Set verbosity for timing
0076   G4RunManagerKernel::GetRunManagerKernel()->GetTrackingManager()->SetVerboseLevel(0);
0077 #ifdef G4VERBOSE
0078   fManager->SetVerboseLevel(1);
0079 #endif
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 void RE06SteppingVerbose::Report()
0085 {
0086   for (G4int i = 0; i < fNofRegions; i++) {
0087     G4cout << G4endl;
0088     G4cout << "Region <" << (*G4RegionStore::GetInstance())[i]->GetName() << ">" << G4endl;
0089     G4cout << " All particles : User=" << fTimers[i]->GetUserElapsed()
0090            << "  Real=" << fTimers[i]->GetRealElapsed()
0091            << "  Sys=" << fTimers[i]->GetSystemElapsed() << G4endl;
0092     G4cout << " e+ / e-       : User=" << fTimers[fNofRegions + i]->GetUserElapsed()
0093            << "  Real=" << fTimers[fNofRegions + i]->GetRealElapsed()
0094            << "  Sys=" << fTimers[fNofRegions + i]->GetSystemElapsed() << G4endl;
0095   }
0096   G4cout << G4endl;
0097 }
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0100 
0101 void RE06SteppingVerbose::NewStep()
0102 {
0103   CopyState();
0104   G4Region* reg =
0105     fTrack->GetStep()->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
0106   fRegIdx = FindRegion(reg);
0107   fTimers[fRegIdx]->Start();
0108   G4ParticleDefinition* pd = fTrack->GetDefinition();
0109   if (pd == G4Electron::ElectronDefinition() || pd == G4Positron::PositronDefinition()) fEp = true;
0110   if (fEp) fTimers[fNofRegions + fRegIdx]->Start();
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 
0115 void RE06SteppingVerbose::StepInfo()
0116 {
0117   fTimers[fRegIdx]->Stop();
0118   if (fEp) {
0119     fTimers[fNofRegions + fRegIdx]->Stop();
0120     fEp = false;
0121   }
0122   fRegIdx = -1;
0123 }
0124 
0125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0126 
0127 G4int RE06SteppingVerbose::FindRegion(G4Region* rgn)
0128 {
0129   G4RegionStore* regionStore = G4RegionStore::GetInstance();
0130   G4int sz = regionStore->size();
0131   for (G4int i = 0; i < sz; i++) {
0132     if (rgn == (*regionStore)[i]) return i;
0133   }
0134   return -1;
0135 }
0136 
0137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......