88 std::unique_ptr<StringCutObjectSelector<reco::PFRecoTauChargedHadron>>
outputSelector_;
95 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
104 for (edm::VParameterSet::const_iterator
pset = psets_builders.begin();
pset != psets_builders.end(); ++
pset) {
114 for (edm::VParameterSet::const_iterator
pset = psets_rankers.begin();
pset != psets_rankers.end(); ++
pset) {
130 produces<reco::PFJetChargedHadronAssociation>();
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);
307 template <
typename T>
311 for (
auto const& ranker :
rankers_) {
314 <<
" " << std::setiosflags(std::ios::left) << std::setw(
width) << ranker->name() <<
" " 315 << std::resetiosflags(std::ios::left) << std::setprecision(3) << (*ranker)(
chargedHadron) << std::endl;
325 desc_ranking.
add<
double>(
"selectionFailValue", 1000.0);
326 desc_ranking.
add<
std::string>(
"selection",
"algoIs(\"kChargedPFCandidate\")");
328 desc_ranking.
add<
std::string>(
"plugin",
"PFRecoTauChargedHadronStringQuality");
332 pset_ranking.addParameter<
double>(
"selectionFailValue", 1000.0);
333 pset_ranking.addParameter<
std::string>(
"selection",
"algoIs(\"kChargedPFCandidate\")");
334 pset_ranking.addParameter<
std::string>(
"name",
"ChargedPFCandidate");
335 pset_ranking.addParameter<
std::string>(
"plugin",
"PFRecoTauChargedHadronStringQuality");
336 std::vector<edm::ParameterSet> vpsd_ranking;
337 vpsd_ranking.push_back(pset_ranking);
339 desc.addVPSet(
"ranking", desc_ranking, vpsd_ranking);
342 desc.add<
int>(
"verbosity", 0);
343 desc.add<
double>(
"maxJetAbsEta", 2.5);
345 desc.add<
double>(
"minJetPt", 14.0);
350 desc_builders.
add<
double>(
"minMergeChargedHadronPt");
354 desc_builders.
addOptional<
bool>(
"dRconeLimitedToJetArea");
355 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadron");
356 desc_builders.
addOptional<
double>(
"dRmergePhoton");
363 desc_builders.
add<
double>(
"minMergeGammaEt");
364 desc_builders.
add<
int>(
"verbosity", 0);
365 desc_builders.
add<
double>(
"minMergeNeutralHadronEt");
367 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtChargedHadron");
368 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtNeutralHadron");
369 desc_builders.
addOptional<
int>(
"maxUnmatchedBlockElementsNeutralHadron");
370 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtElectron");
371 desc_builders.
addOptional<std::vector<int>>(
"chargedHadronCandidatesParticleIds");
372 desc_builders.
addOptional<
int>(
"minBlockElementMatchesPhoton");
373 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtNeutralHadron");
374 desc_builders.
addOptional<
int>(
"maxUnmatchedBlockElementsPhoton");
375 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtOther");
376 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtElectron");
377 desc_builders.
addOptional<
int>(
"minBlockElementMatchesNeutralHadron");
378 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtOther");
379 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtChargedHadron");
383 pset_builders.addParameter<
std::string>(
"plugin",
"");
387 std::vector<edm::ParameterSet> vpsd_builders;
388 vpsd_builders.push_back(pset_builders);
390 desc.addVPSet(
"builders", desc_builders, vpsd_builders);
393 descriptions.
add(
"pfRecoTauChargedHadronProducer",
desc);
Builder::return_type ChargedHadronVector
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::EDGetTokenT< reco::JetView > Jets_token
static void fillDescriptions(edm::ParameterSetDescription &descriptions)
Declare all parameters read from python config file.
def create(alignables, pedeDump, additionalData, outputFile, config)
void print(const T &chargedHadron)
ChargedHadronVector return_type
PFRecoTauChargedHadronProducer(const edm::ParameterSet &cfg)
std::vector< ParameterSet > VParameterSet
std::vector< std::unique_ptr< Builder > > builders_
void produce(edm::Event &evt, const edm::EventSetup &es) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Log< level::Error, false > LogError
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
reco::tau::PFRecoTauChargedHadronBuilderPlugin Builder
reco::tau::RecoTauLexicographicalRanking< RankerList, reco::PFRecoTauChargedHadron > ChargedHadronPredicate
void addParameter(std::string const &name, T const &value)
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
std::vector< std::unique_ptr< Ranker > > RankerList
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Warning, true > LogPrint
reco::tau::PFRecoTauChargedHadronQualityPlugin Ranker
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::unique_ptr< ChargedHadronPredicate > predicate_
~PFRecoTauChargedHadronProducer() override
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_