CMS 3D CMS Logo

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

Public Member Functions

 BoostedTauSeedsProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~BoostedTauSeedsProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef edm::AssociationMap< edm::OneToMany< std::vector< reco::PFJet >, std::vector< reco::PFCandidate >, unsigned int > > JetToPFCandidateAssociation
 
typedef edm::View< reco::JetJetView
 

Private Attributes

bool correctlyExcludeOverlap_
 
std::string moduleLabel_
 
edm::EDGetTokenT< reco::PFCandidateCollectionsrcPFCandidates_
 
edm::EDGetTokenT< JetViewsrcSubjets_
 
int verbosity_
 

Additional Inherited Members

- 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
 

Detailed Description

Definition at line 43 of file BoostedTauSeedsProducer.cc.

Member Typedef Documentation

Definition at line 51 of file BoostedTauSeedsProducer.cc.

Definition at line 55 of file BoostedTauSeedsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 63 of file BoostedTauSeedsProducer.cc.

References correctlyExcludeOverlap_, gather_cfg::cout, reco::deltaR2(), reco::PFCandidate::e, reco::PFCandidate::egamma_HF, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), edm::ParameterSet::exists(), reco::PFCandidate::gamma, reco::Jet::getJetConstituents(), edm::ParameterSet::getParameter(), reco::PFCandidate::h, reco::PFCandidate::h0, reco::PFCandidate::h_HF, training_settings::idx, TopAnalysis_sequences::invert, metsig::jet, reco::Jet::jetArea(), label, reco::PFJet::Specific::mChargedEmEnergy, reco::PFJet::Specific::mChargedHadronEnergy, reco::PFJet::Specific::mChargedMuEnergy, reco::PFJet::Specific::mChargedMultiplicity, reco::PFJet::Specific::mMuonMultiplicity, reco::PFJet::Specific::mNeutralEmEnergy, reco::PFJet::Specific::mNeutralHadronEnergy, reco::PFJet::Specific::mNeutralMultiplicity, reco::PFCandidate::mu, reco::btau::muonMultiplicity, reco::LeafCandidate::p4(), reco::PFCandidate::particleId(), patMuonMerger_cfi::pfCandidates, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), reco::Jet::setJetArea(), srcPFCandidates_, srcSubjets_, AlCaHLTBitMon_QueryRunRegistry::string, verbosity_, and reco::LeafCandidate::vertex().

64  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
65  srcSubjets_ = consumes<JetView>(cfg.getParameter<edm::InputTag>("subjetSrc"));
66  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("pfCandidateSrc"));
67 
68  correctlyExcludeOverlap_ = (cfg.exists("correctlyExcludeOverlap")) ? cfg.getParameter<bool>("correctlyExcludeOverlap") : false;
70  edm::LogWarning("") << "The \"correctlyExcludeOverlap\" flag set to \"False\":\n"
71  << "=> module is working in a buggy backward compatibility mode; is it intended?";
72  }
73 
74  verbosity_ = (cfg.exists("verbosity")) ? cfg.getParameter<int>("verbosity") : 0;
75 
76  produces<reco::PFJetCollection>();
77  produces<JetToPFCandidateAssociation>("pfCandAssocMapForIsolation");
78  //produces<JetToPFCandidateAssociation>("pfCandAssocMapForIsoDepositVetos");
79 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
edm::EDGetTokenT< JetView > srcSubjets_
BoostedTauSeedsProducer::~BoostedTauSeedsProducer ( )
inlineoverride

Definition at line 46 of file BoostedTauSeedsProducer.cc.

References produce().

46 {}

Member Function Documentation

void BoostedTauSeedsProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 194 of file BoostedTauSeedsProducer.cc.

References edm::View< T >::at(), correctlyExcludeOverlap_, gather_cfg::cout, DEFINE_FWK_MODULE, reco::LeafCandidate::eta(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), mps_fire::i, training_settings::idx, reco::Jet::jetArea(), crabWrapper::key, reco::LeafCandidate::mass(), moduleLabel_, eostools::move(), reco::Jet::nConstituents(), patMuonMerger_cfi::pfCandidates, reco::LeafCandidate::phi(), edm::Event::productGetter(), reco::LeafCandidate::pt(), edm::Event::put(), edm::View< T >::size(), srcPFCandidates_, srcSubjets_, and verbosity_.

Referenced by ~BoostedTauSeedsProducer().

