File indexing completed on 2024-04-06 12:31:02
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 "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
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
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
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
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
0098
0099
0100
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
0118 void TrackAssociatorByPositionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0119
0120
0121 edm::ParameterSetDescription desc;
0122 desc.setUnknown();
0123 descriptions.addDefault(desc);
0124 }
0125
0126
0127 DEFINE_FWK_MODULE(TrackAssociatorByPositionProducer);