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
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 ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 
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::TriggerResults
hltOfflineResults_
 
edm::EDGetTokenT
< edm::TriggerResults
hltOnlineResults_
 
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
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 &)
 
- 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 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 32 of file HltComparator.cc.

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

Definition at line 46 of file HltComparator.cc.

47 {
48 }

Member Function Documentation

void HltComparator::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 281 of file HltComparator.cc.

282 {
283 }
void HltComparator::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 287 of file HltComparator.cc.

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

288 {
289 #ifdef NOTDEF
290  std::cout << "HLT-Compare ---------- Trigger Comparison Summary ----------" << std::endl;
291  std::cout << "HLT-Compare The following events had trigger mismatches:" << std::endl;
292  std::map<unsigned int, std::map<std::string, unsigned int> >::iterator it;
293  for(it = triggerComparisonErrors_.begin(); it != triggerComparisonErrors_.end(); ++it) {
294  std::cout << "HLT-Compare Event: " << it->first << std::endl;
295  std::map<std::string, unsigned int>::iterator jt;
296  for(jt = it->second.begin(); jt != it->second.end(); ++jt) {
297  std::cout << "HLT-Compare Path: " << jt->first << " : " << formatResult(jt->second) << std::endl;
298  }
299  }
300  std::cout << "HLT-Compare ------------ End Trigger Comparison ------------" << std::endl;
301 #endif //NOTDEF
302 }
std::string formatResult(const unsigned int)
tuple cout
Definition: gather_cfg.py:145
std::map< unsigned int, std::map< std::string, unsigned int > > triggerComparisonErrors_
Definition: HltComparator.h:30
bool HltComparator::filter ( edm::Event event,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDFilter.

Definition at line 157 of file HltComparator.cc.

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

159 {
160  //std::cout << "top of the filter " << std::endl;
161  // Get trigger results
162  edm::Handle<edm::TriggerResults> onlineResults;
163  edm::Handle<edm::TriggerResults> offlineResults;
164  event.getByToken(hltOnlineResults_, onlineResults);
165  event.getByToken(hltOfflineResults_, offlineResults);
166 
167  std::auto_ptr<StringCollection> resultDescription(new StringCollection);
168 
169  // Initialise comparator if required
170  if (!init_) {
171  initialise(*onlineResults, *offlineResults, event);
172  }
173 
174  // Perform trigger checks
175  bool hasDisagreement = false;
176  for (unsigned int i = 0; i < numTriggers_; ++i) {
177  unsigned int offlineTriggerBit = onlineToOfflineBitMappings_[i];
178 
179  bool onRun = onlineResults->wasrun(i);
180  bool offRun = offlineResults->wasrun(offlineTriggerBit);
181  bool onAccept = onlineResults->accept(i);
182  bool offAccept = offlineResults->accept(offlineTriggerBit);
183  bool onError = onlineResults->error(i);
184  bool offError = offlineResults->error(offlineTriggerBit);
185 
186  int result = -1;
187  if (onError || offError) {
188  if (onError && offError) {
189  result = 4;
190  }
191  else if (onError) {
192  result = 6;
193  }
194  else {
195  result = 5;
196  }
197  }
198  else if ((!onRun) || (!offRun)) {
199  if ((!onRun) && (!offRun)) {
200  result = 9;
201  }
202  else if (!onRun) {
203  result = 8;
204  }
205  else {
206  result = 7;
207  }
208  }
209  else {
210  if (onAccept && offAccept) {
211  result = 0;
212  }
213  else if ((!onAccept) && (!offAccept)) {
214  result = 1;
215  }
216  else if (onAccept) {
217  result = 2;
218  }
219  else {
220  result = 3;
221  }
222  }
223 
224  // Fill the results histogram
225  comparisonHists_[i]->Fill(result);
226 
227  // if the online-offline comparison results in a failure, we
228  // want to send the result to a special stream. Hence we _pass_ the filter.
229  // If it all worked as expected the filter fails and the event doesn't go
230  // to the output stream.
231  if ( (result == kOnPassOffFail) || ( result == kOnFailOffPass ) ||
232  (result == kOnRunOffError) || ( result == kOnErrorOffRun ) ||
233  (result == kOnRunOffNot) || ( result == kOnNotOffRun ) ) {
234  // is this one we should ignore? check the skip list
235  if ( verbose() ) {
236  std::cout << "Found disagreemenet " << result << ", name is "
238  << std::endl;
239  }
240  std::ostringstream desc;
241  desc << onlineActualNames_[i] << ":" << formatResult(result);
242  resultDescription->push_back(desc.str());
243  if ( std::find(skipPathList_.begin(), skipPathList_.end(),
244  onlineActualNames_[i]) == skipPathList_.end() ) {
245 
246  if (usePathList_.size()!=0){
247  //only use specified paths to debug
248  if (std::find(usePathList_.begin(), usePathList_.end(),
249  onlineActualNames_[i]) != usePathList_.end() )
250  hasDisagreement = true;
251  }
252  else
253  hasDisagreement = true;
254  }
255  }
256 
257  // Record the trigger error code
258  // I think this should be result > 2? (pw)
259  if (verbose() && (result > 1)) {
260  std::cout << "HLT-Compare: Event " << event.id().event()
261  << " Path " << onlineActualNames_[i] << " "
262  << formatResult(result) << std::endl;
263 #ifdef NOTDEF
264  triggerComparisonErrors_[event.id().event()][onlineActualNames_[i]] = result;
265 #endif // NOTDEF
266  }
267  }
268 
269  //std::cout << " HERE I STAY " << std::endl;
270  event.put(resultDescription,"failedTriggerDescription");
271  //std::cout << " HERE I WENT " << std::endl;
272 
273  if ( hasDisagreement )
274  return true;
275  else
276  return false;
277 }
int i
Definition: DBlmapReader.cc:9
unsigned int numTriggers_
Definition: HltComparator.h:39
std::vector< unsigned int > onlineToOfflineBitMappings_
Definition: HltComparator.h:27
edm::EDGetTokenT< edm::TriggerResults > hltOnlineResults_
Definition: HltComparator.h:22
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< TH1F * > comparisonHists_
Definition: HltComparator.h:29
tuple result
Definition: mps_fire.py:84
bool verbose() const
Definition: HltComparator.h:34
edm::EDGetTokenT< edm::TriggerResults > hltOfflineResults_
Definition: HltComparator.h:23
std::vector< std::string > onlineActualNames_
Definition: HltComparator.h:25
std::vector< std::string > usePathList_
Definition: HltComparator.h:37
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:36
std::vector< std::string > StringCollection
tuple cout
Definition: gather_cfg.py:145
std::map< unsigned int, std::map< std::string, unsigned int > > triggerComparisonErrors_
Definition: HltComparator.h:30
std::string HltComparator::formatResult ( const unsigned int  i)
private

Definition at line 119 of file HltComparator.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endJob(), and filter().

120 {
121  switch (i) {
122  case 0:
123  return std::string("OnPass_OffPass");
124  break;
125  case 1:
126  return std::string("OnFail_OffFail");
127  break;
128  case 2:
129  return std::string("OnPass_OffFail");
130  break;
131  case 3:
132  return std::string("OnFail_OffPass");
133  break;
134  case 4:
135  return std::string("OnError_OffError");
136  break;
137  case 5:
138  return std::string("OnRun_OffError");
139  break;
140  case 6:
141  return std::string("OnError_OffRun");
142  break;
143  case 7:
144  return std::string("OnRun_OffNotRun");
145  break;
146  case 8:
147  return std::string("OnNotRun_OffRun");
148  break;
149  case 9:
150  return std::string("OnNotRun_OffNotRun");
151  break;
152  }
153  return std::string("CODE NOT KNOWN");
154 }
int i
Definition: DBlmapReader.cc:9
void HltComparator::initialise ( const edm::TriggerResults onlineResults,
const edm::TriggerResults offlineResults,
edm::Event e 
)
private

Definition at line 52 of file HltComparator.cc.

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

Referenced by filter().

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

Definition at line 34 of file HltComparator.h.

References verbose_.

Referenced by filter().

34 { return verbose_; }

Member Data Documentation

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

Definition at line 29 of file HltComparator.h.

Referenced by filter(), and initialise().

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

Definition at line 23 of file HltComparator.h.

Referenced by filter().

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

Definition at line 22 of file HltComparator.h.

Referenced by filter().

bool HltComparator::init_
private

Definition at line 32 of file HltComparator.h.

Referenced by filter(), and initialise().

unsigned int HltComparator::numTriggers_
private

Definition at line 39 of file HltComparator.h.

Referenced by filter(), and initialise().

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

Definition at line 26 of file HltComparator.h.

Referenced by initialise().

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

Definition at line 25 of file HltComparator.h.

Referenced by filter(), and initialise().

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

Definition at line 27 of file HltComparator.h.

Referenced by filter(), and initialise().

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

Definition at line 36 of file HltComparator.h.

Referenced by filter().

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

Definition at line 30 of file HltComparator.h.

Referenced by endJob(), and filter().

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

Definition at line 37 of file HltComparator.h.

Referenced by filter().

bool HltComparator::verbose_
private

Definition at line 33 of file HltComparator.h.

Referenced by verbose().