57 #include "TLorentzVector.h"
59 #include <unordered_map>
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])
395 hltConfig_.saveTags(
plot->moduleNameOR)) {
396 if (firedMap[
plot->pathNameOR])
404 unsigned int moduleFilterIndex = aodTriggerEvent->
filterIndex(moduleFilter);
406 if (moduleFilterIndex + 1 > aodTriggerEvent->
sizeFilters())
423 else if (
pathName == jetPt_.pathName) {
429 else if (
pathName == photonPt_.pathName) {
438 else if (
pathName == electronPt_.pathName) {
447 else if (
pathName == muonPt_.pathName) {
456 else if (
pathName == l2muonPt_.pathName) {
465 else if (
pathName == l2NoBPTXmuonPt_.pathName) {
469 l2NoBPTXmuonPhi_.ME->Fill(
objects[
key].phi());
474 else if (
pathName == mr_.pathName) {
475 double onlineMR = 0, onlineRsq = 0;
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;
490 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(
492 alphaT_jets.push_back(JetLVec);
495 float alphaT = AlphaT(alphaT_jets,
false).value();
500 else if (
pathName == tauPt_.pathName) {
506 else if (
pathName == caloMetPt_.pathName) {
514 else if (
pathName == caloHtPt_.pathName) {
522 else if (
pathName == jetAK8Pt_.pathName) {
530 else if (
pathName == pfMetPt_.pathName) {
538 else if (
pathName == bJetEta_.pathName ||
pathName == bJetEta_.pathNameOR) {
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);
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) {
605 TLorentzVector mu1, mu2, dimu;
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) {
630 TLorentzVector mu1, mu2, dimu;
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;
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) {
680 TLorentzVector mu1, mu2, dimu;
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) {
706 TLorentzVector mu1, mu2, dimu;
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;
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();
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;