CMS 3D CMS Logo

HLTTauDQMOfflineSource.cc
Go to the documentation of this file.
2 
4 
6 
7 using namespace std;
8 using namespace edm;
9 using namespace reco;
10 using namespace trigger;
11 
12 //
13 // constructors and destructor
14 //
16  : hltProcessName_(ps.getUntrackedParameter<std::string>("HLTProcessName", "HLT")),
17  triggerResultsSrc_(ps.getUntrackedParameter<edm::InputTag>("TriggerResultsSrc")),
18  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsSrc_)),
19  triggerEventSrc_(ps.getUntrackedParameter<edm::InputTag>("TriggerEventSrc")),
20  triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventSrc_)),
21  pathRegexString_(ps.getUntrackedParameter<std::string>("Paths")),
22  pathRegex_(pathRegexString_),
23  nPtBins_(ps.getUntrackedParameter<int>("PtHistoBins", 20)),
24  nEtaBins_(ps.getUntrackedParameter<int>("EtaHistoBins", 12)),
25  nPhiBins_(ps.getUntrackedParameter<int>("PhiHistoBins", 18)),
26  ptMax_(ps.getUntrackedParameter<double>("PtHistoMax", 200)),
27  highPtMax_(ps.getUntrackedParameter<double>("HighPtHistoMax", 1000)),
28  l1MatchDr_(ps.getUntrackedParameter<double>("L1MatchDeltaR", 0.5)),
29  hltMatchDr_(ps.getUntrackedParameter<double>("HLTMatchDeltaR", 0.5)),
30  dqmBaseFolder_(ps.getUntrackedParameter<std::string>("DQMBaseFolder")),
31  counterEvt_(0),
32  prescaleEvt_(ps.getUntrackedParameter<int>("prescaleEvt", -1)) {
34  doRefAnalysis_ = matching.getUntrackedParameter<bool>("doMatching");
35 
36  if (ps.exists("L1Plotter") && !ps.exists("TagAndProbe")) {
37  l1Plotter_ = std::make_unique<HLTTauDQML1Plotter>(ps.getUntrackedParameter<edm::ParameterSet>("L1Plotter"),
38  consumesCollector(),
39  nPhiBins_,
40  ptMax_,
41  highPtMax_,
43  l1MatchDr_,
45  }
46  if (ps.exists("PathSummaryPlotter")) {
47  pathSummaryPlotter_ = std::make_unique<HLTTauDQMPathSummaryPlotter>(
49  }
50  tagAndProbe_ = false;
51  if (ps.exists("TagAndProbe")) {
52  tagAndProbePaths = ps.getUntrackedParameter<std::vector<edm::ParameterSet> >("TagAndProbe");
53  tagAndProbe_ = true;
54  }
55 
56  if (doRefAnalysis_) {
57  using VPSet = std::vector<edm::ParameterSet>;
58  VPSet matchObjects = matching.getUntrackedParameter<VPSet>("matchFilters");
59  for (const edm::ParameterSet& pset : matchObjects) {
60  refObjects_.push_back(RefObject{pset.getUntrackedParameter<int>("matchObjectID"),
61  consumes<LVColl>(pset.getUntrackedParameter<edm::InputTag>("FilterName"))});
62  }
63  }
64 }
65 
67 
68 //--------------------------------------------------------
70  //Evaluate configuration for every new trigger menu
71  bool hltMenuChanged = false;
72  if (HLTCP_.init(iRun, iSetup, hltProcessName_, hltMenuChanged)) {
73  LogDebug("HLTTauDQMOffline") << "dqmBeginRun(), hltMenuChanged " << hltMenuChanged;
74  if (hltMenuChanged) {
75  if (!tagAndProbe_) {
76  // Find all paths to monitor
77  std::vector<std::string> foundPaths;
78  std::smatch what;
79  LogDebug("HLTTauDQMOffline") << "Looking for paths with regex " << pathRegexString_;
80  for (const std::string& pathName : HLTCP_.triggerNames()) {
81  if (std::regex_search(pathName, what, pathRegex_)) {
82  LogDebug("HLTTauDQMOffline") << "Found path " << pathName;
83  foundPaths.emplace_back(pathName);
84  }
85  }
86  std::sort(foundPaths.begin(), foundPaths.end());
87 
88  // Construct path plotters
89  std::vector<const HLTTauDQMPath*> pathObjects;
90  pathPlotters_.reserve(foundPaths.size());
91  pathObjects.reserve(foundPaths.size());
92  for (const std::string& pathName : foundPaths) {
93  pathPlotters_.emplace_back(pathName,
94  HLTCP_,
98  nPtBins_,
99  nEtaBins_,
100  nPhiBins_,
101  ptMax_,
102  highPtMax_,
103  l1MatchDr_,
104  hltMatchDr_);
105  if (pathPlotters_.back().isValid()) {
106  pathObjects.push_back(pathPlotters_.back().getPathObject());
107  }
108  }
109 
110  // Update paths to the summary plotter
111  if (pathSummaryPlotter_) {
112  pathSummaryPlotter_->setPathObjects(pathObjects);
113  }
114  } else { // tag and probe
115  // Find all paths to monitor
116  std::vector<std::string> foundPaths;
117  std::smatch what;
118 
119  for (const edm::ParameterSet& tpset : tagAndProbePaths) {
120  std::vector<std::string> moduleLabels;
121  edm::ParameterSet denpset = tpset.getParameter<edm::ParameterSet>("denominator");
122  std::vector<std::string> denominators = denpset.getParameter<std::vector<std::string> >("hltPaths");
123  std::vector<std::string> updatedDenominators;
124  for (size_t i = 0; i < denominators.size(); ++i) {
125  const std::regex denRegex_(denominators[i]);
126  for (const std::string& pathName : HLTCP_.triggerNames()) {
127  if (std::regex_search(pathName, what, denRegex_)) {
128  updatedDenominators.push_back(pathName);
129  moduleLabels = HLTCP_.moduleLabels(pathName);
130  }
131  }
132  }
133  denpset.addParameter<std::vector<std::string> >("hltPaths", updatedDenominators);
134 
135  edm::ParameterSet numpset = tpset.getParameter<edm::ParameterSet>("numerator");
136  std::vector<std::string> numerators = numpset.getParameter<std::vector<std::string> >("hltPaths");
137 
138  const std::regex numRegex_(numerators[0]);
139  for (const std::string& pathName : HLTCP_.triggerNames()) {
140  if (std::regex_search(pathName, what, numRegex_)) {
141  edm::ParameterSet new_tpset = tpset;
142  new_tpset.addParameter<std::string>("name", pathName);
143  std::vector<std::string> updatedHltPaths;
144  updatedHltPaths.push_back(pathName);
145  numpset.addParameter<std::vector<std::string> >("hltPaths", updatedHltPaths);
146  new_tpset.addParameter<edm::ParameterSet>("numerator", numpset);
147  new_tpset.addParameter<edm::ParameterSet>("denominator", denpset);
148 
149  tagandprobePlotters_.emplace_back(
150  new HLTTauDQMTagAndProbePlotter(new_tpset, moduleLabels, dqmBaseFolder_));
151  }
152  }
153  }
154  }
155  }
156  } else {
157  edm::LogWarning("HLTTauDQMOffline") << "HLT config extraction failure with process name '" << hltProcessName_
158  << "'";
159  }
160 }
161 
162 //--------------------------------------------------------
164  const edm::Run& iRun,
165  const EventSetup& iSetup) {
166  if (l1Plotter_) {
167  l1Plotter_->bookHistograms(iBooker);
168  }
169  for (auto& pathPlotter : pathPlotters_) {
170  pathPlotter.bookHistograms(iBooker);
171  }
172  for (auto& tpPlotter : tagandprobePlotters_) {
173  tpPlotter->bookHistograms(iBooker, iRun, iSetup);
174  }
175  if (pathSummaryPlotter_) {
176  pathSummaryPlotter_->bookHistograms(iBooker);
177  }
178 }
179 
180 // ----------------------------------------------------------
182  //Apply the prescaler
183  if (counterEvt_ > prescaleEvt_) {
184  //Do Analysis here
185  counterEvt_ = 0;
186 
187  edm::Handle<edm::TriggerResults> triggerResultsHandle;
188  iEvent.getByToken(triggerResultsToken_, triggerResultsHandle);
189  if (!triggerResultsHandle.isValid()) {
190  edm::LogWarning("HLTTauDQMOffline") << "Unable to read edm::TriggerResults with label " << triggerResultsSrc_;
191  return;
192  }
193 
194  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
195  iEvent.getByToken(triggerEventToken_, triggerEventHandle);
196  if (!triggerEventHandle.isValid()) {
197  edm::LogWarning("HLTTauDQMOffline") << "Unable to read trigger::TriggerEvent with label " << triggerEventSrc_;
198  return;
199  }
200 
201  //Create match collections
203  if (doRefAnalysis_) {
204  for (RefObject& refObj : refObjects_) {
205  edm::Handle<LVColl> collHandle;
206  iEvent.getByToken(refObj.token, collHandle);
207  if (!collHandle.isValid())
208  continue;
209 
210  if (refObj.objID == 11) {
211  refC.electrons.insert(refC.electrons.end(), collHandle->begin(), collHandle->end());
212  } else if (refObj.objID == 13) {
213  refC.muons.insert(refC.muons.end(), collHandle->begin(), collHandle->end());
214  } else if (refObj.objID == 15) {
215  refC.taus.insert(refC.taus.end(), collHandle->begin(), collHandle->end());
216  } else if (refObj.objID == 0) {
217  refC.met.insert(refC.met.end(), collHandle->begin(), collHandle->end());
218  }
219  }
220  }
221 
222  //Path Plotters
223  for (auto& pathPlotter : pathPlotters_) {
224  if (pathPlotter.isValid())
225  pathPlotter.analyze(*triggerResultsHandle, *triggerEventHandle, refC);
226  }
227 
228  if (pathSummaryPlotter_ && pathSummaryPlotter_->isValid()) {
229  pathSummaryPlotter_->analyze(*triggerResultsHandle, *triggerEventHandle, refC);
230  }
231 
232  //L1 Plotter
233  if (l1Plotter_ && l1Plotter_->isValid()) {
234  l1Plotter_->analyze(iEvent, iSetup, refC);
235  }
236 
237  //Tag and probe plotters
238  for (auto& tpPlotter : tagandprobePlotters_) {
239  if (tpPlotter->isValid())
240  tpPlotter->analyze(iEvent, *triggerResultsHandle, *triggerEventHandle, refC);
241  }
242 
243  } else {
244  counterEvt_++;
245  }
246 }
HLTTauDQMOfflineSource::ptMax_
const double ptMax_
Definition: HLTTauDQMOfflineSource.h:50
HLTTauDQMOfflineSource::hltMatchDr_
const double hltMatchDr_
Definition: HLTTauDQMOfflineSource.h:50
HLTTauDQMTagAndProbePlotter
Definition: HLTTauDQMTagAndProbePlotter.h:23
mps_fire.i
i
Definition: mps_fire.py:355
HLTTauDQMOfflineSource::triggerResultsSrc_
edm::InputTag triggerResultsSrc_
Definition: HLTTauDQMOfflineSource.h:41
MessageLogger.h
HLTTauDQMOfflineSource::counterEvt_
int counterEvt_
Definition: HLTTauDQMOfflineSource.h:66
HLTTauDQMOfflineSource::HLTCP_
HLTConfigProvider HLTCP_
Definition: HLTTauDQMOfflineSource.h:53
HLTTauDQMOfflineSource::pathPlotters_
std::vector< HLTTauDQMPathPlotter > pathPlotters_
Definition: HLTTauDQMOfflineSource.h:71
edm::Run
Definition: Run.h:45
TriggerEvent.h
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTTauDQMOfflineSource::pathRegex_
const std::regex pathRegex_
Definition: HLTTauDQMOfflineSource.h:48
HLTTauDQMOfflineSource::HLTTauDQMOfflineSource
HLTTauDQMOfflineSource(const edm::ParameterSet &)
Definition: HLTTauDQMOfflineSource.cc:15
HLTTauDQMOfflineSource::highPtMax_
const double highPtMax_
Definition: HLTTauDQMOfflineSource.h:50
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TtSemiLepJetCombMVATrainer_cfi.matching
matching
Definition: TtSemiLepJetCombMVATrainer_cfi.py:13
edm::Handle< edm::TriggerResults >
HLTTauDQMOfflineSource::prescaleEvt_
const int prescaleEvt_
Definition: HLTTauDQMOfflineSource.h:67
HLTTauDQMOfflineSource::tagandprobePlotters_
std::vector< std::unique_ptr< HLTTauDQMTagAndProbePlotter > > tagandprobePlotters_
Definition: HLTTauDQMOfflineSource.h:73
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
HLTTauDQMOfflineSource::triggerEventSrc_
edm::InputTag triggerEventSrc_
Definition: HLTTauDQMOfflineSource.h:43
hltMonBTagIPClient_cfi.pathName
pathName
Definition: hltMonBTagIPClient_cfi.py:5
edmTracerLogToSimpleConfig.foundPaths
foundPaths
Definition: edmTracerLogToSimpleConfig.py:76
HLTTauDQMOfflineObjects::electrons
std::vector< LV > electrons
Definition: HLTTauDQMPlotter.h:24
trackingPlots.tpPlotter
tpPlotter
Definition: trackingPlots.py:1927
HLTTauDQMOfflineObjects
Definition: HLTTauDQMPlotter.h:18
HLTTauDQMOfflineSource::hltProcessName_
std::string hltProcessName_
Definition: HLTTauDQMOfflineSource.h:40
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTTauDQMOfflineSource::refObjects_
std::vector< RefObject > refObjects_
Definition: HLTTauDQMOfflineSource.h:61
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
HLTTauDQMOfflineSource::bookHistograms
void bookHistograms(DQMStore::IBooker &iBooker, const edm::Run &r, const edm::EventSetup &c) override
Definition: HLTTauDQMOfflineSource.cc:163
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::ParameterSet::addParameter
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:124
HLTTauDQMOfflineObjects::met
std::vector< LV > met
Definition: HLTTauDQMPlotter.h:28
HLTTauDQMOfflineSource::nEtaBins_
const int nEtaBins_
Definition: HLTTauDQMOfflineSource.h:49
createfilelist.int
int
Definition: createfilelist.py:10
HLTTauDQMOfflineSource::l1Plotter_
std::unique_ptr< HLTTauDQML1Plotter > l1Plotter_
Definition: HLTTauDQMOfflineSource.h:70
iEvent
int iEvent
Definition: GenABIO.cc:224
HLTTauDQMOfflineObjects::muons
std::vector< LV > muons
Definition: HLTTauDQMPlotter.h:26
HLTTauDQMOfflineSource::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HLTTauDQMOfflineSource.cc:181
edm::EventSetup
Definition: EventSetup.h:57
trigger::TriggerEvent
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
HLTTauDQMOfflineSource::dqmBeginRun
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: HLTTauDQMOfflineSource.cc:69
HLTTauDQMOfflineSource::triggerResultsToken_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: HLTTauDQMOfflineSource.h:42
HLTTauDQMOfflineSource::pathRegexString_
const std::string pathRegexString_
Definition: HLTTauDQMOfflineSource.h:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HistogramManager_cfi.VPSet
def VPSet(*args)
Definition: HistogramManager_cfi.py:401
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
HLTTauDQMOfflineSource::dqmBaseFolder_
const std::string dqmBaseFolder_
Definition: HLTTauDQMOfflineSource.h:51
HLTTauDQMOfflineSource::~HLTTauDQMOfflineSource
~HLTTauDQMOfflineSource() override
HLTTauDQMOfflineSource::triggerEventToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
Definition: HLTTauDQMOfflineSource.h:44
HLTTauDQMOfflineSource::doRefAnalysis_
bool doRefAnalysis_
Definition: HLTTauDQMOfflineSource.h:56
HLTTauDQMOfflineObjects::taus
std::vector< LV > taus
Definition: HLTTauDQMPlotter.h:27
dqm::implementation::IBooker
Definition: DQMStore.h:43
HLTTauDQMOfflineSource::tagAndProbe_
bool tagAndProbe_
Definition: HLTTauDQMOfflineSource.h:62
trigger
Definition: HLTPrescaleTableCond.h:8
HLTTauDQMOfflineSource.h
HLTConfigProvider::triggerNames
const std::vector< std::string > & triggerNames() const
names of trigger paths
Definition: HLTConfigProvider.h:68
HLTTauDQMOfflineSource::nPtBins_
const int nPtBins_
Definition: HLTTauDQMOfflineSource.h:49
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HLTTauDQMOfflineSource::l1MatchDr_
const double l1MatchDr_
Definition: HLTTauDQMOfflineSource.h:50
edm::Event
Definition: Event.h:73
HLTTauDQMOfflineSource::pathSummaryPlotter_
std::unique_ptr< HLTTauDQMPathSummaryPlotter > pathSummaryPlotter_
Definition: HLTTauDQMOfflineSource.h:72
edm::InputTag
Definition: InputTag.h:15
edm::TriggerResults
Definition: TriggerResults.h:35
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
HLTTauDQMOfflineSource::tagAndProbePaths
std::vector< edm::ParameterSet > tagAndProbePaths
Definition: HLTTauDQMOfflineSource.h:63
HLTTauDQMOfflineSource::nPhiBins_
const int nPhiBins_
Definition: HLTTauDQMOfflineSource.h:49
HLTTauDQMOfflineSource::RefObject
Definition: HLTTauDQMOfflineSource.h:57