58 #include "TLorentzVector.h" 60 #include <unordered_map> 69 using std::unordered_map;
81 int pathIndexOR = -99;
106 double get_wall_time(
void);
115 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[&caloAK4JetPt_] = &caloAK4JetPt_pset;
236 plotMap[&caloAK4JetEta_] = &caloAK4JetEta_pset;
238 plotMap[&caloAK4JetPhi_] = &caloAK4JetPhi_pset;
240 plotMap[&pfAK4JetPt_] = &pfAK4JetPt_pset;
242 plotMap[&pfAK4JetEta_] = &pfAK4JetEta_pset;
244 plotMap[&pfAK4JetPhi_] = &pfAK4JetPhi_pset;
246 plotMap[&caloDiAK4JetPt_] = &caloDiAK4JetPt_pset;
248 plotMap[&caloDiAK4JetEta_] = &caloDiAK4JetEta_pset;
250 plotMap[&caloDiAK4JetPhi_] = &caloDiAK4JetPhi_pset;
252 plotMap[&pfDiAK4JetPt_] = &pfDiAK4JetPt_pset;
254 plotMap[&pfDiAK4JetEta_] = &pfDiAK4JetEta_pset;
256 plotMap[&pfDiAK4JetPhi_] = &pfDiAK4JetPhi_pset;
258 plotMap[&photonPt_] = &photonPt_pset;
260 plotMap[&photonEta_] = &photonEta_pset;
262 plotMap[&photonPhi_] = &photonPhi_pset;
264 plotMap[&photonPPPt_] = &photonPPPt_pset;
266 plotMap[&photonPPEta_] = &photonPPEta_pset;
268 plotMap[&photonPPPhi_] = &photonPPPhi_pset;
270 plotMap[&caloBJetPt_] = &caloBJetPt_pset;
272 plotMap[&caloBJetEta_] = &caloBJetEta_pset;
274 plotMap[&caloBJetPhi_] = &caloBJetPhi_pset;
276 plotMap[&pfBJetPt_] = &pfBJetPt_pset;
278 plotMap[&pfBJetEta_] = &pfBJetEta_pset;
280 plotMap[&pfBJetPhi_] = &pfBJetPhi_pset;
282 plotMap[&electronPt_] = &electronPt_pset;
284 plotMap[&electronEta_] = &electronEta_pset;
286 plotMap[&electronPhi_] = &electronPhi_pset;
288 plotMap[&l3muon3Pt_] = &l3muon3Pt_pset;
290 plotMap[&l3muon3Eta_] = &l3muon3Eta_pset;
292 plotMap[&l3muon3Phi_] = &l3muon3Phi_pset;
294 plotMap[&l2muon12Pt_] = &l2muon12Pt_pset;
296 plotMap[&l2muon12Eta_] = &l2muon12Eta_pset;
298 plotMap[&l2muon12Phi_] = &l2muon12Phi_pset;
300 plotMap[&l3muon12Pt_] = &l3muon12Pt_pset;
302 plotMap[&l3muon12Eta_] = &l3muon12Eta_pset;
304 plotMap[&l3muon12Phi_] = &l3muon12Phi_pset;
306 plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
308 plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
310 plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
312 plotMap[&wallTime_] = &wallTime_pset;
315 for (
auto item = plotMap.begin(); item != plotMap.end(); item++)
317 (*item->first).pathName = (*item->second).
getParameter<
string>(
"pathName");
318 (*item->first).
moduleName = (*item->second).getParameter<
string>(
"moduleName");
319 (*item->first).nBins = (*item->second).getParameter<
int>(
"NbinsX");
320 (*item->first).
xMin = (*item->second).getParameter<
double>(
"Xmin");
321 (*item->first).
xMax = (*item->second).getParameter<
double>(
"Xmax");
322 (*item->first).xAxisLabel = (*item->second).getParameter<
string>(
"axisLabel");
323 (*item->first).plotLabel = (*item->second).getParameter<
string>(
"plotLabel");
324 (*item->first).displayInPrimary = (*item->second).getParameter<
bool>(
"mainWorkspace");
326 if ((*item->second).exists(
"pathName_OR"))
328 (*item->first).pathNameOR = (*item->second).getParameter<
string>(
"pathName_OR");
330 if ((*item->second).exists(
"moduleName_OR"))
332 (*item->first).moduleNameOR = (*item->second).getParameter<
string>(
"moduleName_OR");
335 plotList.push_back(item->first);
363 double start = get_wall_time();
367 if (debugPrint)
std::cout <<
"Inside analyze(). " << std::endl;
371 iEvent.
getByToken(triggerResultsToken_, triggerResults);
372 if (!triggerResults.
isValid())
return;
375 iEvent.
getByToken(aodTriggerToken_, aodTriggerEvent);
376 if (!aodTriggerEvent.
isValid())
return;
379 unordered_map<string, bool> firedMap = acceptMap;
380 for (
auto plot: plotList)
382 if (firedMap[
plot->pathName])
continue;
383 bool triggerAccept =
false;
387 if(
plot->pathIndex > 0 && triggerResults->
accept(
plot->pathIndex) && hltConfig_.saveTags(
plot->moduleName))
390 pathName =
plot->pathName;
391 triggerAccept =
true;
393 else if(
plot->pathIndexOR > 0 && triggerResults->
accept(
plot->pathIndexOR) && hltConfig_.saveTags(
plot->moduleNameOR))
395 if (firedMap[
plot->pathNameOR])
continue;
397 pathName =
plot->pathNameOR;
398 triggerAccept =
true;
403 unsigned int moduleFilterIndex = aodTriggerEvent->
filterIndex(moduleFilter);
405 if (moduleFilterIndex+1 > aodTriggerEvent->
sizeFilters())
return;
415 if (pathName == caloAK4JetPt_.pathName){
416 for (
const auto &
key : keys){
417 caloAK4JetPt_.ME->Fill(objects[
key].
pt());
418 caloAK4JetEta_.ME->Fill(objects[
key].
eta());
419 caloAK4JetPhi_.ME->Fill(objects[
key].phi());
423 else if (pathName == pfAK4JetPt_.pathName){
424 for (
const auto &
key : keys){
425 pfAK4JetPt_.ME->Fill(objects[
key].
pt());
426 pfAK4JetEta_.ME->Fill(objects[
key].
eta());
427 pfAK4JetPhi_.ME->Fill(objects[
key].phi());
431 else if (pathName == caloDiAK4JetPt_.pathName){
432 for (
const auto &
key : keys){
433 caloDiAK4JetPt_.ME->Fill(objects[
key].
pt());
434 caloDiAK4JetEta_.ME->Fill(objects[
key].
eta());
435 caloDiAK4JetPhi_.ME->Fill(objects[
key].phi());
439 else if (pathName == pfDiAK4JetPt_.pathName){
440 for (
const auto &
key : keys){
441 pfDiAK4JetPt_.ME->Fill(objects[
key].
pt());
442 pfDiAK4JetEta_.ME->Fill(objects[
key].
eta());
443 pfDiAK4JetPhi_.ME->Fill(objects[
key].phi());
447 else if (pathName == photonPt_.pathName){
448 for (
const auto &
key : keys){
449 photonPt_.ME->Fill(objects[
key].
pt());
450 photonEta_.ME->Fill(objects[
key].
eta());
451 photonPhi_.ME->Fill(objects[
key].phi());
455 else if (pathName == photonPPPt_.pathName){
456 for (
const auto &
key : keys){
457 photonPPPt_.ME->Fill(objects[
key].
pt());
458 photonPPEta_.ME->Fill(objects[
key].
eta());
459 photonPPPhi_.ME->Fill(objects[
key].phi());
463 else if (pathName == caloBJetPt_.pathName){
464 for (
const auto &
key : keys){
465 caloBJetPt_.ME->Fill(objects[
key].
pt());
466 caloBJetEta_.ME->Fill(objects[
key].
eta());
467 caloBJetPhi_.ME->Fill(objects[
key].phi());
471 else if (pathName == pfBJetPt_.pathName){
472 for (
const auto &
key : keys){
473 pfBJetPt_.ME->Fill(objects[
key].
pt());
474 pfBJetEta_.ME->Fill(objects[
key].
eta());
475 pfBJetPhi_.ME->Fill(objects[
key].phi());
479 else if (pathName == electronPt_.pathName){
480 for (
const auto &
key : keys){
481 electronPt_.ME->Fill(objects[
key].
pt());
482 electronEta_.ME->Fill(objects[
key].
eta());
483 electronPhi_.ME->Fill(objects[
key].phi());
486 else if (pathName == l3muon3Pt_.pathName){
487 for (
const auto &
key : keys){
488 l3muon3Pt_.ME->Fill(objects[
key].
pt());
489 l3muon3Eta_.ME->Fill(objects[
key].
eta());
490 l3muon3Phi_.ME->Fill(objects[
key].phi());
493 else if (pathName == l2muon12Pt_.pathName){
494 for (
const auto &
key : keys){
495 l2muon12Pt_.ME->Fill(objects[
key].
pt());
496 l2muon12Eta_.ME->Fill(objects[
key].
eta());
497 l2muon12Phi_.ME->Fill(objects[
key].phi());
500 else if (pathName == l3muon12Pt_.pathName){
501 for (
const auto &
key : keys){
502 l3muon12Pt_.ME->Fill(objects[
key].
pt());
503 l3muon12Eta_.ME->Fill(objects[
key].
eta());
504 l3muon12Phi_.ME->Fill(objects[
key].phi());
514 else if (pathName == pAL1DoubleMuZMass_.pathName){
515 const double mu_mass(.105658);
516 unsigned int kCnt0 = 0;
517 for (
const auto & key0: keys){
518 unsigned int kCnt1 = 0;
519 for (
const auto & key1: keys){
520 if (key0 != key1 && kCnt1 > kCnt0){
522 TLorentzVector mu1, mu2, dimu;
523 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
524 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
526 if(dimu.M()>pAL1DoubleMuZMass_.xMin && dimu.M()<pAL1DoubleMuZMass_.xMax) pAL1DoubleMuZMass_.ME->Fill(dimu.M());
533 else if (pathName == pAL2DoubleMuZMass_.pathName){
534 const double mu_mass(.105658);
535 unsigned int kCnt0 = 0;
536 for (
const auto & key0: keys){
537 unsigned int kCnt1 = 0;
538 for (
const auto & key1: keys){
539 if (key0 != key1 && kCnt1 > kCnt0){
540 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0)){
541 TLorentzVector mu1, mu2, dimu;
542 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
543 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
545 if(dimu.M()>pAL2DoubleMuZMass_.xMin && dimu.M()<pAL2DoubleMuZMass_.xMax) pAL2DoubleMuZMass_.ME->Fill(dimu.M());
553 else if (pathName == pAL3DoubleMuZMass_.pathName){
554 const double mu_mass(.105658);
555 unsigned int kCnt0 = 0;
556 for (
const auto & key0: keys){
557 unsigned int kCnt1 = 0;
558 for (
const auto & key1: keys){
559 if (key0 != key1 && kCnt1 > kCnt0){
560 if (
abs(objects[key0].
id()) == 13 && (objects[key0].
id()+objects[key1].
id()==0)){
561 TLorentzVector mu1, mu2, dimu;
562 mu1.SetPtEtaPhiM(objects[key0].
pt(), objects[key0].
eta(), objects[key0].phi(), mu_mass);
563 mu2.SetPtEtaPhiM(objects[key1].
pt(), objects[key1].
eta(), objects[key1].phi(), mu_mass);
565 if(dimu.M()>pAL3DoubleMuZMass_.xMin && dimu.M()<pAL3DoubleMuZMass_.xMax) pAL3DoubleMuZMass_.ME->Fill(dimu.M());
574 firedMap[pathName] =
true;
579 double end = get_wall_time();
580 double wallTime = end -
start;
581 wallTime_.ME->Fill(wallTime);
588 if (debugPrint)
std::cout <<
"Calling beginRun. " << std::endl;
590 if (hltConfig_.init(iRun, iSetup, processName_, changed))
592 if (debugPrint)
std::cout <<
"Extracting HLTconfig. " << std::endl;
596 string pathName_noVersion;
597 vector<string>
triggerPaths = hltConfig_.triggerNames();
599 for (
const auto & pathName : triggerPaths)
601 pathName_noVersion = hltConfig_.removeVersion(pathName);
602 for (
auto plot : plotList)
604 if (
plot->pathName == pathName_noVersion)
606 (*plot).pathIndex = hltConfig_.triggerIndex(pathName);
608 else if (
plot->pathNameOR == pathName_noVersion)
610 (*plot).pathIndexOR = hltConfig_.triggerIndex(pathName);
614 vector<hltPlot*> plotList_temp;
615 for (
auto plot : plotList)
617 if (
plot->pathIndex > 0 ||
plot->pathIndexOR > 0)
619 plotList_temp.push_back(
plot);
620 acceptMap[
plot->pathName] =
false;
621 if (
plot->pathIndexOR > 0) acceptMap[
plot->pathNameOR] =
false;
625 plotList = plotList_temp;
626 plotList_temp.clear();
635 if (debugPrint)
std::cout <<
"Calling endRun. " << std::endl;
649 wallTime_.ME = ibooker.
book1D(wallTime_.plotLabel,wallTime_.pathName,wallTime_.nBins,wallTime_.xMin,wallTime_.xMax);
652 for (
auto plot : plotList)
655 if (!
plot->pathNameOR.empty()) display_pathNames =
plot->pathName +
" OR " +
plot->pathNameOR;
657 if (
plot->displayInPrimary)
677 if (gettimeofday(&time,
nullptr))
return 0;
678 return (
double)time.tv_sec + (double)time.tv_usec * .000001;
~HLTObjectMonitorProtonLead() override
edm::ParameterSet caloAK4JetEta_pset
edm::EDGetTokenT< trigger::TriggerEvent > aodTriggerToken_
T getParameter(std::string const &) const
edm::ParameterSet caloBJetEta_pset
trigger::size_type sizeFilters() const
edm::ParameterSet l3muon3Eta_pset
void endRun(edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet pfAK4JetPhi_pset
bool getByToken(EDGetToken token, Handle< PROD > &result) const
def analyze(function, filename, filter=None)
#define DEFINE_FWK_MODULE(type)
hltPlot pAL1DoubleMuZMass_
edm::ParameterSet caloDiAK4JetPt_pset
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
edm::ParameterSet l3muon3Pt_pset
unordered_map< string, bool > acceptMap
edm::ParameterSet pfAK4JetPt_pset
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
void bookHistograms(fwlite::EventContainer &eventCont)
edm::ParameterSet l2muon12Eta_pset
edm::ParameterSet electronEta_pset
edm::ParameterSet wallTime_pset
edm::ParameterSet l3muon12Phi_pset
edm::ParameterSet photonPt_pset
std::string moduleName(Provenance const &provenance)
edm::ParameterSet pfDiAK4JetPt_pset
edm::ParameterSet caloBJetPt_pset
hltPlot pAL2DoubleMuZMass_
const TriggerObjectCollection & getObjects() const
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet electronPhi_pset
edm::ParameterSet l3muon12Pt_pset
MonitorElement * book1D(Args &&...args)
Abs< T >::type abs(const T &t)
edm::ParameterSet pfBJetPhi_pset
static std::string const triggerResults
unordered_map< hltPlot *, edm::ParameterSet * > plotMap
edm::ParameterSet photonPhi_pset
edm::ParameterSet pfDiAK4JetPhi_pset
edm::ParameterSet pAL1DoubleMuZMass_pset
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
edm::ParameterSet photonPPEta_pset
edm::ParameterSet pfDiAK4JetEta_pset
edm::ParameterSet photonPPPhi_pset
HLTConfigProvider hltConfig_
edm::ParameterSet pAL2DoubleMuZMass_pset
void setCurrentFolder(const std::string &fullpath)
edm::ParameterSet caloBJetPhi_pset
std::vector< size_type > Keys
HLTObjectMonitorProtonLead(const edm::ParameterSet &)
edm::ParameterSet pAL3DoubleMuZMass_pset
edm::ParameterSet l2muon12Phi_pset
edm::ParameterSet photonPPPt_pset
edm::ParameterSet electronPt_pset
hltPlot pAL3DoubleMuZMass_
edm::ParameterSet caloDiAK4JetPhi_pset
edm::ParameterSet pfAK4JetEta_pset
edm::ParameterSet pfBJetEta_pset
double get_wall_time(void)
vector< hltPlot * > plotList
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet photonEta_pset
edm::ParameterSet caloAK4JetPt_pset
edm::ParameterSet l3muon3Phi_pset
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 caloAK4JetPhi_pset
edm::ParameterSet caloDiAK4JetEta_pset
edm::ParameterSet pfBJetPt_pset
edm::ParameterSet l3muon12Eta_pset
edm::ParameterSet l2muon12Pt_pset
void analyze(const edm::Event &, const edm::EventSetup &) override