Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-08 00:35:14

0001 // -*- C++ -*-
0002 //
0003 // Implementation:
0004 //
0005 // Original Author:  Jim Kowalkowski
0006 //
0007 
0008 #include "FWCore/Framework/interface/TriggerNamesService.h"
0009 #include "DataFormats/Common/interface/TriggerResults.h"
0010 #include "FWCore/ParameterSet/interface/Registry.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 #include "FWCore/Utilities/interface/EDMException.h"
0013 #include "FWCore/Utilities/interface/Algorithms.h"
0014 #include "FWCore/Utilities/interface/path_configuration.h"
0015 
0016 namespace edm {
0017   namespace service {
0018 
0019     TriggerNamesService::TriggerNamesService(const ParameterSet& pset) {
0020       trigger_pset_ = pset.getParameterSet("@trigger_paths");
0021 
0022       trignames_ = trigger_pset_.getParameter<Strings>("@trigger_paths");
0023       end_names_ = pset.getParameter<Strings>("@end_paths");
0024 
0025       ParameterSet defopts;
0026       ParameterSet const& opts = pset.getUntrackedParameterSet("options", defopts);
0027       wantSummary_ = opts.getUntrackedParameter("wantSummary", false);
0028 
0029       process_name_ = pset.getParameter<std::string>("@process_name");
0030 
0031       loadPosMap(trigpos_, trignames_);
0032       loadPosMap(end_pos_, end_names_);
0033 
0034       const unsigned int n(trignames_.size());
0035       for (unsigned int i = 0; i != n; ++i) {
0036         modulenames_.push_back(
0037             path_configuration::configurationToModuleBitPosition(pset.getParameter<Strings>(trignames_[i])));
0038       }
0039       for (unsigned int i = 0; i != end_names_.size(); ++i) {
0040         end_modulenames_.push_back(
0041             path_configuration::configurationToModuleBitPosition(pset.getParameter<Strings>(end_names_[i])));
0042       }
0043     }
0044 
0045     bool TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
0046                                            Strings& trigPaths,
0047                                            bool& fromPSetRegistry) {
0048       // Get the parameter set containing the trigger names from the parameter set registry
0049       // using the ID from TriggerResults as the key used to find it.
0050       ParameterSet const* pset = nullptr;
0051       pset::Registry const* psetRegistry = pset::Registry::instance();
0052       if (nullptr != (pset = psetRegistry->getMapped(triggerResults.parameterSetID()))) {
0053         // Check to make sure the parameter set contains
0054         // a Strings parameter named "trigger_paths".
0055         // We do not want to throw an exception if it is not there
0056         // for reasons of backward compatibility
0057         Strings const& psetNames = pset->getParameterNamesForType<Strings>();
0058         std::string name("@trigger_paths");
0059         if (search_all(psetNames, name)) {
0060           // It is there, get it
0061           trigPaths = pset->getParameter<Strings>("@trigger_paths");
0062 
0063           // This should never happen
0064           if (trigPaths.size() != triggerResults.size()) {
0065             throw edm::Exception(edm::errors::Unknown)
0066                 << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
0067                    "TriggerResults are different sizes.  This should be impossible,\n"
0068                    "please send information to reproduce this problem to\n"
0069                    "the edm developers.\n";
0070           }
0071 
0072           fromPSetRegistry = true;
0073           return true;
0074         }
0075       }
0076 
0077       fromPSetRegistry = false;
0078 
0079       // In older versions of the code the the trigger names were stored
0080       // inside of the TriggerResults object.  This will provide backward
0081       // compatibility.
0082       if (triggerResults.size() == triggerResults.getTriggerNames().size()) {
0083         trigPaths = triggerResults.getTriggerNames();
0084         return true;
0085       }
0086 
0087       return false;
0088     }
0089 
0090     bool TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths) {
0091       bool dummy;
0092       return getTrigPaths(triggerResults, trigPaths, dummy);
0093     }
0094   }  // namespace service
0095 }  // namespace edm