File indexing completed on 2023-03-17 10:58:36
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Common/interface/TriggerNames.h"
0005 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0006 #include "DQMOffline/Trigger/interface/HotlineDQM.h"
0007
0008 HotlineDQM::HotlineDQM(const edm::ParameterSet& ps) {
0009 edm::LogInfo("HotlineDQM") << "Constructor HotlineDQM::HotlineDQM " << std::endl;
0010
0011 theMuonCollection_ = consumes<reco::MuonCollection>(ps.getParameter<edm::InputTag>("muonCollection"));
0012 thePfMETCollection_ = consumes<reco::PFMETCollection>(ps.getParameter<edm::InputTag>("pfMetCollection"));
0013 theMETCollection_ = consumes<reco::CaloMETCollection>(ps.getParameter<edm::InputTag>("caloMetCollection"));
0014 theCaloJetCollection_ = consumes<reco::CaloJetCollection>(ps.getParameter<edm::InputTag>("caloJetCollection"));
0015 thePhotonCollection_ = consumes<reco::PhotonCollection>(ps.getParameter<edm::InputTag>("photonCollection"));
0016 theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
0017 triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"));
0018 triggerPath_ = ps.getParameter<std::string>("triggerPath");
0019 triggerFilter_ = ps.getParameter<edm::InputTag>("triggerFilter");
0020 useMuons = ps.getParameter<bool>("useMuons");
0021 useMet = ps.getParameter<bool>("useMet");
0022 usePFMet = ps.getParameter<bool>("usePFMet");
0023 useHT = ps.getParameter<bool>("useHT");
0024 usePhotons = ps.getParameter<bool>("usePhotons");
0025 }
0026
0027 HotlineDQM::~HotlineDQM() { edm::LogInfo("HotlineDQM") << "Destructor HotlineDQM::~HotlineDQM " << std::endl; }
0028
0029 void HotlineDQM::bookHistograms(DQMStore::IBooker& ibooker_, edm::Run const&, edm::EventSetup const&) {
0030 edm::LogInfo("HotlineDQM") << "HotlineDQM::bookHistograms" << std::endl;
0031
0032 ibooker_.cd();
0033 ibooker_.setCurrentFolder("HLT/Hotline/" + triggerPath_);
0034
0035
0036 h_MuPt = ibooker_.book1D("MuPt", "Muon Pt; GeV", 20, 0.0, 2000.0);
0037 h_PhotonPt = ibooker_.book1D("PhotonPt", "Photon Pt; GeV", 20, 0.0, 4000.0);
0038 h_HT = ibooker_.book1D("HT", "HT; GeV", 20, 0.0, 6000.0);
0039 h_MetPt = ibooker_.book1D("MetPt", "Calo MET; GeV", 20, 0.0, 2000);
0040 h_PFMetPt = ibooker_.book1D("PFMetPt", "PF MET; GeV", 20, 0.0, 2000);
0041
0042 if (useMuons)
0043 h_OnlineMuPt = ibooker_.book1D("OnlineMuPt", "Online Muon Pt; GeV", 20, 0.0, 2000.0);
0044 if (usePhotons)
0045 h_OnlinePhotonPt = ibooker_.book1D("OnlinePhotonPt", "Online Photon Pt; GeV", 20, 0.0, 4000.0);
0046 if (useHT)
0047 h_OnlineHT = ibooker_.book1D("OnlineHT", "Online HT; GeV", 20, 0.0, 6000.0);
0048 if (useMet)
0049 h_OnlineMetPt = ibooker_.book1D("OnlineMetPt", "Online Calo MET; GeV", 20, 0.0, 2000);
0050 if (usePFMet)
0051 h_OnlinePFMetPt = ibooker_.book1D("OnlinePFMetPt", "Online PF MET; GeV", 20, 0.0, 2000);
0052
0053 ibooker_.cd();
0054 }
0055
0056 void HotlineDQM::analyze(edm::Event const& e, edm::EventSetup const& eSetup) {
0057 edm::LogInfo("HotlineDQM") << "HotlineDQM::analyze" << std::endl;
0058
0059
0060
0061
0062 edm::Handle<reco::PFMETCollection> pfMETCollection;
0063 e.getByToken(thePfMETCollection_, pfMETCollection);
0064 if (!pfMETCollection.isValid()) {
0065 edm::LogError("HotlineDQM") << "invalid collection: PFMET"
0066 << "\n";
0067 return;
0068 }
0069 edm::Handle<reco::CaloMETCollection> caloMETCollection;
0070 e.getByToken(theMETCollection_, caloMETCollection);
0071 if (!caloMETCollection.isValid()) {
0072 edm::LogError("HotlineDQM") << "invalid collection: CaloMET"
0073 << "\n";
0074 return;
0075 }
0076
0077
0078
0079
0080 edm::Handle<reco::CaloJetCollection> caloJetCollection;
0081 e.getByToken(theCaloJetCollection_, caloJetCollection);
0082 if (!caloJetCollection.isValid()) {
0083 edm::LogError("HotlineDQM") << "invalid collection: CaloJets"
0084 << "\n";
0085 return;
0086 }
0087
0088
0089
0090
0091 edm::Handle<reco::MuonCollection> MuonCollection;
0092 e.getByToken(theMuonCollection_, MuonCollection);
0093 if (!MuonCollection.isValid()) {
0094 edm::LogError("HotlineDQM") << "invalid collection: Muons "
0095 << "\n";
0096 return;
0097 }
0098
0099
0100
0101
0102 edm::Handle<reco::PhotonCollection> PhotonCollection;
0103 e.getByToken(thePhotonCollection_, PhotonCollection);
0104 if (!PhotonCollection.isValid()) {
0105 edm::LogError("HotlineDQM") << "invalid collection: Photons "
0106 << "\n";
0107 return;
0108 }
0109
0110
0111
0112
0113 edm::Handle<edm::TriggerResults> hltresults;
0114 e.getByToken(triggerResults_, hltresults);
0115 if (!hltresults.isValid()) {
0116 edm::LogError("HotlineDQM") << "invalid collection: TriggerResults"
0117 << "\n";
0118 return;
0119 }
0120 edm::Handle<trigger::TriggerEvent> triggerSummary;
0121 e.getByToken(theTrigSummary_, triggerSummary);
0122 if (!triggerSummary.isValid()) {
0123 edm::LogError("HotlineDQM") << "invalid collection: TriggerSummary"
0124 << "\n";
0125 return;
0126 }
0127
0128 bool hasFired = false;
0129 const edm::TriggerNames& trigNames = e.triggerNames(*hltresults);
0130 unsigned int numTriggers = trigNames.size();
0131 for (unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
0132 if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) &&
0133 hltresults->accept(hltIndex)) {
0134 hasFired = true;
0135 }
0136 }
0137
0138
0139 float ptMuon = -1, ptPhoton = -1, met = -1, pfMet = -1, ht = 0;
0140 size_t filterIndex = triggerSummary->filterIndex(triggerFilter_);
0141 trigger::TriggerObjectCollection triggerObjects = triggerSummary->getObjects();
0142 if (!(filterIndex >= triggerSummary->sizeFilters())) {
0143 const trigger::Keys& keys = triggerSummary->filterKeys(filterIndex);
0144 for (unsigned short key : keys) {
0145 trigger::TriggerObject foundObject = triggerObjects[key];
0146 if (useMuons && fabs(foundObject.id()) == 13) {
0147 if (foundObject.pt() > ptMuon)
0148 ptMuon = foundObject.pt();
0149 } else if (usePhotons && fabs(foundObject.id()) == 0) {
0150 if (foundObject.pt() > ptPhoton)
0151 ptPhoton = foundObject.pt();
0152 } else if (useMet && fabs(foundObject.id()) == 0) {
0153 met = foundObject.pt();
0154 } else if (usePFMet && fabs(foundObject.id()) == 0) {
0155 pfMet = foundObject.pt();
0156 } else if (useHT && fabs(foundObject.id()) == 89) {
0157 ht = foundObject.pt();
0158 }
0159 }
0160 }
0161
0162 if (hasFired) {
0163
0164 if (useMuons)
0165 h_OnlineMuPt->Fill(ptMuon);
0166 if (usePhotons)
0167 h_OnlinePhotonPt->Fill(ptPhoton);
0168 if (useMet)
0169 h_OnlineMetPt->Fill(met);
0170 if (usePFMet)
0171 h_OnlinePFMetPt->Fill(pfMet);
0172 if (useHT)
0173 h_OnlineHT->Fill(ht);
0174
0175
0176 if (!MuonCollection->empty()) {
0177 float maxMuPt = -1.0;
0178 for (auto& mu : *MuonCollection) {
0179 if (mu.pt() > maxMuPt)
0180 maxMuPt = mu.pt();
0181 }
0182 h_MuPt->Fill(maxMuPt);
0183 }
0184
0185
0186 if (!PhotonCollection->empty()) {
0187 float maxPhoPt = -1.0;
0188 for (auto& pho : *PhotonCollection) {
0189 if (pho.pt() > maxPhoPt)
0190 maxPhoPt = pho.pt();
0191 }
0192 h_PhotonPt->Fill(maxPhoPt);
0193 }
0194
0195
0196 float caloHT = 0.0;
0197 for (auto const& i_calojet : *caloJetCollection) {
0198 if (i_calojet.pt() < 40)
0199 continue;
0200 if (fabs(i_calojet.eta()) > 3.0)
0201 continue;
0202 caloHT += i_calojet.pt();
0203 }
0204 h_HT->Fill(caloHT);
0205
0206
0207 h_MetPt->Fill(caloMETCollection->front().et());
0208
0209
0210 h_PFMetPt->Fill(pfMETCollection->front().et());
0211 }
0212 }
0213
0214 void HotlineDQM::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0215 edm::ParameterSetDescription desc;
0216 desc.add<edm::InputTag>("photonCollection", edm::InputTag("photons"));
0217 desc.add<edm::InputTag>("muonCollection", edm::InputTag("muons"));
0218 desc.add<edm::InputTag>("caloJetCollection", edm::InputTag("ak4CaloJets"));
0219 desc.add<edm::InputTag>("pfMetCollection", edm::InputTag("pfMet"));
0220 desc.add<edm::InputTag>("caloMetCollection", edm::InputTag("caloMet"));
0221 desc.add<edm::InputTag>("triggerResults", edm::InputTag("TriggerResults", "", "HLT"));
0222 desc.add<edm::InputTag>("trigSummary", edm::InputTag("hltTriggerSummaryAOD"));
0223 desc.add<std::string>("triggerPath", "HLT_HT2000_v")->setComment("trigger path name");
0224 desc.add<edm::InputTag>("triggerFilter", edm::InputTag("hltHt2000", "", "HLT"))
0225 ->setComment("name of the last filter in the path");
0226 desc.add<bool>("useMuons", false);
0227 desc.add<bool>("usePhotons", false);
0228 desc.add<bool>("useMet", false);
0229 desc.add<bool>("usePFMet", false);
0230 desc.add<bool>("useHT", false);
0231 descriptions.add("HotlineDQM", desc);
0232 }
0233
0234
0235 DEFINE_FWK_MODULE(HotlineDQM);