CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/FWCore/Framework/src/Path.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/Framework/src/Path.h"
00003 #include "FWCore/Framework/interface/Actions.h"
00004 #include "FWCore/Utilities/interface/Algorithms.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include <algorithm>
00008 #include "boost/bind.hpp"
00009 
00010 namespace edm {
00011   Path::Path(int bitpos, std::string const& path_name,
00012              WorkersInPath const& workers,
00013              TrigResPtr trptr,
00014              ActionTable const& actions,
00015              boost::shared_ptr<ActivityRegistry> areg,
00016              bool isEndPath):
00017     stopwatch_(),
00018     timesRun_(),
00019     timesPassed_(),
00020     timesFailed_(),
00021     timesExcept_(),
00022     state_(hlt::Ready),
00023     bitpos_(bitpos),
00024     name_(path_name),
00025     trptr_(trptr),
00026     actReg_(areg),
00027     act_table_(&actions),
00028     workers_(workers),
00029     isEndPath_(isEndPath) {
00030   }
00031   
00032   bool
00033   Path::handleWorkerFailure(cms::Exception const& e,
00034                             int nwrwue, bool isEvent) {
00035     bool should_continue = true;
00036 
00037     // there is no support as of yet for specific paths having
00038     // different exception behavior
00039     
00040     // If not processing an event, always rethrow.
00041     actions::ActionCodes action = (isEvent ? act_table_->find(e.rootCause()) : actions::Rethrow);
00042     assert (action != actions::FailModule);
00043     switch(action) {
00044       case actions::FailPath: {
00045           should_continue = false;
00046           LogWarning(e.category())
00047             << "Failing path " << name_
00048             << ", due to exception, message:\n"
00049             << e.what() << "\n";
00050           break;
00051       }
00052       default: {
00053           if (isEvent) ++timesExcept_;
00054           state_ = hlt::Exception;
00055           recordStatus(nwrwue, isEvent);
00056           if (action == actions::Rethrow) {
00057             std::string pNF = Exception::codeToString(errors::ProductNotFound);
00058             if (e.category() == pNF) {
00059               e << "If you wish to continue processing events after a " << pNF << " exception,\n" <<
00060               "add \"SkipEvent = cms.untracked.vstring('ProductNotFound')\" to the \"options\" PSet in the configuration.\n";
00061             }
00062           }
00063           e << "ProcessingStopped\n";
00064           e << "Exception going through path " << name_ << "\n";
00065           throw;
00066       }
00067     }
00068 
00069     return should_continue;
00070   }
00071 
00072   void
00073   Path::recordUnknownException(int nwrwue, bool isEvent) {
00074     LogError("PassingThrough")
00075       << "Exception passing through path " << name_ << "\n";
00076     if (isEvent) ++timesExcept_;
00077     state_ = hlt::Exception;
00078     recordStatus(nwrwue, isEvent);
00079   }
00080 
00081   void
00082   Path::recordStatus(int nwrwue, bool isEvent) {
00083     if(isEvent) {
00084       (*trptr_)[bitpos_]=HLTPathStatus(state_, nwrwue);    
00085     }
00086   }
00087 
00088   void
00089   Path::updateCounters(bool success, bool isEvent) {
00090     if (success) {
00091       if (isEvent) ++timesPassed_;
00092       state_ = hlt::Pass;
00093     } else {
00094       if(isEvent) ++timesFailed_;
00095       state_ = hlt::Fail;
00096     }
00097   }
00098 
00099   void
00100   Path::clearCounters() {
00101     timesRun_ = timesPassed_ = timesFailed_ = timesExcept_ = 0;
00102     for_all(workers_, boost::bind(&WorkerInPath::clearCounters, _1));
00103   }
00104 
00105   void
00106   Path::useStopwatch() {
00107     stopwatch_.reset(new RunStopwatch::StopwatchPointer::element_type);
00108     for(WorkersInPath::iterator it=workers_.begin(), itEnd = workers_.end();
00109         it != itEnd;
00110         ++it) {
00111       it->useStopwatch();
00112     }
00113   }
00114 
00115 
00116 }