12 : trackToken(consumes<edm::
View<
reco::Track> >(conf.getParameter<edm::
InputTag>(
"trackLabel"))),
13 candidateToken(consumes<edm::
View<
reco::RecoCandidate> >(conf.getParameter<edm::
InputTag>(
"trackLabel"))),
15 conf.getParameter<edm::
InputTag>(
"triggerFilterElectronsSrc"))),
17 consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::
InputTag>(
"triggerFilterMuonsSrc"))),
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"
29 produces<reco::VertexCollection>();
41 bool vertexAvailable =
false;
46 if (recoBeamSpotHandle.isValid()) {
50 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot found in Event";
57 if ((recoVertexHandle.
isValid()) && (!recoVertexHandle->empty())) {
60 vertexAvailable =
true;
62 edm::LogInfo(
"UnusableVertex") <<
"No vertex found in Event, beam spot used instaed"
71 if ((candidateHandle.
isValid()) && (!candidateHandle->empty())) {
74 for (
unsigned i = 0;
i < candidateHandle->size(); ++
i) {
75 double pt = candidateHandle->ptrAt(
i)->pt();
81 track =
dynamic_cast<const reco::Track*
>(candidateHandle->ptrAt(i_maxpt)->bestTrack());
86 std::vector<reco::ElectronRef> recocandidates;
88 if ((!recocandidates.empty())) {
91 for (
unsigned i = 0;
i < recocandidates.size(); ++
i) {
92 double pt = recocandidates.at(
i)->pt();
97 track =
dynamic_cast<const reco::Track*
>(recocandidates.at(i_maxpt)->bestTrack());
103 std::vector<reco::RecoChargedCandidateRef> recocandidates;
105 if ((!recocandidates.empty())) {
107 unsigned i_maxpt = 0;
108 for (
unsigned i = 0;
i < recocandidates.size(); ++
i) {
109 double pt = recocandidates.at(
i)->pt();
114 track =
dynamic_cast<const reco::Track*
>(recocandidates.at(i_maxpt)->bestTrack());
120 if ((trackHandle.
isValid()) && (!trackHandle->empty())) {
122 unsigned i_maxpt = 0;
123 for (
unsigned i = 0;
i < trackHandle->size(); ++
i) {
124 double pt = trackHandle->ptrAt(
i)->pt();
136 vertexPoint.SetZ(vertexPoint.z() +
track->dz(vertexPoint));
138 vertexPoint.SetZ(
track->vz());
155 edm::LogInfo(
"PVDebugInfo") <<
"Vertices by VertexFromTrackProducer: \n";
156 for (reco::VertexCollection::const_iterator v = vColl.begin(); v != vColl.end(); ++
v) {
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 ";
172 desc.
add<
bool>(
"isRecoCandidate",
false)
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");
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");
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");
187 ->setComment(
"Name of muon filter");
188 desc.
add<
bool>(
"useBeamSpot",
true)->setComment(
"Use beam spot for x/y vertex position");
190 desc.
add<
bool>(
"useVertex",
true)
191 ->setComment(
"Use vertex for x/y vertex position (beam spot is used when PV does not exit)");
194 desc.
addUntracked<
bool>(
"verbose",
false)->setComment(
"Switch on/off verbosity");
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);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double zError() const
error on z
tuple triggerFilterElectronsSrc
std::vector< Vertex > VertexCollection
collection of Vertex objects
Log< level::Error, false > LogError
const Point & position() const
position
const edm::EDGetTokenT< reco::BeamSpot > beamSpotLabel
const edm::EDGetTokenT< edm::View< reco::RecoCandidate > > candidateToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc
const bool fUseTriggerFilterElectrons
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const bool fIsRecoCandidate
Log< level::Info, false > LogInfo
void setComment(std::string const &value)
tuple triggerFilterMuonsSrc
double xError() const
error on x
XYZPointD XYZPoint
point in space with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< edm::View< reco::Track > > trackToken
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc
const Point & position() const
position
const bool fUseTriggerFilterMuons
VertexFromTrackProducer(const edm::ParameterSet &)
double yError() const
error on y
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< edm::View< reco::Vertex > > vertexLabel
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)