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

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

Definition at line 27 of file ShiftedJetProducerByMatchedObject.h.

Constructor & Destructor Documentation

Definition at line 10 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_.

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 }
T getParameter(std::string const &) const
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_

Definition at line 26 of file ShiftedJetProducerByMatchedObject.cc.

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

Member Function Documentation

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

Definition at line 31 of file ShiftedJetProducerByMatchedObject.cc.

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

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
size_type size() const
const_iterator begin() const
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static unsigned int const shift
const_iterator end() const
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
def move(src, dest)
Definition: eostools.py:511

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