CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::PATLostTracks Class Reference
Inheritance diagram for pat::PATLostTracks:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATLostTracks (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~PATLostTracks () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  TrkStatus {
  TrkStatus::NOTUSED = 0, TrkStatus::PFCAND, TrkStatus::PFCANDNOTRKPROPS, TrkStatus::PFELECTRON,
  TrkStatus::PFPOSITRON, TrkStatus::VTX
}
 

Private Member Functions

void addPackedCandidate (std::vector< pat::PackedCandidate > &cands, const reco::TrackRef &trk, const reco::VertexRef &pvSlimmed, const reco::VertexRefProd &pvSlimmedColl, const TrkStatus &trkStatus, const pat::PackedCandidate::PVAssociationQuality &pvAssocQuality, edm::Handle< reco::MuonCollection > muons) const
 
std::pair< int, pat::PackedCandidate::PVAssociationQualityassociateTrkToVtx (const reco::VertexCollection &vertices, const reco::TrackRef &trk) const
 
bool passTrkCuts (const reco::Track &tr) const
 

Private Attributes

const bool allowMuonId_
 
const edm::EDGetTokenT< reco::PFCandidateCollectioncands_
 
const std::vector< int > covariancePackingSchemas_
 
const int covarianceVersion_
 
const bool fillLostInnerHits_
 
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionkshorts_
 
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionlambdas_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
 
const double maxDxyForNotReconstructedPrimary_
 
const double maxDxySigForNotReconstructedPrimary_
 
const double maxDzErrorForPrimaryAssignment_
 
const double maxDzForPrimaryAssignment_
 
const double maxDzSigForPrimaryAssignment_
 
const double minHits_
 
const double minPixelHits_
 
const double minPt_
 
const double minPtToStoreLowQualityProps_
 
const double minPtToStoreProps_
 
const edm::EDGetTokenT< reco::MuonCollectionmuons_
 
StringCutObjectSelector< reco::Track, false > passThroughCut_
 
const edm::EDGetTokenT< reco::VertexCollectionpv_
 
const edm::EDGetTokenT< reco::VertexCollectionpvOrigs_
 
std::vector< reco::TrackBase::TrackQualityqualsToAutoAccept_
 
const edm::EDGetTokenT< reco::TrackCollectiontracks_
 
const bool useLegacySetup_
 
const edm::EDGetTokenT< reco::VertexCollectionvertices_
 
const double xiMassCut_
 
const bool xiSelection_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file PATLostTracks.cc.

Member Enumeration Documentation

enum pat::PATLostTracks::TrkStatus
strongprivate
Enumerator
NOTUSED 
PFCAND 
PFCANDNOTRKPROPS 
PFELECTRON 
PFPOSITRON 
VTX 

Definition at line 34 of file PATLostTracks.cc.

34 { NOTUSED = 0, PFCAND, PFCANDNOTRKPROPS, PFELECTRON, PFPOSITRON, VTX };

Constructor & Destructor Documentation

pat::PATLostTracks::PATLostTracks ( const edm::ParameterSet iConfig)
explicit

Definition at line 78 of file PATLostTracks.cc.

References Exception, spr::find(), edm::ParameterSet::getParameter(), mps_check::msg, reco::TrackBase::qualityByName(), qualsToAutoAccept_, create_public_lumi_plots::transform, and reco::TrackBase::undefQuality.

79  : cands_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("inputCandidates"))),
81  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
82  tracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("inputTracks"))),
83  vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("secondaryVertices"))),
84  kshorts_(consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("kshorts"))),
85  lambdas_(consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("lambdas"))),
86  pv_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertices"))),
87  pvOrigs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("originalVertices"))),
88  minPt_(iConfig.getParameter<double>("minPt")),
89  minHits_(iConfig.getParameter<uint32_t>("minHits")),
90  minPixelHits_(iConfig.getParameter<uint32_t>("minPixelHits")),
91  minPtToStoreProps_(iConfig.getParameter<double>("minPtToStoreProps")),
92  minPtToStoreLowQualityProps_(iConfig.getParameter<double>("minPtToStoreLowQualityProps")),
93  covarianceVersion_(iConfig.getParameter<int>("covarianceVersion")),
94  covariancePackingSchemas_(iConfig.getParameter<std::vector<int>>("covariancePackingSchemas")),
95  muons_(consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muons"))),
96  passThroughCut_(iConfig.getParameter<std::string>("passThroughCut")),
97  allowMuonId_(iConfig.getParameter<bool>("allowMuonId")),
99  iConfig.getParameter<edm::ParameterSet>("pvAssignment").getParameter<double>("maxDzForPrimaryAssignment")),
101  iConfig.getParameter<edm::ParameterSet>("pvAssignment").getParameter<double>("maxDzSigForPrimaryAssignment")),
103  .getParameter<double>("maxDzErrorForPrimaryAssignment")),
105  .getParameter<double>("maxDxyForNotReconstructedPrimary")),
107  .getParameter<double>("maxDxySigForNotReconstructedPrimary")),
108  useLegacySetup_(iConfig.getParameter<bool>("useLegacySetup")),
109  fillLostInnerHits_(iConfig.getParameter<bool>("fillLostInnerHits")),
110  xiSelection_(iConfig.getParameter<bool>("xiSelection")),
111  xiMassCut_(iConfig.getParameter<double>("xiMassCut")) {
112  std::vector<std::string> trkQuals(iConfig.getParameter<std::vector<std::string>>("qualsToAutoAccept"));
114  trkQuals.begin(), trkQuals.end(), std::back_inserter(qualsToAutoAccept_), reco::TrackBase::qualityByName);
115 
117  qualsToAutoAccept_.end()) {
118  std::ostringstream msg;
119  msg << " PATLostTracks has a quality requirement which resolves to undefQuality. This usually means a typo and is "
120  "therefore treated a config error\nquality requirements:\n ";
121  for (const auto& trkQual : trkQuals)
122  msg << trkQual << " ";
123  throw cms::Exception("Configuration") << msg.str();
124  }
125 
126  produces<std::vector<reco::Track>>();
127  produces<std::vector<pat::PackedCandidate>>();
128  produces<std::vector<pat::PackedCandidate>>("eleTracks");
129  produces<edm::Association<pat::PackedCandidateCollection>>();
130 }
T getParameter(std::string const &) const
const double minPt_
const double minPtToStoreProps_
const double maxDzSigForPrimaryAssignment_
const double minPtToStoreLowQualityProps_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const double maxDxyForNotReconstructedPrimary_
const int covarianceVersion_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const double minHits_
const edm::EDGetTokenT< reco::PFCandidateCollection > cands_
const double maxDzErrorForPrimaryAssignment_
const edm::EDGetTokenT< reco::MuonCollection > muons_
const bool useLegacySetup_
const bool allowMuonId_
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > lambdas_
const double xiMassCut_
const double maxDzForPrimaryAssignment_
const double maxDxySigForNotReconstructedPrimary_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:134
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
const edm::EDGetTokenT< reco::TrackCollection > tracks_
const edm::EDGetTokenT< reco::VertexCollection > vertices_
const bool fillLostInnerHits_
const std::vector< int > covariancePackingSchemas_
const bool xiSelection_
tuple msg
Definition: mps_check.py:285
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > kshorts_
std::vector< reco::TrackBase::TrackQuality > qualsToAutoAccept_
StringCutObjectSelector< reco::Track, false > passThroughCut_
const double minPixelHits_
const edm::EDGetTokenT< reco::VertexCollection > pv_
const edm::EDGetTokenT< reco::VertexCollection > pvOrigs_
pat::PATLostTracks::~PATLostTracks ( )
override

