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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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

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 62 of file BoostedTauSeedsProducer.cc.

References gather_cfg::cout, HLTMuonOfflineAnalyzer_cfi::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, l1tstage2_dqm_sourceclient-live_cfg::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(), zmumugammaAnalyzer_cfi::pfCandidates, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), reco::Jet::setJetArea(), srcPFCandidates_, srcSubjets_, AlCaHLTBitMon_QueryRunRegistry::string, verbosity_, and reco::LeafCandidate::vertex().

63  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
64  srcSubjets_ = consumes<JetView>(cfg.getParameter<edm::InputTag>("subjetSrc"));
65  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("pfCandidateSrc"));
66 
67  verbosity_ = (cfg.exists("verbosity")) ? cfg.getParameter<int>("verbosity") : 0;
68 
69  produces<reco::PFJetCollection>();
70  produces<JetToPFCandidateAssociation>("pfCandAssocMapForIsolation");
71  //produces<JetToPFCandidateAssociation>("pfCandAssocMapForIsoDepositVetos");
72 }
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 190 of file BoostedTauSeedsProducer.cc.

References edm::View< T >::at(), gather_cfg::cout, DEFINE_FWK_MODULE, MillePedeFileConverter_cfg::e, reco::LeafCandidate::eta(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), mps_fire::i, training_settings::idx, dqmiolumiharvest::j, reco::Jet::jetArea(), crabWrapper::key, reco::LeafCandidate::mass(), moduleLabel_, eostools::move(), reco::Jet::nConstituents(), zmumugammaAnalyzer_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().

190  {
191  if (verbosity_ >= 1) {
192  std::cout << "<BoostedTauSeedsProducer::produce (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
193  }
194 
195  edm::Handle<JetView> subjets;
196  evt.getByToken(srcSubjets_, subjets);
197  if (verbosity_ >= 1) {
198  std::cout << "#subjets = " << subjets->size() << std::endl;
199  }
200  assert((subjets->size() % 2) == 0); // CV: ensure that subjets come in pairs
201 
203  evt.getByToken(srcPFCandidates_, pfCandidates);
204  if (verbosity_ >= 1) {
205  std::cout << "#pfCandidates = " << pfCandidates->size() << std::endl;
206  }
207 
208  auto selectedSubjets = std::make_unique<reco::PFJetCollection>();
210 
211  auto selectedSubjetPFCandidateAssociationForIsolation =
212  std::make_unique<JetToPFCandidateAssociation>(&evt.productGetter());
213  //auto selectedSubjetPFCandidateAssociationForIsoDepositVetos = std::make_unique<JetToPFCandidateAssociation>(&evt.productGetter());
214 
215  // cache for jet->pfcandidate
216  JetToConstitMap constitmap(subjets->size());
217 
218  // fill constituents map
219  const auto& thesubjets = *subjets;
220  for (unsigned i = 0; i < thesubjets.size(); ++i) {
221  for (unsigned j = 0; j < thesubjets[i].numberOfDaughters(); ++j) {
222  constitmap[i].emplace(thesubjets[i].daughterPtr(j).key());
223  }
224  }
225 
226  for (size_t idx = 0; idx < (subjets->size() / 2); ++idx) {
227  const reco::Jet* subjet1 = &subjets->at(2 * idx);
228  const reco::Jet* subjet2 = &subjets->at(2 * idx + 1);
229  assert(subjet1 && subjet2);
230  if (verbosity_ >= 1) {
231  std::cout << "processing jet #" << idx << ":" << std::endl;
232  std::cout << " subjet1: Pt = " << subjet1->pt() << ", eta = " << subjet1->eta() << ", phi = " << subjet1->phi()
233  << ", mass = " << subjet1->mass() << " (#constituents = " << subjet1->nConstituents()
234  << ", area = " << subjet1->jetArea() << ")" << std::endl;
235  std::cout << " subjet2: Pt = " << subjet2->pt() << ", eta = " << subjet2->eta() << ", phi = " << subjet2->phi()
236  << ", mass = " << subjet2->mass() << " (#constituents = " << subjet2->nConstituents()
237  << ", area = " << subjet2->jetArea() << ")" << std::endl;
238  }
239 
240  if (!(subjet1->nConstituents() >= 1 && subjet1->pt() > 1. && subjet2->nConstituents() >= 1 && subjet2->pt() > 1.))
241  continue; // CV: skip pathological cases
242 
243  // find PFCandidate constituents of each subjet
244  reco::Jet::Constituents subjetConstituents1;
245  getJetConstituents(*subjet1, subjetConstituents1);
246  reco::Jet::Constituents subjetConstituents2;
247  getJetConstituents(*subjet2, subjetConstituents2);
248  if (verbosity_ >= 1) {
249  printJetConstituents("subjetConstituents1", subjetConstituents1);
250  printJetConstituents("subjetConstituents2", subjetConstituents2);
251  }
252 
253  selectedSubjets->push_back(convertToPFJet(*subjet1, subjetConstituents1));
254  edm::Ref<reco::PFJetCollection> subjetRef1(selectedSubjetRefProd, selectedSubjets->size() - 1);
255  selectedSubjets->push_back(convertToPFJet(*subjet2, subjetConstituents2));
256  edm::Ref<reco::PFJetCollection> subjetRef2(selectedSubjetRefProd, selectedSubjets->size() - 1);
257 
258  // find all PFCandidates that are not constituents of the **other** subjet
259  std::vector<reco::PFCandidateRef> pfCandidatesNotInSubjet1 = getPFCandidates_exclJetConstituents(
260  *subjet1, pfCandidates, constitmap[2 * idx], subjetConstituents2, 1.e-4, false);
261  std::vector<reco::PFCandidateRef> pfCandidatesNotInSubjet2 = getPFCandidates_exclJetConstituents(
262  *subjet2, pfCandidates, constitmap[2 * idx + 1], subjetConstituents1, 1.e-4, false);
263  if (verbosity_ >= 1) {
264  std::cout << "#pfCandidatesNotInSubjet1 = " << pfCandidatesNotInSubjet1.size() << std::endl;
265  std::cout << "#pfCandidatesNotInSubjet2 = " << pfCandidatesNotInSubjet2.size() << std::endl;
266  }
267 
268  // build JetToPFCandidateAssociation
269  // (key = subjet, value = collection of PFCandidates that are not constituents of subjet)
270  for (auto const& pfCandidate : pfCandidatesNotInSubjet1) {
271  selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef1, pfCandidate);
272  }
273  for (auto const& pfCandidate : pfCandidatesNotInSubjet2) {
274  selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef2, pfCandidate);
275  }
276  }
277 
278  evt.put(std::move(selectedSubjets));
279  evt.put(std::move(selectedSubjetPFCandidateAssociationForIsolation), "pfCandAssocMapForIsolation");
280 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
Base class for all types of Jets.
Definition: Jet.h:20
EDProductGetter const & productGetter() const
Definition: Event.cc:102
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:156
std::vector< PFJet > PFJetCollection
collection of PFJet objects
virtual float jetArea() const
get jet area
Definition: Jet.h:103
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

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 59 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().