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

Modernized TransientTrackBuilderESProducer #27002

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -12,18 +12,17 @@
using namespace edm;

TransientTrackBuilderESProducer::TransientTrackBuilderESProducer(const edm::ParameterSet& p) {
std::string myname = p.getParameter<std::string>("ComponentName");
pset_ = p;
setWhatProduced(this, myname);
setWhatProduced(this, p.getParameter<std::string>("ComponentName")).setConsumes(magToken_).setConsumes(geomToken_);
}

TransientTrackBuilderESProducer::~TransientTrackBuilderESProducer() {}

std::unique_ptr<TransientTrackBuilder> TransientTrackBuilderESProducer::produce(const TransientTrackRecord& iRecord) {
edm::ESHandle<MagneticField> magfield;
iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield);
edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
iRecord.getRecord<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
return std::make_unique<TransientTrackBuilder>(&iRecord.get(magToken_), iRecord.getHandle(geomToken_));
}

void TransientTrackBuilderESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("ComponentName", "TransientTrackBuilder")
->setComment("data label to use when getting the data product");

return std::make_unique<TransientTrackBuilder>(magfield.product(), theTrackingGeometry);
descriptions.addDefault(desc);
}
Expand Up @@ -7,16 +7,22 @@
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"

#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

#include <memory>

class TransientTrackBuilderESProducer : public edm::ESProducer {
public:
TransientTrackBuilderESProducer(const edm::ParameterSet &p);
~TransientTrackBuilderESProducer() override;

std::unique_ptr<TransientTrackBuilder> produce(const TransientTrackRecord &);

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
edm::ParameterSet pset_;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magToken_;
edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> geomToken_;
};

#endif