137 using namespace reco;
160 trackTimeTag = trackTimeTagHandle.
product();
161 trackTimeResoTag = trackTimeResoTagHandle.
product();
165 std::vector<int> pfToPVVector;
166 std::vector<PrimaryVertexAssignment::Quality> pfToPVQualityVector;
168 std::vector<std::vector<int>> pvToPFVector(vertices->size());
169 std::vector<std::vector<const reco::Candidate*>> pvToCandVector(vertices->size());
170 std::vector<std::vector<PrimaryVertexAssignment::Quality>> pvToPFQualityVector(vertices->size());
171 std::vector<float> vertexScoreOriginal(vertices->size());
172 std::vector<float> vertexScore(vertices->size());
174 for (
auto const&
pf : particles) {
175 std::pair<int, PrimaryVertexAssignment::Quality> vtxWithQuality =
176 runAlgo(*vertices,
pf, trackTimeTag, trackTimeResoTag, *jets, *builder);
177 pfToPVVector.push_back(vtxWithQuality.first);
178 pfToPVQualityVector.push_back(vtxWithQuality.second);
182 for (
size_t i = 0;
i < pfToPVVector.size();
i++) {
183 auto pv = pfToPVVector[
i];
184 auto qual = pfToPVQualityVector[
i];
186 pvToPFVector[
pv].push_back(
i);
190 pvToCandVector[
pv].push_back(&particles[
i]);
191 pvToPFQualityVector[
pv].push_back(qual);
196 std::multimap<float, int> scores;
197 for (
unsigned int i = 0;
i < vertices->size();
i++) {
199 vertexScoreOriginal[
i] =
s;
200 scores.insert(std::pair<float, int>(-s, i));
204 std::vector<int> oldToNew(vertices->size()), newToOld(vertices->size());
206 for (
auto const&
idx : scores) {
208 vertexScore[newIdx] = -
idx.first;
209 oldToNew[
idx.second] = newIdx;
210 newToOld[newIdx] =
idx.second;
215 unique_ptr<CandToVertex> pfCandToOriginalVertexOutput(
new CandToVertex(vertices));
216 unique_ptr<CandToVertexQuality> pfCandToOriginalVertexQualityOutput(
new CandToVertexQuality());
220 cand2VertexFiller.insert(particlesHandle, pfToPVVector.begin(), pfToPVVector.end());
221 cand2VertexQualityFiller.insert(particlesHandle, pfToPVQualityVector.begin(), pfToPVQualityVector.end());
223 cand2VertexFiller.fill();
224 cand2VertexQualityFiller.fill();
225 iEvent.
put(
std::move(pfCandToOriginalVertexOutput),
"original");
226 iEvent.
put(
std::move(pfCandToOriginalVertexQualityOutput),
"original");
228 unique_ptr<VertexScore> vertexScoreOriginalOutput(
new VertexScore);
230 vertexScoreOriginalFiller.insert(vertices, vertexScoreOriginal.begin(), vertexScoreOriginal.end());
231 vertexScoreOriginalFiller.fill();
232 iEvent.
put(
std::move(vertexScoreOriginalOutput),
"original");
236 std::vector<int> pfToSortedPVVector;
238 for (
size_t i = 0; i < pfToPVVector.size(); i++) {
239 pfToSortedPVVector.push_back(oldToNew[pfToPVVector[i]]);
244 for (
size_t i = 0; i < vertices->size(); i++) {
245 sortedVerticesOutput->push_back((*vertices)[newToOld[i]]);
248 unique_ptr<CandToVertex> pfCandToVertexOutput(
new CandToVertex(oh));
253 cand2VertexFiller.insert(particlesHandle, pfToSortedPVVector.begin(), pfToSortedPVVector.end());
254 cand2VertexQualityFiller.insert(particlesHandle, pfToPVQualityVector.begin(), pfToPVQualityVector.end());
256 cand2VertexFiller.fill();
257 cand2VertexQualityFiller.fill();
261 unique_ptr<VertexScore> vertexScoreOutput(
new VertexScore);
263 vertexScoreFiller.insert(oh, vertexScore.begin(), vertexScore.end());
264 vertexScoreFiller.fill();
268 unique_ptr<PFCollection> pfCollectionNOPUOriginalOutput(
new PFCollection);
269 unique_ptr<PFCollection> pfCollectionNOPUOutput(
new PFCollection);
270 unique_ptr<PFCollection> pfCollectionPUOriginalOutput(
new PFCollection);
271 unique_ptr<PFCollection> pfCollectionPUOutput(
new PFCollection);
273 for (
size_t i = 0; i < particles.size(); i++) {
274 auto pv = pfToPVVector[
i];
275 auto qual = pfToPVQualityVector[
i];
279 pfCollectionNOPUOutput->push_back(particles[i]);
283 pfCollectionPUOutput->push_back(particles[i]);
287 pfCollectionNOPUOriginalOutput->push_back(particles[i]);
291 pfCollectionPUOriginalOutput->push_back(particles[i]);
294 iEvent.
put(
std::move(pfCollectionNOPUOutput),
"NoPileUp");
298 iEvent.
put(
std::move(pfCollectionNOPUOriginalOutput),
"originalNoPileUp");
300 iEvent.
put(
std::move(pfCollectionPUOriginalOutput),
"originalPileUp");
edm::Association< reco::VertexCollection > CandToVertex
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
PrimaryVertexSorting sortingAlgo_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool produceOriginalMapping_
bool produceSortedVertices_
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::EDGetTokenT< PFCollection > tokenCandidates_
Candidates to be analyzed.
ParticlesCollection PFCollection
bool needsProductsForTiming()
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeTag_
helper::Filler< ValueMap< int > > Filler
edm::ValueMap< float > VertexScore
T const * product() const
float score(const reco::Vertex &pv, const std::vector< const reco::Candidate * > &candidates, bool useMet) const
edm::ValueMap< int > CandToVertexQuality
edm::EDGetTokenT< edm::ValueMap< float > > tokenTrackTimeResoTag_
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
edm::EDGetTokenT< edm::View< reco::Candidate > > tokenJets_
std::pair< int, PrimaryVertexAssignment::Quality > runAlgo(const reco::VertexCollection &vertices, const typename ParticlesCollection::value_type &pf, const edm::ValueMap< float > *trackTimeTag, const edm::ValueMap< float > *trackTimeResoTag, const edm::View< reco::Candidate > &jets, const TransientTrackBuilder &builder)