CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

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::BeamSpot
beamSpotLabel
 
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::TriggerFilterObjectWithRefs
triggerFilterElectronsSrc
 
const edm::EDGetTokenT
< trigger::TriggerFilterObjectWithRefs
triggerFilterMuonsSrc
 
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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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

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

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

Definition at line 47 of file VertexFromTrackProducer.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file VertexFromTrackProducer.cc.

27  :
30  triggerFilterElectronsSrc( consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("triggerFilterElectronsSrc")) ),
31  triggerFilterMuonsSrc( consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("triggerFilterMuonsSrc")) ),
33  beamSpotLabel( consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpotLabel")) ),
34  fIsRecoCandidate( conf.getParameter<bool>("isRecoCandidate") ),
35  fUseBeamSpot( conf.getParameter<bool>("useBeamSpot") ),
36  fUseVertex( conf.getParameter<bool>("useVertex") ),
37  fUseTriggerFilterElectrons( conf.getParameter<bool>("useTriggerFilterElectrons") ),
38  fUseTriggerFilterMuons( conf.getParameter<bool>("useTriggerFilterMuons") ),
39  fVerbose( conf.getUntrackedParameter<bool>("verbose", false) )
40 {
41  edm::LogInfo("PVDebugInfo")
42  << "Initializing VertexFromTrackProducer" << "\n";
43 
44  produces<reco::VertexCollection>();
45 
46 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< reco::BeamSpot > beamSpotLabel
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< edm::View< reco::RecoCandidate > > candidateToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc
const edm::EDGetTokenT< edm::View< reco::Track > > trackToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc
const edm::EDGetTokenT< edm::View< reco::Vertex > > vertexLabel
VertexFromTrackProducer::~VertexFromTrackProducer ( )

Definition at line 49 of file VertexFromTrackProducer.cc.

49 {}

Member Function Documentation

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

Definition at line 211 of file VertexFromTrackProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), HLT_25ns14e33_v1_cff::InputTag, and edm::ConfigurationDescriptions::setComment().

212 {
213 
215 
216  desc.add<bool>("isRecoCandidate",false)->setComment("If isRecoCandidate=True \"trackLabel\" is used and assumed to be collection of candidates.\nOtherwise it is assumed that \"trackLabel\" is collection of tracks and is used when useTriggerFilterElectrons=False and useTriggerFilterMuons=False");
217  desc.add<edm::InputTag>("trackLabel",edm::InputTag("hltL3MuonCandidates"))->setComment("Collection of tracks or candidates");
218  desc.add<bool>("useTriggerFilterElectrons",false)->setComment("Use leading electron passing \"triggerFilterElectronsSrc\" filter to determine z vertex position");
219  desc.add<edm::InputTag>("triggerFilterElectronsSrc",edm::InputTag("hltEle20CaloIdVTCaloIsoTTrkIdTTrkIsoL1JetTrackIsoFilter"))->setComment("Name of electron filter");
220  desc.add<bool>("useTriggerFilterMuons",true)->setComment("Use leading muon passing \"triggerFilterMuonsSrc\" filter to determine z vertex position");
221  desc.add<edm::InputTag>("triggerFilterMuonsSrc",edm::InputTag("hltSingleMuIsoL3IsoFiltered15"))->setComment("Name of muon filter");
222  desc.add<bool>("useBeamSpot",true)->setComment("Use beam spot for x/y vertex position");
223  desc.add<edm::InputTag>("beamSpotLabel",edm::InputTag("hltOnlineBeamSpot"))->setComment("Beamspot collection");
224  desc.add<bool>("useVertex",true)->setComment("Use vertex for x/y vertex position (beam spot is used when PV does not exit)");
225  desc.add<edm::InputTag>("vertexLabel",edm::InputTag("hltPixelVertices"))->setComment("Vertex collection");
226 
227  desc.addUntracked<bool>("verbose",false)->setComment("Switch on/off verbosity");
228  descriptions.setComment("This module produces vertex with z-coordinate determined with the highest-Pt lepton track and x/y-coordinates taken from BeamSpot/Vertex");
229  descriptions.add("hltVertexFromTrackProducer",desc);
230 
231 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void VertexFromTrackProducer::produce ( edm::StreamID  iStreamId,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 57 of file VertexFromTrackProducer.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, beamSpotLabel, candidateToken, fIsRecoCandidate, fUseBeamSpot, fUseTriggerFilterElectrons, fUseTriggerFilterMuons, fUseVertex, fVerbose, edm::Event::getByToken(), i, edm::HandleBase::isValid(), reco::BeamSpot::position(), reco::Vertex::position(), EnergyCorrector::pt, edm::Event::put(), query::result, trackToken, trigger::TriggerElectron, triggerFilterElectronsSrc, triggerFilterMuonsSrc, trigger::TriggerMuon, findQualityFiles::v, vertexLabel, reco::Vertex::xError(), reco::Vertex::yError(), and reco::Vertex::zError().

58 {
59  using namespace edm;
60 
61  std::auto_ptr<reco::VertexCollection> result(new reco::VertexCollection);
63 
64  math::XYZPoint vertexPoint;
65  bool vertexAvailable = false;
66 
67  // get the BeamSpot
68  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
69  iEvent.getByToken(beamSpotLabel,recoBeamSpotHandle);
70  if (recoBeamSpotHandle.isValid()){
71  reco::BeamSpot beamSpot = *recoBeamSpotHandle;
72  vertexPoint = beamSpot.position();
73  }else{
74  edm::LogError("UnusableBeamSpot") << "No beam spot found in Event";
75  }
76 
77  if(fUseVertex)
78  {
79  // get the Vertex
80  edm::Handle<edm::View<reco::Vertex> > recoVertexHandle;
81  iEvent.getByToken(vertexLabel,recoVertexHandle);
82  if ((recoVertexHandle.isValid()) && (recoVertexHandle->size()>0)){
83  reco::Vertex vertex = recoVertexHandle->at(0);
84  vertexPoint = vertex.position();
85  vertexAvailable = true;
86  }else {
87  edm::LogInfo("UnusableVertex")
88  << "No vertex found in Event, beam spot used instaed" << "\n";
89  }
90  }
91 
92  const reco::Track* track = 0;
94  {
96  iEvent.getByToken(candidateToken, candidateHandle);
97  if ((candidateHandle.isValid())&&(candidateHandle->size()>0)){
98  double maxpt=0.;
99  unsigned i_maxpt=0;
100  for (unsigned i = 0; i < candidateHandle->size(); ++i) {
101  double pt=candidateHandle->ptrAt(i)->pt();
102  if(pt>maxpt)
103  {
104  i_maxpt=i;
105  maxpt=pt;
106  }
107  }
108  track = dynamic_cast<const reco::Track*>(candidateHandle->ptrAt(i_maxpt)->bestTrack());
109  }
110  }
111  else if(fUseTriggerFilterElectrons) {
113  iEvent.getByToken(triggerFilterElectronsSrc, triggerfilter);
114  std::vector<reco::ElectronRef> recocandidates;
115  triggerfilter->getObjects(trigger::TriggerElectron,recocandidates);
116  if ((recocandidates.size()>0)){
117  double maxpt=0.;
118  unsigned i_maxpt=0;
119  for (unsigned i = 0; i < recocandidates.size(); ++i) {
120  double pt=recocandidates.at(i)->pt();
121  if(pt>maxpt)
122  {
123  i_maxpt=i;
124  maxpt=pt;
125  }
126  track = dynamic_cast<const reco::Track*>(recocandidates.at(i_maxpt)->bestTrack());
127  }
128  }
129  }
130  else if(fUseTriggerFilterMuons) {
132  iEvent.getByToken(triggerFilterMuonsSrc, triggerfilter);
133  std::vector<reco::RecoChargedCandidateRef> recocandidates;
134  triggerfilter->getObjects(trigger::TriggerMuon,recocandidates);
135  if ((recocandidates.size()>0)){
136  double maxpt=0.;
137  unsigned i_maxpt=0;
138  for (unsigned i = 0; i < recocandidates.size(); ++i) {
139  double pt=recocandidates.at(i)->pt();
140  if(pt>maxpt)
141  {
142  i_maxpt=i;
143  maxpt=pt;
144  }
145  track = dynamic_cast<const reco::Track*>(recocandidates.at(i_maxpt)->bestTrack());
146  }
147  }
148  }
149  else {
151  iEvent.getByToken(trackToken, trackHandle);
152  if ((trackHandle.isValid())&&(trackHandle->size()>0)){
153  double maxpt=0.;
154  unsigned i_maxpt=0;
155  for (unsigned i = 0; i < trackHandle->size(); ++i) {
156  double pt=trackHandle->ptrAt(i)->pt();
157  if(pt>maxpt)
158  {
159  i_maxpt=i;
160  maxpt=pt;
161  }
162  }
163  track = dynamic_cast<const reco::Track*>(&*trackHandle->ptrAt(i_maxpt));
164  }
165  }
166 
167  if(track) {
168  if(fUseBeamSpot || (fUseVertex && vertexAvailable) ) {
169  vertexPoint.SetZ(vertexPoint.z()+track->dz(vertexPoint));
170  }
171  else {
172  vertexPoint.SetZ(track->vz());
173  }
174  }
175  math::Error<3>::type noErrors;
176  reco::Vertex v(vertexPoint, noErrors);
177  vColl.push_back(v);
178 
179  // provide beamspot or primary vertex if no candidate found
180  //if(vColl.size()==0)
181  //{
182  // math::Error<3>::type noErrors;
183  // reco::Vertex v(vertexPoint, noErrors);
184  // vColl.push_back(v);
185  //}
186 
187  if(fVerbose){
188  int ivtx=0;
189  edm::LogInfo("PVDebugInfo")<< "Vertices by VertexFromTrackProducer: \n";
190  for(reco::VertexCollection::const_iterator v=vColl.begin();
191  v!=vColl.end(); ++v){
192  edm::LogInfo("PVDebugInfo")<< "\t"
193  << "recvtx "<< ivtx++
194  << " x " << std::setw(6) << v->position().x()
195  << " dx " << std::setw(6) << v->xError()
196  << " y " << std::setw(6) << v->position().y()
197  << " dy " << std::setw(6) << v->yError()
198  << " z " << std::setw(6) << v->position().z()
199  << " dz " << std::setw(6) << v->zError()
200  << " \n ";
201  }
202  }
203 
204 
205  *result = vColl;
206  iEvent.put(result);
207 
208 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
ErrorD< N >::type type
Definition: Error.h:39
const Point & position() const
position
Definition: Vertex.h:106
const edm::EDGetTokenT< reco::BeamSpot > beamSpotLabel
const edm::EDGetTokenT< edm::View< reco::RecoCandidate > > candidateToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
tuple result
Definition: query.py:137
bool isValid() const
Definition: HandleBase.h:75
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const edm::EDGetTokenT< edm::View< reco::Track > > trackToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc
const Point & position() const
position
Definition: BeamSpot.h:62
const edm::EDGetTokenT< edm::View< reco::Vertex > > vertexLabel

Member Data Documentation

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

Definition at line 63 of file VertexFromTrackProducer.h.

Referenced by produce().

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

Definition at line 59 of file VertexFromTrackProducer.h.

Referenced by produce().

const bool VertexFromTrackProducer::fIsRecoCandidate
private

Definition at line 66 of file VertexFromTrackProducer.h.

Referenced by produce().

const bool VertexFromTrackProducer::fUseBeamSpot
private

Definition at line 67 of file VertexFromTrackProducer.h.

Referenced by produce().

const bool VertexFromTrackProducer::fUseTriggerFilterElectrons
private

Definition at line 69 of file VertexFromTrackProducer.h.

Referenced by produce().

const bool VertexFromTrackProducer::fUseTriggerFilterMuons
private

Definition at line 69 of file VertexFromTrackProducer.h.

Referenced by produce().

const bool VertexFromTrackProducer::fUseVertex
private

Definition at line 68 of file VertexFromTrackProducer.h.

Referenced by produce().

const bool VertexFromTrackProducer::fVerbose
private

Definition at line 70 of file VertexFromTrackProducer.h.

Referenced by produce().

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

Definition at line 58 of file VertexFromTrackProducer.h.

Referenced by produce().

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

Definition at line 60 of file VertexFromTrackProducer.h.

Referenced by produce().

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

Definition at line 61 of file VertexFromTrackProducer.h.

Referenced by produce().

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

Definition at line 62 of file VertexFromTrackProducer.h.

Referenced by produce().