CMS 3D CMS Logo

HLTMuonValidator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTMuonValidator
4 // Class: HLTMuonValidator
5 //
6 
7 //
8 // Jason Slaunwhite and Jeff Klukas
9 //
10 //
11 
12 // system include files
13 #include <iostream>
14 #include <memory>
15 #include <tuple>
16 
17 // user include files
19 
25 
28 
29 #include "TDirectory.h"
30 #include "TFile.h"
31 #include "TPRegexp.h"
32 
35 
37 public:
38  explicit HLTMuonValidator(const edm::ParameterSet &);
39 
40 private:
41  // Analyzer Methods
42  void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
43  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
44  void analyze(const edm::Event &, const edm::EventSetup &) override;
45 
46  // Extra Methods
47  std::vector<std::string> moduleLabels(std::string);
48  std::vector<std::string> stepLabels(const std::vector<std::string> &);
49 
50  // Input from Configuration File
53  std::vector<std::string> hltPathsToCheck_;
54 
55  // Member Variables
56  std::vector<HLTMuonPlotter> analyzers_;
58  std::tuple<edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
62 };
63 
66 
67 using namespace std;
68 using namespace edm;
69 using namespace reco;
70 using namespace trigger;
71 
72 typedef vector<string> vstring;
73 
76 
78  : pset_(pset),
79  hltProcessName_(pset.getParameter<string>("hltProcessName")),
80  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck")) {
81  myTokens_ = HLTMuonPlotter::getTokens(pset_, consumesCollector());
82 }
83 
84 vector<string> HLTMuonValidator::moduleLabels(string path) {
85  vector<string> modules = hltConfig_.moduleLabels(path);
86  vector<string>::iterator iter = modules.begin();
87 
88  while (iter != modules.end())
89  if (iter->find("Filtered") == string::npos)
90  iter = modules.erase(iter);
91  else
92  ++iter;
93 
94  return modules;
95 }
96 
97 vector<string> HLTMuonValidator::stepLabels(const vector<string> &modules) {
98  vector<string> steps(1, "All");
99  for (size_t i = 0; i < modules.size(); i++) {
100  if ((modules[i].find("IsoFiltered") != string::npos)) {
101  if (modules[i].find("L3") != string::npos)
102  steps.push_back("L3TkIso");
103  else
104  steps.push_back("L2Iso");
105  } else if ((modules[i].find("pfecalIsoRhoFiltered") != string::npos)) {
106  if (modules[i].find("L3") != string::npos)
107  steps.push_back("L3EcalIso");
108  else if (modules[i].find("TkFiltered") != string::npos)
109  steps.push_back("TkEcalIso");
110  } else if ((modules[i].find("pfhcalIsoRhoFiltered") != string::npos)) {
111  if (modules[i].find("L3") != string::npos)
112  steps.push_back("L3HcalIso");
113  else if (modules[i].find("TkFiltered") != string::npos)
114  steps.push_back("TkHcalIso");
115  } else if (modules[i].find("TkFiltered") != string::npos) {
116  steps.push_back("Tk");
117  } else if (modules[i].find("L3") != string::npos)
118  steps.push_back("L3");
119  else if (modules[i].find("L2") != string::npos)
120  steps.push_back("L2");
121  else if (modules[i].find("L1") != string::npos)
122  steps.push_back("L1");
123  else
124  return vector<string>();
125  }
126 
127  if (steps.size() < 2 || ((steps[1] != "L1") && (steps[1] != "Tk")))
128  return vector<string>();
129  return steps;
130 }
131 
132 void HLTMuonValidator::dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {
133  // Initialize hltConfig
134  bool changedConfig;
135  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
136  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
137  return;
138  }
139 
140  // Get the set of trigger paths we want to make plots for
141  set<string> hltPaths;
142  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
143  TPRegexp pattern(hltPathsToCheck_[i]);
144  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
145  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
146  hltPaths.insert(hltConfig_.triggerNames()[j]);
147  }
148 
149  // Initialize the analyzers
150  analyzers_.clear();
151  set<string>::iterator iPath;
152  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
153  string path = *iPath;
154  string shortpath = path;
155  if (path.rfind("_v") < path.length())
156  shortpath = path.substr(0, path.rfind("_v"));
157 
158  vector<string> labels = moduleLabels(path);
159  vector<string> steps = stepLabels(labels);
160 
161  if (!labels.empty() && !steps.empty()) {
163  analyzers_.push_back(analyzer);
164  }
165  }
166 }
167 
168 void HLTMuonValidator::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &iRun, edm::EventSetup const &iSetup) {
169  // Call the beginRun (which books all the histograms)
170  vector<HLTMuonPlotter>::iterator iter;
171  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
172  iter->beginRun(iBooker, iRun, iSetup);
173  }
174 }
175 
176 void HLTMuonValidator::analyze(const Event &iEvent, const EventSetup &iSetup) {
177  vector<HLTMuonPlotter>::iterator iter;
178  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
179  iter->analyze(iEvent, iSetup);
180  }
181 }
182 
183 // define this as a plug-in
HLTMuonValidator::pset_
edm::ParameterSet pset_
Definition: HLTMuonValidator.cc:51
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
HLTMuonValidator::myTokens_
std::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > myTokens_
Definition: HLTMuonValidator.cc:61
HLTMuonValidator::hltProcessName_
std::string hltProcessName_
Definition: HLTMuonValidator.cc:52
HLTMuonValidator::hltPathsToCheck_
std::vector< std::string > hltPathsToCheck_
Definition: HLTMuonValidator.cc:53
mps_fire.i
i
Definition: mps_fire.py:355
LogMessageMonitor_cff.modules
modules
Definition: LogMessageMonitor_cff.py:7
MessageLogger.h
edm::Run
Definition: Run.h:45
modules
Definition: ZHLTMatchFilter.cc:17
edm::EDGetTokenT< reco::GenParticleCollection >
HLTMuonValidator::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: HLTMuonValidator.cc:132
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTSiStripMonitoring_cff.hltPaths
hltPaths
Definition: HLTSiStripMonitoring_cff.py:252
HLTMuonValidator::HLTMuonValidator
HLTMuonValidator(const edm::ParameterSet &)
Definition: HLTMuonValidator.cc:77
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ramdisk_dqm_sourceclient-live_cfg.analyzer
analyzer
Definition: ramdisk_dqm_sourceclient-live_cfg.py:18
HLTConfigProvider::moduleLabels
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
Definition: HLTConfigProvider.h:75
MakerMacros.h
HLTMuonPlotter::getTokens
static std::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > getTokens(const edm::ParameterSet &, edm::ConsumesCollector &&)
Definition: HLTMuonPlotter.cc:264
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
vstring
vector< string > vstring
Definition: HLTMuonValidator.cc:72
Service.h
DQMEDAnalyzer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
HLTMuonPlotter.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
HLTMuonValidator::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HLTMuonValidator.cc:168
iEvent
int iEvent
Definition: GenABIO.cc:224
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
HLTMuonValidator
Definition: HLTMuonValidator.cc:36
edm::EventSetup
Definition: EventSetup.h:57
HLTMuonValidator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HLTMuonValidator.cc:176
HLTConfigProvider.h
HLTConfigProvider
Definition: HLTConfigProvider.h:28
std
Definition: JetResolutionObject.h:76
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
analyzer
Definition: SiPixelLorentzAngle.h:82
Frameworkfwd.h
vstring
vector< string > vstring
Definition: ExoticaDQM.cc:8
customisers.steps
steps
Definition: customisers.py:41
trigger
Definition: HLTPrescaleTableCond.h:8
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
ParameterSet.h
HLTMuonValidator::analyzers_
std::vector< HLTMuonPlotter > analyzers_
Definition: HLTMuonValidator.cc:56
HLTMuonPlotter
Definition: HLTMuonPlotter.h:52
HLTConfigProvider::triggerNames
const std::vector< std::string > & triggerNames() const
names of trigger paths
Definition: HLTConfigProvider.h:68
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTMuonValidator::stepLabels
std::vector< std::string > stepLabels(const std::vector< std::string > &)
Definition: HLTMuonValidator.cc:97
edm::Event
Definition: Event.h:73
HLTMuonValidator::hltConfig_
HLTConfigProvider hltConfig_
Definition: HLTMuonValidator.cc:57
HLTMuonValidator::moduleLabels
std::vector< std::string > moduleLabels(std::string)
Definition: HLTMuonValidator.cc:84
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27