From 3d72e172e06d3be09d74c623049517c8786656a1 Mon Sep 17 00:00:00 2001 From: Marko Petric <marko.petric@cern.ch> Date: Fri, 20 Nov 2020 12:17:25 +0100 Subject: [PATCH] remove all usage of using namespace CLHEP for units protection --- DDG4/plugins/Geant4EventReaderGuineaPig.cpp | 15 +++++++------ DDG4/plugins/Geant4EventReaderHepEvt.cpp | 1 - DDG4/plugins/Geant4EventReaderHepMC.cpp | 21 +++++++++---------- DDG4/plugins/Geant4FieldTrackingSetup.cpp | 1 - .../DDG4_MySensDet/src/MyTrackerSDAction.cpp | 1 - 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp index 61a783dbe..92082b406 100644 --- a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp +++ b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp @@ -80,7 +80,6 @@ namespace dd4hep { #include <cerrno> using namespace std; -using namespace CLHEP; using namespace dd4hep::sim; typedef dd4hep::detail::ReferenceBitMask<int> PropertyMask; @@ -233,12 +232,12 @@ Geant4EventReaderGuineaPig::readParticles(int /* event_number */, } // Momentum vector - p->pex = p->psx = betaX*TMath::Abs(Energy)*GeV; - p->pey = p->psy = betaY*TMath::Abs(Energy)*GeV; - p->pez = p->psz = betaZ*TMath::Abs(Energy)*GeV; + p->pex = p->psx = betaX*TMath::Abs(Energy)*CLHEP::GeV; + p->pey = p->psy = betaY*TMath::Abs(Energy)*CLHEP::GeV; + p->pez = p->psz = betaZ*TMath::Abs(Energy)*CLHEP::GeV; // Mass - p->mass = 0.0005109989461*GeV; + p->mass = 0.0005109989461*CLHEP::GeV; // @@ -249,9 +248,9 @@ Geant4EventReaderGuineaPig::readParticles(int /* event_number */, // Vertex - p->vsx = posX*nm; - p->vsy = posY*nm; - p->vsz = posZ*nm; + p->vsx = posX*CLHEP::nm; + p->vsy = posY*CLHEP::nm; + p->vsz = posZ*CLHEP::nm; Vertex* vtx = new Vertex ; vtx->x = p->vsx ; diff --git a/DDG4/plugins/Geant4EventReaderHepEvt.cpp b/DDG4/plugins/Geant4EventReaderHepEvt.cpp index dad1a0ce1..0fcb2c085 100644 --- a/DDG4/plugins/Geant4EventReaderHepEvt.cpp +++ b/DDG4/plugins/Geant4EventReaderHepEvt.cpp @@ -89,7 +89,6 @@ namespace dd4hep { #include <cerrno> using namespace std; -using namespace CLHEP; using namespace dd4hep::sim; typedef dd4hep::detail::ReferenceBitMask<int> PropertyMask; diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index 1b0133eb2..ad1befbff 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -95,7 +95,6 @@ namespace dd4hep { #include <algorithm> using namespace std; -using namespace CLHEP; using namespace dd4hep::sim; typedef dd4hep::detail::ReferenceBitMask<int> PropertyMask; @@ -175,7 +174,7 @@ namespace dd4hep { void set_io(int typ, const string& k) { io_type = typ; key = k; } void use_default_units() - { mom_unit = MeV; pos_unit = mm; } + { mom_unit = MeV; pos_unit = CLHEP::mm; } bool read(); void clear(); }; @@ -279,7 +278,7 @@ Geant4EventReaderHepMC::readParticles(int /* ev_id */, "+++ %s ID:%3d status:%08X typ:%9d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " "time: %+.2e [ns] #Dau:%3d #Par:%1d", "",p->id,p->status,p->pdgID, - p->psx/MeV,p->psy/MeV,p->psz/MeV,p->time/ns, + p->psx/CLHEP::MeV,p->psy/CLHEP::MeV,p->psz/CLHEP::MeV,p->time/CLHEP::ns, p->daughters.size(), p->parents.size()); //output.emplace_back(p); @@ -619,14 +618,14 @@ int HepMC::read_units(EventStream &info, istringstream & input) { string mom, pos; input >> mom >> pos; if ( !input.fail() ) { - if ( mom == "KEV" ) info.mom_unit = keV; - else if ( mom == "MEV" ) info.mom_unit = MeV; - else if ( mom == "GEV" ) info.mom_unit = GeV; - else if ( mom == "TEV" ) info.mom_unit = TeV; - - if ( pos == "MM" ) info.pos_unit = mm; - else if ( pos == "CM" ) info.pos_unit = cm; - else if ( pos == "M" ) info.pos_unit = m; + if ( mom == "KEV" ) info.mom_unit = CLHEP::keV; + else if ( mom == "MEV" ) info.mom_unit = CLHEP::MeV; + else if ( mom == "GEV" ) info.mom_unit = CLHEP::GeV; + else if ( mom == "TEV" ) info.mom_unit = CLHEP::TeV; + + if ( pos == "MM" ) info.pos_unit = CLHEP::mm; + else if ( pos == "CM" ) info.pos_unit = CLHEP::cm; + else if ( pos == "M" ) info.pos_unit = CLHEP::m; } } return input.fail() ? 0 : 1; diff --git a/DDG4/plugins/Geant4FieldTrackingSetup.cpp b/DDG4/plugins/Geant4FieldTrackingSetup.cpp index d6a129e2d..3aef6274d 100644 --- a/DDG4/plugins/Geant4FieldTrackingSetup.cpp +++ b/DDG4/plugins/Geant4FieldTrackingSetup.cpp @@ -148,7 +148,6 @@ namespace dd4hep { #include <limits> using namespace std; -using namespace CLHEP; using namespace dd4hep; using namespace dd4hep::sim; diff --git a/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp b/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp index f61171c5c..6ed13a791 100644 --- a/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp +++ b/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp @@ -16,7 +16,6 @@ #include "DDG4/Geant4SensDetAction.inl" #include "DDG4/Factories.h" -//using namespace CLHEP; namespace SomeExperiment { -- GitLab