Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DQMOffline/JetMET/interface/HTMHTAnalyzer.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "FWCore/Common/interface/TriggerNames.h"
00012
00013 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00014 #include "DataFormats/JetReco/interface/CaloJet.h"
00015
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017
00018 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00019 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00020 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00021 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00022
00023 #include "DataFormats/Math/interface/LorentzVector.h"
00024
00025 #include "TVector2.h"
00026
00027 #include <string>
00028 using namespace edm;
00029
00030
00031 HTMHTAnalyzer::HTMHTAnalyzer(const edm::ParameterSet& pSet) {
00032
00033 parameters = pSet;
00034 _ptThreshold = 30.;
00035
00036 }
00037
00038
00039 HTMHTAnalyzer::~HTMHTAnalyzer() { }
00040
00041 void HTMHTAnalyzer::beginJob(DQMStore * dbe) {
00042
00043 evtCounter = 0;
00044 metname = "HTMHTAnalyzer";
00045
00046
00047 theJetCollectionForHTMHTLabel = parameters.getParameter<edm::InputTag>("JetCollectionForHTMHTLabel");
00048 _source = parameters.getParameter<std::string>("Source");
00049
00050 LogTrace(metname)<<"[HTMHTAnalyzer] Parameters initialization";
00051 dbe->setCurrentFolder("JetMET/MET/"+_source);
00052
00053 HLTPathsJetMBByName_ = parameters.getParameter<std::vector<std::string > >("HLTPathsJetMB");
00054
00055
00056 _verbose = parameters.getParameter<int>("verbose");
00057 _ptThreshold = parameters.getParameter<double>("ptThreshold");
00058
00059 jetME = dbe->book1D("metReco", "metReco", 4, 1, 5);
00060 jetME->setBinLabel(4,"HTMHT",1);
00061
00062 hNevents = dbe->book1D("METTask_Nevents", "METTask_Nevents", 1,0,1);
00063 hNJets = dbe->book1D("METTask_NJets", "METTask_NJets", 100, 0, 100);
00064 hMHx = dbe->book1D("METTask_MHx", "METTask_MHx", 500,-500,500);
00065 hMHy = dbe->book1D("METTask_MHy", "METTask_MHy", 500,-500,500);
00066 hMHT = dbe->book1D("METTask_MHT", "METTask_MHT", 500,0,1000);
00067 hMHTPhi = dbe->book1D("METTask_MhTPhi", "METTask_MhTPhi", 80,-4,4);
00068 hHT = dbe->book1D("METTask_HT", "METTask_HT", 500,0,2000);
00069
00070 }
00071
00072
00073
00074 void HTMHTAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup,
00075 const edm::TriggerResults& triggerResults) {
00076
00077 LogTrace(metname)<<"[HTMHTAnalyzer] Analyze HT & MHT";
00078
00079 jetME->Fill(4);
00080
00081
00082
00083
00084 if(&triggerResults) {
00085
00087
00088
00089
00090
00091 int ntrigs = triggerResults.size();
00092 if (_verbose) std::cout << "ntrigs=" << ntrigs << std::endl;
00093
00094
00095
00096
00097 const edm::TriggerNames & triggerNames = iEvent.triggerNames(triggerResults);
00098
00099
00100
00101
00102 for (unsigned int i=0; i!=HLTPathsJetMBByName_.size(); i++) {
00103 unsigned int triggerIndex = triggerNames.triggerIndex(HLTPathsJetMBByName_[i]);
00104 if (triggerIndex<triggerResults.size()) {
00105 if (triggerResults.accept(triggerIndex)) {
00106 _trig_JetMB++;
00107 }
00108 }
00109 }
00110
00111 if (HLTPathsJetMBByName_.size()==0) _trig_JetMB=triggerResults.size()-1;
00112
00113 if (_trig_JetMB==0) return;
00114
00115 } else {
00116
00117 edm::LogInfo("CaloMetAnalyzer") << "TriggerResults::HLT not found, "
00118 "automatically select events";
00119
00120
00121 }
00122
00123
00124
00125
00126 edm::Handle<reco::CaloJetCollection> jetcoll;
00127
00128
00129 iEvent.getByLabel(theJetCollectionForHTMHTLabel, jetcoll);
00130
00131 if(!jetcoll.isValid()) return;
00132
00133
00134
00135
00136 int njet=0;
00137 double MHx=0.;
00138 double MHy=0.;
00139 double MHT=0.;
00140 double MHTPhi=0.;
00141 double HT=0.;
00142
00143 for (reco::CaloJetCollection::const_iterator calojet = jetcoll->begin(); calojet!=jetcoll->end(); ++calojet){
00144 if (calojet->pt()>_ptThreshold){
00145 njet++;
00146 MHx += -1.*calojet->px();
00147 MHy += -1.*calojet->py();
00148 HT += calojet->pt();
00149 }
00150 }
00151
00152 TVector2 *tv2 = new TVector2(MHx,MHy);
00153 MHT =tv2->Mod();
00154 MHTPhi=tv2->Phi();
00155
00156
00157
00158 hNevents->Fill(1.);
00159 hNJets->Fill(njet);
00160 if (njet>0){
00161 hMHx->Fill(MHx);
00162 hMHy->Fill(MHy);
00163 hMHT->Fill(MHT);
00164 hMHTPhi->Fill(MHTPhi);
00165 hHT->Fill(HT);
00166 }
00167
00168 }