CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
BoostedDoubleSVProducer Class Reference

#include <​RecoBTag/​SecondaryVertex/plugins/BoostedDoubleSVProducer.cc>

Inheritance diagram for BoostedDoubleSVProducer:
edm::stream::EDProducer<>

Public Member Functions

 BoostedDoubleSVProducer (const edm::ParameterSet &)
 
 ~BoostedDoubleSVProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void calcNsubjettiness (const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > &currentAxes) const
 
void endStream () override
 
void etaRelToTauAxis (const reco::VertexCompositePtrCandidate &vertex, const fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void setTracksPV (const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
 
void setTracksPVBase (const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
 

Private Attributes

const double beta_
 
const double maxDecayLen_
 
const double maxDistToAxis_
 
const double maxSVDeltaRToJet_
 
const double R0_
 
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
 
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordtrackBuilderToken_
 
reco::V0Filter trackPairV0Filter
 
reco::TrackSelector trackSelector
 
edm::Handle< edm::ValueMap< float > > weightsHandle_
 
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
 

Static Private Attributes

static constexpr float bottomThreshold = 5.2f
 
static constexpr float charmThreshold = 1.5f
 
static constexpr float dummyFlightDistance2dSig = -1.0f
 
static constexpr float dummyTrackEtaRel = -1.0f
 
static constexpr float dummyTrackSip2dSigAbove = -19.0f
 
static constexpr float dummyTrackSip3dSig = -50.0f
 
static constexpr float dummyVertexDeltaR = -1.0f
 
static constexpr float dummyVertexEnergyRatio = -1.0f
 
static constexpr float dummyVertexMass = -1.0f
 
static constexpr float dummyZ_ratio = -3.0f
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: EDProducer that produces collection of BoostedDoubleSVTagInfos

Implementation: A collection of SecondaryVertexTagInfos is taken as input and a collection of BoostedDoubleSVTagInfos is produced as output.

Definition at line 62 of file BoostedDoubleSVProducer.cc.

Constructor & Destructor Documentation

◆ BoostedDoubleSVProducer()

BoostedDoubleSVProducer::BoostedDoubleSVProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 125 of file BoostedDoubleSVProducer.cc.

References edm::ParameterSet::getParameter(), HLT_2022v12_cff::srcWeights, trackBuilderToken_, and weightsToken_.

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 }
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::TrackSelector trackSelector
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_

◆ ~BoostedDoubleSVProducer()

BoostedDoubleSVProducer::~BoostedDoubleSVProducer ( )
override

Definition at line 143 of file BoostedDoubleSVProducer.cc.

143  {
144  // do anything here that needs to be done at destruction time
145  // (e.g. close files, deallocate resources etc.)
146 }

Member Function Documentation

◆ beginStream()

void BoostedDoubleSVProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 779 of file BoostedDoubleSVProducer.cc.

779 {}

◆ calcNsubjettiness()

void BoostedDoubleSVProducer::calcNsubjettiness ( const reco::JetBaseRef jet,
float &  tau1,
float &  tau2,
std::vector< fastjet::PseudoJet > &  currentAxes 
) const
private

Definition at line 649 of file BoostedDoubleSVProducer.cc.

References beta_, reco::CompositePtrCandidate::daughterPtr(), geometryDiff::epsilon, Exception, mps_fire::i, edm::Ptr< T >::isNonnull(), edm::isNotFinite(), edm::EDGetTokenT< T >::isUninitialized(), reco::Jet::isWeighted(), metsig::jet, nJettinessAdder_cfi::Njettiness, reco::CompositePtrCandidate::numberOfDaughters(), R0_, jetsAK8_cff::tau1, jetsAK8_cff::tau2, w(), weightsHandle_, and weightsToken_.

Referenced by produce().

652  {
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  if (constit.isNonnull() && constit->pt() > std::numeric_limits<double>::epsilon() ) {
665  // Check if any values were nan or inf
666  float valcheck = constit->px() + constit->py() + constit->pz() + constit->energy();
667  if (edm::isNotFinite(valcheck)) {
668  edm::LogWarning("FaultyJetConstituent")
669  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
670  continue;
671  }
672  if (subjet->isWeighted()) {
673  float w = 0.0;
675  w = (*weightsHandle_)[constit];
676  else {
677  throw cms::Exception("MissingConstituentWeight")
678  << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection"
679  << std::endl;
680  }
681  if ( w > 0 ) {
682  fjParticles.push_back(fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
683  }
684  } else {
685  fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
686  }
687  } else
688  edm::LogWarning("MissingJetConstituent")
689  << "Jet constituent required for N-subjettiness computation is missing!";
690  }
691  } else {
692  // Check if any values were nan or inf
693  float valcheck = daughter->px() + daughter->py() + daughter->pz() + daughter->energy();
694  if (edm::isNotFinite(valcheck)) {
695  edm::LogWarning("FaultyJetConstituent")
696  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
697  continue;
698  }
699  if (jet->isWeighted()) {
700  float w = 0.0;
702  w = (*weightsHandle_)[daughter];
703  else {
704  throw cms::Exception("MissingConstituentWeight")
705  << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
706  }
707  if ( w > 0 && daughter->pt() > std::numeric_limits<double>::epsilon() ) {
708  fjParticles.push_back(fastjet::PseudoJet(daughter->px() * w, daughter->py() * w, daughter->pz() * w, daughter->energy() * w));
709  }
710  } else {
711  fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
712  }
713  }
714  } else
715  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
716  }
717 
718  // N-subjettiness calculator
719  fastjet::contrib::Njettiness njettiness(fastjet::contrib::OnePass_KT_Axes(),
720  fastjet::contrib::NormalizedMeasure(beta_, R0_));
721 
722  // calculate N-subjettiness
723  tau1 = njettiness.getTau(1, fjParticles);
724  tau2 = njettiness.getTau(2, fjParticles);
725  currentAxes = njettiness.currentAxes();
726 }
virtual CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
T w() const
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
Base class for all types of Jets.
Definition: Jet.h:20
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
virtual int isWeighted() const
boolean if weights were applied by algorithm (e.g. PUPPI weights)
Definition: Jet.h:118
edm::Handle< edm::ValueMap< float > > weightsHandle_
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_

