From 0ce793a36637c35b8d353dafb10c5a1bdabeb482 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 24 Mar 2023 19:23:09 +0100 Subject: [PATCH] fixed constant shadowing --- .../Notification/interface/TrackInformation.h | 15 +-------------- SimG4Core/Notification/src/TrackInformation.cc | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/SimG4Core/Notification/interface/TrackInformation.h b/SimG4Core/Notification/interface/TrackInformation.h index 009c5d4ab6e03..62fa4a5680499 100644 --- a/SimG4Core/Notification/interface/TrackInformation.h +++ b/SimG4Core/Notification/interface/TrackInformation.h @@ -7,9 +7,6 @@ #include "DataFormats/Math/interface/Vector3D.h" #include "DataFormats/Math/interface/LorentzVector.h" -constexpr double invcm = 1.0 / CLHEP::cm; -constexpr double invgev = 1.0 / CLHEP::GeV; - class TrackInformation : public G4VUserTrackInformation { public: ~TrackInformation() override = default; @@ -57,17 +54,7 @@ class TrackInformation : public G4VUserTrackInformation { void setCaloSurfaceParticleP(double p) { caloSurfaceParticleP_ = p; } // Boundary crossing variables - void setCrossedBoundary(const G4Track *track) { - crossedBoundary_ = true; - positionAtBoundary_ = math::XYZTLorentzVectorF(track->GetPosition().x() * invcm, - track->GetPosition().y() * invcm, - track->GetPosition().z() * invcm, - track->GetGlobalTime()); - momentumAtBoundary_ = math::XYZTLorentzVectorF(track->GetMomentum().x() * invgev, - track->GetMomentum().y() * invgev, - track->GetMomentum().z() * invgev, - track->GetTotalEnergy() * invgev); - } + void setCrossedBoundary(const G4Track *track); bool crossedBoundary() const { return crossedBoundary_; } const math::XYZTLorentzVectorF &getPositionAtBoundary() const { return positionAtBoundary_; } const math::XYZTLorentzVectorF &getMomentumAtBoundary() const { return momentumAtBoundary_; } diff --git a/SimG4Core/Notification/src/TrackInformation.cc b/SimG4Core/Notification/src/TrackInformation.cc index f17e947ad5442..318074d820c1a 100644 --- a/SimG4Core/Notification/src/TrackInformation.cc +++ b/SimG4Core/Notification/src/TrackInformation.cc @@ -1,9 +1,25 @@ #include "SimG4Core/Notification/interface/TrackInformation.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "G4ThreeVector.hh" +#include "G4SystemOfUnits.hh" + #include -G4ThreadLocal G4Allocator *fpTrackInformationAllocator = nullptr; +G4ThreadLocal G4Allocator* fpTrackInformationAllocator = nullptr; + +void TrackInformation::setCrossedBoundary(const G4Track* track) { + const double invcm = 1.0 / CLHEP::cm; + const double invgev = 1.0 / CLHEP::GeV; + const double invsec = 1.0 / CLHEP::second; + crossedBoundary_ = true; + const G4ThreeVector& v = track->GetPosition(); + positionAtBoundary_ = + math::XYZTLorentzVectorF(v.x() * invcm, v.y() * invcm, v.z() * invcm, track->GetGlobalTime() * invsec); + const G4ThreeVector& p = track->GetMomentum(); + momentumAtBoundary_ = + math::XYZTLorentzVectorF(p.x() * invgev, p.y() * invgev, p.z() * invgev, track->GetTotalEnergy() * invgev); +} void TrackInformation::Print() const { LogDebug("TrackInformation") << " TrackInformation : storeTrack = " << storeTrack_ << "\n"