CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTHtMhtProducer.cc
Go to the documentation of this file.
1 
10 
15 
16 
17 // Constructor
19  usePt_ ( iConfig.getParameter<bool>("usePt") ),
20  excludePFMuons_ ( iConfig.getParameter<bool>("excludePFMuons") ),
21  minNJetHt_ ( iConfig.getParameter<int>("minNJetHt") ),
22  minNJetMht_ ( iConfig.getParameter<int>("minNJetMht") ),
23  minPtJetHt_ ( iConfig.getParameter<double>("minPtJetHt") ),
24  minPtJetMht_ ( iConfig.getParameter<double>("minPtJetMht") ),
25  maxEtaJetHt_ ( iConfig.getParameter<double>("maxEtaJetHt") ),
26  maxEtaJetMht_ ( iConfig.getParameter<double>("maxEtaJetMht") ),
27  jetsLabel_ ( iConfig.getParameter<edm::InputTag>("jetsLabel") ),
28  pfCandidatesLabel_ ( iConfig.getParameter<edm::InputTag>("pfCandidatesLabel") ) {
29  m_theJetToken = consumes<edm::View<reco::Jet>>(jetsLabel_);
30  m_thePFCandidateToken = consumes<reco::PFCandidateCollection>(pfCandidatesLabel_);
31 
32  // Register the products
33  produces<reco::METCollection>();
34 }
35 
36 // Destructor
38 
39 // Fill descriptions
41  // Current default is for hltHtMht
43  desc.add<bool>("usePt", false);
44  desc.add<bool>("excludePFMuons", false);
45  desc.add<int>("minNJetHt", 0);
46  desc.add<int>("minNJetMht", 0);
47  desc.add<double>("minPtJetHt", 40.);
48  desc.add<double>("minPtJetMht", 30.);
49  desc.add<double>("maxEtaJetHt", 3.);
50  desc.add<double>("maxEtaJetMht", 5.);
51  desc.add<edm::InputTag>("jetsLabel", edm::InputTag("hltCaloJetL1FastJetCorrected"));
52  desc.add<edm::InputTag>("pfCandidatesLabel", edm::InputTag("hltParticleFlow"));
53  descriptions.add("hltHtMhtProducer", desc);
54 }
55 
56 // Produce the products
58 
59  // Create a pointer to the products
60  std::auto_ptr<reco::METCollection> result(new reco::METCollection());
61 
62  if (pfCandidatesLabel_.label() == "")
63  excludePFMuons_ = false;
64 
66  iEvent.getByToken(m_theJetToken, jets);
67 
69  if (excludePFMuons_)
70  iEvent.getByToken(m_thePFCandidateToken, pfCandidates);
71 
72  int nj_ht = 0, nj_mht = 0;
73  double ht = 0., mhx = 0., mhy = 0.;
74 
75  if (jets->size() > 0) {
76  for(reco::JetView::const_iterator j = jets->begin(); j != jets->end(); ++j) {
77  double pt = usePt_ ? j->pt() : j->et();
78  double eta = j->eta();
79  double phi = j->phi();
80  double px = usePt_ ? j->px() : j->et() * cos(phi);
81  double py = usePt_ ? j->py() : j->et() * sin(phi);
82 
83  if (pt > minPtJetHt_ && std::abs(eta) < maxEtaJetHt_) {
84  ht += pt;
85  ++nj_ht;
86  }
87 
88  if (pt > minPtJetMht_ && std::abs(eta) < maxEtaJetMht_) {
89  mhx -= px;
90  mhy -= py;
91  ++nj_mht;
92  }
93  }
94  }
95 
96  if (excludePFMuons_) {
97  for (reco::PFCandidateCollection::const_iterator j = pfCandidates->begin(); j != pfCandidates->end(); ++j) {
98  if (std::abs(j->pdgId()) == 13) {
99  mhx += j->px();
100  mhy += j->py();
101  }
102  }
103  }
104 
105  if (nj_ht < minNJetHt_ ) { ht = 0; }
106  if (nj_mht < minNJetMht_) { mhx = 0; mhy = 0; }
107 
108  reco::MET::LorentzVector p4(mhx, mhy, 0, sqrt(mhx*mhx + mhy*mhy));
109  reco::MET::Point vtx(0, 0, 0);
110  reco::MET htmht(ht, p4, vtx);
111  result->push_back(htmht);
112 
113  // Put the products into the Event
114  iEvent.put(result);
115 }
edm::InputTag pfCandidatesLabel_
edm::EDGetTokenT< reco::PFCandidateCollection > m_thePFCandidateToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
int minNJetHt_
Minimum number of jets passing pt and eta requirements.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double minPtJetHt_
Minimum pt requirement for jets.
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
tuple result
Definition: mps_fire.py:95
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
Definition: MET.h:42
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
vector< PseudoJet > jets
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double maxEtaJetHt_
Maximum (abs) eta requirement for jets.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
std::string const & label() const
Definition: InputTag.h:36
bool usePt_
Use pt; otherwise, use et.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
HLTHtMhtProducer(const edm::ParameterSet &iConfig)
edm::InputTag jetsLabel_
Input jet, PFCandidate collections.
edm::EDGetTokenT< reco::JetView > m_theJetToken
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)