CMS 3D CMS Logo

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

Public Types

typedef edm::AssociationMap< edm::OneToOne< reco::JetView, reco::JetView > > JetMatchMap
 
typedef edm::AssociationMap< edm::OneToMany< std::vector< JetType >, std::vector< CandType >, unsigned int > > JetToCandidateAssociation
 
- 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
 

Public Member Functions

template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauGenericJetRegionProducer (const edm::ParameterSet &pset)
 
 ~RecoTauGenericJetRegionProducer () 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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static void fillDescriptionsBase (edm::ConfigurationDescriptions &descriptions, const std::string &name)
 

Private Attributes

double deltaR2_
 
edm::InputTag inputJets_
 
edm::EDGetTokenT< reco::CandidateViewJets_token
 
double maxJetAbsEta_
 
double minJetPt_
 
std::string moduleLabel_
 
edm::EDGetTokenT< std::vector< CandType > > pf_token
 
edm::EDGetTokenT< JetToCandidateAssociationpfCandAssocMap_token
 
edm::InputTag pfCandAssocMapSrc_
 
edm::InputTag pfCandSrc_
 
int verbosity_
 

Detailed Description

template<class JetType, class CandType>
class RecoTauGenericJetRegionProducer< JetType, CandType >

Definition at line 39 of file RecoTauGenericJetRegionProducer.cc.

Member Typedef Documentation

◆ JetMatchMap

template<class JetType , class CandType >
typedef edm::AssociationMap<edm::OneToOne<reco::JetView, reco::JetView> > RecoTauGenericJetRegionProducer< JetType, CandType >::JetMatchMap

Definition at line 41 of file RecoTauGenericJetRegionProducer.cc.

◆ JetToCandidateAssociation

template<class JetType , class CandType >
typedef edm::AssociationMap<edm::OneToMany<std::vector<JetType>, std::vector<CandType>, unsigned int> > RecoTauGenericJetRegionProducer< JetType, CandType >::JetToCandidateAssociation

Definition at line 43 of file RecoTauGenericJetRegionProducer.cc.

Constructor & Destructor Documentation

◆ RecoTauGenericJetRegionProducer()

template<class JetType , class CandType >
RecoTauGenericJetRegionProducer< JetType, CandType >::RecoTauGenericJetRegionProducer ( const edm::ParameterSet pset)
explicit

Definition at line 71 of file RecoTauGenericJetRegionProducer.cc.

72  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
73  inputJets_ = cfg.getParameter<edm::InputTag>("src");
74  pfCandSrc_ = cfg.getParameter<edm::InputTag>("pfCandSrc");
75  pfCandAssocMapSrc_ = cfg.getParameter<edm::InputTag>("pfCandAssocMapSrc");
76 
77  pf_token = consumes<std::vector<CandType> >(pfCandSrc_);
78  Jets_token = consumes<reco::CandidateView>(inputJets_);
79  pfCandAssocMap_token = consumes<JetToCandidateAssociation>(pfCandAssocMapSrc_);
80 
81  double deltaR = cfg.getParameter<double>("deltaR");
83  minJetPt_ = cfg.getParameter<double>("minJetPt");
84  maxJetAbsEta_ = cfg.getParameter<double>("maxJetAbsEta");
85 
86  verbosity_ = cfg.getParameter<int>("verbosity");
87 
88  produces<std::vector<JetType> >("jets");
89  produces<JetMatchMap>();
90 }

References looper::cfg, PbPb_ZMuSkimMuonDPG_cff::deltaR, RecoTauGenericJetRegionProducer< JetType, CandType >::deltaR2_, RecoTauGenericJetRegionProducer< JetType, CandType >::inputJets_, RecoTauGenericJetRegionProducer< JetType, CandType >::Jets_token, RecoTauGenericJetRegionProducer< JetType, CandType >::maxJetAbsEta_, RecoTauGenericJetRegionProducer< JetType, CandType >::minJetPt_, RecoTauGenericJetRegionProducer< JetType, CandType >::pf_token, RecoTauGenericJetRegionProducer< JetType, CandType >::pfCandAssocMap_token, RecoTauGenericJetRegionProducer< JetType, CandType >::pfCandAssocMapSrc_, RecoTauGenericJetRegionProducer< JetType, CandType >::pfCandSrc_, and RecoTauGenericJetRegionProducer< JetType, CandType >::verbosity_.

◆ ~RecoTauGenericJetRegionProducer()

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

Definition at line 45 of file RecoTauGenericJetRegionProducer.cc.

45 {}

Member Function Documentation

