Back to home page

EIC code displayed by LXR

 
 

    


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

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