CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  objectEntryType
 

Public Member Functions

 ShiftedJetProducerByMatchedObjectT (const edm::ParameterSet &)
 
 ~ShiftedJetProducerByMatchedObjectT ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector< TJetCollection
 

Private Member Functions

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

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 28 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 {
13  srcJets_ = consumes<JetCollection>(cfg.getParameter<edm::InputTag>("srcJets"));
14  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
15  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
16 
17  dRmatch_Jet_ = cfg.getParameter<double>("dRmatch_Jet");
18  dRmatch_Object_ = cfg.exists("dRmatch_Object") ?
19  cfg.getParameter<double>("dRmatch_Object") : 0.1;
20 
23 
24  produces<JetCollection>();
25 }
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 28 of file ShiftedJetProducerByMatchedObject.cc.

29 {
30 // nothing to be done yet...
31 }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 34 of file ShiftedJetProducerByMatchedObject.cc.

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

35 {
36  edm::Handle<JetCollection> originalJets;
37  evt.getByToken(srcJets_, originalJets);
38 
39  edm::Handle<reco::CandidateView> unshiftedObjects;
40  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
41 
42  edm::Handle<reco::CandidateView> shiftedObjects;
43  evt.getByToken(srcShiftedObjects_, shiftedObjects);
44 
45  objects_.clear();
46 
47  std::vector<bool> match(shiftedObjects->size(), false);
48  int prevMatch=-1;
49  int cnt = 0;
50 
51  for ( reco::CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
52  unshiftedObject != unshiftedObjects->end(); ++unshiftedObject ) {
53  bool isMatched_Object = false;
54  double dR2bestMatch_Object = std::numeric_limits<double>::max();
55  prevMatch=-1;
56  cnt = 0;
57 
58  reco::Candidate::LorentzVector shiftedObjectP4_matched;
59  for ( reco::CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
60  shiftedObject != shiftedObjects->end(); ++shiftedObject ) {
61  if( match[ cnt ] ) continue;
62 
63  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
64  if ( dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object ) {
65  shiftedObjectP4_matched = shiftedObject->p4();
66  isMatched_Object = true;
67  dR2bestMatch_Object = dR2;
68 
69  prevMatch = cnt;
70  }
71  cnt++;
72  }
73  if ( isMatched_Object ) {
74  //Ambiguity removal
75  match[ prevMatch ] = true;
76  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
77  }
78  }
79 
80 
81  match.assign(objects_.size(), false);
82 
83  std::auto_ptr<JetCollection> shiftedJets(new JetCollection);
84 
85  for ( typename JetCollection::const_iterator originalJet = originalJets->begin();
86  originalJet != originalJets->end(); ++originalJet ) {
87 
88  double shift = 0.;
89  bool applyShift = false;
90  double dR2bestMatch_Jet = std::numeric_limits<double>::max();
91  prevMatch=-1;
92  cnt = 0;
93 
94  for ( typename std::vector<objectEntryType>::const_iterator object = objects_.begin();
95  object != objects_.end(); ++object ) {
96  if ( !object->isValidMatch_ ) continue;
97  if( match[ cnt ] ) continue;
98 
99  double dR2 = deltaR2(originalJet->p4(), object->unshiftedObjectP4_);
100  if ( dR2 < dR2match_Jet_ && dR2 < dR2bestMatch_Jet ) {
101  shift = object->shift_;
102  applyShift = true;
103  dR2bestMatch_Jet = dR2;
104 
105  prevMatch = cnt;
106  }
107  cnt++;
108  }
109 
110  reco::Candidate::LorentzVector shiftedJetP4 = originalJet->p4();
111  if ( applyShift ) {
112  //Ambiguity removal
113  match[ prevMatch ] = true;
114 
115  shiftedJetP4 *= (1. + shift);
116  }
117 
118  T shiftedJet(*originalJet);
119  shiftedJet.setP4(shiftedJetP4);
120 
121  shiftedJets->push_back(shiftedJet);
122  }
123 
124  evt.put(shiftedJets);
125 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
T sqrt(T t)
Definition: SSEVec.h:18
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
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 73 of file ShiftedJetProducerByMatchedObject.h.

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