28 trackToken( consumes<edm::
View<
reco::Track> >(conf.getParameter<edm::
InputTag>(
"trackLabel")) ),
29 candidateToken( consumes<edm::
View<
reco::RecoCandidate> >(conf.getParameter<edm::
InputTag>(
"trackLabel")) ),
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) )
42 <<
"Initializing VertexFromTrackProducer" <<
"\n";
44 produces<reco::VertexCollection>();
65 bool vertexAvailable =
false;
70 if (recoBeamSpotHandle.isValid()){
74 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot found in Event";
82 if ((recoVertexHandle.
isValid()) && (recoVertexHandle->size()>0)){
85 vertexAvailable =
true;
88 <<
"No vertex found in Event, beam spot used instaed" <<
"\n";
97 if ((candidateHandle.
isValid())&&(candidateHandle->size()>0)){
100 for (
unsigned i = 0;
i < candidateHandle->size(); ++
i) {
101 double pt=candidateHandle->ptrAt(
i)->pt();
108 track =
dynamic_cast<const reco::Track*
>(candidateHandle->ptrAt(i_maxpt)->bestTrack());
114 std::vector<reco::ElectronRef> recocandidates;
116 if ((recocandidates.size()>0)){
119 for (
unsigned i = 0;
i < recocandidates.size(); ++
i) {
120 double pt=recocandidates.at(
i)->pt();
126 track =
dynamic_cast<const reco::Track*
>(recocandidates.at(i_maxpt)->bestTrack());
133 std::vector<reco::RecoChargedCandidateRef> recocandidates;
135 if ((recocandidates.size()>0)){
138 for (
unsigned i = 0;
i < recocandidates.size(); ++
i) {
139 double pt=recocandidates.at(
i)->pt();
145 track =
dynamic_cast<const reco::Track*
>(recocandidates.at(i_maxpt)->bestTrack());
152 if ((trackHandle.
isValid())&&(trackHandle->size()>0)){
155 for (
unsigned i = 0;
i < trackHandle->size(); ++
i) {
156 double pt=trackHandle->ptrAt(
i)->pt();
163 track =
dynamic_cast<const reco::Track*
>(&*trackHandle->ptrAt(i_maxpt));
169 vertexPoint.SetZ(vertexPoint.z()+track->dz(vertexPoint));
172 vertexPoint.SetZ(track->vz());
189 edm::LogInfo(
"PVDebugInfo")<<
"Vertices by VertexFromTrackProducer: \n";
190 for(reco::VertexCollection::const_iterator v=vColl.begin();
191 v!=vColl.end(); ++
v){
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()
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");
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");
222 desc.
add<
bool>(
"useBeamSpot",
true)->setComment(
"Use beam spot for x/y vertex position");
224 desc.
add<
bool>(
"useVertex",
true)->setComment(
"Use vertex for x/y vertex position (beam spot is used when PV does not exit)");
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);
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
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
const bool fUseTriggerFilterElectrons
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const bool fIsRecoCandidate
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
volatile std::atomic< bool > shutdown_flag false
VertexFromTrackProducer(const edm::ParameterSet &)
~VertexFromTrackProducer()
double yError() const
error on y
virtual 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)