CMS 3D CMS Logo

TrackAssociatorByChi2Producer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SimTracker/TrackAssociatorProducers
4 // Class: TrackAssociatorByChi2Producer
5 //
13 //
14 // Original Author: Christopher Jones
15 // Created: Tue, 06 Jan 2015 16:13:00 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
30 
34 
36 
39 
40 //
41 // class declaration
42 //
43 
45 public:
47  ~TrackAssociatorByChi2Producer() override = default;
48 
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 private:
52  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
53 
54  // ----------member data ---------------------------
59  const double chi2cut_;
60  const bool onlyDiagonal_;
61 };
62 
63 //
64 // constructors and destructor
65 //
67  : bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
68  magFieldToken_(esConsumes()),
69  tpPutToken_(produces<reco::TrackToTrackingParticleAssociator>()),
70  genPutToken_(produces<reco::TrackToGenParticleAssociator>()),
71  chi2cut_(iConfig.getParameter<double>("chi2cut")),
72  onlyDiagonal_(iConfig.getParameter<bool>("onlyDiagonal")) {}
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called to produce the data ------------
80  using namespace edm;
81 
82  auto const& magField = iSetup.getData(magFieldToken_);
83  auto const& beamSpot = iEvent.get(bsToken_);
84 
85  iEvent.emplace(
87  std::make_unique<TrackAssociatorByChi2Impl>(iEvent.productGetter(), magField, beamSpot, chi2cut_, onlyDiagonal_));
88  iEvent.emplace(genPutToken_,
89  std::make_unique<TrackGenAssociatorByChi2Impl>(magField, beamSpot, chi2cut_, onlyDiagonal_));
90 }
91 
92 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
94  //The following says we do not know what parameters are allowed so do no validation
95  // Please change this to state exactly what you do use, even if it is no parameters
97  desc.setUnknown();
98  descriptions.addDefault(desc);
99 }
100 
101 //define this as a plug-in
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
edm::EDPutTokenT< reco::TrackToTrackingParticleAssociator > tpPutToken_
TrackAssociatorByChi2Producer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
~TrackAssociatorByChi2Producer() override=default
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDPutTokenT< reco::TrackToGenParticleAssociator > genPutToken_
fixed size matrix
HLT enums.
edm::EDGetTokenT< reco::BeamSpot > bsToken_