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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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 37 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 39 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 41 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 69 of file RecoTauGenericJetRegionProducer.cc.

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

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 43 of file RecoTauGenericJetRegionProducer.cc.

43 {}

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 237 of file RecoTauGenericJetRegionProducer.cc.

238  {
239  // RecoTauGenericJetRegionProducer
240  RecoTauGenericJetRegionProducer::fillDescriptionsBase(descriptions, "RecoTauJetRegionProducer");
241 }

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

◆ fillDescriptions() [3/3]

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

Definition at line 244 of file RecoTauGenericJetRegionProducer.cc.

245  {
246  // RecoTauGenericJetRegionProducer
247  RecoTauGenericJetRegionProducer::fillDescriptionsBase(descriptions, "RecoTauPatJetRegionProducer");
248 }

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 222 of file RecoTauGenericJetRegionProducer.cc.

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

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, HLT_FULL_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 91 of file RecoTauGenericJetRegionProducer.cc.

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

References funct::abs(), gather_cfg::cout, reco::deltaR2(), MillePedeFileConverter_cfg::e, edm::Event::get(), edm::Event::getByToken(), heavyIonCSV_trainingSettings::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:51
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition: AssociationMap.h:173
RecoTauGenericJetRegionProducer::maxJetAbsEta_
double maxJetAbsEta_
Definition: RecoTauGenericJetRegionProducer.cc:62
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RecoTauGenericJetRegionProducer::pfCandSrc_
edm::InputTag pfCandSrc_
Definition: RecoTauGenericJetRegionProducer.cc:54
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RecoTauGenericJetRegionProducer::verbosity_
int verbosity_
Definition: RecoTauGenericJetRegionProducer.cc:65
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
RecoTauGenericJetRegionProducer::pfCandAssocMap_token
edm::EDGetTokenT< JetToCandidateAssociation > pfCandAssocMap_token
Definition: RecoTauGenericJetRegionProducer.cc:59
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::Ref
Definition: AssociativeIterator.h:58
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
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:531
RecoTauGenericJetRegionProducer::pf_token
edm::EDGetTokenT< std::vector< CandType > > pf_token
Definition: RecoTauGenericJetRegionProducer.cc:57
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:222
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::Ptr
Definition: AssociationVector.h:31
looper.cfg
cfg
Definition: looper.py:297
RecoTauGenericJetRegionProducer::deltaR2_
double deltaR2_
Definition: RecoTauGenericJetRegionProducer.cc:63
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
RecoTauGenericJetRegionProducer::inputJets_
edm::InputTag inputJets_
Definition: RecoTauGenericJetRegionProducer.cc:53
RecoTauGenericJetRegionProducer::Jets_token
edm::EDGetTokenT< reco::CandidateView > Jets_token
Definition: RecoTauGenericJetRegionProducer.cc:58
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:61
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:338
edm::InputTag
Definition: InputTag.h:15
RecoTauGenericJetRegionProducer::pfCandAssocMapSrc_
edm::InputTag pfCandAssocMapSrc_
Definition: RecoTauGenericJetRegionProducer.cc:55
edm::ProductID
Definition: ProductID.h:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37