CMS 3D CMS Logo

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

Public Member Functions

 PATSecondaryVertexSlimmer (const edm::ParameterSet &)
 
virtual void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const
 
 ~PATSecondaryVertexSlimmer ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
 
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollectionsrc_
 
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
 
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionsrcV0s_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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 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 22 of file PATSecondaryVertexSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 37 of file PATSecondaryVertexSlimmer.cc.

37  :
38  src_(consumes<reco::VertexCompositePtrCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
39  srcLegacy_(mayConsume<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("src"))),
40  srcV0s_(mayConsume<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
42  map2_(mayConsume<edm::Association<pat::PackedCandidateCollection> >(iConfig.existsAs<edm::InputTag>("lostTracksCandidates") ? iConfig.getParameter<edm::InputTag>("lostTracksCandidates") : edm::InputTag("lostTracks") ))
43 {
44  produces< reco::VertexCompositePtrCandidateCollection >();
45 }
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > srcV0s_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > src_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
pat::PATSecondaryVertexSlimmer::~PATSecondaryVertexSlimmer ( )

Definition at line 47 of file PATSecondaryVertexSlimmer.cc.

47 {}

Member Function Documentation

void pat::PATSecondaryVertexSlimmer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
virtual

Must be V0s VertexCompositeCandidate format

Definition at line 49 of file PATSecondaryVertexSlimmer.cc.

References reco::CompositePtrCandidate::addDaughter(), reco::Vertex::chi2(), reco::CompositePtrCandidate::clearDaughters(), reco::CompositeCandidate::daughter(), reco::CompositePtrCandidate::daughterPtrVector(), BPhysicsValidation_cfi::daughters, DEFINE_FWK_MODULE, reco::Vertex::error(), edm::Event::getByToken(), mps_fire::i, edm::HandleBase::isValid(), map2_, map_, eostools::move(), gen::n, reco::Vertex::ndof(), reco::CompositeCandidate::numberOfDaughters(), reco::LeafCandidate::p4(), reco::Vertex::p4(), reco::Vertex::position(), edm::Event::put(), edm::refToPtr(), src_, srcLegacy_, srcV0s_, reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), reco::Vertex::trackWeight(), findQualityFiles::v, reco::LeafCandidate::vertex(), reco::VertexCompositeCandidate::vertexChi2(), reco::VertexCompositeCandidate::vertexCovariance(), reco::VertexCompositeCandidate::vertexNdof(), and ecalDrivenElectronSeedsParameters_cff::vertices.

49  {
50 
51  auto outPtr = std::make_unique<reco::VertexCompositePtrCandidateCollection>();
52 
54  iEvent.getByToken(src_, candVertices);
55 
57  iEvent.getByToken(map_,pf2pc);
58 
59  // if reco::VertexCompositePtrCandidate secondary vertices are present
60  if( candVertices.isValid() )
61  {
62  outPtr->reserve(candVertices->size());
63  for (unsigned int i = 0, n = candVertices->size(); i < n; ++i) {
64 
65  reco::VertexCompositePtrCandidate v = (*candVertices)[i];
66 
67  std::vector<reco::CandidatePtr> daughters = v.daughterPtrVector();
68  v.clearDaughters();
69 
70  for(std::vector<reco::CandidatePtr>::const_iterator it = daughters.begin(); it != daughters.end(); ++it) {
71 
72  if((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0)
73  v.addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it]) ));
74  }
75 
76  outPtr->push_back( v );
77  }
78  }
79  // otherwise fallback to reco::Vertex secondary vertices
80  else
81  {
83  iEvent.getByToken(srcLegacy_, vertices);
84 
85  if( vertices.isValid() ){
86 
88  iEvent.getByToken(map2_,pf2pc2);
89 
90  outPtr->reserve(vertices->size());
91  for (unsigned int i = 0, n = vertices->size(); i < n; ++i) {
92  const reco::Vertex &v = (*vertices)[i];
93  outPtr->push_back(reco::VertexCompositePtrCandidate(0,v.p4(),v.position(), v.error(), v.chi2(), v.ndof()));
94 
95  for(reco::Vertex::trackRef_iterator it=v.tracks_begin(); it != v.tracks_end(); it++) {
96  if(v.trackWeight(*it)>0.5) {
97  if((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0) {
98  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it]) ));
99  }
100  else {
101  if((*pf2pc2)[*it].isNonnull()) {
102  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[*it]) ));
103  }
104  else { edm::LogError("PATSecondaryVertexSlimmer") << "HELPME" << std::endl;}
105  }
106  }
107  }
108  }
109  }else {
112  iEvent.getByToken( srcV0s_, srcV0s );
113 
115  iEvent.getByToken(map2_,pf2pc2);
116 
117  outPtr->reserve(srcV0s->size());
118  for (unsigned int i = 0, n = srcV0s->size(); i < n; ++i) {
119  const reco::VertexCompositeCandidate &v = (*srcV0s)[i];
120  outPtr->push_back(reco::VertexCompositePtrCandidate(0,v.p4(),v.vertex(), v.vertexCovariance(), v.vertexChi2(), v.vertexNdof()));
121 
122  for(size_t dIdx=0; dIdx< v.numberOfDaughters() ; dIdx++){
123  reco::TrackRef trackRef = (dynamic_cast<const reco::RecoChargedCandidate*>(v.daughter(dIdx)))->track();
124  if((*pf2pc)[trackRef].isNonnull() && (*pf2pc)[trackRef]->numberOfHits() > 0) {
125  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[trackRef]) ));
126  }
127  else {
128  if((*pf2pc2)[trackRef].isNonnull()) {
129  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[trackRef]) ));
130  }
131  else { edm::LogError("PATSecondaryVertexSlimmer") << "HELPME" << std::endl;}
132  }
133  }
134  }
135 
136  } // if reco::Vertex
137  } // if Candidate
138 
139  iEvent.put(std::move(outPtr));
140 }
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual const Point & vertex() const
vertex position (overwritten by PF...)
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
const Point & position() const
position
Definition: Vertex.h:109
virtual size_type numberOfDaughters() const
number of daughters
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > srcV0s_
virtual double vertexChi2() const
chi-squares
double chi2() const
chi-squares
Definition: Vertex.h:98
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:81
virtual double vertexCovariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
bool isValid() const
Definition: HandleBase.h:74
double ndof() const
Definition: Vertex.h:105
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products...
Definition: Vertex.cc:135
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Error error() const
return SMatrix
Definition: Vertex.h:139
void clearDaughters()
clear daughter references
const daughters & daughterPtrVector() const
references to daughtes
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
void addDaughter(const CandidatePtr &)
add a daughter via a reference
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > src_
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATSecondaryVertexSlimmer::map2_
private

Definition at line 33 of file PATSecondaryVertexSlimmer.cc.

Referenced by produce().

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

Definition at line 32 of file PATSecondaryVertexSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCompositePtrCandidateCollection> pat::PATSecondaryVertexSlimmer::src_
private

Definition at line 29 of file PATSecondaryVertexSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<reco::Vertex> > pat::PATSecondaryVertexSlimmer::srcLegacy_
private

Definition at line 30 of file PATSecondaryVertexSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> pat::PATSecondaryVertexSlimmer::srcV0s_
private

Definition at line 31 of file PATSecondaryVertexSlimmer.cc.

Referenced by produce().