test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTCaloTowerHtMhtProducer.cc
Go to the documentation of this file.
1 
11 
16 
17 
18 // Constructor
20  usePt_ ( iConfig.getParameter<bool>("usePt") ),
21  minPtTowerHt_ ( iConfig.getParameter<double>("minPtTowerHt") ),
22  minPtTowerMht_ ( iConfig.getParameter<double>("minPtTowerMht") ),
23  maxEtaTowerHt_ ( iConfig.getParameter<double>("maxEtaTowerHt") ),
24  maxEtaTowerMht_ ( iConfig.getParameter<double>("maxEtaTowerMht") ),
25  towersLabel_ ( iConfig.getParameter<edm::InputTag>("towersLabel") ) {
26  m_theTowersToken = consumes<CaloTowerCollection>(towersLabel_);
27 
28  // Register the products
29  produces<reco::METCollection>();
30 }
31 
32 // Destructor
34 
35 // Fill descriptions
37  // Current default is for hltHtMht
39  desc.add<bool>("usePt", false);
40  desc.add<double>("minPtTowerHt", 1.);
41  desc.add<double>("minPtTowerMht", 1.);
42  desc.add<double>("maxEtaTowerHt", 5.);
43  desc.add<double>("maxEtaTowerMht", 5.);
44  desc.add<edm::InputTag>("towersLabel", edm::InputTag("hltTowerMakerForAll"));
45  descriptions.add("hltCaloTowerHtMhtProducer", desc);
46 }
47 
48 // Produce the products
50 
51  // Create a pointer to the products
52  std::auto_ptr<reco::METCollection> result(new reco::METCollection());
53 
55  iEvent.getByToken(m_theTowersToken, towers);
56 
57  double ht = 0., mhx = 0., mhy = 0.;
58 
59  if (towers->size() > 0) {
60  for(CaloTowerCollection::const_iterator j = towers->begin(); j != towers->end(); ++j) {
61  double pt = usePt_ ? j->pt() : j->et();
62  double eta = j->eta();
63  double phi = j->phi();
64  double px = usePt_ ? j->px() : j->et() * cos(phi);
65  double py = usePt_ ? j->py() : j->et() * sin(phi);
66 
67  if (pt > minPtTowerHt_ && std::abs(eta) < maxEtaTowerHt_) {
68  ht += pt;
69  }
70 
71  if (pt > minPtTowerMht_ && std::abs(eta) < maxEtaTowerMht_) {
72  mhx -= px;
73  mhy -= py;
74  }
75  }
76  }
77 
78  reco::MET::LorentzVector p4(mhx, mhy, 0, sqrt(mhx*mhx + mhy*mhy));
79  reco::MET::Point vtx(0, 0, 0);
80  reco::MET htmht(ht, p4, vtx);
81  result->push_back(htmht);
82 
83  // Put the products into the Event
84  iEvent.put(result);
85 }
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< CaloTower >::const_iterator const_iterator
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
HLTCaloTowerHtMhtProducer(const edm::ParameterSet &iConfig)
tuple result
Definition: mps_fire.py:83
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
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double minPtTowerHt_
Minimum pt requirement for jets.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
edm::InputTag towersLabel_
Input CaloTower collection.
edm::EDGetTokenT< CaloTowerCollection > m_theTowersToken
double maxEtaTowerHt_
Maximum (abs) eta requirement for jets.
bool usePt_
Use pt; otherwise, use et.
math::XYZPoint Point
point in the space
Definition: Candidate.h:41