66 nthClosestTrack_(iConfig.getParameter<unsigned
int>(
"saveUpToNthClosest")),
84 if (!muonTrackCollectionHandle.isValid())
86 auto const&
muonTracks = *muonTrackCollectionHandle;
93 if (!allTrackCollectionHandle.isValid())
95 auto const&
allTracks = *allTrackCollectionHandle;
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++) {
111 const auto& recotrack =
allTracks.ptrAt(iAll);
112 const float dR2 =
::deltaR2(*muontrack, *recotrack);
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)
TrackDistanceValueMapProducer(const edm::ParameterSet &)
~TrackDistanceValueMapProducer() override=default
edm::EDGetTokenT< edm::View< reco::Track > > muonTracksToken_
#define DEFINE_FWK_MODULE(type)
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_