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:      TrackAssociatorByPositionProducer
0005 //
0006 /**\class TrackAssociatorByPositionProducer TrackAssociatorByPositionProducer.cc SimTracker/TrackAssociatorProducers/plugins/TrackAssociatorByPositionProducer.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Christopher Jones
0015 //         Created:  Mon, 05 Jan 2015 22:05:57 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 "TrackAssociatorByPositionImpl.h"
0032 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
0033 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0034 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0035 
0036 //
0037 // class declaration
0038 //
0039 using SimHitTPAssociationList = TrackAssociatorByPositionImpl::SimHitTPAssociationList;
0040 
0041 class TrackAssociatorByPositionProducer : public edm::global::EDProducer<> {
0042 public:
0043   explicit TrackAssociatorByPositionProducer(const edm::ParameterSet&);
0044   ~TrackAssociatorByPositionProducer() override = default;
0045 
0046   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0047 
0048 private:
0049   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0050 
0051   // ----------member data ---------------------------
0052   edm::EDGetTokenT<SimHitTPAssociationList> theSimHitTpMapToken;
0053   edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;
0054   edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> theGeometryToken;
0055   edm::EDPutTokenT<reco::TrackToTrackingParticleAssociator> thePutToken;
0056   double theQminCut;
0057   double theQCut;
0058   double thePositionMinimumDistance;
0059   TrackAssociatorByPositionImpl::Method theMethod;
0060   bool theMinIfNoMatch;
0061   bool theConsiderAllSimHits;
0062 };
0063 
0064 //
0065 // static data member definitions
0066 //
0067 static TrackAssociatorByPositionImpl::Method parseMethodName(const std::string& meth) {
0068   if (meth == "chi2") {
0069     return TrackAssociatorByPositionImpl::Method::chi2;
0070   } else if (meth == "dist") {
0071     return TrackAssociatorByPositionImpl::Method::dist;
0072   } else if (meth == "momdr") {
0073     return TrackAssociatorByPositionImpl::Method::momdr;
0074   } else if (meth == "posdr") {
0075     return TrackAssociatorByPositionImpl::Method::posdr;
0076   } else {
0077     throw cms::Exception("BadParameterName") << meth << " TrackAssociatorByPostionImpl::Method name not recognized.";
0078   }
0079 }
0080 
0081 //
0082 // constructors and destructor
0083 //
0084 TrackAssociatorByPositionProducer::TrackAssociatorByPositionProducer(const edm::ParameterSet& iConfig)
0085     : theSimHitTpMapToken{consumes<SimHitTPAssociationList>(iConfig.getParameter<edm::InputTag>("simHitTpMapTag"))},
0086       thePropagatorToken{esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("propagator")))},
0087       theGeometryToken{esConsumes()},
0088       thePutToken{produces<reco::TrackToTrackingParticleAssociator>()},
0089       theQminCut{iConfig.getParameter<double>("QminCut")},
0090       theQCut{iConfig.getParameter<double>("QCut")},
0091       thePositionMinimumDistance{iConfig.getParameter<double>("positionMinimumDistance")},
0092       theMethod{parseMethodName(iConfig.getParameter<std::string>("method"))},
0093       theMinIfNoMatch{iConfig.getParameter<bool>("MinIfNoMatch")},
0094       theConsiderAllSimHits{iConfig.getParameter<bool>("ConsiderAllSimHits")} {}
0095 
0096 //
0097 // member functions
0098 //
0099 
0100 // ------------ method called to produce the data  ------------
0101 void TrackAssociatorByPositionProducer::produce(edm::StreamID,
0102                                                 edm::Event& iEvent,
0103                                                 const edm::EventSetup& iSetup) const {
0104   iEvent.emplace(thePutToken,
0105                  std::make_unique<TrackAssociatorByPositionImpl>(iEvent.productGetter(),
0106                                                                  &iSetup.getData(theGeometryToken),
0107                                                                  &iSetup.getData(thePropagatorToken),
0108                                                                  &iEvent.get(theSimHitTpMapToken),
0109                                                                  theQminCut,
0110                                                                  theQCut,
0111                                                                  thePositionMinimumDistance,
0112                                                                  theMethod,
0113                                                                  theMinIfNoMatch,
0114                                                                  theConsiderAllSimHits));
0115 }
0116 
0117 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0118 void TrackAssociatorByPositionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0119   //The following says we do not know what parameters are allowed so do no validation
0120   // Please change this to state exactly what you do use, even if it is no parameters
0121   edm::ParameterSetDescription desc;
0122   desc.setUnknown();
0123   descriptions.addDefault(desc);
0124 }
0125 
0126 //define this as a plug-in
0127 DEFINE_FWK_MODULE(TrackAssociatorByPositionProducer);