File indexing completed on 2024-04-06 12:31:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/global/EDProducer.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030
0031 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
0032 #include "SimDataFormats/Associations/interface/TrackToGenParticleAssociator.h"
0033 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociatorBaseImpl.h"
0034
0035 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0036
0037 #include "TrackAssociatorByChi2Impl.h"
0038 #include "TrackGenAssociatorByChi2Impl.h"
0039
0040
0041
0042
0043
0044 class TrackAssociatorByChi2Producer : public edm::global::EDProducer<> {
0045 public:
0046 explicit TrackAssociatorByChi2Producer(const edm::ParameterSet&);
0047 ~TrackAssociatorByChi2Producer() override = default;
0048
0049 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0050
0051 private:
0052 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0053
0054
0055 edm::EDGetTokenT<reco::BeamSpot> bsToken_;
0056 edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0057 edm::EDPutTokenT<reco::TrackToTrackingParticleAssociator> tpPutToken_;
0058 edm::EDPutTokenT<reco::TrackToGenParticleAssociator> genPutToken_;
0059 const double chi2cut_;
0060 const bool onlyDiagonal_;
0061 };
0062
0063
0064
0065
0066 TrackAssociatorByChi2Producer::TrackAssociatorByChi2Producer(const edm::ParameterSet& iConfig)
0067 : bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
0068 magFieldToken_(esConsumes()),
0069 tpPutToken_(produces<reco::TrackToTrackingParticleAssociator>()),
0070 genPutToken_(produces<reco::TrackToGenParticleAssociator>()),
0071 chi2cut_(iConfig.getParameter<double>("chi2cut")),
0072 onlyDiagonal_(iConfig.getParameter<bool>("onlyDiagonal")) {}
0073
0074
0075
0076
0077
0078
0079 void TrackAssociatorByChi2Producer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0080 using namespace edm;
0081
0082 auto const& magField = iSetup.getData(magFieldToken_);
0083 auto const& beamSpot = iEvent.get(bsToken_);
0084
0085 iEvent.emplace(
0086 tpPutToken_,
0087 std::make_unique<TrackAssociatorByChi2Impl>(iEvent.productGetter(), magField, beamSpot, chi2cut_, onlyDiagonal_));
0088 iEvent.emplace(genPutToken_,
0089 std::make_unique<TrackGenAssociatorByChi2Impl>(magField, beamSpot, chi2cut_, onlyDiagonal_));
0090 }
0091
0092
0093 void TrackAssociatorByChi2Producer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0094
0095
0096 edm::ParameterSetDescription desc;
0097 desc.setUnknown();
0098 descriptions.addDefault(desc);
0099 }
0100
0101
0102 DEFINE_FWK_MODULE(TrackAssociatorByChi2Producer);