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

◆ JetToPFCandidateAssociation

Definition at line 51 of file BoostedTauSeedsProducer.cc.

◆ JetView

Definition at line 55 of file BoostedTauSeedsProducer.cc.

Constructor & Destructor Documentation

◆ BoostedTauSeedsProducer()

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

Definition at line 62 of file BoostedTauSeedsProducer.cc.

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 }

References looper::cfg, srcPFCandidates_, srcSubjets_, and verbosity_.

◆ ~BoostedTauSeedsProducer()

BoostedTauSeedsProducer::~BoostedTauSeedsProducer ( )
inlineoverride

Definition at line 46 of file BoostedTauSeedsProducer.cc.

46 {}

Member Function Documentation

◆ produce()

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

Definition at line 187 of file BoostedTauSeedsProducer.cc.

187  {
188  if (verbosity_ >= 1) {
189  std::cout << "<BoostedTauSeedsProducer::produce (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
190  }
191 
192  edm::Handle<JetView> subjets;
193  evt.getByToken(srcSubjets_, subjets);
194  if (verbosity_ >= 1) {
195  std::cout << "#subjets = " << subjets->size() << std::endl;
196  }
197  assert((subjets->size() % 2) == 0); // CV: ensure that subjets come in pairs
198 
201  if (verbosity_ >= 1) {
202  std::cout << "#pfCandidates = " << pfCandidates->size() << std::endl;
203  }
204 
205  auto selectedSubjets = std::make_unique<reco::PFJetCollection>();
207 
208  auto selectedSubjetPFCandidateAssociationForIsolation =
209  std::make_unique<JetToPFCandidateAssociation>(&evt.productGetter());
210  //auto selectedSubjetPFCandidateAssociationForIsoDepositVetos = std::make_unique<JetToPFCandidateAssociation>(&evt.productGetter());
211 
212  // cache for jet->pfcandidate
213  JetToConstitMap constitmap(subjets->size());
214 
215  // fill constituents map
216  const auto& thesubjets = *subjets;
217  for (unsigned i = 0; i < thesubjets.size(); ++i) {
218  for (unsigned j = 0; j < thesubjets[i].numberOfDaughters(); ++j) {
219  constitmap[i].emplace(thesubjets[i].daughterPtr(j).key());
220  }
221  }
222 
223  for (size_t idx = 0; idx < (subjets->size() / 2); ++idx) {
224  const reco::Jet* subjet1 = &subjets->at(2 * idx);
225  const reco::Jet* subjet2 = &subjets->at(2 * idx + 1);
226  assert(subjet1 && subjet2);
227  if (verbosity_ >= 1) {
228  std::cout << "processing jet #" << idx << ":" << std::endl;
229  std::cout << " subjet1: Pt = " << subjet1->pt() << ", eta = " << subjet1->eta() << ", phi = " << subjet1->phi()
230  << ", mass = " << subjet1->mass() << " (#constituents = " << subjet1->nConstituents()
231  << ", area = " << subjet1->jetArea() << ")" << std::endl;
232  std::cout << " subjet2: Pt = " << subjet2->pt() << ", eta = " << subjet2->eta() << ", phi = " << subjet2->phi()
233  << ", mass = " << subjet2->mass() << " (#constituents = " << subjet2->nConstituents()
234  << ", area = " << subjet2->jetArea() << ")" << std::endl;
235  }
236 
237  if (!(subjet1->nConstituents() >= 1 && subjet1->pt() > 1. && subjet2->nConstituents() >= 1 && subjet2->pt() > 1.))
238  continue; // CV: skip pathological cases
239 
240  // find PFCandidate constituents of each subjet
241  reco::Jet::Constituents subjetConstituents1;
242  getJetConstituents(*subjet1, subjetConstituents1);
243  reco::Jet::Constituents subjetConstituents2;
244  getJetConstituents(*subjet2, subjetConstituents2);
245  if (verbosity_ >= 1) {
246  printJetConstituents("subjetConstituents1", subjetConstituents1);
247  printJetConstituents("subjetConstituents2", subjetConstituents2);
248  }
249 
250  selectedSubjets->push_back(convertToPFJet(*subjet1, subjetConstituents1));
251  edm::Ref<reco::PFJetCollection> subjetRef1(selectedSubjetRefProd, selectedSubjets->size() - 1);
252  selectedSubjets->push_back(convertToPFJet(*subjet2, subjetConstituents2));
253  edm::Ref<reco::PFJetCollection> subjetRef2(selectedSubjetRefProd, selectedSubjets->size() - 1);
254 
255  // find all PFCandidates that are not constituents of the **other** subjet
256  std::vector<reco::PFCandidateRef> pfCandidatesNotInSubjet1 =
257  getPFCandidates_exclJetConstituents(*subjet1, pfCandidates, constitmap[2 * idx + 1], false);
258  std::vector<reco::PFCandidateRef> pfCandidatesNotInSubjet2 =
259  getPFCandidates_exclJetConstituents(*subjet2, pfCandidates, constitmap[2 * idx], false);
260  if (verbosity_ >= 1) {
261  std::cout << "#pfCandidatesNotInSubjet1 = " << pfCandidatesNotInSubjet1.size() << std::endl;
262  std::cout << "#pfCandidatesNotInSubjet2 = " << pfCandidatesNotInSubjet2.size() << std::endl;
263  }
264 
265  // build JetToPFCandidateAssociation
266  // (key = subjet, value = collection of PFCandidates that are not constituents of subjet)
267  for (auto const& pfCandidate : pfCandidatesNotInSubjet1) {
268  selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef1, pfCandidate);
269  }
270  for (auto const& pfCandidate : pfCandidatesNotInSubjet2) {
271  selectedSubjetPFCandidateAssociationForIsolation->insert(subjetRef2, pfCandidate);
272  }
273  }
274 
275  evt.put(std::move(selectedSubjets));
276  evt.put(std::move(selectedSubjetPFCandidateAssociationForIsolation), "pfCandAssocMapForIsolation");
277 }

