CMS 3D CMS Logo

TemplatedSecondaryVertexProducer.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cstddef>
3 #include <functional>
4 #include <iterator>
5 #include <map>
6 #include <memory>
7 #include <set>
8 #include <string>
9 #include <vector>
10 
11 #include <boost/iterator/transform_iterator.hpp>
12 
24 
28 
33 
38 
46 
51 
57 
59 
60 #include "fastjet/JetDefinition.hh"
61 #include "fastjet/ClusterSequence.hh"
62 #include "fastjet/PseudoJet.hh"
63 
64 //
65 // constants, enums and typedefs
66 //
67 typedef std::shared_ptr<fastjet::ClusterSequence> ClusterSequencePtr;
68 typedef std::shared_ptr<fastjet::JetDefinition> JetDefPtr;
69 
70 using namespace reco;
71 
72 namespace {
73  class VertexInfo : public fastjet::PseudoJet::UserInfoBase {
74  public:
75  VertexInfo(const int vertexIndex) : m_vertexIndex(vertexIndex) {}
76 
77  inline const int vertexIndex() const { return m_vertexIndex; }
78 
79  protected:
80  int m_vertexIndex;
81  };
82 
83  template <typename T>
84  struct RefToBaseLess {
85  inline bool operator()(const edm::RefToBase<T> &r1, const edm::RefToBase<T> &r2) const {
86  return r1.id() < r2.id() || (r1.id() == r2.id() && r1.key() < r2.key());
87  }
88  };
89 } // namespace
90 
92  return GlobalVector(sv.x() - pv.x(), sv.y() - pv.y(), sv.z() - pv.z());
93 }
95  return GlobalVector(sv.vertex().x() - pv.x(), sv.vertex().y() - pv.y(), sv.vertex().z() - pv.z());
96 }
97 const math::XYZPoint &position(const reco::Vertex &sv) { return sv.position(); }
98 const math::XYZPoint &position(const reco::VertexCompositePtrCandidate &sv) { return sv.vertex(); }
99 
100 template <class IPTI, class VTX>
102 public:
105  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
106  typedef std::vector<TemplatedSecondaryVertexTagInfo<IPTI, VTX> > Product;
108  typedef typename IPTI::input_container input_container;
110  typedef typename std::vector<reco::btag::IndexedTrackData> TrackDataVector;
111  void produce(edm::Event &event, const edm::EventSetup &es) override;
112 
113 private:
114  template <class CONTAINER>
115  void matchReclusteredJets(const edm::Handle<CONTAINER> &jets,
116  const std::vector<fastjet::PseudoJet> &matchedJets,
117  std::vector<int> &matchedIndices,
118  const std::string &jetType = "");
119  void matchGroomedJets(const edm::Handle<edm::View<reco::Jet> > &jets,
120  const edm::Handle<edm::View<reco::Jet> > &matchedJets,
121  std::vector<int> &matchedIndices);
122  void matchSubjets(const std::vector<int> &groomedIndices,
123  const edm::Handle<edm::View<reco::Jet> > &groomedJets,
124  const edm::Handle<std::vector<IPTI> > &subjets,
125  std::vector<std::vector<int> > &matchedIndices);
126  void matchSubjets(const edm::Handle<edm::View<reco::Jet> > &fatJets,
127  const edm::Handle<std::vector<IPTI> > &subjets,
128  std::vector<std::vector<int> > &matchedIndices);
129 
130  const reco::Jet *toJet(const reco::Jet &j) { return &j; }
131  const reco::Jet *toJet(const IPTI &j) { return &(*(j.jet())); }
132 
134  CONSTRAINT_NONE = 0,
139  CONSTRAINT_PV_PRIMARIES_IN_FIT
140  };
141  static ConstraintType getConstraintType(const std::string &name);
142 
161  double rParam;
162  double jetPtMin;
170 
173 
174  void markUsedTracks(TrackDataVector &trackData,
175  const input_container &trackRefs,
176  const SecondaryVertex &sv,
177  size_t idx);
178 
179  struct SVBuilder {
180  SVBuilder(const reco::Vertex &pv, const GlobalVector &direction, bool withPVError, double minTrackWeight)
181  : pv(pv), direction(direction), withPVError(withPVError), minTrackWeight(minTrackWeight) {}
182  SecondaryVertex operator()(const TransientVertex &sv) const;
183 
184  SecondaryVertex operator()(const VTX &sv) const { return SecondaryVertex(pv, sv, direction, withPVError); }
185 
186  const Vertex &pv;
190  };
191 
192  struct SVFilter {
193  SVFilter(const VertexFilter &filter, const Vertex &pv, const GlobalVector &direction)
194  : filter(filter), pv(pv), direction(direction) {}
195 
196  inline bool operator()(const SecondaryVertex &sv) const { return !filter(pv, sv, direction); }
197 
199  const Vertex &pv;
201  };
202 };
203 template <class IPTI, class VTX>
206  if (name == "None")
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;
218  else
219  throw cms::Exception("InvalidArgument") << "TemplatedSecondaryVertexProducer: ``constraint'' parameter "
220  "value \""
221  << name << "\" not understood." << std::endl;
222 }
223 
225  if (name == "AlwaysWithGhostTrack")
227  else if (name == "SingleTracksWithGhostTrack")
229  else if (name == "RefitGhostTrackWithVertices")
231  else
232  throw cms::Exception("InvalidArgument") << "TemplatedSecondaryVertexProducer: ``fitType'' "
233  "parameter value \""
234  << name
235  << "\" for "
236  "GhostTrackVertexFinder settings not "
237  "understood."
238  << std::endl;
239 }
240 
241 template <class IPTI, class VTX>
243  : sortCriterium(TrackSorting::getCriterium(params.getParameter<std::string>("trackSort"))),
244  trackSelector(params.getParameter<edm::ParameterSet>("trackSelection")),
245  constraint(getConstraintType(params.getParameter<std::string>("constraint"))),
246  constraintScaling(1.0),
247  vtxRecoPSet(params.getParameter<edm::ParameterSet>("vertexReco")),
248  useGhostTrack(vtxRecoPSet.getParameter<std::string>("finder") == "gtvr"),
249  withPVError(params.getParameter<bool>("usePVError")),
250  minTrackWeight(params.getParameter<double>("minimumTrackWeight")),
251  vertexFilter(params.getParameter<edm::ParameterSet>("vertexCuts")),
252  vertexSorting(params.getParameter<edm::ParameterSet>("vertexSelection")) {
253  token_trackIPTagInfo = consumes<std::vector<IPTI> >(params.getParameter<edm::InputTag>("trackIPTagInfos"));
255  constraintScaling = params.getParameter<double>("pvErrorScaling");
256 
259  token_BeamSpot = consumes<reco::BeamSpot>(params.getParameter<edm::InputTag>("beamSpotTag"));
260  useExternalSV = false;
261  if (params.existsAs<bool>("useExternalSV"))
262  useExternalSV = params.getParameter<bool>("useExternalSV");
263  if (useExternalSV) {
264  token_extSVCollection = consumes<edm::View<VTX> >(params.getParameter<edm::InputTag>("extSVCollection"));
265  extSVDeltaRToJet = params.getParameter<double>("extSVDeltaRToJet");
266  }
267  useSVClustering = (params.existsAs<bool>("useSVClustering") ? params.getParameter<bool>("useSVClustering") : false);
268  useSVMomentum = (params.existsAs<bool>("useSVMomentum") ? params.getParameter<bool>("useSVMomentum") : false);
269  useFatJets = (useExternalSV && params.exists("fatJets"));
270  useGroomedFatJets = (useExternalSV && params.exists("groomedFatJets"));
271  if (useSVClustering) {
272  jetAlgorithm = params.getParameter<std::string>("jetAlgorithm");
273  rParam = params.getParameter<double>("rParam");
274  jetPtMin =
275  0.; // hardcoded to 0. since we simply want to recluster all input jets which already had some PtMin applied
277  (params.existsAs<double>("ghostRescaling") ? params.getParameter<double>("ghostRescaling") : 1e-18);
279  (params.existsAs<double>("relPtTolerance")
280  ? params.getParameter<double>("relPtTolerance")
281  : 1e-03); // 0.1% relative difference in Pt should be sufficient to detect possible misconfigurations
282 
283  // set jet algorithm
284  if (jetAlgorithm == "Kt")
285  fjJetDefinition = std::make_shared<fastjet::JetDefinition>(fastjet::kt_algorithm, rParam);
286  else if (jetAlgorithm == "CambridgeAachen")
287  fjJetDefinition = std::make_shared<fastjet::JetDefinition>(fastjet::cambridge_algorithm, rParam);
288  else if (jetAlgorithm == "AntiKt")
289  fjJetDefinition = std::make_shared<fastjet::JetDefinition>(fastjet::antikt_algorithm, rParam);
290  else
291  throw cms::Exception("InvalidJetAlgorithm") << "Jet clustering algorithm is invalid: " << jetAlgorithm
292  << ", use CambridgeAachen | Kt | AntiKt" << std::endl;
293  }
294  if (useFatJets) {
295  token_fatJets = consumes<edm::View<reco::Jet> >(params.getParameter<edm::InputTag>("fatJets"));
296  }
297  edm::InputTag srcWeights = params.getParameter<edm::InputTag>("weights");
298  if (!srcWeights.label().empty())
300  if (useGroomedFatJets) {
301  token_groomedFatJets = consumes<edm::View<reco::Jet> >(params.getParameter<edm::InputTag>("groomedFatJets"));
302  }
303  if (useFatJets && !useSVClustering)
304  rParam = params.getParameter<double>("rParam"); // will be used later as a dR cut
305 
306  produces<Product>();
307 }
308 template <class IPTI, class VTX>
310 
311 template <class IPTI, class VTX>
313  // typedef std::map<TrackBaseRef, TransientTrack,
314  // RefToBaseLess<Track> > TransientTrackMap;
315  //How about good old pointers?
316  typedef std::map<const Track *, TransientTrack> TransientTrackMap;
317 
319  es.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
320 
322  event.getByToken(token_trackIPTagInfo, trackIPTagInfos);
323 
324  // External Sec Vertex collection (e.g. for IVF usage)
325  edm::Handle<edm::View<VTX> > extSecVertex;
326  if (useExternalSV)
327  event.getByToken(token_extSVCollection, extSecVertex);
328 
329  edm::Handle<edm::View<reco::Jet> > fatJetsHandle;
330  edm::Handle<edm::View<reco::Jet> > groomedFatJetsHandle;
331  if (useFatJets) {
332  event.getByToken(token_fatJets, fatJetsHandle);
333  if (useGroomedFatJets) {
334  event.getByToken(token_groomedFatJets, groomedFatJetsHandle);
335 
336  if (groomedFatJetsHandle->size() > fatJetsHandle->size())
337  edm::LogError("TooManyGroomedJets")
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.";
340  }
341  }
342  edm::Handle<edm::ValueMap<float> > weightsHandle;
343  if (!token_weights.isUninitialized())
344  event.getByToken(token_weights, weightsHandle);
345 
347  unsigned int bsCovSrc[7] = {
348  0,
349  };
350  double sigmaZ = 0.0, beamWidth = 0.0;
351  switch (constraint) {
352  case CONSTRAINT_PV_BEAMSPOT_SIZE:
353  event.getByToken(token_BeamSpot, beamSpot);
354  bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = bsCovSrc[6] = 1;
355  sigmaZ = beamSpot->sigmaZ();
356  beamWidth = beamSpot->BeamWidthX();
357  break;
358 
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;
363  sigmaZ = beamSpot->sigmaZ();
364  break;
365 
366  case CONSTRAINT_PV_ERROR_SCALED:
367  bsCovSrc[0] = bsCovSrc[1] = bsCovSrc[2] = 2;
368  break;
369 
370  case CONSTRAINT_BEAMSPOT:
371  case CONSTRAINT_PV_PRIMARIES_IN_FIT:
372  event.getByToken(token_BeamSpot, beamSpot);
373  break;
374 
375  default:
376  /* nothing */;
377  }
378 
379  // ------------------------------------ SV clustering START --------------------------------------------
380  std::vector<std::vector<int> > clusteredSVs(trackIPTagInfos->size(), std::vector<int>());
381  if (useExternalSV && useSVClustering && !trackIPTagInfos->empty()) {
382  // vector of constituents for reclustering jets and "ghost" SVs
383  std::vector<fastjet::PseudoJet> fjInputs;
384  // loop over all input jets and collect all their constituents
385  if (useFatJets) {
386  for (edm::View<reco::Jet>::const_iterator it = fatJetsHandle->begin(); it != fatJetsHandle->end(); ++it) {
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) {
390  reco::CandidatePtr constit = *m;
391  if (constit->pt() == 0) {
392  edm::LogWarning("NullTransverseMomentum") << "dropping input candidate with pt=0";
393  continue;
394  }
395  if (it->isWeighted()) {
396  if (token_weights.isUninitialized())
397  throw cms::Exception("MissingConstituentWeight")
398  << "TemplatedSecondaryVertexProducer: No weights (e.g. PUPPI) given for weighted jet collection"
399  << std::endl;
400  float w = (*weightsHandle)[constit];
401  fjInputs.push_back(
402  fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
403  } else {
404  fjInputs.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
405  }
406  }
407  }
408  } else {
409  for (typename std::vector<IPTI>::const_iterator it = trackIPTagInfos->begin(); it != trackIPTagInfos->end();
410  ++it) {
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) {
414  reco::CandidatePtr constit = *m;
415  if (constit->pt() == 0) {
416  edm::LogWarning("NullTransverseMomentum") << "dropping input candidate with pt=0";
417  continue;
418  }
419  if (it->jet()->isWeighted()) {
420  if (token_weights.isUninitialized())
421  throw cms::Exception("MissingConstituentWeight")
422  << "TemplatedSecondaryVertexProducer: No weights (e.g. PUPPI) given for weighted jet collection"
423  << std::endl;
424  float w = (*weightsHandle)[constit];
425  fjInputs.push_back(
426  fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
427  } else {
428  fjInputs.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
429  }
430  }
431  }
432  }
433  // insert "ghost" SVs in the vector of constituents
434  for (typename edm::View<VTX>::const_iterator it = extSecVertex->begin(); it != extSecVertex->end(); ++it) {
435  const reco::Vertex &pv = *(trackIPTagInfos->front().primaryVertex());
437  dir = dir.unit();
438  fastjet::PseudoJet p(
439  dir.x(), dir.y(), dir.z(), dir.mag()); // using SV flight direction so treating SV as massless
440  if (useSVMomentum)
441  p = fastjet::PseudoJet(it->p4().px(), it->p4().py(), it->p4().pz(), it->p4().energy());
442  p *= ghostRescaling; // rescale SV direction/momentum
443  p.set_user_info(new VertexInfo(it - extSecVertex->begin()));
444  fjInputs.push_back(p);
445  }
446 
447  // define jet clustering sequence
448  fjClusterSeq = std::make_shared<fastjet::ClusterSequence>(fjInputs, *fjJetDefinition);
449  // recluster jet constituents and inserted "ghosts"
450  std::vector<fastjet::PseudoJet> inclusiveJets = fastjet::sorted_by_pt(fjClusterSeq->inclusive_jets(jetPtMin));
451 
452  if (useFatJets) {
453  if (inclusiveJets.size() < fatJetsHandle->size())
454  edm::LogError("TooFewReclusteredJets")
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.";
458 
459  // match reclustered and original fat jets
460  std::vector<int> reclusteredIndices;
461  matchReclusteredJets<edm::View<reco::Jet> >(fatJetsHandle, inclusiveJets, reclusteredIndices, "fat");
462 
463  // match groomed and original fat jets
464  std::vector<int> groomedIndices;
465  if (useGroomedFatJets)
466  matchGroomedJets(fatJetsHandle, groomedFatJetsHandle, groomedIndices);
467 
468  // match subjets and original fat jets
469  std::vector<std::vector<int> > subjetIndices;
470  if (useGroomedFatJets)
471  matchSubjets(groomedIndices, groomedFatJetsHandle, trackIPTagInfos, subjetIndices);
472  else
473  matchSubjets(fatJetsHandle, trackIPTagInfos, subjetIndices);
474 
475  // collect clustered SVs
476  for (size_t i = 0; i < fatJetsHandle->size(); ++i) {
477  if (reclusteredIndices.at(i) < 0)
478  continue; // continue if matching reclustered to original jets failed
479 
480  if (fatJetsHandle->at(i).pt() == 0) // continue if the original jet has Pt=0
481  {
482  edm::LogWarning("NullTransverseMomentum")
483  << "The original fat jet " << i << " has Pt=0. This is not expected so the jet will be skipped.";
484  continue;
485  }
486 
487  if (subjetIndices.at(i).empty())
488  continue; // continue if the original jet does not have subjets assigned
489 
490  // since the "ghosts" are extremely soft, the configuration and ordering of the reclustered and original fat jets should in principle stay the same
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.) // special handling for low-Pt jets (Pt<10 GeV)
494  edm::LogWarning("JetPtMismatchAtLowPt")
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.";
505  else
506  edm::LogError("JetPtMismatch")
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.";
516  }
517 
518  // get jet constituents
519  std::vector<fastjet::PseudoJet> constituents = inclusiveJets.at(reclusteredIndices.at(i)).constituents();
520 
521  std::vector<int> svIndices;
522  // loop over jet constituents and try to find "ghosts"
523  for (std::vector<fastjet::PseudoJet>::const_iterator it = constituents.begin(); it != constituents.end();
524  ++it) {
525  if (!it->has_user_info())
526  continue; // skip if not a "ghost"
527 
528  svIndices.push_back(it->user_info<VertexInfo>().vertexIndex());
529  }
530 
531  // loop over clustered SVs and assign them to different subjets based on smallest dR
532  for (size_t sv = 0; sv < svIndices.size(); ++sv) {
533  const reco::Vertex &pv = *(trackIPTagInfos->front().primaryVertex());
534  const VTX &extSV = (*extSecVertex)[svIndices.at(sv)];
536  dir = dir.unit();
537  fastjet::PseudoJet p(
538  dir.x(), dir.y(), dir.z(), dir.mag()); // using SV flight direction so treating SV as massless
539  if (useSVMomentum)
540  p = fastjet::PseudoJet(extSV.p4().px(), extSV.p4().py(), extSV.p4().pz(), extSV.p4().energy());
541 
542  std::vector<double> dR2toSubjets;
543 
544  for (size_t sj = 0; sj < subjetIndices.at(i).size(); ++sj)
545  dR2toSubjets.push_back(Geom::deltaR2(p.rapidity(),
546  p.phi_std(),
547  trackIPTagInfos->at(subjetIndices.at(i).at(sj)).jet()->rapidity(),
548  trackIPTagInfos->at(subjetIndices.at(i).at(sj)).jet()->phi()));
549 
550  // find the closest subjet
551  int closestSubjetIdx =
552  std::distance(dR2toSubjets.begin(), std::min_element(dR2toSubjets.begin(), dR2toSubjets.end()));
553 
554  clusteredSVs.at(subjetIndices.at(i).at(closestSubjetIdx)).push_back(svIndices.at(sv));
555  }
556  }
557  } else {
558  if (inclusiveJets.size() < trackIPTagInfos->size())
559  edm::LogError("TooFewReclusteredJets")
560  << "There are fewer reclustered (" << inclusiveJets.size() << ") than original jets ("
561  << trackIPTagInfos->size()
562  << "). Please check that the jet algorithm and jet size match those used for the original jet collection.";
563 
564  // match reclustered and original jets
565  std::vector<int> reclusteredIndices;
566  matchReclusteredJets<std::vector<IPTI> >(trackIPTagInfos, inclusiveJets, reclusteredIndices);
567 
568  // collect clustered SVs
569  for (size_t i = 0; i < trackIPTagInfos->size(); ++i) {
570  if (reclusteredIndices.at(i) < 0)
571  continue; // continue if matching reclustered to original jets failed
572 
573  if (trackIPTagInfos->at(i).jet()->pt() == 0) // continue if the original jet has Pt=0
574  {
575  edm::LogWarning("NullTransverseMomentum")
576  << "The original jet " << i << " has Pt=0. This is not expected so the jet will be skipped.";
577  continue;
578  }
579 
580  // since the "ghosts" are extremely soft, the configuration and ordering of the reclustered and original jets should in principle stay the same
581  if ((std::abs(inclusiveJets.at(reclusteredIndices.at(i)).pt() - trackIPTagInfos->at(i).jet()->pt()) /
582  trackIPTagInfos->at(i).jet()->pt()) > relPtTolerance) {
583  if (trackIPTagInfos->at(i).jet()->pt() < 10.) // special handling for low-Pt jets (Pt<10 GeV)
584  edm::LogWarning("JetPtMismatchAtLowPt")
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.";
595  else
596  edm::LogError("JetPtMismatch")
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.";
606  }
607 
608  // get jet constituents
609  std::vector<fastjet::PseudoJet> constituents = inclusiveJets.at(reclusteredIndices.at(i)).constituents();
610 
611  // loop over jet constituents and try to find "ghosts"
612  for (std::vector<fastjet::PseudoJet>::const_iterator it = constituents.begin(); it != constituents.end();
613  ++it) {
614  if (!it->has_user_info())
615  continue; // skip if not a "ghost"
616  // push back clustered SV indices
617  clusteredSVs.at(i).push_back(it->user_info<VertexInfo>().vertexIndex());
618  }
619  }
620  }
621  }
622  // case where fat jets are used to associate SVs to subjets but no SV clustering is performed
623  else if (useExternalSV && !useSVClustering && !trackIPTagInfos->empty() && useFatJets) {
624  // match groomed and original fat jets
625  std::vector<int> groomedIndices;
626  if (useGroomedFatJets)
627  matchGroomedJets(fatJetsHandle, groomedFatJetsHandle, groomedIndices);
628 
629  // match subjets and original fat jets
630  std::vector<std::vector<int> > subjetIndices;
631  if (useGroomedFatJets)
632  matchSubjets(groomedIndices, groomedFatJetsHandle, trackIPTagInfos, subjetIndices);
633  else
634  matchSubjets(fatJetsHandle, trackIPTagInfos, subjetIndices);
635 
636  // loop over fat jets
637  for (size_t i = 0; i < fatJetsHandle->size(); ++i) {
638  if (fatJetsHandle->at(i).pt() == 0) // continue if the original jet has Pt=0
639  {
640  edm::LogWarning("NullTransverseMomentum")
641  << "The original fat jet " << i << " has Pt=0. This is not expected so the jet will be skipped.";
642  continue;
643  }
644 
645  if (subjetIndices.at(i).empty())
646  continue; // continue if the original jet does not have subjets assigned
647 
648  // loop over SVs, associate them to fat jets based on dR cone and
649  // then assign them to the closets subjet in dR
650  for (typename edm::View<VTX>::const_iterator it = extSecVertex->begin(); it != extSecVertex->end(); ++it) {
651  size_t sv = (it - extSecVertex->begin());
652 
653  const reco::Vertex &pv = *(trackIPTagInfos->front().primaryVertex());
654  const VTX &extSV = (*extSecVertex)[sv];
656  GlobalVector jetDir(fatJetsHandle->at(i).px(), fatJetsHandle->at(i).py(), fatJetsHandle->at(i).pz());
657  // skip SVs outside the dR cone
658  if (Geom::deltaR2(dir, jetDir) > rParam * rParam) // here using the jet clustering rParam as a dR cut
659  continue;
660 
661  dir = dir.unit();
662  fastjet::PseudoJet p(
663  dir.x(), dir.y(), dir.z(), dir.mag()); // using SV flight direction so treating SV as massless
664  if (useSVMomentum)
665  p = fastjet::PseudoJet(extSV.p4().px(), extSV.p4().py(), extSV.p4().pz(), extSV.p4().energy());
666 
667  std::vector<double> dR2toSubjets;
668 
669  for (size_t sj = 0; sj < subjetIndices.at(i).size(); ++sj)
670  dR2toSubjets.push_back(Geom::deltaR2(p.rapidity(),
671  p.phi_std(),
672  trackIPTagInfos->at(subjetIndices.at(i).at(sj)).jet()->rapidity(),
673  trackIPTagInfos->at(subjetIndices.at(i).at(sj)).jet()->phi()));
674 
675  // find the closest subjet
676  int closestSubjetIdx =
677  std::distance(dR2toSubjets.begin(), std::min_element(dR2toSubjets.begin(), dR2toSubjets.end()));
678 
679  clusteredSVs.at(subjetIndices.at(i).at(closestSubjetIdx)).push_back(sv);
680  }
681  }
682  }
683  // ------------------------------------ SV clustering END ----------------------------------------------
684 
685  std::unique_ptr<ConfigurableVertexReconstructor> vertexReco;
686  std::unique_ptr<GhostTrackVertexFinder> vertexRecoGT;
687  if (useGhostTrack)
688  vertexRecoGT.reset(
689  new GhostTrackVertexFinder(vtxRecoPSet.getParameter<double>("maxFitChi2"),
690  vtxRecoPSet.getParameter<double>("mergeThreshold"),
691  vtxRecoPSet.getParameter<double>("primcut"),
692  vtxRecoPSet.getParameter<double>("seccut"),
693  getGhostTrackFitType(vtxRecoPSet.getParameter<std::string>("fitType"))));
694  else
695  vertexReco.reset(new ConfigurableVertexReconstructor(vtxRecoPSet));
696 
697  TransientTrackMap primariesMap;
698 
699  // result secondary vertices
700 
701  auto tagInfos = std::make_unique<Product>();
702 
703  for (typename std::vector<IPTI>::const_iterator iterJets = trackIPTagInfos->begin();
704  iterJets != trackIPTagInfos->end();
705  ++iterJets) {
706  TrackDataVector trackData;
707  // std::cout << "Jet " << iterJets-trackIPTagInfos->begin() << std::endl;
708 
709  const Vertex &pv = *iterJets->primaryVertex();
710 
711  std::set<TransientTrack> primaries;
712  if (constraint == CONSTRAINT_PV_PRIMARIES_IN_FIT) {
713  for (Vertex::trackRef_iterator iter = pv.tracks_begin(); iter != pv.tracks_end(); ++iter) {
714  TransientTrackMap::iterator pos = primariesMap.lower_bound(iter->get());
715 
716  if (pos != primariesMap.end() && pos->first == iter->get())
717  primaries.insert(pos->second);
718  else {
719  TransientTrack track = trackBuilder->build(iter->castTo<TrackRef>());
720  primariesMap.insert(pos, std::make_pair(iter->get(), track));
721  primaries.insert(track);
722  }
723  }
724  }
725 
726  edm::RefToBase<Jet> jetRef = iterJets->jet();
727 
728  GlobalVector jetDir(jetRef->momentum().x(), jetRef->momentum().y(), jetRef->momentum().z());
729 
730  std::vector<std::size_t> indices = iterJets->sortedIndexes(sortCriterium);
731 
732  input_container trackRefs = iterJets->sortedTracks(indices);
733 
734  const std::vector<reco::btag::TrackIPData> &ipData = iterJets->impactParameterData();
735 
736  // build transient tracks used for vertex reconstruction
737 
738  std::vector<TransientTrack> fitTracks;
739  std::vector<GhostTrackState> gtStates;
740  std::unique_ptr<GhostTrackPrediction> gtPred;
741  if (useGhostTrack)
742  gtPred.reset(new GhostTrackPrediction(*iterJets->ghostTrack()));
743 
744  for (unsigned int i = 0; i < indices.size(); i++) {
746 
747  const input_item &trackRef = trackRefs[i];
748 
749  trackData.push_back(IndexedTrackData());
750  trackData.back().first = indices[i];
751 
752  // select tracks for SV finder
753 
754  if (!trackSelector(
755  *reco::btag::toTrack(trackRef), ipData[indices[i]], *jetRef, RecoVertex::convertPos(pv.position()))) {
757  continue;
758  }
759 
760  TransientTrackMap::const_iterator pos = primariesMap.find(reco::btag::toTrack((trackRef)));
761  TransientTrack fitTrack;
762  if (pos != primariesMap.end()) {
763  primaries.erase(pos->second);
764  fitTrack = pos->second;
765  } else
766  fitTrack = trackBuilder->build(trackRef);
767  fitTracks.push_back(fitTrack);
768 
770 
771  if (useGhostTrack) {
772  GhostTrackState gtState(fitTrack);
773  GlobalPoint pos = ipData[indices[i]].closestToGhostTrack;
774  gtState.linearize(*gtPred, true, gtPred->lambda(pos));
775  gtState.setWeight(ipData[indices[i]].ghostTrackWeight);
776  gtStates.push_back(gtState);
777  }
778  }
779 
780  std::unique_ptr<GhostTrack> ghostTrack;
781  if (useGhostTrack)
782  ghostTrack.reset(new GhostTrack(
784  RecoVertex::convertPos(pv.position()),
785  RecoVertex::convertError(pv.error()),
786  GlobalVector(iterJets->ghostTrack()->px(), iterJets->ghostTrack()->py(), iterJets->ghostTrack()->pz()),
787  0.05),
788  *gtPred,
789  gtStates,
790  iterJets->ghostTrack()->chi2(),
791  iterJets->ghostTrack()->ndof()));
792 
793  // perform actual vertex finding
794 
795  std::vector<VTX> extAssoCollection;
796  std::vector<TransientVertex> fittedSVs;
797  std::vector<SecondaryVertex> SVs;
798  if (!useExternalSV) {
799  switch (constraint) {
800  case CONSTRAINT_NONE:
801  if (useGhostTrack)
802  fittedSVs = vertexRecoGT->vertices(pv, *ghostTrack);
803  else
804  fittedSVs = vertexReco->vertices(fitTracks);
805  break;
806 
807  case CONSTRAINT_BEAMSPOT:
808  if (useGhostTrack)
809  fittedSVs = vertexRecoGT->vertices(pv, *beamSpot, *ghostTrack);
810  else
811  fittedSVs = vertexReco->vertices(fitTracks, *beamSpot);
812  break;
813 
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++) {
821  double v = 0.0;
822  if (!covSrc || bsCovSrc[j] != covSrc)
823  v = 0.0;
824  else if (covSrc == 1)
825  v = beamSpot->covariance(i, j);
826  else if (j < 3 && i < 3)
827  v = pv.covariance(i, j) * constraintScaling;
828  cov(i, j) = v;
829  }
830  }
831 
832  BeamSpot bs(pv.position(),
833  sigmaZ,
834  beamSpot.isValid() ? beamSpot->dxdz() : 0.,
835  beamSpot.isValid() ? beamSpot->dydz() : 0.,
836  beamWidth,
837  cov,
839 
840  if (useGhostTrack)
841  fittedSVs = vertexRecoGT->vertices(pv, bs, *ghostTrack);
842  else
843  fittedSVs = vertexReco->vertices(fitTracks, bs);
844  } break;
845 
846  case CONSTRAINT_PV_PRIMARIES_IN_FIT: {
847  std::vector<TransientTrack> primaries_(primaries.begin(), primaries.end());
848  if (useGhostTrack)
849  fittedSVs = vertexRecoGT->vertices(pv, *beamSpot, primaries_, *ghostTrack);
850  else
851  fittedSVs = vertexReco->vertices(primaries_, fitTracks, *beamSpot);
852  } break;
853  }
854  // build combined SV information and filter
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),
859  SVFilter(vertexFilter, pv, jetDir));
860 
861  } else {
862  if (useSVClustering || useFatJets) {
863  size_t jetIdx = (iterJets - trackIPTagInfos->begin());
864 
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)
868  continue;
869  extAssoCollection.push_back(extVertex);
870  }
871  } else {
872  for (size_t iExtSv = 0; iExtSv < extSecVertex->size(); iExtSv++) {
873  const VTX &extVertex = (*extSecVertex)[iExtSv];
874  if (Geom::deltaR2((position(extVertex) - pv.position()), (extSVDeltaRToJet > 0) ? jetDir : -jetDir) >
876  extVertex.p4().M() < 0.3)
877  continue;
878  extAssoCollection.push_back(extVertex);
879  }
880  }
881  // build combined SV information and filter
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),
886  SVFilter(vertexFilter, pv, jetDir));
887  }
888  // clean up now unneeded collections
889  gtPred.reset();
890  ghostTrack.reset();
891  gtStates.clear();
892  fitTracks.clear();
893  fittedSVs.clear();
894  extAssoCollection.clear();
895 
896  // sort SVs by importance
897 
898  std::vector<unsigned int> vtxIndices = vertexSorting(SVs);
899 
900  std::vector<typename TemplatedSecondaryVertexTagInfo<IPTI, VTX>::VertexData> svData;
901 
902  svData.resize(vtxIndices.size());
903  for (unsigned int idx = 0; idx < vtxIndices.size(); idx++) {
904  const SecondaryVertex &sv = SVs[vtxIndices[idx]];
905 
906  svData[idx].vertex = sv;
907  svData[idx].dist1d = sv.dist1d();
908  svData[idx].dist2d = sv.dist2d();
909  svData[idx].dist3d = sv.dist3d();
910  svData[idx].direction = flightDirection(pv, sv);
911  // mark tracks successfully used in vertex fit
912  markUsedTracks(trackData, trackRefs, sv, idx);
913  }
914 
915  // fill result into tag infos
916 
918  trackData,
919  svData,
920  SVs.size(),
922  }
923 
924  event.put(std::move(tagInfos));
925 }
926 
927 //Need specialized template because reco::Vertex iterators are TrackBase and it is a mess to make general
928 template <>
930  const input_container &trackRefs,
931  const SecondaryVertex &sv,
932  size_t idx) {
933  for (Vertex::trackRef_iterator iter = sv.tracks_begin(); iter != sv.tracks_end(); ++iter) {
934  if (sv.trackWeight(*iter) < minTrackWeight)
935  continue;
936 
937  typename input_container::const_iterator pos =
938  std::find(trackRefs.begin(), trackRefs.end(), iter->castTo<input_item>());
939 
940  if (pos == trackRefs.end()) {
941  if (!useExternalSV)
942  throw cms::Exception("TrackNotFound") << "Could not find track from secondary "
943  "vertex in original tracks."
944  << std::endl;
945  } else {
946  unsigned int index = pos - trackRefs.begin();
947  trackData[index].second.svStatus =
948  (btag::TrackData::Status)((unsigned int)btag::TrackData::trackAssociatedToVertex + idx);
949  }
950  }
951 }
952 template <>
954  TrackDataVector &trackData, const input_container &trackRefs, const SecondaryVertex &sv, size_t idx) {
955  for (typename input_container::const_iterator iter = sv.daughterPtrVector().begin();
956  iter != sv.daughterPtrVector().end();
957  ++iter) {
958  typename input_container::const_iterator pos = std::find(trackRefs.begin(), trackRefs.end(), *iter);
959 
960  if (pos != trackRefs.end()) {
961  unsigned int index = pos - trackRefs.begin();
962  trackData[index].second.svStatus =
963  (btag::TrackData::Status)((unsigned int)btag::TrackData::trackAssociatedToVertex + idx);
964  }
965  }
966 }
967 
968 template <>
971  if (!sv.originalTracks().empty() && sv.originalTracks()[0].trackBaseRef().isNonnull())
973  else {
974  edm::LogError("UnexpectedInputs") << "Building from Candidates, should not happen!";
976  }
977 }
978 
979 template <>
982  const TransientVertex &sv) const {
983  if (!sv.originalTracks().empty() && sv.originalTracks()[0].trackBaseRef().isNonnull()) {
984  edm::LogError("UnexpectedInputs") << "Building from Tracks, should not happen!";
985  VertexCompositePtrCandidate vtxCompPtrCand;
986 
987  vtxCompPtrCand.setCovariance(sv.vertexState().error().matrix());
988  vtxCompPtrCand.setChi2AndNdof(sv.totalChiSquared(), sv.degreesOfFreedom());
989  vtxCompPtrCand.setVertex(Candidate::Point(sv.position().x(), sv.position().y(), sv.position().z()));
990 
991  return SecondaryVertex(pv, vtxCompPtrCand, direction, withPVError);
992  } else {
993  VertexCompositePtrCandidate vtxCompPtrCand;
994 
995  vtxCompPtrCand.setCovariance(sv.vertexState().error().matrix());
996  vtxCompPtrCand.setChi2AndNdof(sv.totalChiSquared(), sv.degreesOfFreedom());
997  vtxCompPtrCand.setVertex(Candidate::Point(sv.position().x(), sv.position().y(), sv.position().z()));
998 
1000  for (std::vector<reco::TransientTrack>::const_iterator tt = sv.originalTracks().begin();
1001  tt != sv.originalTracks().end();
1002  ++tt) {
1003  if (sv.trackWeight(*tt) < minTrackWeight)
1004  continue;
1005 
1006  const CandidatePtrTransientTrack *cptt =
1007  dynamic_cast<const CandidatePtrTransientTrack *>(tt->basicTransientTrack());
1008  if (cptt == nullptr)
1009  edm::LogError("DynamicCastingFailed") << "Casting of TransientTrack to CandidatePtrTransientTrack failed!";
1010  else {
1011  p4 += cptt->candidate()->p4();
1012  vtxCompPtrCand.addDaughter(cptt->candidate());
1013  }
1014  }
1015  vtxCompPtrCand.setP4(p4);
1016 
1017  return SecondaryVertex(pv, vtxCompPtrCand, direction, withPVError);
1018  }
1019 }
1020 
1021 // ------------ method that matches reclustered and original jets based on minimum dR ------------
1022 template <class IPTI, class VTX>
1023 template <class CONTAINER>
1026  const std::vector<fastjet::PseudoJet> &reclusteredJets,
1027  std::vector<int> &matchedIndices,
1028  const std::string &jetType) {
1029  std::string type = (!jetType.empty() ? jetType + " " : jetType);
1030 
1031  std::vector<bool> matchedLocks(reclusteredJets.size(), false);
1032 
1033  for (size_t j = 0; j < jets->size(); ++j) {
1034  double matchedDR2 = 1e9;
1035  int matchedIdx = -1;
1036 
1037  for (size_t rj = 0; rj < reclusteredJets.size(); ++rj) {
1038  if (matchedLocks.at(rj))
1039  continue; // skip jets that have already been matched
1040 
1041  double tempDR2 = Geom::deltaR2(toJet(jets->at(j))->rapidity(),
1042  toJet(jets->at(j))->phi(),
1043  reclusteredJets.at(rj).rapidity(),
1044  reclusteredJets.at(rj).phi_std());
1045  if (tempDR2 < matchedDR2) {
1046  matchedDR2 = tempDR2;
1047  matchedIdx = rj;
1048  }
1049  }
1050 
1051  if (matchedIdx >= 0) {
1052  if (matchedDR2 > rParam * rParam) {
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.";
1059  } else
1060  matchedLocks.at(matchedIdx) = true;
1061  } else
1062  edm::LogError("JetMatchingFailed")
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.";
1066 
1067  matchedIndices.push_back(matchedIdx);
1068  }
1069 }
1070 
1071 // ------------ method that matches groomed and original jets based on minimum dR ------------
1072 template <class IPTI, class VTX>
1074  const edm::Handle<edm::View<reco::Jet> > &groomedJets,
1075  std::vector<int> &matchedIndices) {
1076  std::vector<bool> jetLocks(jets->size(), false);
1077  std::vector<int> jetIndices;
1078 
1079  for (size_t gj = 0; gj < groomedJets->size(); ++gj) {
1080  double matchedDR2 = 1e9;
1081  int matchedIdx = -1;
1082 
1083  if (groomedJets->at(gj).pt() > 0.) // skip pathological cases of groomed jets with Pt=0
1084  {
1085  for (size_t j = 0; j < jets->size(); ++j) {
1086  if (jetLocks.at(j))
1087  continue; // skip jets that have already been matched
1088 
1089  double tempDR2 = Geom::deltaR2(
1090  jets->at(j).rapidity(), jets->at(j).phi(), groomedJets->at(gj).rapidity(), groomedJets->at(gj).phi());
1091  if (tempDR2 < matchedDR2) {
1092  matchedDR2 = tempDR2;
1093  matchedIdx = j;
1094  }
1095  }
1096  }
1097 
1098  if (matchedIdx >= 0) {
1099  if (matchedDR2 > rParam * rParam) {
1100  edm::LogWarning("MatchedJetsFarApart")
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
1103  << ".\n"
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.";
1106  matchedIdx = -1;
1107  } else
1108  jetLocks.at(matchedIdx) = true;
1109  }
1110  jetIndices.push_back(matchedIdx);
1111  }
1112 
1113  for (size_t j = 0; j < jets->size(); ++j) {
1114  std::vector<int>::iterator matchedIndex = std::find(jetIndices.begin(), jetIndices.end(), j);
1115 
1116  matchedIndices.push_back(matchedIndex != jetIndices.end() ? std::distance(jetIndices.begin(), matchedIndex) : -1);
1117  }
1118 }
1119 
1120 // ------------ method that matches subjets and original fat jets ------------
1121 template <class IPTI, class VTX>
1122 void TemplatedSecondaryVertexProducer<IPTI, VTX>::matchSubjets(const std::vector<int> &groomedIndices,
1123  const edm::Handle<edm::View<reco::Jet> > &groomedJets,
1124  const edm::Handle<std::vector<IPTI> > &subjets,
1125  std::vector<std::vector<int> > &matchedIndices) {
1126  for (size_t g = 0; g < groomedIndices.size(); ++g) {
1127  std::vector<int> subjetIndices;
1128 
1129  if (groomedIndices.at(g) >= 0) {
1130  for (size_t s = 0; s < groomedJets->at(groomedIndices.at(g)).numberOfDaughters(); ++s) {
1131  const edm::Ptr<reco::Candidate> &subjet = groomedJets->at(groomedIndices.at(g)).daughterPtr(s);
1132 
1133  for (size_t sj = 0; sj < subjets->size(); ++sj) {
1134  const edm::RefToBase<reco::Jet> &subjetRef = subjets->at(sj).jet();
1135  if (subjet == edm::Ptr<reco::Candidate>(subjetRef.id(), subjetRef.get(), subjetRef.key())) {
1136  subjetIndices.push_back(sj);
1137  break;
1138  }
1139  }
1140  }
1141 
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.";
1145 
1146  matchedIndices.push_back(subjetIndices);
1147  } else
1148  matchedIndices.push_back(subjetIndices);
1149  }
1150 }
1151 
1152 // ------------ method that matches subjets and original fat jets ------------
1153 template <class IPTI, class VTX>
1155  const edm::Handle<std::vector<IPTI> > &subjets,
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;
1161 
1162  const pat::Jet *fatJet = dynamic_cast<const pat::Jet *>(fatJets->ptrAt(fj).get());
1163 
1164  if (!fatJet) {
1165  if (fj == 0)
1166  edm::LogError("WrongJetType")
1167  << "Wrong jet type for input fat jets. Please check that the input fat jets are of the pat::Jet type.";
1168 
1169  matchedIndices.push_back(subjetIndices);
1170  continue;
1171  } else {
1172  nSubjetCollections = fatJet->subjetCollectionNames().size();
1173 
1174  if (nSubjetCollections > 0) {
1175  for (size_t coll = 0; coll < nSubjetCollections; ++coll) {
1176  const pat::JetPtrCollection &fatJetSubjets = fatJet->subjets(coll);
1177 
1178  for (size_t fjsj = 0; fjsj < fatJetSubjets.size(); ++fjsj) {
1179  ++nSubjets;
1180 
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());
1183 
1184  if (!subJet) {
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.";
1188 
1189  break;
1190  } else {
1191  if (subJet->originalObjectRef() == fatJetSubjets.at(fjsj)->originalObjectRef()) {
1192  subjetIndices.push_back(sj);
1193  break;
1194  }
1195  }
1196  }
1197  }
1198  }
1199 
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.";
1203 
1204  matchedIndices.push_back(subjetIndices);
1205  } else
1206  matchedIndices.push_back(subjetIndices);
1207  }
1208  }
1209 }
1210 
1211 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
1212 template <class IPTI, class VTX>
1215  desc.add<double>("extSVDeltaRToJet", 0.3);
1216  desc.add<edm::InputTag>("beamSpotTag", edm::InputTag("offlineBeamSpot"));
1217  {
1219  vertexReco.add<double>("primcut", 1.8);
1220  vertexReco.add<double>("seccut", 6.0);
1221  vertexReco.add<std::string>("finder", "avr");
1222  vertexReco.addOptionalNode(edm::ParameterDescription<double>("minweight", 0.5, true) and
1223  edm::ParameterDescription<double>("weightthreshold", 0.001, true) and
1224  edm::ParameterDescription<bool>("smoothing", false, true),
1225  true);
1226  vertexReco.addOptionalNode(
1227  edm::ParameterDescription<double>("maxFitChi2", 10.0, true) and
1228  edm::ParameterDescription<double>("mergeThreshold", 3.0, true) and
1229  edm::ParameterDescription<std::string>("fitType", "RefitGhostTrackWithVertices", true),
1230  true);
1231  desc.add<edm::ParameterSetDescription>("vertexReco", vertexReco);
1232  }
1233  {
1235  vertexSelection.add<std::string>("sortCriterium", "dist3dError");
1236  desc.add<edm::ParameterSetDescription>("vertexSelection", vertexSelection);
1237  }
1238  desc.add<std::string>("constraint", "BeamSpot");
1239  desc.add<edm::InputTag>("trackIPTagInfos", edm::InputTag("impactParameterTagInfos"));
1240  {
1242  vertexCuts.add<double>("distSig3dMax", 99999.9);
1243  vertexCuts.add<double>("fracPV", 0.65);
1244  vertexCuts.add<double>("distVal2dMax", 2.5);
1245  vertexCuts.add<bool>("useTrackWeights", true);
1246  vertexCuts.add<double>("maxDeltaRToJetAxis", 0.4);
1247  {
1249  v0Filter.add<double>("k0sMassWindow", 0.05);
1251  }
1252  vertexCuts.add<double>("distSig2dMin", 3.0);
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);
1259  vertexCuts.add<double>("massMax", 6.5);
1260  vertexCuts.add<double>("distSig3dMin", -99999.9);
1261  desc.add<edm::ParameterSetDescription>("vertexCuts", vertexCuts);
1262  }
1263  desc.add<bool>("useExternalSV", false);
1264  desc.add<double>("minimumTrackWeight", 0.5);
1265  desc.add<bool>("usePVError", true);
1266  {
1268  trackSelection.add<double>("b_pT", 0.3684);
1269  trackSelection.add<double>("max_pT", 500);
1270  trackSelection.add<bool>("useVariableJTA", false);
1271  trackSelection.add<double>("maxDecayLen", 99999.9);
1272  trackSelection.add<double>("sip3dValMin", -99999.9);
1273  trackSelection.add<double>("max_pT_dRcut", 0.1);
1274  trackSelection.add<double>("a_pT", 0.005263);
1275  trackSelection.add<unsigned int>("totalHitsMin", 8);
1276  trackSelection.add<double>("jetDeltaRMax", 0.3);
1277  trackSelection.add<double>("a_dR", -0.001053);
1278  trackSelection.add<double>("maxDistToAxis", 0.2);
1279  trackSelection.add<double>("ptMin", 1.0);
1280  trackSelection.add<std::string>("qualityClass", "any");
1281  trackSelection.add<unsigned int>("pixelHitsMin", 2);
1282  trackSelection.add<double>("sip2dValMax", 99999.9);
1283  trackSelection.add<double>("max_pT_trackPTcut", 3);
1284  trackSelection.add<double>("sip2dValMin", -99999.9);
1285  trackSelection.add<double>("normChi2Max", 99999.9);
1286  trackSelection.add<double>("sip3dValMax", 99999.9);
1287  trackSelection.add<double>("sip3dSigMin", -99999.9);
1288  trackSelection.add<double>("min_pT", 120);
1289  trackSelection.add<double>("min_pT_dRcut", 0.5);
1290  trackSelection.add<double>("sip2dSigMax", 99999.9);
1291  trackSelection.add<double>("sip3dSigMax", 99999.9);
1292  trackSelection.add<double>("sip2dSigMin", -99999.9);
1293  trackSelection.add<double>("b_dR", 0.6263);
1294  desc.add<edm::ParameterSetDescription>("trackSelection", trackSelection);
1295  }
1296  desc.add<std::string>("trackSort", "sip3dSig");
1297  desc.add<edm::InputTag>("extSVCollection", edm::InputTag("secondaryVertices"));
1298  desc.addOptionalNode(edm::ParameterDescription<bool>("useSVClustering", false, true) and
1299  edm::ParameterDescription<std::string>("jetAlgorithm", true) and
1300  edm::ParameterDescription<double>("rParam", true),
1301  true);
1302  desc.addOptional<bool>("useSVMomentum", false);
1303  desc.addOptional<double>("ghostRescaling", 1e-18);
1304  desc.addOptional<double>("relPtTolerance", 1e-03);
1305  desc.addOptional<edm::InputTag>("fatJets");
1306  desc.addOptional<edm::InputTag>("groomedFatJets");
1307  desc.add<edm::InputTag>("weights", edm::InputTag(""));
1308  descriptions.addDefault(desc);
1309 }
1310 
1311 //define this as a plug-in
1314 
TrackSorting
Definition: TrackSorting.h:8
Vector3DBase
Definition: Vector3DBase.h:8
ConfigurationDescriptions.h
reco::Candidate::energy
virtual double energy() const =0
energy
egmGedGsfElectronPFIsolation_cff.vertexIndex
vertexIndex
Definition: egmGedGsfElectronPFIsolation_cff.py:54
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
GhostTrackPrediction.h
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
SecondaryVertexProducer
TemplatedSecondaryVertexProducer< TrackIPTagInfo, reco::Vertex > SecondaryVertexProducer
Definition: TemplatedSecondaryVertexProducer.cc:1312
TemplatedSecondaryVertexProducer::useFatJets
bool useFatJets
Definition: TemplatedSecondaryVertexProducer.cc:165
HLT_2018_cff.trackSelection
trackSelection
Definition: HLT_2018_cff.py:5407
TemplatedSecondaryVertexProducer::token_weights
edm::EDGetTokenT< edm::ValueMap< float > > token_weights
Definition: TemplatedSecondaryVertexProducer.cc:169
HLT_2018_cff.tagInfos
tagInfos
Definition: HLT_2018_cff.py:51519
reco::VertexCompositePtrCandidate::setChi2AndNdof
void setChi2AndNdof(double chi2, double ndof)
set chi2 and ndof
Definition: VertexCompositePtrCandidate.h:94
ClusterSequencePtr
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
Definition: TemplatedSecondaryVertexProducer.cc:67
flightDirection
GlobalVector flightDirection(const reco::Vertex &pv, const reco::Vertex &sv)
Definition: TemplatedSecondaryVertexProducer.cc:91
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
MessageLogger.h
TemplatedSecondaryVertexProducer::constraintScaling
double constraintScaling
Definition: TemplatedSecondaryVertexProducer.cc:148
TemplatedSecondaryVertexProducer::minTrackWeight
double minTrackWeight
Definition: TemplatedSecondaryVertexProducer.cc:152
TemplatedSecondaryVertexProducer::Product
std::vector< TemplatedSecondaryVertexTagInfo< IPTI, VTX > > Product
Definition: TemplatedSecondaryVertexProducer.cc:106
TemplatedSecondaryVertexProducer::vertexFilter
VertexFilter vertexFilter
Definition: TemplatedSecondaryVertexProducer.cc:153
reco::SecondaryVertex
TemplatedSecondaryVertex< reco::Vertex > SecondaryVertex
Definition: SecondaryVertex.h:11
TemplatedSecondaryVertexProducer::useExternalSV
bool useExternalSV
Definition: TemplatedSecondaryVertexProducer.cc:155
TemplatedSecondaryVertexProducer::SVBuilder
Definition: TemplatedSecondaryVertexProducer.cc:179
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
edm::RefToBase::key
size_t key() const
Definition: RefToBase.h:219
pat::Jet::subjets
pat::JetPtrCollection const & subjets(unsigned int index=0) const
Access to subjet list.
HiggsMonitoring_cfi.vertexSelection
vertexSelection
Definition: HiggsMonitoring_cfi.py:107
TemplatedSecondaryVertexProducer::SVBuilder::SVBuilder
SVBuilder(const reco::Vertex &pv, const GlobalVector &direction, bool withPVError, double minTrackWeight)
Definition: TemplatedSecondaryVertexProducer.cc:180
CandIPTagInfo.h
TemplatedSecondaryVertexProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TemplatedSecondaryVertexProducer.cc:1213
TemplatedSecondaryVertexProducer::toJet
const reco::Jet * toJet(const reco::Jet &j)
Definition: TemplatedSecondaryVertexProducer.cc:130
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
TemplatedSecondaryVertexProducer::markUsedTracks
void markUsedTracks(TrackDataVector &trackData, const input_container &trackRefs, const SecondaryVertex &sv, size_t idx)
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
reco::btag::toTrack
const reco::Track * toTrack(const reco::TrackBaseRef &t)
Definition: IPTagInfo.h:24
TemplatedSecondaryVertexProducer::trackSelector
TrackSelector trackSelector
Definition: TemplatedSecondaryVertexProducer.cc:146
VectorUtil.h
edm::EDGetTokenT< reco::BeamSpot >
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::GhostTrackVertexFinder::kSingleTracksWithGhostTrack
Definition: GhostTrackVertexFinder.h:31
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pos
Definition: PixelAliasList.h:18
reco::TemplatedSecondaryVertexTagInfo
Definition: TemplatedSecondaryVertexTagInfo.h:47
TemplatedSecondaryVertexProducer::SVBuilder::pv
const Vertex & pv
Definition: TemplatedSecondaryVertexProducer.cc:186
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
AK4PFJetsMCFlavourInfos_cfi.ghostRescaling
ghostRescaling
Definition: AK4PFJetsMCFlavourInfos_cfi.py:11
Measurement1D.h
reco::GhostTrackState::setWeight
void setWeight(double weight)
Definition: GhostTrackState.h:64
reco::VertexSorting
Definition: VertexSorting.h:18
SecondaryVertex.h
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
TemplatedSecondaryVertexProducer::SecondaryVertex
TemplatedSecondaryVertex< VTX > SecondaryVertex
Definition: TemplatedSecondaryVertexProducer.cc:107
EDProducer.h
reco::CandidatePtrTransientTrack
Definition: CandidatePtrTransientTrack.h:19
reco::Unknown
Definition: MuonSimInfo.h:32
ConvertToFromReco.h
TemplatedSecondaryVertexProducer::useGroomedFatJets
bool useGroomedFatJets
Definition: TemplatedSecondaryVertexProducer.cc:166
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
IfExistsDescription.h
GhostTrackState.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TransientTrack.h
findQualityFiles.v
v
Definition: findQualityFiles.py:179
position
const math::XYZPoint & position(const reco::Vertex &sv)
Definition: TemplatedSecondaryVertexProducer.cc:97
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::btag::SortCriteria
SortCriteria
Definition: IPTagInfo.h:43
btagGenBb_cfi.Status
Status
Definition: btagGenBb_cfi.py:4
TemplatedSecondaryVertexProducer::token_groomedFatJets
edm::EDGetTokenT< edm::View< reco::Jet > > token_groomedFatJets
Definition: TemplatedSecondaryVertexProducer.cc:168
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
TemplatedSecondaryVertexProducer::token_BeamSpot
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
Definition: TemplatedSecondaryVertexProducer.cc:143
reco::VertexCompositePtrCandidate
Definition: VertexCompositePtrCandidate.h:16
TemplatedSecondaryVertexProducer::getConstraintType
static ConstraintType getConstraintType(const std::string &name)
Definition: TemplatedSecondaryVertexProducer.cc:205
TemplatedSecondaryVertexProducer::SVFilter::operator()
bool operator()(const SecondaryVertex &sv) const
Definition: TemplatedSecondaryVertexProducer.cc:196
edm::Ref< TrackCollection >
reco::GhostTrackState
Definition: GhostTrackState.h:21
HLT_2018_cff.vertexReco
vertexReco
Definition: HLT_2018_cff.py:50395
VertexFilter.h
TemplatedSecondaryVertexProducer::extSVDeltaRToJet
double extSVDeltaRToJet
Definition: TemplatedSecondaryVertexProducer.cc:156
reco::btag::IndexedTrackData
std::pair< unsigned int, TrackData > IndexedTrackData
Definition: TemplatedSecondaryVertexTagInfo.h:43
edm::ParameterSetDescription::addOptionalNode
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
Definition: ParameterSetDescription.cc:50
TemplatedSecondaryVertexProducer::input_item
IPTI::input_container::value_type input_item
Definition: TemplatedSecondaryVertexProducer.cc:109
TemplatedSecondaryVertexProducer::SVBuilder::operator()
SecondaryVertex operator()(const TransientVertex &sv) const
TemplatedSecondaryVertexProducer::matchSubjets
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)
Definition: TemplatedSecondaryVertexProducer.cc:1122
MakerMacros.h
TemplatedSecondaryVertexProducer::~TemplatedSecondaryVertexProducer
~TemplatedSecondaryVertexProducer() override
Definition: TemplatedSecondaryVertexProducer.cc:309
TemplatedSecondaryVertexProducer::vtxRecoPSet
edm::ParameterSet vtxRecoPSet
Definition: TemplatedSecondaryVertexProducer.cc:149
alignCSCRings.s
s
Definition: alignCSCRings.py:92
reco::Candidate::pz
virtual double pz() const =0
z coordinate of momentum vector
cms::cuda::bs
bs
Definition: HistoContainer.h:127
pat::Jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
VertexSorting.h
HLT_2018_cff.sortCriterium
sortCriterium
Definition: HLT_2018_cff.py:50465
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TemplatedSecondaryVertexProducer::sortCriterium
reco::btag::SortCriteria sortCriterium
Definition: TemplatedSecondaryVertexProducer.cc:145
ProductProvenance.h
SecondaryVertexTagInfo.h
w
const double w
Definition: UKUtility.cc:23
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
TemplatedSecondaryVertexProducer::CONSTRAINT_BEAMSPOT
Definition: TemplatedSecondaryVertexProducer.cc:135
TemplatedSecondaryVertexProducer::toJet
const reco::Jet * toJet(const IPTI &j)
Definition: TemplatedSecondaryVertexProducer.cc:131
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TemplatedSecondaryVertexProducer::SVFilter::filter
const VertexFilter & filter
Definition: TemplatedSecondaryVertexProducer.cc:198
TemplatedSecondaryVertexProducer::SVBuilder::minTrackWeight
double minTrackWeight
Definition: TemplatedSecondaryVertexProducer.cc:189
TrackIPTagInfo.h
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
reco::BeamSpot
Definition: BeamSpot.h:21
TransientTrackRecord
Definition: TransientTrackRecord.h:11
TemplatedSecondaryVertexProducer::token_trackIPTagInfo
edm::EDGetTokenT< std::vector< IPTI > > token_trackIPTagInfo
Definition: TemplatedSecondaryVertexProducer.cc:144
edm::ESHandle< TransientTrackBuilder >
CandSecondaryVertexProducer
TemplatedSecondaryVertexProducer< CandIPTagInfo, reco::VertexCompositePtrCandidate > CandSecondaryVertexProducer
Definition: TemplatedSecondaryVertexProducer.cc:1313
TemplatedSecondaryVertexProducer::ConstraintType
ConstraintType
Definition: TemplatedSecondaryVertexProducer.cc:133
TemplatedSecondaryVertexProducer::useSVMomentum
bool useSVMomentum
Definition: TemplatedSecondaryVertexProducer.cc:159
TemplatedSecondaryVertexProducer::CONSTRAINT_PV_ERROR_SCALED
Definition: TemplatedSecondaryVertexProducer.cc:138
reco::TemplatedSecondaryVertexTagInfo::IndexedTrackData
reco::btag::IndexedTrackData IndexedTrackData
Definition: TemplatedSecondaryVertexTagInfo.h:50
Point3DBase< float, GlobalTag >
TemplatedSecondaryVertexProducer::rParam
double rParam
Definition: TemplatedSecondaryVertexProducer.cc:161
ParameterSetDescription.h
HLT_2018_cff.rParam
rParam
Definition: HLT_2018_cff.py:7349
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
edm::RefToBase::get
value_type const * get() const
Definition: RefToBase.h:209
reco::LeafCandidate::setVertex
void setVertex(const Point &vertex) override
set vertex
Definition: LeafCandidate.h:173
HLT_2018_cff.srcWeights
srcWeights
Definition: HLT_2018_cff.py:7335
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
TemplatedSecondaryVertexProducer::fjClusterSeq
ClusterSequencePtr fjClusterSeq
Definition: TemplatedSecondaryVertexProducer.cc:171
reco::VertexFilter
Definition: VertexFilter.h:25
edm::LogWarning
Definition: MessageLogger.h:141
reco::Candidate::py
virtual double py() const =0
y coordinate of momentum vector
pat::PATObject::originalObjectRef
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:542
edm::View
Definition: CaloClusterFwd.h:14
HLT_2018_cff.vertexCuts
vertexCuts
Definition: HLT_2018_cff.py:50468
pat::Jet::subjetCollectionNames
std::vector< std::string > const & subjetCollectionNames() const
Subjet collection names.
Definition: Jet.h:566
JetDefPtr
std::shared_ptr< fastjet::JetDefinition > JetDefPtr
Definition: TemplatedSecondaryVertexProducer.cc:68
TemplatedSecondaryVertexProducer::SVFilter::SVFilter
SVFilter(const VertexFilter &filter, const Vertex &pv, const GlobalVector &direction)
Definition: TemplatedSecondaryVertexProducer.cc:193
TransientTrackBuilder.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
TemplatedSecondaryVertexProducer::ghostRescaling
double ghostRescaling
Definition: TemplatedSecondaryVertexProducer.cc:163
edm::ParameterSet
Definition: ParameterSet.h:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
electrons_cff.jetIdx
jetIdx
Definition: electrons_cff.py:356
edm::LogError
Definition: MessageLogger.h:183
TemplatedSecondaryVertexProducer::useGhostTrack
bool useGhostTrack
Definition: TemplatedSecondaryVertexProducer.cc:150
RecoVertex::convertError
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
Event.h
ParameterSet
Definition: Functions.h:16
TemplatedSecondaryVertexProducer::SVBuilder::operator()
SecondaryVertex operator()(const VTX &sv) const
Definition: TemplatedSecondaryVertexProducer.cc:184
TemplatedSecondaryVertexProducer::constraint
ConstraintType constraint
Definition: TemplatedSecondaryVertexProducer.cc:147
TemplatedSecondaryVertexProducer::input_container
IPTI::input_container input_container
Definition: TemplatedSecondaryVertexProducer.cc:108
TemplatedSecondaryVertexProducer::vertexSorting
VertexSorting< SecondaryVertex > vertexSorting
Definition: TemplatedSecondaryVertexProducer.cc:154
TemplatedSecondaryVertexProducer::SVBuilder::withPVError
bool withPVError
Definition: TemplatedSecondaryVertexProducer.cc:188
TemplatedSecondaryVertexProducer::SVBuilder::direction
const GlobalVector & direction
Definition: TemplatedSecondaryVertexProducer.cc:187
TemplatedSecondaryVertexProducer::matchReclusteredJets
void matchReclusteredJets(const edm::Handle< CONTAINER > &jets, const std::vector< fastjet::PseudoJet > &matchedJets, std::vector< int > &matchedIndices, const std::string &jetType="")
Definition: TemplatedSecondaryVertexProducer.cc:1024
TemplatedSecondaryVertexProducer::CONSTRAINT_PV_BEAMSPOT_SIZE
Definition: TemplatedSecondaryVertexProducer.cc:136
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
TemplatedSecondaryVertexProducer::withPVError
bool withPVError
Definition: TemplatedSecondaryVertexProducer.cc:151
reco::GhostTrack
Definition: GhostTrack.h:16
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
p4
double p4[4]
Definition: TauolaWrapper.h:92
ConfigurableVertexReconstructor.h
TemplatedSecondaryVertexProducer::useSVClustering
bool useSVClustering
Definition: TemplatedSecondaryVertexProducer.cc:158
TrackSelector.h
pdwgLeptonRecoSkim_cfi.jetPtMin
jetPtMin
Definition: pdwgLeptonRecoSkim_cfi.py:31
edm::stream::EDProducer
Definition: EDProducer.h:38
reco::GhostTrackState::linearize
bool linearize(const GhostTrackPrediction &pred, bool initial=false, double lambda=0.)
Definition: GhostTrackState.h:47
TransientVertex
Definition: TransientVertex.h:18
edm::EventSetup
Definition: EventSetup.h:57
reco::BeamSpot::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
TemplatedSecondaryVertexProducer::jetAlgorithm
std::string jetAlgorithm
Definition: TemplatedSecondaryVertexProducer.cc:160
TransientTrackRecord.h
TemplatedSecondaryVertexProducer::relPtTolerance
double relPtTolerance
Definition: TemplatedSecondaryVertexProducer.cc:164
reco::VertexCompositePtrCandidate::setCovariance
void setCovariance(const CovarianceMatrix &m)
set covariance matrix
Definition: VertexCompositePtrCandidate.cc:51
get
#define get
Jet.h
TemplatedSecondaryVertexProducer::SVFilter::pv
const Vertex & pv
Definition: TemplatedSecondaryVertexProducer.cc:199
TemplatedSecondaryVertexProducer::SVFilter
Definition: TemplatedSecondaryVertexProducer.cc:192
HLT_2018_cff.useExternalSV
useExternalSV
Definition: HLT_2018_cff.py:50485
GhostTrackVertexFinder.h
ClusterSequencePtr
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
Definition: JetFlavourClustering.cc:108
JetDefPtr
std::shared_ptr< fastjet::JetDefinition > JetDefPtr
Definition: JetFlavourClustering.cc:109
InputTag.h
edm::Ptr< Candidate >
edm::RefToBase::id
ProductID id() const
Definition: RefToBase.h:214
HLT_2018_cff.v0Filter
v0Filter
Definition: HLT_2018_cff.py:50476
DDAxes::phi
Registry.h
reco::GhostTrackVertexFinder::kRefitGhostTrackWithVertices
Definition: GhostTrackVertexFinder.h:31
reco::TrackSelector
Definition: TrackSelector.h:14
CandidatePtrTransientTrack.h
TemplatedSecondaryVertexProducer::CONSTRAINT_PV_BS_Z_ERRORS_SCALED
Definition: TemplatedSecondaryVertexProducer.cc:137
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
TemplatedSecondaryVertexProducer::matchGroomedJets
void matchGroomedJets(const edm::Handle< edm::View< reco::Jet > > &jets, const edm::Handle< edm::View< reco::Jet > > &matchedJets, std::vector< int > &matchedIndices)
Definition: TemplatedSecondaryVertexProducer.cc:1073
type
type
Definition: HCALResponse.h:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HLT_2018_cff.jetType
jetType
Definition: HLT_2018_cff.py:7318
reco::TransientTrack
Definition: TransientTrack.h:19
reco::GhostTrackVertexFinder
Definition: GhostTrackVertexFinder.h:29
TemplatedSecondaryVertexProducer::TrackDataVector
std::vector< reco::btag::IndexedTrackData > TrackDataVector
Definition: TemplatedSecondaryVertexProducer.cc:110
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
reco::Candidate::px
virtual double px() const =0
x coordinate of momentum vector
TemplatedSecondaryVertexProducer::token_fatJets
edm::EDGetTokenT< edm::View< reco::Jet > > token_fatJets
Definition: TemplatedSecondaryVertexProducer.cc:167
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
metsig::jet
Definition: SignAlgoResolutions.h:47
TrackSorting.h
TemplatedSecondaryVertexProducer::SVFilter::direction
const GlobalVector & direction
Definition: TemplatedSecondaryVertexProducer.cc:200
TemplatedSecondaryVertexProducer::TemplatedSecondaryVertexProducer
TemplatedSecondaryVertexProducer(const edm::ParameterSet &params)
Definition: TemplatedSecondaryVertexProducer.cc:242
edm::ValueMap< float >
HLT_2018_cff.constraint
constraint
Definition: HLT_2018_cff.py:50466
Exception
Definition: hltDiff.cc:246
TemplatedSecondaryVertexProducer
Definition: TemplatedSecondaryVertexProducer.cc:101
Provenance.h
TemplatedSecondaryVertexProducer::token_extSVCollection
edm::EDGetTokenT< edm::View< VTX > > token_extSVCollection
Definition: TemplatedSecondaryVertexProducer.cc:157
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
edm::RefToBase
Definition: AssociativeIterator.h:54
Exception.h
reco::Candidate::p4
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
VertexException.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::GhostTrackVertexFinder::FitType
FitType
Definition: GhostTrackVertexFinder.h:31
GhostTrack.h
RecoVertex::convertPos
reco::Vertex::Point convertPos(const GlobalPoint &p)
Definition: ConvertToFromReco.h:7
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
reco::GhostTrackPrediction
Definition: GhostTrackPrediction.h:21
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
TemplatedSecondaryVertexProducer::produce
void produce(edm::Event &event, const edm::EventSetup &es) override
Definition: TemplatedSecondaryVertexProducer.cc:312
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
reco::CompositePtrCandidate::addDaughter
void addDaughter(const CandidatePtr &)
add a daughter via a reference
Definition: CompositePtrCandidate.h:84
getGhostTrackFitType
static GhostTrackVertexFinder::FitType getGhostTrackFitType(const std::string &name)
Definition: TemplatedSecondaryVertexProducer.cc:224
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
reco::Candidate::Point
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
bVertexFilter_cfi.vertexFilter
vertexFilter
Definition: bVertexFilter_cfi.py:6
TemplatedSecondaryVertexProducer::CONSTRAINT_PV_PRIMARIES_IN_FIT
Definition: TemplatedSecondaryVertexProducer.cc:139
fftjetvertexadder_cfi.sigmaZ
sigmaZ
Definition: fftjetvertexadder_cfi.py:32
event
Definition: event.py:1
reco::GhostTrackVertexFinder::kAlwaysWithGhostTrack
Definition: GhostTrackVertexFinder.h:31
edm::Event
Definition: Event.h:73
TrackSorting::getCriterium
reco::btag::SortCriteria getCriterium(const std::string &name)
Definition: TrackSorting.cc:11
TemplatedSecondaryVertexProducer::fjJetDefinition
JetDefPtr fjJetDefinition
Definition: TemplatedSecondaryVertexProducer.cc:172
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::ParameterDescription
Definition: ParameterDescription.h:110
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
reco::TemplatedSecondaryVertex
Definition: TemplatedSecondaryVertex.h:11
g
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
Definition: Activities.doc:4
MinBiasPDSkim_cfg.trackSelector
trackSelector
Tracks selection.
Definition: MinBiasPDSkim_cfg.py:233
ConfigurableVertexReconstructor
Definition: ConfigurableVertexReconstructor.h:13
TemplatedSecondaryVertexProducer::jetPtMin
double jetPtMin
Definition: TemplatedSecondaryVertexProducer.cc:162
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
pat::JetPtrCollection
std::vector< edm::Ptr< pat::Jet > > JetPtrCollection
Definition: Jet.h:75
HLT_2018_cff.extSVDeltaRToJet
extSVDeltaRToJet
Definition: HLT_2018_cff.py:50455
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
reco::CandidatePtrTransientTrack::candidate
CandidatePtr candidate() const override
Definition: CandidatePtrTransientTrack.h:79
HLT_2018_cff.trackIPTagInfos
trackIPTagInfos
Definition: HLT_2018_cff.py:50467