◆ fillDescriptions() [1/3]

template<class JetType , class CandType >
static void RecoTauGenericJetRegionProducer< JetType, CandType >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

◆ fillDescriptions() [2/3]

template<>
void RecoTauGenericJetRegionProducer< reco::PFJet, reco::PFCandidate >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)

Definition at line 239 of file RecoTauGenericJetRegionProducer.cc.

240  {
241  // RecoTauGenericJetRegionProducer
242  RecoTauGenericJetRegionProducer::fillDescriptionsBase(descriptions, "RecoTauJetRegionProducer");
243 }

References RecoTauGenericJetRegionProducer< JetType, CandType >::fillDescriptionsBase().

◆ fillDescriptions() [3/3]

template<>
void RecoTauGenericJetRegionProducer< pat::Jet, pat::PackedCandidate >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)

Definition at line 246 of file RecoTauGenericJetRegionProducer.cc.

247  {
248  // RecoTauGenericJetRegionProducer
249  RecoTauGenericJetRegionProducer::fillDescriptionsBase(descriptions, "RecoTauPatJetRegionProducer");
250 }

References RecoTauGenericJetRegionProducer< JetType, CandType >::fillDescriptionsBase().

◆ fillDescriptionsBase()

template<class JetType , class CandType >
void RecoTauGenericJetRegionProducer< JetType, CandType >::fillDescriptionsBase ( edm::ConfigurationDescriptions descriptions,
const std::string &  name 
)
static

Definition at line 224 of file RecoTauGenericJetRegionProducer.cc.

