57 #include "TLorentzVector.h"
59 #include <unordered_map>
65 using namespace trigger;
67 using std::unordered_map;
78 int pathIndexOR = -99;
101 double get_wall_time(
void);
110 unordered_map<hltPlot*, edm::ParameterSet*>
plotMap;
226 topDirectoryName =
"HLT/ObjectMonitor";
227 mainShifterFolder = topDirectoryName +
"/MainShifter";
228 backupFolder = topDirectoryName +
"/Backup";
231 processName_ = iConfig.
getParameter<
string>(
"processName");
234 plotMap[&rsq_] = &rsq_pset;
236 plotMap[&mr_] = &mr_pset;
238 plotMap[&alphaT_] = &alphaT_pset;
240 plotMap[&photonPt_] = &photonPt_pset;
242 plotMap[&photonEta_] = &photonEta_pset;
244 plotMap[&photonPhi_] = &photonPhi_pset;
246 plotMap[&muonPt_] = &muonPt_pset;
248 plotMap[&muonEta_] = &muonEta_pset;
250 plotMap[&muonPhi_] = &muonPhi_pset;
252 plotMap[&l2muonPt_] = &l2muonPt_pset;
254 plotMap[&l2muonEta_] = &l2muonEta_pset;
256 plotMap[&l2muonPhi_] = &l2muonPhi_pset;
258 plotMap[&l2NoBPTXmuonPt_] = &l2NoBPTXmuonPt_pset;
260 plotMap[&l2NoBPTXmuonEta_] = &l2NoBPTXmuonEta_pset;
262 plotMap[&l2NoBPTXmuonPhi_] = &l2NoBPTXmuonPhi_pset;
264 plotMap[&electronPt_] = &electronPt_pset;
266 plotMap[&electronEta_] = &electronEta_pset;
268 plotMap[&electronPhi_] = &electronPhi_pset;
270 plotMap[&jetPt_] = &jetPt_pset;
272 plotMap[&jetAK8Mass_] = &jetAK8Mass_pset;
274 plotMap[&diMuonLowMass_] = &diMuonLowMass_pset;
276 plotMap[&caloMetPt_] = &caloMetPt_pset;
278 plotMap[&caloMetPhi_] = &caloMetPhi_pset;
280 plotMap[&pfMetPt_] = &pfMetPt_pset;
282 plotMap[&pfMetPhi_] = &pfMetPhi_pset;
284 plotMap[&caloHtPt_] = &caloHtPt_pset;
286 plotMap[&pfHtPt_] = &pfHtPt_pset;
288 plotMap[&bJetPhi_] = &bJetPhi_pset;
290 plotMap[&bJetEta_] = &bJetEta_pset;
292 plotMap[&bJetCSVCalo_] = &bJetCSVCalo_pset;
294 plotMap[&bJetCSVPF_] = &bJetCSVPF_pset;
296 plotMap[&diMuonMass_] = &diMuonMass_pset;
298 plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
300 plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
302 plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
304 plotMap[&diElecMass_] = &diElecMass_pset;
306 plotMap[&muonDxy_] = &muonDxy_pset;
308 plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
310 plotMap[&tauPt_] = &tauPt_pset;
312 plotMap[&wallTime_] = &wallTime_pset;
314 for (
auto item = plotMap.begin();
item != plotMap.end();
item++) {
317 (*
item->first).nBins = (*
item->second).getParameter<
int>(
"NbinsX");
318 (*
item->first).xMin = (*
item->second).getParameter<
double>(
"Xmin");
319 (*
item->first).xMax = (*
item->second).getParameter<
double>(
"Xmax");
320 (*
item->first).xAxisLabel = (*
item->second).getParameter<
string>(
"axisLabel");
322 (*
item->first).displayInPrimary = (*
item->second).getParameter<
bool>(
"mainWorkspace");
324 if ((*
item->second).exists(
"pathName_OR")) {
325 (*
item->first).pathNameOR = (*
item->second).getParameter<
string>(
"pathName_OR");
327 if ((*
item->second).exists(
"moduleName_OR")) {
328 (*
item->first).moduleNameOR = (*
item->second).getParameter<
string>(
"moduleName_OR");
331 plotList.push_back(
item->first);
336 triggerResultsToken_ = consumes<edm::TriggerResults>(
edm::InputTag(
"TriggerResults",
"", processName_));
337 aodTriggerToken_ = consumes<trigger::TriggerEvent>(
edm::InputTag(
"hltTriggerSummaryAOD",
"", processName_));
338 lumiScalersToken_ = consumes<LumiScalersCollection>(
edm::InputTag(
"hltScalersRawToDigi",
"",
""));
339 beamSpotToken_ = consumes<reco::BeamSpot>(
edm::InputTag(
"hltOnlineBeamSpot",
"", processName_));
340 chargedCandToken_ = consumes<vector<reco::RecoChargedCandidate>>(
341 edm::InputTag(
"hltL3NoFiltersNoVtxMuonCandidates",
"", processName_));
343 consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsCalo",
"", processName_));
345 consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsPF",
"", processName_));
347 consumes<vector<reco::CaloJet>>(
edm::InputTag(
"hltSelector8CentralJetsL1FastJet",
"", processName_));
348 csvPfJetsToken_ = consumes<vector<reco::PFJet>>(
edm::InputTag(
"hltPFJetForBtag",
"", processName_));
362 double start = get_wall_time();
367 std::cout <<
"Inside analyze(). " << std::endl;
376 iEvent.
getByToken(aodTriggerToken_, aodTriggerEvent);
377 if (!aodTriggerEvent.isValid())
381 unordered_map<string, bool> firedMap = acceptMap;
382 for (
auto plot : plotList)
384 if (firedMap[
plot->pathName])
386 bool triggerAccept =
false;
392 pathName =
plot->pathName;
393 triggerAccept =
true;
395 hltConfig_.saveTags(
plot->moduleNameOR)) {
396 if (firedMap[
plot->pathNameOR])
399 pathName =
plot->pathNameOR;
400 triggerAccept =
true;
404 unsigned int moduleFilterIndex = aodTriggerEvent->filterIndex(moduleFilter);
406 if (moduleFilterIndex + 1 > aodTriggerEvent->sizeFilters())
408 const Keys&
keys = aodTriggerEvent->filterKeys(moduleFilterIndex);
417 if (pathName == pfHtPt_.pathName) {
418 for (
const auto&
key : keys)
419 pfHtPt_.ME->Fill(objects[
key].
pt());
423 else if (pathName == jetPt_.pathName) {
424 for (
const auto&
key : keys)
425 jetPt_.ME->Fill(objects[
key].
pt());
429 else if (pathName == photonPt_.pathName) {
430 for (
const auto&
key : keys) {
431 photonPt_.ME->Fill(objects[
key].
pt());
432 photonEta_.ME->Fill(objects[
key].
eta());
433 photonPhi_.ME->Fill(objects[
key].phi());
438 else if (pathName == electronPt_.pathName) {
439 for (
const auto&
key : keys) {
440 electronPt_.ME->Fill(objects[
key].
pt());
441 electronEta_.ME->Fill(objects[
key].
eta());
442 electronPhi_.ME->Fill(objects[
key].phi());
447 else if (pathName == muonPt_.pathName) {
448 for (
const auto&
key : keys) {
449 muonPt_.ME->Fill(objects[
key].
pt());
450 muonEta_.ME->Fill(objects[
key].
eta());
451 muonPhi_.ME->Fill(objects[
key].phi());
456 else if (pathName == l2muonPt_.pathName) {
457 for (
const auto&
key : keys) {
458 l2muonPt_.ME->Fill(objects[
key].
pt());
459 l2muonEta_.ME->Fill(objects[
key].
eta());
460 l2muonPhi_.ME->Fill(objects[
key].phi());
465 else if (pathName == l2NoBPTXmuonPt_.pathName) {
466 for (
const auto&
key : keys) {
467 l2NoBPTXmuonPt_.ME->Fill(objects[
key].
pt());
468 l2NoBPTXmuonEta_.ME->Fill(objects[
key].
eta());
469 l2NoBPTXmuonPhi_.ME->Fill(objects[
key].phi());
474 else if (pathName == mr_.pathName) {
475 double onlineMR = 0, onlineRsq = 0;
476 for (
const auto&
key : keys) {
477 if (objects[
key].
id() == 0) {
478 onlineMR = objects[
key].px();
479 onlineRsq = objects[
key].py();
481 mr_.ME->Fill(onlineMR);
482 rsq_.ME->Fill(onlineRsq);
487 else if (pathName == alphaT_.pathName) {
488 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>> alphaT_jets;
489 for (
const auto&
key : keys) {
490 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(
492 alphaT_jets.push_back(JetLVec);
495 float alphaT = AlphaT(alphaT_jets,
false).value();
496 alphaT_.ME->Fill(alphaT);
500 else if (pathName == tauPt_.pathName) {
501 for (
const auto&
key : keys)
502 tauPt_.ME->Fill(objects[
key].
pt());
506 else if (pathName == caloMetPt_.pathName) {
507 for (
const auto&
key : keys) {
508 caloMetPt_.ME->Fill(objects[
key].
pt());
509 caloMetPhi_.ME->Fill(objects[
key].phi());
514 else if (pathName == caloHtPt_.pathName) {
515 for (
const auto&
key : keys) {
516 if (objects[
key].
id() == 89)
517 caloHtPt_.ME->Fill(objects[
key].
pt());
522 else if (pathName == jetAK8Pt_.pathName) {
523 for (
const auto&
key : keys) {
524 jetAK8Pt_.ME->Fill(objects[
key].
pt());
525 jetAK8Mass_.ME->Fill(objects[
key].
mass());
530 else if (pathName == pfMetPt_.pathName) {
531 for (
const auto&
key : keys) {
532 pfMetPt_.ME->Fill(objects[
key].
pt());
533 pfMetPhi_.ME->Fill(objects[
key].phi());
538 else if (pathName == bJetEta_.pathName || pathName == bJetEta_.pathNameOR) {
539 for (
const auto&
key : keys) {
540 bJetEta_.ME->Fill(objects[
key].
eta());
541 bJetPhi_.ME->Fill(objects[
key].phi());
546 if (pathName == bJetCSVPF_.pathName) {
548 iEvent.
getByToken(csvPfTagsToken_, csvPfTags);
550 iEvent.
getByToken(csvPfJetsToken_, csvPfJets);
553 for (
auto iter = csvPfTags->begin(); iter != csvPfTags->end(); iter++)
554 bJetCSVPF_.ME->Fill(iter->second);
557 if (pathName == bJetCSVCalo_.pathName) {
559 iEvent.
getByToken(csvCaloTagsToken_, csvCaloTags);
561 iEvent.
getByToken(csvCaloJetsToken_, csvCaloJets);
564 for (
auto iter = csvCaloTags->begin(); iter != csvCaloTags->end(); iter++)
565 bJetCSVCalo_.ME->Fill(iter->second);
570 else if (pathName == muonDxy_.pathName) {
572 iEvent.
getByToken(chargedCandToken_, recoChargedCands);
574 iEvent.
getByToken(beamSpotToken_, recoBeamSpot);
578 for (
const auto&
key : keys) {
579 muon_dxy = dxyFinder(objects[
key].
eta(), objects[
key].phi(), recoChargedCands, recoBeamSpot);
580 if (muon_dxy != -99.)
581 muonDxy_.ME->Fill(muon_dxy);
593 else if (pathName == diMuonLowMass_.pathName) {
595 unsigned int kCnt0 = 0;
596 for (
const auto& key0 : keys) {
597 unsigned int kCnt1 = 0;
598 for (
const auto& key1 : keys) {
602 if (
abs(objects[key0].
id()) == 13 &&
603 (objects[key0].
id() + objects[key1].
id() == 0))
605 TLorentzVector mu1, mu2, dimu;
606 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
607 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
609 diMuonLowMass_.ME->Fill(dimu.M());
618 else if (pathName == diMuonMass_.pathName || pathName == diMuonMass_.pathNameOR) {
620 unsigned int kCnt0 = 0;
621 for (
const auto& key0 : keys) {
622 unsigned int kCnt1 = 0;
623 for (
const auto& key1 : keys) {
627 if (
abs(objects[key0].
id()) == 13 &&
628 (objects[key0].
id() + objects[key1].
id() == 0))
630 TLorentzVector mu1, mu2, dimu;
631 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
632 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
634 diMuonMass_.ME->Fill(dimu.M());
643 else if (pathName == pAL1DoubleMuZMass_.pathName) {
645 unsigned int kCnt0 = 0;
646 for (
const auto& key0 : keys) {
647 unsigned int kCnt1 = 0;
648 for (
const auto& key1 : keys) {
654 TLorentzVector mu1, mu2, dimu;
655 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
656 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
658 if (dimu.M() > pAL1DoubleMuZMass_.xMin && dimu.M() < pAL1DoubleMuZMass_.xMax)
659 pAL1DoubleMuZMass_.ME->Fill(dimu.M());
668 else if (pathName == pAL2DoubleMuZMass_.pathName) {
670 unsigned int kCnt0 = 0;
671 for (
const auto& key0 : keys) {
672 unsigned int kCnt1 = 0;
673 for (
const auto& key1 : keys) {
677 if (
abs(objects[key0].
id()) == 13 &&
678 (objects[key0].
id() + objects[key1].
id() == 0))
680 TLorentzVector mu1, mu2, dimu;
681 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
682 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
684 if (dimu.M() > pAL2DoubleMuZMass_.xMin && dimu.M() < pAL2DoubleMuZMass_.xMax)
685 pAL2DoubleMuZMass_.ME->Fill(dimu.M());
694 else if (pathName == pAL3DoubleMuZMass_.pathName) {
696 unsigned int kCnt0 = 0;
697 for (
const auto& key0 : keys) {
698 unsigned int kCnt1 = 0;
699 for (
const auto& key1 : keys) {
703 if (
abs(objects[key0].
id()) == 13 &&
704 (objects[key0].
id() + objects[key1].
id() == 0))
706 TLorentzVector mu1, mu2, dimu;
707 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
708 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
710 if (dimu.M() > pAL3DoubleMuZMass_.xMin && dimu.M() < pAL3DoubleMuZMass_.xMax)
711 pAL3DoubleMuZMass_.ME->Fill(dimu.M());
720 else if (pathName == diElecMass_.pathName) {
721 unsigned int kCnt0 = 0;
722 for (
const auto& key0 : keys) {
723 unsigned int kCnt1 = 0;
724 for (
const auto& key1 : keys) {
730 TLorentzVector el1, el2, diEl;
731 el1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), 0);
732 el2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), 0);
734 diElecMass_.ME->Fill(diEl.M());
748 double end = get_wall_time();
756 std::cout <<
"Calling beginRun. " << std::endl;
758 if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
760 std::cout <<
"Extracting HLTconfig. " << std::endl;
764 string pathName_noVersion;
765 vector<string>
triggerPaths = hltConfig_.triggerNames();
767 for (
const auto&
pathName : triggerPaths) {
768 pathName_noVersion = hltConfig_.removeVersion(
pathName);
769 for (
auto plot : plotList) {
770 if (
plot->pathName == pathName_noVersion) {
771 (*plot).pathIndex = hltConfig_.triggerIndex(
pathName);
772 }
else if (
plot->pathNameOR == pathName_noVersion) {
773 (*plot).pathIndexOR = hltConfig_.triggerIndex(
pathName);
777 vector<hltPlot*> plotList_temp;
778 for (
auto plot : plotList) {
779 if (
plot->pathIndex > 0 ||
plot->pathIndexOR > 0) {
780 plotList_temp.push_back(
plot);
781 acceptMap[
plot->pathName] =
false;
782 if (
plot->pathIndexOR > 0)
783 acceptMap[
plot->pathNameOR] =
false;
787 plotList = plotList_temp;
788 plotList_temp.clear();
803 ibooker.
book1D(wallTime_.plotLabel, wallTime_.pathName, wallTime_.nBins, wallTime_.xMin, wallTime_.xMax);
806 for (
auto plot : plotList) {
808 if (!
plot->pathNameOR.empty())
809 display_pathNames =
plot->pathName +
" OR " +
plot->pathNameOR;
811 if (
plot->displayInPrimary) {
813 (*plot).ME = ibooker.
book1D(
plot->plotLabel, display_pathNames.c_str(),
plot->nBins,
plot->xMin,
plot->xMax);
818 (*plot).ME = ibooker.
book1D(
plot->plotLabel, display_pathNames.c_str(),
plot->nBins,
plot->xMin,
plot->xMax);
829 for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin();
830 l3Muon != recoChargedCands->end();
832 if (
deltaR(eta, phi, l3Muon->eta(), l3Muon->phi()) < 0.1) {
833 dxy = (-(l3Muon->vx() - recoBeamSpot->x0()) * l3Muon->py() + (l3Muon->vy() - recoBeamSpot->y0()) * l3Muon->px()) /
843 if (gettimeofday(&time,
nullptr))
845 return (
double)time.tv_sec + (double)time.tv_usec * .000001;
edm::ParameterSet caloMetPt_pset
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
edm::ParameterSet pfMetPhi_pset
edm::ParameterSet muonPhi_pset
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::ParameterSet l2muonEta_pset
virtual void setCurrentFolder(std::string const &fullpath)
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
edm::ParameterSet muonDxy_pset
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
~HLTObjectMonitor() override
edm::ParameterSet l2NoBPTXmuonEta_pset
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_
example_stream void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
HLTObjectMonitor(const edm::ParameterSet &)
hltPlot pAL2DoubleMuZMass_
edm::ParameterSet wallTime_pset
edm::ParameterSet diElecMass_pset
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
if(conf_.getParameter< bool >("UseStripCablingDB"))
tuple key
prepare the HTCondor submission files and eventually submit them
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
T getParameter(std::string const &) const
edm::ParameterSet pAL3DoubleMuZMass_pset
edm::ParameterSet l2NoBPTXmuonPhi_pset
double get_wall_time(void)
edm::EDGetTokenT< vector< reco::CaloJet > > csvCaloJetsToken_
edm::ParameterSet caloMetPhi_pset
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
vector< hltPlot * > plotList
static constexpr float mu_mass
static std::string const triggerPaths
edm::ParameterSet l2NoBPTXmuonPt_pset
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
unordered_map< string, bool > acceptMap
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)