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_2023v12_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:307
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 782 of file BoostedDoubleSVProducer.cc.

782 {}

◆ 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 
665  if (constit.isNonnull() && constit->pt() > std::numeric_limits<double>::epsilon()) {
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  if (w > 0) {
683  fjParticles.push_back(
684  fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
685  }
686  } else {
687  fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
688  }
689  } else
690  edm::LogWarning("MissingJetConstituent")
691  << "Jet constituent required for N-subjettiness computation is missing!";
692  }
693  } else {
694  // Check if any values were nan or inf
695  float valcheck = daughter->px() + daughter->py() + daughter->pz() + daughter->energy();
696  if (edm::isNotFinite(valcheck)) {
697  edm::LogWarning("FaultyJetConstituent")
698  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
699  continue;
700  }
701  if (jet->isWeighted()) {
702  float w = 0.0;
704  w = (*weightsHandle_)[daughter];
705  else {
706  throw cms::Exception("MissingConstituentWeight")
707  << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
708  }
709  if (w > 0 && daughter->pt() > std::numeric_limits<double>::epsilon()) {
710  fjParticles.push_back(
711  fastjet::PseudoJet(daughter->px() * w, daughter->py() * w, daughter->pz() * w, daughter->energy() * w));
712  }
713  } else {
714  fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
715  }
716  }
717  } else
718  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
719  }
720 
721  // N-subjettiness calculator
722  fastjet::contrib::Njettiness njettiness(fastjet::contrib::OnePass_KT_Axes(),
723  fastjet::contrib::NormalizedMeasure(beta_, R0_));
724 
725  // calculate N-subjettiness
726  tau1 = njettiness.getTau(1, fjParticles);
727  tau2 = njettiness.getTau(2, fjParticles);
728  currentAxes = njettiness.currentAxes();
729 }
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:104
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 785 of file BoostedDoubleSVProducer.cc.

785 {}

◆ etaRelToTauAxis()

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

Definition at line 771 of file BoostedDoubleSVProducer.cc.

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

Referenced by produce().

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

◆ fillDescriptions()

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

Definition at line 788 of file BoostedDoubleSVProducer.cc.

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

788  {
790  desc.add<double>("beta", 1.0);
791  desc.add<double>("R0", 0.8);
792  desc.add<double>("maxSVDeltaRToJet", 0.7);
793  {
795  trackSelection.setAllowAnything();
796  desc.add<edm::ParameterSetDescription>("trackSelection", trackSelection);
797  }
798  {
800  trackPairV0Filter.add<double>("k0sMassWindow", 0.03);
801  desc.add<edm::ParameterSetDescription>("trackPairV0Filter", trackPairV0Filter);
802  }
803  desc.add<edm::InputTag>("svTagInfos", edm::InputTag("pfInclusiveSecondaryVertexFinderAK8TagInfos"));
804  desc.add<edm::InputTag>("weights", edm::InputTag(""));
805  descriptions.addDefault(desc);
806 }
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, pv::closest(), 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(), 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(), 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_2023v12_cff::svTagInfos, svTagInfos_, HLT_2023v12_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, L1BJetProducer_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)
vars
Definition: DeepTauIdBase.h:60
int closest(std::vector< int > const &vec, int value)
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
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
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:130
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:80
const math::XYZTLorentzVector & weightedVectorSum() const
const edm::Ref< VertexCollection > & primaryVertex() const
Definition: IPTagInfo.h:133
static constexpr float dummyVertexDeltaR
def move(src, dest)
Definition: eostools.py:511
TrajectoryStateOnSurface impactPointState() const
cont
load Luminosity info ##
Definition: generateEDF.py:620
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 752 of file BoostedDoubleSVProducer.cc.

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

Referenced by produce().

754  {
755  PVweight = 0.;
756 
757  const pat::PackedCandidate* pcand = dynamic_cast<const pat::PackedCandidate*>(trackRef.get());
758 
759  if (pcand) // MiniAOD case
760  {
761  if (pcand->fromPV() == pat::PackedCandidate::PVUsedInFit) {
762  PVweight = 1.;
763  }
764  } else {
765  const reco::PFCandidate* pfcand = dynamic_cast<const reco::PFCandidate*>(trackRef.get());
766 
767  setTracksPVBase(pfcand->trackRef(), vertexRef, PVweight);
768  }
769 }
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 731 of file BoostedDoubleSVProducer.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and L1BJetProducer_cff::vtx.

Referenced by setTracksPV().

733  {
734  PVweight = 0.;
735 
736  const reco::TrackBaseRef trackBaseRef(trackRef);
737 
739 
740  const reco::Vertex& vtx = *(vertexRef);
741  // loop over tracks in vertices
742  for (IT it = vtx.tracks_begin(); it != vtx.tracks_end(); ++it) {
743  const reco::TrackBaseRef& baseRef = *it;
744  // one of the tracks in the vertex is the same as the track considered in the function
745  if (baseRef == trackBaseRef) {
746  PVweight = vtx.trackWeight(baseRef);
747  break;
748  }
749  }
750 }
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().