CMS 3D CMS Logo

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