64 : muonTracksToken_(consumes<edm::
View<
reco::Track>>(iConfig.getParameter<edm::
InputTag>(
"muonTracks"))),
65 otherTracksToken_(consumes<edm::
View<
reco::Track>>(iConfig.getParameter<edm::
InputTag>(
"allTracks"))),
66 nthClosestTrack_(iConfig.getParameter<unsigned int>(
"saveUpToNthClosest")),
67 distancesPutToken_(produces<edm::ValueMap<std::
vector<float>>>()) {}
84 if (!muonTrackCollectionHandle.isValid())
86 auto const& muonTracks = *muonTrackCollectionHandle;
93 if (!allTrackCollectionHandle.isValid())
95 auto const&
allTracks = *allTrackCollectionHandle;
102 unsigned int Nit = muonTracks.size();
104 std::vector<std::vector<float>> v2_dR2;
106 for (
unsigned int iit = 0; iit < Nit; iit++) {
107 const auto& muontrack = muonTracks.ptrAt(iit);
109 std::vector<float> v_dR2;
110 for (
unsigned int iAll = 0; iAll < Nall; iAll++) {
114 v_dR2.push_back(dR2);
119 std::sort(v_dR2.begin(), v_dR2.end(), [](
const float& lhs,
const float& rhs) {
return lhs < rhs; });
122 std::vector<float> reduced_vdR2;
125 std::back_inserter(reduced_vdR2));
126 v2_dR2.push_back(reduced_vdR2);
133 std::unique_ptr<edm::ValueMap<std::vector<float>>> vm_dR2(
new edm::ValueMap<std::vector<float>>());
135 filler.insert(muonTrackCollectionHandle, v2_dR2.begin(), v2_dR2.end());
143 desc.
setComment(
"Produces a value map with all the distances with the other tracks in the event");
145 ->setComment(
"the probe muon tracks");
147 desc.
add<
unsigned int>(
"saveUpToNthClosest", 1)->setComment(
"save the distance only for the nth closest tracks");
edm::EDGetTokenT< edm::View< reco::Track > > otherTracksToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
#define DEFINE_FWK_MODULE(type)
TrackDistanceValueMapProducer(const edm::ParameterSet &)
~TrackDistanceValueMapProducer() override=default
void setComment(std::string const &value)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
edm::EDGetTokenT< edm::View< reco::Track > > muonTracksToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDPutTokenT< edm::ValueMap< std::vector< float > > > distancesPutToken_
unsigned int nthClosestTrack_