CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

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 18 of file PATSecondaryVertexSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 32 of file PATSecondaryVertexSlimmer.cc.

32  :
33  src_(consumes<reco::VertexCompositePtrCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
34  srcLegacy_(mayConsume<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("src"))),
36  map2_(mayConsume<edm::Association<pat::PackedCandidateCollection> >(iConfig.existsAs<edm::InputTag>("lostTracksCandidates") ? iConfig.getParameter<edm::InputTag>("lostTracksCandidates") : edm::InputTag("lostTracks") ))
37 {
38  produces< reco::VertexCompositePtrCandidateCollection >();
39 }
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_
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 41 of file PATSecondaryVertexSlimmer.cc.

41 {}

Member Function Documentation

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

Implements edm::global::EDProducerBase.

Definition at line 43 of file PATSecondaryVertexSlimmer.cc.

References reco::CompositePtrCandidate::addDaughter(), reco::Vertex::chi2(), reco::CompositePtrCandidate::clearDaughters(), reco::CompositePtrCandidate::daughterPtrVector(), reco::Vertex::error(), edm::Event::getByToken(), i, edm::HandleBase::isValid(), gen::n, reco::Vertex::ndof(), reco::Vertex::p4(), reco::Vertex::position(), edm::Event::put(), edm::refToPtr(), reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), reco::Vertex::trackWeight(), findQualityFiles::v, and HLT_25ns14e33_v1_cff::vertices.

43  {
44 
45  std::auto_ptr<reco::VertexCompositePtrCandidateCollection> outPtr(new reco::VertexCompositePtrCandidateCollection);
46 
48  iEvent.getByToken(src_, candVertices);
49 
51  iEvent.getByToken(map_,pf2pc);
52 
53  // if reco::VertexCompositePtrCandidate secondary vertices are present
54  if( candVertices.isValid() )
55  {
56  outPtr->reserve(candVertices->size());
57  for (unsigned int i = 0, n = candVertices->size(); i < n; ++i) {
58 
59  reco::VertexCompositePtrCandidate v = (*candVertices)[i];
60 
61  std::vector<reco::CandidatePtr> daughters = v.daughterPtrVector();
62  v.clearDaughters();
63 
64  for(std::vector<reco::CandidatePtr>::const_iterator it = daughters.begin(); it != daughters.end(); ++it) {
65 
66  if((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0)
67  v.addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it]) ));
68  }
69 
70  outPtr->push_back( v );
71  }
72  }
73  // otherwise fallback to reco::Vertex secondary vertices
74  else
75  {
77  iEvent.getByToken(srcLegacy_, vertices);
78 
80  iEvent.getByToken(map2_,pf2pc2);
81 
82  outPtr->reserve(vertices->size());
83  for (unsigned int i = 0, n = vertices->size(); i < n; ++i) {
84  const reco::Vertex &v = (*vertices)[i];
85  outPtr->push_back(reco::VertexCompositePtrCandidate(0,v.p4(),v.position(), v.error(), v.chi2(), v.ndof()));
86 
87  for(reco::Vertex::trackRef_iterator it=v.tracks_begin(); it != v.tracks_end(); it++) {
88  if(v.trackWeight(*it)>0.5) {
89  if((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0) {
90  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it]) ));
91  }
92  else {
93  if((*pf2pc2)[*it].isNonnull()) {
94  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[*it]) ));
95  }
96  else { edm::LogError("PATSecondaryVertexSlimmer") << "HELPME" << std::endl;}
97  }
98  }
99  }
100  }
101  }
102 
103  iEvent.put(outPtr);
104 }
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
int i
Definition: DBlmapReader.cc:9
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:44
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
const Point & position() const
position
Definition: Vertex.h:106
std::vector< VertexCompositePtrCandidate > VertexCompositePtrCandidateCollection
collection of Candidate objects
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
double chi2() const
chi-squares
Definition: Vertex.h:95
bool isValid() const
Definition: HandleBase.h:75
double ndof() const
Definition: Vertex.h:102
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:113
Error error() const
return SMatrix
Definition: Vertex.h:129
void clearDaughters()
clear daughter references
const daughters & daughterPtrVector() const
references to daughtes
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
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:39

Member Data Documentation

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

Definition at line 28 of file PATSecondaryVertexSlimmer.cc.

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

Definition at line 27 of file PATSecondaryVertexSlimmer.cc.

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

Definition at line 25 of file PATSecondaryVertexSlimmer.cc.

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

Definition at line 26 of file PATSecondaryVertexSlimmer.cc.