CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
JetDeltaRValueMapProducer< T, C, TN > Class Template Reference
Inheritance diagram for JetDeltaRValueMapProducer< T, C, TN >:
edm::stream::EDProducer<>

Public Types

typedef edm::ValueMap< value_typeJetValueMap
 
typedef TN value_type
 
typedef std::vector< value_typeValueVector
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

 JetDeltaRValueMapProducer (edm::ParameterSet const &params)
 
 ~JetDeltaRValueMapProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

const double distMax_
 
std::map< std::string, std::unique_ptr< const StringObjectFunction< C > > > evaluationMap_
 
const bool lazyParser_
 
const edm::EDGetTokenT< typename edm::View< C > > matchedToken_
 
bool multiValue_
 
const edm::EDGetTokenT< typename edm::View< T > > srcToken_
 
const std::string value_
 
const std::vector< std::string > valueLabels_
 
const std::vector< std::string > values_
 

Detailed Description

template<class T, class C = T, typename TN = float>
class JetDeltaRValueMapProducer< T, C, TN >

Definition at line 31 of file JetDeltaRValueMapProducer.cc.

Member Typedef Documentation

◆ JetValueMap

template<class T , class C = T, typename TN = float>
typedef edm::ValueMap<value_type> JetDeltaRValueMapProducer< T, C, TN >::JetValueMap

Definition at line 34 of file JetDeltaRValueMapProducer.cc.

◆ value_type

template<class T , class C = T, typename TN = float>
typedef TN JetDeltaRValueMapProducer< T, C, TN >::value_type

Definition at line 33 of file JetDeltaRValueMapProducer.cc.

◆ ValueVector

template<class T , class C = T, typename TN = float>
typedef std::vector<value_type> JetDeltaRValueMapProducer< T, C, TN >::ValueVector

Definition at line 35 of file JetDeltaRValueMapProducer.cc.

Constructor & Destructor Documentation

◆ JetDeltaRValueMapProducer()

template<class T , class C = T, typename TN = float>
JetDeltaRValueMapProducer< T, C, TN >::JetDeltaRValueMapProducer ( edm::ParameterSet const &  params)
inline

Definition at line 37 of file JetDeltaRValueMapProducer.cc.

References JetDeltaRValueMapProducer< T, C, TN >::evaluationMap_, mps_fire::i, JetDeltaRValueMapProducer< T, C, TN >::lazyParser_, JetDeltaRValueMapProducer< T, C, TN >::multiValue_, JetDeltaRValueMapProducer< T, C, TN >::value_, JetDeltaRValueMapProducer< T, C, TN >::valueLabels_, and JetDeltaRValueMapProducer< T, C, TN >::values_.

