Skip to content

Commit

Permalink
Get MagneticField in beginRun()
Browse files Browse the repository at this point in the history
Given that the ESGetToken is declared such that MagneticField is consumed in beginRun, the product must be read from EventSetup always there. Alternative would be to have two tokens (one for beginRun and another for produce), but always reading in beginRun is simpler and along the planned evolution of this code.
  • Loading branch information
makortel authored Jul 14, 2021
1 parent 766e76f commit 9b6168c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion SimG4Core/Application/src/RunManagerMTWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ void RunManagerMTWorker::beginRun(edm::EventSetup const& es) {
for (auto& maker : m_sdMakers) {
maker.second->beginRun(es);
}
if (m_pUseMagneticField) {
m_pMagField = &es.getData(m_MagField);
}
}

void RunManagerMTWorker::endRun() {
Expand Down Expand Up @@ -312,7 +315,6 @@ void RunManagerMTWorker::initializeG4(RunManagerMT* runManagerMaster, const edm:
if (m_pUseMagneticField) {
const GlobalPoint g(0.f, 0.f, 0.f);

m_pMagField = &es.getData(m_MagField);
sim::FieldBuilder fieldBuilder(m_pMagField, m_pField);

CMSFieldManager* fieldManager = new CMSFieldManager();
Expand Down

0 comments on commit 9b6168c

Please sign in to comment.