Definition at line 132 of file PATLostTracks.cc.

132 {}

Member Function Documentation

void pat::PATLostTracks::addPackedCandidate ( std::vector< pat::PackedCandidate > &  cands,
const reco::TrackRef trk,
const reco::VertexRef pvSlimmed,
const reco::VertexRefProd pvSlimmedColl,
const TrkStatus trkStatus,
const pat::PackedCandidate::PVAssociationQuality pvAssocQuality,
edm::Handle< reco::MuonCollection muons 
) const
private

Definition at line 276 of file PATLostTracks.cc.

References funct::abs(), allowMuonId_, covariancePackingSchemas_, covarianceVersion_, fillLostInnerHits_, reco::TrackBase::highPurity, triggerObjects_cff::id, edm::Ref< C, T, F >::key(), electrons_cff::lostHits, ResonanceBuilder::mass, minPtToStoreLowQualityProps_, minPtToStoreProps_, reco::HitPattern::MISSING_INNER_HITS, pat::PackedCandidate::moreLostInnerHits, RPCpg::mu, pat::PackedCandidate::noLostInnerHits, pat::PackedCandidate::oneLostInnerHit, p4, PFELECTRON, PFPOSITRON, GeomDetEnumerators::PixelBarrel, useLegacySetup_, pat::PackedCandidate::validHitInFirstPixelBarrelLayer, and VTX.

