43 #include <boost/ptr_container/ptr_vector.hpp>
44 #include <boost/ptr_container/ptr_list.hpp>
63 void print(
const T& chargedHadrons);
90 std::unique_ptr<StringCutObjectSelector<reco::PFRecoTauChargedHadron>>
outputSelector_;
97 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
106 for (edm::VParameterSet::const_iterator
pset = psets_builders.begin();
pset != psets_builders.end(); ++
pset) {
116 for (edm::VParameterSet::const_iterator
pset = psets_rankers.begin();
pset != psets_rankers.end(); ++
pset) {
132 produces<reco::PFJetChargedHadronAssociation>();
137 edm::LogPrint(
"PFRecoTauChHProducer") <<
"<PFRecoTauChargedHadronProducer::produce>:";
143 builder.setup(evt, es);
152 size_t nElements =
jets->size();
153 for (
size_t i = 0;
i < nElements; ++
i) {
158 std::unique_ptr<reco::PFJetChargedHadronAssociation> pfJetChargedHadronAssociations;
163 pfJetChargedHadronAssociations = std::make_unique<reco::PFJetChargedHadronAssociation>();
167 for (
const auto& pfJet :
pfJets) {
181 edm::LogPrint(
"PFRecoTauChHProducer") <<
"result of builder = " << builder.name() <<
":";
184 uncleanedChargedHadrons.transfer(uncleanedChargedHadrons.end(),
result);
187 <<
"Exception caught in builder plugin " << builder.name() <<
", rethrowing" << std::endl;
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(uncleanedChargedHadrons.pop_front().release());
207 edm::LogPrint(
"PFRecoTauChHProducer") <<
"processing nextChargedHadron:";
208 edm::LogPrint(
"PFRecoTauChHProducer") << (*nextChargedHadron);
216 if (nextChargedHadron->getChargedPFCandidate().isNonnull()) {
218 dynamic_cast<const reco::PFCandidate*>(&*nextChargedHadron->getChargedPFCandidate());
232 if (nextChargedHadron->getTrack().isNonnull() && !
track) {
233 track = nextChargedHadron->getTrack().get();
237 bool isTrack_overlap =
false;
239 double track_eta =
track->eta();
240 double track_phi =
track->phi();
241 for (std::list<etaPhiPair>::const_iterator trackInCleanCollection = tracksInCleanCollection.begin();
242 trackInCleanCollection != tracksInCleanCollection.end();
243 ++trackInCleanCollection) {
244 double dR =
deltaR(track_eta, track_phi, trackInCleanCollection->first, trackInCleanCollection->second);
246 isTrack_overlap =
true;
250 edm::LogPrint(
"PFRecoTauChHProducer") <<
"isTrack_overlap = " << isTrack_overlap;
256 bool isNeutralPFCand_overlap =
false;
258 for (std::set<reco::CandidatePtr>::const_iterator neutralPFCandInCleanCollection =
259 neutralPFCandsInCleanCollection.begin();
260 neutralPFCandInCleanCollection != neutralPFCandsInCleanCollection.end();
261 ++neutralPFCandInCleanCollection) {
262 if ((*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate())
263 isNeutralPFCand_overlap =
true;
267 edm::LogPrint(
"PFRecoTauChHProducer") <<
"isNeutralPFCand_overlap = " << isNeutralPFCand_overlap;
269 if (isNeutralPFCand_overlap)
273 std::vector<reco::CandidatePtr> uniqueNeutralPFCands;
274 std::set_difference(nextChargedHadron->getNeutralPFCandidates().begin(),
275 nextChargedHadron->getNeutralPFCandidates().end(),
276 neutralPFCandsInCleanCollection.begin(),
277 neutralPFCandsInCleanCollection.end(),
278 std::back_inserter(uniqueNeutralPFCands));
280 if (uniqueNeutralPFCands.size() ==
281 nextChargedHadron->getNeutralPFCandidates()
284 tracksInCleanCollection.push_back(std::make_pair(
track->eta(),
track->phi()));
285 neutralPFCandsInCleanCollection.insert(nextChargedHadron->getNeutralPFCandidates().begin(),
286 nextChargedHadron->getNeutralPFCandidates().end());
288 edm::LogPrint(
"PFRecoTauChHProducer") <<
"--> adding nextChargedHadron to output collection.";
290 cleanedChargedHadrons.push_back(*nextChargedHadron);
292 nextChargedHadron->neutralPFCandidates_.clear();
293 for (
auto const& neutralPFCand : uniqueNeutralPFCands) {
294 nextChargedHadron->neutralPFCandidates_.push_back(neutralPFCand);
301 uncleanedChargedHadrons.begin(), uncleanedChargedHadrons.end(), *nextChargedHadron, *
predicate_);
303 edm::LogPrint(
"PFRecoTauChHProducer") <<
"--> removing non-unique neutral PFCandidates and reinserting "
304 "nextChargedHadron in uncleaned collection.";
306 uncleanedChargedHadrons.insert(insertionPoint,
std::move(nextChargedHadron));
311 print(cleanedChargedHadrons);
315 pfJetChargedHadronAssociations->setValue(pfJet.key(), cleanedChargedHadrons);
321 template <
typename T>
327 for (rankerList::const_iterator ranker =
rankers_.begin(); ranker !=
rankers_.end(); ++ranker) {
328 const unsigned width = 25;
330 <<
" " << std::setiosflags(std::ios::left) << std::setw(
width) << ranker->name() <<
" "
331 << std::resetiosflags(std::ios::left) << std::setprecision(3) << (*ranker)(*chargedHadron) << std::endl;
342 desc_ranking.
add<
double>(
"selectionFailValue", 1000.0);
343 desc_ranking.
add<
std::string>(
"selection",
"algoIs(\"kChargedPFCandidate\")");
345 desc_ranking.
add<
std::string>(
"plugin",
"PFRecoTauChargedHadronStringQuality");
349 pset_ranking.addParameter<
double>(
"selectionFailValue", 1000.0);
350 pset_ranking.addParameter<
std::string>(
"selection",
"algoIs(\"kChargedPFCandidate\")");
351 pset_ranking.addParameter<
std::string>(
"name",
"ChargedPFCandidate");
352 pset_ranking.addParameter<
std::string>(
"plugin",
"PFRecoTauChargedHadronStringQuality");
353 std::vector<edm::ParameterSet> vpsd_ranking;
354 vpsd_ranking.push_back(pset_ranking);
356 desc.
addVPSet(
"ranking", desc_ranking, vpsd_ranking);
359 desc.
add<
int>(
"verbosity", 0);
360 desc.
add<
double>(
"maxJetAbsEta", 2.5);
362 desc.
add<
double>(
"minJetPt", 14.0);
367 desc_builders.
add<
double>(
"minMergeChargedHadronPt");
371 desc_builders.
addOptional<
bool>(
"dRconeLimitedToJetArea");
372 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadron");
373 desc_builders.
addOptional<
double>(
"dRmergePhoton");
378 pset_signalQualityCuts.
add<
double>(
"maxDeltaZ", 0.4);
379 pset_signalQualityCuts.
add<
double>(
"minTrackPt", 0.5);
380 pset_signalQualityCuts.
add<
double>(
"minTrackVertexWeight", -1.0);
381 pset_signalQualityCuts.
add<
double>(
"maxTrackChi2", 100.0);
382 pset_signalQualityCuts.
add<
unsigned int>(
"minTrackPixelHits", 0);
383 pset_signalQualityCuts.
add<
double>(
"minGammaEt", 1.0);
384 pset_signalQualityCuts.
add<
unsigned int>(
"minTrackHits", 3);
385 pset_signalQualityCuts.
add<
double>(
"minNeutralHadronEt", 30.0);
386 pset_signalQualityCuts.
add<
double>(
"maxTransverseImpactParameter", 0.1);
387 pset_signalQualityCuts.
addOptional<
bool>(
"useTracksInsteadOfPFHadrons");
390 pset_vxAssocQualityCuts.
add<
double>(
"minTrackPt", 0.5);
391 pset_vxAssocQualityCuts.add<
double>(
"minTrackVertexWeight", -1.0);
392 pset_vxAssocQualityCuts.add<
double>(
"maxTrackChi2", 100.0);
393 pset_vxAssocQualityCuts.add<
unsigned int>(
"minTrackPixelHits", 0);
394 pset_vxAssocQualityCuts.add<
double>(
"minGammaEt", 1.0);
395 pset_vxAssocQualityCuts.add<
unsigned int>(
"minTrackHits", 3);
396 pset_vxAssocQualityCuts.add<
double>(
"maxTransverseImpactParameter", 0.1);
397 pset_vxAssocQualityCuts.addOptional<
bool>(
"useTracksInsteadOfPFHadrons");
400 pset_isolationQualityCuts.
add<
double>(
"maxDeltaZ", 0.2);
401 pset_isolationQualityCuts.add<
double>(
"minTrackPt", 1.0);
402 pset_isolationQualityCuts.add<
double>(
"minTrackVertexWeight", -1.0);
403 pset_isolationQualityCuts.add<
double>(
"maxTrackChi2", 100.0);
404 pset_isolationQualityCuts.add<
unsigned int>(
"minTrackPixelHits", 0);
405 pset_isolationQualityCuts.add<
double>(
"minGammaEt", 1.5);
406 pset_isolationQualityCuts.add<
unsigned int>(
"minTrackHits", 8);
407 pset_isolationQualityCuts.add<
double>(
"maxTransverseImpactParameter", 0.03);
408 pset_isolationQualityCuts.addOptional<
bool>(
"useTracksInsteadOfPFHadrons");
414 pset_qualityCuts.
add<
std::string>(
"leadingTrkOrPFCandOption",
"leadPFCand");
415 pset_qualityCuts.add<
std::string>(
"pvFindingAlgo",
"closestInDeltaZ");
417 pset_qualityCuts.add<
bool>(
"vertexTrackFiltering",
false);
418 pset_qualityCuts.add<
bool>(
"recoverLeadingTrk",
false);
423 desc_builders.
add<
double>(
"minMergeGammaEt");
424 desc_builders.
add<
int>(
"verbosity", 0);
425 desc_builders.
add<
double>(
"minMergeNeutralHadronEt");
427 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtChargedHadron");
428 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtNeutralHadron");
429 desc_builders.
addOptional<
int>(
"maxUnmatchedBlockElementsNeutralHadron");
430 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtElectron");
431 desc_builders.
addOptional<std::vector<int>>(
"chargedHadronCandidatesParticleIds");
432 desc_builders.
addOptional<
int>(
"minBlockElementMatchesPhoton");
433 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtNeutralHadron");
434 desc_builders.
addOptional<
int>(
"maxUnmatchedBlockElementsPhoton");
435 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtOther");
436 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtElectron");
437 desc_builders.
addOptional<
int>(
"minBlockElementMatchesNeutralHadron");
438 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtOther");
439 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtChargedHadron");
443 pset_builders.addParameter<
std::string>(
"plugin",
"");
447 std::vector<edm::ParameterSet> vpsd_builders;
448 vpsd_builders.push_back(pset_builders);
450 desc.
addVPSet(
"builders", desc_builders, vpsd_builders);
453 descriptions.
add(
"pfRecoTauChargedHadronProducer", desc);