CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedJetProducerByMatchedObjectT< T > Class Template Reference

#include <ShiftedJetProducerByMatchedObject.h>

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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
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
 

Detailed Description

template<typename T>
class ShiftedJetProducerByMatchedObjectT< T >

Definition at line 26 of file ShiftedJetProducerByMatchedObject.h.

Member Typedef Documentation

◆ JetCollection

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

Definition at line 27 of file ShiftedJetProducerByMatchedObject.h.

Constructor & Destructor Documentation

◆ ShiftedJetProducerByMatchedObjectT()

Definition at line 10 of file ShiftedJetProducerByMatchedObject.cc.

11  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
12  srcJets_ = consumes<JetCollection>(cfg.getParameter<edm::InputTag>("srcJets"));
13  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
14  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
15 
16  dRmatch_Jet_ = cfg.getParameter<double>("dRmatch_Jet");
17  dRmatch_Object_ = cfg.exists("dRmatch_Object") ? cfg.getParameter<double>("dRmatch_Object") : 0.1;
18 
21 
22  produces<JetCollection>();
23 }

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 26 of file ShiftedJetProducerByMatchedObject.cc.

26  {
27  // nothing to be done yet...
28 }

Member Function Documentation

◆ produce()

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

Definition at line 31 of file ShiftedJetProducerByMatchedObject.cc.

31  {
32  edm::Handle<JetCollection> originalJets;
33  evt.getByToken(srcJets_, originalJets);
34 
35  edm::Handle<reco::CandidateView> unshiftedObjects;
36  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
37 
38  edm::Handle<reco::CandidateView> shiftedObjects;
39  evt.getByToken(srcShiftedObjects_, shiftedObjects);
40 
41  objects_.clear();
42 
43  std::vector<bool> match(shiftedObjects->size(), false);
44  int prevMatch = -1;
45  int cnt = 0;
46 
47  for (reco::CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
48  unshiftedObject != unshiftedObjects->end();
49  ++unshiftedObject) {
50  bool isMatched_Object = false;
51  double dR2bestMatch_Object = std::numeric_limits<double>::max();
52  prevMatch = -1;
53  cnt = 0;
54 
55  reco::Candidate::LorentzVector shiftedObjectP4_matched;
56  for (reco::CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
57  shiftedObject != shiftedObjects->end();
58  ++shiftedObject) {
59  if (match[cnt])
60  continue;
61 
62  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
63  if (dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object) {
64  shiftedObjectP4_matched = shiftedObject->p4();
65  isMatched_Object = true;
66  dR2bestMatch_Object = dR2;
67 
68  prevMatch = cnt;
69  }
70  cnt++;
71  }
72  if (isMatched_Object) {
73  //Ambiguity removal
74  match[prevMatch] = true;
75  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
76  }
77  }
78 
79  match.assign(objects_.size(), false);
80 
81  auto shiftedJets = std::make_unique<JetCollection>();
82 
83  for (typename JetCollection::const_iterator originalJet = originalJets->begin(); originalJet != originalJets->end();
84  ++originalJet) {
85  double shift = 0.;
86  bool applyShift = false;
87  double dR2bestMatch_Jet = std::numeric_limits<double>::max();
88  prevMatch = -1;
89  cnt = 0;
90 
91  for (typename std::vector<objectEntryType>::const_iterator object = objects_.begin(); object != objects_.end();
92  ++object) {
93  if (!object->isValidMatch_)
94  continue;
95  if (match[cnt])
96  continue;
97 
98  double dR2 = deltaR2(originalJet->p4(), object->unshiftedObjectP4_);
99  if (dR2 < dR2match_Jet_ && dR2 < dR2bestMatch_Jet) {
100  shift = object->shift_;
101  applyShift = true;
102  dR2bestMatch_Jet = dR2;
103 
104  prevMatch = cnt;
105  }
106  cnt++;
107  }
108 
109  reco::Candidate::LorentzVector shiftedJetP4 = originalJet->p4();
110  if (applyShift) {
111  //Ambiguity removal
112  match[prevMatch] = true;
113 
114  shiftedJetP4 *= (1. + shift);
115  }
116 
117  T shiftedJet(*originalJet);
118  shiftedJet.setP4(shiftedJetP4);
119 
120  shiftedJets->push_back(shiftedJet);
121  }
122 
123  evt.put(std::move(shiftedJets));
124 }

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 69 of file ShiftedJetProducerByMatchedObject.h.

◆ 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.h:38
edm::Handle
Definition: AssociativeIterator.h:50
ShiftedJetProducerByMatchedObjectT::dRmatch_Jet_
double dRmatch_Jet_
Definition: ShiftedJetProducerByMatchedObject.h:42
ShiftedJetProducerByMatchedObjectT::srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
Definition: ShiftedJetProducerByMatchedObject.h:40
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
ShiftedJetProducerByMatchedObjectT::dR2match_Jet_
double dR2match_Jet_
Definition: ShiftedJetProducerByMatchedObject.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View::size
size_type size() const
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
ShiftedJetProducerByMatchedObjectT::srcUnshiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
Definition: ShiftedJetProducerByMatchedObject.h:39
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:132
ShiftedJetProducerByMatchedObjectT::dRmatch_Object_
double dRmatch_Object_
Definition: ShiftedJetProducerByMatchedObject.h:43
looper.cfg
cfg
Definition: looper.py:297
ShiftedJetProducerByMatchedObjectT::objects_
std::vector< objectEntryType > objects_
Definition: ShiftedJetProducerByMatchedObject.h:69
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.h:46
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.h:36