CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
GenericBoostedTauSeedsProducer< JetType, CandType > Class Template Reference
Inheritance diagram for GenericBoostedTauSeedsProducer< JetType, CandType >:
edm::stream::EDProducer<>

Public Member Functions

 GenericBoostedTauSeedsProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~GenericBoostedTauSeedsProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef std::vector< CandType > CandTypeCollection
 
typedef edm::AssociationMap< edm::OneToMany< std::vector< JetType >, std::vector< CandType >, unsigned int > > JetToPFCandidateAssociation
 
typedef std::vector< JetType > JetTypeCollection
 
typedef edm::View< reco::JetJetView
 

Private Attributes

std::string moduleLabel_
 
edm::EDGetTokenT< CandTypeCollectionsrcPFCandidates_
 
edm::EDGetTokenT< JetViewsrcSubjets_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<class JetType, class CandType>
class GenericBoostedTauSeedsProducer< JetType, CandType >

Definition at line 46 of file BoostedTauSeedsProducer.cc.

Member Typedef Documentation

◆ CandTypeCollection

template<class JetType , class CandType >
typedef std::vector<CandType> GenericBoostedTauSeedsProducer< JetType, CandType >::CandTypeCollection
private

Definition at line 56 of file BoostedTauSeedsProducer.cc.

◆ JetToPFCandidateAssociation

template<class JetType , class CandType >
typedef edm::AssociationMap<edm::OneToMany<std::vector<JetType>, std::vector<CandType>, unsigned int> > GenericBoostedTauSeedsProducer< JetType, CandType >::JetToPFCandidateAssociation
private

Definition at line 54 of file BoostedTauSeedsProducer.cc.

◆ JetTypeCollection

template<class JetType , class CandType >
typedef std::vector<JetType> GenericBoostedTauSeedsProducer< JetType, CandType >::JetTypeCollection
private

Definition at line 55 of file BoostedTauSeedsProducer.cc.

◆ JetView

template<class JetType , class CandType >
typedef edm::View<reco::Jet> GenericBoostedTauSeedsProducer< JetType, CandType >::JetView
private

Definition at line 60 of file BoostedTauSeedsProducer.cc.

Constructor & Destructor Documentation

◆ GenericBoostedTauSeedsProducer()

template<class JetType , class CandType >
GenericBoostedTauSeedsProducer< JetType, CandType >::GenericBoostedTauSeedsProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 68 of file BoostedTauSeedsProducer.cc.

References looper::cfg, GenericBoostedTauSeedsProducer< JetType, CandType >::srcPFCandidates_, GenericBoostedTauSeedsProducer< JetType, CandType >::srcSubjets_, and GenericBoostedTauSeedsProducer< JetType, CandType >::verbosity_.

69  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
70  srcSubjets_ = consumes<JetView>(cfg.getParameter<edm::InputTag>("subjetSrc"));
71  srcPFCandidates_ = consumes<CandTypeCollection>(cfg.getParameter<edm::InputTag>("pfCandidateSrc"));
72 
73  verbosity_ = (cfg.exists("verbosity")) ? cfg.getParameter<int>("verbosity") : 0;
74 
75  produces<JetTypeCollection>();
76  produces<JetToPFCandidateAssociation>("pfCandAssocMapForIsolation");
77  //produces<JetToPFCandidateAssociation>("pfCandAssocMapForIsoDepositVetos");
78 }
edm::EDGetTokenT< JetView > srcSubjets_
edm::EDGetTokenT< CandTypeCollection > srcPFCandidates_

◆ ~GenericBoostedTauSeedsProducer()

template<class JetType , class CandType >
GenericBoostedTauSeedsProducer< JetType, CandType >::~GenericBoostedTauSeedsProducer ( )
inlineoverride

Definition at line 49 of file BoostedTauSeedsProducer.cc.

49 {}

Member Function Documentation

◆ produce()

template<class JetType , class CandType >
void GenericBoostedTauSeedsProducer< JetType, CandType >::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 195 of file BoostedTauSeedsProducer.cc.

References cms::cuda::assert(), gather_cfg::cout, reco::LeafCandidate::eta(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), mps_fire::i, heavyIonCSV_trainingSettings::idx, dqmiolumiharvest::j, reco::Jet::jetArea(), submitPVResolutionJobs::key, reco::LeafCandidate::mass(), eostools::move(), reco::Jet::nConstituents(), zmumugammaAnalyzer_cfi::pfCandidates, reco::LeafCandidate::phi(), edm::Event::productGetter(), reco::LeafCandidate::pt(), and edm::Event::put().

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

Member Data Documentation

◆ moduleLabel_

template<class JetType , class CandType >
std::string GenericBoostedTauSeedsProducer< JetType, CandType >::moduleLabel_
private

◆ srcPFCandidates_

template<class JetType , class CandType >
edm::EDGetTokenT<CandTypeCollection> GenericBoostedTauSeedsProducer< JetType, CandType >::srcPFCandidates_
private

◆ srcSubjets_

template<class JetType , class CandType >
edm::EDGetTokenT<JetView> GenericBoostedTauSeedsProducer< JetType, CandType >::srcSubjets_
private

◆ verbosity_

template<class JetType , class CandType >
int GenericBoostedTauSeedsProducer< JetType, CandType >::verbosity_
private