CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HLTHighLevel Class Reference

#include <HLTHighLevel.h>

Inheritance diagram for HLTHighLevel:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 HLTHighLevel (const edm::ParameterSet &)
 
std::vector< std::string > pathsFromSetup (const std::string &key, const edm::EventSetup &iSetup) const
 get HLTPaths with key 'key' from EventSetup (AlCaRecoTriggerBitsRcd) More...
 
 ~HLTHighLevel ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void init (const edm::TriggerResults &results, const edm::EventSetup &iSetup, const edm::TriggerNames &triggerNames)
 initialize the trigger conditions (call this if the trigger paths have changed) More...
 
std::string const & moduleLabel () const
 
std::string const & pathName () const
 stolen from HLTFilter More...
 

Private Attributes

bool andOr_
 false = and-mode (all requested triggers), true = or-mode (at least one) More...
 
const std::string eventSetupPathsKey_
 not empty => use read paths from AlCaRecoTriggerBitsRcd via this key More...
 
std::vector< unsigned int > HLTPathsByIndex_
 list of required HLT triggers by HLT index More...
 
std::vector< std::string > HLTPathsByName_
 list of required HLT triggers by HLT name More...
 
std::vector< std::string > HLTPatterns_
 input patterns that will be expanded into trigger names More...
 
edm::InputTag inputTag_
 HLT TriggerResults EDProduct. More...
 
bool throw_
 throw on any requested trigger being unknown More...
 
edm::ParameterSetID triggerNamesID_
 HLT trigger names. More...
 
edm::ESWatcher
< AlCaRecoTriggerBitsRcd > * 
watchAlCaRecoTriggerBitsRcd_
 Watcher to be created and used if 'eventSetupPathsKey_' non empty: More...
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

This class is an HLTFilter (-> EDFilter) implementing filtering on HLT bits

Date:
2012/01/29 00:51:00
Revision:
1.10
Author
Martin Grunewald

See header file for documentation

Date:
2012/01/29 00:51:01
Revision:
1.20
Author
Martin Grunewald

Definition at line 40 of file HLTHighLevel.h.

Constructor & Destructor Documentation

HLTHighLevel::HLTHighLevel ( const edm::ParameterSet iConfig)
explicit

Definition at line 36 of file HLTHighLevel.cc.

References eventSetupPathsKey_, edm::hlt::Exception, edm::ParameterSet::getParameter(), HLTPatterns_, and watchAlCaRecoTriggerBitsRcd_.

36  :
37  inputTag_ (iConfig.getParameter<edm::InputTag> ("TriggerResultsTag")),
38  triggerNamesID_ (),
39  andOr_ (iConfig.getParameter<bool> ("andOr")),
40  throw_ (iConfig.getParameter<bool> ("throw")),
41  eventSetupPathsKey_(iConfig.getParameter<std::string>("eventSetupPathsKey")),
43  HLTPatterns_ (iConfig.getParameter<std::vector<std::string> >("HLTPaths")),
46 {
47  // names and slot numbers are computed during the event loop,
48  // as they need to access the TriggerNames object via the TriggerResults
49 
50  if (eventSetupPathsKey_.size()) {
51  // If paths come from eventsetup, we must watch for IOV changes.
52  if (!HLTPatterns_.empty()) {
53  // We do not want double trigger path setting, so throw!
54  throw cms::Exception("Configuration")
55  << " HLTHighLevel instance: "<< iConfig.getParameter<std::string>("@module_label")
56  << "\n configured with " << HLTPatterns_.size() << " HLTPaths and\n"
57  << " eventSetupPathsKey " << eventSetupPathsKey_ << ", choose either of them.";
58  }
60  }
61 }
T getParameter(std::string const &) const
bool andOr_
false = and-mode (all requested triggers), true = or-mode (at least one)
Definition: HLTHighLevel.h:64
std::vector< unsigned int > HLTPathsByIndex_
list of required HLT triggers by HLT index
Definition: HLTHighLevel.h:85
edm::ParameterSetID triggerNamesID_
HLT trigger names.
Definition: HLTHighLevel.h:61
const std::string eventSetupPathsKey_
not empty =&gt; use read paths from AlCaRecoTriggerBitsRcd via this key
Definition: HLTHighLevel.h:74
bool throw_
throw on any requested trigger being unknown
Definition: HLTHighLevel.h:67
std::vector< std::string > HLTPathsByName_
list of required HLT triggers by HLT name
Definition: HLTHighLevel.h:82
std::vector< std::string > HLTPatterns_
input patterns that will be expanded into trigger names
Definition: HLTHighLevel.h:79
edm::InputTag inputTag_
HLT TriggerResults EDProduct.
Definition: HLTHighLevel.h:58
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchAlCaRecoTriggerBitsRcd_
Watcher to be created and used if &#39;eventSetupPathsKey_&#39; non empty:
Definition: HLTHighLevel.h:76
HLTHighLevel::~HLTHighLevel ( )

