57 #include "TLorentzVector.h" 59 #include <unordered_map> 67 using std::unordered_map;
78 int pathIndexOR = -99;
102 double get_wall_time(
void);
111 unordered_map<hltPlot*, edm::ParameterSet*>
plotMap;
227 topDirectoryName =
"HLT/ObjectMonitor";
228 mainShifterFolder = topDirectoryName +
"/MainShifter";
229 backupFolder = topDirectoryName +
"/Backup";
232 processName_ = iConfig.
getParameter<
string>(
"processName");
235 plotMap[&rsq_] = &rsq_pset;
237 plotMap[&mr_] = &mr_pset;
239 plotMap[&alphaT_] = &alphaT_pset;
241 plotMap[&photonPt_] = &photonPt_pset;
243 plotMap[&photonEta_] = &photonEta_pset;
245 plotMap[&photonPhi_] = &photonPhi_pset;
247 plotMap[&muonPt_] = &muonPt_pset;
249 plotMap[&muonEta_] = &muonEta_pset;
251 plotMap[&muonPhi_] = &muonPhi_pset;
253 plotMap[&l2muonPt_] = &l2muonPt_pset;
255 plotMap[&l2muonEta_] = &l2muonEta_pset;
257 plotMap[&l2muonPhi_] = &l2muonPhi_pset;
259 plotMap[&l2NoBPTXmuonPt_] = &l2NoBPTXmuonPt_pset;
261 plotMap[&l2NoBPTXmuonEta_] = &l2NoBPTXmuonEta_pset;
263 plotMap[&l2NoBPTXmuonPhi_] = &l2NoBPTXmuonPhi_pset;
265 plotMap[&electronPt_] = &electronPt_pset;
267 plotMap[&electronEta_] = &electronEta_pset;
269 plotMap[&electronPhi_] = &electronPhi_pset;
271 plotMap[&jetPt_] = &jetPt_pset;
273 plotMap[&jetAK8Mass_] = &jetAK8Mass_pset;
275 plotMap[&diMuonLowMass_] = &diMuonLowMass_pset;
277 plotMap[&caloMetPt_] = &caloMetPt_pset;
279 plotMap[&caloMetPhi_] = &caloMetPhi_pset;
281 plotMap[&pfMetPt_] = &pfMetPt_pset;
283 plotMap[&pfMetPhi_] = &pfMetPhi_pset;
285 plotMap[&caloHtPt_] = &caloHtPt_pset;
287 plotMap[&pfHtPt_] = &pfHtPt_pset;
289 plotMap[&bJetPhi_] = &bJetPhi_pset;
291 plotMap[&bJetEta_] = &bJetEta_pset;
293 plotMap[&bJetCSVCalo_] = &bJetCSVCalo_pset;
295 plotMap[&bJetCSVPF_] = &bJetCSVPF_pset;
297 plotMap[&diMuonMass_] = &diMuonMass_pset;
299 plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
301 plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
303 plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
305 plotMap[&diElecMass_] = &diElecMass_pset;
307 plotMap[&muonDxy_] = &muonDxy_pset;
309 plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
311 plotMap[&tauPt_] = &tauPt_pset;
313 plotMap[&wallTime_] = &wallTime_pset;
315 for (
auto item = plotMap.begin();
item != plotMap.end();
item++) {
318 (*
item->first).
nBins = (*
item->second).getParameter<
int>(
"NbinsX");
319 (*
item->first).
xMin = (*
item->second).getParameter<
double>(
"Xmin");
320 (*
item->first).
xMax = (*
item->second).getParameter<
double>(
"Xmax");
321 (*
item->first).xAxisLabel = (*
item->second).getParameter<
string>(
"axisLabel");
323 (*
item->first).displayInPrimary = (*
item->second).getParameter<
bool>(
"mainWorkspace");
325 if ((*
item->second).exists(
"pathName_OR")) {
326 (*
item->first).pathNameOR = (*
item->second).getParameter<
string>(
"pathName_OR");
328 if ((*
item->second).exists(
"moduleName_OR")) {
329 (*
item->first).moduleNameOR = (*
item->second).getParameter<
string>(
"moduleName_OR");
332 plotList.push_back(
item->first);
337 triggerResultsToken_ = consumes<edm::TriggerResults>(
edm::InputTag(
"TriggerResults",
"", processName_));
338 aodTriggerToken_ = consumes<trigger::TriggerEvent>(
edm::InputTag(
"hltTriggerSummaryAOD",
"", processName_));
339 lumiScalersToken_ = consumes<LumiScalersCollection>(
edm::InputTag(
"hltScalersRawToDigi",
"",
""));
340 beamSpotToken_ = consumes<reco::BeamSpot>(
edm::InputTag(
"hltOnlineBeamSpot",
"", processName_));
341 chargedCandToken_ = consumes<vector<reco::RecoChargedCandidate>>(
342 edm::InputTag(
"hltL3NoFiltersNoVtxMuonCandidates",
"", processName_));
344 consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsCalo",
"", processName_));
346 consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsPF",
"", processName_));
348 consumes<vector<reco::CaloJet>>(
edm::InputTag(
"hltSelector8CentralJetsL1FastJet",
"", processName_));
349 csvPfJetsToken_ = consumes<vector<reco::PFJet>>(
edm::InputTag(
"hltPFJetForBtag",
"", processName_));
363 double start = get_wall_time();
368 std::cout <<
"Inside analyze(). " << std::endl;
372 iEvent.
getByToken(triggerResultsToken_, triggerResults);
377 iEvent.
getByToken(aodTriggerToken_, aodTriggerEvent);
378 if (!aodTriggerEvent.
isValid())
382 unordered_map<string, bool> firedMap = acceptMap;
383 for (
auto plot : plotList)
385 if (firedMap[
plot->pathName])
391 if (
plot->pathIndex > 0 && triggerResults->
accept(
plot->pathIndex) && hltConfig_.saveTags(
plot->moduleName)) {
393 pathName =
plot->pathName;
394 triggerAccept =
true;
395 }
else if (
plot->pathIndexOR > 0 && triggerResults->
accept(
plot->pathIndexOR) &&
396 hltConfig_.saveTags(
plot->moduleNameOR)) {
397 if (firedMap[
plot->pathNameOR])
400 pathName =
plot->pathNameOR;
401 triggerAccept =
true;
405 unsigned int moduleFilterIndex = aodTriggerEvent->
filterIndex(moduleFilter);
407 if (moduleFilterIndex + 1 > aodTriggerEvent->
sizeFilters())
418 if (pathName == pfHtPt_.pathName) {
419 for (
const auto&
key : keys)
420 pfHtPt_.ME->Fill(objects[
key].
pt());
424 else if (pathName == jetPt_.pathName) {
425 for (
const auto&
key : keys)
426 jetPt_.ME->Fill(objects[
key].
pt());
430 else if (pathName == photonPt_.pathName) {
431 for (
const auto&
key : keys) {
432 photonPt_.ME->Fill(objects[
key].
pt());
433 photonEta_.ME->Fill(objects[
key].
eta());
434 photonPhi_.ME->Fill(objects[
key].phi());
439 else if (pathName == electronPt_.pathName) {
440 for (
const auto&
key : keys) {
441 electronPt_.ME->Fill(objects[
key].
pt());
442 electronEta_.ME->Fill(objects[
key].
eta());
443 electronPhi_.ME->Fill(objects[
key].phi());
448 else if (pathName == muonPt_.pathName) {
449 for (
const auto&
key : keys) {
450 muonPt_.ME->Fill(objects[
key].
pt());
451 muonEta_.ME->Fill(objects[
key].
eta());
452 muonPhi_.ME->Fill(objects[
key].phi());
457 else if (pathName == l2muonPt_.pathName) {
458 for (
const auto&
key : keys) {
459 l2muonPt_.ME->Fill(objects[
key].
pt());
460 l2muonEta_.ME->Fill(objects[
key].
eta());
461 l2muonPhi_.ME->Fill(objects[
key].phi());
466 else if (pathName == l2NoBPTXmuonPt_.pathName) {
467 for (
const auto&
key : keys) {
468 l2NoBPTXmuonPt_.ME->Fill(objects[
key].
pt());
469 l2NoBPTXmuonEta_.ME->Fill(objects[
key].
eta());
470 l2NoBPTXmuonPhi_.ME->Fill(objects[
key].phi());
475 else if (pathName == mr_.pathName) {
476 double onlineMR = 0, onlineRsq = 0;
477 for (
const auto&
key : keys) {
478 if (objects[
key].
id() == 0) {
479 onlineMR = objects[
key].px();
480 onlineRsq = objects[
key].py();
482 mr_.ME->Fill(onlineMR);
483 rsq_.ME->Fill(onlineRsq);
488 else if (pathName == alphaT_.pathName) {
489 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>> alphaT_jets;
490 for (
const auto&
key : keys) {
491 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(
493 alphaT_jets.push_back(JetLVec);
496 float alphaT = AlphaT(alphaT_jets,
false).value();
497 alphaT_.ME->Fill(alphaT);
501 else if (pathName == tauPt_.pathName) {
502 for (
const auto&
key : keys)
503 tauPt_.ME->Fill(objects[
key].
pt());
507 else if (pathName == caloMetPt_.pathName) {
508 for (
const auto&
key : keys) {
509 caloMetPt_.ME->Fill(objects[
key].
pt());
510 caloMetPhi_.ME->Fill(objects[
key].phi());
515 else if (pathName == caloHtPt_.pathName) {
516 for (
const auto&
key : keys) {
517 if (objects[
key].
id() == 89)
518 caloHtPt_.ME->Fill(objects[
key].
pt());
523 else if (pathName == jetAK8Pt_.pathName) {
524 for (
const auto&
key : keys) {
525 jetAK8Pt_.ME->Fill(objects[
key].
pt());
526 jetAK8Mass_.ME->Fill(objects[
key].
mass());
531 else if (pathName == pfMetPt_.pathName) {
532 for (
const auto&
key : keys) {
533 pfMetPt_.ME->Fill(objects[
key].
pt());
534 pfMetPhi_.ME->Fill(objects[
key].phi());
539 else if (pathName == bJetEta_.pathName || pathName == bJetEta_.pathNameOR) {
540 for (
const auto&
key : keys) {
541 bJetEta_.ME->Fill(objects[
key].
eta());
542 bJetPhi_.ME->Fill(objects[
key].phi());
547 if (pathName == bJetCSVPF_.pathName) {
549 iEvent.
getByToken(csvPfTagsToken_, csvPfTags);
551 iEvent.
getByToken(csvPfJetsToken_, csvPfJets);
554 for (
auto iter = csvPfTags->
begin(); iter != csvPfTags->
end(); iter++)
555 bJetCSVPF_.ME->Fill(iter->second);
558 if (pathName == bJetCSVCalo_.pathName) {
560 iEvent.
getByToken(csvCaloTagsToken_, csvCaloTags);
562 iEvent.
getByToken(csvCaloJetsToken_, csvCaloJets);
565 for (
auto iter = csvCaloTags->
begin(); iter != csvCaloTags->
end(); iter++)
566 bJetCSVCalo_.ME->Fill(iter->second);
571 else if (pathName == muonDxy_.pathName) {
573 iEvent.
getByToken(chargedCandToken_, recoChargedCands);
575 iEvent.
getByToken(beamSpotToken_, recoBeamSpot);
579 for (
const auto&
key : keys) {
580 muon_dxy = dxyFinder(objects[
key].
eta(), objects[
key].phi(), recoChargedCands, recoBeamSpot);
581 if (muon_dxy != -99.)
582 muonDxy_.ME->Fill(muon_dxy);
594 else if (pathName == diMuonLowMass_.pathName) {
595 const double mu_mass(.105658);
596 unsigned int kCnt0 = 0;
597 for (
const auto& key0 : keys) {
598 unsigned int kCnt1 = 0;
599 for (
const auto& key1 : keys) {
603 if (
abs(objects[key0].
id()) == 13 &&
604 (objects[key0].
id() + objects[key1].
id() == 0))
606 TLorentzVector mu1, mu2, dimu;
607 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
608 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
610 diMuonLowMass_.ME->Fill(dimu.M());
619 else if (pathName == diMuonMass_.pathName || pathName == diMuonMass_.pathNameOR) {
620 const double mu_mass(.105658);
621 unsigned int kCnt0 = 0;
622 for (
const auto& key0 : keys) {
623 unsigned int kCnt1 = 0;
624 for (
const auto& key1 : keys) {
628 if (
abs(objects[key0].
id()) == 13 &&
629 (objects[key0].
id() + objects[key1].
id() == 0))
631 TLorentzVector mu1, mu2, dimu;
632 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
633 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
635 diMuonMass_.ME->Fill(dimu.M());
644 else if (pathName == pAL1DoubleMuZMass_.pathName) {
645 const double mu_mass(.105658);
646 unsigned int kCnt0 = 0;
647 for (
const auto& key0 : keys) {
648 unsigned int kCnt1 = 0;
649 for (
const auto& key1 : keys) {
655 TLorentzVector mu1, mu2, dimu;
656 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
657 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
659 if (dimu.M() > pAL1DoubleMuZMass_.xMin && dimu.M() < pAL1DoubleMuZMass_.xMax)
660 pAL1DoubleMuZMass_.ME->Fill(dimu.M());
669 else if (pathName == pAL2DoubleMuZMass_.pathName) {
670 const double mu_mass(.105658);
671 unsigned int kCnt0 = 0;
672 for (
const auto& key0 : keys) {
673 unsigned int kCnt1 = 0;
674 for (
const auto& key1 : keys) {
678 if (
abs(objects[key0].
id()) == 13 &&
679 (objects[key0].
id() + objects[key1].
id() == 0))
681 TLorentzVector mu1, mu2, dimu;
682 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
683 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
685 if (dimu.M() > pAL2DoubleMuZMass_.xMin && dimu.M() < pAL2DoubleMuZMass_.xMax)
686 pAL2DoubleMuZMass_.ME->Fill(dimu.M());
695 else if (pathName == pAL3DoubleMuZMass_.pathName) {
696 const double mu_mass(.105658);
697 unsigned int kCnt0 = 0;
698 for (
const auto& key0 : keys) {
699 unsigned int kCnt1 = 0;
700 for (
const auto& key1 : keys) {
704 if (
abs(objects[key0].
id()) == 13 &&
705 (objects[key0].
id() + objects[key1].
id() == 0))
707 TLorentzVector mu1, mu2, dimu;
708 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
709 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
711 if (dimu.M() > pAL3DoubleMuZMass_.xMin && dimu.M() < pAL3DoubleMuZMass_.xMax)
712 pAL3DoubleMuZMass_.ME->Fill(dimu.M());
721 else if (pathName == diElecMass_.pathName) {
722 unsigned int kCnt0 = 0;
723 for (
const auto& key0 : keys) {
724 unsigned int kCnt1 = 0;
725 for (
const auto& key1 : keys) {
731 TLorentzVector el1, el2, diEl;
732 el1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), 0);
733 el2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), 0);
735 diElecMass_.ME->Fill(diEl.M());
749 double end = get_wall_time();
751 wallTime_.ME->Fill(wallTime);
757 std::cout <<
"Calling beginRun. " << std::endl;
759 if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
761 std::cout <<
"Extracting HLTconfig. " << std::endl;
765 string pathName_noVersion;
766 vector<string>
triggerPaths = hltConfig_.triggerNames();
768 for (
const auto&
pathName : triggerPaths) {
769 pathName_noVersion = hltConfig_.removeVersion(
pathName);
770 for (
auto plot : plotList) {
771 if (
plot->pathName == pathName_noVersion) {
772 (*plot).pathIndex = hltConfig_.triggerIndex(
pathName);
773 }
else if (
plot->pathNameOR == pathName_noVersion) {
774 (*plot).pathIndexOR = hltConfig_.triggerIndex(
pathName);
778 vector<hltPlot*> plotList_temp;
779 for (
auto plot : plotList) {
780 if (
plot->pathIndex > 0 ||
plot->pathIndexOR > 0) {
781 plotList_temp.push_back(
plot);
782 acceptMap[
plot->pathName] =
false;
783 if (
plot->pathIndexOR > 0)
784 acceptMap[
plot->pathNameOR] =
false;
788 plotList = plotList_temp;
789 plotList_temp.clear();
796 std::cout <<
"Calling endRun. " << std::endl;
807 ibooker.setCurrentFolder(mainShifterFolder);
809 ibooker.book1D(wallTime_.plotLabel, wallTime_.pathName, wallTime_.nBins, wallTime_.xMin, wallTime_.xMax);
810 wallTime_.ME->setAxisTitle(wallTime_.xAxisLabel);
812 for (
auto plot : plotList) {
814 if (!
plot->pathNameOR.empty())
815 display_pathNames =
plot->pathName +
" OR " +
plot->pathNameOR;
817 if (
plot->displayInPrimary) {
818 ibooker.setCurrentFolder(mainShifterFolder);
819 (*plot).ME = ibooker.book1D(
plot->plotLabel, display_pathNames.c_str(),
plot->nBins,
plot->xMin,
plot->xMax);
820 (*plot).ME->setAxisTitle(
plot->xAxisLabel);
823 ibooker.setCurrentFolder(backupFolder);
824 (*plot).ME = ibooker.book1D(
plot->plotLabel, display_pathNames.c_str(),
plot->nBins,
plot->xMin,
plot->xMax);
825 (*plot).ME->setAxisTitle(
plot->xAxisLabel);
835 for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin();
836 l3Muon != recoChargedCands->end();
838 if (
deltaR(eta, phi, l3Muon->eta(), l3Muon->phi()) < 0.1) {
839 dxy = (-(l3Muon->vx() - recoBeamSpot->
x0()) * l3Muon->py() + (l3Muon->vy() - recoBeamSpot->
y0()) * l3Muon->px()) /
849 if (gettimeofday(&time,
nullptr))
851 return (
double)time.tv_sec + (double)time.tv_usec * .000001;
edm::ParameterSet caloMetPt_pset
T getParameter(std::string const &) const
edm::ParameterSet bJetPhi_pset
edm::ParameterSet bJetCSVCalo_pset
edm::ParameterSet caloHtPt_pset
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet jetAK8Mass_pset
trigger::size_type sizeFilters() const
edm::ParameterSet pfMetPhi_pset
edm::ParameterSet muonPhi_pset
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::ParameterSet l2muonEta_pset
edm::ParameterSet photonPhi_pset
edm::ParameterSet electronPt_pset
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool accept() const
Has at least one path accepted the event?
edm::ParameterSet pAL2DoubleMuZMass_pset
const Keys & filterKeys(trigger::size_type index) const
edm::ParameterSet bJetCSVPF_pset
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
edm::ParameterSet muonEta_pset
edm::ParameterSet diMuonMass_pset
const_iterator end() const
edm::ParameterSet muonDxy_pset
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
~HLTObjectMonitor() override
edm::ParameterSet l2NoBPTXmuonEta_pset
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::ParameterSet pAL1DoubleMuZMass_pset
edm::ParameterSet l2muonPt_pset
edm::EDGetTokenT< vector< reco::PFJet > > csvPfJetsToken_
HLTObjectMonitor(const edm::ParameterSet &)
hltPlot pAL2DoubleMuZMass_
edm::ParameterSet wallTime_pset
edm::ParameterSet diElecMass_pset
edm::ParameterSet photonPt_pset
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< trigger::TriggerEvent > aodTriggerToken_
edm::ParameterSet electronEta_pset
edm::ParameterSet bJetEta_pset
const TriggerObjectCollection & getObjects() const
edm::ParameterSet alphaT_pset
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > chargedCandToken_
edm::ParameterSet tauPt_pset
Abs< T >::type abs(const T &t)
unordered_map< hltPlot *, edm::ParameterSet * > plotMap
edm::ParameterSet rsq_pset
edm::ParameterSet mr_pset
static std::string const triggerResults
hltPlot pAL1DoubleMuZMass_
edm::ParameterSet pfHtPt_pset
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
hltPlot pAL3DoubleMuZMass_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
edm::ParameterSet jetPt_pset
HLTConfigProvider hltConfig_
edm::ParameterSet diMuonLowMass_pset
edm::ParameterSet jetAK8Pt_pset
edm::ParameterSet l2muonPhi_pset
edm::ParameterSet muonPt_pset
double dxyFinder(double, double, edm::Handle< reco::RecoChargedCandidateCollection >, edm::Handle< reco::BeamSpot >)
edm::ParameterSet pfMetPt_pset
edm::ParameterSet electronPhi_pset
std::vector< size_type > Keys
edm::EDGetTokenT< reco::JetTagCollection > csvCaloTagsToken_
edm::EDGetTokenT< reco::JetTagCollection > csvPfTagsToken_
edm::ParameterSet photonEta_pset
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
edm::ParameterSet pAL3DoubleMuZMass_pset
edm::ParameterSet l2NoBPTXmuonPhi_pset
double get_wall_time(void)
double y0() const
y coordinate
edm::EDGetTokenT< vector< reco::CaloJet > > csvCaloJetsToken_
edm::ParameterSet caloMetPhi_pset
vector< hltPlot * > plotList
static std::string const triggerPaths
const_iterator begin() const
edm::ParameterSet l2NoBPTXmuonPt_pset
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
unordered_map< string, bool > acceptMap
double x0() const
x coordinate