CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::PVAssociationQuality
associateTrkToVtx (const reco::VertexCollection &vertices, const reco::TrackRef &trk) const
 
bool passTrkCuts (const reco::Track &tr) const
 

Private Attributes

const edm::EDGetTokenT
< reco::PFCandidateCollection
cands_
 
const std::vector< int > covariancePackingSchemas_
 
const int covarianceVersion_
 
const edm::EDGetTokenT
< reco::VertexCompositeCandidateCollection
kshorts_
 
const edm::EDGetTokenT
< reco::VertexCompositeCandidateCollection
lambdas_
 
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::MuonCollection
muons_
 
StringCutObjectSelector
< reco::Track, false > 
passThroughCut_
 
const edm::EDGetTokenT
< reco::VertexCollection
pv_
 
const edm::EDGetTokenT
< reco::VertexCollection
pvOrigs_
 
std::vector
< reco::TrackBase::TrackQuality
qualsToAutoAccept_
 
const edm::EDGetTokenT
< reco::TrackCollection
tracks_
 
const bool useLegacySetup_
 
const edm::EDGetTokenT
< reco::VertexCollection
vertices_
 
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::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 76 of file PATLostTracks.cc.

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

77  : cands_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("inputCandidates"))),
79  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
80  tracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("inputTracks"))),
81  vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("secondaryVertices"))),
82  kshorts_(consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("kshorts"))),
83  lambdas_(consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("lambdas"))),
84  pv_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertices"))),
85  pvOrigs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("originalVertices"))),
86  minPt_(iConfig.getParameter<double>("minPt")),
87  minHits_(iConfig.getParameter<uint32_t>("minHits")),
88  minPixelHits_(iConfig.getParameter<uint32_t>("minPixelHits")),
89  minPtToStoreProps_(iConfig.getParameter<double>("minPtToStoreProps")),
90  minPtToStoreLowQualityProps_(iConfig.getParameter<double>("minPtToStoreLowQualityProps")),
91  covarianceVersion_(iConfig.getParameter<int>("covarianceVersion")),
92  covariancePackingSchemas_(iConfig.getParameter<std::vector<int>>("covariancePackingSchemas")),
93  muons_(consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muons"))),
94  passThroughCut_(iConfig.getParameter<std::string>("passThroughCut")),
96  iConfig.getParameter<edm::ParameterSet>("pvAssignment").getParameter<double>("maxDzForPrimaryAssignment")),
98  iConfig.getParameter<edm::ParameterSet>("pvAssignment").getParameter<double>("maxDzSigForPrimaryAssignment")),
100  .getParameter<double>("maxDzErrorForPrimaryAssignment")),
102  .getParameter<double>("maxDxyForNotReconstructedPrimary")),
104  .getParameter<double>("maxDxySigForNotReconstructedPrimary")),
105  useLegacySetup_(iConfig.getParameter<bool>("useLegacySetup")),
106  xiSelection_(iConfig.getParameter<bool>("xiSelection")),
107  xiMassCut_(iConfig.getParameter<double>("xiMassCut")) {
108  std::vector<std::string> trkQuals(iConfig.getParameter<std::vector<std::string>>("qualsToAutoAccept"));
110  trkQuals.begin(), trkQuals.end(), std::back_inserter(qualsToAutoAccept_), reco::TrackBase::qualityByName);
111 
113  qualsToAutoAccept_.end()) {
114  std::ostringstream msg;
115  msg << " PATLostTracks has a quality requirement which resolves to undefQuality. This usually means a typo and is "
116  "therefore treated a config error\nquality requirements:\n ";
117  for (const auto& trkQual : trkQuals)
118  msg << trkQual << " ";
119  throw cms::Exception("Configuration") << msg.str();
120  }
121 
122  produces<std::vector<reco::Track>>();
123  produces<std::vector<pat::PackedCandidate>>();
124  produces<std::vector<pat::PackedCandidate>>("eleTracks");
125  produces<edm::Association<pat::PackedCandidateCollection>>();
126 }
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:19
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 edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > lambdas_
const double xiMassCut_
const double maxDzForPrimaryAssignment_
const double maxDxySigForNotReconstructedPrimary_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
const edm::EDGetTokenT< reco::TrackCollection > tracks_
const edm::EDGetTokenT< reco::VertexCollection > vertices_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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_
unsigned transform(const HcalDetId &id, unsigned transformCode)
pat::PATLostTracks::~PATLostTracks ( )
override