194  {
195  if (verbosity_ >= 1) {
196  std::cout << "<BoostedTauSeedsProducer::produce (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
197  }
198 
199  edm::Handle<JetView> subjets;
200  evt.getByToken(srcSubjets_, subjets);
201  if (verbosity_ >= 1) {
202  std::cout << "#subjets = " << subjets->size() << std::endl;
203  }
204  assert((subjets->size() % 2) == 0); // CV: ensure that subjets come in pairs
205 
207  evt.getByToken(srcPFCandidates_, pfCandidates);
208  if (verbosity_ >= 1) {
209  std::cout << "#pfCandidates = " << pfCandidates->size() << std::endl;
210  }
211 
212  auto selectedSubjets = std::make_unique<reco::PFJetCollection>();
214 
215  auto selectedSubjetPFCandidateAssociationForIsolation =
216  std::make_unique<JetToPFCandidateAssociation>(&evt.productGetter());
217  //auto selectedSubjetPFCandidateAssociationForIsoDepositVetos = std::make_unique<JetToPFCandidateAssociation>(&evt.productGetter());
218 
219  // cache for jet->pfcandidate
220  JetToConstitMap constitmap(subjets->size());
221 
222  // fill constituents map
223  const auto& thesubjets = *subjets;
224  for (unsigned i = 0; i < thesubjets.size(); ++i) {
225  for (unsigned j = 0; j < thesubjets[i].numberOfDaughters(); ++j) {
226  constitmap[i].emplace(thesubjets[i].daughterPtr(j).key());
227  }
228  }
229 
230  for (size_t idx = 0; idx < (subjets->size() / 2); ++idx) {
231  const reco::Jet* subjet1 = &subjets->at(2 * idx);
232  const reco::Jet* subjet2 = &subjets->at(2 * idx + 1);
233  assert(subjet1 && subjet2);
234  if (verbosity_ >= 1) {
235  std::cout << "processing jet #" << idx << ":" << std::endl;
236  std::cout << " subjet1: Pt = " << subjet1->pt() << ", eta = " << subjet1->eta() << ", phi = " << subjet1->phi()
237  << ", mass = " << subjet1->mass() << " (#constituents = " << subjet1->nConstituents()
238  << ", area = " << subjet1->jetArea() << ")" << std::endl;
239  std::cout << " subjet2: Pt = " << subjet2->pt() << ", eta = " << subjet2->eta() << ", phi = " << subjet2->phi()
240  << ", mass = " << subjet2->mass() << " (#constituents = " << subjet2->nConstituents()
241  << ", area = " << subjet2->jetArea() << ")" << std::endl;
242  }
243 
244  if (!(subjet1->nConstituents() >= 1 && subjet1->pt() > 1. && subjet2->nConstituents() >= 1 && subjet2->pt() > 1.))
245  continue; // CV: skip pathological cases
246 
247  // find PFCandidate constituents of each subjet
248  reco::Jet::Constituents subjetConstituents1;
249  getJetConstituents(*subjet1, subjetConstituents1);
250  reco::Jet::Constituents subjetConstituents2;
251  getJetConstituents(*subjet2, subjetConstituents2);
252  if (verbosity_ >= 1) {
253  printJetConstituents("subjetConstituents1", subjetConstituents1);
254  printJetConstituents("subjetConstituents2", subjetConstituents2);
255  }
256 
257  selectedSubjets->push_back(convertToPFJet(*subjet1, subjetConstituents1));
258  edm::Ref<reco::PFJetCollection> subjetRef1(selectedSubjetRefProd, selectedSubjets->size() - 1);
259  selectedSubjets->push_back(convertToPFJet(*subjet2, subjetConstituents2));
260  edm::Ref<reco::PFJetCollection> subjetRef2(selectedSubjetRefProd, selectedSubjets->size() - 1);
261 
262  // find all PFCandidates that are not constituents of the **other** subjet
263  std::vector<reco::PFCandidateRef> pfCandidatesNotInSubjet1, pfCandidatesNotInSubjet2;
264  //Overlapping constituents can be incorrectly selected as in previous
265  //buggy version of this module to fulfill non-changing policy in
266  //10_6_X release series.
268  pfCandidatesNotInSubjet1 = getPFCandidates_exclJetConstituents(*subjet1, pfCandidates, constitmap[2 * idx + 1], false);
269  pfCandidatesNotInSubjet2 = getPFCandidates_exclJetConstituents(*subjet2, pfCandidates, constitmap[2 * idx], false);
270  }
271  else {
272  pfCandidatesNotInSubjet1 = getPFCandidates_exclJetConstituents(*subjet1, pfCandidates, constitmap[2 * idx], false);
273  pfCandidatesNotInSubjet2 = getPFCandidates_exclJetConstituents(*subjet2, pfCandidates, constitmap[2 * idx + 1], false);
274  }
275  if (verbosity_ >= 1) {
276  std::cout << "#pfCandidatesNotInSubjet1 = " << pfCandidatesNotInSubjet1.size() << std::endl;
277  std::cout << "#pfCandidatesNotInSubjet2 = " << pfCandidatesNotInSubjet2.size() << std::endl;
278  }
279 
280  // build JetToPFCandidateAssociation
281  // (key = subjet, value = collection of PFCandidates that are not constituents of subjet)
282  for (auto const& pfCandidate : pfCandidatesNotInSubjet1) {
283  selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef1, pfCandidate);
284  }
285  for (auto const& pfCandidate : pfCandidatesNotInSubjet2) {
286  selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef2, pfCandidate);
287  }
288  }
289 
290  evt.put(std::move(selectedSubjets));
291  evt.put(std::move(selectedSubjetPFCandidateAssociationForIsolation), "pfCandAssocMapForIsolation");
292 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Base class for all types of Jets.
Definition: Jet.h:20
EDProductGetter const & productGetter() const
Definition: Event.cc:93
std::vector< Constituent > Constituents
Definition: Jet.h:23
size_type size() const
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
std::vector< PFJet > PFJetCollection
collection of PFJet objects
virtual float jetArea() const
get jet area
Definition: Jet.h:105
virtual int nConstituents() const
of constituents
Definition: Jet.h:65
const_reference at(size_type pos) const
edm::EDGetTokenT< JetView > srcSubjets_
double phi() const final
momentum azimuthal angle
def move(src, dest)
Definition: eostools.py:511
double mass() const final
mass

Member Data Documentation

bool BoostedTauSeedsProducer::correctlyExcludeOverlap_
private

Definition at line 59 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

std::string BoostedTauSeedsProducer::moduleLabel_
private
edm::EDGetTokenT<reco::PFCandidateCollection> BoostedTauSeedsProducer::srcPFCandidates_
private

Definition at line 57 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

edm::EDGetTokenT<JetView> BoostedTauSeedsProducer::srcSubjets_
private

Definition at line 56 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

int BoostedTauSeedsProducer::verbosity_
private

Definition at line 60 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().