43 #include <boost/ptr_container/ptr_vector.hpp> 44 #include <boost/ptr_container/ptr_list.hpp> 64 void print(
const T& chargedHadrons);
91 std::auto_ptr<StringCutObjectSelector<reco::PFRecoTauChargedHadron> >
outputSelector_;
108 for ( edm::VParameterSet::const_iterator
pset = psets_builders.begin();
109 pset != psets_builders.end(); ++
pset ) {
118 for ( edm::VParameterSet::const_iterator
pset = psets_rankers.begin();
119 pset != psets_rankers.end(); ++
pset ) {
131 if ( !selection.empty() ) {
135 produces<reco::PFJetChargedHadronAssociation>();
141 edm::LogPrint(
"PFRecoTauChHProducer")<<
"<PFRecoTauChargedHadronProducer::produce>:" ;
147 builder.setup(evt, es);
156 size_t nElements = jets->
size();
157 for (
size_t i = 0;
i < nElements; ++
i) {
162 std::unique_ptr<reco::PFJetChargedHadronAssociation> pfJetChargedHadronAssociations;
165 if ( !pfJets.
empty() ) {
166 pfJetChargedHadronAssociations = std::make_unique<reco::PFJetChargedHadronAssociation>(
reco::JetRefBaseProd(jets));
168 pfJetChargedHadronAssociations = std::make_unique<reco::PFJetChargedHadronAssociation>();
172 for(
const auto& pfJet : pfJets ) {
181 for(
auto const& builder : builders_ ) {
185 edm::LogPrint(
"PFRecoTauChHProducer")<<
"result of builder = " << builder.name() <<
":" ;
188 uncleanedChargedHadrons.transfer(uncleanedChargedHadrons.end(),
result);
191 <<
"Exception caught in builder plugin " << builder.name()
192 <<
", rethrowing" << std::endl;
201 std::vector<reco::PFRecoTauChargedHadron> cleanedChargedHadrons;
204 typedef std::pair<double, double> etaPhiPair;
205 std::list<etaPhiPair> tracksInCleanCollection;
206 std::set<reco::CandidatePtr> neutralPFCandsInCleanCollection;
208 while ( !uncleanedChargedHadrons.empty() ) {
211 std::auto_ptr<reco::PFRecoTauChargedHadron> nextChargedHadron(uncleanedChargedHadrons.pop_front().release());
213 edm::LogPrint(
"PFRecoTauChHProducer")<<
"processing nextChargedHadron:" ;
214 edm::LogPrint(
"PFRecoTauChHProducer")<< (*nextChargedHadron);
221 if ( nextChargedHadron->getChargedPFCandidate().isNonnull() ) {
231 if ( nextChargedHadron->getTrack().isNonnull() && !
track ) {
232 track = nextChargedHadron->getTrack().get();
236 bool isTrack_overlap =
false;
238 double track_eta = track->
eta();
239 double track_phi = track->
phi();
240 for ( std::list<etaPhiPair>::const_iterator trackInCleanCollection = tracksInCleanCollection.begin();
241 trackInCleanCollection != tracksInCleanCollection.end(); ++trackInCleanCollection ) {
242 double dR =
deltaR(track_eta, track_phi, trackInCleanCollection->first, trackInCleanCollection->second);
243 if ( dR < 1.
e-4 ) isTrack_overlap =
true;
247 edm::LogPrint(
"PFRecoTauChHProducer")<<
"isTrack_overlap = " << isTrack_overlap ;
249 if ( isTrack_overlap )
continue;
252 bool isNeutralPFCand_overlap =
false;
254 for ( std::set<reco::CandidatePtr>::const_iterator neutralPFCandInCleanCollection = neutralPFCandsInCleanCollection.begin();
255 neutralPFCandInCleanCollection != neutralPFCandsInCleanCollection.end(); ++neutralPFCandInCleanCollection ) {
256 if ( (*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate() ) isNeutralPFCand_overlap =
true;
261 edm::LogPrint(
"PFRecoTauChHProducer")<<
"isNeutralPFCand_overlap = " << isNeutralPFCand_overlap ;
263 if ( isNeutralPFCand_overlap )
continue;
266 std::vector<reco::CandidatePtr> uniqueNeutralPFCands;
267 std::set_difference(nextChargedHadron->getNeutralPFCandidates().begin(),
268 nextChargedHadron->getNeutralPFCandidates().end(),
269 neutralPFCandsInCleanCollection.begin(),
270 neutralPFCandsInCleanCollection.end(),
271 std::back_inserter(uniqueNeutralPFCands));
273 if ( uniqueNeutralPFCands.size() == nextChargedHadron->getNeutralPFCandidates().size() ) {
274 if ( track ) tracksInCleanCollection.push_back(std::make_pair(track->
eta(), track->
phi()));
275 neutralPFCandsInCleanCollection.insert(nextChargedHadron->getNeutralPFCandidates().begin(), nextChargedHadron->getNeutralPFCandidates().end());
277 edm::LogPrint(
"PFRecoTauChHProducer")<<
"--> adding nextChargedHadron to output collection." ;
279 cleanedChargedHadrons.push_back(*nextChargedHadron);
281 nextChargedHadron->neutralPFCandidates_.clear();
282 for(
auto const& neutralPFCand : uniqueNeutralPFCands ) {
283 nextChargedHadron->neutralPFCandidates_.push_back(neutralPFCand);
289 ChargedHadronList::iterator insertionPoint =
std::lower_bound(uncleanedChargedHadrons.begin(), uncleanedChargedHadrons.end(), *nextChargedHadron, *
predicate_);
291 edm::LogPrint(
"PFRecoTauChHProducer")<<
"--> removing non-unique neutral PFCandidates and reinserting nextChargedHadron in uncleaned collection." ;
293 uncleanedChargedHadrons.insert(insertionPoint, nextChargedHadron);
298 print(cleanedChargedHadrons);
302 pfJetChargedHadronAssociations->setValue(pfJet.key(), cleanedChargedHadrons);
308 template <
typename T>
311 for (
typename T::const_iterator
chargedHadron = chargedHadrons.begin();
315 for ( rankerList::const_iterator ranker =
rankers_.begin();
316 ranker !=
rankers_.end(); ++ranker) {
317 const unsigned width = 25;
318 edm::LogPrint(
"PFRecoTauChHProducer") <<
" " << std::setiosflags(std::ios::left) << std::setw(width) << ranker->name()
319 <<
" " << std::resetiosflags(std::ios::left) << std::setprecision(3) << (*ranker)(*chargedHadron) << std::endl;
331 desc_ranking.
add<
double>(
"selectionFailValue", 1000.0);
332 desc_ranking.
add<
std::string>(
"selection",
"algoIs(\"kChargedPFCandidate\")");
334 desc_ranking.
add<
std::string>(
"plugin",
"PFRecoTauChargedHadronStringQuality");
338 pset_ranking.addParameter<
double>(
"selectionFailValue", 1000.0);
339 pset_ranking.addParameter<
std::string>(
"selection",
"algoIs(\"kChargedPFCandidate\")");
340 pset_ranking.addParameter<
std::string>(
"name",
"ChargedPFCandidate");
341 pset_ranking.addParameter<
std::string>(
"plugin",
"PFRecoTauChargedHadronStringQuality");
342 std::vector<edm::ParameterSet> vpsd_ranking;
343 vpsd_ranking.push_back(pset_ranking);
345 desc.
addVPSet(
"ranking", desc_ranking, vpsd_ranking);
348 desc.
add<
int>(
"verbosity", 0);
349 desc.
add<
double>(
"maxJetAbsEta", 2.5);
351 desc.
add<
double>(
"minJetPt", 14.0);
356 desc_builders.
add<
double>(
"minMergeChargedHadronPt");
360 desc_builders.
addOptional<
bool>(
"dRconeLimitedToJetArea");
361 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadron");
362 desc_builders.
addOptional<
double>(
"dRmergePhoton");
367 pset_signalQualityCuts.
add<
double>(
"maxDeltaZ", 0.4);
368 pset_signalQualityCuts.
add<
double>(
"minTrackPt", 0.5);
369 pset_signalQualityCuts.
add<
double>(
"minTrackVertexWeight", -1.0);
370 pset_signalQualityCuts.
add<
double>(
"maxTrackChi2", 100.0);
371 pset_signalQualityCuts.
add<
unsigned int>(
"minTrackPixelHits", 0);
372 pset_signalQualityCuts.
add<
double>(
"minGammaEt", 1.0);
373 pset_signalQualityCuts.
add<
unsigned int>(
"minTrackHits", 3);
374 pset_signalQualityCuts.
add<
double>(
"minNeutralHadronEt", 30.0);
375 pset_signalQualityCuts.
add<
double>(
"maxTransverseImpactParameter", 0.1);
376 pset_signalQualityCuts.
addOptional<
bool>(
"useTracksInsteadOfPFHadrons");
379 pset_vxAssocQualityCuts.
add<
double>(
"minTrackPt", 0.5);
380 pset_vxAssocQualityCuts.add<
double>(
"minTrackVertexWeight", -1.0);
381 pset_vxAssocQualityCuts.add<
double>(
"maxTrackChi2", 100.0);
382 pset_vxAssocQualityCuts.add<
unsigned int>(
"minTrackPixelHits", 0);
383 pset_vxAssocQualityCuts.add<
double>(
"minGammaEt", 1.0);
384 pset_vxAssocQualityCuts.add<
unsigned int>(
"minTrackHits", 3);
385 pset_vxAssocQualityCuts.add<
double>(
"maxTransverseImpactParameter", 0.1);
386 pset_vxAssocQualityCuts.addOptional<
bool>(
"useTracksInsteadOfPFHadrons");
389 pset_isolationQualityCuts.
add<
double>(
"maxDeltaZ", 0.2);
390 pset_isolationQualityCuts.add<
double>(
"minTrackPt", 1.0);
391 pset_isolationQualityCuts.add<
double>(
"minTrackVertexWeight", -1.0);
392 pset_isolationQualityCuts.add<
double>(
"maxTrackChi2", 100.0);
393 pset_isolationQualityCuts.add<
unsigned int>(
"minTrackPixelHits", 0);
394 pset_isolationQualityCuts.add<
double>(
"minGammaEt", 1.5);
395 pset_isolationQualityCuts.add<
unsigned int>(
"minTrackHits", 8);
396 pset_isolationQualityCuts.add<
double>(
"maxTransverseImpactParameter", 0.03);
397 pset_isolationQualityCuts.addOptional<
bool>(
"useTracksInsteadOfPFHadrons");
403 pset_qualityCuts.
add<
std::string>(
"leadingTrkOrPFCandOption",
"leadPFCand");
404 pset_qualityCuts.add<
std::string>(
"pvFindingAlgo",
"closestInDeltaZ");
406 pset_qualityCuts.add<
bool>(
"vertexTrackFiltering",
false);
407 pset_qualityCuts.add<
bool>(
"recoverLeadingTrk",
false);
412 desc_builders.
add<
double>(
"minMergeGammaEt");
413 desc_builders.
add<
int>(
"verbosity", 0);
414 desc_builders.
add<
double>(
"minMergeNeutralHadronEt");
416 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtChargedHadron");
417 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtNeutralHadron");
418 desc_builders.
addOptional<
int>(
"maxUnmatchedBlockElementsNeutralHadron");
419 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtElectron");
420 desc_builders.
addOptional<std::vector<int>>(
"chargedHadronCandidatesParticleIds");
421 desc_builders.
addOptional<
int>(
"minBlockElementMatchesPhoton");
422 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtNeutralHadron");
423 desc_builders.
addOptional<
int>(
"maxUnmatchedBlockElementsPhoton");
424 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtOther");
425 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtElectron");
426 desc_builders.
addOptional<
int>(
"minBlockElementMatchesNeutralHadron");
427 desc_builders.
addOptional<
double>(
"dRmergePhotonWrtOther");
428 desc_builders.
addOptional<
double>(
"dRmergeNeutralHadronWrtChargedHadron");
432 pset_builders.addParameter<
std::string>(
"plugin",
"");
436 std::vector<edm::ParameterSet> vpsd_builders;
437 vpsd_builders.push_back(pset_builders);
439 desc.
addVPSet(
"builders", desc_builders, vpsd_builders);
442 descriptions.
add(
"pfRecoTauChargedHadronProducer", desc);
T getParameter(std::string const &) const
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
bool isNonnull() const
Checks for non-null.
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
def create(alignables, pedeDump, additionalData, outputFile, config)
reco::tau::RecoTauLexicographicalRanking< rankerList, reco::PFRecoTauChargedHadron > ChargedHadronPredicate
boost::ptr_vector< Ranker > rankerList
bool getByToken(EDGetToken token, Handle< PROD > &result) const
PFRecoTauChargedHadronProducer(const edm::ParameterSet &cfg)
std::vector< ParameterSet > VParameterSet
double phi() const
azimuthal angle of momentum vector
void produce(edm::Event &evt, const edm::EventSetup &es) override
reco::TrackRef trackRef() const
RefToBase< value_type > refAt(size_type i) const
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
void print(const T &chargedHadrons)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
double eta() const
pseudorapidity of momentum vector
reco::tau::PFRecoTauChargedHadronBuilderPlugin Builder
boost::ptr_vector< reco::PFRecoTauChargedHadron > ChargedHadronVector
std::auto_ptr< ChargedHadronPredicate > predicate_
void addParameter(std::string const &name, T const &value)
Abs< T >::type abs(const T &t)
T const * get() const
Returns C++ pointer to the item.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
boost::ptr_vector< Builder > builderList
reco::MuonRef muonRef() const
reco::tau::PFRecoTauChargedHadronQualityPlugin Ranker
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::auto_ptr< StringCutObjectSelector< reco::PFRecoTauChargedHadron > > outputSelector_
boost::ptr_list< reco::PFRecoTauChargedHadron > ChargedHadronList
~PFRecoTauChargedHadronProducer() override
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
void push_back(const RefToBase< T > &)
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
T get(const Candidate &c)