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