Definition at line 128 of file PATLostTracks.cc.

128 {}

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 272 of file PATLostTracks.cc.

References funct::abs(), reco::TrackBase::highPurity, gpuClustering::id, edm::Ref< C, T, F >::key(), ResonanceBuilder::mass, reco::HitPattern::MISSING_INNER_HITS, pat::PackedCandidate::moreLostInnerHits, RPCpg::mu, pat::PackedCandidate::noLostInnerHits, pat::PackedCandidate::oneLostInnerHit, GeomDetEnumerators::PixelBarrel, and pat::PackedCandidate::validHitInFirstPixelBarrelLayer.

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

Definition at line 336 of file PATLostTracks.cc.

References funct::abs(), pat::PackedCandidate::CompatibilityDz, PVValHelper::dz, SiStripPI::max, pat::PackedCandidate::NotReconstructedPrimary, pat::PackedCandidate::OtherDeltaZ, mathSSE::sqrt(), pat::PackedCandidate::UsedInFitLoose, pat::PackedCandidate::UsedInFitTight, and w.

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

References reco::TrackBase::hitPattern(), reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), and reco::TrackBase::pt().

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

Implements edm::global::EDProducerBase.

Definition at line 130 of file PATLostTracks.cc.

References HLT_FULL_cff::cands, reco::LeafCandidate::charge(), edm::Event::getByToken(), edm::HandleBase::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::key(), submitPVResolutionJobs::key, eostools::move(), patZpeak::muons, reco::LeafCandidate::pdgId(), edm::Event::put(), MetAnalyzer::pv(), alignCSCRings::r, mathSSE::sqrt(), reco::PFCandidate::trackRef(), tracks, and beam_dqm_sourceclient-live_cfg::vertices.

