CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes
TrigObjTnPHistColl::PathSelector Class Reference

#include <TrigObjTnPHistColl.h>

Public Member Functions

void init (const HLTConfigProvider &hltConfig)
 
bool operator() (const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
 
 PathSelector (const edm::ParameterSet &config)
 

Static Public Member Functions

static edm::ParameterSetDescription makePSetDescription ()
 

Static Private Member Functions

static std::string expandPath (const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
 
static std::string expandSelectionStr (const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
 

Private Attributes

std::string expandedSelStr_
 
bool isANDForExpandedPaths_
 
bool isInited_
 
std::string selectionStr_
 
int verbose_
 

Detailed Description

Definition at line 122 of file TrigObjTnPHistColl.h.

Constructor & Destructor Documentation

◆ PathSelector()

TrigObjTnPHistColl::PathSelector::PathSelector ( const edm::ParameterSet config)

Definition at line 134 of file TrigObjTnPHistColl.cc.

135  : selectionStr_(config.getParameter<std::string>("selectionStr")),
136  isANDForExpandedPaths_(config.getParameter<bool>("isANDForExpandedPaths")),
137  verbose_(config.getParameter<int>("verbose")),
138  isInited_(false) {}

Member Function Documentation

◆ expandPath()

std::string TrigObjTnPHistColl::PathSelector::expandPath ( const std::string &  pathPattern,
const HLTConfigProvider hltConfig,
bool  isAND,
int  verbose 
)
staticprivate

Definition at line 204 of file TrigObjTnPHistColl.cc.

207  {
208  // Find matching entries in the menu
209  const std::vector<std::string>& trigNames = hltConfig.triggerNames();
210  std::vector<std::string> matched;
211  const std::string versionWildcard("_v*");
212  if (pathPattern.substr(pathPattern.size() - versionWildcard.size()) == versionWildcard) {
213  const std::string pathPatternBase(pathPattern.substr(0, pathPattern.size() - versionWildcard.size()));
214  matched = hltConfig.restoreVersion(trigNames, pathPatternBase);
215  } else {
216  matched = hltConfig.matched(trigNames, pathPattern);
217  }
218 
219  if (matched.empty()) {
220  if (verbose >= 1)
221  edm::LogWarning("TrigObjTnPHistColl::PathSelector")
222  << "pattern: \"" << pathPattern
223  << "\" could not be resolved, please check your triggers are spelt correctly and present in the data you are "
224  "running over";
225  return "";
226  }
227 
228  // Compose logical expression
229  std::string expanded("(");
230  for (unsigned iVers = 0; iVers < matched.size(); ++iVers) {
231  if (iVers > 0)
232  expanded.append(isAND ? " AND " : " OR ");
233  expanded.append(matched.at(iVers));
234  }
235  expanded.append(")");
236  if (verbose > 1) {
237  edm::LogInfo("TrigObjTnPHistColl::PathSelector") << "Logical expression : \"" << pathPattern << "\"\n"
238  << " expanded to: \"" << expanded << "\"";
239  }
240  return expanded;
241 }

References HltComparatorCreateWorkflow::hltConfig, trigObjTnPSource_cfi::isAND, muonTagProbeFilters_cff::matched, AlCaHLTBitMon_QueryRunRegistry::string, trigNames, and verbose.

◆ expandSelectionStr()

std::string TrigObjTnPHistColl::PathSelector::expandSelectionStr ( const std::string &  selStr,
const HLTConfigProvider hltConfig,
bool  isAND,
int  verbose 
)
staticprivate

Definition at line 185 of file TrigObjTnPHistColl.cc.

188  {
189  std::string expandedSelStr(selStr);
190  //it is very important to pass in as a non-const std::string, see comments else where
191  L1GtLogicParser logicParser(expandedSelStr);
192  for (const auto& token : logicParser.operandTokenVector()) {
193  const std::string& pathName = token.tokenName;
194  if (pathName.find('*') != std::string::npos) {
195  std::string pathPatternExpanded = expandPath(pathName, hltConfig, isAND, verbose);
196  expandedSelStr.replace(expandedSelStr.find(pathName), pathName.size(), pathPatternExpanded);
197  }
198  }
199  return expandedSelStr;
200 }

References HltComparatorCreateWorkflow::hltConfig, trigObjTnPSource_cfi::isAND, L1GtLogicParser::operandTokenVector(), hltMonBTagIPClient_cfi::pathName, AlCaHLTBitMon_QueryRunRegistry::string, unpackBuffers-CaloStage2::token, and verbose.

◆ init()

void TrigObjTnPHistColl::PathSelector::init ( const HLTConfigProvider hltConfig)

Definition at line 148 of file TrigObjTnPHistColl.cc.

148  {
150  isInited_ = true;
151  if (verbose_ > 1) {
152  edm::LogInfo("TrigObjTnPHistColl::PathSelector") << "trigger selection string: \"" << expandedSelStr_ << "\"";
153  }
154 }

References HltComparatorCreateWorkflow::hltConfig.

Referenced by TrigObjTnPHistColl::init().

◆ makePSetDescription()

edm::ParameterSetDescription TrigObjTnPHistColl::PathSelector::makePSetDescription ( )
static

Definition at line 140 of file TrigObjTnPHistColl.cc.

140  {
142  desc.add<std::string>("selectionStr", std::string(""));
143  desc.add<bool>("isANDForExpandedPaths", false);
144  desc.add<int>("verbose", 1);
145  return desc;
146 }

References submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TrigObjTnPHistColl::makePSetDescription().

◆ operator()()

bool TrigObjTnPHistColl::PathSelector::operator() ( const edm::TriggerResults trigResults,
const edm::TriggerNames trigNames 
) const

Definition at line 156 of file TrigObjTnPHistColl.cc.

157  {
158  if (selectionStr_.empty())
159  return true; //didnt specify any selection, default to pass
160  else if (!isInited_) {
161  edm::LogError("TrigObjTnPHistColl")
162  << " error, TrigObjTnPHistColl::PathSelector is not initalised, returning false ";
163  return false;
164  } else if (expandedSelStr_.empty()) {
165  //there was a problem parsing the expression, it was logged at the start, no need to do each run
166  return false;
167  } else {
168  //as of 20/08/18, there is a bug in L1GtLogicParser, it must take a non-const std::string
169  //as input because it overloads the constructor between const and non-const std::string
170  //for like no reason. And the const version is broken, you have to use non-const
171  //hence we make a non-const copy of the selection string
172  std::string selStr = expandedSelStr_;
173  L1GtLogicParser logicParser(selStr);
174  for (auto& token : logicParser.operandTokenVector()) {
175  const std::string& pathName = token.tokenName;
176  auto pathIndex = trigNames.triggerIndex(pathName);
177  bool accept = pathIndex < trigNames.size() ? trigResults.accept(pathIndex) : false;
178  token.tokenResult = accept;
179  }
180  return logicParser.expressionResult();
181  }
182 }

References accept(), edm::HLTGlobalStatus::accept(), L1GtLogicParser::expressionResult(), L1GtLogicParser::operandTokenVector(), hltMonBTagIPClient_cfi::pathName, AlCaHLTBitMon_QueryRunRegistry::string, unpackBuffers-CaloStage2::token, and trigNames.

Member Data Documentation

◆ expandedSelStr_

std::string TrigObjTnPHistColl::PathSelector::expandedSelStr_
private

Definition at line 140 of file TrigObjTnPHistColl.h.

◆ isANDForExpandedPaths_

bool TrigObjTnPHistColl::PathSelector::isANDForExpandedPaths_
private

Definition at line 141 of file TrigObjTnPHistColl.h.

◆ isInited_

bool TrigObjTnPHistColl::PathSelector::isInited_
private

Definition at line 143 of file TrigObjTnPHistColl.h.

◆ selectionStr_

std::string TrigObjTnPHistColl::PathSelector::selectionStr_
private

Definition at line 139 of file TrigObjTnPHistColl.h.

◆ verbose_

int TrigObjTnPHistColl::PathSelector::verbose_
private

Definition at line 142 of file TrigObjTnPHistColl.h.

muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
TrigObjTnPHistColl::PathSelector::expandSelectionStr
static std::string expandSelectionStr(const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
Definition: TrigObjTnPHistColl.cc:185
TrigObjTnPHistColl::PathSelector::expandPath
static std::string expandPath(const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
Definition: TrigObjTnPHistColl.cc:204
trigNames
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
trigObjTnPSource_cfi.isAND
isAND
Definition: trigObjTnPSource_cfi.py:61
config
Definition: config.py:1
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
hltMonBTagIPClient_cfi.pathName
pathName
Definition: hltMonBTagIPClient_cfi.py:5
TrigObjTnPHistColl::PathSelector::verbose_
int verbose_
Definition: TrigObjTnPHistColl.h:142
TrigObjTnPHistColl::PathSelector::selectionStr_
std::string selectionStr_
Definition: TrigObjTnPHistColl.h:139
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrigObjTnPHistColl::PathSelector::isInited_
bool isInited_
Definition: TrigObjTnPHistColl.h:143
TrigObjTnPHistColl::PathSelector::isANDForExpandedPaths_
bool isANDForExpandedPaths_
Definition: TrigObjTnPHistColl.h:141
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
L1GtLogicParser
Definition: L1GtLogicParser.h:31
TrigObjTnPHistColl::PathSelector::expandedSelStr_
std::string expandedSelStr_
Definition: TrigObjTnPHistColl.h:140
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316