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