CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMhtProducer.cc
Go to the documentation of this file.
1 
18 //#include "RecoMET/METProducers/interface/METProducer.h"
24 #include <vector>
25 
26 
27 //
28 // constructors and destructor
29 //
31 {
32  inputJetTag_ = iConfig.getParameter< edm::InputTag > ("inputJetTag");
33  minPtJet_= iConfig.getParameter<double> ("minPtJet");
34  etaJet_= iConfig.getParameter<double> ("etaJet");
35  usePt_= iConfig.getParameter<bool>("usePt");
36 
37  //register your products
38  produces<reco::METCollection>();
39 }
40 
42 
45  desc.add<edm::InputTag>("inputJetTag",edm::InputTag("hltMCJetCorJetIcone5HF07"));
46  desc.add<double>("minPtJet",20.0);
47  desc.add<double>("etaJet",9999.0);
48  desc.add<bool>("usePt",true);
49  descriptions.add("hltMhtProducer",desc);
50 }
51 
52 // ------------ method called to produce the data ------------
53 void
55 {
56  using namespace std;
57  using namespace edm;
58  using namespace reco;
59 
60  auto_ptr<reco::METCollection> result (new reco::METCollection);
61 
62  math::XYZPoint vtx(0,0,0);
63 
64  //Handle<CaloJetCollection> recocalojets;
67 
68  // look at all candidates, check cuts and add to result object
69  double mhtx=0., mhty=0., mht;
70  double jetVar;
71 
72  if(jets->size() > 0){
73  // events with at least one jet
74  //for (CaloJetCollection::const_iterator jet = jets->begin(); jet != jets->end(); jet++) {
75  for(edm::View<reco::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); jet++ ) {
76  jetVar = jet->pt();
77  if (!usePt_) jetVar = jet->et();
78 
79  //---get MHT
80  if (jetVar > minPtJet_ && std::abs(jet->eta()) < etaJet_) {
81  mhtx -= jetVar*cos(jet->phi());
82  mhty -= jetVar*sin(jet->phi());
83  }
84  }
85  mht = sqrt(mhtx*mhtx + mhty*mhty);
86 
87  math::XYZTLorentzVector mhtVec(mhtx,mhty,0,mht);
88  reco::MET mhtobj(mhtVec,vtx);
89  result->push_back( mhtobj );
90 
91  } // events with at least one jet
92 
93 
94  // put object into the Event
95  iEvent.put(result);
96 
97 }
T getParameter(std::string const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
int iEvent
Definition: GenABIO.cc:243
edm::InputTag inputJetTag_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
Definition: MET.h:32
T sqrt(T t)
Definition: SSEVec.h:46
vector< PseudoJet > jets
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
HLTMhtProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
void add(std::string const &label, ParameterSetDescription const &psetDescription)