225  {
226  // RecoTauGenericJetRegionProducer
228  desc.add<edm::InputTag>("src", edm::InputTag("ak4PFJets"));
229  desc.add<double>("deltaR", 0.8);
230  desc.add<edm::InputTag>("pfCandAssocMapSrc", edm::InputTag(""));
231  desc.add<int>("verbosity", 0);
232  desc.add<double>("maxJetAbsEta", 2.5);
233  desc.add<double>("minJetPt", 14.0);
234  desc.add<edm::InputTag>("pfCandSrc", edm::InputTag("particleFlow"));
235  descriptions.add(name, desc);
236 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_2018_cff::InputTag, and Skims_PA_cff::name.

Referenced by RecoTauGenericJetRegionProducer< JetType, CandType >::fillDescriptions().

◆ produce()

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

Definition at line 93 of file RecoTauGenericJetRegionProducer.cc.

93  {
94  if (verbosity_) {
95  std::cout << "<RecoTauJetRegionProducer::produce (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
96  std::cout << " inputJets = " << inputJets_ << std::endl;
97  std::cout << " pfCandSrc = " << pfCandSrc_ << std::endl;
98  std::cout << " pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl;
99  }
100 
101  edm::Handle<std::vector<CandType> > pfCandsHandle;
102  evt.getByToken(pf_token, pfCandsHandle);
103 
104  // Build Ptrs for all the PFCandidates
105  typedef edm::Ptr<CandType> CandPtr;
106  std::vector<CandPtr> pfCands;
107  pfCands.reserve(pfCandsHandle->size());
108  for (size_t icand = 0; icand < pfCandsHandle->size(); ++icand) {
109  pfCands.push_back(CandPtr(pfCandsHandle, icand));
110  }
111 
112  // Get the jets
114  evt.getByToken(Jets_token, jetView);
115  // Convert to a vector of JetRefs
116  edm::RefVector<std::vector<JetType> > jets = reco::tau::castView<edm::RefVector<std::vector<JetType> > >(jetView);
117  size_t nJets = jets.size();
118 
119  // Get the association map matching jets to Candidates
120  // (needed for reconstruction of boosted taus)
122  std::vector<std::unordered_set<unsigned> > fastJetToPFCandMap;
123  if (!pfCandAssocMapSrc_.label().empty()) {
124  evt.getByToken(pfCandAssocMap_token, jetToPFCandMap);
125  fastJetToPFCandMap.resize(nJets);
126  for (size_t ijet = 0; ijet < nJets; ++ijet) {
127  // Get a ref to jet
128  const edm::Ref<std::vector<JetType> >& jetRef = jets[ijet];
129  const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef];
130  for (const auto& pfCandMappedToJet : pfCandsMappedToJet) {
131  fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key());
132  }
133  }
134  }
135 
136  // Get the original product, so we can match against it - otherwise the
137  // indices don't match up.
138  edm::ProductID originalId = jets.id();
139  edm::Handle<std::vector<JetType> > originalJets;
140  size_t nOriginalJets = 0;
141  // We have to make sure that we have some selected jets, otherwise we don't
142  // actually have a valid product ID to the original jets.
143  if (nJets) {
144  try {
145  evt.get(originalId, originalJets);
146  } catch (const cms::Exception& e) {
147  edm::LogError("MissingOriginalCollection") << "Can't get the original jets that made: " << inputJets_
148  << " that have product ID: " << originalId << " from the event!!";
149  throw e;
150  }
151  nOriginalJets = originalJets->size();
152  }
153 
154  auto newJets = std::make_unique<std::vector<JetType> >();
155 
156  // Keep track of the indices of the current jet and the old (original) jet
157  // -1 indicates no match.
158  std::vector<int> matchInfo(nOriginalJets, -1);
159  newJets->reserve(nJets);
160  size_t nNewJets = 0;
161  for (size_t ijet = 0; ijet < nJets; ++ijet) {
162  // Get a ref to jet
163  const edm::Ref<std::vector<JetType> >& jetRef = jets[ijet];
164  if (jetRef->pt() - minJetPt_ < 1e-5)
165  continue;
166  if (std::abs(jetRef->eta()) - maxJetAbsEta_ > -1e-5)
167  continue;
168  // Make an initial copy.
169  newJets->emplace_back(*jetRef);
170  JetType& newJet = newJets->back();
171  // Clear out all the constituents
172  newJet.clearDaughters();
173  // Loop over all the PFCands
174  for (const auto& pfCand : pfCands) {
175  bool isMappedToJet = false;
176  if (jetToPFCandMap.isValid()) {
177  auto temp = jetToPFCandMap->find(jetRef);
178  if (temp == jetToPFCandMap->end()) {
179  edm::LogWarning("WeirdCandidateMap") << "Candidate map for jet " << jetRef.key() << " is empty!";
180  continue;
181  }
182  isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key());
183  } else {
184  isMappedToJet = true;
185  }
186  if (reco::deltaR2(*jetRef, *pfCand) < deltaR2_ && isMappedToJet)
187  newJet.addDaughter(pfCand);
188  }
189  if (verbosity_) {
190  std::cout << "jet #" << ijet << ": Pt = " << jetRef->pt() << ", eta = " << jetRef->eta()
191  << ", phi = " << jetRef->eta() << ","
192  << " mass = " << jetRef->mass() << ", area = " << jetRef->jetArea() << std::endl;
193  auto jetConstituents = newJet.daughterPtrVector();
194  int idx = 0;
195  for (const auto& jetConstituent : jetConstituents) {
196  std::cout << " constituent #" << idx << ": Pt = " << jetConstituent->pt() << ", eta = " << jetConstituent->eta()
197  << ", phi = " << jetConstituent->phi() << std::endl;
198  ++idx;
199  }
200  }
201  // Match the index of the jet we just made to the index into the original
202  // collection.
203  //matchInfo[jetRef.key()] = ijet;
204  matchInfo[jetRef.key()] = nNewJets;
205  nNewJets++;
206  }
207 
208  // Put our new jets into the event
209  edm::OrphanHandle<std::vector<JetType> > newJetsInEvent = evt.put(std::move(newJets), "jets");
210 
211  // Create a matching between original jets -> extra collection
212  auto matching = (nJets != 0)
213  ? std::make_unique<JetMatchMap>(
215  : std::make_unique<JetMatchMap>();
216  for (size_t ijet = 0; ijet < nJets; ++ijet) {
217  matching->insert(edm::RefToBase<reco::Jet>(jets[ijet]),
218  edm::RefToBase<reco::Jet>(edm::Ref<std::vector<JetType> >(newJetsInEvent, matchInfo[ijet])));
219  }
220  evt.put(std::move(matching));
221 }

References funct::abs(), gather_cfg::cout, reco::deltaR2(), MillePedeFileConverter_cfg::e, edm::Event::get(), edm::Event::getByToken(), training_settings::idx, edm::HandleBase::isValid(), singleTopDQM_cfi::jets, edm::Ref< C, T, F >::key(), edm::makeRefToBaseProdFrom(), TtSemiLepJetCombMVATrainer_cfi::matching, eostools::move(), edm::Event::put(), and groupFilesInBlocks::temp.

Member Data Documentation

◆ deltaR2_

template<class JetType , class CandType >
double RecoTauGenericJetRegionProducer< JetType, CandType >::deltaR2_
private

◆ inputJets_

template<class JetType , class CandType >
edm::InputTag RecoTauGenericJetRegionProducer< JetType, CandType >::inputJets_
private

