diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index a196110598721..e9da557de09a6 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -100,16 +100,22 @@ StepperParam = cms.PSet( VacRegions = cms.vstring(), # VacRegions = cms.vstring('DefaultRegionForTheWorld','BeamPipeVacuum','BeamPipeOutside'), - MaximumEpsilonStep = cms.untracked.double(0.01), ## in mm + EnergyThTracker = cms.double(100000), ## in GeV + RmaxTracker = cms.double(8000), ## in mm + ZmaxTracker = cms.double(11000), ## in mm + MaximumEpsilonStep = cms.untracked.double(0.01), DeltaOneStep = cms.double(0.001), ## in mm + DeltaOneStepTracker = cms.double(1e-4),## in mm MaximumLoopCounts = cms.untracked.double(1000.0), - DeltaChord = cms.double(0.001), ## in mm - MinStep = cms.double(0.1), ## in mm + DeltaChord = cms.double(0.001), ## in mm + DeltaChordTracker = cms.double(0.001), ## in mm + MinStep = cms.double(0.1), ## in mm DeltaIntersectionAndOneStep = cms.untracked.double(-1.0), - DeltaIntersection = cms.double(0.0001),## in mm + DeltaIntersection = cms.double(0.0001), ## in mm + DeltaIntersectionTracker = cms.double(1e-6),## in mm MaxStep = cms.double(150.), ## in cm - MinimumEpsilonStep = cms.untracked.double(1e-05), ## in mm - EnergyThSimple = cms.double(0.015), ## in GeV + MinimumEpsilonStep = cms.untracked.double(1e-05), + EnergyThSimple = cms.double(0.015), ## in GeV DeltaChordSimple = cms.double(0.1), ## in mm DeltaOneStepSimple = cms.double(0.1), ## in mm DeltaIntersectionSimple = cms.double(0.01), ## in mm diff --git a/SimG4Core/Application/src/RunManagerMTWorker.cc b/SimG4Core/Application/src/RunManagerMTWorker.cc index e1655796b1777..bd228e42ab983 100644 --- a/SimG4Core/Application/src/RunManagerMTWorker.cc +++ b/SimG4Core/Application/src/RunManagerMTWorker.cc @@ -477,7 +477,7 @@ std::unique_ptr RunManagerMTWorker::produce(const edm::Event& inpevt if (!(m_tls && m_tls->threadInitialized)) { edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::produce(): stream " << inpevt.streamID() << " thread " << getThreadIndex() - << " initializing in the produce(..) method - there is a problem"; + << " Geant4 initialisation for this thread"; initializeG4(&runManagerMaster, es); m_tls->threadInitialized = true; } diff --git a/SimG4Core/MagneticField/interface/CMSFieldManager.h b/SimG4Core/MagneticField/interface/CMSFieldManager.h index d8d11c3af39d3..b56ac0389ae6b 100644 --- a/SimG4Core/MagneticField/interface/CMSFieldManager.h +++ b/SimG4Core/MagneticField/interface/CMSFieldManager.h @@ -39,16 +39,18 @@ class CMSFieldManager : public G4FieldManager { double delta, G4PropagatorInField *); - void SetMonopoleTracking(G4bool); + void setMonopoleTracking(G4bool); + + CMSFieldManager(const CMSFieldManager &) = delete; + CMSFieldManager &operator=(const CMSFieldManager &) = delete; private: bool isInsideVacuum(const G4Track *); + bool isInsideTracker(const G4Track *); void setDefaultChordFinder(); + void setChordFinderForTracker(); void setChordFinderForVacuum(); - CMSFieldManager(const CMSFieldManager &) = delete; - CMSFieldManager &operator=(const CMSFieldManager &) = delete; - std::unique_ptr theField; G4ChordFinder *m_currChordFinder; @@ -60,15 +62,22 @@ class CMSFieldManager : public G4FieldManager { std::vector m_regions; double m_dChord; + double m_dChordTracker; double m_dOneStep; + double m_dOneStepTracker; double m_dIntersection; + double m_dInterTracker; + double m_Rmax2; + double m_Zmax; double m_stepMax; + double m_energyThTracker; double m_energyThreshold; double m_dChordSimple; double m_dOneStepSimple; double m_dIntersectionSimple; double m_stepMaxSimple; + bool m_cfTracker; bool m_cfVacuum; }; #endif diff --git a/SimG4Core/MagneticField/src/CMSFieldManager.cc b/SimG4Core/MagneticField/src/CMSFieldManager.cc index 9895e2d236bdc..2c07ab83a256f 100644 --- a/SimG4Core/MagneticField/src/CMSFieldManager.cc +++ b/SimG4Core/MagneticField/src/CMSFieldManager.cc @@ -17,14 +17,21 @@ CMSFieldManager::CMSFieldManager() m_chordFinderMonopole(nullptr), m_propagator(nullptr), m_dChord(0.001), + m_dChordTracker(0.001), m_dOneStep(0.001), + m_dOneStepTracker(0.0001), m_dIntersection(0.0001), + m_dInterTracker(1e-6), + m_Rmax2(1.e+6), + m_Zmax(3.e+3), m_stepMax(1000000.), + m_energyThTracker(1.e+7), m_energyThreshold(0.0), m_dChordSimple(0.1), m_dOneStepSimple(0.1), m_dIntersectionSimple(0.01), m_stepMaxSimple(1000.), + m_cfTracker(false), m_cfVacuum(false) {} CMSFieldManager::~CMSFieldManager() { @@ -52,13 +59,20 @@ void CMSFieldManager::InitialiseForVolume(const edm::ParameterSet &p, // double m_dChord = p.getParameter("DeltaChord") * CLHEP::mm; + m_dChordTracker = p.getParameter("DeltaChord") * CLHEP::mm; m_dOneStep = p.getParameter("DeltaOneStep") * CLHEP::mm; + m_dOneStepTracker = p.getParameter("DeltaOneStepTracker") * CLHEP::mm; m_dIntersection = p.getParameter("DeltaIntersection") * CLHEP::mm; + m_dInterTracker = p.getParameter("DeltaIntersectionTracker") * CLHEP::mm; m_stepMax = p.getParameter("MaxStep") * CLHEP::cm; m_energyThreshold = p.getParameter("EnergyThSimple") * CLHEP::GeV; + m_energyThTracker = p.getParameter("EnergyThTracker") * CLHEP::GeV; + + double rmax = p.getParameter("RmaxTracker") * CLHEP::mm; + m_Rmax2 = rmax * rmax; + m_Zmax = p.getParameter("ZmaxTracker") * CLHEP::mm; - // double m_dChordSimple = p.getParameter("DeltaChordSimple") * CLHEP::mm; m_dOneStepSimple = p.getParameter("DeltaOneStepSimple") * CLHEP::mm; m_dIntersectionSimple = p.getParameter("DeltaIntersectionSimple") * CLHEP::mm; @@ -77,7 +91,9 @@ void CMSFieldManager::InitialiseForVolume(const edm::ParameterSet &p, << " DeltaChord " << m_dChord << " mm\n" << " DeltaOneStep " << m_dOneStep << " mm\n" << " DeltaIntersection " << m_dIntersection << " mm\n" - << " EnergyThreshold " << m_energyThreshold << " MeV\n" + << " DeltaInterTracker " << m_dInterTracker << " mm\n" + << " EnergyThresholdSimple " << m_energyThreshold / CLHEP::MeV << " MeV\n" + << " EnergyThresholdTracker " << m_energyThTracker / CLHEP::MeV << " MeV\n" << " DeltaChordSimple " << m_dChordSimple << " mm\n" << " DeltaOneStepSimple " << m_dOneStepSimple << " mm\n" << " DeltaIntersectionSimple " << m_dIntersectionSimple << " mm\n" @@ -87,7 +103,6 @@ void CMSFieldManager::InitialiseForVolume(const edm::ParameterSet &p, m_chordFinder = cf; m_chordFinderMonopole = cfmon; - // m_chordFinder->SetDeltaChord(dChord); m_chordFinderMonopole->SetDeltaChord(m_dChord); // initialisation of field manager @@ -102,8 +117,8 @@ void CMSFieldManager::InitialiseForVolume(const edm::ParameterSet &p, pf->SetMinimumEpsilonStep(minEpsStep); pf->SetMaximumEpsilonStep(maxEpsStep); - // initial initialisation the default chord finder is defined - SetMonopoleTracking(false); + // initial initialisation the default chord finder + setMonopoleTracking(false); // define regions std::vector rnames = p.getParameter>("VacRegions"); @@ -124,21 +139,26 @@ void CMSFieldManager::InitialiseForVolume(const edm::ParameterSet &p, void CMSFieldManager::ConfigureForTrack(const G4Track *track) { // run time parameters per track - if ((track->GetKineticEnergy() <= m_energyThreshold && track->GetParentID() > 0) || isInsideVacuum(track)) { + if (track->GetKineticEnergy() > m_energyThTracker && isInsideTracker(track)) { + if (!m_cfTracker) { + setChordFinderForTracker(); + } + + } else if ((track->GetKineticEnergy() <= m_energyThreshold && track->GetParentID() > 0) || isInsideVacuum(track)) { if (!m_cfVacuum) { setChordFinderForVacuum(); } - } else if (m_cfVacuum) { + } else if (m_cfTracker || m_cfVacuum) { // restore defaults setDefaultChordFinder(); } } -void CMSFieldManager::SetMonopoleTracking(G4bool flag) { +void CMSFieldManager::setMonopoleTracking(G4bool flag) { if (flag) { if (m_currChordFinder != m_chordFinderMonopole) { - if (m_cfVacuum) { + if (m_cfTracker || m_cfVacuum) { setDefaultChordFinder(); } m_currChordFinder = m_chordFinderMonopole; @@ -163,20 +183,47 @@ bool CMSFieldManager::isInsideVacuum(const G4Track *track) { return false; } +bool CMSFieldManager::isInsideTracker(const G4Track *track) { + const G4ThreeVector &pos = track->GetPosition(); + const double x = pos.x(); + const double y = pos.y(); + return (x * x + y * y < m_Rmax2 && std::abs(pos.z()) < m_Zmax); +} + void CMSFieldManager::setDefaultChordFinder() { - m_currChordFinder = m_chordFinder; + if (m_currChordFinder != m_chordFinder) { + m_currChordFinder = m_chordFinder; + SetChordFinder(m_currChordFinder); + } m_currChordFinder->SetDeltaChord(m_dChord); - SetChordFinder(m_currChordFinder); SetDeltaOneStep(m_dOneStep); SetDeltaIntersection(m_dIntersection); m_propagator->SetLargestAcceptableStep(m_stepMax); + m_cfVacuum = m_cfTracker = false; +} + +void CMSFieldManager::setChordFinderForTracker() { + if (m_currChordFinder != m_chordFinder) { + m_currChordFinder = m_chordFinder; + SetChordFinder(m_currChordFinder); + } + m_currChordFinder->SetDeltaChord(m_dChordTracker); + SetDeltaOneStep(m_dOneStepTracker); + SetDeltaIntersection(m_dInterTracker); + m_propagator->SetLargestAcceptableStep(m_stepMax); m_cfVacuum = false; + m_cfTracker = true; } void CMSFieldManager::setChordFinderForVacuum() { + if (m_currChordFinder != m_chordFinder) { + m_currChordFinder = m_chordFinder; + SetChordFinder(m_currChordFinder); + } m_currChordFinder->SetDeltaChord(m_dChordSimple); SetDeltaOneStep(m_dOneStepSimple); SetDeltaIntersection(m_dIntersectionSimple); m_propagator->SetLargestAcceptableStep(m_stepMaxSimple); m_cfVacuum = true; + m_cfTracker = false; } diff --git a/SimG4Core/PhysicsLists/src/MonopoleTransportation.cc b/SimG4Core/PhysicsLists/src/MonopoleTransportation.cc index 50b7377fe456e..afb832020ee07 100644 --- a/SimG4Core/PhysicsLists/src/MonopoleTransportation.cc +++ b/SimG4Core/PhysicsLists/src/MonopoleTransportation.cc @@ -104,7 +104,7 @@ G4double MonopoleTransportation::AlongStepGetPhysicalInteractionLength(const G4T G4double& currentSafety, G4GPILSelection* selection) { // change to monopole equation - fieldMgrCMS->SetMonopoleTracking(true); + fieldMgrCMS->setMonopoleTracking(true); G4double geometryStepLength, newSafety; fParticleIsLooping = false; @@ -515,7 +515,7 @@ G4VParticleChange* MonopoleTransportation::PostStepDoIt(const G4Track& track, co fParticleChange.SetTouchableHandle(retCurrentTouchable); // change to normal equation - fieldMgrCMS->SetMonopoleTracking(false); + fieldMgrCMS->setMonopoleTracking(false); return &fParticleChange; }