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;
228 topDirectoryName =
"HLT/ObjectMonitor";
229 mainShifterFolder = topDirectoryName+
"/MainShifter";
230 backupFolder = topDirectoryName+
"/Backup";
233 processName_ = iConfig.
getParameter<
string>(
"processName");
236 plotMap[&rsq_] = &rsq_pset;
238 plotMap[&mr_] = &mr_pset;
240 plotMap[&alphaT_] = &alphaT_pset;
242 plotMap[&photonPt_] = &photonPt_pset;
244 plotMap[&photonEta_] = &photonEta_pset;
246 plotMap[&photonPhi_] = &photonPhi_pset;
248 plotMap[&muonPt_] = &muonPt_pset;
250 plotMap[&muonEta_] = &muonEta_pset;
252 plotMap[&muonPhi_] = &muonPhi_pset;
254 plotMap[&l2muonPt_] = &l2muonPt_pset;
256 plotMap[&l2muonEta_] = &l2muonEta_pset;
258 plotMap[&l2muonPhi_] = &l2muonPhi_pset;
260 plotMap[&l2NoBPTXmuonPt_] = &l2NoBPTXmuonPt_pset;
262 plotMap[&l2NoBPTXmuonEta_] = &l2NoBPTXmuonEta_pset;
264 plotMap[&l2NoBPTXmuonPhi_] = &l2NoBPTXmuonPhi_pset;
266 plotMap[&electronPt_] = &electronPt_pset;
268 plotMap[&electronEta_] = &electronEta_pset;
270 plotMap[&electronPhi_] = &electronPhi_pset;
272 plotMap[&jetPt_] = &jetPt_pset;
274 plotMap[&jetAK8Mass_] = &jetAK8Mass_pset;
276 plotMap[&diMuonLowMass_] = &diMuonLowMass_pset;
278 plotMap[&caloMetPt_] = &caloMetPt_pset;
280 plotMap[&caloMetPhi_] = &caloMetPhi_pset;
282 plotMap[&pfMetPt_] = &pfMetPt_pset;
284 plotMap[&pfMetPhi_] = &pfMetPhi_pset;
286 plotMap[&caloHtPt_] = &caloHtPt_pset;
288 plotMap[&pfHtPt_] = &pfHtPt_pset;
290 plotMap[&bJetPhi_] = &bJetPhi_pset;
292 plotMap[&bJetEta_] = &bJetEta_pset;
294 plotMap[&bJetCSVCalo_] = &bJetCSVCalo_pset;
296 plotMap[&bJetCSVPF_] = &bJetCSVPF_pset;
298 plotMap[&diMuonMass_] = &diMuonMass_pset;
300 plotMap[&diElecMass_] = &diElecMass_pset;
302 plotMap[&muonDxy_] = &muonDxy_pset;
304 plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
306 plotMap[&tauPt_] = &tauPt_pset;
308 plotMap[&wallTime_] = &wallTime_pset;
311 for (
auto item = plotMap.begin(); item != plotMap.end(); item++)
313 (*item->first).
pathName = (*item->second).getParameter<
string>(
"pathName");
314 (*item->first).
moduleName = (*item->second).getParameter<
string>(
"moduleName");
315 (*item->first).nBins = (*item->second).getParameter<
int>(
"NbinsX");
316 (*item->first).xMin = (*item->second).getParameter<
double>(
"Xmin");
317 (*item->first).xMax = (*item->second).getParameter<
double>(
"Xmax");
318 (*item->first).xAxisLabel = (*item->second).getParameter<
string>(
"axisLabel");
319 (*item->first).plotLabel = (*item->second).getParameter<
string>(
"plotLabel");
320 (*item->first).displayInPrimary = (*item->second).getParameter<
bool>(
"mainWorkspace");
322 if ((*item->second).exists(
"pathName_OR"))
324 (*item->first).pathNameOR = (*item->second).getParameter<
string>(
"pathName_OR");
326 if ((*item->second).exists(
"moduleName_OR"))
328 (*item->first).moduleNameOR = (*item->second).getParameter<
string>(
"moduleName_OR");
331 plotList.push_back(item->first);
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>>(
edm::InputTag(
"hltL3NoFiltersNoVtxMuonCandidates",
"",processName_));
341 csvCaloTagsToken_ = consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsCalo",
"",processName_));
342 csvPfTagsToken_ = consumes<reco::JetTagCollection>(
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsPF",
"",processName_));
343 csvCaloJetsToken_ = consumes<vector<reco::CaloJet>>(
edm::InputTag(
"hltSelector8CentralJetsL1FastJet",
"",processName_));
344 csvPfJetsToken_ = consumes<vector<reco::PFJet>>(
edm::InputTag(
"hltPFJetForBtag",
"",processName_));
366 double start = get_wall_time();
370 if (debugPrint)
std::cout <<
"Inside analyze(). " << std::endl;
378 iEvent.
getByToken(aodTriggerToken_, aodTriggerEvent);
379 if (!aodTriggerEvent.isValid())
return;
382 unordered_map<string, bool> firedMap = acceptMap;
383 for (
auto plot: plotList)
385 if (firedMap[
plot->pathName])
continue;
386 bool triggerAccept =
false;
393 pathName =
plot->pathName;
394 triggerAccept =
true;
398 if (firedMap[
plot->pathNameOR])
continue;
400 pathName =
plot->pathNameOR;
401 triggerAccept =
true;
406 unsigned int moduleFilterIndex = aodTriggerEvent->filterIndex(moduleFilter);
408 if (moduleFilterIndex+1 > aodTriggerEvent->sizeFilters())
return;
409 const Keys &
keys = aodTriggerEvent->filterKeys( moduleFilterIndex );
418 if (pathName == pfHtPt_.pathName)
420 for (
const auto &
key : keys) pfHtPt_.ME->Fill(objects[
key].
pt());
424 else if (pathName == jetPt_.pathName)
426 for (
const auto &
key : keys) jetPt_.ME->Fill(objects[
key].
pt());
430 else if (pathName == photonPt_.pathName)
432 for (
const auto &
key : keys)
434 photonPt_.ME->Fill(objects[
key].
pt());
435 photonEta_.ME->Fill(objects[
key].
eta());
436 photonPhi_.ME->Fill(objects[
key].
phi());
441 else if (pathName == electronPt_.pathName)
443 for (
const auto &
key : keys)
445 electronPt_.ME->Fill(objects[
key].
pt());
446 electronEta_.ME->Fill(objects[
key].
eta());
447 electronPhi_.ME->Fill(objects[
key].
phi());
452 else if (pathName == muonPt_.pathName)
454 for (
const auto &
key : keys)
456 muonPt_.ME->Fill(objects[
key].
pt());
457 muonEta_.ME->Fill(objects[
key].
eta());
458 muonPhi_.ME->Fill(objects[
key].
phi());
463 else if (pathName == l2muonPt_.pathName)
465 for (
const auto &
key : keys)
467 l2muonPt_.ME->Fill(objects[
key].
pt());
468 l2muonEta_.ME->Fill(objects[
key].
eta());
469 l2muonPhi_.ME->Fill(objects[
key].
phi());
474 else if (pathName == l2NoBPTXmuonPt_.pathName)
476 for (
const auto &
key : keys)
478 l2NoBPTXmuonPt_.ME->Fill(objects[
key].
pt());
479 l2NoBPTXmuonEta_.ME->Fill(objects[
key].
eta());
480 l2NoBPTXmuonPhi_.ME->Fill(objects[
key].
phi());
485 else if (pathName == mr_.pathName)
487 double onlineMR = 0, onlineRsq = 0;
488 for (
const auto &
key : keys)
490 if(objects[
key].
id() == 0){
491 onlineMR = objects[
key].px();
492 onlineRsq = objects[
key].py();
494 mr_.ME->Fill(onlineMR);
495 rsq_.ME->Fill(onlineRsq);
500 else if (pathName == alphaT_.pathName)
502 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>> alphaT_jets;
503 for (
const auto &
key : keys)
505 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(objects[
key].
pt(),objects[
key].
eta(),objects[
key].
phi(),objects[
key].mass());
506 alphaT_jets.push_back(JetLVec);
509 float alphaT = AlphaT(alphaT_jets,
false).value();
510 alphaT_.ME->Fill(alphaT);
514 else if (pathName == tauPt_.pathName)
516 for (
const auto &
key : keys) tauPt_.ME->Fill(objects[
key].
pt());
520 else if (pathName == caloMetPt_.pathName)
522 for (
const auto &
key : keys)
524 caloMetPt_.ME->Fill(objects[
key].
pt());
525 caloMetPhi_.ME->Fill(objects[
key].
phi());
530 else if (pathName == caloHtPt_.pathName)
532 for (
const auto &
key : keys)
534 if(objects[
key].
id()==89) caloHtPt_.ME->Fill(objects[
key].
pt());
539 else if (pathName == jetAK8Pt_.pathName)
541 for (
const auto &
key : keys)
543 jetAK8Pt_.ME->Fill(objects[
key].
pt());
544 jetAK8Mass_.ME->Fill(objects[
key].mass());
549 else if (pathName == pfMetPt_.pathName)
551 for (
const auto &
key : keys)
553 pfMetPt_.ME->Fill(objects[
key].
pt());
554 pfMetPhi_.ME->Fill(objects[
key].
phi());
559 else if (pathName == bJetEta_.pathName || pathName == bJetEta_.pathNameOR)
561 for (
const auto &
key : keys)
563 bJetEta_.ME->Fill(objects[
key].
eta());
564 bJetPhi_.ME->Fill(objects[
key].
phi());
569 if (pathName == bJetCSVPF_.pathName)
572 iEvent.
getByToken(csvPfTagsToken_, csvPfTags);
574 iEvent.
getByToken(csvPfJetsToken_, csvPfJets);
578 for (
auto iter = csvPfTags->begin(); iter != csvPfTags->end(); iter++) bJetCSVPF_.ME->Fill(iter->second);
581 if (pathName == bJetCSVCalo_.pathName)
584 iEvent.
getByToken(csvCaloTagsToken_, csvCaloTags);
586 iEvent.
getByToken(csvCaloJetsToken_, csvCaloJets);
590 for (
auto iter = csvCaloTags->begin(); iter != csvCaloTags->end(); iter++) bJetCSVCalo_.ME->Fill(iter->second);
595 else if (pathName == muonDxy_.pathName)
598 iEvent.
getByToken(chargedCandToken_, recoChargedCands);
600 iEvent.
getByToken(beamSpotToken_, recoBeamSpot);
605 for (
const auto &
key : keys)
607 muon_dxy = dxyFinder(objects[
key].
eta(), objects[
key].
phi(), recoChargedCands, recoBeamSpot);
608 if (muon_dxy != -99.) muonDxy_.ME->Fill(muon_dxy);
620 else if (pathName == diMuonLowMass_.pathName)
622 const double mu_mass(.105658);
623 unsigned int kCnt0 = 0;
624 for (
const auto & key0: keys)
626 unsigned int kCnt1 = 0;
627 for (
const auto & key1: keys)
629 if (key0 != key1 && kCnt1 > kCnt0)
631 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0))
633 TLorentzVector mu1, mu2, dimu;
634 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
635 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
637 diMuonLowMass_.ME->Fill(dimu.M());
646 else if (pathName == diMuonMass_.pathName || pathName == diMuonMass_.pathNameOR)
648 const double mu_mass(.105658);
649 unsigned int kCnt0 = 0;
650 for (
const auto & key0: keys)
652 unsigned int kCnt1 = 0;
653 for (
const auto & key1: keys)
655 if (key0 != key1 && kCnt1 > kCnt0)
657 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0))
659 TLorentzVector mu1, mu2, dimu;
660 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), mu_mass);
661 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), mu_mass);
663 diMuonMass_.ME->Fill(dimu.M());
672 else if (pathName == diElecMass_.pathName)
674 unsigned int kCnt0 = 0;
675 for (
const auto & key0: keys)
677 unsigned int kCnt1 = 0;
678 for (
const auto & key1: keys)
680 if (key0 != key1 && kCnt1 > kCnt0)
684 TLorentzVector el1, el2, diEl;
685 el1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].
phi(), 0);
686 el2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].
phi(), 0);
688 diElecMass_.ME->Fill(diEl.M());
702 double end = get_wall_time();
704 wallTime_.ME->Fill(wallTime);
711 if (debugPrint)
std::cout <<
"Calling beginRun. " << std::endl;
713 if (hltConfig_.init(iRun, iSetup, processName_, changed))
715 if (debugPrint)
std::cout <<
"Extracting HLTconfig. " << std::endl;
719 string pathName_noVersion;
720 vector<string>
triggerPaths = hltConfig_.triggerNames();
722 for (
const auto &
pathName : triggerPaths)
724 pathName_noVersion = hltConfig_.removeVersion(
pathName);
725 for (
auto plot : plotList)
727 if (
plot->pathName == pathName_noVersion)
729 (*plot).pathIndex = hltConfig_.triggerIndex(
pathName);
731 else if (
plot->pathNameOR == pathName_noVersion)
733 (*plot).pathIndexOR = hltConfig_.triggerIndex(
pathName);
737 vector<hltPlot*> plotList_temp;
738 for (
auto plot : plotList)
740 if (
plot->pathIndex > 0 ||
plot->pathIndexOR > 0)
742 plotList_temp.push_back(
plot);
743 acceptMap[
plot->pathName] =
false;
744 if (
plot->pathIndexOR > 0) acceptMap[
plot->pathNameOR] =
false;
748 plotList = plotList_temp;
749 plotList_temp.clear();
758 if (debugPrint)
std::cout <<
"Calling endRun. " << std::endl;
772 wallTime_.ME = ibooker.
book1D(wallTime_.plotLabel,wallTime_.pathName,wallTime_.nBins,wallTime_.xMin,wallTime_.xMax);
775 for (
auto plot : plotList)
778 if (!
plot->pathNameOR.empty()) display_pathNames =
plot->pathName +
" OR " +
plot->pathNameOR;
780 if (
plot->displayInPrimary)
800 for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin(); l3Muon != recoChargedCands->end(); l3Muon++)
802 if (
deltaR(eta,phi,l3Muon->eta(),l3Muon->phi()) < 0.1)
804 dxy = (-(l3Muon->vx()-recoBeamSpot->x0()) * l3Muon->py() + (l3Muon->vy()-recoBeamSpot->y0()) * l3Muon->px())/l3Muon->pt();
814 if (gettimeofday(&time,
NULL))
return 0;
815 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 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 l2muonPt_pset
edm::EDGetTokenT< vector< reco::PFJet > > csvPfJetsToken_
triggerResultsToken_(consumes< edm::TriggerResults >(edm::InputTag("TriggerResults")))
HLTObjectMonitor(const edm::ParameterSet &)
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
edm::ParameterSet pfHtPt_pset
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
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
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