Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-18 09:32:57

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 // s
0027 /// \file VG01SteppingVerboseWithDir.cc
0028 /// \brief Implementation of the VG01SteppingVerboseWithDir class
0029 
0030 // Author : J. Apostolakis,  (EP/SFT CERN)  2019-21
0031 //
0032 //  Refines the existing G4SteppingVerbose, adding:
0033 //   - direction of particle
0034 //   - safety (at step's start point)
0035 
0036 #include "VG01SteppingVerboseWithDir.hh"
0037 
0038 #include "G4SteppingManager.hh"
0039 #include "G4UnitsTable.hh"
0040 
0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0042 
0043 VG01SteppingVerboseWithDir::VG01SteppingVerboseWithDir() : G4SteppingVerbose() {}
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0046 
0047 VG01SteppingVerboseWithDir::~VG01SteppingVerboseWithDir() {}
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 void VG01SteppingVerboseWithDir::Banner()
0052 {
0053   G4cout << G4endl;
0054   G4cout << std::setw(5) << "Step#"
0055          << " " << std::setw(9) << "X (mm)"
0056          << " " << std::setw(9) << "Y (mm)"
0057          << " " << std::setw(9) << "Z (mm)"
0058          << " " << std::setw(11) << "Ek (MeV)"
0059          << " " << std::setw(8) << "dE (MeV)"
0060          << " " << std::setw(7) << "Step(mm)"
0061          << " " << std::setw(12) << "Track(mm)"
0062          << " " << std::setw(7) << "Safety(mm)"
0063          << " | " << std::setw(11) << " Dir.x "
0064          << " " << std::setw(11) << " Dir.y "
0065          << " " << std::setw(11) << " Dir.z "
0066          << " | " << std::setw(15) << "Material" << std::setw(14) << "Process" << std::setw(15)
0067          << "NextVolu" << G4endl;
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 void VG01SteppingVerboseWithDir::StepInfo()
0073 {
0074   CopyState();
0075 
0076   G4int prec = G4cout.precision(6);
0077 
0078   if (verboseLevel >= 1) {
0079     if (verboseLevel >= 4) VerboseTrack();
0080     if (verboseLevel >= 3) {
0081       Banner();
0082     }
0083 
0084     G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(9)
0085            << fTrack->GetPosition().x() / CLHEP::mm << " " << std::setw(9)
0086            << fTrack->GetPosition().y() / CLHEP::mm << " " << std::setw(9)
0087            << fTrack->GetPosition().z() / CLHEP::mm << " "  // << " Ek  = "
0088            << std::setw(11) << fTrack->GetKineticEnergy() / CLHEP::MeV << " ";
0089     G4cout.precision(3);
0090     G4cout << std::setw(8) << fStep->GetTotalEnergyDeposit() / CLHEP::MeV << " " << std::setw(7)
0091            << fStep->GetStepLength() / CLHEP::mm << " ";
0092     G4cout.precision(6);
0093     G4cout << std::setw(12) << fTrack->GetTrackLength() / CLHEP::mm << " ";
0094 
0095     G4cout.precision(5);
0096     G4StepPoint* preStepPt = fTrack->GetStep()->GetPreStepPoint();
0097     if (preStepPt != nullptr) {
0098       G4double safety = preStepPt->GetSafety();
0099       G4cout << std::setw(8) << ((safety > 1.0e-9) ? safety : 0.0) << " ";
0100     }
0101     else {
0102       G4cout << std::setw(8) << "-0.0_(N/A)"
0103              << " ";
0104     }
0105 
0106     G4cout << "| ";
0107     G4cout << std::setw(11) << fTrack->GetMomentumDirection().x() << " " << std::setw(11)
0108            << fTrack->GetMomentumDirection().y() << " " << std::setw(11)
0109            << fTrack->GetMomentumDirection().z() << " | ";
0110 
0111     G4cout << std::setw(15) << fTrack->GetMaterial()->GetName() << " ";
0112     G4VProcess const* pds = fStep->GetPostStepPoint()->GetProcessDefinedStep();
0113     G4cout << std::setw(14) << ((pds != nullptr) ? pds->GetProcessName() : G4String("User Limit"))
0114            << " ";
0115     // if( fStepStatus != fWorldBoundary){
0116     if (fTrack->GetNextVolume() != nullptr) {
0117       G4cout << std::setw(10) << fTrack->GetNextVolume()->GetName();
0118       G4cout << std::setw(4) << fTrack->GetNextVolume()->GetCopyNo();
0119     }
0120     else {
0121       G4cout << std::setw(10) << "OutOfWorld";
0122     }
0123 
0124     G4cout << " ";
0125 
0126     G4cout << G4endl;
0127 
0128     if (verboseLevel == 2) {
0129       G4int tN2ndariesTot = fN2ndariesAtRestDoIt + fN2ndariesAlongStepDoIt + fN2ndariesPostStepDoIt;
0130       if (tN2ndariesTot > 0) {
0131         G4cout << "    :----- List of 2ndaries - "
0132                << "#SpawnInStep=" << std::setw(3) << tN2ndariesTot << "(Rest=" << std::setw(2)
0133                << fN2ndariesAtRestDoIt << ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
0134                << ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt << "), "
0135                << "#SpawnTotal=" << std::setw(3) << (*fSecondary).size() << " ---------------"
0136                << G4endl;
0137 
0138         for (size_t lp1 = (*fSecondary).size() - tN2ndariesTot; lp1 < (*fSecondary).size(); lp1++) {
0139           G4cout << "    : " << std::setw(8) << (*fSecondary)[lp1]->GetPosition().x() / CLHEP::mm
0140                  << " " << std::setw(8) << (*fSecondary)[lp1]->GetPosition().y() / CLHEP::mm << " "
0141                  << std::setw(8) << (*fSecondary)[lp1]->GetPosition().z() / CLHEP::mm << " "
0142                  << std::setw(8) << (*fSecondary)[lp1]->GetKineticEnergy() / CLHEP::MeV << " "
0143                  << std::setw(10) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << " ";
0144           G4cout << G4endl;
0145         }
0146 
0147         G4cout << "    :-----------------------------"
0148                << "----------------------------------"
0149                << "-- EndOf2ndaries Info ---------------" << G4endl;
0150       }
0151     }
0152   }
0153   G4cout.precision(prec);
0154   // G4cout<< "exit VG01SteppingVerboseWithDir::StepInfo   " <<G4endl;
0155 }
0156 
0157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0158 
0159 void VG01SteppingVerboseWithDir::TrackingStarted()
0160 {
0161   CopyState();
0162   G4int prec = G4cout.precision(6);
0163   if (verboseLevel > 0) {
0164     Banner();
0165 
0166     G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(9)
0167            << fTrack->GetPosition().x() / CLHEP::mm << " " << std::setw(9)
0168            << fTrack->GetPosition().y() / CLHEP::mm << " " << std::setw(9)
0169            << fTrack->GetPosition().z() / CLHEP::mm << " "  // << " E_0 = "
0170            << std::setw(11) << fTrack->GetKineticEnergy() / CLHEP::MeV << " ";
0171     // << " ( = " << std::setw(8) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy") << " ) "
0172     G4cout.precision(3);
0173     G4cout << std::setw(8) << fStep->GetTotalEnergyDeposit() / CLHEP::MeV << " " << std::setw(7)
0174            << fStep->GetStepLength() / CLHEP::mm << " ";
0175     G4cout.precision(6);
0176     G4cout << std::setw(12) << fTrack->GetTrackLength() / CLHEP::mm << " ";
0177 
0178     G4Step const* step = fTrack->GetStep();
0179     G4StepPoint const* preStepPt = nullptr;
0180     if (step != nullptr) preStepPt = fTrack->GetStep()->GetPreStepPoint();
0181     if (preStepPt != nullptr) {
0182       G4double safety = preStepPt->GetSafety();
0183       G4cout << std::setw(8) << ((safety > 1.0e-9) ? safety : 0.0) << " ";
0184     }
0185     else {
0186       G4cout << std::setw(8) << "N/A"
0187              << " ";
0188     }
0189     G4cout << "| ";
0190     G4cout << std::setw(11) << fTrack->GetMomentumDirection().x() << " " << std::setw(11)
0191            << fTrack->GetMomentumDirection().y() << " " << std::setw(11)
0192            << fTrack->GetMomentumDirection().z() << " | ";
0193 
0194     // Material and volume name
0195     if (fTrack->GetVolume()) {
0196       G4Material* material = fTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
0197       if (material != nullptr) {
0198         G4cout << std::setw(15) << material->GetName() << " ";
0199       }
0200       else {
0201         G4cout << std::setw(15) << "No-Material"
0202                << " ";
0203       }
0204       G4cout << std::setw(14) << "initStep"
0205              << " ";
0206       G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
0207       G4cout << std::setw(4) << fTrack->GetVolume()->GetCopyNo() << " (initial Volume)";
0208     }
0209     else {
0210       G4cout << std::setw(10) << "No-Material"
0211              << " ";
0212       G4cout << std::setw(14) << "initStep"
0213              << " ";
0214       G4cout << std::setw(10) << "OutOfWorld"
0215              << " ";
0216     }
0217     // fTrack->GetMaterial() fails at track start !!!!
0218     G4cout << G4endl;
0219   }
0220   G4cout.precision(prec);
0221 }