CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
PFRecoTauChargedHadronProducer Class Reference
Inheritance diagram for PFRecoTauChargedHadronProducer:
edm::stream::EDProducer<>

Public Types

typedef reco::tau::PFRecoTauChargedHadronBuilderPlugin Builder
 
typedef reco::tau::PFRecoTauChargedHadronQualityPlugin Ranker
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 PFRecoTauChargedHadronProducer (const edm::ParameterSet &cfg)
 
template<typename T >
void print (const T &chargedHadrons)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 ~PFRecoTauChargedHadronProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef boost::ptr_vector< BuilderbuilderList
 
typedef boost::ptr_list< reco::PFRecoTauChargedHadronChargedHadronList
 
typedef reco::tau::RecoTauLexicographicalRanking< rankerList, reco::PFRecoTauChargedHadronChargedHadronPredicate
 
typedef boost::ptr_vector< reco::PFRecoTauChargedHadronChargedHadronVector
 
typedef boost::ptr_vector< RankerrankerList
 

Private Attributes

builderList builders_
 
edm::EDGetTokenT< reco::JetViewJets_token
 
double maxJetAbsEta_
 
double minJetPt_
 
std::string moduleLabel_
 
std::auto_ptr< StringCutObjectSelector< reco::PFRecoTauChargedHadron > > outputSelector_
 
std::auto_ptr< ChargedHadronPredicatepredicate_
 
rankerList rankers_
 
edm::InputTag srcJets_
 
int verbosity_
 

Detailed Description

Definition at line 54 of file PFRecoTauChargedHadronProducer.cc.

Member Typedef Documentation

Definition at line 57 of file PFRecoTauChargedHadronProducer.cc.

typedef boost::ptr_vector<Builder> PFRecoTauChargedHadronProducer::builderList
private

Definition at line 69 of file PFRecoTauChargedHadronProducer.cc.

Definition at line 72 of file PFRecoTauChargedHadronProducer.cc.

Definition at line 74 of file PFRecoTauChargedHadronProducer.cc.

Definition at line 71 of file PFRecoTauChargedHadronProducer.cc.

Definition at line 58 of file PFRecoTauChargedHadronProducer.cc.

typedef boost::ptr_vector<Ranker> PFRecoTauChargedHadronProducer::rankerList
private

Definition at line 70 of file PFRecoTauChargedHadronProducer.cc.

Constructor & Destructor Documentation

PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 97 of file PFRecoTauChargedHadronProducer.cc.

References edm::ParameterSet::addParameter(), builders_, beamerCreator::create(), reco::get(), edm::ParameterSet::getParameter(), Jets_token, maxJetAbsEta_, minJetPt_, outputSelector_, predicate_, muonDTDigis_cfi::pset, rankers_, corrVsCorr::selection, srcJets_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

