CMS 3D CMS Logo

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

◆ JetCollection

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

Definition at line 28 of file ShiftedJetProducerByMatchedObject.cc.

Constructor & Destructor Documentation

◆ ShiftedJetProducerByMatchedObjectT()

Definition at line 74 of file ShiftedJetProducerByMatchedObject.cc.

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 }

References looper::cfg, ShiftedJetProducerByMatchedObjectT< T >::dR2match_Jet_, ShiftedJetProducerByMatchedObjectT< T >::dR2match_Object_, ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Jet_, ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Object_, ShiftedJetProducerByMatchedObjectT< T >::srcJets_, ShiftedJetProducerByMatchedObjectT< T >::srcShiftedObjects_, and ShiftedJetProducerByMatchedObjectT< T >::srcUnshiftedObjects_.

◆ ~ShiftedJetProducerByMatchedObjectT()

Definition at line 90 of file ShiftedJetProducerByMatchedObject.cc.

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

Member Function Documentation

◆ produce()

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

Definition at line 95 of file ShiftedJetProducerByMatchedObject.cc.

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 }

References edm::View< T >::begin(), HLTMuonOfflineAnalyzer_cfi::deltaR2, edm::View< T >::end(), edm::Event::getByToken(), match(), SiStripPI::max, eostools::move(), resolutioncreator_cfi::object, edm::Event::put(), edm::shift, edm::View< T >::size(), and mathSSE::sqrt().

Member Data Documentation

◆ dR2match_Jet_

template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dR2match_Jet_
private

◆ dR2match_Object_

template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dR2match_Object_
private

◆ dRmatch_Jet_

template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Jet_
private

◆ dRmatch_Object_

template<typename T >
double ShiftedJetProducerByMatchedObjectT< T >::dRmatch_Object_
private

◆ moduleLabel_

template<typename T >
std::string ShiftedJetProducerByMatchedObjectT< T >::moduleLabel_
private

◆ objects_

template<typename T >
std::vector<objectEntryType> ShiftedJetProducerByMatchedObjectT< T >::objects_
private

Definition at line 70 of file ShiftedJetProducerByMatchedObject.cc.

◆ srcJets_

template<typename T >
edm::EDGetTokenT<JetCollection> ShiftedJetProducerByMatchedObjectT< T >::srcJets_
private

◆ srcShiftedObjects_

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

◆ srcUnshiftedObjects_

template<typename T >
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedJetProducerByMatchedObjectT< T >::srcUnshiftedObjects_
private
edm::View::begin
const_iterator begin() const
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
ShiftedJetProducerByMatchedObjectT::srcJets_
edm::EDGetTokenT< JetCollection > srcJets_
Definition: ShiftedJetProducerByMatchedObject.cc:39
edm::Handle
Definition: AssociativeIterator.h:50
ShiftedJetProducerByMatchedObjectT::dRmatch_Jet_
double dRmatch_Jet_
Definition: ShiftedJetProducerByMatchedObject.cc:43
ShiftedJetProducerByMatchedObjectT::srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
Definition: ShiftedJetProducerByMatchedObject.cc:41
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
ShiftedJetProducerByMatchedObjectT::dR2match_Jet_
double dR2match_Jet_
Definition: ShiftedJetProducerByMatchedObject.cc:46
edm::View::size
size_type size() const
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
ShiftedJetProducerByMatchedObjectT::srcUnshiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
Definition: ShiftedJetProducerByMatchedObject.cc:40
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
ShiftedJetProducerByMatchedObjectT::dRmatch_Object_
double dRmatch_Object_
Definition: ShiftedJetProducerByMatchedObject.cc:44
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
ShiftedJetProducerByMatchedObjectT::objects_
std::vector< objectEntryType > objects_
Definition: ShiftedJetProducerByMatchedObject.cc:70
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
T
long double T
Definition: Basic3DVectorLD.h:48
ShiftedJetProducerByMatchedObjectT::dR2match_Object_
double dR2match_Object_
Definition: ShiftedJetProducerByMatchedObject.cc:47
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::View::end
const_iterator end() const
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::InputTag
Definition: InputTag.h:15
ShiftedJetProducerByMatchedObjectT::moduleLabel_
std::string moduleLabel_
Definition: ShiftedJetProducerByMatchedObject.cc:37