◆ endStream()

void BoostedDoubleSVProducer::endStream ( )
overrideprivate

Definition at line 782 of file BoostedDoubleSVProducer.cc.

782 {}

◆ etaRelToTauAxis()

void BoostedDoubleSVProducer::etaRelToTauAxis ( const reco::VertexCompositePtrCandidate vertex,
const fastjet::PseudoJet &  tauAxis,
std::vector< float > &  tau_trackEtaRel 
) const
private

Definition at line 768 of file BoostedDoubleSVProducer.cc.

References funct::abs(), reco::btau::etaRel(), HLT_2022v12_cff::track, tracks, and bphysicsOniaDQM_cfi::vertex.

Referenced by produce().

770  {
771  math::XYZVector direction(tauAxis.px(), tauAxis.py(), tauAxis.pz());
772  const std::vector<reco::CandidatePtr>& tracks = vertex.daughterPtrVector();
773 
774  for (std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track)
775  tau_trackEtaRel.push_back(std::abs(reco::btau::etaRel(direction.Unit(), (*track)->momentum())));
776 }
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
auto const & tracks
cannot be loose
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31

◆ fillDescriptions()

void BoostedDoubleSVProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 785 of file BoostedDoubleSVProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, HLT_2022v12_cff::InputTag, trackPairV0Filter, and HLT_2022v12_cff::trackSelection.

