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
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)
 
 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 (const std::string &iProcessName, std::vector< const char * > &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 edm::View
< reco::Candidate
CandidateView
 

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::PFCandidateCollection
srcPFCandidatesToken_
 
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, 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

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

Implements edm::stream::EDProducerBase.

Definition at line 28 of file ShiftedPFCandidateProducerForPFMVAMEt.cc.

References reco::deltaR2(), dR2match_Object_, dR2match_PFCandidate_, dRDefault, edm::Event::getByToken(), match(), dbtoconf::object, objects_, edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, 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  std::auto_ptr<reco::PFCandidateCollection> shiftedPFCandidates(new 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(shiftedPFCandidates);
117 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
T sqrt(T t)
Definition: SSEVec.h:48
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
list object
Definition: dbtoconf.py:77
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
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
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().