Definition at line 63 of file HLTHighLevel.cc.

References watchAlCaRecoTriggerBitsRcd_.

64 {
65  delete watchAlCaRecoTriggerBitsRcd_; // safe on null pointer...
66 }
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchAlCaRecoTriggerBitsRcd_
Watcher to be created and used if &#39;eventSetupPathsKey_&#39; non empty:
Definition: HLTHighLevel.h:76

Member Function Documentation

bool HLTHighLevel::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 187 of file HLTHighLevel.cc.

References accept(), andOr_, edm::ESWatcher< T >::check(), edm::InputTag::encode(), edm::hlt::Exception, edm::Event::getByLabel(), HLTPathsByIndex_, HLTPathsByName_, i, init(), inputTag_, LogDebug, LogTrace, python.rootplot.argparse::message, moduleLabel(), n, or, pathName(), throw_, edm::Event::triggerNames(), triggerNamesID_, and watchAlCaRecoTriggerBitsRcd_.

188 {
189  using namespace std;
190  using namespace edm;
191 
192  // get hold of TriggerResults Object
194  iEvent.getByLabel(inputTag_, trh);
195  if (trh.isValid()) {
196  LogDebug("HLTHighLevel") << "TriggerResults found, number of HLT paths: " << trh->size();
197  } else {
198  LogError("HLTHighLevel") << "TriggerResults product " << inputTag_.encode() << " not found - returning result=false!";
199  return false;
200  }
201 
202  // init the TriggerNames with the TriggerResults
203  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*trh);
204  bool config_changed = false;
205  if (triggerNamesID_ != triggerNames.parameterSetID()) {
206  triggerNamesID_ = triggerNames.parameterSetID();
207  config_changed = true;
208  }
209 
210  // (re)run the initialization stuff if
211  // - this is the first event
212  // - or the HLT table has changed
213  // - or selected trigger bits come from AlCaRecoTriggerBitsRcd and these changed
214  if (config_changed or (watchAlCaRecoTriggerBitsRcd_ and watchAlCaRecoTriggerBitsRcd_->check(iSetup))) {
215  this->init(*trh, iSetup, triggerNames);
216  }
217  unsigned int n = HLTPathsByName_.size();
218  unsigned int nbad = 0;
219  unsigned int fired = 0;
220 
221  // count invalid and fired triggers
222  for (unsigned int i = 0; i < n; i++)
223  if (HLTPathsByIndex_[i] == (unsigned int) -1)
224  ++nbad;
225  else if (trh->accept(HLTPathsByIndex_[i]))
226  ++fired;
227 
228  if ((nbad > 0) and (config_changed or throw_)) {
229  // only generate the error message if it's actually going to be used
230  std::string message;
231 
232  for (unsigned int i = 0; i < n; i++)
233  if (HLTPathsByIndex_[i] == (unsigned int) -1)
234  message += HLTPathsByName_[i] + " ";
235 
236  if (config_changed) {
237  LogTrace("HLTHighLevel")
238  << " HLTHighLevel [instance: " << moduleLabel()
239  << " - path: " << pathName()
240  << "] configured with " << nbad
241  << "/" << n
242  << " unknown HLT path names: " << message;
243  }
244 
245  if (throw_) {
246  throw cms::Exception("Configuration")
247  << " HLTHighLevel [instance: " << moduleLabel()
248  << " - path: " << pathName()
249  << "] configured with " << nbad
250  << "/" << n
251  << " unknown HLT path names: " << message;
252  }
253  }
254 
255  // Boolean filter result (always at least one trigger)
256  const bool accept( (fired > 0) and ( andOr_ or (fired == n-nbad) ) );
257  LogDebug("HLTHighLevel") << "Accept = " << std::boolalpha << accept;
258 
259  return accept;
260 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:199
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool andOr_
false = and-mode (all requested triggers), true = or-mode (at least one)
Definition: HLTHighLevel.h:64
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
std::string encode() const
Definition: InputTag.cc:72
std::string const & moduleLabel() const
std::vector< unsigned int > HLTPathsByIndex_
list of required HLT triggers by HLT index
Definition: HLTHighLevel.h:85
edm::ParameterSetID triggerNamesID_
HLT trigger names.
Definition: HLTHighLevel.h:61
void init(const edm::TriggerResults &results, const edm::EventSetup &iSetup, const edm::TriggerNames &triggerNames)
initialize the trigger conditions (call this if the trigger paths have changed)
Definition: HLTHighLevel.cc:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
std::string const & pathName() const
stolen from HLTFilter
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
bool throw_
throw on any requested trigger being unknown
Definition: HLTHighLevel.h:67
std::vector< std::string > HLTPathsByName_
list of required HLT triggers by HLT name
Definition: HLTHighLevel.h:82
edm::InputTag inputTag_
HLT TriggerResults EDProduct.
Definition: HLTHighLevel.h:58
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchAlCaRecoTriggerBitsRcd_
Watcher to be created and used if &#39;eventSetupPathsKey_&#39; non empty:
Definition: HLTHighLevel.h:76
void HLTHighLevel::init ( const edm::TriggerResults results,
const edm::EventSetup iSetup,
const edm::TriggerNames triggerNames 
)
private

