81 vertexAssociator_(pset.getParameter<edm::
ParameterSet>(
"qualityCuts"),std::
move(iC)),
135 bool isMatchedByBlockElement(
const reco::PFCandidate& pfCandidate1,
const reco::PFCandidate& pfCandidate2,
int minMatches1,
int minMatches2,
int maxUnmatchedBlockElements1plus2)
138 int numBlocks1 = blockElements1.size();
140 int numBlocks2 = blockElements2.size();
141 int numBlocks_matched = 0;
142 for ( reco::PFCandidate::ElementsInBlocks::const_iterator blockElement1 = blockElements1.begin();
143 blockElement1 != blockElements1.end(); ++blockElement1 ) {
145 for ( reco::PFCandidate::ElementsInBlocks::const_iterator blockElement2 = blockElements2.begin();
146 blockElement2 != blockElements2.end(); ++blockElement2 ) {
147 if ( blockElement1->first.id() == blockElement2->first.id() &&
148 blockElement1->first.key() == blockElement2->first.key() &&
149 blockElement1->second == blockElement2->second ) {
153 if ( isMatched ) ++numBlocks_matched;
155 assert(numBlocks_matched <= numBlocks1);
156 assert(numBlocks_matched <= numBlocks2);
157 if ( numBlocks_matched >= minMatches1 && numBlocks_matched >= minMatches2 &&
158 ((numBlocks1 - numBlocks_matched) + (numBlocks2 - numBlocks_matched)) <= maxUnmatchedBlockElements1plus2 ) {
169 edm::LogPrint(
"TauChHadronFromPF") <<
"<PFRecoTauChargedHadronFromPFCandidatePlugin::operator()>:";
179 for ( PFCandPtrs::iterator cand = candsVector.begin();
180 cand != candsVector.end(); ++cand ) {
182 edm::LogPrint(
"TauChHadronFromPF") <<
"processing PFCandidate: Pt = " << (*cand)->pt() <<
", eta = " << (*cand)->eta() <<
", phi = " << (*cand)->phi()
183 <<
" (type = " << getPFCandidateType((*cand)->particleId()) <<
", charge = " << (*cand)->charge() <<
")" ;
190 if ( (*cand)->trackRef().isNonnull() ) chargedHadron->track_ =
edm::refToPtr((*cand)->trackRef());
191 else if ( (*cand)->muonRef().isNonnull() && (*cand)->muonRef()->innerTrack().isNonnull() ) chargedHadron->track_ =
edm::refToPtr((*cand)->muonRef()->innerTrack());
192 else if ( (*cand)->muonRef().isNonnull() && (*cand)->muonRef()->globalTrack().isNonnull() ) chargedHadron->track_ =
edm::refToPtr((*cand)->muonRef()->globalTrack());
193 else if ( (*cand)->muonRef().isNonnull() && (*cand)->muonRef()->outerTrack().isNonnull() ) chargedHadron->track_ =
edm::refToPtr((*cand)->muonRef()->outerTrack());
194 else if ( (*cand)->gsfTrackRef().isNonnull() ) chargedHadron->track_ =
edm::refToPtr((*cand)->gsfTrackRef());
195 chargedHadron->chargedPFCandidate_ = (*cand);
196 chargedHadron->addDaughter(*cand);
198 chargedHadron->positionAtECALEntrance_ = (*cand)->positionAtECALEntrance();
204 for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
205 jetConstituent != jetConstituents.end(); ++jetConstituent ) {
207 if ( (*jetConstituent) == chargedHadron->chargedPFCandidate_ )
continue;
212 double dR =
deltaR((*jetConstituent)->positionAtECALEntrance(), chargedHadron->positionAtECALEntrance_);
213 double dRmerge = -1.;
214 int minBlockElementMatches = 1000;
215 int maxUnmatchedBlockElements = 0;
216 double minMergeEt = 1.e+6;
234 if ( (*jetConstituent)->et() > minMergeEt &&
235 (dR < dRmerge || isMatchedByBlockElement(**jetConstituent, *chargedHadron->chargedPFCandidate_, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) ) {
236 chargedHadron->neutralPFCandidates_.push_back(*jetConstituent);
237 chargedHadron->addDaughter(*jetConstituent);
248 if ( chargedHadron->daughterPtr(0).isNonnull() ) chargedHadron->setVertex(chargedHadron->daughterPtr(0)->vertex());
249 output.push_back(chargedHadron);
252 return output.release();
T getParameter(std::string const &) const
RecoTauVertexAssociator vertexAssociator_
return_type operator()(const reco::PFJet &) const
Build a collection of chargedHadrons from objects in the input jet.
ParticleType
particle types
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of PFCandidates.
std::vector< reco::PFCandidatePtr > PFCandPtrs
double dRmergePhotonWrtElectron_
RecoTauQualityCuts * qcuts_
double dRmergePhotonWrtOther_
PFRecoTauChargedHadronFromPFCandidatePlugin(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
reco::VertexRef associatedVertex(const PFJet &jet) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void setEvent(const edm::Event &evt)
Load the vertices from the event.
int minBlockElementMatchesNeutralHadron_
int maxUnmatchedBlockElementsPhoton_
double deltaR(const T1 &t1, const T2 &t2)
double minMergeChargedHadronPt_
virtual ~PFRecoTauChargedHadronFromPFCandidatePlugin()
int maxUnmatchedBlockElementsNeutralHadron_
boost::ptr_vector< PFRecoTauChargedHadron > ChargedHadronVector
Jets made from PFObjects.
std::vector< ElementInBlock > ElementsInBlocks
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
PFRecoTauChargedHadronAlgorithm
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
bool isMatched(TrackingRecHit const &hit)
double dRmergeNeutralHadronWrtChargedHadron_
int minBlockElementMatchesPhoton_
const edm::Event * evt() const
ParameterSet const & getParameterSet(std::string const &) const
std::auto_ptr< ChargedHadronVector > return_type
double dRmergePhotonWrtChargedHadron_
double dRmergeNeutralHadronWrtNeutralHadron_
double dRmergeNeutralHadronWrtOther_
Particle reconstructed by the particle flow algorithm.
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
#define DEFINE_EDM_PLUGIN(factory, type, name)
virtual void beginEvent()
Hook called at the beginning of the event.
double dRmergeNeutralHadronWrtElectron_
double minMergeNeutralHadronEt_
const std::string & name() const
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
const ElementsInBlocks & elementsInBlocks() const
std::vector< int > inputPdgIds_
double dRmergePhotonWrtNeutralHadron_