Referenced by produce().

282  {
283  const float mass = 0.13957018;
284 
285  int id = 211 * trk->charge();
286  if (trkStatus == TrkStatus::PFELECTRON)
287  id = 11;
288  else if (trkStatus == TrkStatus::PFPOSITRON)
289  id = -11;
290 
291  // assign the proper pdgId for tracks that are reconstructed as a muon
292  if (allowMuonId_) {
293  for (auto& mu : *muons) {
294  if (reco::TrackRef(mu.innerTrack()) == trk) {
295  id = -13 * trk->charge();
296  break;
297  }
298  }
299  }
300 
301  reco::Candidate::PolarLorentzVector p4(trk->pt(), trk->eta(), trk->phi(), mass);
302  cands.emplace_back(
303  pat::PackedCandidate(p4, trk->vertex(), trk->pt(), trk->eta(), trk->phi(), id, pvSlimmedColl, pvSlimmed.key()));
304 
305  if (fillLostInnerHits_) {
307  int nlost = trk->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
308  if (nlost == 0) {
309  if (trk->hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1)) {
311  }
312  } else {
314  }
315  cands.back().setLostInnerHits(lostHits);
316  }
317 
318  cands.back().setTrackHighPurity(trk->quality(reco::TrackBase::highPurity));
319 
320  if (trk->pt() > minPtToStoreProps_ || trkStatus == TrkStatus::VTX) {
321  if (useLegacySetup_ || std::abs(id) == 11 || trkStatus == TrkStatus::VTX) {
322  cands.back().setTrackProperties(*trk, covariancePackingSchemas_[4], covarianceVersion_);
323  } else {
324  if (trk->hitPattern().numberOfValidPixelHits() > 0) {
325  cands.back().setTrackProperties(
326  *trk, covariancePackingSchemas_[0], covarianceVersion_); // high quality with pixels
327  } else {
328  cands.back().setTrackProperties(
329  *trk, covariancePackingSchemas_[1], covarianceVersion_); // high quality without pixels
330  }
331  }
332  } else if (!useLegacySetup_ && trk->pt() > minPtToStoreLowQualityProps_) {
333  if (trk->hitPattern().numberOfValidPixelHits() > 0) {
334  cands.back().setTrackProperties(
335  *trk, covariancePackingSchemas_[2], covarianceVersion_); // low quality with pixels
336  } else {
337  cands.back().setTrackProperties(
338  *trk, covariancePackingSchemas_[3], covarianceVersion_); // low quality without pixels
339  }
340  }
341  cands.back().setAssociationQuality(pvAssocQuality);
342 }
const double minPtToStoreProps_
const double minPtToStoreLowQualityProps_
key_type key() const
Accessor for product key.
Definition: Ref.h:263
const int covarianceVersion_
const bool useLegacySetup_
double p4[4]
Definition: TauolaWrapper.h:92
const bool allowMuonId_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
LostInnerHits
Enumerator specifying the.
const bool fillLostInnerHits_
const std::vector< int > covariancePackingSchemas_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:39
std::pair< int, pat::PackedCandidate::PVAssociationQuality > pat::PATLostTracks::associateTrkToVtx ( const reco::VertexCollection vertices,
const reco::TrackRef trk 
) const
private

Definition at line 344 of file PATLostTracks.cc.

References funct::abs(), pat::PackedCandidate::CompatibilityDz, DEFINE_FWK_MODULE, PVValHelper::dz, electrons_cff::dzErr, training_settings::idx, SiStripPI::max, maxDxyForNotReconstructedPrimary_, maxDxySigForNotReconstructedPrimary_, maxDzErrorForPrimaryAssignment_, maxDzForPrimaryAssignment_, histoParameters_cff::minDz, pat::PackedCandidate::NotReconstructedPrimary, pat::PackedCandidate::OtherDeltaZ, mathSSE::sqrt(), pat::PackedCandidate::UsedInFitLoose, pat::PackedCandidate::UsedInFitTight, useLegacySetup_, extraflags_cff::vtx, and w.

Referenced by produce().

