CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedPFCandidateProducerForPFMVAMEt Class Reference

#include <ShiftedPFCandidateProducerForPFMVAMEt.h>

Inheritance diagram for ShiftedPFCandidateProducerForPFMVAMEt:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  objectEntryType
 

Public Member Functions

 ShiftedPFCandidateProducerForPFMVAMEt (const edm::ParameterSet &)
 
 ~ShiftedPFCandidateProducerForPFMVAMEt ()
 
- 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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef edm::View< reco::CandidateCandidateView
 

Private Member Functions

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

Private Attributes

double dR2match_Object_
 
double dR2match_PFCandidate_
 
double dRmatch_Object_
 
double dRmatch_PFCandidate_
 
std::string moduleLabel_
 
std::vector< objectEntryTypeobjects_
 
edm::EDGetTokenT< reco::PFCandidateCollectionsrcPFCandidatesToken_
 
edm::EDGetTokenT< CandidateViewsrcShiftedObjectsToken_
 
edm::EDGetTokenT< CandidateViewsrcUnshiftedObjectsToken_
 

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

Vary energy of PFCandidates coinciding in eta-phi with selected electrons/muons/tau-jets/jets by electron/muon/tau-jet/jet energy uncertainty.

NOTE: Auxiliary class specific to estimating systematic uncertainty on PFMET reconstructed by MVA-based algorithm (implemented in RecoMET/METPUSubtraction/src/PFMETProducerMVA.cc)

Author
Christian Veelken, LLR

Definition at line 33 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Member Typedef Documentation

Definition at line 41 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Constructor & Destructor Documentation

ShiftedPFCandidateProducerForPFMVAMEt::ShiftedPFCandidateProducerForPFMVAMEt ( const edm::ParameterSet cfg)
explicit

Definition at line 7 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

References dR2match_Object_, dR2match_PFCandidate_, dRmatch_Object_, dRmatch_PFCandidate_, edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

