Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:35

0001 //==========================================================================
0002 //  AIDA Detector description implementation
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DDG4/Geant4StepHandler.h>
0016 #include <DDSegmentation/Segmentation.h>
0017 #include <DD4hep/DD4hepUnits.h>
0018 #include <CLHEP/Units/SystemOfUnits.h>
0019 
0020 // Geant4 include files
0021 #include <G4Version.hh>
0022 
0023 namespace units = dd4hep;
0024 using namespace dd4hep::sim;
0025 
0026 /// Returns the step status in form of a string
0027 const char* Geant4StepHandler::stepStatus(G4StepStatus status) {
0028   switch (status) {
0029     // Step reached the world boundary
0030   case fWorldBoundary:
0031     return "WorldBoundary";
0032     // Step defined by a geometry boundary
0033   case fGeomBoundary:
0034     return "GeomBoundary";
0035     // Step defined by a PreStepDoItVector
0036   case fAtRestDoItProc:
0037     return "AtRestDoItProc";
0038     // Step defined by a AlongStepDoItVector
0039   case fAlongStepDoItProc:
0040     return "AlongStepDoItProc";
0041     // Step defined by a PostStepDoItVector
0042   case fPostStepDoItProc:
0043     return "PostStepDoItProc";
0044     // Step defined by the user Step limit in the logical volume
0045   case fUserDefinedLimit:
0046     return "UserDefinedLimit";
0047     // Step defined by an exclusively forced PostStepDoIt process
0048   case fExclusivelyForcedProc:
0049     return "ExclusivelyForcedProc";
0050     // Step not defined yet
0051   case fUndefined:
0052   default:
0053     return "Undefined";
0054   };
0055 }
0056 
0057 /// Returns the pre-step status in form of a string
0058 const char* Geant4StepHandler::preStepStatus() const {
0059   return stepStatus(pre ? pre->GetStepStatus() : fUndefined);
0060 }
0061 
0062 /// Returns the post-step status in form of a string
0063 const char* Geant4StepHandler::postStepStatus() const {
0064   return stepStatus(post ? post->GetStepStatus() : fUndefined);
0065 }
0066 
0067 /// Apply BirksLaw
0068 double Geant4StepHandler::birkAttenuation() const    {
0069 #if G4VERSION_NUMBER >= 1001
0070   static G4EmSaturation s_emSaturation(1);
0071 #else
0072   static G4EmSaturation s_emSaturation();
0073   s_emSaturation.SetVerbose(1);
0074 #endif
0075 
0076 #if G4VERSION_NUMBER >= 1030
0077   static bool s_initialised = false;
0078   if(not s_initialised) {
0079       s_emSaturation.InitialiseG4Saturation();
0080       s_initialised = true;
0081   }
0082 #endif
0083 
0084   double energyDeposition = step->GetTotalEnergyDeposit();
0085   double length = step->GetStepLength();
0086   double niel   = step->GetNonIonizingEnergyDeposit();
0087   const G4Track* trk = step->GetTrack();
0088   const G4ParticleDefinition* particle = trk->GetDefinition();
0089   const G4MaterialCutsCouple* couple = trk->GetMaterialCutsCouple();
0090   double engyVis = s_emSaturation.VisibleEnergyDeposition(particle,
0091                                                           couple,
0092                                                           length,
0093                                                           energyDeposition,
0094                                                           niel);
0095   return engyVis;
0096 }