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

Member Typedef Documentation

Definition at line 53 of file BoostedTauSeedsProducer.cc.

Definition at line 57 of file BoostedTauSeedsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 64 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(), diffTwoXMLs::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().

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

References produce().

49 {}

Member Function Documentation

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

Definition at line 193 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().

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

Member Data Documentation

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

Definition at line 59 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

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

Definition at line 58 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().

int BoostedTauSeedsProducer::verbosity_
private

Definition at line 61 of file BoostedTauSeedsProducer.cc.

Referenced by BoostedTauSeedsProducer(), and produce().