CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedJetProducerByMatchedObjectT< T > Class Template Reference
Inheritance diagram for ShiftedJetProducerByMatchedObjectT< T >:
edm::stream::EDProducer<>

Classes

struct  objectEntryType
 

Public Member Functions

 ShiftedJetProducerByMatchedObjectT (const edm::ParameterSet &)
 
 ~ShiftedJetProducerByMatchedObjectT () 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 Types

typedef std::vector< TJetCollection
 

Private Member Functions

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

Private Attributes

double dR2match_Jet_
 
double dR2match_Object_
 
double dRmatch_Jet_
 
double dRmatch_Object_
 
std::string moduleLabel_
 
std::vector< objectEntryTypeobjects_
 
edm::EDGetTokenT< JetCollectionsrcJets_
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
srcShiftedObjects_
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
srcUnshiftedObjects_
 

Additional Inherited Members

- 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
 

Detailed Description

template<typename T>
class ShiftedJetProducerByMatchedObjectT< T >

Definition at line 27 of file ShiftedJetProducerByMatchedObject.cc.

Member Typedef Documentation

template<typename T >
typedef std::vector<T> ShiftedJetProducerByMatchedObjectT< T >::JetCollection
private

Definition at line 28 of file ShiftedJetProducerByMatchedObject.cc.

Constructor & Destructor Documentation

Definition at line 74 of file ShiftedJetProducerByMatchedObject.cc.

References ShiftedJetProducerByMatchedObjectT< T >::dR2match_Jet_, ShiftedJetProducerByMatchedObjectT< T >::dR2match_Object_, ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Jet_, ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Object_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), ShiftedJetProducerByMatchedObjectT< T >::srcJets_, ShiftedJetProducerByMatchedObjectT< T >::srcShiftedObjects_, and ShiftedJetProducerByMatchedObjectT< T >::srcUnshiftedObjects_.

75  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
76  srcJets_ = consumes<JetCollection>(cfg.getParameter<edm::InputTag>("srcJets"));
77  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
78  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
79 
80  dRmatch_Jet_ = cfg.getParameter<double>("dRmatch_Jet");
81  dRmatch_Object_ = cfg.exists("dRmatch_Object") ? cfg.getParameter<double>("dRmatch_Object") : 0.1;
82 
85 
86  produces<JetCollection>();
87 }
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Definition at line 90 of file ShiftedJetProducerByMatchedObject.cc.

90  {
91  // nothing to be done yet...
92 }

Member Function Documentation

template<typename T >
void ShiftedJetProducerByMatchedObjectT< T >::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 95 of file ShiftedJetProducerByMatchedObject.cc.

References reco::deltaR2(), edm::Event::getByToken(), match(), SiStripPI::max, eostools::move(), edm::Event::put(), edm::shift, and mathSSE::sqrt().

95  {
96  edm::Handle<JetCollection> originalJets;
97  evt.getByToken(srcJets_, originalJets);
98 
99  edm::Handle<reco::CandidateView> unshiftedObjects;
100  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
101 
102  edm::Handle<reco::CandidateView> shiftedObjects;
103  evt.getByToken(srcShiftedObjects_, shiftedObjects);
104 
105  objects_.clear();
106 
107  std::vector<bool> match(shiftedObjects->size(), false);
108  int prevMatch = -1;
109  int cnt = 0;
110 
111  for (reco::CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
112  unshiftedObject != unshiftedObjects->end();
113  ++unshiftedObject) {
114  bool isMatched_Object = false;
115  double dR2bestMatch_Object = std::numeric_limits<double>::max();
116  prevMatch = -1;
117  cnt = 0;
118 
119  reco::Candidate::LorentzVector shiftedObjectP4_matched;
120  for (reco::CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
121  shiftedObject != shiftedObjects->end();
122  ++shiftedObject) {
123  if (match[cnt])
124  continue;
125 
126  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
127  if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
128  shiftedObjectP4_matched = shiftedObject->p4();
129  isMatched_Object = true;
130  dR2bestMatch_Object = dR2;
131 
132  prevMatch = cnt;
133  }
134  cnt++;
135  }
136  if (isMatched_Object) {
137  //Ambiguity removal
138  match[prevMatch] = true;
139  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
140  }
141  }
142 
143  match.assign(objects_.size(), false);
144 
145  auto shiftedJets = std::make_unique<JetCollection>();
146 
147  for (typename JetCollection::const_iterator originalJet = originalJets->begin(); originalJet != originalJets->end();
148  ++originalJet) {
149  double shift = 0.;
150  bool applyShift = false;
151  double dR2bestMatch_Jet = std::numeric_limits<double>::max();
152  prevMatch = -1;
153  cnt = 0;
154 
155  for (typename std::vector<objectEntryType>::const_iterator object = objects_.begin(); object != objects_.end();
156  ++object) {
157  if (!object->isValidMatch_)
158  continue;
159  if (match[cnt])
160  continue;
161 
162  double dR2 = deltaR2(originalJet->p4(), object->unshiftedObjectP4_);
163  if (dR2 < dR2match_Jet_ && dR2 < dR2bestMatch_Jet) {
164  shift = object->shift_;
165  applyShift = true;
166  dR2bestMatch_Jet = dR2;
167 
168  prevMatch = cnt;
169  }
170  cnt++;
171  }
172 
173  reco::Candidate::LorentzVector shiftedJetP4 = originalJet->p4();
174  if (applyShift) {
175  //Ambiguity removal
176  match[prevMatch] = true;
177 
178  shiftedJetP4 *= (1. + shift);
179  }
180 
181  T shiftedJet(*originalJet);
182  shiftedJet.setP4(shiftedJetP4);
183 
184  shiftedJets->push_back(shiftedJet);
185  }
186 
187  evt.put(std::move(shiftedJets));
188 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static unsigned int const shift
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
long double T

Member Data Documentation

template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dR2match_Jet_
private
template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dR2match_Object_
private
template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Jet_
private
template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Object_
private
template<typename T >
std::string ShiftedJetProducerByMatchedObjectT< T >::moduleLabel_
private
template<typename T >
std::vector<objectEntryType> ShiftedJetProducerByMatchedObjectT< T >::objects_
private

Definition at line 70 of file ShiftedJetProducerByMatchedObject.cc.

template<typename T >
edm::EDGetTokenT<JetCollection> ShiftedJetProducerByMatchedObjectT< T >::srcJets_
private
template<typename T >
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedJetProducerByMatchedObjectT< T >::srcShiftedObjects_
private
template<typename T >
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedJetProducerByMatchedObjectT< T >::srcUnshiftedObjects_
private