References cms::cuda::assert(), edm::View< T >::at(), gather_cfg::cout, 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_.

Member Data Documentation

◆ moduleLabel_

std::string BoostedTauSeedsProducer::moduleLabel_
private

◆ srcPFCandidates_

edm::EDGetTokenT<reco::PFCandidateCollection> BoostedTauSeedsProducer::srcPFCandidates_
private

Definition at line 57 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

◆ srcSubjets_

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

Definition at line 56 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

◆ verbosity_

int BoostedTauSeedsProducer::verbosity_
private

Definition at line 59 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

edm::RefProd
Definition: EDProductfwd.h:25
edm::Event::getRefBeforePut
RefProd< PROD > getRefBeforePut()
Definition: Event.h:157
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
mps_fire.i
i
Definition: mps_fire.py:355
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
reco::Jet::Constituents
std::vector< Constituent > Constituents
Definition: Jet.h:23
BoostedTauSeedsProducer::srcSubjets_
edm::EDGetTokenT< JetView > srcSubjets_
Definition: BoostedTauSeedsProducer.cc:56
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::Event::productGetter
EDProductGetter const & productGetter() const
Definition: Event.cc:101
cms::cuda::assert
assert(be >=bs)
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
edm::Ref
Definition: AssociativeIterator.h:58
BoostedTauSeedsProducer::srcPFCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
Definition: BoostedTauSeedsProducer.cc:57
reco::Jet::nConstituents
virtual int nConstituents() const
Definition: Jet.h:65
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::Jet::jetArea
virtual float jetArea() const
get jet area
Definition: Jet.h:103
edm::View::size
size_type size() const
BoostedTauSeedsProducer::moduleLabel_
std::string moduleLabel_
Definition: BoostedTauSeedsProducer.cc:53
edm::View::at
const_reference at(size_type pos) const
reco::LeafCandidate::mass
double mass() const final
mass
Definition: LeafCandidate.h:131
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
reco::PFJetCollection
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Definition: PFJetCollection.h:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BoostedTauSeedsProducer::verbosity_
int verbosity_
Definition: BoostedTauSeedsProducer.cc:59
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::InputTag
Definition: InputTag.h:15