CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/HLTrigger/JetMET/src/HLTMhtProducer.cc

Go to the documentation of this file.
00001 
00008 #include "HLTrigger/JetMET/interface/HLTMhtProducer.h"
00009 #include "DataFormats/Common/interface/Handle.h"
00010 #include "DataFormats/Common/interface/View.h"
00011 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "DataFormats/Math/interface/deltaPhi.h"
00016 #include "DataFormats/Math/interface/LorentzVector.h"
00017 #include "DataFormats/Math/interface/Point3D.h"
00018 #include "RecoMET/METProducers/interface/METProducer.h"
00019 #include "DataFormats/METReco/interface/METFwd.h"
00020 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00022 #include "FWCore/Utilities/interface/InputTag.h"
00023 #include <vector>
00024 
00025 
00026 //
00027 // constructors and destructor
00028 //
00029 HLTMhtProducer::HLTMhtProducer(const edm::ParameterSet& iConfig)
00030 {
00031   inputJetTag_ = iConfig.getParameter< edm::InputTag > ("inputJetTag");
00032   minPtJet_= iConfig.getParameter<double> ("minPtJet");
00033   etaJet_= iConfig.getParameter<double> ("etaJet");
00034   usePt_= iConfig.getParameter<bool>("usePt");
00035 
00036   //register your products
00037   produces<reco::METCollection>();
00038 }
00039 
00040 HLTMhtProducer::~HLTMhtProducer(){}
00041 
00042 void HLTMhtProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00043   edm::ParameterSetDescription desc;
00044   desc.add<edm::InputTag>("inputJetTag",edm::InputTag("hltMCJetCorJetIcone5HF07"));
00045   desc.add<double>("minPtJet",20.0);
00046   desc.add<double>("etaJet",9999.0);
00047   desc.add<bool>("usePt",true);
00048   descriptions.add("hltMhtProducer",desc);
00049 }
00050 
00051 // ------------ method called to produce the data  ------------
00052 void
00053   HLTMhtProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00054 {
00055   using namespace std;
00056   using namespace edm;
00057   using namespace reco;
00058 
00059   auto_ptr<reco::METCollection> result (new reco::METCollection); 
00060 
00061   math::XYZPoint vtx(0,0,0);
00062   
00063   //Handle<CaloJetCollection> recocalojets;
00064   edm::Handle<edm::View<reco::Jet> > jets;
00065   iEvent.getByLabel(inputJetTag_,jets);
00066 
00067   // look at all candidates,  check cuts and add to result object
00068   double mhtx=0., mhty=0., mht;
00069   double jetVar;
00070   
00071   if(jets->size() > 0){
00072     // events with at least one jet
00073     //for (CaloJetCollection::const_iterator jet = jets->begin(); jet != jets->end(); jet++) {
00074     for(edm::View<reco::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); jet++ ) {
00075       jetVar = jet->pt();
00076       if (!usePt_) jetVar = jet->et();
00077 
00078       //---get MHT
00079       if (jetVar > minPtJet_ && std::abs(jet->eta()) < etaJet_) {
00080         mhtx -= jetVar*cos(jet->phi());
00081         mhty -= jetVar*sin(jet->phi());
00082       }
00083     }
00084     mht = sqrt(mhtx*mhtx + mhty*mhty);
00085 
00086     math::XYZTLorentzVector mhtVec(mhtx,mhty,0,mht);
00087     reco::MET mhtobj(mhtVec,vtx);
00088     result->push_back( mhtobj );
00089     
00090   } // events with at least one jet
00091   
00092     
00093   // put object into the Event
00094   iEvent.put(result);
00095 
00096 }