CMS 3D CMS Logo

BoostedDoubleSVProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ​RecoBTag/​SecondaryVertex
4 // Class: BoostedDoubleSVProducer
5 //
14 //
15 // Original Author: Dinko Ferencek
16 // Created: Thu, 06 Oct 2016 14:02:30 GMT
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
34 
44 
52 
53 #include "fastjet/PseudoJet.hh"
54 #include "fastjet/contrib/Njettiness.hh"
55 
56 #include <map>
57 
58 //
59 // class declaration
60 //
61 
63 public:
65  ~BoostedDoubleSVProducer() override;
66 
67  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
68 
69 private:
70  void beginStream(edm::StreamID) override;
71  void produce(edm::Event&, const edm::EventSetup&) override;
72  void endStream() override;
73 
75  float& tau1,
76  float& tau2,
77  std::vector<fastjet::PseudoJet>& currentAxes) const;
78  void setTracksPVBase(const reco::TrackRef& trackRef, const reco::VertexRef& vertexRef, float& PVweight) const;
79  void setTracksPV(const reco::CandidatePtr& trackRef, const reco::VertexRef& vertexRef, float& PVweight) const;
81  const fastjet::PseudoJet& tauAxis,
82  std::vector<float>& tau_trackEtaRel) const;
83 
84  // ----------member data ---------------------------
86 
87  const double beta_;
88  const double R0_;
89 
90  const double maxSVDeltaRToJet_;
91  const double maxDistToAxis_;
92  const double maxDecayLen_;
95 
99 
100  // static variables
101  static constexpr float dummyZ_ratio = -3.0f;
102  static constexpr float dummyTrackSip3dSig = -50.0f;
103  static constexpr float dummyTrackSip2dSigAbove = -19.0f;
104  static constexpr float dummyTrackEtaRel = -1.0f;
105  static constexpr float dummyVertexMass = -1.0f;
106  static constexpr float dummyVertexEnergyRatio = -1.0f;
107  static constexpr float dummyVertexDeltaR = -1.0f;
108  static constexpr float dummyFlightDistance2dSig = -1.0f;
109 
110  static constexpr float charmThreshold = 1.5f;
111  static constexpr float bottomThreshold = 5.2f;
112 };
113 
114 //
115 // constants, enums and typedefs
116 //
117 
118 //
119 // static data member definitions
120 //
121 
122 //
123 // constructors and destructor
124 //
126  : svTagInfos_(
127  consumes<std::vector<reco::CandSecondaryVertexTagInfo>>(iConfig.getParameter<edm::InputTag>("svTagInfos"))),
128  beta_(iConfig.getParameter<double>("beta")),
129  R0_(iConfig.getParameter<double>("R0")),
130  maxSVDeltaRToJet_(iConfig.getParameter<double>("maxSVDeltaRToJet")),
131  maxDistToAxis_(iConfig.getParameter<edm::ParameterSet>("trackSelection").getParameter<double>("maxDistToAxis")),
132  maxDecayLen_(iConfig.getParameter<edm::ParameterSet>("trackSelection").getParameter<double>("maxDecayLen")),
133  trackPairV0Filter(iConfig.getParameter<edm::ParameterSet>("trackPairV0Filter")),
134  trackSelector(iConfig.getParameter<edm::ParameterSet>("trackSelection")) {
135  edm::InputTag srcWeights = iConfig.getParameter<edm::InputTag>("weights");
137  esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"));
138  if (!srcWeights.label().empty())
140  produces<std::vector<reco::BoostedDoubleSVTagInfo>>();
141 }
142 
144  // do anything here that needs to be done at destruction time
145  // (e.g. close files, deallocate resources etc.)
146 }
147 
148 //
149 // member functions
150 //
151 
152 // ------------ method called to produce the data ------------
154  // get the track builder
156 
157  // get input secondary vertex TagInfos
159  iEvent.getByToken(svTagInfos_, svTagInfos);
160 
162  iEvent.getByToken(weightsToken_, weightsHandle_);
163 
164  // create the output collection
165  auto tagInfos = std::make_unique<std::vector<reco::BoostedDoubleSVTagInfo>>();
166 
167  // loop over TagInfos
168  for (std::vector<reco::CandSecondaryVertexTagInfo>::const_iterator iterTI = svTagInfos->begin();
169  iterTI != svTagInfos->end();
170  ++iterTI) {
171  // get TagInfos
172  const reco::CandIPTagInfo& ipTagInfo = *(iterTI->trackIPTagInfoRef().get());
173  const reco::CandSecondaryVertexTagInfo& svTagInfo = *(iterTI);
174 
175  // default variable values
176  float z_ratio = dummyZ_ratio;
191  float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
192 
193  // get the jet reference
194  const reco::JetBaseRef jet = svTagInfo.jet();
195 
196  std::vector<fastjet::PseudoJet> currentAxes;
197  float tau2, tau1;
198  // calculate N-subjettiness
199  calcNsubjettiness(jet, tau1, tau2, currentAxes);
200 
201  const reco::VertexRef& vertexRef = ipTagInfo.primaryVertex();
202  GlobalPoint pv(0., 0., 0.);
203  if (ipTagInfo.primaryVertex().isNonnull())
204  pv = GlobalPoint(vertexRef->x(), vertexRef->y(), vertexRef->z());
205 
206  const std::vector<reco::CandidatePtr>& selectedTracks = ipTagInfo.selectedTracks();
207  const std::vector<reco::btag::TrackIPData>& ipData = ipTagInfo.impactParameterData();
208  size_t trackSize = selectedTracks.size();
209 
210  reco::TrackKinematics allKinematics;
211  std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
212  int contTrk = 0;
213 
214  // loop over tracks associated to the jet
215  for (size_t itt = 0; itt < trackSize; ++itt) {
216  const reco::CandidatePtr trackRef = selectedTracks[itt];
217 
218  float track_PVweight = 0.;
219  setTracksPV(trackRef, vertexRef, track_PVweight);
220  if (track_PVweight > 0.5)
221  allKinematics.add(trackRef);
222 
223  const reco::btag::TrackIPData& data = ipData[itt];
224  bool isSelected = false;
225  if (trackSelector(trackRef, data, *jet, pv))
226  isSelected = true;
227 
228  // check if the track is from V0
229  bool isfromV0 = false, isfromV0Tight = false;
230  std::vector<reco::CandidatePtr> trackPairV0Test(2);
231 
232  trackPairV0Test[0] = trackRef;
233 
234  for (size_t jtt = 0; jtt < trackSize; ++jtt) {
235  if (itt == jtt)
236  continue;
237 
238  const reco::btag::TrackIPData& pairTrackData = ipData[jtt];
239  const reco::CandidatePtr pairTrackRef = selectedTracks[jtt];
240 
241  trackPairV0Test[1] = pairTrackRef;
242 
243  if (!trackPairV0Filter(trackPairV0Test)) {
244  isfromV0 = true;
245 
246  if (trackSelector(pairTrackRef, pairTrackData, *jet, pv))
247  isfromV0Tight = true;
248  }
249 
250  if (isfromV0 && isfromV0Tight)
251  break;
252  }
253 
254  if (isSelected && !isfromV0Tight)
255  jetNTracks += 1.;
256 
257  reco::TransientTrack transientTrack = trackBuilder->build(trackRef);
258  GlobalVector direction(jet->px(), jet->py(), jet->pz());
259 
260  int index = 0;
261  if (currentAxes.size() > 1 &&
262  reco::deltaR2(trackRef->momentum(), currentAxes[1]) < reco::deltaR2(trackRef->momentum(), currentAxes[0]))
263  index = 1;
264  direction = GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
265 
266  // decay distance and track distance wrt to the closest tau axis
267  float decayLengthTau = -1;
268  float distTauAxis = -1;
269 
271  transientTrack.impactPointState(), *vertexRef, direction, transientTrack.field());
272  if (closest.isValid())
273  decayLengthTau = (closest.globalPosition() - RecoVertex::convertPos(vertexRef->position())).mag();
274 
275  distTauAxis = std::abs(IPTools::jetTrackDistance(transientTrack, direction, *vertexRef).second.value());
276 
277  float IP3Dsig = ipTagInfo.impactParameterData()[itt].ip3d.significance();
278 
279  if (!isfromV0 && decayLengthTau < maxDecayLen_ && distTauAxis < maxDistToAxis_) {
280  IP3Ds.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
281  ++contTrk;
282  if (currentAxes.size() > 1) {
283  if (reco::deltaR2(trackRef->momentum(), currentAxes[0]) < reco::deltaR2(trackRef->momentum(), currentAxes[1]))
284  IP3Ds_1.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
285  else
286  IP3Ds_2.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
287  } else
288  IP3Ds_1.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
289  }
290  }
291 
292  std::vector<size_t> indices = ipTagInfo.sortedIndexes(reco::btag::IP2DSig);
293  bool charmThreshSet = false;
294 
296  for (size_t i = 0; i < indices.size(); ++i) {
297  size_t idx = indices[i];
298  const reco::btag::TrackIPData& data = ipData[idx];
299  const reco::CandidatePtr trackRef = selectedTracks[idx];
300 
301  kin.add(trackRef);
302 
303  if (kin.vectorSum().M() > charmThreshold // charm cut
304  && !charmThreshSet) {
305  trackSip2dSigAboveCharm_0 = data.ip2d.significance();
306 
307  charmThreshSet = true;
308  }
309 
310  if (kin.vectorSum().M() > bottomThreshold) // bottom cut
311  {
312  trackSip2dSigAboveBottom_0 = data.ip2d.significance();
313  if ((i + 1) < indices.size())
314  trackSip2dSigAboveBottom_1 = (ipData[indices[i + 1]]).ip2d.significance();
315 
316  break;
317  }
318  }
319 
320  float dummyTrack = -50.;
321 
322  std::sort(IP3Ds.begin(), IP3Ds.end(), std::greater<float>());
323  std::sort(IP3Ds_1.begin(), IP3Ds_1.end(), std::greater<float>());
324  std::sort(IP3Ds_2.begin(), IP3Ds_2.end(), std::greater<float>());
325  int num_1 = IP3Ds_1.size();
326  int num_2 = IP3Ds_2.size();
327 
328  switch (contTrk) {
329  case 0:
330 
331  trackSip3dSig_0 = dummyTrack;
332  trackSip3dSig_1 = dummyTrack;
333  trackSip3dSig_2 = dummyTrack;
334  trackSip3dSig_3 = dummyTrack;
335 
336  break;
337 
338  case 1:
339 
340  trackSip3dSig_0 = IP3Ds.at(0);
341  trackSip3dSig_1 = dummyTrack;
342  trackSip3dSig_2 = dummyTrack;
343  trackSip3dSig_3 = dummyTrack;
344 
345  break;
346 
347  case 2:
348 
349  trackSip3dSig_0 = IP3Ds.at(0);
350  trackSip3dSig_1 = IP3Ds.at(1);
351  trackSip3dSig_2 = dummyTrack;
352  trackSip3dSig_3 = dummyTrack;
353 
354  break;
355 
356  case 3:
357 
358  trackSip3dSig_0 = IP3Ds.at(0);
359  trackSip3dSig_1 = IP3Ds.at(1);
360  trackSip3dSig_2 = IP3Ds.at(2);
361  trackSip3dSig_3 = dummyTrack;
362 
363  break;
364 
365  default:
366 
367  trackSip3dSig_0 = IP3Ds.at(0);
368  trackSip3dSig_1 = IP3Ds.at(1);
369  trackSip3dSig_2 = IP3Ds.at(2);
370  trackSip3dSig_3 = IP3Ds.at(3);
371  }
372 
373  switch (num_1) {
374  case 0:
375 
376  tau1_trackSip3dSig_0 = dummyTrack;
377  tau1_trackSip3dSig_1 = dummyTrack;
378 
379  break;
380 
381  case 1:
382 
383  tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
384  tau1_trackSip3dSig_1 = dummyTrack;
385 
386  break;
387 
388  default:
389 
390  tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
391  tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
392  }
393 
394  switch (num_2) {
395  case 0:
396 
397  tau2_trackSip3dSig_0 = dummyTrack;
398  tau2_trackSip3dSig_1 = dummyTrack;
399 
400  break;
401 
402  case 1:
403  tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
404  tau2_trackSip3dSig_1 = dummyTrack;
405 
406  break;
407 
408  default:
409 
410  tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
411  tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
412  }
413 
414  math::XYZVector jetDir = jet->momentum().Unit();
415  reco::TrackKinematics tau1Kinematics;
416  reco::TrackKinematics tau2Kinematics;
417  std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
418 
419  std::map<double, size_t> VTXmap;
420  for (size_t vtx = 0; vtx < svTagInfo.nVertices(); ++vtx) {
422  // get the vertex kinematics
423  reco::TrackKinematics vertexKinematic(vertex);
424 
425  if (currentAxes.size() > 1) {
426  if (reco::deltaR2(svTagInfo.flightDirection(vtx), currentAxes[1]) <
427  reco::deltaR2(svTagInfo.flightDirection(vtx), currentAxes[0])) {
428  tau2Kinematics = tau2Kinematics + vertexKinematic;
429  if (tau2_flightDistance2dSig < 0) {
431  tau2_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx), currentAxes[1]);
432  }
433  etaRelToTauAxis(vertex, currentAxes[1], tau2_trackEtaRels);
434  tau2_nSecondaryVertices += 1.;
435  } else {
436  tau1Kinematics = tau1Kinematics + vertexKinematic;
437  if (tau1_flightDistance2dSig < 0) {
439  tau1_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx), currentAxes[0]);
440  }
441  etaRelToTauAxis(vertex, currentAxes[0], tau1_trackEtaRels);
442  tau1_nSecondaryVertices += 1.;
443  }
444 
445  } else if (!currentAxes.empty()) {
446  tau1Kinematics = tau1Kinematics + vertexKinematic;
447  if (tau1_flightDistance2dSig < 0) {
449  tau1_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx), currentAxes[0]);
450  }
451  etaRelToTauAxis(vertex, currentAxes[0], tau1_trackEtaRels);
452  tau1_nSecondaryVertices += 1.;
453  }
454 
455  const GlobalVector& flightDir = svTagInfo.flightDirection(vtx);
456  if (reco::deltaR2(flightDir, jetDir) < (maxSVDeltaRToJet_ * maxSVDeltaRToJet_))
457  VTXmap[svTagInfo.flightDistance(vtx).error()] = vtx;
458  }
459  nSV = VTXmap.size();
460 
461  math::XYZTLorentzVector allSum = allKinematics.weightedVectorSum();
462  if (tau1_nSecondaryVertices > 0.) {
463  const math::XYZTLorentzVector& tau1_vertexSum = tau1Kinematics.weightedVectorSum();
464  if (allSum.E() > 0.)
465  tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
466  if (tau1_vertexEnergyRatio > 50.)
468 
469  tau1_vertexMass = tau1_vertexSum.M();
470  }
471 
472  if (tau2_nSecondaryVertices > 0.) {
473  const math::XYZTLorentzVector& tau2_vertexSum = tau2Kinematics.weightedVectorSum();
474  if (allSum.E() > 0.)
475  tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
476  if (tau2_vertexEnergyRatio > 50.)
478 
479  tau2_vertexMass = tau2_vertexSum.M();
480  }
481 
482  float dummyEtaRel = -1.;
483 
484  std::sort(tau1_trackEtaRels.begin(), tau1_trackEtaRels.end());
485  std::sort(tau2_trackEtaRels.begin(), tau2_trackEtaRels.end());
486 
487  switch (tau2_trackEtaRels.size()) {
488  case 0:
489 
490  tau2_trackEtaRel_0 = dummyEtaRel;
491  tau2_trackEtaRel_1 = dummyEtaRel;
492  tau2_trackEtaRel_2 = dummyEtaRel;
493 
494  break;
495 
496  case 1:
497 
498  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
499  tau2_trackEtaRel_1 = dummyEtaRel;
500  tau2_trackEtaRel_2 = dummyEtaRel;
501 
502  break;
503 
504  case 2:
505 
506  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
507  tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
508  tau2_trackEtaRel_2 = dummyEtaRel;
509 
510  break;
511 
512  default:
513 
514  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
515  tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
516  tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
517  }
518 
519  switch (tau1_trackEtaRels.size()) {
520  case 0:
521 
522  tau1_trackEtaRel_0 = dummyEtaRel;
523  tau1_trackEtaRel_1 = dummyEtaRel;
524  tau1_trackEtaRel_2 = dummyEtaRel;
525 
526  break;
527 
528  case 1:
529 
530  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
531  tau1_trackEtaRel_1 = dummyEtaRel;
532  tau1_trackEtaRel_2 = dummyEtaRel;
533 
534  break;
535 
536  case 2:
537 
538  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
539  tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
540  tau1_trackEtaRel_2 = dummyEtaRel;
541 
542  break;
543 
544  default:
545 
546  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
547  tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
548  tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
549  }
550 
551  int cont = 0;
552  GlobalVector flightDir_0, flightDir_1;
553  reco::Candidate::LorentzVector SV_p4_0, SV_p4_1;
554  double vtxMass = 0.;
555 
556  for (std::map<double, size_t>::iterator iVtx = VTXmap.begin(); iVtx != VTXmap.end(); ++iVtx) {
557  ++cont;
558  const reco::VertexCompositePtrCandidate& vertex = svTagInfo.secondaryVertex(iVtx->second);
559  if (cont == 1) {
560  flightDir_0 = svTagInfo.flightDirection(iVtx->second);
561  SV_p4_0 = vertex.p4();
562  vtxMass = SV_p4_0.mass();
563 
564  if (vtxMass > 0.)
565  z_ratio = reco::deltaR(currentAxes[1], currentAxes[0]) * SV_p4_0.pt() / vtxMass;
566  }
567  if (cont == 2) {
568  flightDir_1 = svTagInfo.flightDirection(iVtx->second);
569  SV_p4_1 = vertex.p4();
570  vtxMass = (SV_p4_1 + SV_p4_0).mass();
571 
572  if (vtxMass > 0.)
573  z_ratio = reco::deltaR(flightDir_0, flightDir_1) * SV_p4_1.pt() / vtxMass;
574 
575  break;
576  }
577  }
578 
579  // when only one tau axis has SVs assigned, they are all assigned to the 1st tau axis
580  // in the special case below need to swap values
581  if ((tau1_vertexMass < 0 && tau2_vertexMass > 0)) {
582  float temp = tau1_trackEtaRel_0;
585 
589 
593 
597 
599 
603 
607  }
608 
610 
611  vars.insert(reco::btau::jetNTracks, jetNTracks, true);
612  vars.insert(reco::btau::jetNSecondaryVertices, nSV, true);
621  vars.insert(reco::btau::trackSip2dSigAboveCharm, trackSip2dSigAboveCharm_0, true);
637  vars.insert(reco::btau::z_ratio, z_ratio, true);
638 
639  vars.finalize();
640 
642  vars, edm::Ref<std::vector<reco::CandSecondaryVertexTagInfo>>(svTagInfos, iterTI - svTagInfos->begin())));
643  }
644 
645  // put the output in the event
646  iEvent.put(std::move(tagInfos));
647 }
648 
650  float& tau1,
651  float& tau2,
652  std::vector<fastjet::PseudoJet>& currentAxes) const {
653  std::vector<fastjet::PseudoJet> fjParticles;
654 
655  // loop over jet constituents and push them in the vector of FastJet constituents
656  for (const reco::CandidatePtr& daughter : jet->daughterPtrVector()) {
657  if (daughter.isNonnull() && daughter.isAvailable()) {
658  const reco::Jet* subjet = dynamic_cast<const reco::Jet*>(daughter.get());
659  // if the daughter is actually a subjet
660  if (subjet && daughter->numberOfDaughters() > 1) {
661  // loop over subjet constituents and push them in the vector of FastJet constituents
662  for (size_t i = 0; i < daughter->numberOfDaughters(); ++i) {
663  const reco::CandidatePtr& constit = subjet->daughterPtr(i);
664 
665  if (constit.isNonnull()) {
666  // Check if any values were nan or inf
667  float valcheck = constit->px() + constit->py() + constit->pz() + constit->energy();
668  if (edm::isNotFinite(valcheck)) {
669  edm::LogWarning("FaultyJetConstituent")
670  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
671  continue;
672  }
673  if (subjet->isWeighted()) {
674  float w = 0.0;
676  w = (*weightsHandle_)[constit];
677  else {
678  throw cms::Exception("MissingConstituentWeight")
679  << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection"
680  << std::endl;
681  }
682  fjParticles.push_back(
683  fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
684  } else
685  fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
686  } else
687  edm::LogWarning("MissingJetConstituent")
688  << "Jet constituent required for N-subjettiness computation is missing!";
689  }
690  } else {
691  // Check if any values were nan or inf
692  float valcheck = daughter->px() + daughter->py() + daughter->pz() + daughter->energy();
693  if (edm::isNotFinite(valcheck)) {
694  edm::LogWarning("FaultyJetConstituent")
695  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
696  continue;
697  }
698  if (jet->isWeighted()) {
699  float w = 0.0;
701  w = (*weightsHandle_)[daughter];
702  else {
703  throw cms::Exception("MissingConstituentWeight")
704  << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
705  }
706  fjParticles.push_back(
707  fastjet::PseudoJet(daughter->px() * w, daughter->py() * w, daughter->pz() * w, daughter->energy() * w));
708  } else
709  fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
710  }
711  } else
712  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
713  }
714 
715  // N-subjettiness calculator
716  fastjet::contrib::Njettiness njettiness(fastjet::contrib::OnePass_KT_Axes(),
717  fastjet::contrib::NormalizedMeasure(beta_, R0_));
718 
719  // calculate N-subjettiness
720  tau1 = njettiness.getTau(1, fjParticles);
721  tau2 = njettiness.getTau(2, fjParticles);
722  currentAxes = njettiness.currentAxes();
723 }
724 
726  const reco::VertexRef& vertexRef,
727  float& PVweight) const {
728  PVweight = 0.;
729 
730  const reco::TrackBaseRef trackBaseRef(trackRef);
731 
733 
734  const reco::Vertex& vtx = *(vertexRef);
735  // loop over tracks in vertices
736  for (IT it = vtx.tracks_begin(); it != vtx.tracks_end(); ++it) {
737  const reco::TrackBaseRef& baseRef = *it;
738  // one of the tracks in the vertex is the same as the track considered in the function
739  if (baseRef == trackBaseRef) {
740  PVweight = vtx.trackWeight(baseRef);
741  break;
742  }
743  }
744 }
745 
747  const reco::VertexRef& vertexRef,
748  float& PVweight) const {
749  PVweight = 0.;
750 
751  const pat::PackedCandidate* pcand = dynamic_cast<const pat::PackedCandidate*>(trackRef.get());
752 
753  if (pcand) // MiniAOD case
754  {
755  if (pcand->fromPV() == pat::PackedCandidate::PVUsedInFit) {
756  PVweight = 1.;
757  }
758  } else {
759  const reco::PFCandidate* pfcand = dynamic_cast<const reco::PFCandidate*>(trackRef.get());
760 
761  setTracksPVBase(pfcand->trackRef(), vertexRef, PVweight);
762  }
763 }
764 
766  const fastjet::PseudoJet& tauAxis,
767  std::vector<float>& tau_trackEtaRel) const {
768  math::XYZVector direction(tauAxis.px(), tauAxis.py(), tauAxis.pz());
769  const std::vector<reco::CandidatePtr>& tracks = vertex.daughterPtrVector();
770 
771  for (std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track)
772  tau_trackEtaRel.push_back(std::abs(reco::btau::etaRel(direction.Unit(), (*track)->momentum())));
773 }
774 
775 // ------------ method called once each stream before processing any runs, lumis or events ------------
777 
778 // ------------ method called once each stream after processing all runs, lumis and events ------------
780 
781 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
784  desc.add<double>("beta", 1.0);
785  desc.add<double>("R0", 0.8);
786  desc.add<double>("maxSVDeltaRToJet", 0.7);
787  {
789  trackSelection.setAllowAnything();
790  desc.add<edm::ParameterSetDescription>("trackSelection", trackSelection);
791  }
792  {
794  trackPairV0Filter.add<double>("k0sMassWindow", 0.03);
795  desc.add<edm::ParameterSetDescription>("trackPairV0Filter", trackPairV0Filter);
796  }
797  desc.add<edm::InputTag>("svTagInfos", edm::InputTag("pfInclusiveSecondaryVertexFinderAK8TagInfos"));
798  desc.add<edm::InputTag>("weights", edm::InputTag(""));
799  descriptions.addDefault(desc);
800 }
801 
802 //define this as a plug-in
Vector3DBase
Definition: Vector3DBase.h:8
reco::IPTagInfo::primaryVertex
const edm::Ref< VertexCollection > & primaryVertex() const
Definition: IPTagInfo.h:133
reco::btau::tau2_trackEtaRel_1
Definition: TaggingVariable.h:145
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
edm::StreamID
Definition: StreamID.h:30
reco::btau::tau1_vertexEnergyRatio
Definition: TaggingVariable.h:148
reco::TrackKinematics
Definition: TrackKinematics.h:16
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
reco::IPTagInfo
Definition: IPTagInfo.h:48
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
BoostedDoubleSVProducer::dummyVertexDeltaR
static constexpr float dummyVertexDeltaR
Definition: BoostedDoubleSVProducer.cc:107
HLT_FULL_cff.tagInfos
tagInfos
Definition: HLT_FULL_cff.py:52997
reco::btau::trackSip2dSigAboveBottom_0
Definition: TaggingVariable.h:139
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
PFCandidate.h
CandIPTagInfo.h
reco::btau::tau2_trackEtaRel_2
Definition: TaggingVariable.h:146
edm::EDGetTokenT
Definition: EDGetToken.h:33
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
BoostedDoubleSVProducer::charmThreshold
static constexpr float charmThreshold
Definition: BoostedDoubleSVProducer.cc:110
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
reco::IPTagInfo::selectedTracks
const Container & selectedTracks() const
Definition: IPTagInfo.h:99
reco::btau::trackSip2dSigAboveCharm
Definition: TaggingVariable.h:90
reco::TemplatedSecondaryVertexTagInfo
Definition: TemplatedSecondaryVertexTagInfo.h:47
BoostedDoubleSVProducer::dummyTrackSip2dSigAbove
static constexpr float dummyTrackSip2dSigAbove
Definition: BoostedDoubleSVProducer.cc:103
V0Filter.h
reco::TemplatedSecondaryVertexTagInfo::nVertices
unsigned int nVertices() const
Definition: TemplatedSecondaryVertexTagInfo.h:112
reco::TaggingVariableList
Definition: TaggingVariable.h:194
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
BoostedDoubleSVProducer::~BoostedDoubleSVProducer
~BoostedDoubleSVProducer() override
Definition: BoostedDoubleSVProducer.cc:143
generateEDF.cont
cont
load Luminosity info ##
Definition: generateEDF.py:629
BoostedDoubleSVProducer::beginStream
void beginStream(edm::StreamID) override
Definition: BoostedDoubleSVProducer.cc:776
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
EDProducer.h
IPTools::closestApproachToJet
TrajectoryStateOnSurface closestApproachToJet(const TrajectoryStateOnSurface &state, const reco::Vertex &vertex, const GlobalVector &aJetDirection, const MagneticField *field)
Definition: IPTools.cc:182
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
reco::btau::trackSip2dSigAboveBottom_1
Definition: TaggingVariable.h:140
ConvertToFromReco.h
reco::CandSecondaryVertexTagInfo
reco::TemplatedSecondaryVertexTagInfo< reco::CandIPTagInfo, reco::VertexCompositePtrCandidate > CandSecondaryVertexTagInfo
Definition: CandSecondaryVertexTagInfo.h:10
nJettinessAdder_cfi.Njettiness
Njettiness
Definition: nJettinessAdder_cfi.py:4
BoostedDoubleSVProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: BoostedDoubleSVProducer.cc:153
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
BoostedDoubleSVProducer::etaRelToTauAxis
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, const fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
Definition: BoostedDoubleSVProducer.cc:765
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
BoostedDoubleSVProducer::dummyTrackSip3dSig
static constexpr float dummyTrackSip3dSig
Definition: BoostedDoubleSVProducer.cc:102
HLT_FULL_cff.trackSelection
trackSelection
Definition: HLT_FULL_cff.py:6723
ESGetToken.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
BoostedDoubleSVProducer::svTagInfos_
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
Definition: BoostedDoubleSVProducer.cc:85
reco::btau::tau2_trackEtaRel_0
Definition: TaggingVariable.h:144
reco::VertexCompositePtrCandidate
Definition: VertexCompositePtrCandidate.h:16
reco::btau::tau2_flightDistance2dSig
Definition: TaggingVariable.h:153
edm::Ref< TrackCollection >
pfDeepBoostedJetPreprocessParams_cfi.pfcand
pfcand
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:8
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
pat::PackedCandidate::PVUsedInFit
Definition: PackedCandidate.h:703
HLT_FULL_cff.svTagInfos
svTagInfos
Definition: HLT_FULL_cff.py:52116
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
HLT_FULL_cff.trackPairV0Filter
trackPairV0Filter
Definition: HLT_FULL_cff.py:6744
MakerMacros.h
reco::Jet::isWeighted
virtual int isWeighted() const
boolean if weights were applied by algorithm (e.g. PUPPI weights)
Definition: Jet.h:118
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::TemplatedSecondaryVertexTagInfo::jet
edm::RefToBase< Jet > jet(void) const override
returns a polymorphic reference to the tagged jet
Definition: TemplatedSecondaryVertexTagInfo.h:98
vars
vars
Definition: DeepTauId.cc:163
BoostedDoubleSVProducer::maxSVDeltaRToJet_
const double maxSVDeltaRToJet_
Definition: BoostedDoubleSVProducer.cc:90
BoostedDoubleSVProducer::dummyVertexEnergyRatio
static constexpr float dummyVertexEnergyRatio
Definition: BoostedDoubleSVProducer.cc:106
w
const double w
Definition: UKUtility.cc:23
BoostedDoubleSVProducer::trackPairV0Filter
reco::V0Filter trackPairV0Filter
Definition: BoostedDoubleSVProducer.cc:93
edm::ESHandle< TransientTrackBuilder >
reco::btau::trackSip3dSig_2
Definition: TaggingVariable.h:133
VertexCompositePtrCandidate.h
reco::btau::trackSip3dSig_3
Definition: TaggingVariable.h:134
BoostedDoubleSVProducer::setTracksPV
void setTracksPV(const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
Definition: BoostedDoubleSVProducer.cc:746
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
reco::TrackKinematics::vectorSum
const math::XYZTLorentzVector & vectorSum() const
Definition: TrackKinematics.h:47
reco::btau::trackSip3dSig_0
Definition: TaggingVariable.h:131
Point3DBase< float, GlobalTag >
BoostedDoubleSVProducer::dummyTrackEtaRel
static constexpr float dummyTrackEtaRel
Definition: BoostedDoubleSVProducer.cc:104
reco::V0Filter
Definition: V0Filter.h:14
Measurement1D::error
double error() const
Definition: Measurement1D.h:27
pat::PackedCandidate::fromPV
const PVAssoc fromPV(size_t ipv=0) const
Definition: PackedCandidate.h:704
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Vertex.h
IPTools::jetTrackDistance
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:206
Measurement1D::significance
double significance() const
Definition: Measurement1D.h:29
BoostedDoubleSVProducer::dummyVertexMass
static constexpr float dummyVertexMass
Definition: BoostedDoubleSVProducer.cc:105
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:47
reco::btau::z_ratio
Definition: TaggingVariable.h:155
BoostedDoubleSVProducer::trackSelector
reco::TrackSelector trackSelector
Definition: BoostedDoubleSVProducer.cc:94
reco::btau::trackSip3dSig_1
Definition: TaggingVariable.h:132
Event.h
ParameterSet
Definition: Functions.h:16
BoostedDoubleSVProducer::trackBuilderToken_
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
Definition: BoostedDoubleSVProducer.cc:97
pat::PackedCandidate
Definition: PackedCandidate.h:22
BoostedDoubleSVProducer::BoostedDoubleSVProducer
BoostedDoubleSVProducer(const edm::ParameterSet &)
Definition: BoostedDoubleSVProducer.cc:125
PackedCandidate.h
reco::btau::tau1_trackEtaRel_0
Definition: TaggingVariable.h:141
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
reco::btau::jetNSecondaryVertices
Definition: TaggingVariable.h:72
BoostedDoubleSVProducer::endStream
void endStream() override
Definition: BoostedDoubleSVProducer.cc:779
reco::TemplatedSecondaryVertexTagInfo::secondaryVertex
const VTX & secondaryVertex(unsigned int index) const
Definition: TemplatedSecondaryVertexTagInfo.h:107
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::IPTagInfo::sortedIndexes
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
Definition: IPTagInfo.h:231
BoostedDoubleSVProducer::weightsHandle_
edm::Handle< edm::ValueMap< float > > weightsHandle_
Definition: BoostedDoubleSVProducer.cc:98
reco::TransientTrack::impactPointState
TrajectoryStateOnSurface impactPointState() const
Definition: TransientTrack.h:98
jets_cff.vtxMass
vtxMass
Definition: jets_cff.py:142
reco::BoostedDoubleSVTagInfo
Definition: BoostedDoubleSVTagInfo.h:12
reco::btau::tau2_trackSip3dSig_0
Definition: TaggingVariable.h:137
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::btau::etaRel
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
Definition: TaggingVariable.h:22
TrackKinematics.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
TrackSelector.h
edm::stream::EDProducer
Definition: EDProducer.h:38
reco::btau::tau1_trackEtaRel_1
Definition: TaggingVariable.h:142
BoostedDoubleSVProducer::dummyFlightDistance2dSig
static constexpr float dummyFlightDistance2dSig
Definition: BoostedDoubleSVProducer.cc:108
edm::EventSetup
Definition: EventSetup.h:57
TransientTrackRecord.h
reco::IPTagInfo::impactParameterData
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition: IPTagInfo.h:90
reco::btau::tau1_vertexDeltaR
Definition: TaggingVariable.h:150
IT
std::vector< LinkConnSpec >::const_iterator IT
Definition: TriggerBoardSpec.cc:5
reco::TransientTrack::field
const MagneticField * field() const
Definition: TransientTrack.h:110
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord >
BoostedDoubleSVProducer::beta_
const double beta_
Definition: BoostedDoubleSVProducer.cc:87
HLT_FULL_cff.srcWeights
srcWeights
Definition: HLT_FULL_cff.py:8647
CandSecondaryVertexTagInfo.h
reco::CompositePtrCandidate::numberOfDaughters
size_t numberOfDaughters() const override
number of daughters
Definition: CompositePtrCandidate.cc:18
edm::Ptr< Candidate >
reco::btau::tau1_trackSip3dSig_0
Definition: TaggingVariable.h:135
VertexFwd.h
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
reco::TrackSelector
Definition: TrackSelector.h:14
reco::btau::tau2_vertexEnergyRatio
Definition: TaggingVariable.h:152
reco::btau::tau1_trackEtaRel_2
Definition: TaggingVariable.h:143
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
reco::TrackKinematics::weightedVectorSum
const math::XYZTLorentzVector & weightedVectorSum() const
Definition: TrackKinematics.h:48
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
IPTools.h
reco::TemplatedSecondaryVertexTagInfo::flightDistance
Measurement1D flightDistance(unsigned int index, int dim=0) const
Definition: TemplatedSecondaryVertexTagInfo.h:131
reco::TransientTrack
Definition: TransientTrack.h:19
BoostedDoubleSVProducer::R0_
const double R0_
Definition: BoostedDoubleSVProducer.cc:88
isFinite.h
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
Frameworkfwd.h
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::btau::tau2_vertexMass
Definition: TaggingVariable.h:151
reco::btau::tau2_trackSip3dSig_1
Definition: TaggingVariable.h:138
metsig::jet
Definition: SignAlgoResolutions.h:47
BoostedDoubleSVProducer
Definition: BoostedDoubleSVProducer.cc:62
edm::ValueMap< float >
Exception
Definition: hltDiff.cc:246
jets_cff.tau1
tau1
Definition: jets_cff.py:426
jets_cff.tau2
tau2
Definition: jets_cff.py:427
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
BoostedDoubleSVProducer::bottomThreshold
static constexpr float bottomThreshold
Definition: BoostedDoubleSVProducer.cc:111
BoostedDoubleSVProducer::weightsToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Definition: BoostedDoubleSVProducer.cc:96
reco::btau::jetNTracks
Definition: TaggingVariable.h:37
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< Jet >
BoostedDoubleSVProducer::maxDecayLen_
const double maxDecayLen_
Definition: BoostedDoubleSVProducer.cc:92
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
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::btau::tau1_vertexMass
Definition: TaggingVariable.h:147
BoostedDoubleSVProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: BoostedDoubleSVProducer.cc:782
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::btau::tau1_trackSip3dSig_1
Definition: TaggingVariable.h:136
reco::btau::tau2_vertexDeltaR
Definition: TaggingVariable.h:154
BoostedDoubleSVProducer::calcNsubjettiness
void calcNsubjettiness(const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > &currentAxes) const
Definition: BoostedDoubleSVProducer.cc:649
ParameterSet.h
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
TaggingVariable.h
edm::Event
Definition: Event.h:73
BoostedDoubleSVProducer::dummyZ_ratio
static constexpr float dummyZ_ratio
Definition: BoostedDoubleSVProducer.cc:101
BoostedDoubleSVProducer::maxDistToAxis_
const double maxDistToAxis_
Definition: BoostedDoubleSVProducer.cc:91
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
BoostedDoubleSVTagInfo.h
StreamID.h
reco::btau::tau1_flightDistance2dSig
Definition: TaggingVariable.h:149
edm::InputTag
Definition: InputTag.h:15
BoostedDoubleSVProducer::setTracksPVBase
void setTracksPVBase(const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
Definition: BoostedDoubleSVProducer.cc:725
reco::Vertex
Definition: Vertex.h:35
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
MinBiasPDSkim_cfg.trackSelector
trackSelector
Tracks selection.
Definition: MinBiasPDSkim_cfg.py:233
reco::btag::IP2DSig
Definition: IPTagInfo.h:43
TrackCollections2monitor_cff.selectedTracks
selectedTracks
Definition: TrackCollections2monitor_cff.py:32
reco::btag::TrackIPData
Definition: IPTagInfo.h:28
reco::CompositePtrCandidate::daughterPtr
virtual CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
Definition: CompositePtrCandidate.h:61
reco::TemplatedSecondaryVertexTagInfo::flightDirection
const GlobalVector & flightDirection(unsigned int index) const
Definition: TemplatedSecondaryVertexTagInfo.h:139
reco::TrackKinematics::add
void add(const reco::Track &track, double weight=1.0)
Definition: TrackKinematics.cc:57