345  {
346  //For legacy setup check only if the track is used in fit of the PV, i.e. vertices[0],
347  //and associate quality if weight > 0.5. Otherwise return invalid vertex index (-1)
348  //and default quality flag (NotReconstructedPrimary = 0)
349  if (useLegacySetup_) {
350  float w = vertices[0].trackWeight(trk);
351  if (w > 0.5) {
352  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(0, pat::PackedCandidate::UsedInFitTight);
353  } else if (w > 0.) {
354  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(0,
356  } else {
357  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(-1,
359  }
360  }
361 
362  //Inspired by CommonTools/RecoAlgos/interface/PrimaryVertexAssignment.h
363  //but without specific association for secondaries in jets and option to use timing
364 
365  int iVtxMaxWeight = -1;
366  int iVtxMinDzDist = -1;
367  size_t idx = 0;
368  float maxWeight = 0;
370  double minDzSig = std::numeric_limits<double>::max();
371  for (auto const& vtx : vertices) {
372  float w = vtx.trackWeight(trk);
373  double dz = std::abs(trk->dz(vtx.position()));
374  double dzSig = dz / trk->dzError();
375  if (w > maxWeight) {
376  maxWeight = w;
377  iVtxMaxWeight = idx;
378  }
379  if (dzSig < minDzSig) {
380  minDzSig = dzSig;
381  minDz = dz;
382  iVtxMinDzDist = idx;
383  }
384  idx++;
385  }
386  // vertex in which fit the track was used
387  if (iVtxMaxWeight >= 0) {
388  if (maxWeight > 0.5) {
389  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMaxWeight,
391  } else {
392  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMaxWeight,
394  }
395  }
396  // vertex "closest in Z" with tight cuts (targetting primary particles)
397  if (minDz < maxDzForPrimaryAssignment_) {
398  const double add_cov = vertices[iVtxMinDzDist].covariance(2, 2);
399  const double dzErr = sqrt(trk->dzError() * trk->dzError() + add_cov);
400  if (minDz / dzErr < maxDzSigForPrimaryAssignment_ && trk->dzError() < maxDzErrorForPrimaryAssignment_) {
401  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMinDzDist,
403  }
404  }
405  // if the track is not compatible with other PVs but is compatible with the BeamSpot, we may simply have not reco'ed the PV!
406  // we still point it to the closest in Z, but flag it as possible orphan-primary
407  if (!vertices.empty() && std::abs(trk->dxy(vertices[0].position())) < maxDxyForNotReconstructedPrimary_ &&
408  std::abs(trk->dxy(vertices[0].position()) / trk->dxyError()) < maxDxySigForNotReconstructedPrimary_)
409  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMinDzDist,
411  // for tracks not associated to any PV return the closest in dz
412  return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMinDzDist, pat::PackedCandidate::OtherDeltaZ);
413 }
const double w
Definition: UKUtility.cc:23
const double maxDxyForNotReconstructedPrimary_
const double maxDzErrorForPrimaryAssignment_
const bool useLegacySetup_
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const double maxDzForPrimaryAssignment_
const double maxDxySigForNotReconstructedPrimary_
bool pat::PATLostTracks::passTrkCuts ( const reco::Track tr) const
private

Definition at line 268 of file PATLostTracks.cc.

References reco::TrackBase::hitPattern(), minHits_, minPixelHits_, minPt_, reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), passThroughCut_, reco::TrackBase::pt(), and qualsToAutoAccept_.

Referenced by produce().

268  {
269  const bool passTrkHits = tr.pt() > minPt_ && tr.numberOfValidHits() >= minHits_ &&
271  const bool passTrkQual = passesQuality(tr, qualsToAutoAccept_);
272 
273  return passTrkHits || passTrkQual || passThroughCut_(tr);
274 }
const double minPt_
const double minHits_
double pt() const
track transverse momentum
Definition: TrackBase.h:660
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:901
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:485
std::vector< reco::TrackBase::TrackQuality > qualsToAutoAccept_
StringCutObjectSelector< reco::Track, false > passThroughCut_
int numberOfValidPixelHits() const
Definition: HitPattern.h:916
const double minPixelHits_
void pat::PATLostTracks::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
override

Definition at line 134 of file PATLostTracks.cc.

