10 #include <boost/iterator/transform_iterator.hpp>
55 #include "fastjet/JetDefinition.hh"
56 #include "fastjet/ClusterSequence.hh"
57 #include "fastjet/PseudoJet.hh"
63 typedef boost::shared_ptr<fastjet::JetDefinition>
JetDefPtr;
69 class VertexInfo :
public fastjet::PseudoJet::UserInfoBase{
71 VertexInfo(
const int vertexIndex) :
72 m_vertexIndex(vertexIndex) { }
74 inline const int vertexIndex()
const {
return m_vertexIndex; }
81 struct RefToBaseLess :
public std::binary_function<edm::RefToBase<T>,
87 return r1.
id() < r2.
id() ||
105 template <
class IPTI,
class VTX>
111 typedef std::vector<TemplatedSecondaryVertexTagInfo<IPTI,VTX> >
Product;
119 template<
class CONTAINER>
121 const std::vector<fastjet::PseudoJet>& matchedJets,
122 std::vector<int>& matchedIndices,
126 std::vector<int>& matchedIndices);
127 void matchSubjets(
const std::vector<int>& groomedIndices,
130 std::vector<std::vector<int> >& matchedIndices);
133 std::vector<std::vector<int> >& matchedIndices);
144 CONSTRAINT_PV_PRIMARIES_IN_FIT
181 public std::unary_function<const VTX&, SecondaryVertex> {
186 double minTrackWeight) :
187 pv(pv), direction(direction),
188 withPVError(withPVError),
189 minTrackWeight(minTrackWeight) {}
203 public std::unary_function<const SecondaryVertex&, bool> {
207 filter(filter), pv(pv), direction(direction) {}
210 {
return !
filter(
pv, sv, direction); }
217 template <
class IPTI,
class VTX>
222 return CONSTRAINT_NONE;
223 else if (name ==
"BeamSpot")
224 return CONSTRAINT_BEAMSPOT;
225 else if (name ==
"BeamSpot+PVPosition")
226 return CONSTRAINT_PV_BEAMSPOT_SIZE;
227 else if (name ==
"BeamSpotZ+PVErrorScaledXY")
228 return CONSTRAINT_PV_BS_Z_ERRORS_SCALED;
229 else if (name ==
"PVErrorScaled")
230 return CONSTRAINT_PV_ERROR_SCALED;
231 else if (name ==
"BeamSpot+PVTracksInFit")
232 return CONSTRAINT_PV_PRIMARIES_IN_FIT;
235 <<
"TemplatedSecondaryVertexProducer: ``constraint'' parameter "
236 "value \"" << name <<
"\" not understood."
243 if (name ==
"AlwaysWithGhostTrack")
245 else if (name ==
"SingleTracksWithGhostTrack")
247 else if (name ==
"RefitGhostTrackWithVertices")
251 <<
"TemplatedSecondaryVertexProducer: ``fitType'' "
252 "parameter value \"" << name <<
"\" for "
253 "GhostTrackVertexFinder settings not "
254 "understood." << std::endl;
257 template <
class IPTI,
class VTX>
260 sortCriterium(TrackSorting::
getCriterium(params.getParameter<std::
string>(
"trackSort"))),
262 constraint(getConstraintType(params.getParameter<std::
string>(
"constraint"))),
263 constraintScaling(1.0),
264 vtxRecoPSet(params.getParameter<edm::
ParameterSet>(
"vertexReco")),
265 useGhostTrack(vtxRecoPSet.getParameter<std::
string>(
"finder") ==
"gtvr"),
266 withPVError(params.getParameter<bool>(
"usePVError")),
267 minTrackWeight(params.getParameter<double>(
"minimumTrackWeight")),
268 vertexFilter(params.getParameter<edm::
ParameterSet>(
"vertexCuts")),
269 vertexSorting(params.getParameter<edm::
ParameterSet>(
"vertexSelection"))
307 throw cms::Exception(
"InvalidJetAlgorithm") <<
"Jet clustering algorithm is invalid: " <<
jetAlgorithm <<
", use CambridgeAachen | Kt | AntiKt" << std::endl;
318 template <
class IPTI,
class VTX>
323 template <
class IPTI,
class VTX>
330 typedef std::map<const Track *, TransientTrack> TransientTrackMap;
338 event.getByToken(token_trackIPTagInfo, trackIPTagInfos);
342 if(
useExternalSV)
event.getByToken(token_extSVCollection,extSecVertex);
348 event.getByToken(token_fatJets, fatJetsHandle);
350 if( useGroomedFatJets )
352 event.getByToken(token_groomedFatJets, groomedFatJetsHandle);
354 if( groomedFatJetsHandle->size() > fatJetsHandle->size() )
355 edm::LogError(
"TooManyGroomedJets") <<
"There are more groomed (" << groomedFatJetsHandle->size() <<
") than original fat jets (" << fatJetsHandle->size() <<
"). Please check that the two jet collections belong to each other.";
360 unsigned int bsCovSrc[7] = { 0, };
361 double sigmaZ = 0.0, beamWidth = 0.0;
363 case CONSTRAINT_PV_BEAMSPOT_SIZE:
364 event.getByToken(token_BeamSpot,beamSpot);
365 bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = bsCovSrc[6] = 1;
366 sigmaZ = beamSpot->sigmaZ();
367 beamWidth = beamSpot->BeamWidthX();
370 case CONSTRAINT_PV_BS_Z_ERRORS_SCALED:
371 event.getByToken(token_BeamSpot,beamSpot);
372 bsCovSrc[0] = bsCovSrc[1] = 2;
373 bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = 1;
374 sigmaZ = beamSpot->sigmaZ();
377 case CONSTRAINT_PV_ERROR_SCALED:
378 bsCovSrc[0] = bsCovSrc[1] = bsCovSrc[2] = 2;
381 case CONSTRAINT_BEAMSPOT:
382 case CONSTRAINT_PV_PRIMARIES_IN_FIT:
383 event.getByToken(token_BeamSpot,beamSpot);
391 std::vector<std::vector<int> > clusteredSVs(trackIPTagInfos->size(),std::vector<int>());
392 if(
useExternalSV && useSVClustering && trackIPTagInfos->size()>0 )
395 std::vector<fastjet::PseudoJet> fjInputs;
401 std::vector<edm::Ptr<reco::Candidate> > constituents = it->getJetConstituents();
402 std::vector<edm::Ptr<reco::Candidate> >::const_iterator
m;
403 for( m = constituents.begin(); m != constituents.end(); ++
m )
406 if(constit->pt() == 0)
408 edm::LogWarning(
"NullTransverseMomentum") <<
"dropping input candidate with pt=0";
411 fjInputs.push_back(fastjet::PseudoJet(constit->px(),constit->py(),constit->pz(),constit->energy()));
417 for(
typename std::vector<IPTI>::const_iterator it = trackIPTagInfos->begin(); it != trackIPTagInfos->end(); ++it)
419 std::vector<edm::Ptr<reco::Candidate> > constituents = it->jet()->getJetConstituents();
420 std::vector<edm::Ptr<reco::Candidate> >::const_iterator
m;
421 for( m = constituents.begin(); m != constituents.end(); ++
m )
424 if(constit->pt() == 0)
426 edm::LogWarning(
"NullTransverseMomentum") <<
"dropping input candidate with pt=0";
429 fjInputs.push_back(fastjet::PseudoJet(constit->px(),constit->py(),constit->pz(),constit->energy()));
436 const reco::Vertex &
pv = *(trackIPTagInfos->front().primaryVertex());
439 fastjet::PseudoJet
p(dir.
x(),dir.
y(),dir.
z(),dir.
mag());
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 =
ClusterSequencePtr(
new fastjet::ClusterSequence( fjInputs, *fjJetDefinition ) );
450 std::vector<fastjet::PseudoJet> inclusiveJets = fastjet::sorted_by_pt( fjClusterSeq->inclusive_jets(
jetPtMin) );
454 if( inclusiveJets.size() < fatJetsHandle->size() )
455 edm::LogError(
"TooFewReclusteredJets") <<
"There are fewer reclustered (" << inclusiveJets.size() <<
") than original fat jets (" << fatJetsHandle->size() <<
"). Please check that the jet algorithm and jet size match those used for the original jet collection.";
458 std::vector<int> reclusteredIndices;
459 matchReclusteredJets<edm::View<reco::Jet> >(fatJetsHandle,inclusiveJets,reclusteredIndices,
"fat");
462 std::vector<int> groomedIndices;
463 if( useGroomedFatJets )
464 matchGroomedJets(fatJetsHandle,groomedFatJetsHandle,groomedIndices);
467 std::vector<std::vector<int> > subjetIndices;
468 if( useGroomedFatJets )
469 matchSubjets(groomedIndices,groomedFatJetsHandle,trackIPTagInfos,subjetIndices);
471 matchSubjets(fatJetsHandle,trackIPTagInfos,subjetIndices);
474 for(
size_t i=0;
i<fatJetsHandle->size(); ++
i)
476 if( reclusteredIndices.at(
i) < 0 )
continue;
478 if( fatJetsHandle->at(
i).pt() == 0 )
480 edm::LogWarning(
"NullTransverseMomentum") <<
"The original fat jet " <<
i <<
" has Pt=0. This is not expected so the jet will be skipped.";
484 if( subjetIndices.at(
i).size()==0 )
continue;
487 if( (
std::abs( inclusiveJets.at(reclusteredIndices.at(
i)).
pt() - fatJetsHandle->at(
i).pt() ) / fatJetsHandle->at(
i).pt() ) > relPtTolerance )
489 if( fatJetsHandle->at(
i).pt() < 10. )
490 edm::LogWarning(
"JetPtMismatchAtLowPt") <<
"The reclustered and original fat jet " <<
i <<
" have different Pt's (" << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " << fatJetsHandle->at(
i).pt() <<
" GeV, respectively).\n"
491 <<
"Please check that the jet algorithm and jet size match those used for the original fat jet collection and also make sure the original fat jets are uncorrected. In addition, make sure you are not using CaloJets which are presently not supported.\n"
492 <<
"Since the mismatch is at low Pt, it is ignored and only a warning is issued.\n"
493 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine precision in which case make sure the original jet collection is produced and reclustering is performed in the same job.";
495 edm::LogError(
"JetPtMismatch") <<
"The reclustered and original fat jet " <<
i <<
" have different Pt's (" << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " << fatJetsHandle->at(
i).pt() <<
" GeV, respectively).\n"
496 <<
"Please check that the jet algorithm and jet size match those used for the original fat jet collection and also make sure the original fat jets are uncorrected. In addition, make sure you are not using CaloJets which are presently not supported.\n"
497 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine precision in which case make sure the original jet collection is produced and reclustering is performed in the same job.";
501 std::vector<fastjet::PseudoJet> constituents = inclusiveJets.at(reclusteredIndices.at(
i)).constituents();
503 std::vector<int> svIndices;
505 for(std::vector<fastjet::PseudoJet>::const_iterator it = constituents.begin(); it != constituents.end(); ++it)
507 if( !it->has_user_info() )
continue;
509 svIndices.push_back( it->user_info<VertexInfo>().vertexIndex() );
513 for(
size_t sv=0; sv<svIndices.size(); ++sv)
515 const reco::Vertex &
pv = *(trackIPTagInfos->front().primaryVertex());
516 const VTX &extSV = (*extSecVertex)[ svIndices.at(sv) ];
519 fastjet::PseudoJet
p(dir.
x(),dir.
y(),dir.
z(),dir.
mag());
521 p = fastjet::PseudoJet(extSV.p4().px(),extSV.p4().py(),extSV.p4().pz(),extSV.p4().energy());
523 std::vector<double> dR2toSubjets;
525 for(
size_t sj=0; sj<subjetIndices.at(
i).size(); ++sj)
526 dR2toSubjets.push_back(
Geom::deltaR2(
p.rapidity(),
p.phi_std(), trackIPTagInfos->at(subjetIndices.at(
i).at(sj)).
jet()->rapidity(), trackIPTagInfos->at(subjetIndices.at(
i).at(sj)).
jet()->phi() ) );
529 int closestSubjetIdx =
std::distance( dR2toSubjets.begin(), std::min_element(dR2toSubjets.begin(), dR2toSubjets.end()) );
531 clusteredSVs.at(subjetIndices.at(
i).at(closestSubjetIdx)).push_back( svIndices.at(sv) );
537 if( inclusiveJets.size() < trackIPTagInfos->size() )
538 edm::LogError(
"TooFewReclusteredJets") <<
"There are fewer reclustered (" << inclusiveJets.size() <<
") than original jets (" << trackIPTagInfos->size() <<
"). Please check that the jet algorithm and jet size match those used for the original jet collection.";
541 std::vector<int> reclusteredIndices;
542 matchReclusteredJets<std::vector<IPTI> >(
trackIPTagInfos,inclusiveJets,reclusteredIndices);
545 for(
size_t i=0;
i<trackIPTagInfos->size(); ++
i)
547 if( reclusteredIndices.at(
i) < 0 )
continue;
549 if( trackIPTagInfos->at(
i).jet()->pt() == 0 )
551 edm::LogWarning(
"NullTransverseMomentum") <<
"The original jet " <<
i <<
" has Pt=0. This is not expected so the jet will be skipped.";
556 if( (
std::abs( inclusiveJets.at(reclusteredIndices.at(
i)).
pt() - trackIPTagInfos->at(
i).jet()->pt() ) / trackIPTagInfos->at(
i).jet()->pt() ) > relPtTolerance )
558 if( trackIPTagInfos->at(
i).jet()->pt() < 10. )
559 edm::LogWarning(
"JetPtMismatchAtLowPt") <<
"The reclustered and original jet " <<
i <<
" have different Pt's (" << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " << trackIPTagInfos->at(
i).jet()->pt() <<
" GeV, respectively).\n"
560 <<
"Please check that the jet algorithm and jet size match those used for the original jet collection and also make sure the original jets are uncorrected. In addition, make sure you are not using CaloJets which are presently not supported.\n"
561 <<
"Since the mismatch is at low Pt, it is ignored and only a warning is issued.\n"
562 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine precision in which case make sure the original jet collection is produced and reclustering is performed in the same job.";
564 edm::LogError(
"JetPtMismatch") <<
"The reclustered and original jet " <<
i <<
" have different Pt's (" << inclusiveJets.at(reclusteredIndices.at(
i)).
pt() <<
" vs " << trackIPTagInfos->at(
i).jet()->pt() <<
" GeV, respectively).\n"
565 <<
"Please check that the jet algorithm and jet size match those used for the original jet collection and also make sure the original jets are uncorrected. In addition, make sure you are not using CaloJets which are presently not supported.\n"
566 <<
"\nIn extremely rare instances the mismatch could be caused by a difference in the machine precision in which case make sure the original jet collection is produced and reclustering is performed in the same job.";
570 std::vector<fastjet::PseudoJet> constituents = inclusiveJets.at(reclusteredIndices.at(
i)).constituents();
573 for(std::vector<fastjet::PseudoJet>::const_iterator it = constituents.begin(); it != constituents.end(); ++it)
575 if( !it->has_user_info() )
continue;
577 clusteredSVs.at(
i).push_back( it->user_info<VertexInfo>().vertexIndex() );
583 else if(
useExternalSV && !useSVClustering && trackIPTagInfos->size()>0 && useFatJets )
586 std::vector<int> groomedIndices;
587 if( useGroomedFatJets )
588 matchGroomedJets(fatJetsHandle,groomedFatJetsHandle,groomedIndices);
591 std::vector<std::vector<int> > subjetIndices;
592 if( useGroomedFatJets )
593 matchSubjets(groomedIndices,groomedFatJetsHandle,trackIPTagInfos,subjetIndices);
595 matchSubjets(fatJetsHandle,trackIPTagInfos,subjetIndices);
598 for(
size_t i=0;
i<fatJetsHandle->size(); ++
i)
600 if( fatJetsHandle->at(
i).pt() == 0 )
602 edm::LogWarning(
"NullTransverseMomentum") <<
"The original fat jet " <<
i <<
" has Pt=0. This is not expected so the jet will be skipped.";
606 if( subjetIndices.at(
i).size()==0 )
continue;
612 size_t sv = ( it - extSecVertex->begin() );
614 const reco::Vertex &
pv = *(trackIPTagInfos->front().primaryVertex());
615 const VTX &extSV = (*extSecVertex)[sv];
618 fatJetsHandle->at(
i).py(),
619 fatJetsHandle->at(
i).pz());
625 fastjet::PseudoJet
p(dir.
x(),dir.
y(),dir.
z(),dir.
mag());
627 p = fastjet::PseudoJet(extSV.p4().px(),extSV.p4().py(),extSV.p4().pz(),extSV.p4().energy());
629 std::vector<double> dR2toSubjets;
631 for(
size_t sj=0; sj<subjetIndices.at(
i).size(); ++sj)
632 dR2toSubjets.push_back(
Geom::deltaR2(
p.rapidity(),
p.phi_std(), trackIPTagInfos->at(subjetIndices.at(
i).at(sj)).
jet()->rapidity(), trackIPTagInfos->at(subjetIndices.at(
i).at(sj)).
jet()->phi() ) );
635 int closestSubjetIdx =
std::distance( dR2toSubjets.begin(), std::min_element(dR2toSubjets.begin(), dR2toSubjets.end()) );
637 clusteredSVs.at(subjetIndices.at(
i).at(closestSubjetIdx)).push_back(sv);
643 std::auto_ptr<ConfigurableVertexReconstructor>
vertexReco;
644 std::auto_ptr<GhostTrackVertexFinder> vertexRecoGT;
647 vtxRecoPSet.getParameter<
double>(
"maxFitChi2"),
648 vtxRecoPSet.getParameter<
double>(
"mergeThreshold"),
649 vtxRecoPSet.getParameter<
double>(
"primcut"),
650 vtxRecoPSet.getParameter<
double>(
"seccut"),
656 TransientTrackMap primariesMap;
662 for(
typename std::vector<IPTI>::const_iterator iterJets =
663 trackIPTagInfos->begin(); iterJets != trackIPTagInfos->end();
668 const Vertex &
pv = *iterJets->primaryVertex();
670 std::set<TransientTrack> primaries;
671 if (
constraint == CONSTRAINT_PV_PRIMARIES_IN_FIT) {
674 TransientTrackMap::iterator pos =
675 primariesMap.lower_bound(iter->get());
677 if (pos != primariesMap.end() &&
678 pos->first == iter->get())
679 primaries.insert(pos->second);
684 primariesMap.insert(pos,
685 std::make_pair(iter->get(), track));
686 primaries.insert(track);
697 std::vector<std::size_t> indices =
698 iterJets->sortedIndexes(sortCriterium);
702 const std::vector<reco::btag::TrackIPData> &ipData =
703 iterJets->impactParameterData();
707 std::vector<TransientTrack> fitTracks;
708 std::vector<GhostTrackState> gtStates;
709 std::auto_ptr<GhostTrackPrediction> gtPred;
712 *iterJets->ghostTrack()));
714 for(
unsigned int i = 0;
i < indices.size();
i++) {
720 trackData.back().first = indices[
i];
727 trackData.back().second.svStatus =
732 TransientTrackMap::const_iterator pos =
735 if (pos != primariesMap.end()) {
736 primaries.erase(pos->second);
737 fitTrack = pos->second;
739 fitTrack = trackBuilder->build(trackRef);
740 fitTracks.push_back(fitTrack);
742 trackData.back().second.svStatus =
748 ipData[indices[
i]].closestToGhostTrack;
750 gtPred->lambda(pos));
751 gtState.
setWeight(ipData[indices[i]].ghostTrackWeight);
752 gtStates.push_back(gtState);
756 std::auto_ptr<GhostTrack> ghostTrack;
763 iterJets->ghostTrack()->px(),
764 iterJets->ghostTrack()->py(),
765 iterJets->ghostTrack()->pz()),
768 iterJets->ghostTrack()->chi2(),
769 iterJets->ghostTrack()->ndof()));
774 std::vector<VTX> extAssoCollection;
775 std::vector<TransientVertex> fittedSVs;
776 std::vector<SecondaryVertex> SVs;
779 case CONSTRAINT_NONE:
781 fittedSVs = vertexRecoGT->vertices(
784 fittedSVs = vertexReco->vertices(fitTracks);
787 case CONSTRAINT_BEAMSPOT:
789 fittedSVs = vertexRecoGT->vertices(
790 pv, *beamSpot, *ghostTrack);
792 fittedSVs = vertexReco->vertices(fitTracks,
796 case CONSTRAINT_PV_BEAMSPOT_SIZE:
797 case CONSTRAINT_PV_BS_Z_ERRORS_SCALED:
798 case CONSTRAINT_PV_ERROR_SCALED: {
800 for(
unsigned int i = 0;
i < 7;
i++) {
801 unsigned int covSrc = bsCovSrc[
i];
802 for(
unsigned int j = 0;
j < 7;
j++) {
804 if (!covSrc || bsCovSrc[
j] != covSrc)
806 else if (covSrc == 1)
807 v = beamSpot->covariance(
i,
j);
816 beamSpot.
isValid() ? beamSpot->dxdz() : 0.,
817 beamSpot.
isValid() ? beamSpot->dydz() : 0.,
821 fittedSVs = vertexRecoGT->vertices(
822 pv, bs, *ghostTrack);
824 fittedSVs = vertexReco->vertices(fitTracks, bs);
827 case CONSTRAINT_PV_PRIMARIES_IN_FIT: {
828 std::vector<TransientTrack> primaries_(
829 primaries.begin(), primaries.end());
831 fittedSVs = vertexRecoGT->vertices(
832 pv, *beamSpot, primaries_,
835 fittedSVs = vertexReco->vertices(
836 primaries_, fitTracks,
841 SVBuilder svBuilder(pv, jetDir, withPVError, minTrackWeight);
842 std::remove_copy_if(boost::make_transform_iterator(
843 fittedSVs.begin(), svBuilder),
844 boost::make_transform_iterator(
845 fittedSVs.end(), svBuilder),
846 std::back_inserter(SVs),
847 SVFilter(vertexFilter, pv, jetDir));
850 if( useSVClustering || useFatJets ) {
851 size_t jetIdx = ( iterJets - trackIPTagInfos->begin() );
853 for(
size_t iExtSv = 0; iExtSv < clusteredSVs.at(jetIdx).size(); iExtSv++){
854 const VTX & extVertex = (*extSecVertex)[ clusteredSVs.at(jetIdx).at(iExtSv) ];
855 if( extVertex.p4().M() < 0.3 )
857 extAssoCollection.push_back( extVertex );
861 for(
size_t iExtSv = 0; iExtSv < extSecVertex->size(); iExtSv++){
862 const VTX & extVertex = (*extSecVertex)[iExtSv];
865 extAssoCollection.push_back( extVertex );
869 SVBuilder svBuilder(pv, jetDir, withPVError, minTrackWeight);
870 std::remove_copy_if(boost::make_transform_iterator( extAssoCollection.begin(), svBuilder),
871 boost::make_transform_iterator(extAssoCollection.end(), svBuilder),
872 std::back_inserter(SVs),
873 SVFilter(vertexFilter, pv, jetDir));
881 extAssoCollection.clear();
885 std::vector<unsigned int> vtxIndices = vertexSorting(SVs);
887 std::vector<typename TemplatedSecondaryVertexTagInfo<IPTI,VTX>::VertexData> svData;
889 svData.resize(vtxIndices.size());
890 for(
unsigned int idx = 0;
idx < vtxIndices.size();
idx++) {
893 svData[
idx].vertex = sv;
898 markUsedTracks(trackData,trackRefs,sv,
idx);
905 trackData, svData, SVs.size(),
907 iterJets - trackIPTagInfos->begin())));
918 if (sv.trackWeight(*iter) < minTrackWeight)
921 typename input_container::const_iterator pos =
922 std::find(trackRefs.begin(), trackRefs.end(),
925 if (pos == trackRefs.end() ) {
928 <<
"Could not find track from secondary "
929 "vertex in original tracks."
932 unsigned int index = pos - trackRefs.begin();
933 trackData[
index].second.svStatus =
935 ((
unsigned int)btag::TrackData::trackAssociatedToVertex +
idx);
942 for(
typename input_container::const_iterator iter = sv.daughterPtrVector().begin(); iter != sv.daughterPtrVector().end(); ++iter)
944 typename input_container::const_iterator pos =
945 std::find(trackRefs.begin(), trackRefs.end(), *iter);
947 if (pos != trackRefs.end() )
949 unsigned int index = pos - trackRefs.begin();
950 trackData[
index].second.svStatus =
952 ((
unsigned int)btag::TrackData::trackAssociatedToVertex +
idx);
966 edm::LogError(
"UnexpectedInputs") <<
"Building from Candidates, should not happen!";
977 edm::LogError(
"UnexpectedInputs") <<
"Building from Tracks, should not happen!";
1002 edm::LogError(
"DynamicCastingFailed") <<
"Casting of TransientTrack to CandidatePtrTransientTrack failed!";
1009 vtxCompPtrCand.
setP4(p4);
1016 template<
class IPTI,
class VTX>
1017 template<
class CONTAINER>
1019 const std::vector<fastjet::PseudoJet>& reclusteredJets,
1020 std::vector<int>& matchedIndices,
1025 std::vector<bool> matchedLocks(reclusteredJets.size(),
false);
1027 for(
size_t j=0;
j<jets->size(); ++
j)
1029 double matchedDR2 = 1e9;
1030 int matchedIdx = -1;
1032 for(
size_t rj=0; rj<reclusteredJets.size(); ++rj)
1034 if( matchedLocks.at(rj) )
continue;
1036 double tempDR2 =
Geom::deltaR2(
toJet(jets->at(
j))->rapidity(),
toJet(jets->at(
j))->
phi(), reclusteredJets.at(rj).rapidity(), reclusteredJets.at(rj).phi_std() );
1037 if( tempDR2 < matchedDR2 )
1039 matchedDR2 = tempDR2;
1048 edm::LogError(
"JetMatchingFailed") <<
"Matched reclustered jet " << matchedIdx <<
" and original " << type <<
"jet " <<
j <<
" are separated by dR=" <<
sqrt(matchedDR2) <<
" which is greater than the jet size R=" << rParam <<
".\n"
1049 <<
"This is not expected so please check that the jet algorithm and jet size match those used for the original " << type <<
"jet collection.";
1052 matchedLocks.at(matchedIdx) =
true;
1055 edm::LogError(
"JetMatchingFailed") <<
"Matching reclustered to original " << type <<
"jets failed. Please check that the jet algorithm and jet size match those used for the original " << type <<
"jet collection.";
1057 matchedIndices.push_back(matchedIdx);
1062 template<
class IPTI,
class VTX>
1065 std::vector<int>& matchedIndices)
1067 std::vector<bool> jetLocks(
jets->size(),
false);
1068 std::vector<int> jetIndices;
1070 for(
size_t gj=0; gj<groomedJets->size(); ++gj)
1072 double matchedDR2 = 1e9;
1073 int matchedIdx = -1;
1075 if( groomedJets->at(gj).pt()>0. )
1077 for(
size_t j=0;
j<
jets->size(); ++
j)
1079 if( jetLocks.at(
j) )
continue;
1081 double tempDR2 =
Geom::deltaR2(
jets->at(
j).rapidity(),
jets->at(
j).phi(), groomedJets->at(gj).rapidity(), groomedJets->at(gj).phi() );
1082 if( tempDR2 < matchedDR2 )
1084 matchedDR2 = tempDR2;
1094 edm::LogWarning(
"MatchedJetsFarApart") <<
"Matched groomed jet " << gj <<
" and original jet " << matchedIdx <<
" are separated by dR=" <<
sqrt(matchedDR2) <<
" which is greater than the jet size R=" << rParam <<
".\n"
1095 <<
"This is not expected so the matching of these two jets has been discarded. Please check that the two jet collections belong to each other.";
1099 jetLocks.at(matchedIdx) =
true;
1101 jetIndices.push_back(matchedIdx);
1104 for(
size_t j=0;
j<
jets->size(); ++
j)
1106 std::vector<int>::iterator matchedIndex =
std::find( jetIndices.begin(), jetIndices.end(),
j );
1108 matchedIndices.push_back( matchedIndex != jetIndices.end() ?
std::distance(jetIndices.begin(),matchedIndex) : -1 );
1113 template<
class IPTI,
class VTX>
1117 std::vector<std::vector<int> >& matchedIndices)
1119 for(
size_t g=0;
g<groomedIndices.size(); ++
g)
1121 std::vector<int> subjetIndices;
1123 if( groomedIndices.at(
g)>=0 )
1125 for(
size_t s=0;
s<groomedJets->at(groomedIndices.at(
g)).numberOfDaughters(); ++
s)
1129 for(
size_t sj=0; sj<subjets->size(); ++sj)
1134 subjetIndices.push_back(sj);
1140 if( subjetIndices.size() == 0 )
1141 edm::LogError(
"SubjetMatchingFailed") <<
"Matching subjets to original fat jets failed. Please check that the groomed fat jet and subjet collections belong to each other.";
1143 matchedIndices.push_back(subjetIndices);
1146 matchedIndices.push_back(subjetIndices);
1151 template<
class IPTI,
class VTX>
1154 std::vector<std::vector<int> >& matchedIndices)
1156 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() );
1166 if( fj==0 )
edm::LogError(
"WrongJetType") <<
"Wrong jet type for input fat jets. Please check that the input fat jets are of the pat::Jet type.";
1168 matchedIndices.push_back(subjetIndices);
1175 if( nSubjetCollections>0 )
1181 for(
size_t fjsj=0; fjsj<fatJetSubjets.size(); ++fjsj)
1185 for(
size_t sj=0; sj<subjets->size(); ++sj)
1187 const pat::Jet * subJet =
dynamic_cast<const pat::Jet *
>( subjets->at(sj).jet().get() );
1191 if( fj==0 &&
coll==0 && fjsj==0 && sj==0 )
edm::LogError(
"WrongJetType") <<
"Wrong jet type for input subjets. Please check that the input subjets are of the pat::Jet type.";
1197 if( subJet->
originalObjectRef() == fatJetSubjets.at(fjsj)->originalObjectRef() )
1199 subjetIndices.push_back(sj);
1207 if( subjetIndices.size() == 0 && nSubjets > 0)
1208 edm::LogError(
"SubjetMatchingFailed") <<
"Matching subjets to fat jets failed. Please check that the fat jet and subjet collections belong to each other.";
1210 matchedIndices.push_back(subjetIndices);
1213 matchedIndices.push_back(subjetIndices);
1219 template<
class IPTI,
class VTX>
1223 desc.
add<
double>(
"extSVDeltaRToJet",0.3);
1227 vertexReco.
add<
double>(
"primcut",1.8);
1228 vertexReco.
add<
double>(
"seccut",6.0);
1247 vertexCuts.
add<
double>(
"distSig3dMax",99999.9);
1248 vertexCuts.
add<
double>(
"fracPV",0.65);
1249 vertexCuts.
add<
double>(
"distVal2dMax",2.5);
1250 vertexCuts.
add<
bool>(
"useTrackWeights",
true);
1251 vertexCuts.
add<
double>(
"maxDeltaRToJetAxis",0.4);
1254 v0Filter.
add<
double>(
"k0sMassWindow",0.05);
1257 vertexCuts.
add<
double>(
"distSig2dMin",3.0);
1258 vertexCuts.
add<
unsigned int>(
"multiplicityMin",2);
1259 vertexCuts.
add<
double>(
"distVal2dMin",0.01);
1260 vertexCuts.
add<
double>(
"distSig2dMax",99999.9);
1261 vertexCuts.
add<
double>(
"distVal3dMax",99999.9);
1262 vertexCuts.
add<
double>(
"minimumTrackWeight",0.5);
1263 vertexCuts.
add<
double>(
"distVal3dMin",-99999.9);
1264 vertexCuts.
add<
double>(
"massMax",6.5);
1265 vertexCuts.
add<
double>(
"distSig3dMin",-99999.9);
1268 desc.
add<
bool>(
"useExternalSV",
false);
1269 desc.
add<
double>(
"minimumTrackWeight",0.5);
1270 desc.
add<
bool>(
"usePVError",
true);
1273 trackSelection.
add<
double>(
"b_pT",0.3684);
1274 trackSelection.
add<
double>(
"max_pT",500);
1275 trackSelection.
add<
bool>(
"useVariableJTA",
false);
1276 trackSelection.
add<
double>(
"maxDecayLen",99999.9);
1277 trackSelection.
add<
double>(
"sip3dValMin",-99999.9);
1278 trackSelection.
add<
double>(
"max_pT_dRcut",0.1);
1279 trackSelection.
add<
double>(
"a_pT",0.005263);
1280 trackSelection.
add<
unsigned int>(
"totalHitsMin",8);
1281 trackSelection.
add<
double>(
"jetDeltaRMax",0.3);
1282 trackSelection.
add<
double>(
"a_dR",-0.001053);
1283 trackSelection.
add<
double>(
"maxDistToAxis",0.2);
1284 trackSelection.
add<
double>(
"ptMin",1.0);
1286 trackSelection.
add<
unsigned int>(
"pixelHitsMin",2);
1287 trackSelection.
add<
double>(
"sip2dValMax",99999.9);
1288 trackSelection.
add<
double>(
"max_pT_trackPTcut",3);
1289 trackSelection.
add<
double>(
"sip2dValMin",-99999.9);
1290 trackSelection.
add<
double>(
"normChi2Max",99999.9);
1291 trackSelection.
add<
double>(
"sip3dValMax",99999.9);
1292 trackSelection.
add<
double>(
"sip3dSigMin",-99999.9);
1293 trackSelection.
add<
double>(
"min_pT",120);
1294 trackSelection.
add<
double>(
"min_pT_dRcut",0.5);
1295 trackSelection.
add<
double>(
"sip2dSigMax",99999.9);
1296 trackSelection.
add<
double>(
"sip3dSigMax",99999.9);
1297 trackSelection.
add<
double>(
"sip2dSigMin",-99999.9);
1298 trackSelection.
add<
double>(
"b_dR",0.6263);
math::Error< dimension >::type CovarianceMatrix
reco::Vertex::Point convertPos(const GlobalPoint &p)
value_type const * get() const
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::Jet > > token_fatJets
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
reco::btag::SortCriteria getCriterium(const std::string &name)
TemplatedSecondaryVertex< reco::Vertex > SecondaryVertex
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
TrackSelector trackSelector
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
trackRef_iterator tracks_end() const
last iterator over tracks
TemplatedSecondaryVertexProducer(const edm::ParameterSet ¶ms)
virtual void produce(edm::Event &event, const edm::EventSetup &es) override
const GlobalVector & direction
ClusterSequencePtr fjClusterSeq
virtual const Point & vertex() const
vertex position (overwritten by PF...)
boost::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
double y() const
y coordinate
Base class for all types of Jets.
CandidatePtr candidate() const
float totalChiSquared() const
reco::Vertex::Error convertError(const GlobalError &ge)
Measurement1D dist3d() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
Measurement1D dist2d() const
void setWeight(double weight)
SVFilter(const VertexFilter &filter, const Vertex &pv, const GlobalVector &direction)
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
VertexFilter vertexFilter
reco::btag::SortCriteria sortCriterium
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const reco::Track * toTrack(const reco::TrackBaseRef &t)
const Point & position() const
position
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
TemplatedSecondaryVertexProducer< TrackIPTagInfo, reco::Vertex > SecondaryVertexProducer
const AlgebraicSymMatrix33 & matrix_new() const
static GhostTrackVertexFinder::FitType getGhostTrackFitType(const std::string &name)
void matchReclusteredJets(const edm::Handle< CONTAINER > &jets, const std::vector< fastjet::PseudoJet > &matchedJets, std::vector< int > &matchedIndices, const std::string &jetType="")
ConstraintType constraint
edm::EDGetTokenT< std::vector< IPTI > > token_trackIPTagInfo
IPTI::input_container::value_type input_item
Container::value_type value_type
reco::btag::IndexedTrackData IndexedTrackData
void addDefault(ParameterSetDescription const &psetDescription)
GlobalVector flightDirection(const reco::Vertex &pv, const reco::Vertex &sv)
std::vector< reco::TransientTrack > const & originalTracks() const
float degreesOfFreedom() const
const reco::Jet * toJet(const IPTI &j)
GlobalPoint position() const
std::vector< edm::Ptr< pat::Jet > > JetPtrCollection
Abs< T >::type abs(const T &t)
double z() const
y coordinate
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
VertexSorting< SecondaryVertex > vertexSorting
std::vector< std::string > const & subjetCollectionNames() const
Subjet collection names.
static ConstraintType getConstraintType(const std::string &name)
~TemplatedSecondaryVertexProducer()
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
float trackWeight(const reco::TransientTrack &track) const
virtual void setVertex(const Point &vertex)
set vertex
void matchGroomedJets(const edm::Handle< edm::View< reco::Jet > > &jets, const edm::Handle< edm::View< reco::Jet > > &matchedJets, std::vector< int > &matchedIndices)
void matchSubjets(const std::vector< int > &groomedIndices, const edm::Handle< edm::View< reco::Jet > > &groomedJets, const edm::Handle< std::vector< IPTI > > &subjets, std::vector< std::vector< int > > &matchedIndices)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void markUsedTracks(TrackDataVector &trackData, const input_container &trackRefs, const SecondaryVertex &sv, size_t idx)
edm::EDGetTokenT< edm::View< VTX > > token_extSVCollection
Vector3DBase unit() const
SVBuilder(const reco::Vertex &pv, const GlobalVector &direction, bool withPVError, double minTrackWeight)
double x() const
x coordinate
virtual Vector momentum() const final
spatial momentum vector
TemplatedSecondaryVertex< VTX > SecondaryVertex
edm::ParameterSet vtxRecoPSet
edm::EDGetTokenT< edm::View< reco::Jet > > token_groomedFatJets
bool linearize(const GhostTrackPrediction &pred, bool initial=false, double lambda=0.)
XYZPointD XYZPoint
point in space with cartesian internal representation
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Analysis-level calorimeter jet class.
SecondaryVertex operator()(const TransientVertex &sv) const
Error error() const
return SMatrix
TemplatedSecondaryVertexProducer< CandIPTagInfo, reco::VertexCompositePtrCandidate > CandSecondaryVertexProducer
math::XYZTLorentzVector LorentzVector
Lorentz vector.
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
std::vector< reco::btag::IndexedTrackData > TrackDataVector
const GlobalVector & direction
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
static int position[264][3]
std::vector< TemplatedSecondaryVertexTagInfo< IPTI, VTX > > Product
void setCovariance(const CovarianceMatrix &m)
set covariance matrix
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
void addDaughter(const CandidatePtr &)
add a daughter via a reference
const VertexFilter & filter
math::XYZPoint Point
point in the space
GlobalError error() const
volatile std::atomic< bool > shutdown_flag false
void setChi2AndNdof(double chi2, double ndof)
set chi2 and ndof
trackRef_iterator tracks_begin() const
first iterator over tracks
JetDefPtr fjJetDefinition
VertexState const & vertexState() const
pat::JetPtrCollection const & subjets(unsigned int index=0) const
Access to subjet list.
const reco::Jet * toJet(const reco::Jet &j)
std::pair< unsigned int, TrackData > IndexedTrackData
Global3DVector GlobalVector
IPTI::input_container input_container
tuple trackSelector
Tracks selection.