11 #include <boost/iterator/transform_iterator.hpp>
60 #include "fastjet/JetDefinition.hh"
61 #include "fastjet/ClusterSequence.hh"
62 #include "fastjet/PseudoJet.hh"
68 typedef std::shared_ptr<fastjet::JetDefinition>
JetDefPtr;
73 class VertexInfo :
public fastjet::PseudoJet::UserInfoBase {
77 inline const int vertexIndex()
const {
return m_vertexIndex; }
84 struct RefToBaseLess {
86 return r1.id() <
r2.id() || (
r1.id() ==
r2.id() &&
r1.key() <
r2.key());
100 template <
class IPTI,
class VTX>
106 typedef std::vector<TemplatedSecondaryVertexTagInfo<IPTI, VTX> >
Product;
114 template <
class CONTAINER>
116 const std::vector<fastjet::PseudoJet> &matchedJets,
117 std::vector<int> &matchedIndices,
121 std::vector<int> &matchedIndices);
122 void matchSubjets(
const std::vector<int> &groomedIndices,
125 std::vector<std::vector<int> > &matchedIndices);
128 std::vector<std::vector<int> > &matchedIndices);
139 CONSTRAINT_PV_PRIMARIES_IN_FIT
181 :
pv(
pv), direction(direction), withPVError(withPVError), minTrackWeight(minTrackWeight) {}
203 template <
class IPTI,
class VTX>
207 return CONSTRAINT_NONE;
208 else if (
name ==
"BeamSpot")
209 return CONSTRAINT_BEAMSPOT;
210 else if (
name ==
"BeamSpot+PVPosition")
211 return CONSTRAINT_PV_BEAMSPOT_SIZE;
212 else if (
name ==
"BeamSpotZ+PVErrorScaledXY")
213 return CONSTRAINT_PV_BS_Z_ERRORS_SCALED;
214 else if (
name ==
"PVErrorScaled")
215 return CONSTRAINT_PV_ERROR_SCALED;
216 else if (
name ==
"BeamSpot+PVTracksInFit")
217 return CONSTRAINT_PV_PRIMARIES_IN_FIT;
219 throw cms::Exception(
"InvalidArgument") <<
"TemplatedSecondaryVertexProducer: ``constraint'' parameter "
221 <<
name <<
"\" not understood." << std::endl;
225 if (
name ==
"AlwaysWithGhostTrack")
227 else if (
name ==
"SingleTracksWithGhostTrack")
229 else if (
name ==
"RefitGhostTrackWithVertices")
232 throw cms::Exception(
"InvalidArgument") <<
"TemplatedSecondaryVertexProducer: ``fitType'' "
236 "GhostTrackVertexFinder settings not "
241 template <
class IPTI,
class VTX>
246 constraintScaling(1.0),
248 useGhostTrack(vtxRecoPSet.getParameter<
std::
string>(
"finder") ==
"gtvr"),
249 withPVError(
params.getParameter<
bool>(
"usePVError")),
250 minTrackWeight(
params.getParameter<double>(
"minimumTrackWeight")),
261 if (
params.existsAs<
bool>(
"useExternalSV"))
277 (
params.existsAs<
double>(
"ghostRescaling") ?
params.getParameter<
double>(
"ghostRescaling") : 1
e-18);
279 (
params.existsAs<
double>(
"relPtTolerance")
280 ?
params.getParameter<
double>(
"relPtTolerance")
292 <<
", use CambridgeAachen | Kt | AntiKt" << std::endl;
308 template <
class IPTI,
class VTX>
311 template <
class IPTI,
class VTX>
316 typedef std::map<const Track *, TransientTrack> TransientTrackMap;
327 event.getByToken(token_extSVCollection, extSecVertex);
332 event.getByToken(token_fatJets, fatJetsHandle);
333 if (useGroomedFatJets) {
334 event.getByToken(token_groomedFatJets, groomedFatJetsHandle);
336 if (groomedFatJetsHandle->size() > fatJetsHandle->size())
338 <<
"There are more groomed (" << groomedFatJetsHandle->size() <<
") than original fat jets ("
339 << fatJetsHandle->size() <<
"). Please check that the two jet collections belong to each other.";
343 if (!token_weights.isUninitialized())
344 event.getByToken(token_weights, weightsHandle);
347 unsigned int bsCovSrc[7] = {
350 double sigmaZ = 0.0, beamWidth = 0.0;
352 case CONSTRAINT_PV_BEAMSPOT_SIZE:
353 event.getByToken(token_BeamSpot,
beamSpot);
354 bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = bsCovSrc[6] = 1;
359 case CONSTRAINT_PV_BS_Z_ERRORS_SCALED:
360 event.getByToken(token_BeamSpot,
beamSpot);
361 bsCovSrc[0] = bsCovSrc[1] = 2;
362 bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = 1;
366 case CONSTRAINT_PV_ERROR_SCALED:
367 bsCovSrc[0] = bsCovSrc[1] = bsCovSrc[2] = 2;
370 case CONSTRAINT_BEAMSPOT:
371 case CONSTRAINT_PV_PRIMARIES_IN_FIT:
372 event.getByToken(token_BeamSpot,
beamSpot);
380 std::vector<std::vector<int> > clusteredSVs(
trackIPTagInfos->size(), std::vector<int>());
383 std::vector<fastjet::PseudoJet> fjInputs;
387 std::vector<edm::Ptr<reco::Candidate> > constituents = it->getJetConstituents();
388 std::vector<edm::Ptr<reco::Candidate> >::const_iterator
m;
389 for (
m = constituents.begin();
m != constituents.end(); ++
m) {
391 if (constit->
pt() == 0) {
392 edm::LogWarning(
"NullTransverseMomentum") <<
"dropping input candidate with pt=0";
395 if (it->isWeighted()) {
396 if (token_weights.isUninitialized())
398 <<
"TemplatedSecondaryVertexProducer: No weights (e.g. PUPPI) given for weighted jet collection"
400 float w = (*weightsHandle)[constit];
402 fastjet::PseudoJet(constit->
px() *
w, constit->
py() *
w, constit->
pz() *
w, constit->
energy() *
w));
404 fjInputs.push_back(fastjet::PseudoJet(constit->
px(), constit->
py(), constit->
pz(), constit->
energy()));
411 std::vector<edm::Ptr<reco::Candidate> > constituents = it->jet()->getJetConstituents();
412 std::vector<edm::Ptr<reco::Candidate> >::const_iterator
m;
413 for (
m = constituents.begin();
m != constituents.end(); ++
m) {
415 if (constit->
pt() == 0) {
416 edm::LogWarning(
"NullTransverseMomentum") <<
"dropping input candidate with pt=0";
419 if (it->jet()->isWeighted()) {
420 if (token_weights.isUninitialized())
422 <<
"TemplatedSecondaryVertexProducer: No weights (e.g. PUPPI) given for weighted jet collection"
424 float w = (*weightsHandle)[constit];
426 fastjet::PseudoJet(constit->
px() *
w, constit->
py() *
w, constit->
pz() *
w, constit->
energy() *
w));
428 fjInputs.push_back(fastjet::PseudoJet(constit->
px(), constit->
py(), constit->
pz(), constit->
energy()));
438 fastjet::PseudoJet
p(
441 p = fastjet::PseudoJet(it->p4().px(), it->p4().py(), it->p4().pz(), it->p4().energy());
443 p.set_user_info(
new VertexInfo(it - extSecVertex->begin()));
444 fjInputs.push_back(
p);
448 fjClusterSeq = std::make_shared<fastjet::ClusterSequence>(fjInputs, *fjJetDefinition);
450 std::vector<fastjet::PseudoJet> inclusiveJets = fastjet::sorted_by_pt(fjClusterSeq->inclusive_jets(
jetPtMin));
453 if (inclusiveJets.size() < fatJetsHandle->size())
455 <<
"There are fewer reclustered (" << inclusiveJets.size() <<
") than original fat jets ("
456 << fatJetsHandle->size()
457 <<
"). Please check that the jet algorithm and jet size match those used for the original jet collection.";
460 std::vector<int> reclusteredIndices;
461 matchReclusteredJets<edm::View<reco::Jet> >(fatJetsHandle, inclusiveJets, reclusteredIndices,
"fat");
464 std::vector<int> groomedIndices;
465 if (useGroomedFatJets)
466 matchGroomedJets(fatJetsHandle, groomedFatJetsHandle, groomedIndices);
469 std::vector<std::vector<int> > subjetIndices;
470 if (useGroomedFatJets)
471 matchSubjets(groomedIndices, groomedFatJetsHandle,
trackIPTagInfos, subjetIndices);
476 for (
size_t i = 0;
i < fatJetsHandle->size(); ++
i) {
477 if (reclusteredIndices.at(
i) < 0)
480 if (fatJetsHandle->at(
i).pt() == 0)
483 <<
"The original fat jet " <<
i <<
" has Pt=0. This is not expected so the jet will be skipped.";
487 if (subjetIndices.at(
i).empty())
491 if ((
std::abs(inclusiveJets.at(reclusteredIndices.at(
i)).
pt() - fatJetsHandle->at(
i).pt()) /
492 fatJetsHandle->at(
i).pt()) > relPtTolerance) {
493 if (fatJetsHandle->at(
i).pt() < 10.)
495 <<
"The reclustered and original fat jet " <<
i <<
" have different Pt's ("
496 << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " << fatJetsHandle->at(
i).pt()
497 <<
" GeV, respectively).\n"
498 <<
"Please check that the jet algorithm and jet size match those used for the original fat jet "
499 "collection and also make sure the original fat jets are uncorrected. In addition, make sure you "
500 "are not using CaloJets which are presently not supported.\n"
501 <<
"Since the mismatch is at low Pt, it is ignored and only a warning is issued.\n"
502 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine "
503 "precision in which case make sure the original jet collection is produced and reclustering is "
504 "performed in the same job.";
507 <<
"The reclustered and original fat jet " <<
i <<
" have different Pt's ("
508 << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " << fatJetsHandle->at(
i).pt()
509 <<
" GeV, respectively).\n"
510 <<
"Please check that the jet algorithm and jet size match those used for the original fat jet "
511 "collection and also make sure the original fat jets are uncorrected. In addition, make sure you "
512 "are not using CaloJets which are presently not supported.\n"
513 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine "
514 "precision in which case make sure the original jet collection is produced and reclustering is "
515 "performed in the same job.";
519 std::vector<fastjet::PseudoJet> constituents = inclusiveJets.at(reclusteredIndices.at(
i)).constituents();
521 std::vector<int> svIndices;
523 for (std::vector<fastjet::PseudoJet>::const_iterator it = constituents.begin(); it != constituents.end();
525 if (!it->has_user_info())
528 svIndices.push_back(it->user_info<VertexInfo>().vertexIndex());
532 for (
size_t sv = 0;
sv < svIndices.size(); ++
sv) {
534 const VTX &extSV = (*extSecVertex)[svIndices.at(
sv)];
537 fastjet::PseudoJet
p(
540 p = fastjet::PseudoJet(extSV.p4().px(), extSV.p4().py(), extSV.p4().pz(), extSV.p4().energy());
542 std::vector<double> dR2toSubjets;
544 for (
size_t sj = 0; sj < subjetIndices.at(
i).size(); ++sj)
551 int closestSubjetIdx =
552 std::distance(dR2toSubjets.begin(), std::min_element(dR2toSubjets.begin(), dR2toSubjets.end()));
554 clusteredSVs.at(subjetIndices.at(
i).at(closestSubjetIdx)).push_back(svIndices.at(
sv));
560 <<
"There are fewer reclustered (" << inclusiveJets.size() <<
") than original jets ("
562 <<
"). Please check that the jet algorithm and jet size match those used for the original jet collection.";
565 std::vector<int> reclusteredIndices;
566 matchReclusteredJets<std::vector<IPTI> >(
trackIPTagInfos, inclusiveJets, reclusteredIndices);
570 if (reclusteredIndices.at(
i) < 0)
576 <<
"The original jet " <<
i <<
" has Pt=0. This is not expected so the jet will be skipped.";
585 <<
"The reclustered and original jet " <<
i <<
" have different Pt's ("
586 << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " <<
trackIPTagInfos->at(
i).jet()->pt()
587 <<
" GeV, respectively).\n"
588 <<
"Please check that the jet algorithm and jet size match those used for the original jet collection "
589 "and also make sure the original jets are uncorrected. In addition, make sure you are not using "
590 "CaloJets which are presently not supported.\n"
591 <<
"Since the mismatch is at low Pt, it is ignored and only a warning is issued.\n"
592 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine "
593 "precision in which case make sure the original jet collection is produced and reclustering is "
594 "performed in the same job.";
597 <<
"The reclustered and original jet " <<
i <<
" have different Pt's ("
598 << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " <<
trackIPTagInfos->at(
i).jet()->pt()
599 <<
" GeV, respectively).\n"
600 <<
"Please check that the jet algorithm and jet size match those used for the original jet collection "
601 "and also make sure the original jets are uncorrected. In addition, make sure you are not using "
602 "CaloJets which are presently not supported.\n"
603 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine "
604 "precision in which case make sure the original jet collection is produced and reclustering is "
605 "performed in the same job.";
609 std::vector<fastjet::PseudoJet> constituents = inclusiveJets.at(reclusteredIndices.at(
i)).constituents();
612 for (std::vector<fastjet::PseudoJet>::const_iterator it = constituents.begin(); it != constituents.end();
614 if (!it->has_user_info())
617 clusteredSVs.at(
i).push_back(it->user_info<VertexInfo>().vertexIndex());
625 std::vector<int> groomedIndices;
626 if (useGroomedFatJets)
627 matchGroomedJets(fatJetsHandle, groomedFatJetsHandle, groomedIndices);
630 std::vector<std::vector<int> > subjetIndices;
631 if (useGroomedFatJets)
632 matchSubjets(groomedIndices, groomedFatJetsHandle,
trackIPTagInfos, subjetIndices);
637 for (
size_t i = 0;
i < fatJetsHandle->size(); ++
i) {
638 if (fatJetsHandle->at(
i).pt() == 0)
641 <<
"The original fat jet " <<
i <<
" has Pt=0. This is not expected so the jet will be skipped.";
645 if (subjetIndices.at(
i).empty())
651 size_t sv = (it - extSecVertex->begin());
654 const VTX &extSV = (*extSecVertex)[
sv];
656 GlobalVector jetDir(fatJetsHandle->at(
i).px(), fatJetsHandle->at(
i).py(), fatJetsHandle->at(
i).pz());
662 fastjet::PseudoJet
p(
665 p = fastjet::PseudoJet(extSV.p4().px(), extSV.p4().py(), extSV.p4().pz(), extSV.p4().energy());
667 std::vector<double> dR2toSubjets;
669 for (
size_t sj = 0; sj < subjetIndices.at(
i).size(); ++sj)
676 int closestSubjetIdx =
677 std::distance(dR2toSubjets.begin(), std::min_element(dR2toSubjets.begin(), dR2toSubjets.end()));
679 clusteredSVs.at(subjetIndices.at(
i).at(closestSubjetIdx)).push_back(
sv);
685 std::unique_ptr<ConfigurableVertexReconstructor>
vertexReco;
686 std::unique_ptr<GhostTrackVertexFinder> vertexRecoGT;
690 vtxRecoPSet.getParameter<
double>(
"mergeThreshold"),
691 vtxRecoPSet.getParameter<
double>(
"primcut"),
692 vtxRecoPSet.getParameter<
double>(
"seccut"),
697 TransientTrackMap primariesMap;
701 auto tagInfos = std::make_unique<Product>();
703 for (
typename std::vector<IPTI>::const_iterator iterJets =
trackIPTagInfos->begin();
709 const Vertex &
pv = *iterJets->primaryVertex();
711 std::set<TransientTrack> primaries;
712 if (
constraint == CONSTRAINT_PV_PRIMARIES_IN_FIT) {
714 TransientTrackMap::iterator
pos = primariesMap.lower_bound(iter->get());
716 if (
pos != primariesMap.end() &&
pos->first == iter->get())
717 primaries.insert(
pos->second);
720 primariesMap.insert(
pos, std::make_pair(iter->get(),
track));
721 primaries.insert(
track);
728 GlobalVector jetDir(jetRef->momentum().x(), jetRef->momentum().y(), jetRef->momentum().z());
734 const std::vector<reco::btag::TrackIPData> &ipData = iterJets->impactParameterData();
738 std::vector<TransientTrack> fitTracks;
739 std::vector<GhostTrackState> gtStates;
740 std::unique_ptr<GhostTrackPrediction> gtPred;
744 for (
unsigned int i = 0;
i <
indices.size();
i++) {
750 trackData.back().first =
indices[
i];
762 if (
pos != primariesMap.end()) {
763 primaries.erase(
pos->second);
764 fitTrack =
pos->second;
766 fitTrack = trackBuilder->
build(trackRef);
767 fitTracks.push_back(fitTrack);
776 gtStates.push_back(gtState);
780 std::unique_ptr<GhostTrack> ghostTrack;
786 GlobalVector(iterJets->ghostTrack()->px(), iterJets->ghostTrack()->py(), iterJets->ghostTrack()->pz()),
790 iterJets->ghostTrack()->chi2(),
791 iterJets->ghostTrack()->ndof()));
795 std::vector<VTX> extAssoCollection;
796 std::vector<TransientVertex> fittedSVs;
797 std::vector<SecondaryVertex> SVs;
800 case CONSTRAINT_NONE:
802 fittedSVs = vertexRecoGT->vertices(
pv, *ghostTrack);
807 case CONSTRAINT_BEAMSPOT:
809 fittedSVs = vertexRecoGT->vertices(
pv, *
beamSpot, *ghostTrack);
814 case CONSTRAINT_PV_BEAMSPOT_SIZE:
815 case CONSTRAINT_PV_BS_Z_ERRORS_SCALED:
816 case CONSTRAINT_PV_ERROR_SCALED: {
818 for (
unsigned int i = 0;
i < 7;
i++) {
819 unsigned int covSrc = bsCovSrc[
i];
820 for (
unsigned int j = 0;
j < 7;
j++) {
822 if (!covSrc || bsCovSrc[
j] != covSrc)
824 else if (covSrc == 1)
826 else if (
j < 3 &&
i < 3)
827 v =
pv.covariance(
i,
j) * constraintScaling;
841 fittedSVs = vertexRecoGT->vertices(
pv,
bs, *ghostTrack);
846 case CONSTRAINT_PV_PRIMARIES_IN_FIT: {
847 std::vector<TransientTrack> primaries_(primaries.begin(), primaries.end());
849 fittedSVs = vertexRecoGT->vertices(
pv, *
beamSpot, primaries_, *ghostTrack);
855 SVBuilder svBuilder(
pv, jetDir, withPVError, minTrackWeight);
856 std::remove_copy_if(boost::make_transform_iterator(fittedSVs.begin(), svBuilder),
857 boost::make_transform_iterator(fittedSVs.end(), svBuilder),
858 std::back_inserter(SVs),
862 if (useSVClustering || useFatJets) {
865 for (
size_t iExtSv = 0; iExtSv < clusteredSVs.at(
jetIdx).size(); iExtSv++) {
866 const VTX &extVertex = (*extSecVertex)[clusteredSVs.at(
jetIdx).at(iExtSv)];
867 if (extVertex.p4().M() < 0.3)
869 extAssoCollection.push_back(extVertex);
872 for (
size_t iExtSv = 0; iExtSv < extSecVertex->size(); iExtSv++) {
873 const VTX &extVertex = (*extSecVertex)[iExtSv];
876 extVertex.p4().M() < 0.3)
878 extAssoCollection.push_back(extVertex);
882 SVBuilder svBuilder(
pv, jetDir, withPVError, minTrackWeight);
883 std::remove_copy_if(boost::make_transform_iterator(extAssoCollection.begin(), svBuilder),
884 boost::make_transform_iterator(extAssoCollection.end(), svBuilder),
885 std::back_inserter(SVs),
894 extAssoCollection.clear();
898 std::vector<unsigned int> vtxIndices = vertexSorting(SVs);
900 std::vector<typename TemplatedSecondaryVertexTagInfo<IPTI, VTX>::VertexData> svData;
902 svData.resize(vtxIndices.size());
903 for (
unsigned int idx = 0;
idx < vtxIndices.size();
idx++) {
906 svData[
idx].vertex =
sv;
907 svData[
idx].dist1d =
sv.dist1d();
908 svData[
idx].dist2d =
sv.dist2d();
909 svData[
idx].dist3d =
sv.dist3d();
912 markUsedTracks(trackData, trackRefs,
sv,
idx);
934 if (
sv.trackWeight(*iter) < minTrackWeight)
937 typename input_container::const_iterator
pos =
940 if (
pos == trackRefs.end()) {
942 throw cms::Exception(
"TrackNotFound") <<
"Could not find track from secondary "
943 "vertex in original tracks."
946 unsigned int index =
pos - trackRefs.begin();
947 trackData[
index].second.svStatus =
955 for (
typename input_container::const_iterator iter =
sv.daughterPtrVector().begin();
956 iter !=
sv.daughterPtrVector().end();
958 typename input_container::const_iterator
pos =
std::find(trackRefs.begin(), trackRefs.end(), *iter);
960 if (
pos != trackRefs.end()) {
961 unsigned int index =
pos - trackRefs.begin();
962 trackData[
index].second.svStatus =
971 if (!
sv.originalTracks().empty() &&
sv.originalTracks()[0].trackBaseRef().isNonnull())
974 edm::LogError(
"UnexpectedInputs") <<
"Building from Candidates, should not happen!";
983 if (!
sv.originalTracks().empty() &&
sv.originalTracks()[0].trackBaseRef().isNonnull()) {
984 edm::LogError(
"UnexpectedInputs") <<
"Building from Tracks, should not happen!";
1000 for (std::vector<reco::TransientTrack>::const_iterator
tt =
sv.originalTracks().begin();
1001 tt !=
sv.originalTracks().end();
1007 dynamic_cast<const CandidatePtrTransientTrack *>(
tt->basicTransientTrack());
1008 if (cptt ==
nullptr)
1009 edm::LogError(
"DynamicCastingFailed") <<
"Casting of TransientTrack to CandidatePtrTransientTrack failed!";
1022 template <
class IPTI,
class VTX>
1023 template <
class CONTAINER>
1026 const std::vector<fastjet::PseudoJet> &reclusteredJets,
1027 std::vector<int> &matchedIndices,
1031 std::vector<bool> matchedLocks(reclusteredJets.size(),
false);
1033 for (
size_t j = 0;
j <
jets->size(); ++
j) {
1034 double matchedDR2 = 1e9;
1035 int matchedIdx = -1;
1037 for (
size_t rj = 0; rj < reclusteredJets.size(); ++rj) {
1038 if (matchedLocks.at(rj))
1043 reclusteredJets.at(rj).rapidity(),
1044 reclusteredJets.at(rj).phi_std());
1045 if (tempDR2 < matchedDR2) {
1046 matchedDR2 = tempDR2;
1051 if (matchedIdx >= 0) {
1053 edm::LogError(
"JetMatchingFailed") <<
"Matched reclustered jet " << matchedIdx <<
" and original " <<
type
1054 <<
"jet " <<
j <<
" are separated by dR=" <<
sqrt(matchedDR2)
1055 <<
" which is greater than the jet size R=" <<
rParam <<
".\n"
1056 <<
"This is not expected so please check that the jet algorithm and jet "
1057 "size match those used for the original "
1058 <<
type <<
"jet collection.";
1060 matchedLocks.at(matchedIdx) =
true;
1063 <<
"Matching reclustered to original " <<
type
1064 <<
"jets failed. Please check that the jet algorithm and jet size match those used for the original " <<
type
1065 <<
"jet collection.";
1067 matchedIndices.push_back(matchedIdx);
1072 template <
class IPTI,
class VTX>
1075 std::vector<int> &matchedIndices) {
1076 std::vector<bool> jetLocks(
jets->size(),
false);
1077 std::vector<int> jetIndices;
1079 for (
size_t gj = 0; gj < groomedJets->size(); ++gj) {
1080 double matchedDR2 = 1e9;
1081 int matchedIdx = -1;
1083 if (groomedJets->at(gj).pt() > 0.)
1085 for (
size_t j = 0;
j <
jets->size(); ++
j) {
1090 jets->at(
j).rapidity(),
jets->at(
j).phi(), groomedJets->at(gj).rapidity(), groomedJets->at(gj).phi());
1091 if (tempDR2 < matchedDR2) {
1092 matchedDR2 = tempDR2;
1098 if (matchedIdx >= 0) {
1101 <<
"Matched groomed jet " << gj <<
" and original jet " << matchedIdx
1102 <<
" are separated by dR=" <<
sqrt(matchedDR2) <<
" which is greater than the jet size R=" <<
rParam
1104 <<
"This is not expected so the matching of these two jets has been discarded. Please check that the two "
1105 "jet collections belong to each other.";
1108 jetLocks.at(matchedIdx) =
true;
1110 jetIndices.push_back(matchedIdx);
1113 for (
size_t j = 0;
j <
jets->size(); ++
j) {
1114 std::vector<int>::iterator matchedIndex =
std::find(jetIndices.begin(), jetIndices.end(),
j);
1116 matchedIndices.push_back(matchedIndex != jetIndices.end() ?
std::distance(jetIndices.begin(), matchedIndex) : -1);
1121 template <
class IPTI,
class VTX>
1125 std::vector<std::vector<int> > &matchedIndices) {
1126 for (
size_t g = 0;
g < groomedIndices.size(); ++
g) {
1127 std::vector<int> subjetIndices;
1129 if (groomedIndices.at(
g) >= 0) {
1130 for (
size_t s = 0;
s < groomedJets->at(groomedIndices.at(
g)).numberOfDaughters(); ++
s) {
1133 for (
size_t sj = 0; sj < subjets->size(); ++sj) {
1136 subjetIndices.push_back(sj);
1142 if (subjetIndices.empty())
1143 edm::LogError(
"SubjetMatchingFailed") <<
"Matching subjets to original fat jets failed. Please check that the "
1144 "groomed fat jet and subjet collections belong to each other.";
1146 matchedIndices.push_back(subjetIndices);
1148 matchedIndices.push_back(subjetIndices);
1153 template <
class IPTI,
class VTX>
1156 std::vector<std::vector<int> > &matchedIndices) {
1157 for (
size_t fj = 0; fj < fatJets->size(); ++fj) {
1158 std::vector<int> subjetIndices;
1159 size_t nSubjetCollections = 0;
1160 size_t nSubjets = 0;
1162 const pat::Jet *fatJet = dynamic_cast<const pat::Jet *>(fatJets->ptrAt(fj).get());
1167 <<
"Wrong jet type for input fat jets. Please check that the input fat jets are of the pat::Jet type.";
1169 matchedIndices.push_back(subjetIndices);
1174 if (nSubjetCollections > 0) {
1175 for (
size_t coll = 0; coll < nSubjetCollections; ++coll) {
1178 for (
size_t fjsj = 0; fjsj < fatJetSubjets.size(); ++fjsj) {
1181 for (
size_t sj = 0; sj < subjets->size(); ++sj) {
1182 const pat::Jet *subJet = dynamic_cast<const pat::Jet *>(subjets->at(sj).jet().get());
1185 if (fj == 0 && coll == 0 && fjsj == 0 && sj == 0)
1186 edm::LogError(
"WrongJetType") <<
"Wrong jet type for input subjets. Please check that the input "
1187 "subjets are of the pat::Jet type.";
1191 if (subJet->
originalObjectRef() == fatJetSubjets.at(fjsj)->originalObjectRef()) {
1192 subjetIndices.push_back(sj);
1200 if (subjetIndices.empty() && nSubjets > 0)
1201 edm::LogError(
"SubjetMatchingFailed") <<
"Matching subjets to fat jets failed. Please check that the fat jet "
1202 "and subjet collections belong to each other.";
1204 matchedIndices.push_back(subjetIndices);
1206 matchedIndices.push_back(subjetIndices);
1212 template <
class IPTI,
class VTX>
1215 desc.
add<
double>(
"extSVDeltaRToJet", 0.3);
1242 vertexCuts.add<
double>(
"distSig3dMax", 99999.9);
1245 vertexCuts.add<
bool>(
"useTrackWeights",
true);
1246 vertexCuts.add<
double>(
"maxDeltaRToJetAxis", 0.4);
1249 v0Filter.add<
double>(
"k0sMassWindow", 0.05);
1253 vertexCuts.add<
unsigned int>(
"multiplicityMin", 2);
1254 vertexCuts.add<
double>(
"distVal2dMin", 0.01);
1255 vertexCuts.add<
double>(
"distSig2dMax", 99999.9);
1256 vertexCuts.add<
double>(
"distVal3dMax", 99999.9);
1257 vertexCuts.add<
double>(
"minimumTrackWeight", 0.5);
1258 vertexCuts.add<
double>(
"distVal3dMin", -99999.9);
1260 vertexCuts.add<
double>(
"distSig3dMin", -99999.9);
1263 desc.
add<
bool>(
"useExternalSV",
false);
1264 desc.
add<
double>(
"minimumTrackWeight", 0.5);
1265 desc.
add<
bool>(
"usePVError",
true);