CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Actions.cc
Go to the documentation of this file.
1 
5 #include "boost/lambda/lambda.hpp"
6 
7 #include <vector>
8 #include <iostream>
9 
10 namespace edm {
11  namespace actions {
12  namespace {
13  struct ActionNames {
14  ActionNames():table_(LastCode + 1) {
15  table_[IgnoreCompletely] = "IgnoreCompletely";
16  table_[Rethrow] = "Rethrow";
17  table_[SkipEvent] = "SkipEvent";
18  table_[FailModule] = "FailModule";
19  table_[FailPath] = "FailPath";
20  }
21 
22  typedef std::vector<char const*> Table;
23  Table table_;
24  };
25  }
26 
27  char const* actionName(ActionCodes code) {
28  static ActionNames tab;
29  return static_cast<unsigned int>(code) < tab.table_.size() ? tab.table_[code] : "UnknownAction";
30  }
31  }
32 
34  addDefaults();
35  }
36 
37  namespace {
38  inline void install(actions::ActionCodes code,
40  ParameterSet const& pset) {
41  using boost::lambda::_1;
42  using boost::lambda::var;
43  typedef std::vector<std::string> vstring;
44 
45  // we cannot have parameters in the main process section so look
46  // for an untracked (optional) ParameterSet called "options" for
47  // now. Notice that all exceptions (most actally) throw
48  // edm::Exception with the configuration category. This
49  // category should probably be more specific or a derived
50  // exception type should be used so the catch can be more
51  // specific.
52 
53 // cerr << pset.toString() << std::endl;
54 
55  ParameterSet defopts;
56  ParameterSet const& opts = pset.getUntrackedParameterSet("options", defopts);
57  //cerr << "looking for " << actionName(code) << std::endl;
58  vstring v = opts.getUntrackedParameter(actionName(code),vstring());
59  for_all(v, var(out)[_1] = code);
60 
61  }
62  }
63 
64  ActionTable::ActionTable(ParameterSet const& pset) : map_() {
65  addDefaults();
66 
67  install(actions::SkipEvent, map_, pset);
68  install(actions::Rethrow, map_, pset);
69  install(actions::IgnoreCompletely, map_, pset);
70  install(actions::FailModule, map_, pset);
71  install(actions::FailPath, map_, pset);
72  }
73 
75  using namespace boost::lambda;
76  // populate defaults that are not 'Rethrow'
77  // (There are none as of CMSSW_3_4_X.)
78  // 'Rethrow' is the default default.
79  if(2 <= debugit()) {
80  ActionMap::const_iterator ib(map_.begin()),ie(map_.end());
81  for(;ib != ie; ++ib) {
82  std::cerr << ib->first << ',' << ib->second << '\n';
83  }
84  std::cerr << std::endl;
85  }
86  }
87 
89  }
90 
91  void ActionTable::add(std::string const& category, actions::ActionCodes code) {
92  map_[category] = code;
93  }
94 
95  actions::ActionCodes ActionTable::find(std::string const& category) const {
96  ActionMap::const_iterator i(map_.find(category));
97  return i != map_.end() ? i->second : actions::Rethrow;
98  }
99 
100 }
void add(const std::string &category, actions::ActionCodes code)
Definition: Actions.cc:91
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const char * actionName(ActionCodes code)
Definition: Actions.cc:27
ActionMap map_
Definition: Actions.h:36
roAction_t actions[nactions]
Definition: GenABIO.cc:200
debugvalue debugit
Definition: DebugMacros.cc:13
std::vector< std::string > vstring
Definition: Schedule.cc:136
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
std::map< std::string, actions::ActionCodes > ActionMap
Definition: Actions.h:25
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
tuple pset
Definition: CrabTask.py:85
void addDefaults()
Definition: Actions.cc:74
tuple out
Definition: dbtoconf.py:99
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
actions::ActionCodes find(const std::string &category) const
Definition: Actions.cc:95
Table table_
Definition: Actions.cc:23
mathSSE::Vec4< T > v