References addPackedCandidate(), associateTrkToVtx(), egammaForCoreTracking_cff::cands, cands_, reco::LeafCandidate::charge(), edm::Event::getByToken(), edm::HandleBase::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), crabWrapper::key, edm::Ref< C, T, F >::key(), lostTracks_cfi::kshorts, kshorts_, lostTracks_cfi::lambdas, lambdas_, map_, taus_updatedMVAIds_cff::mapping, eostools::move(), extraflags_cff::muons, muons_, NOTUSED, passTrkCuts(), reco::LeafCandidate::pdgId(), PFCAND, PFCANDNOTRKPROPS, PFELECTRON, PFPOSITRON, edm::Event::put(), MetAnalyzer::pv(), pv_, pvOrigs_, alignCSCRings::r, mathSSE::sqrt(), reco::PFCandidate::trackRef(), l1t::tracks, tracks_, electrons_cff::vertices, vertices_, VTX, xiMassCut_, and xiSelection_.

134  {
136  iEvent.getByToken(cands_, cands);
137 
139  iEvent.getByToken(map_, pf2pc);
140 
142  iEvent.getByToken(tracks_, tracks);
143 
145  iEvent.getByToken(vertices_, vertices);
146 
148  iEvent.getByToken(muons_, muons);
149 
151  iEvent.getByToken(kshorts_, kshorts);
153  iEvent.getByToken(lambdas_, lambdas);
154 
156  iEvent.getByToken(pv_, pvs);
157  reco::VertexRef pv(pvs.id());
158  reco::VertexRefProd pvRefProd(pvs);
160  iEvent.getByToken(pvOrigs_, pvOrigs);
161 
162  auto outPtrTrks = std::make_unique<std::vector<reco::Track>>();
163  auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
164  auto outPtrEleTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
165 
166  std::vector<TrkStatus> trkStatus(tracks->size(), TrkStatus::NOTUSED);
167  //Mark all tracks used in candidates
168  //check if packed candidates are storing the tracks by seeing if number of hits >0
169  //currently we dont use that information though
170  //electrons will never store their track (they store the GSF track)
171  for (unsigned int ic = 0, nc = cands->size(); ic < nc; ++ic) {
173  const reco::PFCandidate& cand = (*cands)[ic];
174  if (cand.charge() && cand.trackRef().isNonnull() && cand.trackRef().id() == tracks.id()) {
175  if (cand.pdgId() == 11)
176  trkStatus[cand.trackRef().key()] = TrkStatus::PFELECTRON;
177  else if (cand.pdgId() == -11)
178  trkStatus[cand.trackRef().key()] = TrkStatus::PFPOSITRON;
179  else if ((*pf2pc)[r]->numberOfHits() > 0)
180  trkStatus[cand.trackRef().key()] = TrkStatus::PFCAND;
181  else
182  trkStatus[cand.trackRef().key()] = TrkStatus::PFCANDNOTRKPROPS;
183  }
184  }
185 
186  //Mark all tracks used in secondary vertices
187  for (const auto& secVert : *vertices) {
188  for (auto trkIt = secVert.tracks_begin(); trkIt != secVert.tracks_end(); trkIt++) {
189  if (trkStatus[trkIt->key()] == TrkStatus::NOTUSED)
190  trkStatus[trkIt->key()] = TrkStatus::VTX;
191  }
192  }
193  for (const auto& v0 : *kshorts) {
194  for (size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
195  size_t key = (dynamic_cast<const reco::RecoChargedCandidate*>(v0.daughter(dIdx)))->track().key();
196  if (trkStatus[key] == TrkStatus::NOTUSED)
197  trkStatus[key] = TrkStatus::VTX;
198  }
199  }
200  for (const auto& v0 : *lambdas) {
201  double protonCharge = 0;
202  for (size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
203  size_t key = (dynamic_cast<const reco::RecoChargedCandidate*>(v0.daughter(dIdx)))->track().key();
204  if (trkStatus[key] == TrkStatus::NOTUSED)
205  trkStatus[key] = TrkStatus::VTX;
206  protonCharge += v0.daughter(dIdx)->charge() * v0.daughter(dIdx)->momentum().mag2();
207  }
208  if (xiSelection_) {
209  // selecting potential Xi- -> Lambda pi candidates
210  math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass() * v0.mass()));
211 
212  for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
213  reco::TrackRef trk(tracks, trkIndx);
214  if ((*trk).charge() * protonCharge < 0 || trkStatus[trkIndx] != TrkStatus::NOTUSED)
215  continue;
216 
218  trk->px(), trk->py(), trk->pz(), sqrt(trk->momentum().mag2() + 0.01947995518)); // pion mass ^2
219  if ((p4Lambda + p4pi).M() < xiMassCut_)
220  trkStatus[trkIndx] = TrkStatus::VTX; // selecting potential Xi- candidates
221  }
222  }
223  }
224  std::vector<int> mapping(tracks->size(), -1);
225  int lostTrkIndx = 0;
226  for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
227  reco::TrackRef trk(tracks, trkIndx);
228  if (trkStatus[trkIndx] == TrkStatus::VTX || (trkStatus[trkIndx] == TrkStatus::NOTUSED && passTrkCuts(*trk))) {
229  outPtrTrks->emplace_back(*trk);
230  //association to PV
231  std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso = associateTrkToVtx(*pvOrigs, trk);
232  const reco::VertexRef& pvOrigRef = reco::VertexRef(pvOrigs, pvAsso.first);
233  if (pvOrigRef.isNonnull()) {
234  pv = reco::VertexRef(pvs, pvOrigRef.key()); // WARNING: assume the PV slimmer is keeping same order
235  } else if (!pvs->empty()) {
236  pv = reco::VertexRef(pvs, 0);
237  }
238  addPackedCandidate(*outPtrTrksAsCands, trk, pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
239 
240  //for creating the reco::Track -> pat::PackedCandidate map
241  //not done for the lostTrack:eleTracks collection
242  mapping[trkIndx] = lostTrkIndx;
243  lostTrkIndx++;
244  } else if ((trkStatus[trkIndx] == TrkStatus::PFELECTRON || trkStatus[trkIndx] == TrkStatus::PFPOSITRON) &&
245  passTrkCuts(*trk)) {
246  //association to PV
247  std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso = associateTrkToVtx(*pvOrigs, trk);
248  const reco::VertexRef& pvOrigRef = reco::VertexRef(pvOrigs, pvAsso.first);
249  if (pvOrigRef.isNonnull()) {
250  pv = reco::VertexRef(pvs, pvOrigRef.key()); // WARNING: assume the PV slimmer is keeping same order
251  } else if (!pvs->empty()) {
252  pv = reco::VertexRef(pvs, 0);
253  }
254  addPackedCandidate(*outPtrEleTrksAsCands, trk, pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
255  }
256  }
257 
258  iEvent.put(std::move(outPtrTrks));
259  iEvent.put(std::move(outPtrEleTrksAsCands), "eleTracks");
260  edm::OrphanHandle<pat::PackedCandidateCollection> oh = iEvent.put(std::move(outPtrTrksAsCands));
261  auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
263  tk2pcFiller.insert(tracks, mapping.begin(), mapping.end());
264  tk2pcFiller.fill();
265  iEvent.put(std::move(tk2pc));
266 }
int pdgId() const final
PDG identifier.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int charge() const final
electric charge
Definition: LeafCandidate.h:91
key_type key() const
Accessor for product key.
Definition: Ref.h:263
ProductID id() const
Accessor for product ID.
Definition: Ref.h:257
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const edm::EDGetTokenT< reco::PFCandidateCollection > cands_
const edm::EDGetTokenT< reco::MuonCollection > muons_
T sqrt(T t)
Definition: SSEVec.h:18
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > lambdas_
def pv(vc)
Definition: MetAnalyzer.py:7
const double xiMassCut_
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
std::pair< int, pat::PackedCandidate::PVAssociationQuality > associateTrkToVtx(const reco::VertexCollection &vertices, const reco::TrackRef &trk) const
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
void addPackedCandidate(std::vector< pat::PackedCandidate > &cands, const reco::TrackRef &trk, const reco::VertexRef &pvSlimmed, const reco::VertexRefProd &pvSlimmedColl, const TrkStatus &trkStatus, const pat::PackedCandidate::PVAssociationQuality &pvAssocQuality, edm::Handle< reco::MuonCollection > muons) const
bool passTrkCuts(const reco::Track &tr) const
const edm::EDGetTokenT< reco::TrackCollection > tracks_
const edm::EDGetTokenT< reco::VertexCollection > vertices_
const bool xiSelection_
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > kshorts_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
const edm::EDGetTokenT< reco::VertexCollection > pv_
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::VertexCollection > pvOrigs_

