CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Path.cc
Go to the documentation of this file.
1 
8 
9 #include <algorithm>
10 
11 namespace edm {
12  Path::Path(int bitpos, std::string const& path_name,
13  WorkersInPath const& workers,
14  TrigResPtr trptr,
16  std::shared_ptr<ActivityRegistry> areg,
17  StreamContext const* streamContext,
18  PathContext::PathType pathType) :
19  timesRun_(),
20  timesPassed_(),
21  timesFailed_(),
22  timesExcept_(),
23  state_(hlt::Ready),
24  bitpos_(bitpos),
25  trptr_(trptr),
26  actReg_(areg),
27  act_table_(&actions),
28  workers_(workers),
29  pathContext_(path_name, streamContext, bitpos, pathType) {
30 
31  for (auto& workerInPath : workers_) {
32  workerInPath.setPathContext(&pathContext_);
33  }
34  }
35 
36  Path::Path(Path const& r) :
37  timesRun_(r.timesRun_),
38  timesPassed_(r.timesPassed_),
39  timesFailed_(r.timesFailed_),
40  timesExcept_(r.timesExcept_),
41  state_(r.state_),
42  bitpos_(r.bitpos_),
43  trptr_(r.trptr_),
44  actReg_(r.actReg_),
45  act_table_(r.act_table_),
46  workers_(r.workers_),
47  earlyDeleteHelpers_(r.earlyDeleteHelpers_),
48  pathContext_(r.pathContext_) {
49 
50  for (auto& workerInPath : workers_) {
51  workerInPath.setPathContext(&pathContext_);
52  }
53  }
54 
55 
56  bool
58  int nwrwue,
59  bool isEvent,
60  bool begin,
62  ModuleDescription const& desc,
63  std::string const& id) {
64 
65  exceptionContext(e, isEvent, begin, branchType, desc, id, pathContext_);
66 
67  bool should_continue = true;
68 
69  // there is no support as of yet for specific paths having
70  // different exception behavior
71 
72  // If not processing an event, always rethrow.
74  switch(action) {
76  should_continue = false;
77  edm::printCmsExceptionWarning("FailPath", e);
78  break;
79  }
80  default: {
81  if (isEvent) ++timesExcept_;
83  recordStatus(nwrwue, isEvent);
84  if (action == exception_actions::Rethrow) {
86  if (e.category() == pNF) {
87  std::ostringstream ost;
88  ost << "If you wish to continue processing events after a " << pNF << " exception,\n" <<
89  "add \"SkipEvent = cms.untracked.vstring('ProductNotFound')\" to the \"options\" PSet in the configuration.\n";
90  e.addAdditionalInfo(ost.str());
91  }
92  }
93  throw;
94  }
95  }
96 
97  return should_continue;
98  }
99 
100  void
102  bool isEvent,
103  bool begin,
105  ModuleDescription const& desc,
106  std::string const& id,
107  PathContext const& pathContext) {
108  std::ostringstream ost;
109  if (isEvent) {
110  ost << "Calling event method";
111  }
112  else if (begin && branchType == InRun) {
113  ost << "Calling beginRun";
114  }
115  else if (begin && branchType == InLumi) {
116  ost << "Calling beginLuminosityBlock";
117  }
118  else if (!begin && branchType == InLumi) {
119  ost << "Calling endLuminosityBlock";
120  }
121  else if (!begin && branchType == InRun) {
122  ost << "Calling endRun";
123  }
124  else {
125  // It should be impossible to get here ...
126  ost << "Calling unknown function";
127  }
128  ost << " for module " << desc.moduleName() << "/'" << desc.moduleLabel() << "'";
129  ex.addContext(ost.str());
130  ost.str("");
131  ost << "Running path '" << pathContext.pathName() << "'";
132  ex.addContext(ost.str());
133  ost.str("");
134  ost << "Processing ";
135  ost << id;
136  ex.addContext(ost.str());
137  }
138 
139  void
140  Path::recordStatus(int nwrwue, bool isEvent) {
141  if(isEvent && trptr_) {
142  (*trptr_)[bitpos_]=HLTPathStatus(state_, nwrwue);
143  }
144  }
145 
146  void
147  Path::updateCounters(bool success, bool isEvent) {
148  if (success) {
149  if (isEvent) ++timesPassed_;
150  state_ = hlt::Pass;
151  } else {
152  if(isEvent) ++timesFailed_;
153  state_ = hlt::Fail;
154  }
155  }
156 
157  void
159  using std::placeholders::_1;
161  for_all(workers_, std::bind(&WorkerInPath::clearCounters, _1));
162  }
163 
164  void
165  Path::setEarlyDeleteHelpers(std::map<const Worker*,EarlyDeleteHelper*> const& iWorkerToDeleter) {
166  //we use a temp so we can overset the size but then when moving to earlyDeleteHelpers we only
167  // have to use the space necessary
168  std::vector<EarlyDeleteHelper*> temp;
169  temp.reserve(iWorkerToDeleter.size());
170  for(unsigned int index=0; index !=size();++index) {
171  auto found = iWorkerToDeleter.find(getWorker(index));
172  if(found != iWorkerToDeleter.end()) {
173  temp.push_back(found->second);
174  found->second->addedToPath();
175  }
176  }
177  std::vector<EarlyDeleteHelper*> tempCorrectSize(temp.begin(),temp.end());
178  earlyDeleteHelpers_.swap(tempCorrectSize);
179  }
180 
181  void
183  for(auto helper: earlyDeleteHelpers_) {
184  helper->pathFinished(iEvent);
185  }
186  }
187 
188 }
std::string const & pathName() const
Definition: PathContext.h:37
void recordStatus(int nwrwue, bool isEvent)
Definition: Path.cc:140
void handleEarlyFinish(EventPrincipal const &)
Definition: Path.cc:182
static const std::string & codeToString(Code)
-----------— implementation details ---------------—
Definition: EDMException.cc:50
std::vector< EarlyDeleteHelper * > earlyDeleteHelpers_
Definition: Path.h:102
int timesFailed_
Definition: Path.h:91
std::vector< WorkerInPath > WorkersInPath
Definition: Path.h:44
reject
Definition: HLTenums.h:20
std::string const & moduleName() const
std::string const & category() const
Definition: Exception.cc:183
exception_actions::ActionCodes find(const std::string &category) const
int timesExcept_
Definition: Path.h:92
PathContext pathContext_
Definition: Path.h:104
size_type size() const
Definition: Path.h:74
actions
Definition: Schedule.cc:374
std::string const & moduleLabel() const
BranchType
Definition: BranchType.h:11
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
TrigResPtr trptr_
Definition: Path.h:97
int iEvent
Definition: GenABIO.cc:230
std::shared_ptr< HLTGlobalStatus > TrigResPtr
Definition: Path.h:46
accept
Definition: HLTenums.h:19
int bitpos_
Definition: Path.h:96
Definition: Path.h:40
void addAdditionalInfo(std::string const &info)
Definition: Exception.cc:235
areg
Definition: Schedule.cc:374
WorkersInPath workers_
Definition: Path.h:101
static void exceptionContext(cms::Exception &ex, bool isEvent, bool begin, BranchType branchType, ModuleDescription const &, std::string const &id, PathContext const &)
Definition: Path.cc:101
void updateCounters(bool succeed, bool isEvent)
Definition: Path.cc:147
void addContext(std::string const &context)
Definition: Exception.cc:227
bool handleWorkerFailure(cms::Exception &e, int nwrwue, bool isEvent, bool begin, BranchType branchType, ModuleDescription const &, std::string const &id)
Definition: Path.cc:57
void setEarlyDeleteHelpers(std::map< const Worker *, EarlyDeleteHelper * > const &)
Definition: Path.cc:165
ExceptionToActionTable const * act_table_
Definition: Path.h:99
State state_
Definition: Path.h:94
#define begin
Definition: vmac.h:30
Worker const * getWorker(size_type i) const
Definition: Path.h:79
int timesPassed_
Definition: Path.h:90
int timesRun_
Definition: Path.h:89
void clearCounters()
Definition: Path.cc:158
Path(int bitpos, std::string const &path_name, WorkersInPath const &workers, TrigResPtr trptr, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > reg, StreamContext const *streamContext, PathContext::PathType pathType)
Definition: Path.cc:12
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)