CMS 3D CMS Logo

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

Public Member Functions

void addPackedCandidate (std::vector< pat::PackedCandidate > &cands, const reco::Track trk, const reco::VertexRef &pvSlimmed, const reco::VertexRefProd &pvSlimmedColl, bool passPixelTrackSel) const
 
 PATTracksToPackedCandidates (const edm::ParameterSet &)
 
- 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const int covarianceSchema_
 
const int covarianceVersion_
 
const double dxySigCut_
 
const double dxySigHP_
 
const double dzSigCut_
 
const double dzSigHP_
 
const double ptMax_
 
const double ptMin_
 
const bool resetHP_
 
const edm::EDGetTokenT< reco::BeamSpotsrcOfflineBeamSpot_
 
const edm::EDGetTokenT< reco::VertexCollectionsrcPrimaryVertices_
 
const edm::EDGetTokenT< reco::TrackCollectionsrcTracks_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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 32 of file PATTracksToPackedCandidates.cc.

Constructor & Destructor Documentation

◆ PATTracksToPackedCandidates()

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

Definition at line 73 of file PATTracksToPackedCandidates.cc.

74  : srcTracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("srcTracks"))),
75  srcPrimaryVertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("srcPrimaryVertices"))),
76  srcOfflineBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("srcOfflineBeamSpot"))),
77  dzSigCut_(iConfig.getParameter<double>("dzSigCut")),
78  dxySigCut_(iConfig.getParameter<double>("dxySigCut")),
79  dzSigHP_(iConfig.getParameter<double>("dzSigHP")),
80  dxySigHP_(iConfig.getParameter<double>("dxySigHP")),
81  ptMax_(iConfig.getParameter<double>("ptMax")),
82  ptMin_(iConfig.getParameter<double>("ptMin")),
83  resetHP_(iConfig.getParameter<bool>("resetHP")),
84  covarianceVersion_(iConfig.getParameter<int>("covarianceVersion")),
85  covarianceSchema_(iConfig.getParameter<int>("covarianceSchema")) {
86  produces<std::vector<pat::PackedCandidate>>();
87  produces<edm::Association<pat::PackedCandidateCollection>>();
88 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< reco::VertexCollection > srcPrimaryVertices_
const edm::EDGetTokenT< reco::TrackCollection > srcTracks_
const edm::EDGetTokenT< reco::BeamSpot > srcOfflineBeamSpot_

Member Function Documentation

◆ addPackedCandidate()

void PATTracksToPackedCandidates::addPackedCandidate ( std::vector< pat::PackedCandidate > &  cands,
const reco::Track  trk,
const reco::VertexRef pvSlimmed,
const reco::VertexRefProd pvSlimmedColl,
bool  passPixelTrackSel 
) const

Definition at line 159 of file PATTracksToPackedCandidates.cc.

References HLT_2024v14_cff::cands, reco::TrackBase::charge(), covarianceSchema_, covarianceVersion_, reco::TrackBase::eta(), reco::TrackBase::highPurity, l1ctLayer2EG_cff::id, edm::Ref< C, T, F >::key(), EgHLTOffHistBins_cfi::mass, reco::TrackBase::phi(), reco::TrackBase::pt(), reco::TrackBase::quality(), resetHP_, and reco::TrackBase::vertex().

Referenced by produce().

163  {
164  const float mass = 0.13957018;
165 
166  int id = 211 * trk.charge();
167 
168  reco::Candidate::PolarLorentzVector p4(trk.pt(), trk.eta(), trk.phi(), mass);
169  cands.emplace_back(p4, trk.vertex(), trk.pt(), trk.eta(), trk.phi(), id, pvSlimmedColl, pvSlimmed.key());
170 
171  if (resetHP_) {
172  if (passPixelTrackSel)
173  cands.back().setTrackHighPurity(true);
174  else
175  cands.back().setTrackHighPurity(false);
176  } else {
178  cands.back().setTrackHighPurity(true);
179  else
180  cands.back().setTrackHighPurity(false);
181  }
182 
183  cands.back().setTrackProperties(trk, covarianceSchema_, covarianceVersion_);
184 }
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:552
key_type key() const
Accessor for product key.
Definition: Ref.h:250
double pt() const
track transverse momentum
Definition: TrackBase.h:637
int charge() const
track electric charge
Definition: TrackBase.h:596
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:676
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

◆ fillDescriptions()

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

Definition at line 187 of file PATTracksToPackedCandidates.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), and submitPVResolutionJobs::desc.

