CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

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) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

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.

References HLTConfigProvider::matched(), HLTConfigProvider::restoreVersion(), AlCaHLTBitMon_QueryRunRegistry::string, HLTConfigProvider::triggerNames(), and trigNames.

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 }
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
const std::vector< std::string > & triggerNames() const
names of trigger paths
static constexpr int verbose
Log< level::Info, false > LogInfo
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
Log< level::Warning, false > LogWarning
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.

References L1GtLogicParser::operandTokenVector(), EgammaValidation_cff::pathName, AlCaHLTBitMon_QueryRunRegistry::string, and unpackBuffers-CaloStage2::token.

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 }
static std::string expandPath(const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
static constexpr int verbose
void TrigObjTnPHistColl::PathSelector::init ( const HLTConfigProvider hltConfig)

Definition at line 148 of file TrigObjTnPHistColl.cc.

Referenced by TrigObjTnPHistColl::init().

148  {
150  isInited_ = true;
151  if (verbose_ > 1) {
152  edm::LogInfo("TrigObjTnPHistColl::PathSelector") << "trigger selection string: \"" << expandedSelStr_ << "\"";
153  }
154 }
Log< level::Info, false > LogInfo
static std::string expandSelectionStr(const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
edm::ParameterSetDescription TrigObjTnPHistColl::PathSelector::makePSetDescription ( )
static

Definition at line 140 of file TrigObjTnPHistColl.cc.

References edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TrigObjTnPHistColl::makePSetDescription().

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 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool TrigObjTnPHistColl::PathSelector::operator() ( const edm::TriggerResults trigResults,
const edm::TriggerNames trigNames 
) const

Definition at line 156 of file TrigObjTnPHistColl.cc.

References accept(), edm::HLTGlobalStatus::accept(), L1GtLogicParser::expressionResult(), L1GtLogicParser::operandTokenVector(), EgammaValidation_cff::pathName, edm::TriggerNames::size(), AlCaHLTBitMon_QueryRunRegistry::string, unpackBuffers-CaloStage2::token, and edm::TriggerNames::triggerIndex().

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 }
std::size_t size() const
Definition: TriggerNames.cc:59
bool accept() const
Has at least one path accepted the event?
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
Log< level::Error, false > LogError
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31

Member Data Documentation

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

Definition at line 140 of file TrigObjTnPHistColl.h.

bool TrigObjTnPHistColl::PathSelector::isANDForExpandedPaths_
private

Definition at line 141 of file TrigObjTnPHistColl.h.

bool TrigObjTnPHistColl::PathSelector::isInited_
private

Definition at line 143 of file TrigObjTnPHistColl.h.

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

Definition at line 139 of file TrigObjTnPHistColl.h.

int TrigObjTnPHistColl::PathSelector::verbose_
private

Definition at line 142 of file TrigObjTnPHistColl.h.