Member Data Documentation

const bool pat::PATLostTracks::allowMuonId_
private

Definition at line 65 of file PATLostTracks.cc.

Referenced by addPackedCandidate().

const edm::EDGetTokenT<reco::PFCandidateCollection> pat::PATLostTracks::cands_
private

Definition at line 47 of file PATLostTracks.cc.

Referenced by produce().

const std::vector<int> pat::PATLostTracks::covariancePackingSchemas_
private

Definition at line 61 of file PATLostTracks.cc.

Referenced by addPackedCandidate().

const int pat::PATLostTracks::covarianceVersion_
private

Definition at line 60 of file PATLostTracks.cc.

Referenced by addPackedCandidate().

const bool pat::PATLostTracks::fillLostInnerHits_
private

Definition at line 72 of file PATLostTracks.cc.

Referenced by addPackedCandidate().

const edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> pat::PATLostTracks::kshorts_
private

Definition at line 51 of file PATLostTracks.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> pat::PATLostTracks::lambdas_
private

Definition at line 52 of file PATLostTracks.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATLostTracks::map_
private

Definition at line 48 of file PATLostTracks.cc.

Referenced by produce().

const double pat::PATLostTracks::maxDxyForNotReconstructedPrimary_
private

Definition at line 69 of file PATLostTracks.cc.

