15 if (mode ==
"firstVertex") {
17 }
else if (mode ==
"nearestToCandidate") {
19 }
else if (mode ==
"fromCandidate") {
21 }
else if (mode ==
"beamSpot") {
24 throw cms::Exception(
"Configuration") <<
"PATSingleVertexSelector: Mode '" << mode <<
"' not recognized or not supported.\n";
30 vtxPreselection_( iConfig.existsAs<std::
string>(
"vertexPreselection") ? iConfig.getParameter<std::
string>(
"vertexPreselection") : std::
string(
" 1 == 1 ") ),
31 candPreselection_( iConfig.existsAs<std::
string>(
"candidatePreselection") ? iConfig.getParameter<std::
string>(
"candidatePreselection") : std::
string(
" 1 == 1 ") ),
32 doFilterEvents_(
false)
37 if (iConfig.
exists(
"fallbacks")) {
38 vector<string> modes = iConfig.
getParameter<vector<string> >(
"fallbacks");
39 for (vector<string>::const_iterator it = modes.begin(), ed = modes.end(); it != ed; ++it) {
53 if ( iConfig.exists(
"filter") )
doFilterEvents_ = iConfig.getParameter<
bool>(
"filter");
55 produces<vector<reco::Vertex> >();
80 for (vector<reco::Vertex>::const_iterator itv = vertices->begin(), edv = vertices->end(); itv != edv; ++itv) {
87 vector<pair<double, reco::CandidatePtr> > cands;
96 if (!cands.empty())
bestCand_ = cands.front().second;
100 auto_ptr<vector<reco::Vertex> >
result;
102 for (std::vector<Mode>::const_iterator itm =
modes_.begin(), endm =
modes_.end(); itm != endm; ++itm) {
117 std::auto_ptr<std::vector<reco::Vertex> >
121 std::auto_ptr<std::vector<reco::Vertex> >
result(
new std::vector<reco::Vertex>());
124 if (
selVtxs_.empty())
return result;
125 result->push_back(*
selVtxs_.front());
137 result->push_back(vtx);
143 float dzmin = 9999.0;
144 for (
auto itv =
selVtxs_.begin(), edv =
selVtxs_.end(); itv != edv; ++itv) {
146 if (dz < dzmin) { dzmin = dz; which = *itv; }
149 result->push_back(*which);
155 reco::Vertex bs(beamSpot->position(), beamSpot->covariance3D(), 0, 0, 0);
156 result->push_back(bs);
T getParameter(std::string const &) const
Produces a list containing a single vertex selected by some criteria.
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
bool isNonnull() const
Checks for non-null.
const VtxSel vtxPreselection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
bool hasMode_(Mode mode) const
std::auto_ptr< std::vector< reco::Vertex > > filter_(Mode mode, const edm::Event &iEvent, const edm::EventSetup &iSetup)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::EDGetTokenT< std::vector< reco::Vertex > > verticesToken_
math::Error< dimension >::type Error
covariance error matrix (3x3)
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
~PATSingleVertexSelector()
std::vector< reco::VertexRef > selVtxs_
reco::CandidatePtr bestCand_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Mode parseMode(const std::string &name) const
bool isNull() const
Checks for null.
Abs< T >::type abs(const T &t)
const CandSel candPreselection_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > candidatesToken_
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &iSetup) override
PATSingleVertexSelector(const edm::ParameterSet &iConfig)
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
volatile std::atomic< bool > shutdown_flag false
std::vector< Mode > modes_