24 algorithm_(iConfig.getParameter<int>(
"Algorithm")),
25 qualityCutsPSet_(iConfig.getParameter<edm::
ParameterSet>(
"qualityCuts")),
26 useBeamSpot_(iConfig.getParameter<bool>(
"useBeamSpot")),
27 useSelectedTaus_(iConfig.getParameter<bool>(
"useSelectedTaus")),
28 removeMuonTracks_(iConfig.getParameter<bool>(
"RemoveMuonTracks")),
29 removeElectronTracks_(iConfig.getParameter<bool>(
"RemoveElectronTracks")) {
32 iConfig.
getParameter<std::vector<edm::ParameterSet>>(
"discriminators");
34 for (
auto const&
pset : discriminators) {
41 newCut->
cut_ =
pset.getParameter<
double>(
"selectionCut");
48 produces<edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::VertexRef>>>();
49 produces<reco::VertexCollection>(
"PFTauPrimaryVertices");
101 auto avPFTauPV = std::make_unique<edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::VertexRef>>>(
103 auto vertexCollection_out = std::make_unique<reco::VertexCollection>();
110 disc->discr_ = &(*discr);
131 for (
auto const& disc : discriminators_) {
133 bool passedDisc =
true;
134 if (disc->cutFormula_)
135 passedDisc = (disc->cutFormula_->Eval((*disc->discr_)[tau]) > 0.5);
137 passedDisc = ((*disc->discr_)[tau] > disc->cut_);
143 if (passed &&
cut_.get()) {
144 passed = (*cut_)(*tau);
147 std::vector<edm::Ptr<reco::TrackBase>> signalTracks;
153 for (
const auto& pfcand : pfTauRef->signalChargedHadrCands()) {
158 signalTracks.push_back(trackPtr);
165 for (
const auto&
muon : *muons) {
166 if (
muon.track().isNonnull())
174 for (
const auto&
electron : *electrons) {
177 if (
electron.gsfTrack().isNonnull())
184 std::vector<const reco::Track*> nonTauTracks;
190 std::vector<reco::TransientTrack> transTracks;
191 transTracks.reserve(nonTauTracks.size());
192 for (
const auto track : nonTauTracks) {
193 transTracks.push_back(transTrackBuilder.build(*
track));
196 if (transTracks.size() >= 2) {
200 transVtx = avf.
vertex(transTracks);
202 transVtx = avf.
vertex(transTracks, *beamSpot);
208 if (!std::isfinite(transVtx.
position().
z()))
217 vertexCollection_out->push_back(thePV);
218 avPFTauPV->setValue(iPFTau, vtxRef);
221 iEvent.
put(
std::move(vertexCollection_out),
"PFTauPrimaryVertices");
232 vpsd1.
add<
double>(
"selectionCut");
233 desc.
addVPSet(
"discriminators", vpsd1);
241 desc.
add<
int>(
"Algorithm", 0);
242 desc.
add<
bool>(
"RemoveElectronTracks",
false);
243 desc.
add<
bool>(
"RemoveMuonTracks",
false);
244 desc.
add<
bool>(
"useBeamSpot",
true);
245 desc.
add<
bool>(
"useSelectedTaus",
false);
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
static void fillDescriptions(edm::ParameterSetDescription &descriptions)
Declare all parameters read from python config file.
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void nonTauTracksInPV(const reco::VertexRef &, const std::vector< edm::Ptr< reco::TrackBase > > &, std::vector< const reco::Track * > &)=0
edm::EDGetTokenT< reco::VertexCollection > pvToken_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< Vertex > VertexCollection
collection of Vertex objects
~PFTauPrimaryVertexProducerBase() override
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
std::vector< Vertex > VertexCollection
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
virtual void beginEvent(const edm::Event &, const edm::EventSetup &)
reco::TrackRef trackRef() const
bool getData(T &iHolder) const
void setWeightThreshold(float w)
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transTrackBuilderToken_
GlobalPoint position() const
edm::EDGetTokenT< std::vector< reco::PFTau > > pftauToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
RefProd< PROD > getRefBeforePut()
bool isNonnull() const
Checks for non-null.
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
bool removeElectronTracks_
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
std::unique_ptr< reco::tau::RecoTauVertexAssociator > vertexAssociator_
T getParameter(std::string const &) const
PFTauPrimaryVertexProducerBase(const edm::ParameterSet &iConfig)
static edm::ParameterSetDescription getDescriptionsBase()
Particle reconstructed by the particle flow algorithm.
DiscCutPairVec discriminators_
reco::GsfTrackRef gsfTrackRef() const
void produce(edm::Event &, const edm::EventSetup &) override
constexpr char Electron[]
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > cut_
edm::ParameterSet qualityCutsPSet_
edm::EDGetTokenT< reco::PFTauDiscriminator > inputToken_
edm::EDGetTokenT< edm::View< reco::Electron > > electronToken_