Referenced by associateTrkToVtx().

const double pat::PATLostTracks::maxDxySigForNotReconstructedPrimary_
private

Definition at line 70 of file PATLostTracks.cc.

Referenced by associateTrkToVtx().

const double pat::PATLostTracks::maxDzErrorForPrimaryAssignment_
private

Definition at line 68 of file PATLostTracks.cc.

Referenced by associateTrkToVtx().

const double pat::PATLostTracks::maxDzForPrimaryAssignment_
private

Definition at line 66 of file PATLostTracks.cc.

Referenced by associateTrkToVtx().

const double pat::PATLostTracks::maxDzSigForPrimaryAssignment_
private

Definition at line 67 of file PATLostTracks.cc.

const double pat::PATLostTracks::minHits_
private

Definition at line 56 of file PATLostTracks.cc.

Referenced by passTrkCuts().

const double pat::PATLostTracks::minPixelHits_
private

Definition at line 57 of file PATLostTracks.cc.

Referenced by passTrkCuts().

const double pat::PATLostTracks::minPt_
private

Definition at line 55 of file PATLostTracks.cc.

Referenced by passTrkCuts().

const double pat::PATLostTracks::minPtToStoreLowQualityProps_
private

Definition at line 59 of file PATLostTracks.cc.

Referenced by addPackedCandidate().

const double pat::PATLostTracks::minPtToStoreProps_
private

Definition at line 58 of file PATLostTracks.cc.

Referenced by addPackedCandidate().

const edm::EDGetTokenT<reco::MuonCollection> pat::PATLostTracks::muons_
private

Definition at line 63 of file PATLostTracks.cc.

Referenced by produce().

StringCutObjectSelector<reco::Track, false> pat::PATLostTracks::passThroughCut_
private

Definition at line 64 of file PATLostTracks.cc.

Referenced by passTrkCuts().

const edm::EDGetTokenT<reco::VertexCollection> pat::PATLostTracks::pv_
private

Definition at line 53 of file PATLostTracks.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCollection> pat::PATLostTracks::pvOrigs_
private

Definition at line 54 of file PATLostTracks.cc.

Referenced by produce().

std::vector<reco::TrackBase::TrackQuality> pat::PATLostTracks::qualsToAutoAccept_
private

Definition at line 62 of file PATLostTracks.cc.

Referenced by passTrkCuts(), and PATLostTracks().

const edm::EDGetTokenT<reco::TrackCollection> pat::PATLostTracks::tracks_
private

Definition at line 49 of file PATLostTracks.cc.

Referenced by produce().

const bool pat::PATLostTracks::useLegacySetup_
private

Definition at line 71 of file PATLostTracks.cc.

Referenced by addPackedCandidate(), and associateTrkToVtx().

const edm::EDGetTokenT<reco::VertexCollection> pat::PATLostTracks::vertices_
private

Definition at line 50 of file PATLostTracks.cc.

Referenced by produce().

const double pat::PATLostTracks::xiMassCut_
private

Definition at line 74 of file PATLostTracks.cc.

Referenced by produce().

const bool pat::PATLostTracks::xiSelection_
private

Definition at line 73 of file PATLostTracks.cc.

Referenced by produce().