38  : srcToken_(consumes<typename edm::View<T> >(params.getParameter<edm::InputTag>("src"))),
39  matchedToken_(consumes<typename edm::View<C> >(params.getParameter<edm::InputTag>("matched"))),
40  distMax_(params.getParameter<double>("distMax")),
41  value_(params.existsAs<std::string>("value") ? params.getParameter<std::string>("value") : ""),
42  values_(params.existsAs<std::vector<std::string> >("values")
43  ? params.getParameter<std::vector<std::string> >("values")
44  : std::vector<std::string>()),
45  valueLabels_(params.existsAs<std::vector<std::string> >("valueLabels")
46  ? params.getParameter<std::vector<std::string> >("valueLabels")
47  : std::vector<std::string>()),
48  lazyParser_(params.existsAs<bool>("lazyParser") ? params.getParameter<bool>("lazyParser") : false),
49  multiValue_(false) {
50  if (!value_.empty()) {
51  if (value_ != "index") {
52  evaluationMap_.insert(std::make_pair(
54  }
55  produces<JetValueMap>();
56  }
57 
58  if (!valueLabels_.empty() || !values_.empty()) {
59  if (valueLabels_.size() == values_.size()) {
60  multiValue_ = true;
61  for (size_t i = 0; i < valueLabels_.size(); ++i) {
62  evaluationMap_.insert(std::make_pair(
63  valueLabels_[i],
65  produces<JetValueMap>(valueLabels_[i]);
66  }
67  } else
68  edm::LogWarning("ValueLabelMismatch")
69  << "The number of value labels does not match the number of values. Values will not be evaluated.";
70  }
71  }
const edm::EDGetTokenT< typename edm::View< T > > srcToken_
const std::vector< std::string > valueLabels_
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
std::map< std::string, std::unique_ptr< const StringObjectFunction< C > > > evaluationMap_
const edm::EDGetTokenT< typename edm::View< C > > matchedToken_
Log< level::Warning, false > LogWarning
const std::vector< std::string > values_

◆ ~JetDeltaRValueMapProducer()

template<class T , class C = T, typename TN = float>
JetDeltaRValueMapProducer< T, C, TN >::~JetDeltaRValueMapProducer ( )
inlineoverride

Definition at line 73 of file JetDeltaRValueMapProducer.cc.

73 {}

Member Function Documentation

◆ produce()

template<class T , class C = T, typename TN = float>
void JetDeltaRValueMapProducer< T, C, TN >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverrideprivate

Definition at line 76 of file JetDeltaRValueMapProducer.cc.

References reco::deltaR2(), JetDeltaRValueMapProducer< T, C, TN >::distMax_, JetDeltaRValueMapProducer< T, C, TN >::evaluationMap_, trigObjTnPSource_cfi::filler, mps_fire::i, iEvent, JetDeltaRValueMapProducer< T, C, TN >::matchedToken_, eostools::move(), JetDeltaRValueMapProducer< T, C, TN >::multiValue_, JetDeltaRValueMapProducer< T, C, TN >::srcToken_, JetDeltaRValueMapProducer< T, C, TN >::value_, JetDeltaRValueMapProducer< T, C, TN >::valueLabels_, and contentValuesCheck::values.

76  {
78  iEvent.getByToken(srcToken_, h_jets1);
80  iEvent.getByToken(matchedToken_, h_jets2);
81 
82  ValueVector values(h_jets1->size(), -99999);
83 
84  std::map<std::string, std::vector<float> > valuesMap;
85  if (multiValue_) {
86  for (size_t i = 0; i < valueLabels_.size(); ++i)
87  valuesMap.insert(std::make_pair(valueLabels_[i], std::vector<float>(h_jets1->size(), -99999)));
88  }
89  std::vector<bool> jets1_locks(h_jets1->size(), false);
90 
91  for (typename edm::View<C>::const_iterator ibegin = h_jets2->begin(), iend = h_jets2->end(), ijet = ibegin;
92  ijet != iend;
93  ++ijet) {
94  float matched_dR2 = 1e9;
95  int matched_index = -1;
96  int iindex = ijet - ibegin;
97 
98  for (typename edm::View<T>::const_iterator jbegin = h_jets1->begin(), jend = h_jets1->end(), jjet = jbegin;
99  jjet != jend;
100  ++jjet) {
101  int jindex = jjet - jbegin;
102 
103  if (jets1_locks.at(jindex))
104  continue; // skip jets that have already been matched
105 
106  float temp_dR2 = reco::deltaR2(ijet->eta(), ijet->phi(), jjet->eta(), jjet->phi());
107  if (temp_dR2 < matched_dR2) {
108  matched_dR2 = temp_dR2;
109  matched_index = jindex;
110  }
111  } // end loop over src jets
112 
113  if (matched_index >= 0) {
114  if (matched_dR2 > distMax_ * distMax_)
115  edm::LogInfo("MatchedJetsFarApart") << "Matched jets separated by dR greater than distMax=" << distMax_;
116  else {
117  jets1_locks.at(matched_index) = true;
118  if (!value_.empty()) {
119  if (value_ == "index") {
120  values.at(matched_index) = iindex;
121  } else {
122  values.at(matched_index) = (*(evaluationMap_.at(value_)))(*ijet);
123  }
124  }
125  if (multiValue_) {
126  for (size_t i = 0; i < valueLabels_.size(); ++i)
127  valuesMap.at(valueLabels_[i]).at(matched_index) = (*(evaluationMap_.at(valueLabels_[i])))(*ijet);
128  }
129  }
130  }
131  } // end loop over matched jets
132 
133  if (!value_.empty()) {
134  std::unique_ptr<JetValueMap> jetValueMap(new JetValueMap());
135 
136  typename JetValueMap::Filler filler(*jetValueMap);
137  filler.insert(h_jets1, values.begin(), values.end());
138  filler.fill();
139 
140  // put in Event
141  iEvent.put(std::move(jetValueMap));
142  }
143  if (multiValue_) {
144  for (size_t i = 0; i < valueLabels_.size(); ++i) {
145  std::unique_ptr<JetValueMap> jetValueMap(new JetValueMap());
146 
147  typename JetValueMap::Filler filler(*jetValueMap);
148  filler.insert(h_jets1, valuesMap.at(valueLabels_[i]).begin(), valuesMap.at(valueLabels_[i]).end());
149  filler.fill();
150 
151  // put in Event
152  iEvent.put(std::move(jetValueMap), valueLabels_[i]);
153  }
154  }
155  }
const edm::EDGetTokenT< typename edm::View< T > > srcToken_
const std::vector< std::string > valueLabels_
edm::ValueMap< value_type > JetValueMap
int iEvent
Definition: GenABIO.cc:224
std::vector< value_type > ValueVector
Log< level::Info, false > LogInfo
helper::Filler< ValueMap< T > > Filler
Definition: ValueMap.h:162
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
std::map< std::string, std::unique_ptr< const StringObjectFunction< C > > > evaluationMap_
const edm::EDGetTokenT< typename edm::View< C > > matchedToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ distMax_

template<class T , class C = T, typename TN = float>
const double JetDeltaRValueMapProducer< T, C, TN >::distMax_
private

◆ evaluationMap_

template<class T , class C = T, typename TN = float>
std::map<std::string, std::unique_ptr<const StringObjectFunction<C> > > JetDeltaRValueMapProducer< T, C, TN >::evaluationMap_
private

◆ lazyParser_

template<class T , class C = T, typename TN = float>
const bool JetDeltaRValueMapProducer< T, C, TN >::lazyParser_
private

◆ matchedToken_

template<class T , class C = T, typename TN = float>
const edm::EDGetTokenT<typename edm::View<C> > JetDeltaRValueMapProducer< T, C, TN >::matchedToken_
private

◆ multiValue_

template<class T , class C = T, typename TN = float>
bool JetDeltaRValueMapProducer< T, C, TN >::multiValue_
private

◆ srcToken_

template<class T , class C = T, typename TN = float>
const edm::EDGetTokenT<typename edm::View<T> > JetDeltaRValueMapProducer< T, C, TN >::srcToken_
private

◆ value_

template<class T , class C = T, typename TN = float>
const std::string JetDeltaRValueMapProducer< T, C, TN >::value_
private

◆ valueLabels_

template<class T , class C = T, typename TN = float>
const std::vector<std::string> JetDeltaRValueMapProducer< T, C, TN >::valueLabels_
private

◆ values_

template<class T , class C = T, typename TN = float>
const std::vector<std::string> JetDeltaRValueMapProducer< T, C, TN >::values_
private