59 #include "TLorentzVector.h"
61 #include <unordered_map>
67 using namespace trigger;
70 using std::unordered_map;
82 int pathIndexOR = -99;
108 double get_wall_time(
void);
117 unordered_map<hltPlot*, edm::ParameterSet*>
plotMap;
234 topDirectoryName =
"HLT/ObjectMonitor";
235 mainShifterFolder = topDirectoryName+
"/MainShifter";
236 backupFolder = topDirectoryName+
"/Backup";
239 processName_ = iConfig.
getParameter<
string>(
"processName");
242 plotMap[&rsq_] = &rsq_pset;
244 plotMap[&mr_] = &mr_pset;
246 plotMap[&alphaT_] = &alphaT_pset;
248 plotMap[&photonPt_] = &photonPt_pset;
250 plotMap[&photonEta_] = &photonEta_pset;
252 plotMap[&photonPhi_] = &photonPhi_pset;
254 plotMap[&muonPt_] = &muonPt_pset;
256 plotMap[&muonEta_] = &muonEta_pset;
258 plotMap[&muonPhi_] = &muonPhi_pset;
260 plotMap[&l2muonPt_] = &l2muonPt_pset;
262 plotMap[&l2muonEta_] = &l2muonEta_pset;
264 plotMap[&l2muonPhi_] = &l2muonPhi_pset;
266 plotMap[&l2NoBPTXmuonPt_] = &l2NoBPTXmuonPt_pset;
268 plotMap[&l2NoBPTXmuonEta_] = &l2NoBPTXmuonEta_pset;
270 plotMap[&l2NoBPTXmuonPhi_] = &l2NoBPTXmuonPhi_pset;
272 plotMap[&electronPt_] = &electronPt_pset;
274 plotMap[&electronEta_] = &electronEta_pset;
276 plotMap[&electronPhi_] = &electronPhi_pset;
278 plotMap[&jetPt_] = &jetPt_pset;
280 plotMap[&jetAK8Mass_] = &jetAK8Mass_pset;
282 plotMap[&diMuonLowMass_] = &diMuonLowMass_pset;
284 plotMap[&caloMetPt_] = &caloMetPt_pset;
286 plotMap[&caloMetPhi_] = &caloMetPhi_pset;
288 plotMap[&pfMetPt_] = &pfMetPt_pset;
290 plotMap[&pfMetPhi_] = &pfMetPhi_pset;
292 plotMap[&caloHtPt_] = &caloHtPt_pset;
294 plotMap[&pfHtPt_] = &pfHtPt_pset;
296 plotMap[&bJetPhi_] = &bJetPhi_pset;
298 plotMap[&bJetEta_] = &bJetEta_pset;
300 plotMap[&bJetCSVCalo_] = &bJetCSVCalo_pset;
302 plotMap[&bJetCSVPF_] = &bJetCSVPF_pset;
304 plotMap[&diMuonMass_] = &diMuonMass_pset;
306 plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
308 plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
310 plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
312 plotMap[&diElecMass_] = &diElecMass_pset;
314 plotMap[&muonDxy_] = &muonDxy_pset;
316 plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
318 plotMap[&tauPt_] = &tauPt_pset;
320 plotMap[&wallTime_] = &wallTime_pset;
323 for (
auto item = plotMap.begin(); item != plotMap.end(); item++)
325 (*item->first).
pathName = (*item->second).getParameter<
string>(
"pathName");
326 (*item->first).
moduleName = (*item->second).getParameter<
string>(
"moduleName");
327 (*item->first).nBins = (*item->second).getParameter<
int>(
"NbinsX");
328 (*item->first).xMin = (*item->second).getParameter<
double>(
"Xmin");
329 (*item->first).xMax = (*item->second).getParameter<
double>(
"Xmax");
330 (*item->first).xAxisLabel = (*item->second).getParameter<
string>(
"axisLabel");
331 (*item->first).plotLabel = (*item->second).getParameter<
string>(
"plotLabel");
332 (*item->first).displayInPrimary = (*item->second).getParameter<
bool>(
"mainWorkspace");
334 if ((*item->second).exists(
"pathName_OR"))
336 (*item->first).pathNameOR = (*item->second).getParameter<
string>(
"pathName_OR");
338 if ((*item->second).exists(
"moduleName_OR"))
340 (*item->first).moduleNameOR = (*item->second).getParameter<
string>(
"moduleName_OR");
343 plotList.push_back(item->first);
349 aodTriggerToken_ = consumes<trigger::TriggerEvent>(
edm::InputTag(
"hltTriggerSummaryAOD",
"", processName_));
350 lumiScalersToken_ = consumes<LumiScalersCollection>(
edm::InputTag(
"hltScalersRawToDigi",
"",
""));
351 beamSpotToken_ = consumes<reco::BeamSpot>(
edm::InputTag(
"hltOnlineBeamSpot",
"",processName_));
352 chargedCandToken_ = consumes<vector<reco::RecoChargedCandidate>>(
edm::InputTag(
"hltL3NoFiltersNoVtxMuonCandidates",
"",processName_));
353 csvCaloTagsToken_ = consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsCalo",
"",processName_));
354 csvPfTagsToken_ = consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsPF",
"",processName_));
355 csvCaloJetsToken_ = consumes<vector<reco::CaloJet>>(
edm::InputTag(
"hltSelector8CentralJetsL1FastJet",
"",processName_));
356 csvPfJetsToken_ = consumes<vector<reco::PFJet>>(
edm::InputTag(
"hltPFJetForBtag",
"",processName_));
378 double start = get_wall_time();
382 if (debugPrint)
std::cout <<
"Inside analyze(). " << std::endl;
390 iEvent.
getByToken(aodTriggerToken_, aodTriggerEvent);
391 if (!aodTriggerEvent.isValid())
return;
394 unordered_map<string, bool> firedMap = acceptMap;
395 for (
auto plot: plotList)
397 if (firedMap[
plot->pathName])
continue;
398 bool triggerAccept =
false;
405 pathName =
plot->pathName;
406 triggerAccept =
true;
410 if (firedMap[
plot->pathNameOR])
continue;
412 pathName =
plot->pathNameOR;
413 triggerAccept =
true;
418 unsigned int moduleFilterIndex = aodTriggerEvent->filterIndex(moduleFilter);
420 if (moduleFilterIndex+1 > aodTriggerEvent->sizeFilters())
return;
421 const Keys &
keys = aodTriggerEvent->filterKeys( moduleFilterIndex );
430 if (pathName == pfHtPt_.pathName)
432 for (
const auto &
key : keys) pfHtPt_.ME->Fill(objects[
key].
pt());
436 else if (pathName == jetPt_.pathName)
438 for (
const auto &
key : keys) jetPt_.ME->Fill(objects[
key].
pt());
442 else if (pathName == photonPt_.pathName)
444 for (
const auto &
key : keys)
446 photonPt_.ME->Fill(objects[
key].
pt());
447 photonEta_.ME->Fill(objects[
key].
eta());
448 photonPhi_.ME->Fill(objects[
key].
phi());
453 else if (pathName == electronPt_.pathName)
455 for (
const auto &
key : keys)
457 electronPt_.ME->Fill(objects[
key].
pt());
458 electronEta_.ME->Fill(objects[
key].
eta());
459 electronPhi_.ME->Fill(objects[
key].
phi());
464 else if (pathName == muonPt_.pathName)
466 for (
const auto &
key : keys)
468 muonPt_.ME->Fill(objects[
key].
pt());
469 muonEta_.ME->Fill(objects[
key].
eta());
470 muonPhi_.ME->Fill(objects[
key].
phi());
475 else if (pathName == l2muonPt_.pathName)
477 for (
const auto &
key : keys)
479 l2muonPt_.ME->Fill(objects[
key].
pt());
480 l2muonEta_.ME->Fill(objects[
key].
eta());
481 l2muonPhi_.ME->Fill(objects[
key].
phi());
486 else if (pathName == l2NoBPTXmuonPt_.pathName)
488 for (
const auto &
key : keys)
490 l2NoBPTXmuonPt_.ME->Fill(objects[
key].
pt());
491 l2NoBPTXmuonEta_.ME->Fill(objects[
key].
eta());
492 l2NoBPTXmuonPhi_.ME->Fill(objects[
key].
phi());
497 else if (pathName == mr_.pathName)
499 double onlineMR = 0, onlineRsq = 0;
500 for (
const auto &
key : keys)
502 if(objects[
key].
id() == 0){
503 onlineMR = objects[
key].px();
504 onlineRsq = objects[
key].py();
506 mr_.ME->Fill(onlineMR);
507 rsq_.ME->Fill(onlineRsq);
512 else if (pathName == alphaT_.pathName)
514 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>> alphaT_jets;
515 for (
const auto &
key : keys)
517 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(objects[
key].
pt(),objects[
key].
eta(),objects[
key].
phi(),objects[
key].
mass());
518 alphaT_jets.push_back(JetLVec);
521 float alphaT = AlphaT(alphaT_jets,
false).value();
522 alphaT_.ME->Fill(alphaT);
526 else if (pathName == tauPt_.pathName)
528 for (
const auto &
key : keys) tauPt_.ME->Fill(objects[
key].
pt());
532 else if (pathName == caloMetPt_.pathName)
534 for (
const auto &
key : keys)
536 caloMetPt_.ME->Fill(objects[
key].
pt());
537 caloMetPhi_.ME->Fill(objects[
key].
phi());
542 else if (pathName == caloHtPt_.pathName)
544 for (
const auto &
key : keys)
546 if(objects[
key].
id()==89) caloHtPt_.ME->Fill(objects[
key].
pt());
551 else if (pathName == jetAK8Pt_.pathName)
553 for (
const auto &
key : keys)
555 jetAK8Pt_.ME->Fill(objects[
key].
pt());
556 jetAK8Mass_.ME->Fill(objects[
key].
mass());
561 else if (pathName == pfMetPt_.pathName)
563 for (
const auto &
key : keys)
565 pfMetPt_.ME->Fill(objects[
key].
pt());
566 pfMetPhi_.ME->Fill(objects[
key].
phi());
571 else if (pathName == bJetEta_.pathName || pathName == bJetEta_.pathNameOR)
573 for (
const auto &
key : keys)
575 bJetEta_.ME->Fill(objects[
key].
eta());
576 bJetPhi_.ME->Fill(objects[
key].
phi());
581 if (pathName == bJetCSVPF_.pathName)
584 iEvent.
getByToken(csvPfTagsToken_, csvPfTags);
586 iEvent.
getByToken(csvPfJetsToken_, csvPfJets);
590 for (
auto iter = csvPfTags->begin(); iter != csvPfTags->end(); iter++) bJetCSVPF_.ME->Fill(iter->second);
593 if (pathName == bJetCSVCalo_.pathName)
596 iEvent.
getByToken(csvCaloTagsToken_, csvCaloTags);
598 iEvent.
getByToken(csvCaloJetsToken_, csvCaloJets);
602 for (
auto iter = csvCaloTags->begin(); iter != csvCaloTags->end(); iter++) bJetCSVCalo_.ME->Fill(iter->second);
607 else if (pathName == muonDxy_.pathName)
610 iEvent.
getByToken(chargedCandToken_, recoChargedCands);
612 iEvent.
getByToken(beamSpotToken_, recoBeamSpot);
617 for (
const auto &
key : keys)
619 muon_dxy = dxyFinder(objects[
key].
eta(), objects[
key].
phi(), recoChargedCands, recoBeamSpot);
620 if (muon_dxy != -99.) muonDxy_.ME->Fill(muon_dxy);
632 else if (pathName == diMuonLowMass_.pathName)
634 const double mu_mass(.105658);
635 unsigned int kCnt0 = 0;
636 for (
const auto & key0: keys)
638 unsigned int kCnt1 = 0;
639 for (
const auto & key1: keys)
641 if (key0 != key1 && kCnt1 > kCnt0)
643 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0))
645 TLorentzVector mu1, mu2, dimu;
646 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
647 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
649 diMuonLowMass_.ME->Fill(dimu.M());
658 else if (pathName == diMuonMass_.pathName || pathName == diMuonMass_.pathNameOR)
660 const double mu_mass(.105658);
661 unsigned int kCnt0 = 0;
662 for (
const auto & key0: keys)
664 unsigned int kCnt1 = 0;
665 for (
const auto & key1: keys)
667 if (key0 != key1 && kCnt1 > kCnt0)
669 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0))
671 TLorentzVector mu1, mu2, dimu;
672 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
673 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
675 diMuonMass_.ME->Fill(dimu.M());
684 else if (pathName == pAL1DoubleMuZMass_.pathName)
686 const double mu_mass(.105658);
687 unsigned int kCnt0 = 0;
688 for (
const auto & key0: keys)
690 unsigned int kCnt1 = 0;
691 for (
const auto & key1: keys)
693 if (key0 != key1 && kCnt1 > kCnt0)
697 TLorentzVector mu1, mu2, dimu;
698 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
699 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
701 if(dimu.M()>pAL1DoubleMuZMass_.xMin && dimu.M()<pAL1DoubleMuZMass_.xMax) pAL1DoubleMuZMass_.ME->Fill(dimu.M());
710 else if (pathName == pAL2DoubleMuZMass_.pathName)
712 const double mu_mass(.105658);
713 unsigned int kCnt0 = 0;
714 for (
const auto & key0: keys)
716 unsigned int kCnt1 = 0;
717 for (
const auto & key1: keys)
719 if (key0 != key1 && kCnt1 > kCnt0)
721 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0))
723 TLorentzVector mu1, mu2, dimu;
724 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
725 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
727 if(dimu.M()>pAL2DoubleMuZMass_.xMin && dimu.M()<pAL2DoubleMuZMass_.xMax) pAL2DoubleMuZMass_.ME->Fill(dimu.M());
736 else if (pathName == pAL3DoubleMuZMass_.pathName)
738 const double mu_mass(.105658);
739 unsigned int kCnt0 = 0;
740 for (
const auto & key0: keys)
742 unsigned int kCnt1 = 0;
743 for (
const auto & key1: keys)
745 if (key0 != key1 && kCnt1 > kCnt0)
747 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0))
749 TLorentzVector mu1, mu2, dimu;
750 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
751 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
753 if(dimu.M()>pAL3DoubleMuZMass_.xMin && dimu.M()<pAL3DoubleMuZMass_.xMax) pAL3DoubleMuZMass_.ME->Fill(dimu.M());
762 else if (pathName == diElecMass_.pathName)
764 unsigned int kCnt0 = 0;
765 for (
const auto & key0: keys)
767 unsigned int kCnt1 = 0;
768 for (
const auto & key1: keys)
770 if (key0 != key1 && kCnt1 > kCnt0)
774 TLorentzVector el1, el2, diEl;
775 el1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), 0);
776 el2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), 0);
778 diElecMass_.ME->Fill(diEl.M());
792 double end = get_wall_time();
794 wallTime_.ME->Fill(wallTime);
801 if (debugPrint)
std::cout <<
"Calling beginRun. " << std::endl;
803 if (hltConfig_.init(iRun, iSetup, processName_, changed))
805 if (debugPrint)
std::cout <<
"Extracting HLTconfig. " << std::endl;
809 string pathName_noVersion;
810 vector<string>
triggerPaths = hltConfig_.triggerNames();
812 for (
const auto &
pathName : triggerPaths)
814 pathName_noVersion = hltConfig_.removeVersion(
pathName);
815 for (
auto plot : plotList)
817 if (
plot->pathName == pathName_noVersion)
819 (*plot).pathIndex = hltConfig_.triggerIndex(
pathName);
821 else if (
plot->pathNameOR == pathName_noVersion)
823 (*plot).pathIndexOR = hltConfig_.triggerIndex(
pathName);
827 vector<hltPlot*> plotList_temp;
828 for (
auto plot : plotList)
830 if (
plot->pathIndex > 0 ||
plot->pathIndexOR > 0)
832 plotList_temp.push_back(
plot);
833 acceptMap[
plot->pathName] =
false;
834 if (
plot->pathIndexOR > 0) acceptMap[
plot->pathNameOR] =
false;
838 plotList = plotList_temp;
839 plotList_temp.clear();
848 if (debugPrint)
std::cout <<
"Calling endRun. " << std::endl;
862 wallTime_.ME = ibooker.
book1D(wallTime_.plotLabel,wallTime_.pathName,wallTime_.nBins,wallTime_.xMin,wallTime_.xMax);
865 for (
auto plot : plotList)
868 if (!
plot->pathNameOR.empty()) display_pathNames =
plot->pathName +
" OR " +
plot->pathNameOR;
870 if (
plot->displayInPrimary)
890 for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin(); l3Muon != recoChargedCands->end(); l3Muon++)
892 if (
deltaR(eta,phi,l3Muon->eta(),l3Muon->phi()) < 0.1)
894 dxy = (-(l3Muon->vx()-recoBeamSpot->x0()) * l3Muon->py() + (l3Muon->vy()-recoBeamSpot->y0()) * l3Muon->px())/l3Muon->pt();
904 if (gettimeofday(&time,
NULL))
return 0;
905 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
tuple start
Check for commandline option errors.
edm::ParameterSet caloHtPt_pset
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet jetAK8Mass_pset
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
#define DEFINE_FWK_MODULE(type)
edm::ParameterSet pAL2DoubleMuZMass_pset
edm::ParameterSet bJetCSVPF_pset
edm::ParameterSet muonEta_pset
edm::ParameterSet diMuonMass_pset
void endRun(edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet muonDxy_pset
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
edm::ParameterSet l2NoBPTXmuonEta_pset
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
void bookHistograms(fwlite::EventContainer &eventCont)
edm::ParameterSet pAL1DoubleMuZMass_pset
edm::ParameterSet l2muonPt_pset
edm::EDGetTokenT< vector< reco::PFJet > > csvPfJetsToken_
triggerResultsToken_(consumes< edm::TriggerResults >(edm::InputTag("TriggerResults")))
HLTObjectMonitor(const edm::ParameterSet &)
hltPlot pAL2DoubleMuZMass_
edm::ParameterSet wallTime_pset
edm::ParameterSet diElecMass_pset
std::string moduleName(Provenance const &provenance)
edm::ParameterSet photonPt_pset
edm::EDGetTokenT< trigger::TriggerEvent > aodTriggerToken_
edm::ParameterSet electronEta_pset
edm::ParameterSet bJetEta_pset
edm::ParameterSet alphaT_pset
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > chargedCandToken_
edm::ParameterSet tauPt_pset
MonitorElement * book1D(Args &&...args)
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
hltPlot pAL3DoubleMuZMass_
double deltaR(double eta1, double eta2, double phi1, double phi2)
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 >)
void setCurrentFolder(const std::string &fullpath)
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
edm::ParameterSet pAL3DoubleMuZMass_pset
Geom::Phi< T > phi() const
edm::ParameterSet l2NoBPTXmuonPhi_pset
double get_wall_time(void)
edm::EDGetTokenT< vector< reco::CaloJet > > csvCaloJetsToken_
edm::ParameterSet caloMetPhi_pset
vector< hltPlot * > plotList
static std::string const triggerPaths
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
edm::ParameterSet l2NoBPTXmuonPt_pset
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
unordered_map< string, bool > acceptMap