130  {
132  iEvent.getByToken(cands_, cands);
133 
135  iEvent.getByToken(map_, pf2pc);
136 
138  iEvent.getByToken(tracks_, tracks);
139 
141  iEvent.getByToken(vertices_, vertices);
142 
144  iEvent.getByToken(muons_, muons);
145 
147  iEvent.getByToken(kshorts_, kshorts);
149  iEvent.getByToken(lambdas_, lambdas);
150 
152  iEvent.getByToken(pv_, pvs);
153  reco::VertexRef pv(pvs.id());
154  reco::VertexRefProd pvRefProd(pvs);
156  iEvent.getByToken(pvOrigs_, pvOrigs);
157 
158  auto outPtrTrks = std::make_unique<std::vector<reco::Track>>();
159  auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
160  auto outPtrEleTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
161 
162  std::vector<TrkStatus> trkStatus(tracks->size(), TrkStatus::NOTUSED);
163  //Mark all tracks used in candidates
164  //check if packed candidates are storing the tracks by seeing if number of hits >0
165  //currently we dont use that information though
166  //electrons will never store their track (they store the GSF track)
167  for (unsigned int ic = 0, nc = cands->size(); ic < nc; ++ic) {
169  const reco::PFCandidate& cand = (*cands)[ic];
170  if (cand.charge() && cand.trackRef().isNonnull() && cand.trackRef().id() == tracks.id()) {
171  if (cand.pdgId() == 11)
172  trkStatus[cand.trackRef().key()] = TrkStatus::PFELECTRON;
173  else if (cand.pdgId() == -11)
174  trkStatus[cand.trackRef().key()] = TrkStatus::PFPOSITRON;
175  else if ((*pf2pc)[r]->numberOfHits() > 0)
176  trkStatus[cand.trackRef().key()] = TrkStatus::PFCAND;
177  else
178  trkStatus[cand.trackRef().key()] = TrkStatus::PFCANDNOTRKPROPS;
179  }
180  }
181 
182  //Mark all tracks used in secondary vertices
183  for (const auto& secVert : *vertices) {
184  for (auto trkIt = secVert.tracks_begin(); trkIt != secVert.tracks_end(); trkIt++) {
185  if (trkStatus[trkIt->key()] == TrkStatus::NOTUSED)
186  trkStatus[trkIt->key()] = TrkStatus::VTX;
187  }
188  }
189  for (const auto& v0 : *kshorts) {
190  for (size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
191  size_t key = (dynamic_cast<const reco::RecoChargedCandidate*>(v0.daughter(dIdx)))->track().key();
192  if (trkStatus[key] == TrkStatus::NOTUSED)
193  trkStatus[key] = TrkStatus::VTX;
194  }
195  }
196  for (const auto& v0 : *lambdas) {
197  double protonCharge = 0;
198  for (size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
199  size_t key = (dynamic_cast<const reco::RecoChargedCandidate*>(v0.daughter(dIdx)))->track().key();
200  if (trkStatus[key] == TrkStatus::NOTUSED)
201  trkStatus[key] = TrkStatus::VTX;
202  protonCharge += v0.daughter(dIdx)->charge() * v0.daughter(dIdx)->momentum().mag2();
203  }
204  if (xiSelection_) {
205  // selecting potential Xi- -> Lambda pi candidates
206  math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass() * v0.mass()));
207 
208  for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
209  reco::TrackRef trk(tracks, trkIndx);
210  if ((*trk).charge() * protonCharge < 0 || trkStatus[trkIndx] != TrkStatus::NOTUSED)
211  continue;
212 
214  trk->px(), trk->py(), trk->pz(), sqrt(trk->momentum().mag2() + 0.01947995518)); // pion mass ^2
215  if ((p4Lambda + p4pi).M() < xiMassCut_)
216  trkStatus[trkIndx] = TrkStatus::VTX; // selecting potential Xi- candidates
217  }
218  }
219  }
220  std::vector<int> mapping(tracks->size(), -1);
221  int lostTrkIndx = 0;
222  for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
223  reco::TrackRef trk(tracks, trkIndx);
224  if (trkStatus[trkIndx] == TrkStatus::VTX || (trkStatus[trkIndx] == TrkStatus::NOTUSED && passTrkCuts(*trk))) {
225  outPtrTrks->emplace_back(*trk);
226  //association to PV
227  std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso = associateTrkToVtx(*pvOrigs, trk);
228  const reco::VertexRef& pvOrigRef = reco::VertexRef(pvOrigs, pvAsso.first);
229  if (pvOrigRef.isNonnull()) {
230  pv = reco::VertexRef(pvs, pvOrigRef.key()); // WARNING: assume the PV slimmer is keeping same order
231  } else if (!pvs->empty()) {
232  pv = reco::VertexRef(pvs, 0);
233  }
234  addPackedCandidate(*outPtrTrksAsCands, trk, pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
235 
236  //for creating the reco::Track -> pat::PackedCandidate map
237  //not done for the lostTrack:eleTracks collection
238  mapping[trkIndx] = lostTrkIndx;
239  lostTrkIndx++;
240  } else if ((trkStatus[trkIndx] == TrkStatus::PFELECTRON || trkStatus[trkIndx] == TrkStatus::PFPOSITRON) &&
241  passTrkCuts(*trk)) {
242  //association to PV
243  std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso = associateTrkToVtx(*pvOrigs, trk);
244  const reco::VertexRef& pvOrigRef = reco::VertexRef(pvOrigs, pvAsso.first);
245  if (pvOrigRef.isNonnull()) {
246  pv = reco::VertexRef(pvs, pvOrigRef.key()); // WARNING: assume the PV slimmer is keeping same order
247  } else if (!pvs->empty()) {
248  pv = reco::VertexRef(pvs, 0);
249  }
250  addPackedCandidate(*outPtrEleTrksAsCands, trk, pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
251  }
252  }
253 
254  iEvent.put(std::move(outPtrTrks));
255  iEvent.put(std::move(outPtrEleTrksAsCands), "eleTracks");
256  edm::OrphanHandle<pat::PackedCandidateCollection> oh = iEvent.put(std::move(outPtrTrksAsCands));
257  auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
259  tk2pcFiller.insert(tracks, mapping.begin(), mapping.end());
260  tk2pcFiller.fill();
261  iEvent.put(std::move(tk2pc));
262 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
ProductID id() const
Definition: HandleBase.cc:29
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
auto const & tracks
cannot be loose
key_type key() const
Accessor for product key.
Definition: Ref.h:250
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:430
int pdgId() const final
PDG identifier.
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:19
def move
Definition: eostools.py:511
tuple key
prepare the HTCondor submission files and eventually submit them
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > lambdas_
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:41
tuple muons
Definition: patZpeak.py:39
const edm::EDGetTokenT< reco::VertexCollection > pv_
int charge() const final
electric charge
const edm::EDGetTokenT< reco::VertexCollection > pvOrigs_

Member Data Documentation

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

Definition at line 47 of file PATLostTracks.cc.

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

Definition at line 61 of file PATLostTracks.cc.

const int pat::PATLostTracks::covarianceVersion_
private

Definition at line 60 of file PATLostTracks.cc.

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

Definition at line 51 of file PATLostTracks.cc.

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

Definition at line 52 of file PATLostTracks.cc.

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

Definition at line 48 of file PATLostTracks.cc.

const double pat::PATLostTracks::maxDxyForNotReconstructedPrimary_
private

Definition at line 68 of file PATLostTracks.cc.

const double pat::PATLostTracks::maxDxySigForNotReconstructedPrimary_
private

Definition at line 69 of file PATLostTracks.cc.

const double pat::PATLostTracks::maxDzErrorForPrimaryAssignment_
private

Definition at line 67 of file PATLostTracks.cc.

const double pat::PATLostTracks::maxDzForPrimaryAssignment_
private

Definition at line 65 of file PATLostTracks.cc.

const double pat::PATLostTracks::maxDzSigForPrimaryAssignment_
private

Definition at line 66 of file PATLostTracks.cc.

const double pat::PATLostTracks::minHits_
private

Definition at line 56 of file PATLostTracks.cc.

const double pat::PATLostTracks::minPixelHits_
private

Definition at line 57 of file PATLostTracks.cc.

const double pat::PATLostTracks::minPt_
private

Definition at line 55 of file PATLostTracks.cc.

const double pat::PATLostTracks::minPtToStoreLowQualityProps_
private

Definition at line 59 of file PATLostTracks.cc.

const double pat::PATLostTracks::minPtToStoreProps_
private

Definition at line 58 of file PATLostTracks.cc.

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

Definition at line 63 of file PATLostTracks.cc.

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

Definition at line 64 of file PATLostTracks.cc.

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

Definition at line 53 of file PATLostTracks.cc.

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

Definition at line 54 of file PATLostTracks.cc.

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

Definition at line 62 of file PATLostTracks.cc.

Referenced by PATLostTracks().

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

Definition at line 49 of file PATLostTracks.cc.

const bool pat::PATLostTracks::useLegacySetup_
private

Definition at line 70 of file PATLostTracks.cc.

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

Definition at line 50 of file PATLostTracks.cc.

const double pat::PATLostTracks::xiMassCut_
private

Definition at line 72 of file PATLostTracks.cc.

const bool pat::PATLostTracks::xiSelection_
private

Definition at line 71 of file PATLostTracks.cc.