785  {
787  desc.add<double>("beta", 1.0);
788  desc.add<double>("R0", 0.8);
789  desc.add<double>("maxSVDeltaRToJet", 0.7);
790  {
792  trackSelection.setAllowAnything();
793  desc.add<edm::ParameterSetDescription>("trackSelection", trackSelection);
794  }
795  {
797  trackPairV0Filter.add<double>("k0sMassWindow", 0.03);
798  desc.add<edm::ParameterSetDescription>("trackPairV0Filter", trackPairV0Filter);
799  }
800  desc.add<edm::InputTag>("svTagInfos", edm::InputTag("pfInclusiveSecondaryVertexFinderAK8TagInfos"));
801  desc.add<edm::InputTag>("weights", edm::InputTag(""));
802  descriptions.addDefault(desc);
803 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void BoostedDoubleSVProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 153 of file BoostedDoubleSVProducer.cc.

References funct::abs(), reco::TrackKinematics::add(), bottomThreshold, TransientTrackBuilder::build(), calcNsubjettiness(), charmThreshold, IPTools::closestApproachToJet(), generateEDF::cont, RecoVertex::convertPos(), data, reco::deltaR(), reco::deltaR2(), dummyFlightDistance2dSig, dummyTrackEtaRel, dummyTrackSip2dSigAbove, dummyTrackSip3dSig, dummyVertexDeltaR, dummyVertexEnergyRatio, dummyVertexMass, dummyZ_ratio, etaRelToTauAxis(), reco::TransientTrack::field(), edm::EventSetup::getHandle(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, heavyIonCSV_trainingSettings::idx, iEvent, reco::IPTagInfo< Container, Base >::impactParameterData(), reco::TransientTrack::impactPointState(), dqmdumpme::indices, reco::btag::IP2DSig, edm::Ref< C, T, F >::isNonnull(), isSelected(), edm::EDGetTokenT< T >::isUninitialized(), TrajectoryStateOnSurface::isValid(), metsig::jet, reco::btau::jetNSecondaryVertices, reco::btau::jetNTracks, IPTools::jetTrackDistance(), EgHLTOffHistBins_cfi::mass, maxDecayLen_, maxDistToAxis_, maxSVDeltaRToJet_, eostools::move(), reco::IPTagInfo< Container, Base >::primaryVertex(), MetAnalyzer::pv(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, edm::second(), TrackCollections2monitor_cff::selectedTracks, reco::IPTagInfo< Container, Base >::selectedTracks(), setTracksPV(), jetUpdater_cfi::sort, reco::IPTagInfo< Container, Base >::sortedIndexes(), bTagMiniDQM_cff::svTagInfo, HLT_2022v12_cff::svTagInfos, svTagInfos_, HLT_2022v12_cff::tagInfos, jetsAK8_cff::tau1, reco::btau::tau1_flightDistance2dSig, reco::btau::tau1_trackEtaRel_0, reco::btau::tau1_trackEtaRel_1, reco::btau::tau1_trackEtaRel_2, reco::btau::tau1_trackSip3dSig_0, reco::btau::tau1_trackSip3dSig_1, reco::btau::tau1_vertexDeltaR, reco::btau::tau1_vertexEnergyRatio, reco::btau::tau1_vertexMass, jetsAK8_cff::tau2, reco::btau::tau2_flightDistance2dSig, reco::btau::tau2_trackEtaRel_0, reco::btau::tau2_trackEtaRel_1, reco::btau::tau2_trackEtaRel_2, reco::btau::tau2_trackSip3dSig_0, reco::btau::tau2_trackSip3dSig_1, reco::btau::tau2_vertexDeltaR, reco::btau::tau2_vertexEnergyRatio, reco::btau::tau2_vertexMass, groupFilesInBlocks::temp, trackBuilderToken_, trackPairV0Filter, trackSelector, reco::btau::trackSip2dSigAboveBottom_0, reco::btau::trackSip2dSigAboveBottom_1, reco::btau::trackSip2dSigAboveCharm, reco::btau::trackSip3dSig_0, reco::btau::trackSip3dSig_1, reco::btau::trackSip3dSig_2, reco::btau::trackSip3dSig_3, reco::TrackKinematics::vectorSum(), bphysicsOniaDQM_cfi::vertex, extraflags_cff::vtx, jetsAK4_CHS_cff::vtxMass, reco::TrackKinematics::weightedVectorSum(), weightsHandle_, weightsToken_, and reco::btau::z_ratio.

153  {
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) {
421  const reco::VertexCompositePtrCandidate& vertex = svTagInfo.secondaryVertex(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) {
430  tau2_flightDistance2dSig = svTagInfo.flightDistance(vtx, true).significance();
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) {
438  tau1_flightDistance2dSig = svTagInfo.flightDistance(vtx, true).significance();
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) {
448  tau1_flightDistance2dSig = svTagInfo.flightDistance(vtx, true).significance();
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 }
static constexpr float charmThreshold
static constexpr float dummyTrackSip2dSigAbove
reco::Vertex::Point convertPos(const GlobalPoint &p)
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
void calcNsubjettiness(const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > &currentAxes) const
void add(const reco::Track &track, double weight=1.0)
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const Container & selectedTracks() const
Definition: IPTagInfo.h:99
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
static constexpr float dummyTrackEtaRel
TrajectoryStateOnSurface closestApproachToJet(const TrajectoryStateOnSurface &state, const reco::Vertex &vertex, const GlobalVector &aJetDirection, const MagneticField *field)
Definition: IPTools.cc:182
reco::TrackSelector trackSelector
void setTracksPV(const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:206
reco::TransientTrack build(const reco::Track *p) const
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
int iEvent
Definition: GenABIO.cc:224
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, const fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
GlobalPoint globalPosition() const
static constexpr float dummyTrackSip3dSig
edm::Handle< edm::ValueMap< float > > weightsHandle_
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
Definition: IPTagInfo.h:231
const MagneticField * field() const
static constexpr float dummyFlightDistance2dSig
const math::XYZTLorentzVector & vectorSum() const
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition: IPTagInfo.h:90
static constexpr float dummyVertexEnergyRatio
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
static constexpr float bottomThreshold
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
static constexpr float dummyZ_ratio
static constexpr float dummyVertexMass
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const math::XYZTLorentzVector & weightedVectorSum() const
const edm::Ref< VertexCollection > & primaryVertex() const
Definition: IPTagInfo.h:133
vars
Definition: DeepTauId.cc:30
static constexpr float dummyVertexDeltaR
def move(src, dest)
Definition: eostools.py:511
TrajectoryStateOnSurface impactPointState() const
cont
load Luminosity info ##
Definition: generateEDF.py:628
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ setTracksPV()

void BoostedDoubleSVProducer::setTracksPV ( const reco::CandidatePtr trackRef,
const reco::VertexRef vertexRef,
float &  PVweight 
) const
private

Definition at line 749 of file BoostedDoubleSVProducer.cc.

References pat::PackedCandidate::fromPV(), edm::Ptr< T >::get(), pfDeepBoostedJetPreprocessParams_cfi::pfcand, pat::PackedCandidate::PVUsedInFit, and setTracksPVBase().

Referenced by produce().

751  {
752  PVweight = 0.;
753 
754  const pat::PackedCandidate* pcand = dynamic_cast<const pat::PackedCandidate*>(trackRef.get());
755 
756  if (pcand) // MiniAOD case
757  {
758  if (pcand->fromPV() == pat::PackedCandidate::PVUsedInFit) {
759  PVweight = 1.;
760  }
761  } else {
762  const reco::PFCandidate* pfcand = dynamic_cast<const reco::PFCandidate*>(trackRef.get());
763 
764  setTracksPVBase(pfcand->trackRef(), vertexRef, PVweight);
765  }
766 }
void setTracksPVBase(const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
const PVAssoc fromPV(size_t ipv=0) const
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41

◆ setTracksPVBase()

void BoostedDoubleSVProducer::setTracksPVBase ( const reco::TrackRef trackRef,
const reco::VertexRef vertexRef,
float &  PVweight 
) const
private

Definition at line 728 of file BoostedDoubleSVProducer.cc.

References extraflags_cff::vtx.

Referenced by setTracksPV().

730  {
731  PVweight = 0.;
732 
733  const reco::TrackBaseRef trackBaseRef(trackRef);
734 
736 
737  const reco::Vertex& vtx = *(vertexRef);
738  // loop over tracks in vertices
739  for (IT it = vtx.tracks_begin(); it != vtx.tracks_end(); ++it) {
740  const reco::TrackBaseRef& baseRef = *it;
741  // one of the tracks in the vertex is the same as the track considered in the function
742  if (baseRef == trackBaseRef) {
743  PVweight = vtx.trackWeight(baseRef);
744  break;
745  }
746  }
747 }
std::vector< LinkConnSpec >::const_iterator IT
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38

Member Data Documentation

◆ beta_

const double BoostedDoubleSVProducer::beta_
private

Definition at line 87 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness().

◆ bottomThreshold

constexpr float BoostedDoubleSVProducer::bottomThreshold = 5.2f
staticprivate

Definition at line 111 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ charmThreshold

constexpr float BoostedDoubleSVProducer::charmThreshold = 1.5f
staticprivate

Definition at line 110 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyFlightDistance2dSig

constexpr float BoostedDoubleSVProducer::dummyFlightDistance2dSig = -1.0f
staticprivate

Definition at line 108 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyTrackEtaRel

constexpr float BoostedDoubleSVProducer::dummyTrackEtaRel = -1.0f
staticprivate

Definition at line 104 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyTrackSip2dSigAbove

constexpr float BoostedDoubleSVProducer::dummyTrackSip2dSigAbove = -19.0f
staticprivate

Definition at line 103 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyTrackSip3dSig

constexpr float BoostedDoubleSVProducer::dummyTrackSip3dSig = -50.0f
staticprivate

Definition at line 102 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyVertexDeltaR

constexpr float BoostedDoubleSVProducer::dummyVertexDeltaR = -1.0f
staticprivate

Definition at line 107 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyVertexEnergyRatio

constexpr float BoostedDoubleSVProducer::dummyVertexEnergyRatio = -1.0f
staticprivate

Definition at line 106 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyVertexMass

constexpr float BoostedDoubleSVProducer::dummyVertexMass = -1.0f
staticprivate

Definition at line 105 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ dummyZ_ratio

constexpr float BoostedDoubleSVProducer::dummyZ_ratio = -3.0f
staticprivate

Definition at line 101 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ maxDecayLen_

const double BoostedDoubleSVProducer::maxDecayLen_
private

Definition at line 92 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ maxDistToAxis_

const double BoostedDoubleSVProducer::maxDistToAxis_
private

Definition at line 91 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ maxSVDeltaRToJet_

const double BoostedDoubleSVProducer::maxSVDeltaRToJet_
private

Definition at line 90 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ R0_

const double BoostedDoubleSVProducer::R0_
private

Definition at line 88 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness().

◆ svTagInfos_

const edm::EDGetTokenT<std::vector<reco::CandSecondaryVertexTagInfo> > BoostedDoubleSVProducer::svTagInfos_
private

Definition at line 85 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ trackBuilderToken_

edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> BoostedDoubleSVProducer::trackBuilderToken_
private

Definition at line 97 of file BoostedDoubleSVProducer.cc.

Referenced by BoostedDoubleSVProducer(), and produce().

◆ trackPairV0Filter

reco::V0Filter BoostedDoubleSVProducer::trackPairV0Filter
private

Definition at line 93 of file BoostedDoubleSVProducer.cc.

Referenced by fillDescriptions(), and produce().

◆ trackSelector

reco::TrackSelector BoostedDoubleSVProducer::trackSelector
private

Definition at line 94 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

◆ weightsHandle_

edm::Handle<edm::ValueMap<float> > BoostedDoubleSVProducer::weightsHandle_
private

Definition at line 98 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness(), and produce().

◆ weightsToken_

edm::EDGetTokenT<edm::ValueMap<float> > BoostedDoubleSVProducer::weightsToken_
private

Definition at line 96 of file BoostedDoubleSVProducer.cc.

Referenced by BoostedDoubleSVProducer(), calcNsubjettiness(), and produce().