187  {
188  //The following says we do not know what parameters are allowed so do no validation
189  // Please change this to state exactly what you do use, even if it is no parameters
191  desc.add<edm::InputTag>("srcTracks", {"hiConformalPixelTracks"});
192  desc.add<edm::InputTag>("srcPrimaryVertices", {"offlineSlimmedPrimaryVertices"});
193  desc.add<edm::InputTag>("srcOfflineBeamSpot", {"offlineBeamSpot"})
194  ->setComment("use BeamSpot if empty vtx collection");
195  desc.add<double>("dzSigCut", 10.0);
196  desc.add<double>("dxySigCut", 25.0);
197  desc.add<double>("dzSigHP", 7.0)->setComment("to set HighPurity flag for pixel tracks");
198  desc.add<double>("dxySigHP", 20.0)->setComment("to set HighPurity flag for pixel tracks");
199  desc.add<double>("ptMax", 1.0)->setComment("max pT for pixel tracks - above this will use general tracks");
200  desc.add<double>("ptMin", 0.3)->setComment("min pT for pixel tracks");
201  desc.add<bool>("resetHP", true)
202  ->setComment("pixel tracks do not have HP flag set. Use False if does not want to reset HP flag");
203  desc.add<int>("covarianceVersion", 0)->setComment("so far: 0 is Phase0, 1 is Phase1");
204  desc.add<int>("covarianceSchema", 520)->setComment("use less accurate schema - reduce size of collection");
205  descriptions.addWithDefaultLabel(desc);
206 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void PATTracksToPackedCandidates::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 95 of file PATTracksToPackedCandidates.cc.

References funct::abs(), addPackedCandidate(), cms::cuda::bs, dxySigCut_, dxySigHP_, dzSigCut_, dzSigHP_, Matriplex::hypot(), iEvent, HPSPFTaus_cff::mapping, eostools::move(), ptMax_, ptMin_, MetAnalyzer::pv(), FSQDQM_cfi::pvs, srcOfflineBeamSpot_, srcPrimaryVertices_, srcTracks_, DiMuonV_cfg::tracks, and L1BJetProducer_cff::vtx.

95  {
96  using namespace edm;
97  using namespace std;
98 
99  //track collection
100  auto tracks = iEvent.getHandle(srcTracks_);
101 
102  auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
103 
104  //vtx collection
105  auto pvs = iEvent.getHandle(srcPrimaryVertices_);
106  reco::VertexRef pv(pvs.id());
107  reco::VertexRefProd pvRefProd(pvs);
108 
109  //best vertex
110  double bestvzError;
111  math::XYZPoint bestvtx;
112  math::Error<3>::type vtx_cov;
113  if (!pvs->empty()) {
114  pv = reco::VertexRef(pvs, 0);
115  const reco::Vertex& vtx = (*pvs)[0];
116  bestvzError = vtx.zError();
117  bestvtx = vtx.position();
118  vtx_cov = vtx.covariance();
119  } else {
120  const auto& bs = iEvent.get(srcOfflineBeamSpot_);
121  bestvzError = bs.z0Error();
122  bestvtx = bs.position();
123  vtx_cov = bs.covariance3D();
124  }
125 
126  std::vector<int> mapping(tracks->size(), -1);
127  int savedCandIndx = 0;
128  int trkIndx = -1;
129  for (auto const& trk : *tracks) {
130  trkIndx++;
131  double dzvtx = std::abs(trk.dz(bestvtx));
132  double dxyvtx = std::abs(trk.dxy(bestvtx));
133  double dzerror = std::hypot(trk.dzError(), bestvzError);
134  double dxyerror = trk.dxyError(bestvtx, vtx_cov);
135 
136  if (dzvtx >= dzSigCut_ * dzerror)
137  continue;
138  if (dxyvtx >= dxySigCut_ * dxyerror)
139  continue;
140  if (trk.pt() >= ptMax_ || trk.pt() <= ptMin_)
141  continue;
142 
143  bool passSelection = (dzvtx < dzSigHP_ * dzerror && dxyvtx < dxySigHP_ * dxyerror);
144 
145  addPackedCandidate(*outPtrTrksAsCands, trk, pv, pvRefProd, passSelection);
146 
147  //for creating the reco::Track -> pat::PackedCandidate map
148  mapping[trkIndx] = savedCandIndx;
149  savedCandIndx++;
150  }
152  auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
154  tk2pcFiller.insert(tracks, mapping.begin(), mapping.end());
155  tk2pcFiller.fill();
156  iEvent.put(std::move(tk2pc));
157 }
void addPackedCandidate(std::vector< pat::PackedCandidate > &cands, const reco::Track trk, const reco::VertexRef &pvSlimmed, const reco::VertexRefProd &pvSlimmedColl, bool passPixelTrackSel) const
const edm::EDGetTokenT< reco::VertexCollection > srcPrimaryVertices_
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
Definition: Matriplex.h:436
const edm::EDGetTokenT< reco::TrackCollection > srcTracks_
ErrorD< N >::type type
Definition: Error.h:32
int iEvent
Definition: GenABIO.cc:224
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
HLT enums.
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::BeamSpot > srcOfflineBeamSpot_

Member Data Documentation

◆ covarianceSchema_

const int PATTracksToPackedCandidates::covarianceSchema_
private

Definition at line 59 of file PATTracksToPackedCandidates.cc.

Referenced by addPackedCandidate().

◆ covarianceVersion_

const int PATTracksToPackedCandidates::covarianceVersion_
private

Definition at line 58 of file PATTracksToPackedCandidates.cc.

Referenced by addPackedCandidate().

◆ dxySigCut_

const double PATTracksToPackedCandidates::dxySigCut_
private

Definition at line 52 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ dxySigHP_

const double PATTracksToPackedCandidates::dxySigHP_
private

Definition at line 54 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ dzSigCut_

const double PATTracksToPackedCandidates::dzSigCut_
private

Definition at line 51 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ dzSigHP_

const double PATTracksToPackedCandidates::dzSigHP_
private

Definition at line 53 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ ptMax_

const double PATTracksToPackedCandidates::ptMax_
private

Definition at line 55 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ ptMin_

const double PATTracksToPackedCandidates::ptMin_
private

Definition at line 56 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ resetHP_

const bool PATTracksToPackedCandidates::resetHP_
private

Definition at line 57 of file PATTracksToPackedCandidates.cc.

Referenced by addPackedCandidate().

◆ srcOfflineBeamSpot_

const edm::EDGetTokenT<reco::BeamSpot> PATTracksToPackedCandidates::srcOfflineBeamSpot_
private

Definition at line 50 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ srcPrimaryVertices_

const edm::EDGetTokenT<reco::VertexCollection> PATTracksToPackedCandidates::srcPrimaryVertices_
private

Definition at line 49 of file PATTracksToPackedCandidates.cc.

Referenced by produce().

◆ srcTracks_

const edm::EDGetTokenT<reco::TrackCollection> PATTracksToPackedCandidates::srcTracks_
private

Definition at line 48 of file PATTracksToPackedCandidates.cc.

Referenced by produce().