initialize the trigger conditions (call this if the trigger paths have changed)

Definition at line 76 of file HLTHighLevel.cc.

References andOr_, edm::InputTag::encode(), eventSetupPathsKey_, edm::hlt::Exception, HLTPathsByIndex_, HLTPathsByName_, HLTPatterns_, i, inputTag_, edm::is_glob(), LogDebug, LogTrace, match(), n, pathsFromSetup(), listBenchmarks::pattern, edm::regexMatch(), edm::HLTGlobalStatus::size(), throw_, edm::TriggerNames::triggerIndex(), edm::TriggerNames::triggerName(), edm::TriggerNames::triggerNames(), and TrackValidation_HighPurity_cff::valid.

Referenced by filter().

79 {
80  unsigned int n;
81 
82  // clean up old data
83  HLTPathsByName_.clear();
84  HLTPathsByIndex_.clear();
85 
86  // Overwrite paths from EventSetup via AlCaRecoTriggerBitsRcd if configured:
87  if (eventSetupPathsKey_.size()) {
89  }
90 
91  if (HLTPatterns_.empty()) {
92  // for empty input vector, default to all HLT trigger paths
93  n = result.size();
94  HLTPathsByName_.resize(n);
95  HLTPathsByIndex_.resize(n);
96  for (unsigned int i = 0; i < n; ++i) {
97  HLTPathsByName_[i] = triggerNames.triggerName(i);
98  HLTPathsByIndex_[i] = i;
99  }
100  } else {
101  // otherwise, expand wildcards in trigger names...
102  BOOST_FOREACH(const std::string & pattern, HLTPatterns_) {
103  if (edm::is_glob(pattern)) {
104  // found a glob pattern, expand it
105  std::vector< std::vector<std::string>::const_iterator > matches = edm::regexMatch(triggerNames.triggerNames(), pattern);
106  if (matches.empty()) {
107  // pattern does not match any trigger paths
108  if (throw_)
109  throw cms::Exception("Configuration") << "requested pattern \"" << pattern << "\" does not match any HLT paths";
110  else
111  edm::LogInfo("Configuration") << "requested pattern \"" << pattern << "\" does not match any HLT paths";
112  } else {
113  // store the matching patterns
114  BOOST_FOREACH(std::vector<std::string>::const_iterator match, matches)
115  HLTPathsByName_.push_back(*match);
116  }
117  } else {
118  // found a trigger name, just copy it
119  HLTPathsByName_.push_back(pattern);
120  }
121  }
122  n = HLTPathsByName_.size();
123 
124  // ...and get hold of trigger indices
125  bool valid = false;
126  HLTPathsByIndex_.resize(n);
127  for (unsigned int i = 0; i < HLTPathsByName_.size(); i++) {
128  HLTPathsByIndex_[i] = triggerNames.triggerIndex(HLTPathsByName_[i]);
129  if (HLTPathsByIndex_[i] < result.size()) {
130  valid = true;
131  } else {
132  // trigger path not found
133  HLTPathsByIndex_[i] = (unsigned int) -1;
134  if (throw_)
135  throw cms::Exception("Configuration") << "requested HLT path \"" << HLTPathsByName_[i] << "\" does not exist";
136  else
137  edm::LogInfo("Configuration") << "requested HLT path \"" << HLTPathsByName_[i] << "\" does not exist";
138  }
139  }
140 
141  if (not valid) {
142  // no point in throwing - if requested, it should have already happened
143  edm::LogWarning("Configuration") << "none of the requested paths and pattern match any HLT path - no events will be selected";
144  }
145 
146  }
147 
148  // report on what is finally used
149  LogDebug("HLTHighLevel") << "HLT trigger paths: " + inputTag_.encode()
150  << " - Number of paths: " << n
151  << " - andOr mode: " << andOr_
152  << " - throw mode: " << throw_;
153 
154  LogTrace("HLTHighLevel") << "The HLT trigger paths (# index name):";
155  for (unsigned int i = 0; i < n; ++i)
156  if (HLTPathsByIndex_[i] == (unsigned int) -1)
157  LogTrace("HLTHighLevel") << " n/a " << HLTPathsByName_[i];
158  else
159  LogTrace("HLTHighLevel") << " " << std::setw(4) << HLTPathsByIndex_[i] << " " << HLTPathsByName_[i];
160 
161 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:18
bool andOr_
false = and-mode (all requested triggers), true = or-mode (at least one)
Definition: HLTHighLevel.h:64
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
std::string encode() const
Definition: InputTag.cc:72
std::vector< std::string > pathsFromSetup(const std::string &key, const edm::EventSetup &iSetup) const
get HLTPaths with key &#39;key&#39; from EventSetup (AlCaRecoTriggerBitsRcd)
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
tuple result
Definition: query.py:137
std::vector< unsigned int > HLTPathsByIndex_
list of required HLT triggers by HLT index
Definition: HLTHighLevel.h:85
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, boost::regex const &regexp)
Definition: RegexMatch.cc:30
#define LogTrace(id)
const std::string eventSetupPathsKey_
not empty =&gt; use read paths from AlCaRecoTriggerBitsRcd via this key
Definition: HLTHighLevel.h:74
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
bool throw_
throw on any requested trigger being unknown
Definition: HLTHighLevel.h:67
std::vector< std::string > HLTPathsByName_
list of required HLT triggers by HLT name
Definition: HLTHighLevel.h:82
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
std::vector< std::string > HLTPatterns_
input patterns that will be expanded into trigger names
Definition: HLTHighLevel.h:79
edm::InputTag inputTag_
HLT TriggerResults EDProduct.
Definition: HLTHighLevel.h:58
std::string const & HLTHighLevel::moduleLabel ( ) const
private

