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

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

References produce().

47 {}

Member Function Documentation

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

Definition at line 191 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, reco::Jet::jetArea(), crabWrapper::key, reco::LeafCandidate::mass(), moduleLabel_, eostools::move(), reco::Jet::nConstituents(), slimmedMuons_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().

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

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().