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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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_
 
reco::V0Filter trackPairV0Filter
 
reco::TrackSelector trackSelector
 

Static Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 117 of file BoostedDoubleSVProducer.cc.

117  :
118  svTagInfos_( consumes<std::vector<reco::CandSecondaryVertexTagInfo> >(iConfig.getParameter<edm::InputTag>("svTagInfos")) ),
119  beta_(iConfig.getParameter<double>("beta")),
120  R0_(iConfig.getParameter<double>("R0")),
121  maxSVDeltaRToJet_(iConfig.getParameter<double>("maxSVDeltaRToJet")),
122  maxDistToAxis_(iConfig.getParameter<edm::ParameterSet>("trackSelection").getParameter<double>("maxDistToAxis")),
123  maxDecayLen_(iConfig.getParameter<edm::ParameterSet>("trackSelection").getParameter<double>("maxDecayLen")),
124  trackPairV0Filter(iConfig.getParameter<edm::ParameterSet>("trackPairV0Filter")),
125  trackSelector(iConfig.getParameter<edm::ParameterSet>("trackSelection"))
126 {
127  produces<std::vector<reco::BoostedDoubleSVTagInfo> >();
128 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
reco::TrackSelector trackSelector
BoostedDoubleSVProducer::~BoostedDoubleSVProducer ( )
override

Definition at line 131 of file BoostedDoubleSVProducer.cc.

132 {
133 
134  // do anything here that needs to be done at destruction time
135  // (e.g. close files, deallocate resources etc.)
136 
137 }

Member Function Documentation

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

Definition at line 768 of file BoostedDoubleSVProducer.cc.

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

Definition at line 654 of file BoostedDoubleSVProducer.cc.

References beta_, reco::Candidate::daughter(), reco::Candidate::energy(), mps_fire::i, edm::isNotFinite(), nJettinessAdder_cfi::Njettiness, reco::CompositePtrCandidate::numberOfDaughters(), reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), and R0_.

Referenced by produce().

655 {
656  std::vector<fastjet::PseudoJet> fjParticles;
657 
658  // loop over jet constituents and push them in the vector of FastJet constituents
659  for(const reco::CandidatePtr & daughter : jet->daughterPtrVector())
660  {
661  if ( daughter.isNonnull() && daughter.isAvailable() )
662  {
663  const reco::Jet * subjet = dynamic_cast<const reco::Jet *>(daughter.get());
664  // if the daughter is actually a subjet
665  if( subjet && daughter->numberOfDaughters() > 1 )
666  {
667  // loop over subjet constituents and push them in the vector of FastJet constituents
668  for(size_t i=0; i<daughter->numberOfDaughters(); ++i)
669  {
670  const reco::Candidate * constit = daughter->daughter(i);
671 
672  if (constit) {
673  // Check if any values were nan or inf
674  float valcheck = constit->px() + constit->py() + constit->pz() + constit->energy();
675  if (edm::isNotFinite(valcheck)) {
676  edm::LogWarning("FaultyJetConstituent")
677  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
678  continue;
679  }
680  fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
681  } else
682  edm::LogWarning("MissingJetConstituent")
683  << "Jet constituent required for N-subjettiness computation is missing!";
684  }
685  } else {
686  // Check if any values were nan or inf
687  float valcheck = daughter->px() + daughter->py() + daughter->pz() + daughter->energy();
688  if (edm::isNotFinite(valcheck)) {
689  edm::LogWarning("FaultyJetConstituent")
690  << "Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
691  continue;
692  }
693  fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
694  }
695  } else
696  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
697  }
698 
699  // N-subjettiness calculator
700  fastjet::contrib::Njettiness njettiness(fastjet::contrib::OnePass_KT_Axes(), fastjet::contrib::NormalizedMeasure(beta_,R0_));
701 
702  // calculate N-subjettiness
703  tau1 = njettiness.getTau(1, fjParticles);
704  tau2 = njettiness.getTau(2, fjParticles);
705  currentAxes = njettiness.currentAxes();
706 }
virtual double pz() const =0
z coordinate of momentum vector
Base class for all types of Jets.
Definition: Jet.h:20
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
size_t numberOfDaughters() const override
number of daughters
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
bool isNotFinite(T x)
Definition: isFinite.h:10
virtual double px() const =0
x coordinate of momentum vector
void BoostedDoubleSVProducer::endStream ( )
overrideprivate

