File indexing completed on 2024-09-07 04:36:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021 #include <sys/time.h>
0022 #include <cstdlib>
0023
0024
0025 #include "DataFormats/Common/interface/TriggerResults.h"
0026 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0027 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0028 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0029 #include "DataFormats/Scalers/interface/LumiScalers.h"
0030
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "FWCore/Framework/interface/Event.h"
0033 #include "FWCore/Framework/interface/MakerMacros.h"
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036
0037 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0038
0039
0040 #include "HLTrigger/JetMET/interface/AlphaT.h"
0041 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0042 #include "DataFormats/METReco/interface/MET.h"
0043 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
0044 #include "DataFormats/BTauReco/interface/JetTag.h"
0045 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
0046 #include "DataFormats/Math/interface/deltaR.h"
0047 #include "DataFormats/JetReco/interface/PFJet.h"
0048 #include "DataFormats/JetReco/interface/CaloJet.h"
0049
0050 #include "DQMServices/Core/interface/DQMStore.h"
0051 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0052
0053 #include "TMath.h"
0054 #include "TStyle.h"
0055 #include "TLorentzVector.h"
0056
0057 #include <unordered_map>
0058
0059
0060
0061
0062
0063 using namespace trigger;
0064 using std::string;
0065 using std::unordered_map;
0066 using std::vector;
0067
0068 class HLTObjectMonitor : public DQMEDAnalyzer {
0069 struct hltPlot {
0070 MonitorElement* ME;
0071 string pathName;
0072 string pathNameOR;
0073 string moduleName;
0074 string moduleNameOR;
0075 int pathIndex = -99;
0076 int pathIndexOR = -99;
0077 string plotLabel;
0078 string xAxisLabel;
0079 int nBins;
0080 double xMin;
0081 double xMax;
0082 bool displayInPrimary;
0083 };
0084
0085 public:
0086 explicit HLTObjectMonitor(const edm::ParameterSet&);
0087
0088 private:
0089 void analyze(const edm::Event&, const edm::EventSetup&) override;
0090 void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
0091 void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0092 vector<hltPlot*> plotList;
0093 double dxyFinder(double, double, edm::Handle<reco::RecoChargedCandidateCollection>, edm::Handle<reco::BeamSpot>);
0094 double get_wall_time(void);
0095
0096
0097 bool debugPrint;
0098 HLTConfigProvider hltConfig_;
0099 string topDirectoryName;
0100 string mainShifterFolder;
0101 string backupFolder;
0102 unordered_map<string, bool> acceptMap;
0103 unordered_map<hltPlot*, edm::ParameterSet*> plotMap;
0104
0105
0106 edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_;
0107 edm::EDGetTokenT<trigger::TriggerEvent> aodTriggerToken_;
0108 edm::EDGetTokenT<LumiScalersCollection> lumiScalersToken_;
0109 edm::EDGetTokenT<reco::BeamSpot> beamSpotToken_;
0110 edm::EDGetTokenT<reco::RecoChargedCandidateCollection> chargedCandToken_;
0111 edm::EDGetTokenT<reco::JetTagCollection> csvCaloTagsToken_;
0112 edm::EDGetTokenT<reco::JetTagCollection> csvPfTagsToken_;
0113 edm::EDGetTokenT<vector<reco::CaloJet>> csvCaloJetsToken_;
0114 edm::EDGetTokenT<vector<reco::PFJet>> csvPfJetsToken_;
0115
0116
0117 edm::ParameterSet rsq_pset;
0118 edm::ParameterSet mr_pset;
0119 edm::ParameterSet alphaT_pset;
0120 edm::ParameterSet photonPt_pset;
0121 edm::ParameterSet photonEta_pset;
0122 edm::ParameterSet photonPhi_pset;
0123 edm::ParameterSet muonPt_pset;
0124 edm::ParameterSet muonEta_pset;
0125 edm::ParameterSet muonPhi_pset;
0126 edm::ParameterSet l2muonPt_pset;
0127 edm::ParameterSet l2muonEta_pset;
0128 edm::ParameterSet l2muonPhi_pset;
0129 edm::ParameterSet l2NoBPTXmuonPt_pset;
0130 edm::ParameterSet l2NoBPTXmuonEta_pset;
0131 edm::ParameterSet l2NoBPTXmuonPhi_pset;
0132 edm::ParameterSet electronPt_pset;
0133 edm::ParameterSet electronEta_pset;
0134 edm::ParameterSet electronPhi_pset;
0135 edm::ParameterSet jetPt_pset;
0136 edm::ParameterSet jetAK8Pt_pset;
0137 edm::ParameterSet jetAK8Mass_pset;
0138 edm::ParameterSet tauPt_pset;
0139 edm::ParameterSet diMuonLowMass_pset;
0140 edm::ParameterSet caloMetPt_pset;
0141 edm::ParameterSet caloMetPhi_pset;
0142 edm::ParameterSet pfMetPt_pset;
0143 edm::ParameterSet pfMetPhi_pset;
0144 edm::ParameterSet caloHtPt_pset;
0145 edm::ParameterSet pfHtPt_pset;
0146 edm::ParameterSet bJetPhi_pset;
0147 edm::ParameterSet bJetEta_pset;
0148 edm::ParameterSet bJetCSVCalo_pset;
0149 edm::ParameterSet bJetCSVPF_pset;
0150 edm::ParameterSet diMuonMass_pset;
0151 edm::ParameterSet pAL1DoubleMuZMass_pset;
0152 edm::ParameterSet pAL2DoubleMuZMass_pset;
0153 edm::ParameterSet pAL3DoubleMuZMass_pset;
0154 edm::ParameterSet diElecMass_pset;
0155 edm::ParameterSet muonDxy_pset;
0156 edm::ParameterSet wallTime_pset;
0157
0158 string processName_;
0159
0160 hltPlot rsq_;
0161 hltPlot mr_;
0162 hltPlot alphaT_;
0163 hltPlot photonPt_;
0164 hltPlot photonEta_;
0165 hltPlot photonPhi_;
0166 hltPlot muonPt_;
0167 hltPlot muonEta_;
0168 hltPlot muonPhi_;
0169 hltPlot l2muonPt_;
0170 hltPlot l2muonEta_;
0171 hltPlot l2muonPhi_;
0172 hltPlot l2NoBPTXmuonPt_;
0173 hltPlot l2NoBPTXmuonEta_;
0174 hltPlot l2NoBPTXmuonPhi_;
0175 hltPlot electronPt_;
0176 hltPlot electronEta_;
0177 hltPlot electronPhi_;
0178 hltPlot jetPt_;
0179 hltPlot jetAK8Pt_;
0180 hltPlot jetAK8Mass_;
0181 hltPlot tauPt_;
0182 hltPlot diMuonLowMass_;
0183 hltPlot caloMetPt_;
0184 hltPlot caloMetPhi_;
0185 hltPlot pfMetPt_;
0186 hltPlot pfMetPhi_;
0187 hltPlot caloHtPt_;
0188 hltPlot pfHtPt_;
0189 hltPlot bJetPhi_;
0190 hltPlot bJetEta_;
0191 hltPlot bJetCSVCalo_;
0192 hltPlot bJetCSVPF_;
0193 hltPlot diMuonMass_;
0194 hltPlot pAL1DoubleMuZMass_;
0195 hltPlot pAL2DoubleMuZMass_;
0196 hltPlot pAL3DoubleMuZMass_;
0197 hltPlot diElecMass_;
0198 hltPlot muonDxy_;
0199 hltPlot wallTime_;
0200 };
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213 HLTObjectMonitor::HLTObjectMonitor(const edm::ParameterSet& iConfig)
0214
0215 {
0216
0217 debugPrint = false;
0218
0219 topDirectoryName = "HLT/ObjectMonitor";
0220 mainShifterFolder = topDirectoryName + "/MainShifter";
0221 backupFolder = topDirectoryName + "/Backup";
0222
0223
0224 processName_ = iConfig.getParameter<string>("processName");
0225
0226 rsq_pset = iConfig.getParameter<edm::ParameterSet>("rsq");
0227 plotMap[&rsq_] = &rsq_pset;
0228 mr_pset = iConfig.getParameter<edm::ParameterSet>("mr");
0229 plotMap[&mr_] = &mr_pset;
0230 alphaT_pset = iConfig.getParameter<edm::ParameterSet>("alphaT");
0231 plotMap[&alphaT_] = &alphaT_pset;
0232 photonPt_pset = iConfig.getParameter<edm::ParameterSet>("photonPt");
0233 plotMap[&photonPt_] = &photonPt_pset;
0234 photonEta_pset = iConfig.getParameter<edm::ParameterSet>("photonEta");
0235 plotMap[&photonEta_] = &photonEta_pset;
0236 photonPhi_pset = iConfig.getParameter<edm::ParameterSet>("photonPhi");
0237 plotMap[&photonPhi_] = &photonPhi_pset;
0238 muonPt_pset = iConfig.getParameter<edm::ParameterSet>("muonPt");
0239 plotMap[&muonPt_] = &muonPt_pset;
0240 muonEta_pset = iConfig.getParameter<edm::ParameterSet>("muonEta");
0241 plotMap[&muonEta_] = &muonEta_pset;
0242 muonPhi_pset = iConfig.getParameter<edm::ParameterSet>("muonPhi");
0243 plotMap[&muonPhi_] = &muonPhi_pset;
0244 l2muonPt_pset = iConfig.getParameter<edm::ParameterSet>("l2muonPt");
0245 plotMap[&l2muonPt_] = &l2muonPt_pset;
0246 l2muonEta_pset = iConfig.getParameter<edm::ParameterSet>("l2muonEta");
0247 plotMap[&l2muonEta_] = &l2muonEta_pset;
0248 l2muonPhi_pset = iConfig.getParameter<edm::ParameterSet>("l2muonPhi");
0249 plotMap[&l2muonPhi_] = &l2muonPhi_pset;
0250 l2NoBPTXmuonPt_pset = iConfig.getParameter<edm::ParameterSet>("l2NoBPTXmuonPt");
0251 plotMap[&l2NoBPTXmuonPt_] = &l2NoBPTXmuonPt_pset;
0252 l2NoBPTXmuonEta_pset = iConfig.getParameter<edm::ParameterSet>("l2NoBPTXmuonEta");
0253 plotMap[&l2NoBPTXmuonEta_] = &l2NoBPTXmuonEta_pset;
0254 l2NoBPTXmuonPhi_pset = iConfig.getParameter<edm::ParameterSet>("l2NoBPTXmuonPhi");
0255 plotMap[&l2NoBPTXmuonPhi_] = &l2NoBPTXmuonPhi_pset;
0256 electronPt_pset = iConfig.getParameter<edm::ParameterSet>("electronPt");
0257 plotMap[&electronPt_] = &electronPt_pset;
0258 electronEta_pset = iConfig.getParameter<edm::ParameterSet>("electronEta");
0259 plotMap[&electronEta_] = &electronEta_pset;
0260 electronPhi_pset = iConfig.getParameter<edm::ParameterSet>("electronPhi");
0261 plotMap[&electronPhi_] = &electronPhi_pset;
0262 jetPt_pset = iConfig.getParameter<edm::ParameterSet>("jetPt");
0263 plotMap[&jetPt_] = &jetPt_pset;
0264 jetAK8Mass_pset = iConfig.getParameter<edm::ParameterSet>("jetAK8Mass");
0265 plotMap[&jetAK8Mass_] = &jetAK8Mass_pset;
0266 diMuonLowMass_pset = iConfig.getParameter<edm::ParameterSet>("diMuonLowMass");
0267 plotMap[&diMuonLowMass_] = &diMuonLowMass_pset;
0268 caloMetPt_pset = iConfig.getParameter<edm::ParameterSet>("caloMetPt");
0269 plotMap[&caloMetPt_] = &caloMetPt_pset;
0270 caloMetPhi_pset = iConfig.getParameter<edm::ParameterSet>("caloMetPhi");
0271 plotMap[&caloMetPhi_] = &caloMetPhi_pset;
0272 pfMetPt_pset = iConfig.getParameter<edm::ParameterSet>("pfMetPt");
0273 plotMap[&pfMetPt_] = &pfMetPt_pset;
0274 pfMetPhi_pset = iConfig.getParameter<edm::ParameterSet>("pfMetPhi");
0275 plotMap[&pfMetPhi_] = &pfMetPhi_pset;
0276 caloHtPt_pset = iConfig.getParameter<edm::ParameterSet>("caloHtPt");
0277 plotMap[&caloHtPt_] = &caloHtPt_pset;
0278 pfHtPt_pset = iConfig.getParameter<edm::ParameterSet>("pfHtPt");
0279 plotMap[&pfHtPt_] = &pfHtPt_pset;
0280 bJetPhi_pset = iConfig.getParameter<edm::ParameterSet>("bJetPhi");
0281 plotMap[&bJetPhi_] = &bJetPhi_pset;
0282 bJetEta_pset = iConfig.getParameter<edm::ParameterSet>("bJetEta");
0283 plotMap[&bJetEta_] = &bJetEta_pset;
0284 bJetCSVCalo_pset = iConfig.getParameter<edm::ParameterSet>("bJetCSVCalo");
0285 plotMap[&bJetCSVCalo_] = &bJetCSVCalo_pset;
0286 bJetCSVPF_pset = iConfig.getParameter<edm::ParameterSet>("bJetCSVPF");
0287 plotMap[&bJetCSVPF_] = &bJetCSVPF_pset;
0288 diMuonMass_pset = iConfig.getParameter<edm::ParameterSet>("diMuonMass");
0289 plotMap[&diMuonMass_] = &diMuonMass_pset;
0290 pAL1DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL1DoubleMuZMass");
0291 plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
0292 pAL2DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL2DoubleMuZMass");
0293 plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
0294 pAL3DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL3DoubleMuZMass");
0295 plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
0296 diElecMass_pset = iConfig.getParameter<edm::ParameterSet>("diElecMass");
0297 plotMap[&diElecMass_] = &diElecMass_pset;
0298 muonDxy_pset = iConfig.getParameter<edm::ParameterSet>("muonDxy");
0299 plotMap[&muonDxy_] = &muonDxy_pset;
0300 jetAK8Pt_pset = iConfig.getParameter<edm::ParameterSet>("jetAK8Pt");
0301 plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
0302 tauPt_pset = iConfig.getParameter<edm::ParameterSet>("tauPt");
0303 plotMap[&tauPt_] = &tauPt_pset;
0304 wallTime_pset = iConfig.getParameter<edm::ParameterSet>("wallTime");
0305 plotMap[&wallTime_] = &wallTime_pset;
0306
0307 for (auto item = plotMap.begin(); item != plotMap.end(); item++) {
0308 (*item->first).pathName = (*item->second).getParameter<string>("pathName");
0309 (*item->first).moduleName = (*item->second).getParameter<string>("moduleName");
0310 (*item->first).nBins = (*item->second).getParameter<int>("NbinsX");
0311 (*item->first).xMin = (*item->second).getParameter<double>("Xmin");
0312 (*item->first).xMax = (*item->second).getParameter<double>("Xmax");
0313 (*item->first).xAxisLabel = (*item->second).getParameter<string>("axisLabel");
0314 (*item->first).plotLabel = (*item->second).getParameter<string>("plotLabel");
0315 (*item->first).displayInPrimary = (*item->second).getParameter<bool>("mainWorkspace");
0316
0317 if ((*item->second).exists("pathName_OR")) {
0318 (*item->first).pathNameOR = (*item->second).getParameter<string>("pathName_OR");
0319 }
0320 if ((*item->second).exists("moduleName_OR")) {
0321 (*item->first).moduleNameOR = (*item->second).getParameter<string>("moduleName_OR");
0322 }
0323
0324 plotList.push_back(item->first);
0325 }
0326 plotMap.clear();
0327
0328
0329 triggerResultsToken_ = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults", "", processName_));
0330 aodTriggerToken_ = consumes<trigger::TriggerEvent>(edm::InputTag("hltTriggerSummaryAOD", "", processName_));
0331 lumiScalersToken_ = consumes<LumiScalersCollection>(edm::InputTag("hltScalersRawToDigi", "", ""));
0332 beamSpotToken_ = consumes<reco::BeamSpot>(edm::InputTag("hltOnlineBeamSpot", "", processName_));
0333 chargedCandToken_ = consumes<vector<reco::RecoChargedCandidate>>(
0334 edm::InputTag("hltL3NoFiltersNoVtxMuonCandidates", "", processName_));
0335 csvCaloTagsToken_ =
0336 consumes<reco::JetTagCollection>(edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo", "", processName_));
0337 csvPfTagsToken_ =
0338 consumes<reco::JetTagCollection>(edm::InputTag("hltCombinedSecondaryVertexBJetTagsPF", "", processName_));
0339 csvCaloJetsToken_ =
0340 consumes<vector<reco::CaloJet>>(edm::InputTag("hltSelector8CentralJetsL1FastJet", "", processName_));
0341 csvPfJetsToken_ = consumes<vector<reco::PFJet>>(edm::InputTag("hltPFJetForBtag", "", processName_));
0342 }
0343
0344
0345
0346
0347
0348
0349 void HLTObjectMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0350 double start = get_wall_time();
0351
0352 using namespace edm;
0353
0354 if (debugPrint)
0355 std::cout << "Inside analyze(). " << std::endl;
0356
0357
0358 edm::Handle<edm::TriggerResults> triggerResults;
0359 iEvent.getByToken(triggerResultsToken_, triggerResults);
0360 if (!triggerResults.isValid())
0361 return;
0362
0363 edm::Handle<trigger::TriggerEvent> aodTriggerEvent;
0364 iEvent.getByToken(aodTriggerToken_, aodTriggerEvent);
0365 if (!aodTriggerEvent.isValid())
0366 return;
0367
0368
0369 unordered_map<string, bool> firedMap = acceptMap;
0370 for (auto plot : plotList)
0371 {
0372 if (firedMap[plot->pathName])
0373 continue;
0374 bool triggerAccept = false;
0375 const TriggerObjectCollection objects = aodTriggerEvent->getObjects();
0376 edm::InputTag moduleFilter;
0377 std::string pathName;
0378 if (plot->pathIndex > 0 && triggerResults->accept(plot->pathIndex) && hltConfig_.saveTags(plot->moduleName)) {
0379 moduleFilter = edm::InputTag(plot->moduleName, "", processName_);
0380 pathName = plot->pathName;
0381 triggerAccept = true;
0382 } else if (plot->pathIndexOR > 0 && triggerResults->accept(plot->pathIndexOR) &&
0383 hltConfig_.saveTags(plot->moduleNameOR)) {
0384 if (firedMap[plot->pathNameOR])
0385 continue;
0386 moduleFilter = edm::InputTag(plot->moduleNameOR, "", processName_);
0387 pathName = plot->pathNameOR;
0388 triggerAccept = true;
0389 }
0390
0391 if (triggerAccept) {
0392 unsigned int moduleFilterIndex = aodTriggerEvent->filterIndex(moduleFilter);
0393
0394 if (moduleFilterIndex + 1 > aodTriggerEvent->sizeFilters())
0395 return;
0396 const Keys& keys = aodTriggerEvent->filterKeys(moduleFilterIndex);
0397
0398
0399
0400
0401
0402
0403
0404
0405 if (pathName == pfHtPt_.pathName) {
0406 for (const auto& key : keys)
0407 pfHtPt_.ME->Fill(objects[key].pt());
0408 }
0409
0410
0411 else if (pathName == jetPt_.pathName) {
0412 for (const auto& key : keys)
0413 jetPt_.ME->Fill(objects[key].pt());
0414 }
0415
0416
0417 else if (pathName == photonPt_.pathName) {
0418 for (const auto& key : keys) {
0419 photonPt_.ME->Fill(objects[key].pt());
0420 photonEta_.ME->Fill(objects[key].eta());
0421 photonPhi_.ME->Fill(objects[key].phi());
0422 }
0423 }
0424
0425
0426 else if (pathName == electronPt_.pathName) {
0427 for (const auto& key : keys) {
0428 electronPt_.ME->Fill(objects[key].pt());
0429 electronEta_.ME->Fill(objects[key].eta());
0430 electronPhi_.ME->Fill(objects[key].phi());
0431 }
0432 }
0433
0434
0435 else if (pathName == muonPt_.pathName) {
0436 for (const auto& key : keys) {
0437 muonPt_.ME->Fill(objects[key].pt());
0438 muonEta_.ME->Fill(objects[key].eta());
0439 muonPhi_.ME->Fill(objects[key].phi());
0440 }
0441 }
0442
0443
0444 else if (pathName == l2muonPt_.pathName) {
0445 for (const auto& key : keys) {
0446 l2muonPt_.ME->Fill(objects[key].pt());
0447 l2muonEta_.ME->Fill(objects[key].eta());
0448 l2muonPhi_.ME->Fill(objects[key].phi());
0449 }
0450 }
0451
0452
0453 else if (pathName == l2NoBPTXmuonPt_.pathName) {
0454 for (const auto& key : keys) {
0455 l2NoBPTXmuonPt_.ME->Fill(objects[key].pt());
0456 l2NoBPTXmuonEta_.ME->Fill(objects[key].eta());
0457 l2NoBPTXmuonPhi_.ME->Fill(objects[key].phi());
0458 }
0459 }
0460
0461
0462 else if (pathName == mr_.pathName) {
0463 double onlineMR = 0, onlineRsq = 0;
0464 for (const auto& key : keys) {
0465 if (objects[key].id() == 0) {
0466 onlineMR = objects[key].px();
0467 onlineRsq = objects[key].py();
0468 }
0469 mr_.ME->Fill(onlineMR);
0470 rsq_.ME->Fill(onlineRsq);
0471 }
0472 }
0473
0474
0475 else if (pathName == alphaT_.pathName) {
0476 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>> alphaT_jets;
0477 for (const auto& key : keys) {
0478 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(
0479 objects[key].pt(), objects[key].eta(), objects[key].phi(), objects[key].mass());
0480 alphaT_jets.push_back(JetLVec);
0481 }
0482
0483 float alphaT = AlphaT(alphaT_jets, false).value();
0484 alphaT_.ME->Fill(alphaT);
0485 }
0486
0487
0488 else if (pathName == tauPt_.pathName) {
0489 for (const auto& key : keys)
0490 tauPt_.ME->Fill(objects[key].pt());
0491 }
0492
0493
0494 else if (pathName == caloMetPt_.pathName) {
0495 for (const auto& key : keys) {
0496 caloMetPt_.ME->Fill(objects[key].pt());
0497 caloMetPhi_.ME->Fill(objects[key].phi());
0498 }
0499 }
0500
0501
0502 else if (pathName == caloHtPt_.pathName) {
0503 for (const auto& key : keys) {
0504 if (objects[key].id() == 89)
0505 caloHtPt_.ME->Fill(objects[key].pt());
0506 }
0507 }
0508
0509
0510 else if (pathName == jetAK8Pt_.pathName) {
0511 for (const auto& key : keys) {
0512 jetAK8Pt_.ME->Fill(objects[key].pt());
0513 jetAK8Mass_.ME->Fill(objects[key].mass());
0514 }
0515 }
0516
0517
0518 else if (pathName == pfMetPt_.pathName) {
0519 for (const auto& key : keys) {
0520 pfMetPt_.ME->Fill(objects[key].pt());
0521 pfMetPhi_.ME->Fill(objects[key].phi());
0522 }
0523 }
0524
0525
0526 else if (pathName == bJetEta_.pathName || pathName == bJetEta_.pathNameOR) {
0527 for (const auto& key : keys) {
0528 bJetEta_.ME->Fill(objects[key].eta());
0529 bJetPhi_.ME->Fill(objects[key].phi());
0530 }
0531 }
0532
0533
0534 if (pathName == bJetCSVPF_.pathName) {
0535 edm::Handle<reco::JetTagCollection> csvPfTags;
0536 iEvent.getByToken(csvPfTagsToken_, csvPfTags);
0537 edm::Handle<vector<reco::PFJet>> csvPfJets;
0538 iEvent.getByToken(csvPfJetsToken_, csvPfJets);
0539
0540 if (csvPfTags.isValid() && csvPfJets.isValid()) {
0541 for (auto iter = csvPfTags->begin(); iter != csvPfTags->end(); iter++)
0542 bJetCSVPF_.ME->Fill(iter->second);
0543 }
0544 }
0545 if (pathName == bJetCSVCalo_.pathName) {
0546 edm::Handle<reco::JetTagCollection> csvCaloTags;
0547 iEvent.getByToken(csvCaloTagsToken_, csvCaloTags);
0548 edm::Handle<vector<reco::CaloJet>> csvCaloJets;
0549 iEvent.getByToken(csvCaloJetsToken_, csvCaloJets);
0550
0551 if (csvCaloTags.isValid() && csvCaloJets.isValid()) {
0552 for (auto iter = csvCaloTags->begin(); iter != csvCaloTags->end(); iter++)
0553 bJetCSVCalo_.ME->Fill(iter->second);
0554 }
0555 }
0556
0557
0558 else if (pathName == muonDxy_.pathName) {
0559 edm::Handle<vector<reco::RecoChargedCandidate>> recoChargedCands;
0560 iEvent.getByToken(chargedCandToken_, recoChargedCands);
0561 edm::Handle<reco::BeamSpot> recoBeamSpot;
0562 iEvent.getByToken(beamSpotToken_, recoBeamSpot);
0563 double muon_dxy;
0564
0565 if (recoChargedCands.isValid() && recoBeamSpot.isValid()) {
0566 for (const auto& key : keys) {
0567 muon_dxy = dxyFinder(objects[key].eta(), objects[key].phi(), recoChargedCands, recoBeamSpot);
0568 if (muon_dxy != -99.)
0569 muonDxy_.ME->Fill(muon_dxy);
0570 }
0571 }
0572 }
0573
0574
0575
0576
0577
0578
0579
0580
0581 else if (pathName == diMuonLowMass_.pathName) {
0582 const double mu_mass(.105658);
0583 unsigned int kCnt0 = 0;
0584 for (const auto& key0 : keys) {
0585 unsigned int kCnt1 = 0;
0586 for (const auto& key1 : keys) {
0587 if (key0 != key1 &&
0588 kCnt1 > kCnt0)
0589 {
0590 if (abs(objects[key0].id()) == 13 &&
0591 (objects[key0].id() + objects[key1].id() == 0))
0592 {
0593 TLorentzVector mu1, mu2, dimu;
0594 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0595 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0596 dimu = mu1 + mu2;
0597 diMuonLowMass_.ME->Fill(dimu.M());
0598 }
0599 }
0600 kCnt1 += 1;
0601 }
0602 kCnt0 += 1;
0603 }
0604 }
0605
0606 else if (pathName == diMuonMass_.pathName || pathName == diMuonMass_.pathNameOR) {
0607 const double mu_mass(.105658);
0608 unsigned int kCnt0 = 0;
0609 for (const auto& key0 : keys) {
0610 unsigned int kCnt1 = 0;
0611 for (const auto& key1 : keys) {
0612 if (key0 != key1 &&
0613 kCnt1 > kCnt0)
0614 {
0615 if (abs(objects[key0].id()) == 13 &&
0616 (objects[key0].id() + objects[key1].id() == 0))
0617 {
0618 TLorentzVector mu1, mu2, dimu;
0619 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0620 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0621 dimu = mu1 + mu2;
0622 diMuonMass_.ME->Fill(dimu.M());
0623 }
0624 }
0625 kCnt1 += 1;
0626 }
0627 kCnt0 += 1;
0628 }
0629 }
0630
0631 else if (pathName == pAL1DoubleMuZMass_.pathName) {
0632 const double mu_mass(.105658);
0633 unsigned int kCnt0 = 0;
0634 for (const auto& key0 : keys) {
0635 unsigned int kCnt1 = 0;
0636 for (const auto& key1 : keys) {
0637 if (key0 != key1 &&
0638 kCnt1 > kCnt0)
0639 {
0640
0641
0642 TLorentzVector mu1, mu2, dimu;
0643 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0644 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0645 dimu = mu1 + mu2;
0646 if (dimu.M() > pAL1DoubleMuZMass_.xMin && dimu.M() < pAL1DoubleMuZMass_.xMax)
0647 pAL1DoubleMuZMass_.ME->Fill(dimu.M());
0648
0649 }
0650 kCnt1 += 1;
0651 }
0652 kCnt0 += 1;
0653 }
0654 }
0655
0656 else if (pathName == pAL2DoubleMuZMass_.pathName) {
0657 const double mu_mass(.105658);
0658 unsigned int kCnt0 = 0;
0659 for (const auto& key0 : keys) {
0660 unsigned int kCnt1 = 0;
0661 for (const auto& key1 : keys) {
0662 if (key0 != key1 &&
0663 kCnt1 > kCnt0)
0664 {
0665 if (abs(objects[key0].id()) == 13 &&
0666 (objects[key0].id() + objects[key1].id() == 0))
0667 {
0668 TLorentzVector mu1, mu2, dimu;
0669 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0670 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0671 dimu = mu1 + mu2;
0672 if (dimu.M() > pAL2DoubleMuZMass_.xMin && dimu.M() < pAL2DoubleMuZMass_.xMax)
0673 pAL2DoubleMuZMass_.ME->Fill(dimu.M());
0674 }
0675 }
0676 kCnt1 += 1;
0677 }
0678 kCnt0 += 1;
0679 }
0680 }
0681
0682 else if (pathName == pAL3DoubleMuZMass_.pathName) {
0683 const double mu_mass(.105658);
0684 unsigned int kCnt0 = 0;
0685 for (const auto& key0 : keys) {
0686 unsigned int kCnt1 = 0;
0687 for (const auto& key1 : keys) {
0688 if (key0 != key1 &&
0689 kCnt1 > kCnt0)
0690 {
0691 if (abs(objects[key0].id()) == 13 &&
0692 (objects[key0].id() + objects[key1].id() == 0))
0693 {
0694 TLorentzVector mu1, mu2, dimu;
0695 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0696 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0697 dimu = mu1 + mu2;
0698 if (dimu.M() > pAL3DoubleMuZMass_.xMin && dimu.M() < pAL3DoubleMuZMass_.xMax)
0699 pAL3DoubleMuZMass_.ME->Fill(dimu.M());
0700 }
0701 }
0702 kCnt1 += 1;
0703 }
0704 kCnt0 += 1;
0705 }
0706 }
0707
0708 else if (pathName == diElecMass_.pathName) {
0709 unsigned int kCnt0 = 0;
0710 for (const auto& key0 : keys) {
0711 unsigned int kCnt1 = 0;
0712 for (const auto& key1 : keys) {
0713 if (key0 != key1 &&
0714 kCnt1 > kCnt0)
0715 {
0716
0717
0718 TLorentzVector el1, el2, diEl;
0719 el1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), 0);
0720 el2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), 0);
0721 diEl = el1 + el2;
0722 diElecMass_.ME->Fill(diEl.M());
0723
0724 }
0725 kCnt1 += 1;
0726 }
0727 kCnt0 += 1;
0728 }
0729 }
0730
0731 firedMap[pathName] = true;
0732 }
0733 }
0734
0735
0736 double end = get_wall_time();
0737 double wallTime = end - start;
0738 wallTime_.ME->Fill(wallTime);
0739 }
0740
0741
0742 void HLTObjectMonitor::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
0743 if (debugPrint)
0744 std::cout << "Calling beginRun. " << std::endl;
0745 bool changed = true;
0746 if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
0747 if (debugPrint)
0748 std::cout << "Extracting HLTconfig. " << std::endl;
0749 }
0750
0751
0752 string pathName_noVersion;
0753 vector<string> triggerPaths = hltConfig_.triggerNames();
0754
0755 for (const auto& pathName : triggerPaths) {
0756 pathName_noVersion = hltConfig_.removeVersion(pathName);
0757 for (auto plot : plotList) {
0758 if (plot->pathName == pathName_noVersion) {
0759 (*plot).pathIndex = hltConfig_.triggerIndex(pathName);
0760 } else if (plot->pathNameOR == pathName_noVersion) {
0761 (*plot).pathIndexOR = hltConfig_.triggerIndex(pathName);
0762 }
0763 }
0764 }
0765 vector<hltPlot*> plotList_temp;
0766 for (auto plot : plotList) {
0767 if (plot->pathIndex > 0 || plot->pathIndexOR > 0) {
0768 plotList_temp.push_back(plot);
0769 acceptMap[plot->pathName] = false;
0770 if (plot->pathIndexOR > 0)
0771 acceptMap[plot->pathNameOR] = false;
0772 }
0773 }
0774
0775 plotList = plotList_temp;
0776 plotList_temp.clear();
0777 }
0778
0779
0780
0781 void HLTObjectMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
0782
0783
0784
0785
0786
0787
0788
0789 ibooker.setCurrentFolder(mainShifterFolder);
0790 wallTime_.ME =
0791 ibooker.book1D(wallTime_.plotLabel, wallTime_.pathName, wallTime_.nBins, wallTime_.xMin, wallTime_.xMax);
0792 wallTime_.ME->setAxisTitle(wallTime_.xAxisLabel);
0793
0794 for (auto plot : plotList) {
0795 std::string display_pathNames = plot->pathName;
0796 if (!plot->pathNameOR.empty())
0797 display_pathNames = plot->pathName + " OR " + plot->pathNameOR;
0798
0799 if (plot->displayInPrimary) {
0800 ibooker.setCurrentFolder(mainShifterFolder);
0801 (*plot).ME = ibooker.book1D(plot->plotLabel, display_pathNames.c_str(), plot->nBins, plot->xMin, plot->xMax);
0802 (*plot).ME->setAxisTitle(plot->xAxisLabel);
0803
0804 } else {
0805 ibooker.setCurrentFolder(backupFolder);
0806 (*plot).ME = ibooker.book1D(plot->plotLabel, display_pathNames.c_str(), plot->nBins, plot->xMin, plot->xMax);
0807 (*plot).ME->setAxisTitle(plot->xAxisLabel);
0808 }
0809 }
0810 }
0811
0812 double HLTObjectMonitor::dxyFinder(double eta,
0813 double phi,
0814 edm::Handle<reco::RecoChargedCandidateCollection> recoChargedCands,
0815 edm::Handle<reco::BeamSpot> recoBeamSpot) {
0816 double dxy = -99.;
0817 for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin();
0818 l3Muon != recoChargedCands->end();
0819 l3Muon++) {
0820 if (deltaR(eta, phi, l3Muon->eta(), l3Muon->phi()) < 0.1) {
0821 dxy = (-(l3Muon->vx() - recoBeamSpot->x0()) * l3Muon->py() + (l3Muon->vy() - recoBeamSpot->y0()) * l3Muon->px()) /
0822 l3Muon->pt();
0823 break;
0824 }
0825 }
0826 return dxy;
0827 }
0828
0829 double HLTObjectMonitor::get_wall_time() {
0830 struct timeval time;
0831 if (gettimeofday(&time, nullptr))
0832 return 0;
0833 return (double)time.tv_sec + (double)time.tv_usec * .000001;
0834 }
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863 DEFINE_FWK_MODULE(HLTObjectMonitor);