98  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
99 {
100  srcJets_ = cfg.getParameter<edm::InputTag>("jetSrc");
101  Jets_token = consumes<reco::JetView>(srcJets_);
102  minJetPt_ = cfg.getParameter<double>("minJetPt");
103  maxJetAbsEta_ = cfg.getParameter<double>("maxJetAbsEta");
104  verbosity_ = cfg.getParameter<int>("verbosity");
105 
106  // get set of ChargedHadron builder plugins
107  edm::VParameterSet psets_builders = cfg.getParameter<edm::VParameterSet>("builders");
108  for ( edm::VParameterSet::const_iterator pset = psets_builders.begin();
109  pset != psets_builders.end(); ++pset ) {
110  std::string pluginType = pset->getParameter<std::string>("plugin");
111  edm::ParameterSet pset_modified = (*pset);
112  pset_modified.addParameter<int>("verbosity", verbosity_);
113  builders_.push_back(PFRecoTauChargedHadronBuilderPluginFactory::get()->create(pluginType, pset_modified, consumesCollector()));
114  }
115 
116  // get set of plugins for ranking ChargedHadrons in quality
117  edm::VParameterSet psets_rankers = cfg.getParameter<edm::VParameterSet>("ranking");
118  for ( edm::VParameterSet::const_iterator pset = psets_rankers.begin();
119  pset != psets_rankers.end(); ++pset ) {
120  std::string pluginType = pset->getParameter<std::string>("plugin");
121  edm::ParameterSet pset_modified = (*pset);
122  pset_modified.addParameter<int>("verbosity", verbosity_);
123  rankers_.push_back(PFRecoTauChargedHadronQualityPluginFactory::get()->create(pluginType, pset_modified));
124  }
125 
126  // build the sorting predicate
127  predicate_ = std::auto_ptr<ChargedHadronPredicate>(new ChargedHadronPredicate(rankers_));
128 
129  // check if we want to apply a final output selection
130  std::string selection = cfg.getParameter<std::string>("outputSelection");
131  if ( !selection.empty() ) {
133  }
134 
135  produces<reco::PFJetChargedHadronAssociation>();
136 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::JetView > Jets_token
def create(alignables, pedeDump, additionalData, outputFile, config)
reco::tau::RecoTauLexicographicalRanking< rankerList, reco::PFRecoTauChargedHadron > ChargedHadronPredicate
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
selection
main part
Definition: corrVsCorr.py:100
std::auto_ptr< ChargedHadronPredicate > predicate_
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
std::auto_ptr< StringCutObjectSelector< reco::PFRecoTauChargedHadron > > outputSelector_
T get(const Candidate &c)
Definition: component.h:55
PFRecoTauChargedHadronProducer::~PFRecoTauChargedHadronProducer ( )
inlineoverride

Definition at line 61 of file PFRecoTauChargedHadronProducer.cc.

References fillDescriptions(), print(), and produce().

61 {}

Member Function Documentation

void PFRecoTauChargedHadronProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 325 of file PFRecoTauChargedHadronProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSet::addParameter(), edm::ParameterSetDescription::addVPSet(), DEFINE_FWK_MODULE, CaloRecoTauDiscriminationByFlightPathSignificance_cfi::qualityCuts, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~PFRecoTauChargedHadronProducer().

325  {
326  // ak4PFJetsRecoTauChargedHadrons
328  {
329  edm::ParameterSetDescription desc_ranking;
330  desc_ranking.add<std::string>("selectionPassFunction", "-pt");
331  desc_ranking.add<double>("selectionFailValue", 1000.0);
332  desc_ranking.add<std::string>("selection", "algoIs(\"kChargedPFCandidate\")");
333  desc_ranking.add<std::string>("name", "ChargedPFCandidate");
334  desc_ranking.add<std::string>("plugin", "PFRecoTauChargedHadronStringQuality");
335 
336  edm::ParameterSet pset_ranking;
337  pset_ranking.addParameter<std::string>("selectionPassFunction", "-pt");
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);
344 
345  desc.addVPSet("ranking", desc_ranking, vpsd_ranking);
346  }
347 
348  desc.add<int>("verbosity", 0);
349  desc.add<double>("maxJetAbsEta", 2.5);
350  desc.add<std::string>("outputSelection", "pt > 0.5");
351  desc.add<double>("minJetPt", 14.0);
352  desc.add<edm::InputTag>("jetSrc", edm::InputTag("ak4PFJets"));
353 
354  {
355  edm::ParameterSetDescription desc_builders;
356  desc_builders.add<double>("minMergeChargedHadronPt");
357  desc_builders.add<std::string>("name");
358  desc_builders.add<std::string>("plugin");
359  desc_builders.addOptional<double>("dRcone");
360  desc_builders.addOptional<bool>("dRconeLimitedToJetArea");
361  desc_builders.addOptional<double>("dRmergeNeutralHadron");
362  desc_builders.addOptional<double>("dRmergePhoton");
363  desc_builders.addOptional<edm::InputTag>("srcTracks");
364 
365  {
366  edm::ParameterSetDescription pset_signalQualityCuts;
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");
377 
378  edm::ParameterSetDescription pset_vxAssocQualityCuts;
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");
387 
388  edm::ParameterSetDescription pset_isolationQualityCuts;
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");
398 
399  edm::ParameterSetDescription pset_qualityCuts;
400  pset_qualityCuts.add<edm::ParameterSetDescription>("signalQualityCuts", pset_signalQualityCuts);
401  pset_qualityCuts.add<edm::ParameterSetDescription>("vxAssocQualityCuts", pset_vxAssocQualityCuts);
402  pset_qualityCuts.add<edm::ParameterSetDescription>("isolationQualityCuts", pset_isolationQualityCuts);
403  pset_qualityCuts.add<std::string>("leadingTrkOrPFCandOption", "leadPFCand");
404  pset_qualityCuts.add<std::string>("pvFindingAlgo", "closestInDeltaZ");
405  pset_qualityCuts.add<edm::InputTag>("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices"));
406  pset_qualityCuts.add<bool>("vertexTrackFiltering", false);
407  pset_qualityCuts.add<bool>("recoverLeadingTrk", false);
408 
409  desc_builders.add<edm::ParameterSetDescription>("qualityCuts", pset_qualityCuts);
410  }
411 
412  desc_builders.add<double>("minMergeGammaEt");
413  desc_builders.add<int>("verbosity", 0);
414  desc_builders.add<double>("minMergeNeutralHadronEt");
415 
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");
429 
430  edm::ParameterSet pset_builders;
431  pset_builders.addParameter<std::string>("name","");
432  pset_builders.addParameter<std::string>("plugin","");
434  pset_builders.addParameter<edm::ParameterSet>("qualityCuts",qualityCuts);
435  pset_builders.addParameter<int>("verbosity",0);
436  std::vector<edm::ParameterSet> vpsd_builders;
437  vpsd_builders.push_back(pset_builders);
438 
439  desc.addVPSet("builders", desc_builders, vpsd_builders);
440  }
441 
442  descriptions.add("pfRecoTauChargedHadronProducer", desc);
443 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename T >
void PFRecoTauChargedHadronProducer::print ( const T chargedHadrons)