Definition at line 774 of file BoostedDoubleSVProducer.cc.

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

Definition at line 757 of file BoostedDoubleSVProducer.cc.

References funct::abs(), reco::CompositePtrCandidate::daughterPtrVector(), reco::btau::etaRel(), HiIsolationCommonParameters_cff::track, and l1t::tracks.

Referenced by produce().

758 {
759  math::XYZVector direction(tauAxis.px(), tauAxis.py(), tauAxis.pz());
760  const std::vector<reco::CandidatePtr> & tracks = vertex.daughterPtrVector();
761 
762  for(std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track)
763  tau_trackEtaRel.push_back(std::abs(reco::btau::etaRel(direction.Unit(), (*track)->momentum())));
764 }
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
virtual const daughters & daughterPtrVector() const
references to daughtes
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void BoostedDoubleSVProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 779 of file BoostedDoubleSVProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

779  {
780  //The following says we do not know what parameters are allowed so do no validation
781  // Please change this to state exactly what you do use, even if it is no parameters
783  desc.setUnknown();
784  descriptions.addDefault(desc);
785 }
void addDefault(ParameterSetDescription const &psetDescription)
void BoostedDoubleSVProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 146 of file BoostedDoubleSVProducer.cc.

References funct::abs(), reco::TrackKinematics::add(), bottomThreshold, TransientTrackBuilder::build(), calcNsubjettiness(), charmThreshold, IPTools::closestApproachToJet(), RecoVertex::convertPos(), data, reco::deltaR(), reco::deltaR2(), dummyFlightDistance2dSig, dummyTrackEtaRel, dummyTrackSip2dSigAbove, dummyTrackSip3dSig, dummyVertexDeltaR, dummyVertexEnergyRatio, dummyVertexMass, dummyZ_ratio, Measurement1D::error(), etaRelToTauAxis(), reco::TransientTrack::field(), reco::TaggingVariableList::finalize(), reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::flightDirection(), reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::flightDistance(), edm::EventSetup::get(), edm::Event::getByToken(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, training_settings::idx, reco::IPTagInfo< Container, Base >::impactParameterData(), reco::TransientTrack::impactPointState(), reco::TaggingVariableList::insert(), reco::btag::TrackIPData::ip2d, reco::btag::IP2DSig, edm::Ref< C, T, F >::isNonnull(), TrajectoryStateOnSurface::isValid(), metsig::jet, reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::jet(), reco::btau::jetNSecondaryVertices, reco::btau::jetNTracks, IPTools::jetTrackDistance(), ResonanceBuilder::mass, maxDecayLen_, maxDistToAxis_, maxSVDeltaRToJet_, eostools::move(), reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::nVertices(), reco::LeafCandidate::p4(), reco::IPTagInfo< Container, Base >::primaryVertex(), edm::Event::put(), MetAnalyzer::pv(), edm::second(), reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::secondaryVertex(), reco::IPTagInfo< Container, Base >::selectedTracks(), trackingPlots::selectedTracks, setTracksPV(), Measurement1D::significance(), reco::IPTagInfo< Container, Base >::sortedIndexes(), caloDeepCSVTagInfos_cfi::svTagInfos, svTagInfos_, combinedMVAV2BJetTags_cfi::tagInfos, jets_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, jets_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, 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(), badGlobalMuonTaggersAOD_cff::vtx, jets_cff::vtxMass, reco::TrackKinematics::weightedVectorSum(), and reco::btau::z_ratio.

147 {
148  // get the track builder
150  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",trackBuilder);
151 
152  // get input secondary vertex TagInfos
154  iEvent.getByToken(svTagInfos_, svTagInfos);
155 
156  // create the output collection
157  auto tagInfos = std::make_unique<std::vector<reco::BoostedDoubleSVTagInfo> >();
158 
159  // loop over TagInfos
160  for(std::vector<reco::CandSecondaryVertexTagInfo>::const_iterator iterTI = svTagInfos->begin(); iterTI != svTagInfos->end(); ++iterTI)
161  {
162  // get TagInfos
163  const reco::CandIPTagInfo & ipTagInfo = *(iterTI->trackIPTagInfoRef().get());
164  const reco::CandSecondaryVertexTagInfo & svTagInfo = *(iterTI);
165 
166  // default variable values
167  float z_ratio = dummyZ_ratio;
175  float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
176 
177  // get the jet reference
178  const reco::JetBaseRef jet = svTagInfo.jet();
179 
180  std::vector<fastjet::PseudoJet> currentAxes;
181  float tau2, tau1;
182  // calculate N-subjettiness
183  calcNsubjettiness(jet, tau1, tau2, currentAxes);
184 
185  const reco::VertexRef & vertexRef = ipTagInfo.primaryVertex();
186  GlobalPoint pv(0.,0.,0.);
187  if ( ipTagInfo.primaryVertex().isNonnull() )
188  pv = GlobalPoint(vertexRef->x(),vertexRef->y(),vertexRef->z());
189 
190  const std::vector<reco::CandidatePtr> & selectedTracks = ipTagInfo.selectedTracks();
191  const std::vector<reco::btag::TrackIPData> & ipData = ipTagInfo.impactParameterData();
192  size_t trackSize = selectedTracks.size();
193 
194 
195  reco::TrackKinematics allKinematics;
196  std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
197  int contTrk=0;
198 
199  // loop over tracks associated to the jet
200  for (size_t itt=0; itt < trackSize; ++itt)
201  {
202  const reco::CandidatePtr trackRef = selectedTracks[itt];
203 
204  float track_PVweight = 0.;
205  setTracksPV(trackRef, vertexRef, track_PVweight);
206  if (track_PVweight>0.5) allKinematics.add(trackRef);
207 
208  const reco::btag::TrackIPData &data = ipData[itt];
209  bool isSelected = false;
210  if (trackSelector(trackRef, data, *jet, pv)) isSelected = true;
211 
212  // check if the track is from V0
213  bool isfromV0 = false, isfromV0Tight = false;
214  std::vector<reco::CandidatePtr> trackPairV0Test(2);
215 
216  trackPairV0Test[0] = trackRef;
217 
218  for (size_t jtt=0; jtt < trackSize; ++jtt)
219  {
220  if (itt == jtt) continue;
221 
222  const reco::btag::TrackIPData & pairTrackData = ipData[jtt];
223  const reco::CandidatePtr pairTrackRef = selectedTracks[jtt];
224 
225  trackPairV0Test[1] = pairTrackRef;
226 
227  if (!trackPairV0Filter(trackPairV0Test))
228  {
229  isfromV0 = true;
230 
231  if ( trackSelector(pairTrackRef, pairTrackData, *jet, pv) )
232  isfromV0Tight = true;
233  }
234 
235  if (isfromV0 && isfromV0Tight)
236  break;
237  }
238 
239  if( isSelected && !isfromV0Tight ) jetNTracks += 1.;
240 
241  reco::TransientTrack transientTrack = trackBuilder->build(trackRef);
242  GlobalVector direction(jet->px(), jet->py(), jet->pz());
243 
244  int index = 0;
245  if (currentAxes.size() > 1 && reco::deltaR2(trackRef->momentum(),currentAxes[1]) < reco::deltaR2(trackRef->momentum(),currentAxes[0]))
246  index = 1;
247  direction = GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
248 
249  // decay distance and track distance wrt to the closest tau axis
250  float decayLengthTau=-1;
251  float distTauAxis=-1;
252 
253  TrajectoryStateOnSurface closest = IPTools::closestApproachToJet(transientTrack.impactPointState(), *vertexRef , direction, transientTrack.field());
254  if (closest.isValid())
255  decayLengthTau = (closest.globalPosition() - RecoVertex::convertPos(vertexRef->position())).mag();
256 
257  distTauAxis = std::abs(IPTools::jetTrackDistance(transientTrack, direction, *vertexRef ).second.value());
258 
259  float IP3Dsig = ipTagInfo.impactParameterData()[itt].ip3d.significance();
260 
261  if( !isfromV0 && decayLengthTau<maxDecayLen_ && distTauAxis<maxDistToAxis_ )
262  {
263  IP3Ds.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
264  ++contTrk;
265  if (currentAxes.size() > 1)
266  {
267  if (reco::deltaR2(trackRef->momentum(),currentAxes[0]) < reco::deltaR2(trackRef->momentum(),currentAxes[1]))
268  IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
269  else
270  IP3Ds_2.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
271  }
272  else
273  IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
274  }
275  }
276 
277  std::vector<size_t> indices = ipTagInfo.sortedIndexes(reco::btag::IP2DSig);
278  bool charmThreshSet = false;
279 
281  for (size_t i=0; i<indices.size(); ++i)
282  {
283  size_t idx = indices[i];
284  const reco::btag::TrackIPData & data = ipData[idx];
285  const reco::CandidatePtr trackRef = selectedTracks[idx];
286 
287  kin.add(trackRef);
288 
289  if ( kin.vectorSum().M() > charmThreshold // charm cut
290  && !charmThreshSet )
291  {
292  trackSip2dSigAboveCharm_0 = data.ip2d.significance();
293 
294  charmThreshSet = true;
295  }
296 
297  if ( kin.vectorSum().M() > bottomThreshold ) // bottom cut
298  {
299  trackSip2dSigAboveBottom_0 = data.ip2d.significance();
300  if ( (i+1)<indices.size() ) trackSip2dSigAboveBottom_1 = (ipData[indices[i+1]]).ip2d.significance();
301 
302  break;
303  }
304  }
305 
306  float dummyTrack = -50.;
307 
308  std::sort( IP3Ds.begin(),IP3Ds.end(),std::greater<float>() );
309  std::sort( IP3Ds_1.begin(),IP3Ds_1.end(),std::greater<float>() );
310  std::sort( IP3Ds_2.begin(),IP3Ds_2.end(),std::greater<float>() );
311  int num_1 = IP3Ds_1.size();
312  int num_2 = IP3Ds_2.size();
313 
314  switch(contTrk){
315  case 0:
316 
317  trackSip3dSig_0 = dummyTrack;
318  trackSip3dSig_1 = dummyTrack;
319  trackSip3dSig_2 = dummyTrack;
320  trackSip3dSig_3 = dummyTrack;
321 
322  break;
323 
324  case 1:
325 
326  trackSip3dSig_0 = IP3Ds.at(0);
327  trackSip3dSig_1 = dummyTrack;
328  trackSip3dSig_2 = dummyTrack;
329  trackSip3dSig_3 = dummyTrack;
330 
331  break;
332 
333  case 2:
334 
335  trackSip3dSig_0 = IP3Ds.at(0);
336  trackSip3dSig_1 = IP3Ds.at(1);
337  trackSip3dSig_2 = dummyTrack;
338  trackSip3dSig_3 = dummyTrack;
339 
340  break;
341 
342  case 3:
343 
344  trackSip3dSig_0 = IP3Ds.at(0);
345  trackSip3dSig_1 = IP3Ds.at(1);
346  trackSip3dSig_2 = IP3Ds.at(2);
347  trackSip3dSig_3 = dummyTrack;
348 
349  break;
350 
351  default:
352 
353  trackSip3dSig_0 = IP3Ds.at(0);
354  trackSip3dSig_1 = IP3Ds.at(1);
355  trackSip3dSig_2 = IP3Ds.at(2);
356  trackSip3dSig_3 = IP3Ds.at(3);
357 
358  }
359 
360  switch(num_1){
361  case 0:
362 
363  tau1_trackSip3dSig_0 = dummyTrack;
364  tau1_trackSip3dSig_1 = dummyTrack;
365 
366  break;
367 
368  case 1:
369 
370  tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
371  tau1_trackSip3dSig_1 = dummyTrack;
372 
373  break;
374 
375  default:
376 
377  tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
378  tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
379 
380  }
381 
382  switch(num_2){
383  case 0:
384 
385  tau2_trackSip3dSig_0 = dummyTrack;
386  tau2_trackSip3dSig_1 = dummyTrack;
387 
388  break;
389 
390  case 1:
391  tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
392  tau2_trackSip3dSig_1 = dummyTrack;
393 
394  break;
395 
396  default:
397 
398  tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
399  tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
400 
401  }
402 
403  math::XYZVector jetDir = jet->momentum().Unit();
404  reco::TrackKinematics tau1Kinematics;
405  reco::TrackKinematics tau2Kinematics;
406  std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
407 
408  std::map<double, size_t> VTXmap;
409  for (size_t vtx = 0; vtx < svTagInfo.nVertices(); ++vtx)
410  {
411  const reco::VertexCompositePtrCandidate& vertex = svTagInfo.secondaryVertex(vtx);
412  // get the vertex kinematics
413  reco::TrackKinematics vertexKinematic(vertex);
414 
415  if (currentAxes.size() > 1)
416  {
417  if (reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[1]) < reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[0]))
418  {
419  tau2Kinematics = tau2Kinematics + vertexKinematic;
420  if( tau2_flightDistance2dSig < 0 )
421  {
422  tau2_flightDistance2dSig = svTagInfo.flightDistance(vtx,true).significance();
423  tau2_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[1]);
424  }
425  etaRelToTauAxis(vertex, currentAxes[1], tau2_trackEtaRels);
426  tau2_nSecondaryVertices += 1.;
427  }
428  else
429  {
430  tau1Kinematics = tau1Kinematics + vertexKinematic;
431  if( tau1_flightDistance2dSig < 0 )
432  {
433  tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,true).significance();
434  tau1_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
435  }
436  etaRelToTauAxis(vertex, currentAxes[0], tau1_trackEtaRels);
437  tau1_nSecondaryVertices += 1.;
438  }
439 
440  }
441  else if (!currentAxes.empty())
442  {
443  tau1Kinematics = tau1Kinematics + vertexKinematic;
444  if( tau1_flightDistance2dSig < 0 )
445  {
446  tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,true).significance();
447  tau1_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
448  }
449  etaRelToTauAxis(vertex, currentAxes[0], tau1_trackEtaRels);
450  tau1_nSecondaryVertices += 1.;
451  }
452 
453  const GlobalVector& flightDir = svTagInfo.flightDirection(vtx);
454  if (reco::deltaR2(flightDir, jetDir)<(maxSVDeltaRToJet_*maxSVDeltaRToJet_))
455  VTXmap[svTagInfo.flightDistance(vtx).error()]=vtx;
456  }
457  nSV = VTXmap.size();
458 
459 
460  math::XYZTLorentzVector allSum = allKinematics.weightedVectorSum() ;
461  if ( tau1_nSecondaryVertices > 0. )
462  {
463  const math::XYZTLorentzVector& tau1_vertexSum = tau1Kinematics.weightedVectorSum();
464  if ( allSum.E() > 0. ) tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
465  if ( tau1_vertexEnergyRatio > 50. ) tau1_vertexEnergyRatio = 50.;
466 
467  tau1_vertexMass = tau1_vertexSum.M();
468  }
469 
470  if ( tau2_nSecondaryVertices > 0. )
471  {
472  const math::XYZTLorentzVector& tau2_vertexSum = tau2Kinematics.weightedVectorSum();
473  if ( allSum.E() > 0. ) tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
474  if ( tau2_vertexEnergyRatio > 50. ) tau2_vertexEnergyRatio = 50.;
475 
476  tau2_vertexMass= tau2_vertexSum.M();
477  }
478 
479 
480  float dummyEtaRel = -1.;
481 
482  std::sort( tau1_trackEtaRels.begin(),tau1_trackEtaRels.end() );
483  std::sort( tau2_trackEtaRels.begin(),tau2_trackEtaRels.end() );
484 
485  switch(tau2_trackEtaRels.size()){
486  case 0:
487 
488  tau2_trackEtaRel_0 = dummyEtaRel;
489  tau2_trackEtaRel_1 = dummyEtaRel;
490  tau2_trackEtaRel_2 = dummyEtaRel;
491 
492  break;
493 
494  case 1:
495 
496  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
497  tau2_trackEtaRel_1 = dummyEtaRel;
498  tau2_trackEtaRel_2 = dummyEtaRel;
499 
500  break;
501 
502  case 2:
503 
504  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
505  tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
506  tau2_trackEtaRel_2 = dummyEtaRel;
507 
508  break;
509 
510  default:
511 
512  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
513  tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
514  tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
515 
516  }
517 
518  switch(tau1_trackEtaRels.size()){
519  case 0:
520 
521  tau1_trackEtaRel_0 = dummyEtaRel;
522  tau1_trackEtaRel_1 = dummyEtaRel;
523  tau1_trackEtaRel_2 = dummyEtaRel;
524 
525  break;
526 
527  case 1:
528 
529  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
530  tau1_trackEtaRel_1 = dummyEtaRel;
531  tau1_trackEtaRel_2 = dummyEtaRel;
532 
533  break;
534 
535  case 2:
536 
537  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
538  tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
539  tau1_trackEtaRel_2 = dummyEtaRel;
540 
541  break;
542 
543  default:
544 
545  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
546  tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
547  tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
548 
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  {
558  ++cont;
559  const reco::VertexCompositePtrCandidate &vertex = svTagInfo.secondaryVertex(iVtx->second);
560  if (cont==1)
561  {
562  flightDir_0 = svTagInfo.flightDirection(iVtx->second);
563  SV_p4_0 = vertex.p4();
564  vtxMass = SV_p4_0.mass();
565 
566  if(vtxMass > 0.)
567  z_ratio = reco::deltaR(currentAxes[1],currentAxes[0])*SV_p4_0.pt()/vtxMass;
568  }
569  if (cont==2)
570  {
571  flightDir_1 = svTagInfo.flightDirection(iVtx->second);
572  SV_p4_1 = vertex.p4();
573  vtxMass = (SV_p4_1+SV_p4_0).mass();
574 
575  if(vtxMass > 0.)
576  z_ratio = reco::deltaR(flightDir_0,flightDir_1)*SV_p4_1.pt()/vtxMass;
577 
578  break;
579  }
580  }
581 
582  // when only one tau axis has SVs assigned, they are all assigned to the 1st tau axis
583  // in the special case below need to swap values
584  if( (tau1_vertexMass<0 && tau2_vertexMass>0) )
585  {
586  float temp = tau1_trackEtaRel_0;
587  tau1_trackEtaRel_0= tau2_trackEtaRel_0;
588  tau2_trackEtaRel_0= temp;
589 
590  temp = tau1_trackEtaRel_1;
591  tau1_trackEtaRel_1= tau2_trackEtaRel_1;
592  tau2_trackEtaRel_1= temp;
593 
594  temp = tau1_trackEtaRel_2;
595  tau1_trackEtaRel_2= tau2_trackEtaRel_2;
596  tau2_trackEtaRel_2= temp;
597 
599  tau1_flightDistance2dSig= tau2_flightDistance2dSig;
600  tau2_flightDistance2dSig= temp;
601 
602  tau1_vertexDeltaR= tau2_vertexDeltaR;
603 
604  temp = tau1_vertexEnergyRatio;
605  tau1_vertexEnergyRatio= tau2_vertexEnergyRatio;
606  tau2_vertexEnergyRatio= temp;
607 
608  temp = tau1_vertexMass;
609  tau1_vertexMass= tau2_vertexMass;
610  tau2_vertexMass= temp;
611  }
612 
614 
615  vars.insert(reco::btau::jetNTracks, jetNTracks, true);
616  vars.insert(reco::btau::jetNSecondaryVertices, nSV, true);
617  vars.insert(reco::btau::trackSip3dSig_0, trackSip3dSig_0, true);
618  vars.insert(reco::btau::trackSip3dSig_1, trackSip3dSig_1, true);
619  vars.insert(reco::btau::trackSip3dSig_2, trackSip3dSig_2, true);
620  vars.insert(reco::btau::trackSip3dSig_3, trackSip3dSig_3, true);
621  vars.insert(reco::btau::tau1_trackSip3dSig_0, tau1_trackSip3dSig_0, true);
622  vars.insert(reco::btau::tau1_trackSip3dSig_1, tau1_trackSip3dSig_1, true);
623  vars.insert(reco::btau::tau2_trackSip3dSig_0, tau2_trackSip3dSig_0, true);
624  vars.insert(reco::btau::tau2_trackSip3dSig_1, tau2_trackSip3dSig_1, true);
625  vars.insert(reco::btau::trackSip2dSigAboveCharm, trackSip2dSigAboveCharm_0, true);
626  vars.insert(reco::btau::trackSip2dSigAboveBottom_0, trackSip2dSigAboveBottom_0, true);
627  vars.insert(reco::btau::trackSip2dSigAboveBottom_1, trackSip2dSigAboveBottom_1, true);
628  vars.insert(reco::btau::tau1_trackEtaRel_0, tau1_trackEtaRel_0, true);
629  vars.insert(reco::btau::tau1_trackEtaRel_1, tau1_trackEtaRel_1, true);
630  vars.insert(reco::btau::tau1_trackEtaRel_2, tau1_trackEtaRel_2, true);
631  vars.insert(reco::btau::tau2_trackEtaRel_0, tau2_trackEtaRel_0, true);
632  vars.insert(reco::btau::tau2_trackEtaRel_1, tau2_trackEtaRel_1, true);
633  vars.insert(reco::btau::tau2_trackEtaRel_2, tau2_trackEtaRel_2, true);
634  vars.insert(reco::btau::tau1_vertexMass, tau1_vertexMass, true);
635  vars.insert(reco::btau::tau1_vertexEnergyRatio, tau1_vertexEnergyRatio, true);
636  vars.insert(reco::btau::tau1_flightDistance2dSig, tau1_flightDistance2dSig, true);
637  vars.insert(reco::btau::tau1_vertexDeltaR, tau1_vertexDeltaR, true);
638  vars.insert(reco::btau::tau2_vertexMass, tau2_vertexMass, true);
639  vars.insert(reco::btau::tau2_vertexEnergyRatio, tau2_vertexEnergyRatio, true);
640  vars.insert(reco::btau::tau2_flightDistance2dSig, tau2_flightDistance2dSig, true);
641  vars.insert(reco::btau::z_ratio, z_ratio, true);
642 
643  vars.finalize();
644 
645  tagInfos->push_back( reco::BoostedDoubleSVTagInfo(vars, edm::Ref<std::vector<reco::CandSecondaryVertexTagInfo> >(svTagInfos, iterTI - svTagInfos->begin())) );
646  }
647 
648  // put the output in the event
649  iEvent.put( std::move(tagInfos) );
650 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
const math::XYZTLorentzVector & weightedVectorSum() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
void add(const reco::Track &track, double weight=1.0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
const VTX & secondaryVertex(unsigned int index) const
Measurement1D ip2d
Definition: IPTagInfo.h:31
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
reco::TransientTrack build(const reco::Track *p) const
double error() const
Definition: Measurement1D.h:30
edm::RefToBase< Jet > jet(void) const override
returns a polymorphic reference to the tagged jet
GlobalPoint globalPosition() const
const Container & selectedTracks() const
Definition: IPTagInfo.h:101
TrajectoryStateOnSurface closestApproachToJet(const TrajectoryStateOnSurface &state, const reco::Vertex &vertex, const GlobalVector &aJetDirection, const MagneticField *field)
Definition: IPTools.cc:177
const MagneticField * field() const
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, const fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
reco::TrackSelector trackSelector
const edm::Ref< VertexCollection > & primaryVertex() const
Definition: IPTagInfo.h:133
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:200
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void calcNsubjettiness(const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > &currentAxes) const
def pv(vc)
Definition: MetAnalyzer.py:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
Definition: IPTagInfo.h:238
const GlobalVector & flightDirection(unsigned int index) const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition: IPTagInfo.h:91
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
double significance() const
Definition: Measurement1D.h:32
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const math::XYZTLorentzVector & vectorSum() const
Measurement1D flightDistance(unsigned int index, int dim=0) const
void setTracksPV(const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
T get() const
Definition: EventSetup.h:63
TrajectoryStateOnSurface impactPointState() const
vars
Definition: DeepTauId.cc:77
def move(src, dest)
Definition: eostools.py:510
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void insert(const TaggingVariable &variable, bool delayed=false)
void BoostedDoubleSVProducer::setTracksPV ( const reco::CandidatePtr trackRef,
const reco::VertexRef vertexRef,
float &  PVweight 
) const
private

Definition at line 734 of file BoostedDoubleSVProducer.cc.

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

Referenced by produce().

735 {
736  PVweight = 0.;
737 
738  const pat::PackedCandidate * pcand = dynamic_cast<const pat::PackedCandidate *>(trackRef.get());
739 
740  if(pcand) // MiniAOD case
741  {
742  if( pcand->fromPV() == pat::PackedCandidate::PVUsedInFit )
743  {
744  PVweight = 1.;
745  }
746  }
747  else
748  {
749  const reco::PFCandidate * pfcand = dynamic_cast<const reco::PFCandidate *>(trackRef.get());
750 
751  setTracksPVBase(pfcand->trackRef(), vertexRef, PVweight);
752  }
753 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
void setTracksPVBase(const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
const PVAssoc fromPV(size_t ipv=0) const
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
void BoostedDoubleSVProducer::setTracksPVBase ( const reco::TrackRef trackRef,
const reco::VertexRef vertexRef,
float &  PVweight 
) const
private

Definition at line 710 of file BoostedDoubleSVProducer.cc.

References reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), reco::Vertex::trackWeight(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by setTracksPV().

711 {
712  PVweight = 0.;
713 
714  const reco::TrackBaseRef trackBaseRef( trackRef );
715 
717 
718  const reco::Vertex & vtx = *(vertexRef);
719  // loop over tracks in vertices
720  for(IT it=vtx.tracks_begin(); it!=vtx.tracks_end(); ++it)
721  {
722  const reco::TrackBaseRef & baseRef = *it;
723  // one of the tracks in the vertex is the same as the track considered in the function
724  if( baseRef == trackBaseRef )
725  {
726  PVweight = vtx.trackWeight(baseRef);
727  break;
728  }
729  }
730 }
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:81
std::vector< LinkConnSpec >::const_iterator IT
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76

Member Data Documentation

const double BoostedDoubleSVProducer::beta_
private

Definition at line 82 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness().

float BoostedDoubleSVProducer::bottomThreshold = 5.2f
staticprivate

Definition at line 102 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::charmThreshold = 1.5f
staticprivate

Definition at line 101 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyFlightDistance2dSig = -1.0f
staticprivate

Definition at line 99 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyTrackEtaRel = -1.0f
staticprivate

Definition at line 95 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyTrackSip2dSigAbove = -19.0f
staticprivate

Definition at line 94 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyTrackSip3dSig = -50.0f
staticprivate

Definition at line 93 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyVertexDeltaR = -1.0f
staticprivate

Definition at line 98 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyVertexEnergyRatio = -1.0f
staticprivate

Definition at line 97 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyVertexMass = -1.0f
staticprivate

Definition at line 96 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyZ_ratio = -3.0f
staticprivate

Definition at line 92 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::maxDecayLen_
private

Definition at line 87 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::maxDistToAxis_
private

Definition at line 86 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::maxSVDeltaRToJet_
private

Definition at line 85 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::R0_
private

Definition at line 83 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness().

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

Definition at line 80 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

reco::V0Filter BoostedDoubleSVProducer::trackPairV0Filter
private

Definition at line 88 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

reco::TrackSelector BoostedDoubleSVProducer::trackSelector
private

Definition at line 89 of file BoostedDoubleSVProducer.cc.

Referenced by produce().