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 133 of file TrigObjTnPHistColl.cc.

134  : selectionStr_(config.getParameter<std::string>("selectionStr")),
135  isANDForExpandedPaths_(config.getParameter<bool>("isANDForExpandedPaths")),
136  verbose_(config.getParameter<int>("verbose")),
137  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 203 of file TrigObjTnPHistColl.cc.

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

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 184 of file TrigObjTnPHistColl.cc.

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

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 147 of file TrigObjTnPHistColl.cc.

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

References HltComparatorCreateWorkflow::hltConfig.

Referenced by TrigObjTnPHistColl::init().

◆ makePSetDescription()

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

Definition at line 139 of file TrigObjTnPHistColl.cc.

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

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 155 of file TrigObjTnPHistColl.cc.

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

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:184
TrigObjTnPHistColl::PathSelector::expandPath
static std::string expandPath(const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
Definition: TrigObjTnPHistColl.cc:203
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:30
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:318