8  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
9  , srcPFCandidatesToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates")))
10  , srcUnshiftedObjectsToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects")))
11  , srcShiftedObjectsToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcShiftedObjects")))
12 {
13  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
14  dRmatch_Object_ = cfg.exists("dRmatch_Object") ?
15  cfg.getParameter<double>("dRmatch_Object") : 0.1;
16 
18  dR2match_Object_ = dRmatch_Object_*dRmatch_Object_;
19 
20  produces<reco::PFCandidateCollection>();
21 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< CandidateView > srcUnshiftedObjectsToken_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_
ShiftedPFCandidateProducerForPFMVAMEt::~ShiftedPFCandidateProducerForPFMVAMEt ( )

Definition at line 23 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

24 {
25 // nothing to be done yet...
26 }

Member Function Documentation

void ShiftedPFCandidateProducerForPFMVAMEt::produce ( edm::Event evt,
const edm::EventSetup es 
)
private

Definition at line 28 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

References edm::View< T >::begin(), DEFINE_FWK_MODULE, reco::deltaR2(), dR2match_Object_, dR2match_PFCandidate_, dRDefault, edm::View< T >::end(), edm::Event::getByToken(), match(), eostools::move(), resolutioncreator_cfi::object, objects_, edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, edm::View< T >::size(), mathSSE::sqrt(), srcPFCandidatesToken_, srcShiftedObjectsToken_, and srcUnshiftedObjectsToken_.

29 {
30  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
31  evt.getByToken(srcPFCandidatesToken_, originalPFCandidates);
32 
33  edm::Handle<CandidateView> unshiftedObjects;
34  evt.getByToken(srcUnshiftedObjectsToken_, unshiftedObjects);
35 
36  edm::Handle<CandidateView> shiftedObjects;
37  evt.getByToken(srcShiftedObjectsToken_, shiftedObjects);
38 
39  objects_.clear();
40 
41  std::vector<bool> match(shiftedObjects->size(), false);
42  int prevMatch=-1;
43  int cnt = 0;
44 
45  for ( CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
46  unshiftedObject != unshiftedObjects->end(); ++unshiftedObject ) {
47  bool isMatched_Object = false;
48  double dR2bestMatch_Object = dRDefault;
49  reco::Candidate::LorentzVector shiftedObjectP4_matched;
50  prevMatch=-1;
51 
52  for ( CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
53  shiftedObject != shiftedObjects->end(); ++shiftedObject ) {
54  if( match[ cnt ] ) continue;
55 
56  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
57  if ( dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object ) {
58  shiftedObjectP4_matched = shiftedObject->p4();
59  isMatched_Object = true;
60  dR2bestMatch_Object = dR2;
61 
62  prevMatch = cnt;
63  }
64  cnt++;
65  }
66  if ( isMatched_Object ) {
67  //Ambiguity removal
68  match[ prevMatch ] = true;
69  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), sqrt(dR2bestMatch_Object)));
70  }
71  }
72 
73  match.assign(objects_.size(), false);
74 
75  auto shiftedPFCandidates = std::make_unique<reco::PFCandidateCollection>();
76 
77  for ( reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
78  originalPFCandidate != originalPFCandidates->end(); ++originalPFCandidate ) {
79 
80  double shift = 0.;
81  bool applyShift = false;
82  double dR2bestMatch_PFCandidate = dRDefault;
83  prevMatch=-1;
84  cnt = 0;
85 
86  for ( std::vector<objectEntryType>::const_iterator object = objects_.begin();
87  object != objects_.end(); ++object ) {
88  if ( !object->isValidMatch_ ) continue;
89  if( match[ cnt ] ) continue;
90 
91  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
92  if ( dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate ) {
93  shift = object->shift_;
94  applyShift = true;
95  dR2bestMatch_PFCandidate = dR2;
96 
97  prevMatch = cnt;
98  }
99  cnt++;
100  }
101 
102  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
103  if ( applyShift ) {
104  //Ambiguity removal
105  match[ prevMatch ] = true;
106 
107  shiftedPFCandidateP4 *= (1. + shift);
108  }
109 
110  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
111  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
112 
113  shiftedPFCandidates->push_back(shiftedPFCandidate);
114  }
115 
116  evt.put(std::move(shiftedPFCandidates));
117 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
size_type size() const
const double dRDefault
const_iterator begin() const
T sqrt(T t)
Definition: SSEVec.h:18
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
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
def move(src, dest)
Definition: eostools.py:510
edm::EDGetTokenT< CandidateView > srcUnshiftedObjectsToken_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidatesToken_

Member Data Documentation

double ShiftedPFCandidateProducerForPFMVAMEt::dR2match_Object_
private
double ShiftedPFCandidateProducerForPFMVAMEt::dR2match_PFCandidate_
private
double ShiftedPFCandidateProducerForPFMVAMEt::dRmatch_Object_
private
double ShiftedPFCandidateProducerForPFMVAMEt::dRmatch_PFCandidate_
private
std::string ShiftedPFCandidateProducerForPFMVAMEt::moduleLabel_
private
std::vector<objectEntryType> ShiftedPFCandidateProducerForPFMVAMEt::objects_
private

Definition at line 80 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

edm::EDGetTokenT<reco::PFCandidateCollection> ShiftedPFCandidateProducerForPFMVAMEt::srcPFCandidatesToken_
private

Definition at line 47 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

edm::EDGetTokenT<CandidateView> ShiftedPFCandidateProducerForPFMVAMEt::srcShiftedObjectsToken_
private

Definition at line 49 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().

edm::EDGetTokenT<CandidateView> ShiftedPFCandidateProducerForPFMVAMEt::srcUnshiftedObjectsToken_
private

Definition at line 48 of file ShiftedPFCandidateProducerForPFMVAMEt.h.

Referenced by produce().