CMS 3D CMS Logo

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

Public Member Functions

 PATTrackAndVertexUnpacker (const edm::ParameterSet &iConfig)
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~PATTrackAndVertexUnpacker () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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

typedef std::vector< edm::InputTagVInputTag
 

Private Attributes

const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
 
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
 
const edm::EDGetTokenT< reco::VertexCollectionPVs_
 
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollectionSVs_
 

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)
 
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 TrackAndVertexUnpacker.cc.

Member Typedef Documentation

Definition at line 34 of file TrackAndVertexUnpacker.cc.

Constructor & Destructor Documentation

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

Definition at line 47 of file TrackAndVertexUnpacker.cc.

48  : Cands_(consumes<std::vector<pat::PackedCandidate>>(iConfig.getParameter<edm::InputTag>("packedCandidates"))),
49  PVs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("slimmedVertices"))),
50  SVs_(consumes<reco::VertexCompositePtrCandidateCollection>(
51  iConfig.getParameter<edm::InputTag>("slimmedSecondaryVertices"))),
53  consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("additionalTracks"))) {
54  produces<reco::TrackCollection>();
55  produces<reco::VertexCollection>();
56  produces<reco::VertexCollection>("secondary");
57 }
const edm::EDGetTokenT< reco::VertexCollection > PVs_
T getParameter(std::string const &) const
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > SVs_
PATTrackAndVertexUnpacker::~PATTrackAndVertexUnpacker ( )
override

Definition at line 59 of file TrackAndVertexUnpacker.cc.

59 {}

Member Function Documentation

void PATTrackAndVertexUnpacker::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
override

Definition at line 61 of file TrackAndVertexUnpacker.cc.

References reco::Vertex::add(), AdditionalTracks_, HltBtagPostValidation_cff::c, HLT_2018_cff::cands, Cands_, pat::PackedCandidate::charge(), reco::CompositePtrCandidate::daughterPtr(), DEFINE_FWK_MODULE, pat::PackedCandidate::fromPV(), edm::Event::getByToken(), pat::PackedCandidate::hasTrackDetails(), mps_fire::i, edm::HandleBase::id(), edm::Ptr< T >::id(), dqmiolumiharvest::j, edm::Ptr< T >::key(), eostools::move(), reco::CompositePtrCandidate::numberOfDaughters(), pat::PackedCandidate::numberOfHits(), pat::PackedCandidate::pseudoTrack(), edm::Event::put(), MetAnalyzer::pv(), FSQDQM_cfi::pvs, PVs_, pat::PackedCandidate::PVUsedInFit, alignCSCRings::r, findQualityFiles::rr, pfDeepBoostedJetPreprocessParams_cfi::sv, SVs_, reco::LeafCandidate::vertex(), reco::VertexCompositePtrCandidate::vertexChi2(), reco::VertexCompositePtrCandidate::vertexCovariance(), and reco::VertexCompositePtrCandidate::vertexNdof().

61  {
62  using namespace edm;
63  using namespace std;
64  using namespace reco;
66  iEvent.getByToken(Cands_, cands);
68  iEvent.getByToken(PVs_, pvs);
70  iEvent.getByToken(SVs_, svs);
72  iEvent.getByToken(AdditionalTracks_, addTracks);
73 
74  auto outTks = std::make_unique<std::vector<reco::Track>>();
75  std::map<unsigned int, std::vector<unsigned int>> asso;
76  std::map<unsigned int, unsigned int> trackKeys;
77  unsigned int j = 0;
78  for (unsigned int i = 0; i < cands->size(); i++) {
79  const pat::PackedCandidate& c = (*cands)[i];
80  if (c.hasTrackDetails() && c.charge() != 0 && c.numberOfHits() > 0) {
81  outTks->push_back(c.pseudoTrack());
82  for (size_t ipv = 0; ipv < pvs->size(); ++ipv) {
84  asso[ipv].push_back(j);
85  }
86  trackKeys[i] = j;
87  j++;
88  }
89  }
90 
91  int offsetAdd = j;
92  for (unsigned int i = 0; i < addTracks->size(); i++) {
93  if ((*addTracks)[i].hasTrackDetails()) {
94  outTks->push_back((*addTracks)[i].pseudoTrack());
95  for (size_t ipv = 0; ipv < pvs->size(); ++ipv) {
96  if ((*addTracks)[i].fromPV(ipv) == pat::PackedCandidate::PVUsedInFit)
97  asso[ipv].push_back(j);
98  }
99  j++;
100  }
101  }
102 
104 
105  auto outPv = std::make_unique<std::vector<reco::Vertex>>();
106 
107  for (size_t ipv = 0; ipv < pvs->size(); ++ipv) {
108  reco::Vertex pv = (*pvs)[ipv];
109  for (unsigned int i = 0; i < asso[ipv].size(); i++) {
110  TrackRef r(oh, asso[ipv][i]);
111  TrackBaseRef rr(r);
112  pv.add(rr);
113  }
114  outPv->push_back(pv);
115  }
116  iEvent.put(std::move(outPv));
117 
118  auto outSv = std::make_unique<std::vector<reco::Vertex>>();
119  for (size_t i = 0; i < svs->size(); i++) {
120  const reco::VertexCompositePtrCandidate& sv = (*svs)[i];
121  outSv->push_back(reco::Vertex(sv.vertex(), sv.vertexCovariance(), sv.vertexChi2(), sv.vertexNdof(), 0));
122  for (size_t j = 0; j < sv.numberOfDaughters(); j++) {
123  TrackRef r;
124  if (sv.daughterPtr(j).id() == cands.id()) {
125  // use trackKeys because cand->track has gaps from neutral
126  r = TrackRef(oh, trackKeys[sv.daughterPtr(j).key()]);
127  } else {
128  // use directly the key because addTracks is only charged
129  r = TrackRef(oh, offsetAdd + sv.daughterPtr(j).key());
130  }
131  TrackBaseRef rr(r);
132  outSv->back().add(rr);
133  }
134  }
135 
136  iEvent.put(std::move(outSv), "secondary");
137 }
const edm::EDGetTokenT< reco::VertexCollection > PVs_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
int numberOfHits() const
key_type key() const
Definition: Ptr.h:163
ProductID id() const
Definition: HandleBase.cc:13
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
size_t numberOfDaughters() const override
number of daughters
int charge() const override
electric charge
const PVAssoc fromPV(size_t ipv=0) const
double vertexCovariance(int i, int j) const override
(i, j)-th element of error matrix, i, j = 0, ... 3
const Point & vertex() const override
vertex position (overwritten by PF...)
def pv(vc)
Definition: MetAnalyzer.py:7
virtual const reco::Track & pseudoTrack() const
void add(const TrackBaseRef &r, float w=1.0)
add a reference to a Track
Definition: Vertex.cc:79
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > SVs_
virtual CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
fixed size matrix
HLT enums.
double vertexChi2() const override
chi-squares
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const edm::EDGetTokenT<std::vector<pat::PackedCandidate> > pat::PATTrackAndVertexUnpacker::AdditionalTracks_
private

Definition at line 39 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<pat::PackedCandidate> > pat::PATTrackAndVertexUnpacker::Cands_
private

Definition at line 36 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCollection> pat::PATTrackAndVertexUnpacker::PVs_
private

Definition at line 37 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCompositePtrCandidateCollection> pat::PATTrackAndVertexUnpacker::SVs_
private

Definition at line 38 of file TrackAndVertexUnpacker.cc.

Referenced by produce().