00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "FWCore/Framework/interface/TriggerNamesService.h"
00010 #include "DataFormats/Common/interface/TriggerResults.h"
00011 #include "FWCore/ParameterSet/interface/Registry.h"
00012 #include "FWCore/Utilities/interface/ThreadSafeRegistry.h"
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 #include "FWCore/Utilities/interface/Algorithms.h"
00015
00016
00017 namespace edm {
00018 namespace service {
00019
00020 TriggerNamesService::TriggerNamesService(const ParameterSet& pset) {
00021
00022 trigger_pset_ =
00023 pset.getUntrackedParameter<ParameterSet>("@trigger_paths");
00024
00025 trignames_ = trigger_pset_.getParameter<Strings>("@trigger_paths");
00026 end_names_ = pset.getParameter<Strings>("@end_paths");
00027
00028 ParameterSet defopts;
00029 ParameterSet opts =
00030 pset.getUntrackedParameter<ParameterSet>("options", defopts);
00031 wantSummary_ =
00032 opts.getUntrackedParameter("wantSummary",false);
00033
00034 process_name_ = pset.getParameter<std::string>("@process_name");
00035
00036 loadPosMap(trigpos_,trignames_);
00037 loadPosMap(end_pos_,end_names_);
00038
00039 const unsigned int n(trignames_.size());
00040 for(unsigned int i=0;i!=n;++i) {
00041 modulenames_.push_back(pset.getParameter<Strings>(trignames_[i]));
00042 }
00043 }
00044
00045 bool
00046 TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
00047 Strings& trigPaths,
00048 bool& fromPSetRegistry) {
00049
00050
00051
00052 ParameterSet pset;
00053 pset::Registry* psetRegistry = pset::Registry::instance();
00054 if (psetRegistry->getMapped(triggerResults.parameterSetID(),
00055 pset)) {
00056
00057
00058
00059
00060
00061 Strings psetNames = pset.getParameterNamesForType<Strings>();
00062 std::string name("@trigger_paths");
00063 if (search_all(psetNames, name)) {
00064
00065 trigPaths = pset.getParameter<Strings>("@trigger_paths");
00066
00067
00068 if (trigPaths.size() != triggerResults.size()) {
00069 throw edm::Exception(edm::errors::Unknown)
00070 << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
00071 "TriggerResults are different sizes. This should be impossible,\n"
00072 "please send information to reproduce this problem to\n"
00073 "the edm developers.\n";
00074 }
00075
00076 fromPSetRegistry = true;
00077 return true;
00078 }
00079 }
00080
00081 fromPSetRegistry = false;
00082
00083
00084
00085
00086 if (triggerResults.size() == triggerResults.getTriggerNames().size()) {
00087 trigPaths = triggerResults.getTriggerNames();
00088 return true;
00089 }
00090
00091 return false;
00092 }
00093
00094 bool
00095 TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
00096 Strings& trigPaths) {
00097 bool dummy;
00098 return getTrigPaths(triggerResults, trigPaths, dummy);
00099 }
00100 }
00101 }