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 123 of file TrigObjTnPHistColl.h.

Constructor & Destructor Documentation

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

Definition at line 135 of file TrigObjTnPHistColl.cc.

135  :
136  selectionStr_(config.getParameter<std::string>("selectionStr")),
137  isANDForExpandedPaths_(config.getParameter<bool>("isANDForExpandedPaths")),
138  verbose_(config.getParameter<int>("verbose")),
139  isInited_(false)
140 {
141 
142 }
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 206 of file TrigObjTnPHistColl.cc.

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

Referenced by expandSelectionStr().

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 ) edm::LogWarning("TrigObjTnPHistColl::PathSelector") << "pattern: \"" << pathPattern << "\" could not be resolved, please check your triggers are spelt correctly and present in the data you are running over";
221  return "";
222  }
223 
224  // Compose logical expression
225  std::string expanded( "(" );
226  for( unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
227  if( iVers > 0 ) expanded.append( isAND ? " AND " : " OR " );
228  expanded.append( matched.at( iVers ) );
229  }
230  expanded.append( ")" );
231  if(verbose>1 ) {
232  edm::LogInfo("TrigObjTnPHistColl::PathSelector" ) << "Logical expression : \"" << pathPattern << "\"\n"
233  << " expanded to: \"" << expanded << "\"";
234  }
235  return expanded;
236 }
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:74
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 189 of file TrigObjTnPHistColl.cc.

References expandPath(), L1GtLogicParser::operandTokenVector(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by init().

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

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

Referenced by TrigObjTnPHistColl::init().

154 {
156  isInited_ = true;
157  if(verbose_>1){
158  edm::LogInfo("TrigObjTnPHistColl::PathSelector" ) << "trigger selection string: \"" << expandedSelStr_ << "\"";
159  }
160 }
static std::string expandSelectionStr(const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
edm::ParameterSetDescription TrigObjTnPHistColl::PathSelector::makePSetDescription ( )
static

Definition at line 144 of file TrigObjTnPHistColl.cc.

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

Referenced by TrigObjTnPHistColl::makePSetDescription().

145 {
147  desc.add<std::string>("selectionStr",std::string(""));
148  desc.add<bool>("isANDForExpandedPaths",false);
149  desc.add<int>("verbose",1);
150  return desc;
151 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool TrigObjTnPHistColl::PathSelector::operator() ( const edm::TriggerResults trigResults,
const edm::TriggerNames trigNames 
) const

Definition at line 162 of file TrigObjTnPHistColl.cc.

References accept(), edm::HLTGlobalStatus::accept(), expandedSelStr_, L1GtLogicParser::expressionResult(), isInited_, L1GtLogicParser::operandTokenVector(), selectionStr_, edm::TriggerNames::size(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::TriggerNames::triggerIndex().

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

Member Data Documentation

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

Definition at line 134 of file TrigObjTnPHistColl.h.

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

bool TrigObjTnPHistColl::PathSelector::isANDForExpandedPaths_
private

Definition at line 135 of file TrigObjTnPHistColl.h.

Referenced by init().

bool TrigObjTnPHistColl::PathSelector::isInited_
private

Definition at line 137 of file TrigObjTnPHistColl.h.

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

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

Definition at line 133 of file TrigObjTnPHistColl.h.

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

int TrigObjTnPHistColl::PathSelector::verbose_
private

Definition at line 136 of file TrigObjTnPHistColl.h.

Referenced by init().