135 edm::LogPrint(
"PFRecoTauChHProducer") <<
"<PFRecoTauChargedHadronProducer::produce>:";
141 builder->setup(evt, es);
150 size_t nElements =
jets->size();
151 for (
size_t i = 0;
i < nElements; ++
i) {
156 std::unique_ptr<reco::PFJetChargedHadronAssociation> pfJetChargedHadronAssociations;
161 pfJetChargedHadronAssociations = std::make_unique<reco::PFJetChargedHadronAssociation>();
165 for (
const auto& pfJet :
pfJets) {
179 edm::LogPrint(
"PFRecoTauChHProducer") <<
"result of builder = " << builder->name() <<
":";
180 for (
auto const& had :
result) {
187 <<
"Exception caught in builder plugin " << builder->name() <<
", rethrowing" << std::endl;
193 uncleanedChargedHadrons.sort([
this](
const auto&
a,
const auto&
b) {
return (*
predicate_)(*
a, *
b); });
196 std::vector<reco::PFRecoTauChargedHadron> cleanedChargedHadrons;
199 typedef std::pair<double, double> etaPhiPair;
200 std::list<etaPhiPair> tracksInCleanCollection;
201 std::set<reco::CandidatePtr> neutralPFCandsInCleanCollection;
203 while (!uncleanedChargedHadrons.empty()) {
205 std::unique_ptr<reco::PFRecoTauChargedHadron> nextChargedHadron =
std::move(uncleanedChargedHadrons.front());
206 uncleanedChargedHadrons.pop_front();
208 edm::LogPrint(
"PFRecoTauChHProducer") <<
"processing nextChargedHadron:";
209 edm::LogPrint(
"PFRecoTauChHProducer") << (*nextChargedHadron);
219 bool isTrack_overlap =
false;
221 double track_eta =
track->eta();
222 double track_phi =
track->phi();
223 for (std::list<etaPhiPair>::const_iterator trackInCleanCollection = tracksInCleanCollection.begin();
224 trackInCleanCollection != tracksInCleanCollection.end();
225 ++trackInCleanCollection) {
226 double dR =
deltaR(track_eta, track_phi, trackInCleanCollection->first, trackInCleanCollection->second);
228 isTrack_overlap =
true;
232 edm::LogPrint(
"PFRecoTauChHProducer") <<
"isTrack_overlap = " << isTrack_overlap;
238 bool isNeutralPFCand_overlap =
false;
240 for (std::set<reco::CandidatePtr>::const_iterator neutralPFCandInCleanCollection =
241 neutralPFCandsInCleanCollection.begin();
242 neutralPFCandInCleanCollection != neutralPFCandsInCleanCollection.end();
243 ++neutralPFCandInCleanCollection) {
244 if ((*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate())
245 isNeutralPFCand_overlap =
true;
249 edm::LogPrint(
"PFRecoTauChHProducer") <<
"isNeutralPFCand_overlap = " << isNeutralPFCand_overlap;
251 if (isNeutralPFCand_overlap)
255 std::vector<reco::CandidatePtr> uniqueNeutralPFCands;
257 nextChargedHadron->getNeutralPFCandidates().end(),
258 neutralPFCandsInCleanCollection.begin(),
259 neutralPFCandsInCleanCollection.end(),
260 std::back_inserter(uniqueNeutralPFCands));
262 if (uniqueNeutralPFCands.size() ==
263 nextChargedHadron->getNeutralPFCandidates()
266 tracksInCleanCollection.push_back(std::make_pair(
track->eta(),
track->phi()));
267 neutralPFCandsInCleanCollection.insert(nextChargedHadron->getNeutralPFCandidates().begin(),
268 nextChargedHadron->getNeutralPFCandidates().end());
270 edm::LogPrint(
"PFRecoTauChHProducer") <<
"--> adding nextChargedHadron to output collection.";
272 cleanedChargedHadrons.push_back(*nextChargedHadron);
274 nextChargedHadron->neutralPFCandidates_.clear();
275 for (
auto const& neutralPFCand : uniqueNeutralPFCands) {
276 nextChargedHadron->neutralPFCandidates_.push_back(neutralPFCand);
283 uncleanedChargedHadrons.end(),
285 [
this](
const auto&
a,
const auto&
b) {
return (*
predicate_)(*
a,
b); });
287 edm::LogPrint(
"PFRecoTauChHProducer") <<
"--> removing non-unique neutral PFCandidates and reinserting " 288 "nextChargedHadron in uncleaned collection.";
290 uncleanedChargedHadrons.insert(insertionPoint,
std::move(nextChargedHadron));
295 for (
auto const& had : cleanedChargedHadrons) {
301 pfJetChargedHadronAssociations->setValue(pfJet.key(), cleanedChargedHadrons);
Builder::return_type ChargedHadronVector
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::JetView > Jets_token
void print(const T &chargedHadron)
std::vector< std::unique_ptr< Builder > > builders_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Log< level::Error, false > LogError
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Abs< T >::type abs(const T &t)
Log< level::Warning, true > LogPrint
std::unique_ptr< ChargedHadronPredicate > predicate_
const reco::Track * getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron &chargedHadron)
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
std::list< std::unique_ptr< reco::PFRecoTauChargedHadron > > ChargedHadronList
std::unique_ptr< StringCutObjectSelector< reco::PFRecoTauChargedHadron > > outputSelector_