31 conf.getParameter<
edm::
InputTag>(
"triggerFilterElectronsSrc"))),
33 consumes<
trigger::TriggerFilterObjectWithRefs>(conf.getParameter<
edm::
InputTag>(
"triggerFilterMuonsSrc"))),
36 fIsRecoCandidate(conf.getParameter<
bool>(
"isRecoCandidate")),
37 fUseBeamSpot(conf.getParameter<
bool>(
"useBeamSpot")),
38 fUseVertex(conf.getParameter<
bool>(
"useVertex")),
39 fUseTriggerFilterElectrons(conf.getParameter<
bool>(
"useTriggerFilterElectrons")),
40 fUseTriggerFilterMuons(conf.getParameter<
bool>(
"useTriggerFilterMuons")),
41 fVerbose(conf.getUntrackedParameter<
bool>(
"verbose",
false)) {
42 edm::LogInfo(
"PVDebugInfo") <<
"Initializing VertexFromTrackProducer"
45 produces<reco::VertexCollection>();
64 bool vertexAvailable =
false;
69 if (recoBeamSpotHandle.
isValid()) {
73 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot found in Event";
80 if ((recoVertexHandle.
isValid()) && (!recoVertexHandle->empty())) {
82 vertexPoint =
vertex.position();
83 vertexAvailable =
true;
85 edm::LogInfo(
"UnusableVertex") <<
"No vertex found in Event, beam spot used instaed"
94 if ((candidateHandle.
isValid()) && (!candidateHandle->empty())) {
97 for (
unsigned i = 0;
i < candidateHandle->size(); ++
i) {
98 double pt = candidateHandle->ptrAt(
i)->pt();
104 track = dynamic_cast<const reco::Track*>(candidateHandle->ptrAt(i_maxpt)->bestTrack());
109 std::vector<reco::ElectronRef> recocandidates;
111 if ((!recocandidates.empty())) {
113 unsigned i_maxpt = 0;
114 for (
unsigned i = 0;
i < recocandidates.size(); ++
i) {
115 double pt = recocandidates.at(
i)->pt();
120 track = dynamic_cast<const reco::Track*>(recocandidates.at(i_maxpt)->bestTrack());
126 std::vector<reco::RecoChargedCandidateRef> recocandidates;
128 if ((!recocandidates.empty())) {
130 unsigned i_maxpt = 0;
131 for (
unsigned i = 0;
i < recocandidates.size(); ++
i) {
132 double pt = recocandidates.at(
i)->pt();
137 track = dynamic_cast<const reco::Track*>(recocandidates.at(i_maxpt)->bestTrack());
143 if ((trackHandle.
isValid()) && (!trackHandle->empty())) {
145 unsigned i_maxpt = 0;
146 for (
unsigned i = 0;
i < trackHandle->size(); ++
i) {
147 double pt = trackHandle->ptrAt(
i)->pt();
153 track = dynamic_cast<const reco::Track*>(&*trackHandle->ptrAt(i_maxpt));
159 vertexPoint.SetZ(vertexPoint.z() +
track->dz(vertexPoint));
161 vertexPoint.SetZ(
track->vz());
178 edm::LogInfo(
"PVDebugInfo") <<
"Vertices by VertexFromTrackProducer: \n";
179 for (reco::VertexCollection::const_iterator
v = vColl.begin();
v != vColl.end(); ++
v) {
181 <<
"recvtx " << ivtx++ <<
" x " << std::setw(6) <<
v->position().x() <<
" dx "
182 << std::setw(6) <<
v->xError() <<
" y " << std::setw(6) <<
v->position().y() <<
" dy "
183 << std::setw(6) <<
v->yError() <<
" z " << std::setw(6) <<
v->position().z() <<
" dz "
184 << std::setw(6) <<
v->zError() <<
" \n ";
195 desc.add<
bool>(
"isRecoCandidate",
false)
197 "If isRecoCandidate=True \"trackLabel\" is used and assumed to be collection of candidates.\nOtherwise it is "
198 "assumed that \"trackLabel\" is collection of tracks and is used when useTriggerFilterElectrons=False and "
199 "useTriggerFilterMuons=False");
201 ->setComment(
"Collection of tracks or candidates");
202 desc.add<
bool>(
"useTriggerFilterElectrons",
false)
203 ->setComment(
"Use leading electron passing \"triggerFilterElectronsSrc\" filter to determine z vertex position");
205 edm::InputTag(
"hltEle20CaloIdVTCaloIsoTTrkIdTTrkIsoL1JetTrackIsoFilter"))
206 ->setComment(
"Name of electron filter");
207 desc.add<
bool>(
"useTriggerFilterMuons",
true)
208 ->setComment(
"Use leading muon passing \"triggerFilterMuonsSrc\" filter to determine z vertex position");
210 ->setComment(
"Name of muon filter");
211 desc.add<
bool>(
"useBeamSpot",
true)->setComment(
"Use beam spot for x/y vertex position");
213 desc.add<
bool>(
"useVertex",
true)
214 ->setComment(
"Use vertex for x/y vertex position (beam spot is used when PV does not exit)");
217 desc.addUntracked<
bool>(
"verbose",
false)->setComment(
"Switch on/off verbosity");
219 "This module produces vertex with z-coordinate determined with the highest-Pt lepton track and x/y-coordinates "
220 "taken from BeamSpot/Vertex");
221 descriptions.
add(
"hltVertexFromTrackProducer",
desc);