Definition at line 309 of file PFRecoTauChargedHadronProducer.cc.

References muons2muons_cfi::chargedHadron, rankers_, and ApeEstimator_cff::width.

Referenced by produce(), and ~PFRecoTauChargedHadronProducer().

310 {
311  for ( typename T::const_iterator chargedHadron = chargedHadrons.begin();
312  chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
313  edm::LogPrint("PFRecoTauChHProducer") << (*chargedHadron);
314  edm::LogPrint("PFRecoTauChHProducer") << "Rankers:" ;
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;
320  }
321  }
322 }
void PFRecoTauChargedHadronProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 138 of file PFRecoTauChargedHadronProducer.cc.

References funct::abs(), builders_, boostedElectronIsolation_cff::deltaR, MillePedeFileConverter_cfg::e, edm::RefToBaseVector< T >::empty(), reco::TrackBase::eta(), cppFunctionSkipper::exception, edm::Ref< C, T, F >::get(), edm::Event::getByToken(), reco::PFCandidate::gsfTrackRef(), mps_fire::i, edm::Ref< C, T, F >::isNonnull(), fwrapper::jets, Jets_token, reco::PFRecoTauChargedHadron::kPFNeutralHadron, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, maxJetAbsEta_, minJetPt_, moduleLabel_, eostools::move(), reco::PFCandidate::muonRef(), outputSelector_, pfJetBenchmark_cfi::pfJets, reco::TrackBase::phi(), predicate_, print(), edm::RefToBaseVector< T >::push_back(), edm::Event::put(), edm::View< T >::refAt(), mps_fire::result, reco::tau::setChargedHadronP4(), edm::View< T >::size(), HiIsolationCommonParameters_cff::track, reco::PFCandidate::trackRef(), and verbosity_.

Referenced by ~PFRecoTauChargedHadronProducer().