◆ Jets_token

template<class JetType , class CandType >
edm::EDGetTokenT<reco::CandidateView> RecoTauGenericJetRegionProducer< JetType, CandType >::Jets_token
private

◆ maxJetAbsEta_

template<class JetType , class CandType >
double RecoTauGenericJetRegionProducer< JetType, CandType >::maxJetAbsEta_
private

◆ minJetPt_

template<class JetType , class CandType >
double RecoTauGenericJetRegionProducer< JetType, CandType >::minJetPt_
private

◆ moduleLabel_

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

◆ pf_token

template<class JetType , class CandType >
edm::EDGetTokenT<std::vector<CandType> > RecoTauGenericJetRegionProducer< JetType, CandType >::pf_token
private

◆ pfCandAssocMap_token

template<class JetType , class CandType >
edm::EDGetTokenT<JetToCandidateAssociation> RecoTauGenericJetRegionProducer< JetType, CandType >::pfCandAssocMap_token
private

◆ pfCandAssocMapSrc_

template<class JetType , class CandType >
edm::InputTag RecoTauGenericJetRegionProducer< JetType, CandType >::pfCandAssocMapSrc_
private

◆ pfCandSrc_

template<class JetType , class CandType >
edm::InputTag RecoTauGenericJetRegionProducer< JetType, CandType >::pfCandSrc_
private

◆ verbosity_

template<class JetType , class CandType >
int RecoTauGenericJetRegionProducer< JetType, CandType >::verbosity_
private
RecoTauGenericJetRegionProducer::moduleLabel_
std::string moduleLabel_
Definition: RecoTauGenericJetRegionProducer.cc:53
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition: AssociationMap.h:173
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
RecoTauGenericJetRegionProducer::maxJetAbsEta_
double maxJetAbsEta_
Definition: RecoTauGenericJetRegionProducer.cc:64
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RecoTauGenericJetRegionProducer::pfCandSrc_
edm::InputTag pfCandSrc_
Definition: RecoTauGenericJetRegionProducer.cc:56
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RecoTauGenericJetRegionProducer::verbosity_
int verbosity_
Definition: RecoTauGenericJetRegionProducer.cc:67
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
RecoTauGenericJetRegionProducer::pfCandAssocMap_token
edm::EDGetTokenT< JetToCandidateAssociation > pfCandAssocMap_token
Definition: RecoTauGenericJetRegionProducer.cc:61
edm::RefVector
Definition: EDProductfwd.h:27
TtSemiLepJetCombMVATrainer_cfi.matching
matching
Definition: TtSemiLepJetCombMVATrainer_cfi.py:13
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
training_settings.idx
idx
Definition: training_settings.py:16
edm::Ref
Definition: AssociativeIterator.h:58
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
RecoTauGenericJetRegionProducer::pf_token
edm::EDGetTokenT< std::vector< CandType > > pf_token
Definition: RecoTauGenericJetRegionProducer.cc:59
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::LogError
Definition: MessageLogger.h:183
edm::makeRefToBaseProdFrom
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Definition: makeRefToBaseProdFrom.h:34
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
RecoTauGenericJetRegionProducer::fillDescriptionsBase
static void fillDescriptionsBase(edm::ConfigurationDescriptions &descriptions, const std::string &name)
Definition: RecoTauGenericJetRegionProducer.cc:224
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::Ptr
Definition: AssociationVector.h:31
looper.cfg
cfg
Definition: looper.py:297
RecoTauGenericJetRegionProducer::deltaR2_
double deltaR2_
Definition: RecoTauGenericJetRegionProducer.cc:65
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
RecoTauGenericJetRegionProducer::inputJets_
edm::InputTag inputJets_
Definition: RecoTauGenericJetRegionProducer.cc:55
RecoTauGenericJetRegionProducer::Jets_token
edm::EDGetTokenT< reco::CandidateView > Jets_token
Definition: RecoTauGenericJetRegionProducer.cc:60
fftjetcms::JetType
JetType
Definition: JetType.h:7
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::RefToBase< reco::Jet >
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RecoTauGenericJetRegionProducer::minJetPt_
double minJetPt_
Definition: RecoTauGenericJetRegionProducer.cc:63
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event::get
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:337
edm::InputTag
Definition: InputTag.h:15
RecoTauGenericJetRegionProducer::pfCandAssocMapSrc_
edm::InputTag pfCandAssocMapSrc_
Definition: RecoTauGenericJetRegionProducer.cc:57
edm::ProductID
Definition: ProductID.h:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37