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