Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed CMS deprecation warnings from MagneticField/Engine #35672

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions MagneticField/Engine/test/queryField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -29,19 +29,16 @@ using namespace edm;
using namespace Geom;
using namespace std;

class queryField : public edm::EDAnalyzer {
class queryField : public edm::one::EDAnalyzer<> {
public:
queryField(const edm::ParameterSet& pset) {}
queryField(const edm::ParameterSet&) : m_fieldToken(esConsumes()) {}

~queryField() {}
~queryField() override {}

virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) {
ESHandle<MagneticField> magfield;
setup.get<IdealMagneticFieldRecord>().get(magfield);
void analyze(const edm::Event& event, const edm::EventSetup& setup) final {
auto const& field = setup.getData(m_fieldToken);

field = magfield.product();

cout << "Field Nominal Value: " << field->nominalValue() << endl;
cout << "Field Nominal Value: " << field.nominalValue() << endl;

double x, y, z;

Expand All @@ -53,12 +50,12 @@ class queryField : public edm::EDAnalyzer {

GlobalPoint g(x, y, z);

cout << "At R=" << g.perp() << " phi=" << g.phi() << " B=" << field->inTesla(g) << endl;
cout << "At R=" << g.perp() << " phi=" << g.phi() << " B=" << field.inTesla(g) << endl;
}
}

private:
const MagneticField* field;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_fieldToken;
};

DEFINE_FWK_MODULE(queryField);
16 changes: 7 additions & 9 deletions MagneticField/Engine/test/testMagneticField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <memory>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -52,9 +52,9 @@ using namespace edm;
using namespace Geom;
using namespace std;

class testMagneticField : public edm::EDAnalyzer {
class testMagneticField : public edm::one::EDAnalyzer<> {
public:
testMagneticField(const edm::ParameterSet& pset) {
testMagneticField(const edm::ParameterSet& pset) : fieldToken(esConsumes()) {
// verbose::debugOut = true;
outputFile = pset.getUntrackedParameter<string>("outputTable", "");
inputFile = pset.getUntrackedParameter<string>("inputTable", "");
Expand All @@ -72,15 +72,12 @@ class testMagneticField : public edm::EDAnalyzer {
maxZ = pset.getUntrackedParameter<double>("maxZ", 2400);
}

~testMagneticField() {}
~testMagneticField() override {}

void go(GlobalPoint g) { std::cout << "At: " << g << " phi=" << g.phi() << " B= " << field->inTesla(g) << std::endl; }

virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) {
ESHandle<MagneticField> magfield;
setup.get<IdealMagneticFieldRecord>().get(magfield);

field = magfield.product();
void analyze(const edm::Event& event, const edm::EventSetup& setup) final {
field = &setup.getData(fieldToken);

std::cout << "Nominal Field " << field->nominalValue() << "\n" << std::endl;

Expand Down Expand Up @@ -131,6 +128,7 @@ class testMagneticField : public edm::EDAnalyzer {
void compareSectorTables(string file);

private:
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> fieldToken;
const MagneticField* field;
string inputFile;
string inputFileType;
Expand Down