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

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) {}
T getParameter(std::string const &) const

Member Function Documentation

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.

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

Referenced by expandSelectionStr().

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 }
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 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)
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.

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

Referenced by init().

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

Definition at line 147 of file TrigObjTnPHistColl.cc.

References expandedSelStr_, expandSelectionStr(), isANDForExpandedPaths_, isInited_, selectionStr_, and verbose_.

Referenced by TrigObjTnPHistColl::init().

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

Definition at line 139 of file TrigObjTnPHistColl.cc.

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

Referenced by TrigObjTnPHistColl::makePSetDescription().

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

Definition at line 155 of file TrigObjTnPHistColl.cc.

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

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 }
bool accept() const
Has at least one path accepted the event?
Strings::size_type size() const
Definition: TriggerNames.cc:31
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:24

Member Data Documentation

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

Definition at line 140 of file TrigObjTnPHistColl.h.

Referenced by init(), and operator()().

bool TrigObjTnPHistColl::PathSelector::isANDForExpandedPaths_
private

Definition at line 141 of file TrigObjTnPHistColl.h.

Referenced by init().

bool TrigObjTnPHistColl::PathSelector::isInited_
private

Definition at line 143 of file TrigObjTnPHistColl.h.

Referenced by init(), and operator()().

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

Definition at line 139 of file TrigObjTnPHistColl.h.

Referenced by init(), and operator()().

int TrigObjTnPHistColl::PathSelector::verbose_
private

Definition at line 142 of file TrigObjTnPHistColl.h.

Referenced by init().