Definition at line 267 of file HLTHighLevel.cc.

References edm::EDFilter::currentContext(), and edm::CurrentProcessingContext::moduleLabel().

Referenced by filter(), and pathsFromSetup().

267  {
268  return * currentContext()->moduleLabel();
269 }
std::string const * moduleLabel() const
CurrentProcessingContext const * currentContext() const
Definition: EDFilter.cc:115
std::string const & HLTHighLevel::pathName ( ) const
private

stolen from HLTFilter

Definition at line 263 of file HLTHighLevel.cc.

References edm::EDFilter::currentContext(), and edm::CurrentProcessingContext::pathName().

Referenced by filter(), and pathsFromSetup().

263  {
264  return * currentContext()->pathName();
265 }
std::string const * pathName() const
CurrentProcessingContext const * currentContext() const
Definition: EDFilter.cc:115
std::vector< std::string > HLTHighLevel::pathsFromSetup ( const std::string &  key,
const edm::EventSetup iSetup 
) const

get HLTPaths with key 'key' from EventSetup (AlCaRecoTriggerBitsRcd)

Definition at line 165 of file HLTHighLevel.cc.

References edm::hlt::Exception, edm::EventSetup::get(), moduleLabel(), and pathName().

Referenced by init().

166 {
167  // Get map of strings to concatenated list of names of HLT paths from EventSetup:
169  iSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
170  typedef std::map<std::string, std::string> TriggerMap;
171  const TriggerMap &triggerMap = triggerBits->m_alcarecoToTrig;
172 
173  TriggerMap::const_iterator listIter = triggerMap.find(key);
174  if (listIter == triggerMap.end()) {
175  throw cms::Exception("Configuration")
176  << " HLTHighLevel [instance: " << moduleLabel() << " - path: " << pathName()
177  << "]: No triggerList with key " << key << " in AlCaRecoTriggerBitsRcd";
178  }
179 
180  // We must avoid a map<string,vector<string> > in DB for performance reason,
181  // so the paths are mapped into one string that we have to decompose:
182  return triggerBits->decompose(listIter->second);
183 }
std::string const & moduleLabel() const
const T & get() const
Definition: EventSetup.h:55
std::string const & pathName() const
stolen from HLTFilter
list key
Definition: combine.py:13