139 {
140  if ( verbosity_ ) {
141  edm::LogPrint("PFRecoTauChHProducer")<< "<PFRecoTauChargedHadronProducer::produce>:" ;
142  edm::LogPrint("PFRecoTauChHProducer")<< " moduleLabel = " << moduleLabel_ ;
143  }
144 
145  // give each of our plugins a chance at doing something with the edm::Event
146  for(auto& builder : builders_ ) {
147  builder.setup(evt, es);
148  }
149 
150  // get a view of our jets via the base candidates
152  evt.getByToken(Jets_token, jets);
153 
154  // convert the view to a RefVector of actual PFJets
156  size_t nElements = jets->size();
157  for (size_t i = 0; i < nElements; ++i) {
158  pfJets.push_back(jets->refAt(i));
159  }
160 
161  // make our association
162  std::unique_ptr<reco::PFJetChargedHadronAssociation> pfJetChargedHadronAssociations;
163 
164 
165  if ( !pfJets.empty() ) {
166  pfJetChargedHadronAssociations = std::make_unique<reco::PFJetChargedHadronAssociation>(reco::JetRefBaseProd(jets));
167  } else {
168  pfJetChargedHadronAssociations = std::make_unique<reco::PFJetChargedHadronAssociation>();
169  }
170 
171  // loop over our jets
172  for(const auto& pfJet : pfJets ) {
173 
174  if(pfJet->pt() - minJetPt_ < 1e-5) continue;
175  if(std::abs(pfJet->eta()) - maxJetAbsEta_ > -1e-5) continue;
176 
177  // build global list of ChargedHadron candidates for each jet
178  ChargedHadronList uncleanedChargedHadrons;
179 
180  // merge candidates reconstructed by all desired algorithm plugins
181  for(auto const& builder : builders_ ) {
182  try {
183  ChargedHadronVector result(builder(*pfJet));
184  if ( verbosity_ ) {
185  edm::LogPrint("PFRecoTauChHProducer")<< "result of builder = " << builder.name() << ":" ;
186  print(result);
187  }
188  uncleanedChargedHadrons.transfer(uncleanedChargedHadrons.end(), result);
189  } catch ( cms::Exception& exception ) {
190  edm::LogError("BuilderPluginException")
191  << "Exception caught in builder plugin " << builder.name()
192  << ", rethrowing" << std::endl;
193  throw exception;
194  }
195  }
196 
197  // rank the candidates according to our quality plugins
198  uncleanedChargedHadrons.sort(*predicate_);
199 
200  // define collection of cleaned ChargedHadrons;
201  std::vector<reco::PFRecoTauChargedHadron> cleanedChargedHadrons;
202 
203  // keep track of neutral PFCandidates, charged PFCandidates and tracks "used" by ChargedHadron candidates in the clean collection
204  typedef std::pair<double, double> etaPhiPair;
205  std::list<etaPhiPair> tracksInCleanCollection;
206  std::set<reco::CandidatePtr> neutralPFCandsInCleanCollection;
207 
208  while ( !uncleanedChargedHadrons.empty() ) {
209 
210  // get next best ChargedHadron candidate
211  std::auto_ptr<reco::PFRecoTauChargedHadron> nextChargedHadron(uncleanedChargedHadrons.pop_front().release());
212  if ( verbosity_ ) {
213  edm::LogPrint("PFRecoTauChHProducer")<< "processing nextChargedHadron:" ;
214  edm::LogPrint("PFRecoTauChHProducer")<< (*nextChargedHadron);
215  }
216 
217  // discard candidates which fail final output selection
218  if ( !(*outputSelector_)(*nextChargedHadron) ) continue;
219 
220  const reco::Track* track = nullptr;
221  if ( nextChargedHadron->getChargedPFCandidate().isNonnull() ) {
222  const reco::PFCandidate* chargedPFCand = dynamic_cast<const reco::PFCandidate*> (&*nextChargedHadron->getChargedPFCandidate());
223  if (chargedPFCand) {
224  if ( chargedPFCand->trackRef().isNonnull() ) track = chargedPFCand->trackRef().get();
225  else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->innerTrack().isNonnull() ) track = chargedPFCand->muonRef()->innerTrack().get();
226  else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->globalTrack().isNonnull() ) track = chargedPFCand->muonRef()->globalTrack().get();
227  else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->outerTrack().isNonnull() ) track = chargedPFCand->muonRef()->outerTrack().get();
228  else if ( chargedPFCand->gsfTrackRef().isNonnull() ) track = chargedPFCand->gsfTrackRef().get();
229  }
230  }
231  if ( nextChargedHadron->getTrack().isNonnull() && !track ) {
232  track = nextChargedHadron->getTrack().get();
233  }
234 
235  // discard candidate in case its track is "used" by any ChargedHadron in the clean collection
236  bool isTrack_overlap = false;
237  if ( track ) {
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;
244  }
245  }
246  if ( verbosity_ ) {
247  edm::LogPrint("PFRecoTauChHProducer")<< "isTrack_overlap = " << isTrack_overlap ;
248  }
249  if ( isTrack_overlap ) continue;
250 
251  // discard ChargedHadron candidates without track in case they are close to neutral PFCandidates "used" by ChargedHadron candidates in the clean collection
252  bool isNeutralPFCand_overlap = false;
253  if ( nextChargedHadron->algoIs(reco::PFRecoTauChargedHadron::kPFNeutralHadron) ) {
254  for ( std::set<reco::CandidatePtr>::const_iterator neutralPFCandInCleanCollection = neutralPFCandsInCleanCollection.begin();
255  neutralPFCandInCleanCollection != neutralPFCandsInCleanCollection.end(); ++neutralPFCandInCleanCollection ) {
256  if ( (*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate() ) isNeutralPFCand_overlap = true;
257 
258  }
259  }
260  if ( verbosity_ ) {
261  edm::LogPrint("PFRecoTauChHProducer")<< "isNeutralPFCand_overlap = " << isNeutralPFCand_overlap ;
262  }
263  if ( isNeutralPFCand_overlap ) continue;
264 
265  // find neutral PFCandidates that are not "used" by any ChargedHadron in the clean collection
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));
272 
273  if ( uniqueNeutralPFCands.size() == nextChargedHadron->getNeutralPFCandidates().size() ) { // all neutral PFCandidates are unique, add ChargedHadron candidate to clean collection
274  if ( track ) tracksInCleanCollection.push_back(std::make_pair(track->eta(), track->phi()));
275  neutralPFCandsInCleanCollection.insert(nextChargedHadron->getNeutralPFCandidates().begin(), nextChargedHadron->getNeutralPFCandidates().end());
276  if ( verbosity_ ) {
277  edm::LogPrint("PFRecoTauChHProducer")<< "--> adding nextChargedHadron to output collection." ;
278  }
279  cleanedChargedHadrons.push_back(*nextChargedHadron);
280  } else { // remove overlapping neutral PFCandidates, reevaluate ranking criterion and process ChargedHadron candidate again
281  nextChargedHadron->neutralPFCandidates_.clear();
282  for(auto const& neutralPFCand : uniqueNeutralPFCands ) {
283  nextChargedHadron->neutralPFCandidates_.push_back(neutralPFCand);
284  }
285  // update ChargedHadron four-momentum
286  reco::tau::setChargedHadronP4(*nextChargedHadron);
287  // reinsert ChargedHadron candidate into list of uncleaned candidates,
288  // at position according to new rank
289  ChargedHadronList::iterator insertionPoint = std::lower_bound(uncleanedChargedHadrons.begin(), uncleanedChargedHadrons.end(), *nextChargedHadron, *predicate_);
290  if ( verbosity_ ) {
291  edm::LogPrint("PFRecoTauChHProducer")<< "--> removing non-unique neutral PFCandidates and reinserting nextChargedHadron in uncleaned collection." ;
292  }
293  uncleanedChargedHadrons.insert(insertionPoint, nextChargedHadron);
294  }
295  }
296 
297  if ( verbosity_ ) {
298  print(cleanedChargedHadrons);
299  }
300 
301  // add ChargedHadron-to-jet association
302  pfJetChargedHadronAssociations->setValue(pfJet.key(), cleanedChargedHadrons);
303  }
304 
305  evt.put(std::move(pfJetChargedHadronAssociations));
306 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::EDGetTokenT< reco::JetView > Jets_token
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
size_type size() const
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:684
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
RefToBase< value_type > refAt(size_type i) const
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Definition: JetCollection.h:14
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:690
boost::ptr_vector< reco::PFRecoTauChargedHadron > ChargedHadronVector
std::auto_ptr< ChargedHadronPredicate > predicate_
vector< PseudoJet > jets
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:459
std::auto_ptr< StringCutObjectSelector< reco::PFRecoTauChargedHadron > > outputSelector_
boost::ptr_list< reco::PFRecoTauChargedHadron > ChargedHadronList
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:480
void push_back(const RefToBase< T > &)
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

builderList PFRecoTauChargedHadronProducer::builders_
private

Definition at line 85 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().

edm::EDGetTokenT<reco::JetView> PFRecoTauChargedHadronProducer::Jets_token
private

Definition at line 80 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().

double PFRecoTauChargedHadronProducer::maxJetAbsEta_
private

Definition at line 82 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().

double PFRecoTauChargedHadronProducer::minJetPt_
private

Definition at line 81 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().

std::string PFRecoTauChargedHadronProducer::moduleLabel_
private
std::auto_ptr<StringCutObjectSelector<reco::PFRecoTauChargedHadron> > PFRecoTauChargedHadronProducer::outputSelector_
private

Definition at line 91 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().

std::auto_ptr<ChargedHadronPredicate> PFRecoTauChargedHadronProducer::predicate_
private

Definition at line 88 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().

rankerList PFRecoTauChargedHadronProducer::rankers_
private

Definition at line 86 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and print().

edm::InputTag PFRecoTauChargedHadronProducer::srcJets_
private

Definition at line 79 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer().

int PFRecoTauChargedHadronProducer::verbosity_
private

Definition at line 94 of file PFRecoTauChargedHadronProducer.cc.

Referenced by PFRecoTauChargedHadronProducer(), and produce().