CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ShiftedPFCandidateProducerForPFMEtMVA.cc
Go to the documentation of this file.
2 
8 
10  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
11 {
12  srcPFCandidates_ = cfg.getParameter<edm::InputTag>("srcPFCandidates");
13  srcUnshiftedObjects_ = cfg.getParameter<edm::InputTag>("srcUnshiftedObjects");
14  srcShiftedObjects_ = cfg.getParameter<edm::InputTag>("srcShiftedObjects");
15 
16  dRmatch_PFCandidate_ = cfg.getParameter<double>("dRmatch_PFCandidate");
17  dRmatch_Object_ = cfg.exists("dRmatch_Object") ?
18  cfg.getParameter<double>("dRmatch_Object") : 0.1;
19 
20  produces<reco::PFCandidateCollection>();
21 }
22 
24 {
25 // nothing to be done yet...
26 }
27 
29 {
30  edm::Handle<reco::PFCandidateCollection> originalPFCandidates;
31  evt.getByLabel(srcPFCandidates_, originalPFCandidates);
32 
34 
35  edm::Handle<CandidateView> unshiftedObjects;
36  evt.getByLabel(srcUnshiftedObjects_, unshiftedObjects);
37 
38  edm::Handle<CandidateView> shiftedObjects;
39  evt.getByLabel(srcShiftedObjects_, shiftedObjects);
40 
41  objects_.clear();
42 
43  for ( CandidateView::const_iterator unshiftedObject = unshiftedObjects->begin();
44  unshiftedObject != unshiftedObjects->end(); ++unshiftedObject ) {
45  bool isMatched_Object = false;
46  double dRbestMatch_Object = 1.e+3;
47  reco::Candidate::LorentzVector shiftedObjectP4_matched;
48  for ( CandidateView::const_iterator shiftedObject = shiftedObjects->begin();
49  shiftedObject != shiftedObjects->end(); ++shiftedObject ) {
50  double dR = deltaR(unshiftedObject->p4(), shiftedObject->p4());
51  if ( dR < dRmatch_Object_ && dR < dRbestMatch_Object ) {
52  shiftedObjectP4_matched = shiftedObject->p4();
53  isMatched_Object = true;
54  dRbestMatch_Object = dR;
55  }
56  }
57  if ( isMatched_Object ) {
58  objects_.push_back(objectEntryType(shiftedObjectP4_matched, unshiftedObject->p4(), dRbestMatch_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 dRbestMatch_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 dR = deltaR(originalPFCandidate->p4(), object->unshiftedObjectP4_);
74  if ( dR < dRmatch_PFCandidate_ && dR < dRbestMatch_PFCandidate ) {
75  shift = object->shift_;
76  applyShift = true;
77  dRbestMatch_PFCandidate = dR;
78  }
79  }
80 
81  reco::Candidate::LorentzVector shiftedPFCandidateP4 = originalPFCandidate->p4();
82  if ( applyShift ) shiftedPFCandidateP4 *= (1. + shift);
83 
84  reco::PFCandidate shiftedPFCandidate(*originalPFCandidate);
85  shiftedPFCandidate.setP4(shiftedPFCandidateP4);
86 
87  shiftedPFCandidates->push_back(shiftedPFCandidate);
88  }
89 
90  evt.put(shiftedPFCandidates);
91 }
92 
94 
96 
97 
98 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool exists(std::string const &parameterName) const
checks if a parameter exists
virtual void setP4(const LorentzVector &p4)
set 4-momentum
void produce(edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
list object
Definition: dbtoconf.py:77
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
static unsigned int const shift
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23