CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
VertexFromTrackProducer Class Reference

#include <RecoVertex/PrimaryVertexProducer/src/VertexFromTrackProducer.cc>

Inheritance diagram for VertexFromTrackProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 VertexFromTrackProducer (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 Attributes

const edm::EDGetTokenT< reco::BeamSpotbeamSpotLabel
 
const edm::EDGetTokenT< edm::View< reco::RecoCandidate > > candidateToken
 
const bool fIsRecoCandidate
 
const bool fUseBeamSpot
 
const bool fUseTriggerFilterElectrons
 
const bool fUseTriggerFilterMuons
 
const bool fUseVertex
 
const bool fVerbose
 
const edm::EDGetTokenT< edm::View< reco::Track > > trackToken
 
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefstriggerFilterElectronsSrc
 
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefstriggerFilterMuonsSrc
 
const edm::EDGetTokenT< edm::View< reco::Vertex > > vertexLabel
 

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

Description: produces a primary vertex extrapolating the track of a candidate on the beam axis

Implementation: <Notes on="" implementation>="">

Definition at line 32 of file VertexFromTrackProducer.h.

Constructor & Destructor Documentation

◆ VertexFromTrackProducer()

VertexFromTrackProducer::VertexFromTrackProducer ( const edm::ParameterSet conf)
explicit

Definition at line 11 of file VertexFromTrackProducer.cc.

14  triggerFilterElectronsSrc(consumes<trigger::TriggerFilterObjectWithRefs>(
15  conf.getParameter<edm::InputTag>("triggerFilterElectronsSrc"))),
17  consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("triggerFilterMuonsSrc"))),
19  beamSpotLabel(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpotLabel"))),
20  fIsRecoCandidate(conf.getParameter<bool>("isRecoCandidate")),
21  fUseBeamSpot(conf.getParameter<bool>("useBeamSpot")),
22  fUseVertex(conf.getParameter<bool>("useVertex")),
23  fUseTriggerFilterElectrons(conf.getParameter<bool>("useTriggerFilterElectrons")),
24  fUseTriggerFilterMuons(conf.getParameter<bool>("useTriggerFilterMuons")),
25  fVerbose(conf.getUntrackedParameter<bool>("verbose", false)) {
26  edm::LogInfo("PVDebugInfo") << "Initializing VertexFromTrackProducer"
27  << "\n";
28 
29  produces<reco::VertexCollection>();
30 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< reco::BeamSpot > beamSpotLabel
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< edm::View< reco::RecoCandidate > > candidateToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc
Log< level::Info, false > LogInfo
const edm::EDGetTokenT< edm::View< reco::Track > > trackToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc
const edm::EDGetTokenT< edm::View< reco::Vertex > > vertexLabel

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 169 of file VertexFromTrackProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and edm::ConfigurationDescriptions::setComment().

169  {
171 
172  desc.add<bool>("isRecoCandidate", false)
173  ->setComment(
174  "If isRecoCandidate=True \"trackLabel\" is used and assumed to be collection of candidates.\nOtherwise it is "
175  "assumed that \"trackLabel\" is collection of tracks and is used when useTriggerFilterElectrons=False and "
176  "useTriggerFilterMuons=False");
177  desc.add<edm::InputTag>("trackLabel", edm::InputTag("hltL3MuonCandidates"))
178  ->setComment("Collection of tracks or candidates");
179  desc.add<bool>("useTriggerFilterElectrons", false)
180  ->setComment("Use leading electron passing \"triggerFilterElectronsSrc\" filter to determine z vertex position");
181  desc.add<edm::InputTag>("triggerFilterElectronsSrc",
182  edm::InputTag("hltEle20CaloIdVTCaloIsoTTrkIdTTrkIsoL1JetTrackIsoFilter"))
183  ->setComment("Name of electron filter");
184  desc.add<bool>("useTriggerFilterMuons", true)
185  ->setComment("Use leading muon passing \"triggerFilterMuonsSrc\" filter to determine z vertex position");
186  desc.add<edm::InputTag>("triggerFilterMuonsSrc", edm::InputTag("hltSingleMuIsoL3IsoFiltered15"))
187  ->setComment("Name of muon filter");
188  desc.add<bool>("useBeamSpot", true)->setComment("Use beam spot for x/y vertex position");
189  desc.add<edm::InputTag>("beamSpotLabel", edm::InputTag("hltOnlineBeamSpot"))->setComment("Beamspot collection");
190  desc.add<bool>("useVertex", true)
191  ->setComment("Use vertex for x/y vertex position (beam spot is used when PV does not exit)");
192  desc.add<edm::InputTag>("vertexLabel", edm::InputTag("hltPixelVertices"))->setComment("Vertex collection");
193 
194  desc.addUntracked<bool>("verbose", false)->setComment("Switch on/off verbosity");
195  descriptions.setComment(
196  "This module produces vertex with z-coordinate determined with the highest-Pt lepton track and x/y-coordinates "
197  "taken from BeamSpot/Vertex");
198  descriptions.add("hltVertexFromTrackProducer", desc);
199 }
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void VertexFromTrackProducer::produce ( edm::StreamID  iStreamId,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 32 of file VertexFromTrackProducer.cc.

References pwdgSkimBPark_cfi::beamSpot, beamSpotLabel, candidateToken, fIsRecoCandidate, fUseBeamSpot, fUseTriggerFilterElectrons, fUseTriggerFilterMuons, fUseVertex, fVerbose, trigger::TriggerRefsCollections::getObjects(), mps_fire::i, iEvent, edm::HandleBase::isValid(), HiEvtPlane_cfi::maxpt, eostools::move(), DiDispStaMuonMonitor_cfi::pt, mps_fire::result, HLT_2024v11_cff::track, trackToken, trigger::TriggerElectron, triggerFilterElectronsSrc, triggerFilterMuonsSrc, trigger::TriggerMuon, findQualityFiles::v, bphysicsOniaDQM_cfi::vertex, and vertexLabel.

34  {
35  using namespace edm;
36 
37  std::unique_ptr<reco::VertexCollection> result(new reco::VertexCollection);
39 
40  math::XYZPoint vertexPoint;
41  bool vertexAvailable = false;
42 
43  // get the BeamSpot
44  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
45  iEvent.getByToken(beamSpotLabel, recoBeamSpotHandle);
46  if (recoBeamSpotHandle.isValid()) {
47  const reco::BeamSpot& beamSpot = *recoBeamSpotHandle;
48  vertexPoint = beamSpot.position();
49  } else {
50  edm::LogError("UnusableBeamSpot") << "No beam spot found in Event";
51  }
52 
53  if (fUseVertex) {
54  // get the Vertex
55  edm::Handle<edm::View<reco::Vertex> > recoVertexHandle;
56  iEvent.getByToken(vertexLabel, recoVertexHandle);
57  if ((recoVertexHandle.isValid()) && (!recoVertexHandle->empty())) {
58  reco::Vertex vertex = recoVertexHandle->at(0);
59  vertexPoint = vertex.position();
60  vertexAvailable = true;
61  } else {
62  edm::LogInfo("UnusableVertex") << "No vertex found in Event, beam spot used instaed"
63  << "\n";
64  }
65  }
66 
67  const reco::Track* track = nullptr;
68  if (fIsRecoCandidate) {
70  iEvent.getByToken(candidateToken, candidateHandle);
71  if ((candidateHandle.isValid()) && (!candidateHandle->empty())) {
72  double maxpt = 0.;
73  unsigned i_maxpt = 0;
74  for (unsigned i = 0; i < candidateHandle->size(); ++i) {
75  double pt = candidateHandle->ptrAt(i)->pt();
76  if (pt > maxpt) {
77  i_maxpt = i;
78  maxpt = pt;
79  }
80  }
81  track = dynamic_cast<const reco::Track*>(candidateHandle->ptrAt(i_maxpt)->bestTrack());
82  }
83  } else if (fUseTriggerFilterElectrons) {
85  iEvent.getByToken(triggerFilterElectronsSrc, triggerfilter);
86  std::vector<reco::ElectronRef> recocandidates;
87  triggerfilter->getObjects(trigger::TriggerElectron, recocandidates);
88  if ((!recocandidates.empty())) {
89  double maxpt = 0.;
90  unsigned i_maxpt = 0;
91  for (unsigned i = 0; i < recocandidates.size(); ++i) {
92  double pt = recocandidates.at(i)->pt();
93  if (pt > maxpt) {
94  i_maxpt = i;
95  maxpt = pt;
96  }
97  track = dynamic_cast<const reco::Track*>(recocandidates.at(i_maxpt)->bestTrack());
98  }
99  }
100  } else if (fUseTriggerFilterMuons) {
102  iEvent.getByToken(triggerFilterMuonsSrc, triggerfilter);
103  std::vector<reco::RecoChargedCandidateRef> recocandidates;
104  triggerfilter->getObjects(trigger::TriggerMuon, recocandidates);
105  if ((!recocandidates.empty())) {
106  double maxpt = 0.;
107  unsigned i_maxpt = 0;
108  for (unsigned i = 0; i < recocandidates.size(); ++i) {
109  double pt = recocandidates.at(i)->pt();
110  if (pt > maxpt) {
111  i_maxpt = i;
112  maxpt = pt;
113  }
114  track = dynamic_cast<const reco::Track*>(recocandidates.at(i_maxpt)->bestTrack());
115  }
116  }
117  } else {
119  iEvent.getByToken(trackToken, trackHandle);
120  if ((trackHandle.isValid()) && (!trackHandle->empty())) {
121  double maxpt = 0.;
122  unsigned i_maxpt = 0;
123  for (unsigned i = 0; i < trackHandle->size(); ++i) {
124  double pt = trackHandle->ptrAt(i)->pt();
125  if (pt > maxpt) {
126  i_maxpt = i;
127  maxpt = pt;
128  }
129  }
130  track = dynamic_cast<const reco::Track*>(&*trackHandle->ptrAt(i_maxpt));
131  }
132  }
133 
134  if (track) {
135  if (fUseBeamSpot || (fUseVertex && vertexAvailable)) {
136  vertexPoint.SetZ(vertexPoint.z() + track->dz(vertexPoint));
137  } else {
138  vertexPoint.SetZ(track->vz());
139  }
140  }
141  math::Error<3>::type noErrors;
142  reco::Vertex v(vertexPoint, noErrors);
143  vColl.push_back(v);
144 
145  // provide beamspot or primary vertex if no candidate found
146  //if(vColl.size()==0)
147  //{
148  // math::Error<3>::type noErrors;
149  // reco::Vertex v(vertexPoint, noErrors);
150  // vColl.push_back(v);
151  //}
152 
153  if (fVerbose) {
154  int ivtx = 0;
155  edm::LogInfo("PVDebugInfo") << "Vertices by VertexFromTrackProducer: \n";
156  for (reco::VertexCollection::const_iterator v = vColl.begin(); v != vColl.end(); ++v) {
157  edm::LogInfo("PVDebugInfo") << "\t"
158  << "recvtx " << ivtx++ << " x " << std::setw(6) << v->position().x() << " dx "
159  << std::setw(6) << v->xError() << " y " << std::setw(6) << v->position().y() << " dy "
160  << std::setw(6) << v->yError() << " z " << std::setw(6) << v->position().z() << " dz "
161  << std::setw(6) << v->zError() << " \n ";
162  }
163  }
164 
165  *result = vColl;
166  iEvent.put(std::move(result));
167 }
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
ErrorD< N >::type type
Definition: Error.h:32
Log< level::Error, false > LogError
const edm::EDGetTokenT< reco::BeamSpot > beamSpotLabel
const edm::EDGetTokenT< edm::View< reco::RecoCandidate > > candidateToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc
int iEvent
Definition: GenABIO.cc:224
Log< level::Info, false > LogInfo
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< edm::View< reco::Track > > trackToken
HLT enums.
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< edm::View< reco::Vertex > > vertexLabel

Member Data Documentation

◆ beamSpotLabel

const edm::EDGetTokenT<reco::BeamSpot> VertexFromTrackProducer::beamSpotLabel
private

Definition at line 47 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ candidateToken

const edm::EDGetTokenT<edm::View<reco::RecoCandidate> > VertexFromTrackProducer::candidateToken
private

Definition at line 43 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ fIsRecoCandidate

const bool VertexFromTrackProducer::fIsRecoCandidate
private

Definition at line 50 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ fUseBeamSpot

const bool VertexFromTrackProducer::fUseBeamSpot
private

Definition at line 51 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ fUseTriggerFilterElectrons

const bool VertexFromTrackProducer::fUseTriggerFilterElectrons
private

Definition at line 53 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ fUseTriggerFilterMuons

const bool VertexFromTrackProducer::fUseTriggerFilterMuons
private

Definition at line 53 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ fUseVertex

const bool VertexFromTrackProducer::fUseVertex
private

Definition at line 52 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ fVerbose

const bool VertexFromTrackProducer::fVerbose
private

Definition at line 54 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ trackToken

const edm::EDGetTokenT<edm::View<reco::Track> > VertexFromTrackProducer::trackToken
private

Definition at line 42 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ triggerFilterElectronsSrc

const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> VertexFromTrackProducer::triggerFilterElectronsSrc
private

Definition at line 44 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ triggerFilterMuonsSrc

const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> VertexFromTrackProducer::triggerFilterMuonsSrc
private

Definition at line 45 of file VertexFromTrackProducer.h.

Referenced by produce().

◆ vertexLabel

const edm::EDGetTokenT<edm::View<reco::Vertex> > VertexFromTrackProducer::vertexLabel
private

Definition at line 46 of file VertexFromTrackProducer.h.

Referenced by produce().