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 Member Functions | Private Attributes
ShiftedPFCandidateProducerByMatchedObject Class Reference

#include <ShiftedPFCandidateProducerByMatchedObject.h>

Inheritance diagram for ShiftedPFCandidateProducerByMatchedObject:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  objectEntryType
 

Public Member Functions

 ShiftedPFCandidateProducerByMatchedObject (const edm::ParameterSet &)
 
 ~ShiftedPFCandidateProducerByMatchedObject ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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< edm::Handle
< reco::PFCandidateCollection > > 
srcPFCandidates_
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
srcShiftedObjects_
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
srcUnshiftedObjects_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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.

Author
Christian Veelken, LLR

Definition at line 31 of file ShiftedPFCandidateProducerByMatchedObject.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file ShiftedPFCandidateProducerByMatchedObject.cc.

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

6  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
7 {
8  srcPFCandidates_ = consumes<edm::Handle<reco::PFCandidateCollection> >(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
9  srcUnshiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcUnshiftedObjects"));
10  srcShiftedObjects_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcShiftedObjects"));
11 
12  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
14  dRmatch_Object_ = cfg.exists("dRmatch_Object") ?
15  cfg.getParameter<double>("dRmatch_Object") : 0.1;
17  produces<reco::PFCandidateCollection>();
18 }
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::Handle< reco::PFCandidateCollection > > srcPFCandidates_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
ShiftedPFCandidateProducerByMatchedObject::~ShiftedPFCandidateProducerByMatchedObject ( )

Definition at line 20 of file ShiftedPFCandidateProducerByMatchedObject.cc.

21 {
22 // nothing to be done yet...
23 }

Member Function Documentation

void ShiftedPFCandidateProducerByMatchedObject::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 25 of file ShiftedPFCandidateProducerByMatchedObject.cc.

References reco::deltaR2(), dR2match_Object_, dR2match_PFCandidate_, edm::Event::getByToken(), dbtoconf::object, objects_, edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, mathSSE::sqrt(), srcPFCandidates_, srcShiftedObjects_, and srcUnshiftedObjects_.

26 {
27  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
28  evt.getByToken(srcPFCandidates_, originalPFCandidates);
29 
31 
32  edm::Handle<CandidateView> unshiftedObjects;
33  evt.getByToken(srcUnshiftedObjects_, unshiftedObjects);
34 
35  edm::Handle<CandidateView> shiftedObjects;
36  evt.getByToken(srcShiftedObjects_, shiftedObjects);
37 
38  objects_.clear();
39 
40  CandidateView::const_iterator shiftedObjectP4_matched;
41  bool isMatched_Object = false;
42  double dR2bestMatch_Object = 1.e+3;
43  for ( CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
44  unshiftedObject != unshiftedObjects->end(); ++unshiftedObject ) {
45  isMatched_Object = false;
46  dR2bestMatch_Object = 1.e+3;
47 
48  for ( CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
49  shiftedObject != shiftedObjects->end(); ++shiftedObject ) {
50  double dR2 = deltaR2(unshiftedObject->p4(), shiftedObject->p4());
51  if ( dR2 < dR2match_Object_ && dR2 < dR2bestMatch_Object ) {
52  shiftedObjectP4_matched = shiftedObject;
53  isMatched_Object = true;
54  dR2bestMatch_Object = dR2;
55  }
56  }
57  if ( isMatched_Object ) {
58  objects_.push_back(objectEntryType(shiftedObjectP4_matched->p4(), unshiftedObject->p4(), sqrt(dR2bestMatch_Object) ));
59  }
60  }
61 
62  std::auto_ptr<reco::PFCandidateCollection> shiftedPFCandidates(new reco::PFCandidateCollection);
63 
64  for ( reco::PFCandidateCollection::const_iterator originalPFCandidate = originalPFCandidates->begin();
65  originalPFCandidate != originalPFCandidates->end(); ++originalPFCandidate ) {
66 
67  double shift = 0.;
68  bool applyShift = false;
69  double dR2bestMatch_PFCandidate = 1.e+3;
70  for ( std::vector<objectEntryType>::const_iterator object = objects_.begin();
71  object != objects_.end(); ++object ) {
72  if ( !object->isValidMatch_ ) continue;
73  double dR2 = deltaR2(originalPFCandidate->p4(), object->unshiftedObjectP4_);
74  if ( dR2 < dR2match_PFCandidate_ && dR2 < dR2bestMatch_PFCandidate ) {
75  shift = object->shift_;
76  applyShift = true;
77  dR2bestMatch_PFCandidate = dR2;
78  }
79  }
80 
81  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
82  if ( applyShift ) {
83  double shiftedPx = (1. + shift)*originalPFCandidate->px();
84  double shiftedPy = (1. + shift)*originalPFCandidate->py();
85  double shiftedPz = (1. + shift)*originalPFCandidate->pz();
86  double mass = originalPFCandidate->mass();
87  double shiftedEn = TMath::Sqrt(shiftedPx*shiftedPx + shiftedPy*shiftedPy + shiftedPz*shiftedPz + mass*mass);
88  shiftedPFCandidateP4.SetPxPyPzE(shiftedPx, shiftedPy, shiftedPz, shiftedEn);
89  }
90 
91  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
92  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
93 
94  shiftedPFCandidates->push_back(shiftedPFCandidate);
95  }
96 
97  evt.put(shiftedPFCandidates);
98 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
edm::EDGetTokenT< edm::View< reco::Candidate > > srcShiftedObjects_
edm::View< reco::Candidate > CandidateView
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
T sqrt(T t)
Definition: SSEVec.h:48
edm::EDGetTokenT< edm::Handle< reco::PFCandidateCollection > > srcPFCandidates_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcUnshiftedObjects_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58
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:81
static unsigned int const shift

Member Data Documentation

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

Definition at line 75 of file ShiftedPFCandidateProducerByMatchedObject.h.

Referenced by produce().

edm::EDGetTokenT<edm::Handle<reco::PFCandidateCollection> > ShiftedPFCandidateProducerByMatchedObject::srcPFCandidates_
private
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedPFCandidateProducerByMatchedObject::srcShiftedObjects_
private
edm::EDGetTokenT<edm::View<reco::Candidate> > ShiftedPFCandidateProducerByMatchedObject::srcUnshiftedObjects_
private