50 #include <boost/foreach.hpp> 61 enum Alg{useInputPV=0, useFontPV};
98 std::auto_ptr<StringCutObjectSelector<reco::PFTau> >
cut_;
103 PFTauTag_(iConfig.getParameter<
edm::
InputTag>(
"PFTauTag")),
104 PFTauToken_(consumes<
std::vector<
reco::
PFTau> >(PFTauTag_)),
105 ElectronTag_(iConfig.getParameter<
edm::
InputTag>(
"ElectronTag")),
107 MuonTag_(iConfig.getParameter<
edm::
InputTag>(
"MuonTag")),
108 MuonToken_(consumes<
std::vector<
reco::
Muon> >(MuonTag_)),
109 PVTag_(iConfig.getParameter<
edm::
InputTag>(
"PVTag")),
111 beamSpotTag_(iConfig.getParameter<
edm::
InputTag>(
"beamSpot")),
113 TrackCollectionTag_(iConfig.getParameter<
edm::
InputTag>(
"TrackCollectionTag")),
115 Algorithm_(iConfig.getParameter<
int>(
"Algorithm")),
116 qualityCutsPSet_(iConfig.getParameter<
edm::
ParameterSet>(
"qualityCuts")),
117 useBeamSpot_(iConfig.getParameter<
bool>(
"useBeamSpot")),
118 useSelectedTaus_(iConfig.getParameter<
bool>(
"useSelectedTaus")),
119 RemoveMuonTracks_(iConfig.getParameter<
bool>(
"RemoveMuonTracks")),
120 RemoveElectronTracks_(iConfig.getParameter<
bool>(
"RemoveElectronTracks"))
136 produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::VertexRef> > >();
137 produces<VertexCollection>(
"PFTauPrimaryVertices");
168 auto AVPFTauPV = std::make_unique<edm::AssociationVector<PFTauRefProd, std::vector<reco::VertexRef>>>(
PFTauRefProd(Tau));
169 auto VertexCollection_out = std::make_unique<VertexCollection>();
199 bool passedDisc =
true;
201 else passedDisc = ((*disc->
discr_)[tau] > disc->
cut_);
202 if ( !passedDisc ){passed =
false;
break;}
204 if (passed &&
cut_.get()){passed = (*cut_)(*tau);}
206 std::vector<reco::TrackBaseRef> SignalTracks;
212 const std::vector<edm::Ptr<reco::PFCandidate> > cands = RefPFTau->signalPFChargedHadrCands();
214 if(iter->get()->trackRef().isNonnull()) SignalTracks.push_back(
reco::TrackBaseRef(iter->get()->trackRef()));
215 else if(iter->get()->gsfTrackRef().isNonnull()){SignalTracks.push_back(
reco::TrackBaseRef(((iter)->
get()->gsfTrackRef())));}
256 for(std::vector<reco::TrackBaseRef>::const_iterator vtxTrkRef=thePV.
tracks_begin();vtxTrkRef<thePV.
tracks_end();vtxTrkRef++){
258 for (
unsigned int sigTrk = 0; sigTrk < SignalTracks.size(); sigTrk++) {
259 if ( (*vtxTrkRef) == SignalTracks[sigTrk] ) {
263 if ( !matched ) nonTauTracks.push_back(**vtxTrkRef);
268 std::vector<reco::TransientTrack> transTracks;
269 for (reco::TrackCollection::iterator iter=nonTauTracks.begin(); iter!=nonTauTracks.end(); ++iter){
270 transTracks.push_back(transTrackBuilder->
build(*iter));
273 if ( transTracks.size() >= 2 ) {
278 transVtx = avf.
vertex(transTracks);
280 transVtx = avf.
vertex(transTracks, *beamSpot);
285 }
else FitOk =
false;
286 if ( FitOk ) thePV = transVtx;
289 VertexCollection_out->push_back(thePV);
290 AVPFTauPV->setValue(iPFTau, VRef);
293 iEvent.
put(
std::move(VertexCollection_out),
"PFTauPrimaryVertices");
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
const reco::PFTauDiscriminator * discr_
DiscCutPairVec discriminators_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
~PFTauPrimaryVertexProducer() override
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
trackRef_iterator tracks_end() const
last iterator over tracks
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::ParameterSet qualityCutsPSet_
PFTauPrimaryVertexProducer
edm::EDGetTokenT< reco::PFTauDiscriminator > inputToken_
edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
std::vector< Track > TrackCollection
collection of Tracks
reco::TransientTrack build(const reco::Track *p) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
edm::EDGetTokenT< reco::VertexCollection > PVToken_
void setWeightThreshold(float w)
edm::InputTag ElectronTag_
edm::EDGetTokenT< std::vector< reco::Muon > > MuonToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
edm::EDGetTokenT< reco::TrackCollection > TrackCollectionToken_
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
RefProd< PROD > getRefBeforePut()
bool RemoveElectronTracks_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > cut_
std::vector< DiscCutPair * > DiscCutPairVec
PFTauPrimaryVertexProducer(const edm::ParameterSet &iConfig)
edm::InputTag TrackCollectionTag_
edm::InputTag beamSpotTag_
trackRef_iterator tracks_begin() const
first iterator over tracks
edm::EDGetTokenT< std::vector< reco::Electron > > ElectronToken_