Skip to content

Commit

Permalink
migrate CosmicGenFilterHelix to esConsumes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Mar 9, 2021
1 parent c0eb377 commit c6467af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
22 changes: 5 additions & 17 deletions GeneratorInterface/GenFilters/plugins/CosmicGenFilterHelix.cc
Expand Up @@ -8,19 +8,12 @@
// user include files
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/Common/interface/Handle.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"

#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
#include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
#include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"

#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "CommonTools/Utils/interface/TFileDirectory.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -38,9 +31,10 @@

///////////////////////////////////////////////////////////////////////////////////////////////////
CosmicGenFilterHelix::CosmicGenFilterHelix(const edm::ParameterSet &cfg)
: theIds(cfg.getParameter<std::vector<int> >("pdgIds")),
: theMFToken(esConsumes()),
thePropToken(esConsumes(edm::ESInputTag("", cfg.getParameter<std::string>("propagator")))),
theIds(cfg.getParameter<std::vector<int> >("pdgIds")),
theCharges(cfg.getParameter<std::vector<int> >("charges")),
thePropagatorName(cfg.getParameter<std::string>("propagator")),
theMinP2(cfg.getParameter<double>("minP") * cfg.getParameter<double>("minP")),
theMinPt2(cfg.getParameter<double>("minPt") * cfg.getParameter<double>("minPt")),
theDoMonitor(cfg.getUntrackedParameter<bool>("doMonitor")) {
Expand Down Expand Up @@ -345,18 +339,12 @@ bool CosmicGenFilterHelix::charge(int id, int &charge) const {

//_________________________________________________________________________________________________
const MagneticField *CosmicGenFilterHelix::getMagneticField(const edm::EventSetup &setup) const {
edm::ESHandle<MagneticField> fieldHandle;
setup.get<IdealMagneticFieldRecord>().get(fieldHandle);

return fieldHandle.product();
return &setup.getData(theMFToken);
}

//_________________________________________________________________________________________________
const Propagator *CosmicGenFilterHelix::getPropagator(const edm::EventSetup &setup) const {
edm::ESHandle<Propagator> propHandle;
setup.get<TrackingComponentsRecord>().get(thePropagatorName, propHandle);

const Propagator *prop = propHandle.product();
const Propagator *prop = &setup.getData(thePropToken);
if (!dynamic_cast<const SteppingHelixPropagator *>(prop)) {
edm::LogWarning("BadConfig") << "@SUB=CosmicGenFilterHelix::getPropagator"
<< "Not a SteppingHelixPropagator!";
Expand Down
15 changes: 10 additions & 5 deletions GeneratorInterface/GenFilters/plugins/CosmicGenFilterHelix.h
Expand Up @@ -29,6 +29,9 @@

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include <TObjArray.h>

#include <vector>
Expand Down Expand Up @@ -59,12 +62,14 @@ class CosmicGenFilterHelix : public edm::one::EDFilter<edm::one::SharedResources
const Propagator *getPropagator(const edm::EventSetup &setup) const;
// ----------member data ---------------------------

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMFToken;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropToken;

edm::EDGetTokenT<edm::HepMCProduct> theSrcToken;
const std::vector<int> theIds; /// requested Ids
const std::vector<int> theCharges; /// charges, parallel to theIds
const std::string thePropagatorName; // tag to get propagator from ESetup
const double theMinP2; /// minimal momentum^2 after propagation to cylinder
const double theMinPt2; /// minimal transverse^2 momentum after propagation to cylinder
const std::vector<int> theIds; /// requested Ids
const std::vector<int> theCharges; /// charges, parallel to theIds
const double theMinP2; /// minimal momentum^2 after propagation to cylinder
const double theMinPt2; /// minimal transverse^2 momentum after propagation to cylinder

Cylinder::ConstCylinderPointer theTargetCylinder; /// target cylinder, around z-axis
Plane::ConstPlanePointer theTargetPlaneMin; /// plane closing cylinder at 'negative' side
Expand Down

0 comments on commit c6467af

Please sign in to comment.