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 61 of file BoostedDoubleSVProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 116 of file BoostedDoubleSVProducer.cc.

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

Definition at line 130 of file BoostedDoubleSVProducer.cc.

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

Member Function Documentation

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

Definition at line 753 of file BoostedDoubleSVProducer.cc.

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

Definition at line 653 of file BoostedDoubleSVProducer.cc.

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

Referenced by produce().

654 {
655  std::vector<fastjet::PseudoJet> fjParticles;
656 
657  // loop over jet constituents and push them in the vector of FastJet constituents
658  for(const reco::CandidatePtr & daughter : jet->daughterPtrVector())
659  {
660  if ( daughter.isNonnull() && daughter.isAvailable() )
661  {
662  const reco::Jet * subjet = dynamic_cast<const reco::Jet *>(daughter.get());
663  // if the daughter is actually a subjet
664  if( subjet && daughter->numberOfDaughters() > 1 )
665  {
666  // loop over subjet constituents and push them in the vector of FastJet constituents
667  for(size_t i=0; i<daughter->numberOfDaughters(); ++i)
668  {
669  const reco::Candidate * constit = daughter->daughter(i);
670 
671  if ( constit )
672  fjParticles.push_back( fastjet::PseudoJet( constit->px(), constit->py(), constit->pz(), constit->energy() ) );
673  else
674  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
675  }
676  }
677  else
678  fjParticles.push_back( fastjet::PseudoJet( daughter->px(), daughter->py(), daughter->pz(), daughter->energy() ) );
679  }
680  else
681  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
682  }
683 
684  // N-subjettiness calculator
685  fastjet::contrib::Njettiness njettiness(fastjet::contrib::OnePass_KT_Axes(), fastjet::contrib::NormalizedMeasure(beta_,R0_));
686 
687  // calculate N-subjettiness
688  tau1 = njettiness.getTau(1, fjParticles);
689  tau2 = njettiness.getTau(2, fjParticles);
690  currentAxes = njettiness.currentAxes();
691 }
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
virtual double px() const =0
x coordinate of momentum vector
void BoostedDoubleSVProducer::endStream ( )
overrideprivate

Definition at line 759 of file BoostedDoubleSVProducer.cc.

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

Definition at line 742 of file BoostedDoubleSVProducer.cc.

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

Referenced by produce().

743 {
744  math::XYZVector direction(tauAxis.px(), tauAxis.py(), tauAxis.pz());
745  const std::vector<reco::CandidatePtr> & tracks = vertex.daughterPtrVector();
746 
747  for(std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track)
748  tau_trackEtaRel.push_back(std::abs(reco::btau::etaRel(direction.Unit(), (*track)->momentum())));
749 }
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 764 of file BoostedDoubleSVProducer.cc.

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

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

Definition at line 145 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.

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

720 {
721  PVweight = 0.;
722 
723  const pat::PackedCandidate * pcand = dynamic_cast<const pat::PackedCandidate *>(trackRef.get());
724 
725  if(pcand) // MiniAOD case
726  {
727  if( pcand->fromPV() == pat::PackedCandidate::PVUsedInFit )
728  {
729  PVweight = 1.;
730  }
731  }
732  else
733  {
734  const reco::PFCandidate * pfcand = dynamic_cast<const reco::PFCandidate *>(trackRef.get());
735 
736  setTracksPVBase(pfcand->trackRef(), vertexRef, PVweight);
737  }
738 }
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 695 of file BoostedDoubleSVProducer.cc.

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

Referenced by setTracksPV().

696 {
697  PVweight = 0.;
698 
699  const reco::TrackBaseRef trackBaseRef( trackRef );
700 
702 
703  const reco::Vertex & vtx = *(vertexRef);
704  // loop over tracks in vertices
705  for(IT it=vtx.tracks_begin(); it!=vtx.tracks_end(); ++it)
706  {
707  const reco::TrackBaseRef & baseRef = *it;
708  // one of the tracks in the vertex is the same as the track considered in the function
709  if( baseRef == trackBaseRef )
710  {
711  PVweight = vtx.trackWeight(baseRef);
712  break;
713  }
714  }
715 }
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 81 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness().

float BoostedDoubleSVProducer::bottomThreshold = 5.2f
staticprivate

Definition at line 101 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::charmThreshold = 1.5f
staticprivate

Definition at line 100 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyFlightDistance2dSig = -1.0f
staticprivate

Definition at line 98 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyTrackEtaRel = -1.0f
staticprivate

Definition at line 94 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyTrackSip2dSigAbove = -19.0f
staticprivate

Definition at line 93 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyTrackSip3dSig = -50.0f
staticprivate

Definition at line 92 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyVertexDeltaR = -1.0f
staticprivate

Definition at line 97 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyVertexEnergyRatio = -1.0f
staticprivate

Definition at line 96 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyVertexMass = -1.0f
staticprivate

Definition at line 95 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

float BoostedDoubleSVProducer::dummyZ_ratio = -3.0f
staticprivate

Definition at line 91 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::maxDecayLen_
private

Definition at line 86 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::maxDistToAxis_
private

Definition at line 85 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::maxSVDeltaRToJet_
private

Definition at line 84 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

const double BoostedDoubleSVProducer::R0_
private

Definition at line 82 of file BoostedDoubleSVProducer.cc.

Referenced by calcNsubjettiness().

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

Definition at line 79 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

reco::V0Filter BoostedDoubleSVProducer::trackPairV0Filter
private

Definition at line 87 of file BoostedDoubleSVProducer.cc.

Referenced by produce().

reco::TrackSelector BoostedDoubleSVProducer::trackSelector
private

Definition at line 88 of file BoostedDoubleSVProducer.cc.

Referenced by produce().