diff --git a/DDG4/include/DDG4/Geant4Data.h b/DDG4/include/DDG4/Geant4Data.h index 7047181c604653a59210d77aed966c50c8f265b7..5cf3c0adebfe018b4b749f3ad8106f25b73a0ec7 100644 --- a/DDG4/include/DDG4/Geant4Data.h +++ b/DDG4/include/DDG4/Geant4Data.h @@ -179,6 +179,8 @@ namespace DD4hep { virtual ~Geant4HitData(); /// Extract the MC contribution for a given hit from the step information static Contribution extractContribution(const G4Step* step); + /// Extract the MC contribution for a given hit from the step information with BirksLaw option + static Contribution extractContribution(const G4Step* step, bool ApplyBirksLaw); }; /// Helper class to define structures used by the generic DDG4 tracker sensitive detector diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index 408c64fd066bbf294af62dd094442e6298ce19bf..0232f5b891adae814b35ee6b8565abf85934bc1a 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -70,6 +70,18 @@ Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* ste Contribution contrib(h.trkID(),h.trkPdgID(),deposit,h.trkTime(),pos); return contrib; } +/// Extract the MC contribution for a given hit from the step information with BirksLaw effect option +Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* step, bool ApplyBirksLaw) { + Geant4StepHandler h(step); + if ( ApplyBirksLaw == true ) h.doApplyBirksLaw(); + double deposit = + (h.trackDef() == G4OpticalPhoton::OpticalPhotonDefinition()) ? h.trkEnergy() : h.totalEnergy(); + const G4ThreeVector& pre = h.prePosG4(); + const G4ThreeVector& post = h.postPosG4(); + float pos[] = {float((pre.x()+post.x())/2.0),float((pre.y()+post.y())/2.0),float((pre.z()+post.z())/2.0) }; + Contribution contrib(h.trkID(),h.trkPdgID(),deposit,h.trkTime(),pos); + return contrib; +} /// Default constructor Geant4Tracker::Hit::Hit()