53 typedef std::vector<reco::CandidatePtr>
CandPtrs;
86 vertexAssociator_(pset.getParameter<edm::
ParameterSet>(
"qualityCuts"), std::
move(iC)),
127 int maxUnmatchedBlockElements1plus2) {
129 int numBlocks1 = blockElements1.size();
131 int numBlocks2 = blockElements2.size();
132 int numBlocks_matched = 0;
133 for (reco::PFCandidate::ElementsInBlocks::const_iterator blockElement1 = blockElements1.begin();
134 blockElement1 != blockElements1.end();
137 for (reco::PFCandidate::ElementsInBlocks::const_iterator blockElement2 = blockElements2.begin();
138 blockElement2 != blockElements2.end();
140 if (blockElement1->first.id() == blockElement2->first.id() &&
141 blockElement1->first.key() == blockElement2->first.key() &&
142 blockElement1->second == blockElement2->second) {
149 assert(numBlocks_matched <= numBlocks1);
150 assert(numBlocks_matched <= numBlocks2);
151 if (numBlocks_matched >= minMatches1 && numBlocks_matched >= minMatches2 &&
152 ((numBlocks1 - numBlocks_matched) + (numBlocks2 - numBlocks_matched)) <= maxUnmatchedBlockElements1plus2) {
163 edm::LogPrint(
"TauChHadronFromPF") <<
"<PFRecoTauChargedHadronFromPFCandidatePlugin::operator()>:";
173 for (CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand) {
176 <<
"processing PFCandidate: Pt = " << (*cand)->pt() <<
", eta = " << (*cand)->eta()
177 <<
", phi = " << (*cand)->phi() <<
" (pdgId = " << (*cand)->pdgId() <<
", charge = " << (*cand)->charge()
182 if (
std::abs((*cand)->charge()) > 0.5)
186 auto chargedHadron = std::make_unique<PFRecoTauChargedHadron>(**cand,
algo);
190 if (pfCand->trackRef().isNonnull())
192 else if (pfCand->muonRef().isNonnull() && pfCand->muonRef()->innerTrack().isNonnull())
193 chargedHadron->track_ =
edm::refToPtr(pfCand->muonRef()->innerTrack());
194 else if (pfCand->muonRef().isNonnull() && pfCand->muonRef()->globalTrack().isNonnull())
195 chargedHadron->track_ =
edm::refToPtr(pfCand->muonRef()->globalTrack());
196 else if (pfCand->muonRef().isNonnull() && pfCand->muonRef()->outerTrack().isNonnull())
197 chargedHadron->track_ =
edm::refToPtr(pfCand->muonRef()->outerTrack());
198 else if (pfCand->gsfTrackRef().isNonnull())
199 chargedHadron->track_ =
edm::refToPtr(pfCand->gsfTrackRef());
203 chargedHadron->chargedPFCandidate_ = (*cand);
204 chargedHadron->addDaughter(*cand);
206 int pdgId =
std::abs(chargedHadron->chargedPFCandidate_->pdgId());
211 if (jetConstituent == chargedHadron->chargedPFCandidate_)
214 int jetConstituentPdgId =
std::abs(jetConstituent->pdgId());
215 if (!(jetConstituentPdgId == 130 || jetConstituentPdgId == 22))
220 double dRmerge = -1.;
221 int minBlockElementMatches = 1000;
222 int maxUnmatchedBlockElements = 0;
223 double minMergeEt = 1.e+6;
224 if (jetConstituentPdgId == 130) {
227 else if (pdgId == 130)
229 else if (pdgId == 11)
236 }
else if (jetConstituentPdgId == 22) {
239 else if (pdgId == 130)
241 else if (pdgId == 11)
250 if (jetConstituent->et() > minMergeEt) {
252 chargedHadron->neutralPFCandidates_.push_back(jetConstituent);
253 chargedHadron->addDaughter(jetConstituent);
258 if (pfCand !=
nullptr && pfJetConstituent !=
nullptr) {
259 if (isMatchedByBlockElement(*pfJetConstituent,
261 minBlockElementMatches,
262 minBlockElementMatches,
263 maxUnmatchedBlockElements)) {
264 chargedHadron->neutralPFCandidates_.push_back(jetConstituent);
279 if (chargedHadron->daughterPtr(0).isNonnull())
280 chargedHadron->setVertex(chargedHadron->daughterPtr(0)->vertex());
281 output.push_back(
std::move(chargedHadron));
294 "PFRecoTauChargedHadronFromPFCandidatePlugin");
std::vector< CandidatePtr > pfCandidates(const Jet &jet, int particleId, bool sort=true)
RecoTauVertexAssociator vertexAssociator_
std::vector< std::unique_ptr< PFRecoTauChargedHadron > > ChargedHadronVector
math::XYZPointF atECALEntrance(const reco::Candidate *part, double bField)
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
return_type operator()(const reco::Jet &) const override
Build a collection of chargedHadrons from objects in the input jet.
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of Candidates.
ChargedHadronVector return_type
double dRmergePhotonWrtElectron_
Base class for all types of Jets.
RecoTauQualityCuts * qcuts_
double dRmergePhotonWrtOther_
PFRecoTauChargedHadronFromPFCandidatePlugin(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
Global3DPoint GlobalPoint
void setEvent(const edm::Event &evt)
Load the vertices from the event.
int minBlockElementMatchesNeutralHadron_
int maxUnmatchedBlockElementsPhoton_
double minMergeChargedHadronPt_
int maxUnmatchedBlockElementsNeutralHadron_
virtual const daughters & daughterPtrVector() const
references to daughtes
std::vector< ElementInBlock > ElementsInBlocks
bool getData(T &iHolder) const
PFRecoTauChargedHadronAlgorithm
Abs< T >::type abs(const T &t)
bool isMatched(TrackingRecHit const &hit)
double dRmergeNeutralHadronWrtChargedHadron_
int minBlockElementMatchesPhoton_
const edm::EventSetup * evtSetup() const
std::vector< int > inputParticleIds_
Log< level::Warning, true > LogPrint
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
std::vector< reco::CandidatePtr > CandPtrs
const edm::Event * evt() const
ParameterSet const & getParameterSet(std::string const &) const
~PFRecoTauChargedHadronFromPFCandidatePlugin() override
T getParameter(std::string const &) const
double dRmergePhotonWrtChargedHadron_
double dRmergeNeutralHadronWrtNeutralHadron_
double dRmergeNeutralHadronWrtOther_
Particle reconstructed by the particle flow algorithm.
reco::VertexRef associatedVertex(const Jet &jet) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken_
#define DEFINE_EDM_PLUGIN(factory, type, name)
double dRmergeNeutralHadronWrtElectron_
double minMergeNeutralHadronEt_
const std::string & name() const
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
const ElementsInBlocks & elementsInBlocks() const
void setPV(const reco::VertexRef &vtx)
Update the primary vertex.
void beginEvent() override
Hook called at the beginning of the event.
double dRmergePhotonWrtNeutralHadron_