Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:39

0001 // -*- C++ -*-
0002 //
0003 // Package:    SimTracker/TrackAssociatorProducers
0004 // Class:      TrackAssociatorByChi2Producer
0005 //
0006 /**\class TrackAssociatorByChi2Producer TrackAssociatorByChi2Producer.cc SimTracker/TrackAssociatorProducers/plugins/TrackAssociatorByChi2Producer.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Christopher Jones
0015 //         Created:  Tue, 06 Jan 2015 16:13:00 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
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 // class declaration
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   // ----------member data ---------------------------
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 // constructors and destructor
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 // member functions
0076 //
0077 
0078 // ------------ method called to produce the data  ------------
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 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0093 void TrackAssociatorByChi2Producer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0094   //The following says we do not know what parameters are allowed so do no validation
0095   // Please change this to state exactly what you do use, even if it is no parameters
0096   edm::ParameterSetDescription desc;
0097   desc.setUnknown();
0098   descriptions.addDefault(desc);
0099 }
0100 
0101 //define this as a plug-in
0102 DEFINE_FWK_MODULE(TrackAssociatorByChi2Producer);