CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HltComparator Class Reference

#include <HltComparator.h>

Inheritance diagram for HltComparator:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HltComparator (const edm::ParameterSet &)
 
 ~HltComparator () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
std::string formatResult (const unsigned int)
 
void initialise (const edm::TriggerResults &, const edm::TriggerResults &, edm::Event &e)
 
bool verbose () const
 

Private Attributes

std::vector< TH1F * > comparisonHists_
 
edm::EDGetTokenT< edm::TriggerResultshltOfflineResults_
 
edm::EDGetTokenT< edm::TriggerResultshltOnlineResults_
 
bool init_
 
unsigned int numTriggers_
 
std::vector< std::string > offlineActualNames_
 
std::vector< std::string > onlineActualNames_
 
std::vector< unsigned int > onlineToOfflineBitMappings_
 
std::vector< std::string > skipPathList_
 
std::map< unsigned int, std::map< std::string, unsigned int > > triggerComparisonErrors_
 
std::vector< std::string > usePathList_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 15 of file HltComparator.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file HltComparator.cc.

37  : hltOnlineResults_(consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("OnlineResults"))),
38  hltOfflineResults_(consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("OfflineResults"))),
39  init_(false),
40  verbose_(iConfig.getUntrackedParameter<bool>("verbose")),
41  skipPathList_(iConfig.getUntrackedParameter<std::vector<std::string>>("skipPaths")),
42  usePathList_(iConfig.getUntrackedParameter<std::vector<std::string>>("usePaths")) {
43  // std::cout << " HERE I AM " << std::endl;
44  produces<StringCollection>("failedTriggerDescription");
45  // std::cout << " HERE I GO " << std::endl;
46 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::TriggerResults > hltOnlineResults_
Definition: HltComparator.h:21
edm::EDGetTokenT< edm::TriggerResults > hltOfflineResults_
Definition: HltComparator.h:22
std::vector< std::string > usePathList_
Definition: HltComparator.h:36
std::vector< std::string > skipPathList_
Definition: HltComparator.h:35
HltComparator::~HltComparator ( )
override

Definition at line 48 of file HltComparator.cc.

48 {}

Member Function Documentation

void HltComparator::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 249 of file HltComparator.cc.

249 {}
void HltComparator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 252 of file HltComparator.cc.

References gather_cfg::cout, formatResult(), and triggerComparisonErrors_.

252  {
253 #ifdef NOTDEF
254  std::cout << "HLT-Compare ---------- Trigger Comparison Summary ----------" << std::endl;
255  std::cout << "HLT-Compare The following events had trigger mismatches:" << std::endl;
256  std::map<unsigned int, std::map<std::string, unsigned int>>::iterator it;
257  for (it = triggerComparisonErrors_.begin(); it != triggerComparisonErrors_.end(); ++it) {
258  std::cout << "HLT-Compare Event: " << it->first << std::endl;
259  std::map<std::string, unsigned int>::iterator jt;
260  for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
261  std::cout << "HLT-Compare Path: " << jt->first << " : " << formatResult(jt->second) << std::endl;
262  }
263  }
264  std::cout << "HLT-Compare ------------ End Trigger Comparison ------------" << std::endl;
265 #endif // NOTDEF
266 }
std::string formatResult(const unsigned int)
std::map< unsigned int, std::map< std::string, unsigned int > > triggerComparisonErrors_
Definition: HltComparator.h:29
bool HltComparator::filter ( edm::Event event,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 146 of file HltComparator.cc.

References edm::HLTGlobalStatus::accept(), comparisonHists_, gather_cfg::cout, edm::HLTGlobalStatus::error(), spr::find(), formatResult(), hltOfflineResults_, hltOnlineResults_, mps_fire::i, init_, initialise(), kOnErrorOffRun, kOnFailOffPass, kOnNotOffRun, kOnPassOffFail, kOnRunOffError, kOnRunOffNot, eostools::move(), numTriggers_, onlineActualNames_, onlineToOfflineBitMappings_, mps_fire::result, skipPathList_, triggerComparisonErrors_, usePathList_, verbose(), and edm::HLTGlobalStatus::wasrun().

146  {
147  // std::cout << "top of the filter " << std::endl;
148  // Get trigger results
149  edm::Handle<edm::TriggerResults> onlineResults;
150  edm::Handle<edm::TriggerResults> offlineResults;
151  event.getByToken(hltOnlineResults_, onlineResults);
152  event.getByToken(hltOfflineResults_, offlineResults);
153 
154  std::unique_ptr<StringCollection> resultDescription(new StringCollection);
155 
156  // Initialise comparator if required
157  if (!init_) {
158  initialise(*onlineResults, *offlineResults, event);
159  }
160 
161  // Perform trigger checks
162  bool hasDisagreement = false;
163  for (unsigned int i = 0; i < numTriggers_; ++i) {
164  unsigned int offlineTriggerBit = onlineToOfflineBitMappings_[i];
165 
166  bool onRun = onlineResults->wasrun(i);
167  bool offRun = offlineResults->wasrun(offlineTriggerBit);
168  bool onAccept = onlineResults->accept(i);
169  bool offAccept = offlineResults->accept(offlineTriggerBit);
170  bool onError = onlineResults->error(i);
171  bool offError = offlineResults->error(offlineTriggerBit);
172 
173  int result = -1;
174  if (onError || offError) {
175  if (onError && offError) {
176  result = 4;
177  } else if (onError) {
178  result = 6;
179  } else {
180  result = 5;
181  }
182  } else if ((!onRun) || (!offRun)) {
183  if ((!onRun) && (!offRun)) {
184  result = 9;
185  } else if (!onRun) {
186  result = 8;
187  } else {
188  result = 7;
189  }
190  } else {
191  if (onAccept && offAccept) {
192  result = 0;
193  } else if ((!onAccept) && (!offAccept)) {
194  result = 1;
195  } else if (onAccept) {
196  result = 2;
197  } else {
198  result = 3;
199  }
200  }
201 
202  // Fill the results histogram
203  comparisonHists_[i]->Fill(result);
204 
205  // if the online-offline comparison results in a failure, we
206  // want to send the result to a special stream. Hence we _pass_ the filter.
207  // If it all worked as expected the filter fails and the event doesn't go
208  // to the output stream.
209  if ((result == kOnPassOffFail) || (result == kOnFailOffPass) || (result == kOnRunOffError) ||
210  (result == kOnErrorOffRun) || (result == kOnRunOffNot) || (result == kOnNotOffRun)) {
211  // is this one we should ignore? check the skip list
212  if (verbose()) {
213  std::cout << "Found disagreemenet " << result << ", name is " << onlineActualNames_[i] << std::endl;
214  }
215  std::ostringstream desc;
216  desc << onlineActualNames_[i] << ":" << formatResult(result);
217  resultDescription->push_back(desc.str());
218  if (std::find(skipPathList_.begin(), skipPathList_.end(), onlineActualNames_[i]) == skipPathList_.end()) {
219  if (!usePathList_.empty()) {
220  // only use specified paths to debug
221  if (std::find(usePathList_.begin(), usePathList_.end(), onlineActualNames_[i]) != usePathList_.end())
222  hasDisagreement = true;
223  } else
224  hasDisagreement = true;
225  }
226  }
227 
228  // Record the trigger error code
229  // I think this should be result > 2? (pw)
230  if (verbose() && (result > 1)) {
231  std::cout << "HLT-Compare: Event " << event.id().event() << " Path " << onlineActualNames_[i] << " "
232  << formatResult(result) << std::endl;
233 #ifdef NOTDEF
234  triggerComparisonErrors_[event.id().event()][onlineActualNames_[i]] = result;
235 #endif // NOTDEF
236  }
237  }
238 
239  // std::cout << " HERE I STAY " << std::endl;
240  event.put(std::move(resultDescription), "failedTriggerDescription");
241  // std::cout << " HERE I WENT " << std::endl;
242 
243  if (hasDisagreement)
244  return true;
245  else
246  return false;
247 }
bool wasrun() const
Was at least one path run?
unsigned int numTriggers_
Definition: HltComparator.h:38
std::vector< unsigned int > onlineToOfflineBitMappings_
Definition: HltComparator.h:26
bool accept() const
Has at least one path accepted the event?
edm::EDGetTokenT< edm::TriggerResults > hltOnlineResults_
Definition: HltComparator.h:21
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool verbose() const
Definition: HltComparator.h:33
std::vector< TH1F * > comparisonHists_
Definition: HltComparator.h:28
edm::EDGetTokenT< edm::TriggerResults > hltOfflineResults_
Definition: HltComparator.h:22
std::vector< std::string > onlineActualNames_
Definition: HltComparator.h:24
std::vector< std::string > usePathList_
Definition: HltComparator.h:36
bool error() const
Has any path encountered an error (exception)
void initialise(const edm::TriggerResults &, const edm::TriggerResults &, edm::Event &e)
std::string formatResult(const unsigned int)
std::vector< std::string > skipPathList_
Definition: HltComparator.h:35
std::vector< std::string > StringCollection
std::map< unsigned int, std::map< std::string, unsigned int > > triggerComparisonErrors_
Definition: HltComparator.h:29
def move(src, dest)
Definition: eostools.py:511
std::string HltComparator::formatResult ( const unsigned int  i)
private

Definition at line 110 of file HltComparator.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endJob(), and filter().

110  {
111  switch (i) {
112  case 0:
113  return std::string("OnPass_OffPass");
114  break;
115  case 1:
116  return std::string("OnFail_OffFail");
117  break;
118  case 2:
119  return std::string("OnPass_OffFail");
120  break;
121  case 3:
122  return std::string("OnFail_OffPass");
123  break;
124  case 4:
125  return std::string("OnError_OffError");
126  break;
127  case 5:
128  return std::string("OnRun_OffError");
129  break;
130  case 6:
131  return std::string("OnError_OffRun");
132  break;
133  case 7:
134  return std::string("OnRun_OffNotRun");
135  break;
136  case 8:
137  return std::string("OnNotRun_OffRun");
138  break;
139  case 9:
140  return std::string("OnNotRun_OffNotRun");
141  break;
142  }
143  return std::string("CODE NOT KNOWN");
144 }
void HltComparator::initialise ( const edm::TriggerResults onlineResults,
const edm::TriggerResults offlineResults,
edm::Event e 
)
private

Definition at line 51 of file HltComparator.cc.

References a, comparisonHists_, Exception, h, mps_fire::i, init_, TFileService::make(), numTriggers_, offlineActualNames_, onlineActualNames_, onlineToOfflineBitMappings_, edm::TriggerNames::triggerNames(), and edm::Event::triggerNames().

Referenced by filter().

53  {
54  init_ = true;
55 
56  // Get trigger names
57  const edm::TriggerNames &onlineTriggerNames = e.triggerNames(onlineResults);
58  const edm::TriggerNames &offlineTriggerNames = e.triggerNames(offlineResults);
59  onlineActualNames_ = onlineTriggerNames.triggerNames();
60  offlineActualNames_ = offlineTriggerNames.triggerNames();
62 
63  // do we need to throw? I guess the whole job is crap if this happens.
64  // sort of assumes we're the only game in town.
65  if (numTriggers_ != offlineActualNames_.size()) {
66  throw cms::Exception("IncorrectTriggers") << "Online had " << numTriggers_ << "triggers, "
67  << "Offline had " << offlineActualNames_.size() << "triggers";
68  }
69 
70  // Create bit mappings
71  std::map<std::string, unsigned int> offlineNameBitMap;
72  for (unsigned int i = 0; i < numTriggers_; ++i) {
73  offlineNameBitMap[offlineActualNames_[i]] = i;
74  }
75  for (unsigned int i = 0; i < numTriggers_; ++i) {
76  // Find offline position for fixed online bit
77  std::map<std::string, unsigned int>::iterator it = offlineNameBitMap.find(onlineActualNames_[i]);
78  if (it != offlineNameBitMap.end()) {
79  onlineToOfflineBitMappings_.push_back(it->second);
80  } else {
81  throw cms::Exception("IncorrectTriggers") << "Online trigger path " << onlineActualNames_[i]
82  << " not found in Offline "
83  "processing";
84  }
85  }
86 
87  // Create histograms
89  for (std::vector<std::string>::iterator it = onlineActualNames_.begin(); it != onlineActualNames_.end(); ++it) {
90  // Bin descriptions: OnOfPass, OnOffFail, OnPassOffFail, OnFailOffPass,
91  // OnOffError, OnRunOffError, OnErrorOffRun, OnRunOffNot OnNotOffRun
92  // OnNotOffNot
93  TH1F *h = fs->make<TH1F>(it->c_str(), it->c_str(), 10, 0, 10);
94  TAxis *a = h->GetXaxis();
95  a->SetBinLabel(1, "OnPass_OffPass");
96  a->SetBinLabel(2, "OnFail_OffFail");
97  a->SetBinLabel(3, "OnPass_OffFail");
98  a->SetBinLabel(4, "OnFail_OffPass");
99  a->SetBinLabel(5, "OnError_OffError");
100  a->SetBinLabel(6, "OnRun_OffError");
101  a->SetBinLabel(7, "OnError_OffRun");
102  a->SetBinLabel(8, "OnRun_OffNotRun");
103  a->SetBinLabel(9, "OnNotRun_OffRun");
104  a->SetBinLabel(10, "OnNotRun_OffNotRun");
105  comparisonHists_.push_back(h);
106  }
107 }
unsigned int numTriggers_
Definition: HltComparator.h:38
std::vector< unsigned int > onlineToOfflineBitMappings_
Definition: HltComparator.h:26
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
Strings const & triggerNames() const
Definition: TriggerNames.cc:20
std::vector< TH1F * > comparisonHists_
Definition: HltComparator.h:28
std::vector< std::string > onlineActualNames_
Definition: HltComparator.h:24
std::vector< std::string > offlineActualNames_
Definition: HltComparator.h:25
double a
Definition: hdecay.h:121
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:256
bool HltComparator::verbose ( ) const
inlineprivate

Definition at line 33 of file HltComparator.h.

References verbose_.

Referenced by filter().

33 { return verbose_; }

Member Data Documentation

std::vector<TH1F *> HltComparator::comparisonHists_
private

Definition at line 28 of file HltComparator.h.

Referenced by filter(), and initialise().

edm::EDGetTokenT<edm::TriggerResults> HltComparator::hltOfflineResults_
private

Definition at line 22 of file HltComparator.h.

Referenced by filter().

edm::EDGetTokenT<edm::TriggerResults> HltComparator::hltOnlineResults_
private

Definition at line 21 of file HltComparator.h.

Referenced by filter().

bool HltComparator::init_
private

Definition at line 31 of file HltComparator.h.

Referenced by filter(), and initialise().

unsigned int HltComparator::numTriggers_
private

Definition at line 38 of file HltComparator.h.

Referenced by filter(), and initialise().

std::vector<std::string> HltComparator::offlineActualNames_
private

Definition at line 25 of file HltComparator.h.

Referenced by initialise().

std::vector<std::string> HltComparator::onlineActualNames_
private

Definition at line 24 of file HltComparator.h.

Referenced by filter(), and initialise().

std::vector<unsigned int> HltComparator::onlineToOfflineBitMappings_
private

Definition at line 26 of file HltComparator.h.

Referenced by filter(), and initialise().

std::vector<std::string> HltComparator::skipPathList_
private

Definition at line 35 of file HltComparator.h.

Referenced by filter().

std::map<unsigned int, std::map<std::string, unsigned int> > HltComparator::triggerComparisonErrors_
private

Definition at line 29 of file HltComparator.h.

Referenced by endJob(), and filter().

std::vector<std::string> HltComparator::usePathList_
private

Definition at line 36 of file HltComparator.h.

Referenced by filter().

bool HltComparator::verbose_
private

Definition at line 32 of file HltComparator.h.

Referenced by verbose().