Member Data Documentation

bool HLTHighLevel::andOr_
private

false = and-mode (all requested triggers), true = or-mode (at least one)

Definition at line 64 of file HLTHighLevel.h.

Referenced by filter(), and init().

const std::string HLTHighLevel::eventSetupPathsKey_
private

not empty => use read paths from AlCaRecoTriggerBitsRcd via this key

Definition at line 74 of file HLTHighLevel.h.

Referenced by HLTHighLevel(), and init().

std::vector<unsigned int> HLTHighLevel::HLTPathsByIndex_
private

list of required HLT triggers by HLT index

Definition at line 85 of file HLTHighLevel.h.

Referenced by filter(), and init().

std::vector<std::string> HLTHighLevel::HLTPathsByName_
private

list of required HLT triggers by HLT name

Definition at line 82 of file HLTHighLevel.h.

Referenced by filter(), and init().

std::vector<std::string> HLTHighLevel::HLTPatterns_
private

input patterns that will be expanded into trigger names

Definition at line 79 of file HLTHighLevel.h.

Referenced by HLTHighLevel(), and init().

edm::InputTag HLTHighLevel::inputTag_
private

HLT TriggerResults EDProduct.

Definition at line 58 of file HLTHighLevel.h.

Referenced by filter(), and init().

bool HLTHighLevel::throw_
private

throw on any requested trigger being unknown

Definition at line 67 of file HLTHighLevel.h.

Referenced by filter(), and init().

edm::ParameterSetID HLTHighLevel::triggerNamesID_
private

HLT trigger names.

Definition at line 61 of file HLTHighLevel.h.

Referenced by filter().

edm::ESWatcher<AlCaRecoTriggerBitsRcd>* HLTHighLevel::watchAlCaRecoTriggerBitsRcd_
private

Watcher to be created and used if 'eventSetupPathsKey_' non empty:

Definition at line 76 of file HLTHighLevel.h.

Referenced by filter(), HLTHighLevel(), and ~HLTHighLevel().